@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.
@@ -14,7 +14,13 @@ export type VoiceSessionNotice = "network" | "not-capturing" | "nothing-heard" |
14
14
  /** H3: a barge-in stopped the assistant but no words followed (a cough, a door). */
15
15
  | "hands-free-nothing-heard"
16
16
  /** H3: hands-free gave up for this conversation; the tap-first path is in charge. */
17
- | "hands-free-fallback";
17
+ | "hands-free-fallback"
18
+ /**
19
+ * BOFF-8822 (operator decision D7 b): this turn's reply was refused by its
20
+ * audio output (`output-not-cleared`) and never heard; its text is in the
21
+ * transcript.
22
+ */
23
+ | "reply-not-heard";
18
24
  /**
19
25
  * A line the PANEL says in the voice conversation, outside any turn (BOFF-7803
20
26
  * FE9: the readback of a change that waits for its button).
@@ -3,245 +3,253 @@ import { planSubmitTimer as t, resolveVoiceGraceMs as n } from "../voice/handsFr
3
3
  import { readHandsFreeOverride as r, resolveHandsFreeEnabled as ee } from "../voice/handsfree/handsFreeSetting.js";
4
4
  import { silencePlaybackReference as te } from "../voice/handsfree/playbackReference.js";
5
5
  import { speechFeed as ne } from "../speech/speechFeed.js";
6
- import { INITIAL_SESSION as re, INTERRUPT_MAX_MS as ie, NOTHING_HEARD as ae, advanceHeardClock as oe, isCapturing as i, isSubmittable as se, planListeningHold as ce, planReplyConsumption as le, planVoiceAnnouncement as ue, shouldRecognise as de, spokenSoFar as a, voiceSessionReducer as fe } from "../voice/voiceSession.js";
7
- import { useHandsFreeInterrupt as pe } from "../voice/handsfree/useHandsFreeInterrupt.js";
8
- import { isTurnSuperseded as o } from "../voice/supersededTurns.js";
9
- import { captionChunks as me } from "../voice/speechPlayback.js";
10
- import { turnClockMs as s } from "../turnTimeline.js";
11
- import { useAssistantSpeech as he } from "./AssistantSpeechProvider.js";
12
- import { useCallback as c, useEffect as l, useLayoutEffect as ge, useMemo as _e, useReducer as ve, useRef as u, useState as d } from "react";
6
+ import { INITIAL_SESSION as re, INTERRUPT_MAX_MS as ie, NOTHING_HEARD as ae, advanceHeardClock as oe, isCapturing as se, isSubmittable as ce, planListeningHold as le, planReplyConsumption as ue, planVoiceAnnouncement as de, shouldRecognise as fe, spokenSoFar as i, voiceSessionReducer as pe } from "../voice/voiceSession.js";
7
+ import { useHandsFreeInterrupt as me } from "../voice/handsfree/useHandsFreeInterrupt.js";
8
+ import { isTurnSuperseded as a } from "../voice/supersededTurns.js";
9
+ import { captionChunks as he } from "../voice/speechPlayback.js";
10
+ import { turnClockMs as o } from "../turnTimeline.js";
11
+ import { useAssistantSpeech as ge } from "./AssistantSpeechProvider.js";
12
+ import { useCallback as s, useEffect as c, useLayoutEffect as _e, useMemo as ve, useReducer as ye, useRef as l, useState as u } from "react";
13
13
  //#region src/shared/assistant/ui/useVoiceSession.ts
14
- var ye = 4e3, be = 2500, xe = 5e3, Se = 12e3, Ce = "data:audio/wav;base64,UklGRiQAAABXQVZFZm10IBAAAAABAAEARKwAAIhYAQACABAAZGF0YQAAAAA=";
15
- function we({ onSubmit: we, latestReply: f, language: p, graceMs: Te, onSupersede: Ee, handsFreeInterrupt: De, handsFreeStreamNoticeAccepted: Oe, onAcceptHandsFreeStreamNotice: ke, onBargeIn: m }) {
16
- let h = n(Te), g = u(null), [_, v] = ve(c((e, t) => fe(e, t, g.current), []), re), y = he(), { setSessionSpeaking: b, setSessionMicOpen: x, speakingMessageId: S, stop: C } = y, w = u(y.toggle), T = y.toggle;
17
- ge(() => {
18
- w.current = T;
19
- }, [T]);
20
- let E = u(null), D = u({}), O = u(ae), k = u(null), A = u(!1), j = u(null), [M, N] = d(null), [P, F] = d(!1), [Ae, I] = d(!1), [L, R] = d(!1), z = u(_);
21
- z.current = _;
22
- let B = u([]), V = u(null), H = u(!1), U = c(() => {
23
- B.current = [], V.current = null, H.current = !1;
24
- }, []), W = c(() => {
14
+ var be = 4e3, xe = 2500, Se = 5e3, Ce = 12e3, we = "data:audio/wav;base64,UklGRiQAAABXQVZFZm10IBAAAAABAAEARKwAAIhYAQACABAAZGF0YQAAAAA=";
15
+ function Te({ onSubmit: Te, latestReply: d, language: f, graceMs: Ee, onSupersede: De, handsFreeInterrupt: Oe, handsFreeStreamNoticeAccepted: ke, onAcceptHandsFreeStreamNotice: Ae, onBargeIn: je }) {
16
+ let Me = n(Ee), p = l(null), [m, h] = ye(s((e, t) => pe(e, t, p.current), []), re), g = ge(), { setSessionSpeaking: _, setSessionMicOpen: v, speakingMessageId: y, stop: b } = g, x = l(g.toggle), S = g.toggle;
17
+ _e(() => {
18
+ x.current = S;
19
+ }, [S]);
20
+ let C = l(null), w = l({}), T = l(ae), E = l(null), D = l(!1), O = l(null), [k, A] = u(null), [j, M] = u(!1), [Ne, N] = u(!1), [P, F] = u(!1), I = l(m);
21
+ I.current = m;
22
+ let L = l([]), R = l(null), z = l(!1), B = s(() => {
23
+ L.current = [], R.current = null, z.current = !1;
24
+ }, []), V = s(() => {
25
25
  for (;;) {
26
- let e = B.current.shift();
26
+ let e = L.current.shift();
27
27
  if (!e) return !1;
28
28
  if (!(e.stillWanted && !e.stillWanted())) {
29
- V.current = e, g.current = g.current ? `${g.current} ${e.text}` : e.text;
29
+ R.current = e, p.current = p.current ? `${p.current} ${e.text}` : e.text;
30
30
  try {
31
- w.current(e.id, e.text, e.lang);
31
+ x.current(e.id, e.text, e.lang);
32
32
  } catch {
33
- V.current = null;
33
+ R.current = null;
34
34
  continue;
35
35
  }
36
36
  return !0;
37
37
  }
38
38
  }
39
- }, []), G = u(!1), je = c((e) => {
40
- let t = ce({
39
+ }, []), H = l(!1), Pe = s((e) => {
40
+ let t = le({
41
41
  requested: e,
42
- held: G.current,
43
- muted: z.current.muted
42
+ held: H.current,
43
+ muted: I.current.muted
44
44
  });
45
- G.current = t.held, t.mute !== null && v({
45
+ H.current = t.held, t.mute !== null && h({
46
46
  type: "mute",
47
47
  muted: t.mute
48
48
  });
49
- }, []), K = c((e) => {
50
- let t = ue(z.current);
51
- t !== "drop" && (V.current?.id === e.id || B.current.some((t) => t.id === e.id) || (B.current.push(e), t === "start" && !H.current && (H.current = !0, v({ type: "announce" }))));
52
- }, []), Me = c((e) => {
53
- if (z.current.phase !== "thinking") {
54
- K(e);
49
+ }, []), U = s((e) => {
50
+ let t = de(I.current);
51
+ t !== "drop" && (R.current?.id === e.id || L.current.some((t) => t.id === e.id) || (L.current.push(e), t === "start" && !z.current && (z.current = !0, h({ type: "announce" }))));
52
+ }, []), Fe = s((e) => {
53
+ if (I.current.phase !== "thinking") {
54
+ U(e);
55
55
  return;
56
56
  }
57
- B.current.push(e), H.current = !0, v({ type: "answered-locally" });
58
- }, [K]), Ne = u(f);
59
- Ne.current = f, l(() => {
60
- if (_.phase === "speaking") {
61
- let e = j.current;
62
- g.current = e && k.current === e.id && f?.id !== e.id ? e.text : f?.text ?? null;
57
+ L.current.push(e), z.current = !0, h({ type: "answered-locally" });
58
+ }, [U]), Ie = l(d);
59
+ Ie.current = d, c(() => {
60
+ if (m.phase === "speaking") {
61
+ let e = O.current;
62
+ p.current = e && E.current === e.id && d?.id !== e.id ? e.text : d?.text ?? null;
63
63
  return;
64
64
  }
65
- if (g.current === null) return;
65
+ if (p.current === null) return;
66
66
  let e = setTimeout(() => {
67
- g.current = null;
68
- }, be);
67
+ p.current = null;
68
+ }, xe);
69
69
  return () => clearTimeout(e);
70
- }, [_.phase, f]);
71
- let q = u(p);
72
- q.current = p;
73
- let J = c((e, t) => {
74
- v({
70
+ }, [m.phase, d]);
71
+ let W = l(f);
72
+ W.current = f;
73
+ let G = s((e, t) => {
74
+ h({
75
75
  type: "speech",
76
76
  transcript: e,
77
77
  final: t,
78
78
  at: Date.now(),
79
- language: q.current
79
+ language: W.current
80
80
  });
81
- }, []), Pe = c((e, t, n) => {
82
- v({
81
+ }, []), Le = s((e, t, n) => {
82
+ h({
83
83
  type: "speech",
84
84
  transcript: e,
85
85
  final: t,
86
86
  at: Date.now(),
87
- language: n ?? q.current,
87
+ language: n ?? W.current,
88
88
  gated: !0
89
89
  });
90
- }, []), Y = u(0), Fe = c(() => {
91
- U(), C(), Y.current = Date.now(), F(!0), v({ type: "interrupt" });
92
- }, [C, U]), X = e({
93
- onFinalize: c((e) => J(e, !0), [J]),
94
- language: p
95
- }), Ie = u(m);
96
- Ie.current = m;
97
- let Le = c(() => {
98
- U(), te(), C(), Y.current = Date.now(), F(!0), v({ type: "interrupt" }), Ie.current?.();
99
- }, [C, U]), Z = pe({
100
- enabled: ee(De, r()),
101
- phase: _.phase,
102
- muted: _.muted,
103
- language: p,
104
- streamNoticeAccepted: Oe ?? null,
105
- onAcceptStreamNotice: ke,
106
- onBargeIn: Le,
107
- onTranscript: Pe
108
- }), Re = Z.mode === "notice", Q = X.isListening || Z.suppressWebSpeech && Z.mode === "active";
109
- l(() => {
110
- X.interim && J(X.interim, !1);
111
- }, [X.interim, J]), l(() => {
112
- E.current && clearTimeout(E.current), I(!1), O.current = oe(O.current, _, s());
90
+ }, []), K = l(0), Re = s(() => {
91
+ B(), b(), K.current = Date.now(), M(!0), h({ type: "interrupt" });
92
+ }, [b, B]), q = e({
93
+ onFinalize: s((e) => G(e, !0), [G]),
94
+ language: f
95
+ }), ze = l(je);
96
+ ze.current = je;
97
+ let Be = s(() => {
98
+ B(), te(), b(), K.current = Date.now(), M(!0), h({ type: "interrupt" }), ze.current?.();
99
+ }, [b, B]), J = me({
100
+ enabled: ee(Oe, r()),
101
+ phase: m.phase,
102
+ muted: m.muted,
103
+ language: f,
104
+ streamNoticeAccepted: ke ?? null,
105
+ onAcceptStreamNotice: Ae,
106
+ onBargeIn: Be,
107
+ onTranscript: Le
108
+ }), Ve = J.mode === "notice", Y = q.isListening || J.suppressWebSpeech && J.mode === "active";
109
+ c(() => {
110
+ q.interim && G(q.interim, !1);
111
+ }, [q.interim, G]), c(() => {
112
+ C.current && clearTimeout(C.current), N(!1), T.current = oe(T.current, m, o());
113
113
  let e = t({
114
- phase: _.phase,
115
- muted: _.muted,
116
- spoken: a(_),
117
- holding: L,
118
- graceMs: h
114
+ phase: m.phase,
115
+ muted: m.muted,
116
+ spoken: i(m),
117
+ holding: P,
118
+ graceMs: Me
119
119
  });
120
120
  if (!e.arm) return;
121
- let n = setTimeout(() => I(!0), Math.min(800, e.delayMs)), r = s();
122
- return E.current = setTimeout(() => {
123
- D.current = {
124
- speechEnded: O.current.at ?? r,
121
+ let n = setTimeout(() => N(!0), Math.min(800, e.delayMs)), r = o();
122
+ return C.current = setTimeout(() => {
123
+ w.current = {
124
+ speechEnded: T.current.at ?? r,
125
125
  graceStarted: r,
126
- graceEnded: s()
127
- }, v({
126
+ graceEnded: o()
127
+ }, h({
128
128
  type: "silence",
129
129
  at: Date.now()
130
130
  });
131
131
  }, e.delayMs), () => {
132
- clearTimeout(n), E.current && clearTimeout(E.current);
132
+ clearTimeout(n), C.current && clearTimeout(C.current);
133
133
  };
134
134
  }, [
135
- _,
136
- L,
137
- h
138
- ]), l(() => {
139
- (_.phase !== "listening" || _.muted) && R(!1);
140
- }, [_.phase, _.muted]), l(() => {
141
- if (!P) return;
142
- let e = Date.now() - Y.current, t = Q ? Math.max(0, 500 - e) : Math.max(0, ie - e), n = setTimeout(() => F(!1), t);
135
+ m,
136
+ P,
137
+ Me
138
+ ]), c(() => {
139
+ (m.phase !== "listening" || m.muted) && F(!1);
140
+ }, [m.phase, m.muted]), c(() => {
141
+ if (!j) return;
142
+ let e = Date.now() - K.current, t = Y ? Math.max(0, 500 - e) : Math.max(0, ie - e), n = setTimeout(() => M(!1), t);
143
143
  return () => clearTimeout(n);
144
- }, [P, Q]);
145
- let ze = u("");
146
- _.phase === "listening" && (ze.current = a(_)), l(() => {
147
- if (_.phase !== "thinking") return;
148
- x(!1), U();
149
- let e = ze.current.trim();
150
- e && we(e, $.current ?? `vs-orphan-${Date.now().toString(36)}`, D.current, { correction: z.current.correcting }), D.current = {}, O.current = ae;
151
- }, [_.phase]), l(() => {
152
- let e = le(f?.id, _.phase, k.current, o(f?.id));
153
- e.claim && (k.current = f?.id ?? null, e.advance && f && v({
144
+ }, [j, Y]);
145
+ let He = l("");
146
+ m.phase === "listening" && (He.current = i(m)), c(() => {
147
+ if (m.phase !== "thinking") return;
148
+ v(!1), B();
149
+ let e = He.current.trim();
150
+ e && Te(e, Z.current ?? `vs-orphan-${Date.now().toString(36)}`, w.current, { correction: I.current.correcting }), w.current = {}, T.current = ae;
151
+ }, [m.phase]), c(() => {
152
+ let e = ue(d?.id, m.phase, E.current, a(d?.id));
153
+ e.claim && (E.current = d?.id ?? null, e.advance && d && h({
154
154
  type: "reply",
155
- text: f.text
155
+ text: d.text
156
156
  }));
157
- }, [f, _.phase]), l(() => {
158
- if (S === null || _.phase !== "thinking" || k.current === S) return;
159
- if (o(S)) {
160
- C();
157
+ }, [d, m.phase]), c(() => {
158
+ if (y === null || m.phase !== "thinking" || E.current === y) return;
159
+ if (a(y)) {
160
+ b();
161
161
  return;
162
162
  }
163
- let e = ne.peek(S);
164
- !e || e.channel !== "voice" || e.voiceSessionId === void 0 || e.voiceSessionId !== $.current || (k.current = S, j.current = {
165
- id: S,
163
+ let e = ne.peek(y);
164
+ !e || e.channel !== "voice" || e.voiceSessionId === void 0 || e.voiceSessionId !== Z.current || (E.current = y, O.current = {
165
+ id: y,
166
166
  text: e.text
167
- }, v({
167
+ }, h({
168
168
  type: "reply-audio-started",
169
- replyId: S
169
+ replyId: y
170
170
  }));
171
171
  }, [
172
- S,
173
- _.phase,
174
- C
175
- ]), l(() => {
176
- let e = S !== null;
177
- A.current && !e && (V.current = null, (z.current.phase !== "speaking" || !W()) && v({ type: "speech-ended" })), A.current = e;
178
- }, [S, W]), l(() => {
179
- _.phase !== "listening" && N((e) => e === "nothing-heard" ? null : e);
180
- }, [_.phase]), l(() => {
181
- if (_.phase !== "speaking" || S !== null) return;
172
+ y,
173
+ m.phase,
174
+ b
175
+ ]), c(() => {
176
+ let e = y !== null;
177
+ D.current && !e && (R.current = null, (I.current.phase !== "speaking" || !V()) && h({ type: "speech-ended" })), D.current = e;
178
+ }, [y, V]), c(() => {
179
+ m.phase !== "listening" && A((e) => e === "nothing-heard" ? null : e);
180
+ }, [m.phase]), c(() => {
181
+ if (m.phase !== "speaking" || y !== null) return;
182
182
  let e = setTimeout(() => {
183
- A.current || (U(), v({ type: "speech-ended" }));
184
- }, ye);
183
+ D.current || (B(), h({ type: "speech-ended" }));
184
+ }, be);
185
185
  return () => clearTimeout(e);
186
186
  }, [
187
- _.phase,
188
- S,
189
- U
187
+ m.phase,
188
+ y,
189
+ B
190
190
  ]);
191
- let Be = u(Ee);
192
- Be.current = Ee;
193
- let Ve = u(0);
194
- l(() => {
195
- let e = _.superseded;
196
- e !== Ve.current && (Ve.current = e, e !== 0 && (U(), C(), Be.current?.()));
191
+ let X = g.outputNotCleared;
192
+ c(() => {
193
+ if (X === null || E.current !== X.messageId) return;
194
+ let { phase: e } = I.current;
195
+ e === "idle" || e === "ended" || e === "thinking" || A("reply-not-heard");
196
+ }, [X]), c(() => {
197
+ m.phase === "listening" || m.phase === "thinking" || A((e) => e === "reply-not-heard" ? null : e);
198
+ }, [m.phase]);
199
+ let Ue = l(De);
200
+ Ue.current = De;
201
+ let We = l(0);
202
+ c(() => {
203
+ let e = m.superseded;
204
+ e !== We.current && (We.current = e, e !== 0 && (B(), b(), Ue.current?.()));
197
205
  }, [
198
- _.superseded,
199
- U,
200
- C
201
- ]), l(() => {
202
- x(i(_)), de(_) && !Z.suppressWebSpeech ? X.isActive || X.start("auto") : X.isActive && X.stop();
206
+ m.superseded,
207
+ B,
208
+ b
209
+ ]), c(() => {
210
+ v(se(m)), fe(m) && !J.suppressWebSpeech ? q.isActive || q.start("auto") : q.isActive && q.stop();
203
211
  }, [
204
- _,
205
- X,
206
- x,
207
- Z.suppressWebSpeech
208
- ]), l(() => {
209
- _.phase !== "speaking" || !H.current || (H.current = !1, W() || v({ type: "speech-ended" }));
210
- }, [_.phase, W]), l(() => {
211
- X.error === "not-allowed" || X.error === "audio-capture" ? v({
212
+ m,
213
+ q,
214
+ v,
215
+ J.suppressWebSpeech
216
+ ]), c(() => {
217
+ m.phase !== "speaking" || !z.current || (z.current = !1, V() || h({ type: "speech-ended" }));
218
+ }, [m.phase, V]), c(() => {
219
+ q.error === "not-allowed" || q.error === "audio-capture" ? h({
212
220
  type: "fail",
213
221
  error: "mic-denied"
214
- }) : X.error === "language-not-supported" ? v({
222
+ }) : q.error === "language-not-supported" ? h({
215
223
  type: "fail",
216
224
  error: "no-speech-support"
217
- }) : X.error === "network" ? N("network") : X.error === "unknown" && N("recognition-failed");
218
- }, [X.error]), l(() => {
219
- X.error !== null || !Q || N((e) => e === "network" || e === "recognition-failed" ? null : e);
220
- }, [X.error, Q]), l(() => {
221
- if (Q && N((e) => e === "not-capturing" ? null : e), !i(_) || Q || Re) return;
222
- let e = setTimeout(() => N("not-capturing"), xe);
225
+ }) : q.error === "network" ? A("network") : q.error === "unknown" && A("recognition-failed");
226
+ }, [q.error]), c(() => {
227
+ q.error !== null || !Y || A((e) => e === "network" || e === "recognition-failed" ? null : e);
228
+ }, [q.error, Y]), c(() => {
229
+ if (Y && A((e) => e === "not-capturing" ? null : e), !se(m) || Y || Ve) return;
230
+ let e = setTimeout(() => A("not-capturing"), Se);
223
231
  return () => clearTimeout(e);
224
232
  }, [
225
- _,
226
- Q,
227
- Re
228
- ]), l(() => {
229
- if (_.phase !== "listening" || _.muted || !Q || a(_) !== "") return;
230
- let e = setTimeout(() => N("nothing-heard"), Se);
233
+ m,
234
+ Y,
235
+ Ve
236
+ ]), c(() => {
237
+ if (m.phase !== "listening" || m.muted || !Y || i(m) !== "") return;
238
+ let e = setTimeout(() => A("nothing-heard"), Ce);
231
239
  return () => clearTimeout(e);
232
- }, [_, Q]), l(() => {
233
- a(_) !== "" && N(null);
234
- }, [_]);
235
- let $ = u(null), He = c(() => {
236
- if (F(!1), I(!1), R(!1), U(), G.current = !1, !X.isSupported) {
237
- v({
240
+ }, [m, Y]), c(() => {
241
+ i(m) !== "" && A(null);
242
+ }, [m]);
243
+ let Z = l(null), Ge = s(() => {
244
+ if (M(!1), N(!1), F(!1), B(), H.current = !1, !q.isSupported) {
245
+ h({
238
246
  type: "fail",
239
247
  error: "no-speech-support"
240
248
  });
241
249
  return;
242
250
  }
243
- if (y.isBlocked) {
244
- v({
251
+ if (g.isBlocked) {
252
+ h({
245
253
  type: "fail",
246
254
  error: "no-voice-support"
247
255
  });
@@ -256,102 +264,102 @@ function we({ onSubmit: we, latestReply: f, language: p, graceMs: Te, onSupersed
256
264
  } catch {}
257
265
  try {
258
266
  if (typeof window < "u" && typeof window.Audio == "function") {
259
- let e = new window.Audio(Ce);
267
+ let e = new window.Audio(we);
260
268
  e.volume = 0, e.play().catch(() => {});
261
269
  }
262
270
  } catch {}
263
- b(!0), N(null), k.current = Ne.current?.id ?? null, j.current = null, $.current = `vs-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`, v({ type: "start" });
271
+ _(!0), A(null), E.current = Ie.current?.id ?? null, O.current = null, Z.current = `vs-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`, h({ type: "start" });
264
272
  }, [
265
- X.isSupported,
266
- y.isBlocked,
267
- b,
268
- U
269
- ]), Ue = c(() => {
270
- F(!1), I(!1), R(!1), U(), G.current = !1, $.current = null, v({ type: "end" }), C(), b(!1);
273
+ q.isSupported,
274
+ g.isBlocked,
275
+ _,
276
+ B
277
+ ]), Q = s(() => {
278
+ M(!1), N(!1), F(!1), B(), H.current = !1, Z.current = null, h({ type: "end" }), b(), _(!1);
271
279
  }, [
272
- C,
273
280
  b,
274
- U
275
- ]), We = c((e) => $.current === e, []), Ge = c(() => {
276
- let e = z.current;
277
- e.phase !== "listening" || e.muted || R(!0);
278
- }, []), Ke = c(() => {
279
- R(!1);
280
- let e = z.current;
281
- if (e.phase !== "listening" || e.muted || !se(a(e))) return;
282
- let t = s();
283
- D.current = {
284
- speechEnded: O.current.at ?? t,
281
+ _,
282
+ B
283
+ ]), Ke = s((e) => Z.current === e, []), qe = s(() => {
284
+ let e = I.current;
285
+ e.phase !== "listening" || e.muted || F(!0);
286
+ }, []), Je = s(() => {
287
+ F(!1);
288
+ let e = I.current;
289
+ if (e.phase !== "listening" || e.muted || !ce(i(e))) return;
290
+ let t = o();
291
+ w.current = {
292
+ speechEnded: T.current.at ?? t,
285
293
  graceStarted: t,
286
294
  graceEnded: t
287
- }, v({
295
+ }, h({
288
296
  type: "silence",
289
297
  at: Date.now()
290
298
  });
291
- }, []), qe = c(() => {
292
- v({
299
+ }, []), Ye = s(() => {
300
+ h({
293
301
  type: "mute",
294
- muted: !z.current.muted
302
+ muted: !I.current.muted
295
303
  });
296
304
  }, []);
297
- l(() => () => {
298
- b(!1), x(!1);
299
- }, [b, x]);
300
- let Je = me(y.spokenChunks, _.phase, S);
301
- return _e(() => ({
302
- session: _,
303
- notice: M ?? (Z.fallbackReason !== null && Z.fallbackReason !== "notice-declined" ? "hands-free-fallback" : Z.nothingHeard ? "hands-free-nothing-heard" : null),
304
- spokenChunks: Je,
305
- capturing: Q,
306
- active: _.phase !== "idle" && (_.phase !== "ended" || _.error !== null),
307
- interrupting: P,
308
- awaitingEndpoint: Ae,
309
- holding: L,
310
- correcting: _.correcting,
305
+ c(() => () => {
306
+ _(!1), v(!1);
307
+ }, [_, v]);
308
+ let $ = he(g.spokenChunks, m.phase, y);
309
+ return ve(() => ({
310
+ session: m,
311
+ notice: k ?? (J.fallbackReason !== null && J.fallbackReason !== "notice-declined" ? "hands-free-fallback" : J.nothingHeard ? "hands-free-nothing-heard" : null),
312
+ spokenChunks: $,
313
+ capturing: Y,
314
+ active: m.phase !== "idle" && (m.phase !== "ended" || m.error !== null),
315
+ interrupting: j,
316
+ awaitingEndpoint: Ne,
317
+ holding: P,
318
+ correcting: m.correcting,
311
319
  handsFree: {
312
- mode: Z.mode,
313
- nothingHeard: Z.nothingHeard,
314
- transportKind: Z.transportKind,
315
- fallbackReason: Z.fallbackReason,
316
- privacyNotice: Z.privacyNotice
320
+ mode: J.mode,
321
+ nothingHeard: J.nothingHeard,
322
+ transportKind: J.transportKind,
323
+ fallbackReason: J.fallbackReason,
324
+ privacyNotice: J.privacyNotice
317
325
  },
318
- available: X.isSupported && !y.isBlocked,
319
- start: He,
320
- end: Ue,
321
- isCurrentSession: We,
322
- toggleMute: qe,
323
- interrupt: Fe,
324
- letMeFinish: Ge,
325
- imDone: Ke,
326
- announce: K,
327
- holdListening: je,
328
- answerLocally: Me
326
+ available: q.isSupported && !g.isBlocked,
327
+ start: Ge,
328
+ end: Q,
329
+ isCurrentSession: Ke,
330
+ toggleMute: Ye,
331
+ interrupt: Re,
332
+ letMeFinish: qe,
333
+ imDone: Je,
334
+ announce: U,
335
+ holdListening: Pe,
336
+ answerLocally: Fe
329
337
  }), [
330
- _,
331
- M,
338
+ m,
339
+ k,
340
+ j,
341
+ Ne,
332
342
  P,
333
- Ae,
334
- L,
335
- Q,
336
- Z.mode,
337
- Z.nothingHeard,
338
- Z.transportKind,
339
- Z.fallbackReason,
340
- Z.privacyNotice,
341
- X.isSupported,
342
- y.isBlocked,
343
- Je,
344
- He,
345
- Ue,
346
- We,
347
- qe,
348
- Fe,
343
+ Y,
344
+ J.mode,
345
+ J.nothingHeard,
346
+ J.transportKind,
347
+ J.fallbackReason,
348
+ J.privacyNotice,
349
+ q.isSupported,
350
+ g.isBlocked,
351
+ $,
349
352
  Ge,
353
+ Q,
350
354
  Ke,
351
- K,
352
- je,
353
- Me
355
+ Ye,
356
+ Re,
357
+ qe,
358
+ Je,
359
+ U,
360
+ Pe,
361
+ Fe
354
362
  ]);
355
363
  }
356
364
  //#endregion
357
- export { we as useVoiceSession };
365
+ export { Te as useVoiceSession };