@burdenoff/microfe-healthybowl 2026.828.2 → 2026.829.2

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.
@@ -2,9 +2,10 @@ import { useAssistantStore as e } from "../../store/assistantStore.js";
2
2
  import { useTr as t } from "../../shared/hooks/useTr.js";
3
3
  import { checkAssistantAiCredits as n, createAssistantSandbox as r, createAssistantSession as i, extendAssistantSandboxTTL as a, findExistingSandbox as o, getAssistantArtifacts as s, getAssistantMessages as c, getAssistantSession as l, reportAssistantAiTokenUsage as u, sendAssistantPromptAsync as d, waitForAssistantServiceReady as f, waitForSandboxReady as p } from "../../services/assistantApi.js";
4
4
  import { gatherPageContext as m } from "../../utils/pageContext.js";
5
- import { isTurnInFlight as h } from "../../utils/assistantTurnState.js";
6
- import { getOrganizationId as g, getWorkspaceId as ee } from "../../utils/assistantContext.js";
7
- import { buildPromptParts as te, buildPromptWithAttachments as ne, countInlineImageCandidates as re, countInlinedImageParts as ie, toMessageAttachment as _ } from "../../utils/assistantAttachments.js";
5
+ import { languageDisplayName as h } from "../../utils/speechVoices.js";
6
+ import { isTurnInFlight as g } from "../../utils/assistantTurnState.js";
7
+ import { getOrganizationId as _, getWorkspaceId as ee } from "../../utils/assistantContext.js";
8
+ import { buildPromptParts as te, buildPromptWithAttachments as ne, countInlineImageCandidates as re, countInlinedImageParts as ie, toMessageAttachment as ae } from "../../utils/assistantAttachments.js";
8
9
  import { AssistantMessageList as v } from "./AssistantMessageList.js";
9
10
  import { AssistantApiCallsConsentDialog as y } from "./AssistantApiCallsConsentDialog.js";
10
11
  import { ASSISTANT_MODES as b } from "../../types/assistant.js";
@@ -12,46 +13,47 @@ import { AssistantEmptyState as x } from "./AssistantEmptyState.js";
12
13
  import { AssistantComposer as S } from "./composer/AssistantComposer.js";
13
14
  import { useAssistantApiAccess as C } from "../../hooks/useAssistantApiAccess.js";
14
15
  import { isQuotaExhaustedError as w } from "../../utils/quotaUtils.js";
15
- import { dispatchAssistantQuotaExhausted as T, notifyAiCreditsUpdated as ae } from "../../utils/aiCredits.js";
16
- import { buildPromptForMode as oe } from "../../utils/assistantPrompt.js";
17
- import { isMultimodalBodyRejection as se, isRecoverableAssistantError as ce } from "../../utils/assistantTransportErrors.js";
18
- import { useCallback as E, useEffect as D, useMemo as le, useRef as O, useState as ue } from "react";
19
- import { jsx as k, jsxs as de } from "react/jsx-runtime";
20
- import { useGatewayClient as fe } from "@burdenoff/fe-libs/shared/graphql";
21
- import { useAuthToken as pe } from "@burdenoff/fe-libs/shared/providers/shell";
22
- import { getAssistantMedia as A } from "@burdenoff/fe-libs/shared/assistant";
16
+ import { dispatchAssistantQuotaExhausted as oe, notifyAiCreditsUpdated as se } from "../../utils/aiCredits.js";
17
+ import { buildPromptForMode as ce } from "../../utils/assistantPrompt.js";
18
+ import { isMultimodalBodyRejection as le, isRecoverableAssistantError as ue } from "../../utils/assistantTransportErrors.js";
19
+ import { useCallback as T, useEffect as de, useMemo as fe, useRef as E, useState as pe } from "react";
20
+ import { useI18n as me } from "@burdenoff/fe-libs/shared/providers/shell/I18nProvider";
21
+ import { jsx as D, jsxs as he } from "react/jsx-runtime";
22
+ import { useGatewayClient as ge } from "@burdenoff/fe-libs/shared/graphql";
23
+ import { useAuthToken as _e } from "@burdenoff/fe-libs/shared/providers/shell";
24
+ import { getAssistantMedia as O } from "@burdenoff/fe-libs/shared/assistant";
23
25
  //#region src/components/assistant/AssistantChatArea.tsx
24
- var me = {
26
+ var ve = {
25
27
  general: 18e4,
26
28
  assistant: 18e4,
27
29
  "api-calls": 18e4,
28
30
  "vibe-plugins": 6e5
29
- }, he = 18e4;
30
- function ge() {
31
+ }, ye = 18e4;
32
+ function be() {
31
33
  return `${Date.now()}-${Math.random().toString(36).slice(2, 9)}`;
32
34
  }
33
- function _e(e) {
35
+ function xe(e) {
34
36
  return e.replace(/(Authorization\s*:\s*Bearer\s+)[^\s\n]+/gi, "$1[REDACTED]").replace(/(X-Workspace-Authorization\s*:\s*Bearer\s+)[^\s\n]+/gi, "$1[REDACTED]").replace(/\beyJ[A-Za-z0-9_-]+\.[A-Za-z0-9._-]+\.[A-Za-z0-9._-]+\b/g, "[REDACTED_JWT]").replace(/\bsk-ant-[A-Za-z0-9-]+\b/g, "[REDACTED_API_KEY]");
35
37
  }
36
- function j(e) {
38
+ function k(e) {
37
39
  return e.info?.time?.created ?? 0;
38
40
  }
39
- function M(e) {
41
+ function A(e) {
40
42
  return (e ?? []).filter((e) => e.type === "text" && typeof e.text == "string").map((e) => e.text?.trim() ?? "").filter(Boolean).join("\n");
41
43
  }
42
- function N(e) {
44
+ function j(e) {
43
45
  return (e ?? []).filter((e) => e.type === "tool" && e.tool).map((e) => {
44
46
  let t = e.state?.status ?? "running", n = e.tool ?? "tool";
45
47
  return t === "completed" ? `Completed: ${n}` : t === "failed" ? `Failed: ${n}` : `Running: ${n}`;
46
48
  });
47
49
  }
48
- function ve(e, t) {
49
- let n = e.filter((e) => e.info?.role === "assistant" && j(e) > t).sort((e, t) => j(e) - j(t));
50
+ function Se(e, t) {
51
+ let n = e.filter((e) => e.info?.role === "assistant" && k(e) > t).sort((e, t) => k(e) - k(t));
50
52
  if (n.length === 0) return {
51
53
  content: "Thinking...",
52
54
  done: !1
53
55
  };
54
- let r = n[n.length - 1], i = M(r.parts), a = A(r.parts), o = N(r.parts);
56
+ let r = n[n.length - 1], i = A(r.parts), a = O(r.parts), o = j(r.parts);
55
57
  return {
56
58
  content: [
57
59
  i,
@@ -62,7 +64,7 @@ function ve(e, t) {
62
64
  tokens: r.info?.tokens
63
65
  };
64
66
  }
65
- function ye(e) {
67
+ function Ce(e) {
66
68
  switch (e) {
67
69
  case "provisioning": return "Starting assistant environment...";
68
70
  case "connecting": return "Connecting to assistant...";
@@ -70,85 +72,85 @@ function ye(e) {
70
72
  default: return "";
71
73
  }
72
74
  }
73
- var P = () => {
74
- let A = t(), M = fe("workspace"), { getAccessToken: N, getWorkspaceToken: P, userId: be } = pe(), { conversations: xe, activeConversationId: F, mode: I, processingByConversationId: Se, setMode: L, setConversationMode: R, setActiveConversation: Ce, createConversation: z, addMessage: B, updateMessage: V, patchMessage: H, setConversationProcessing: U, clearConversationProcessing: we, setBackendSessionId: W, clearBackendSessionId: G, setSandbox: K, clearSandbox: Te, acknowledgeApiCalls: Ee } = e(), q = xe.find((e) => e.id === F)?.messages ?? [], J = F ? Se[F] : void 0, De = h(J?.status), Oe = De ? J?.messageId ?? null : null, ke = J?.status === "error" ? J.messageId : null, { canUseApiCalls: Y, loading: Ae } = C(g()), je = le(() => b.filter((e) => !e.requiresAdmin || Y), [Y]), [Me, Ne] = ue(null), Pe = O({}), Fe = O(/* @__PURE__ */ new Set());
75
- D(() => {
76
- if (Ae) return;
77
- let e = b.find((e) => e.id === I);
78
- (!e || e.requiresAdmin && !Y) && I !== "assistant" && L("assistant");
75
+ var M = () => {
76
+ let O = t(), A = ge("workspace"), { getAccessToken: j, getWorkspaceToken: M, userId: we } = _e(), { locale: Te } = me(), Ee = fe(() => h(Te, "en"), [Te]), { conversations: De, activeConversationId: N, mode: P, processingByConversationId: Oe, setMode: F, setConversationMode: I, setActiveConversation: ke, createConversation: L, addMessage: R, updateMessage: z, patchMessage: B, setConversationProcessing: V, clearConversationProcessing: Ae, setBackendSessionId: H, clearBackendSessionId: U, setSandbox: W, clearSandbox: je, acknowledgeApiCalls: Me } = e(), G = De.find((e) => e.id === N)?.messages ?? [], K = N ? Oe[N] : void 0, Ne = g(K?.status), Pe = Ne ? K?.messageId ?? null : null, Fe = K?.status === "error" ? K.messageId : null, { canUseApiCalls: q, loading: Ie } = C(_()), Le = fe(() => b.filter((e) => !e.requiresAdmin || q), [q]), [J, Y] = pe(null), Re = E({}), X = E(/* @__PURE__ */ new Set());
77
+ de(() => {
78
+ if (Ie) return;
79
+ let e = b.find((e) => e.id === P);
80
+ (!e || e.requiresAdmin && !q) && P !== "assistant" && F("assistant");
79
81
  }, [
80
- I,
81
- Y,
82
- Ae,
83
- L
82
+ P,
83
+ q,
84
+ Ie,
85
+ F
84
86
  ]);
85
- let X = E((e, t, n, r) => {
86
- U(e, n, t, null), r ? V(e, t, r) : V(e, t, ye(n));
87
- }, [U, V]), Ie = E(async (t, n, a, s, c) => {
87
+ let Z = T((e, t, n, r) => {
88
+ V(e, n, t, null), r ? z(e, t, r) : z(e, t, Ce(n));
89
+ }, [V, z]), ze = T(async (t, n, a, s, c) => {
88
90
  let u = e.getState().sandboxesByMode[a]?.sandboxId ?? null, d = async (e) => {
89
91
  try {
90
- return await p(M, e, s, c, 3e5, (e) => X(t, n, "provisioning", e)), await f(M, e, s, c, 9e4, (e) => X(t, n, "connecting", e)), !0;
92
+ return await p(A, e, s, c, 3e5, (e) => Z(t, n, "provisioning", e)), await f(A, e, s, c, 9e4, (e) => Z(t, n, "connecting", e)), !0;
91
93
  } catch {
92
94
  return !1;
93
95
  }
94
96
  };
95
- if (u && (K(a, u, "provisioning"), X(t, n, "provisioning", "Reusing assistant environment..."), await d(u) || (K(a, null, "provisioning"), u = null)), !u) {
96
- X(t, n, "provisioning", "Looking for existing environment...");
97
- let e = await o(M, s, a, c);
98
- e && (K(a, e, "provisioning"), X(t, n, "provisioning", "Reusing assistant environment..."), await d(e) ? u = e : K(a, null, "provisioning"));
97
+ if (u && (W(a, u, "provisioning"), Z(t, n, "provisioning", "Reusing assistant environment..."), await d(u) || (W(a, null, "provisioning"), u = null)), !u) {
98
+ Z(t, n, "provisioning", "Looking for existing environment...");
99
+ let e = await o(A, s, a, c);
100
+ e && (W(a, e, "provisioning"), Z(t, n, "provisioning", "Reusing assistant environment..."), await d(e) ? u = e : W(a, null, "provisioning"));
99
101
  }
100
102
  if (!u) {
101
- if (a === "api-calls" && !N()) throw Error("API Calls mode requires an authenticated session. Please sign in again.");
102
- X(t, n, "provisioning", "Starting assistant environment..."), K(a, null, "provisioning"), u = await r(M, a, s, c), K(a, u, "provisioning"), await p(M, u, s, c, 3e5, (e) => X(t, n, "provisioning", e)), await f(M, u, s, c, 9e4, (e) => X(t, n, "connecting", e));
103
+ if (a === "api-calls" && !j()) throw Error("API Calls mode requires an authenticated session. Please sign in again.");
104
+ Z(t, n, "provisioning", "Starting assistant environment..."), W(a, null, "provisioning"), u = await r(A, a, s, c), W(a, u, "provisioning"), await p(A, u, s, c, 3e5, (e) => Z(t, n, "provisioning", e)), await f(A, u, s, c, 9e4, (e) => Z(t, n, "connecting", e));
103
105
  }
104
- K(a, u, "running");
106
+ W(a, u, "running");
105
107
  let m = e.getState().conversations.find((e) => e.id === t)?.backendSessionId ?? null;
106
108
  if (m) try {
107
- let e = await l(M, u, s, m, c);
109
+ let e = await l(A, u, s, m, c);
108
110
  if (e.mode !== a) throw Error(`Session mode mismatch: expected ${a}, received ${e.mode}`);
109
111
  } catch {
110
- G(t), m = null;
112
+ U(t), m = null;
111
113
  }
112
- return m || (X(t, n, "connecting", "Preparing session..."), m = (await i(M, u, s, a, c)).sessionId, W(t, m)), {
114
+ return m || (Z(t, n, "connecting", "Preparing session..."), m = (await i(A, u, s, a, c)).sessionId, H(t, m)), {
113
115
  sandboxId: u,
114
116
  sessionId: m
115
117
  };
116
118
  }, [
117
- M,
118
- G,
119
- N,
119
+ A,
120
+ U,
121
+ j,
122
+ H,
120
123
  W,
121
- K,
122
- X
123
- ]), Z = E(async (t, r = []) => {
124
- let i = e.getState(), o = i.activeConversationId ?? F;
125
- if (o && (h(i.processingByConversationId[o]?.status) || Fe.current.has(o))) return;
126
- let l = i.mode, f = F, p = f ? e.getState().conversations.find((e) => e.id === f) : void 0;
127
- if (f ? p && p.mode !== l && (p.messages.length > 0 || p.backendSessionId) ? f = z(void 0, l) : p && p.mode !== l && R(f, l) : f = z(void 0, l), !f) return;
128
- Pe.current[f] = r;
129
- let v = ee(), y = {
130
- accessToken: N(),
131
- workspaceToken: P(),
132
- userId: be,
133
- organizationId: g()
134
- }, b = {
135
- id: ge(),
124
+ Z
125
+ ]), Q = T(async (t, r = []) => {
126
+ let i = e.getState(), o = i.activeConversationId ?? N;
127
+ if (o && (g(i.processingByConversationId[o]?.status) || X.current.has(o))) return;
128
+ let l = i.mode, f = N, p = f ? e.getState().conversations.find((e) => e.id === f) : void 0;
129
+ if (f ? p && p.mode !== l && (p.messages.length > 0 || p.backendSessionId) ? f = L(void 0, l) : p && p.mode !== l && I(f, l) : f = L(void 0, l), !f) return;
130
+ Re.current[f] = r;
131
+ let h = ee(), v = {
132
+ accessToken: j(),
133
+ workspaceToken: M(),
134
+ userId: we,
135
+ organizationId: _()
136
+ }, y = {
137
+ id: be(),
136
138
  role: "user",
137
139
  content: t,
138
140
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
139
- metadata: r.length ? { attachments: r.map(_) } : void 0
141
+ metadata: r.length ? { attachments: r.map(ae) } : void 0
140
142
  };
141
- B(f, b);
142
- let x = ge();
143
- B(f, {
144
- id: x,
143
+ R(f, y);
144
+ let b = be();
145
+ R(f, {
146
+ id: b,
145
147
  role: "assistant",
146
148
  content: "",
147
149
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
148
- }), U(f, "provisioning", x, null);
149
- let S = (e, t, n, r) => {
150
- H(f, x, {
151
- content: _e(e),
150
+ }), V(f, "provisioning", b, null);
151
+ let x = (e, t, n, r) => {
152
+ B(f, b, {
153
+ content: xe(e),
152
154
  metadata: t?.length || n || r ? {
153
155
  artifacts: t,
154
156
  mode: l,
@@ -156,167 +158,168 @@ var P = () => {
156
158
  sandboxId: r
157
159
  } : void 0
158
160
  });
159
- }, C = async (e = 1) => {
161
+ }, S = async (e = 1) => {
160
162
  let i = !1;
161
163
  try {
162
- await n(M, v, y);
164
+ await n(A, h, v);
163
165
  } catch (e) {
164
166
  if (w(e)) {
165
- T("ai-credits"), S("You've run out of AI credits for this billing cycle. Upgrade your plan to keep chatting."), U(f, "error", x, null);
167
+ oe("ai-credits"), x("You've run out of AI credits for this billing cycle. Upgrade your plan to keep chatting."), V(f, "error", b, null);
166
168
  return;
167
169
  }
168
170
  console.warn("[assistant] AI-credit pre-flight check failed with a non-quota error; proceeding — gateway @usage(checkQuota) still enforces the real budget downstream", e);
169
171
  }
170
172
  try {
171
- let { sandboxId: e, sessionId: n } = await Ie(f, x, l, v, y), o = (await c(M, e, v, n, y, 50).catch(() => [])).reduce((e, t) => Math.max(e, j(t)), 0);
172
- X(f, x, "streaming", "Thinking...");
173
- let p = oe(l, ne(t, r)), h = te(p, r), g = ie(h), ee = g > 0, _ = m();
174
- i = re(r) > g;
173
+ let { sandboxId: e, sessionId: n } = await ze(f, b, l, h, v), o = (await c(A, e, h, n, v, 50).catch(() => [])).reduce((e, t) => Math.max(e, k(t)), 0);
174
+ Z(f, b, "streaming", "Thinking...");
175
+ let p = ce(l, ne(t, r), Ee), g = te(p, r), _ = ie(g), ee = _ > 0, ae = m();
176
+ i = re(r) > _;
175
177
  try {
176
- await d(M, e, v, n, p, l, _, y, h);
178
+ await d(A, e, h, n, p, l, ae, v, g);
177
179
  } catch (t) {
178
- if (!h || !se(t)) throw t;
179
- await d(M, e, v, n, p, l, _, y, void 0), i ||= ee;
180
+ if (!g || !le(t)) throw t;
181
+ await d(A, e, h, n, p, l, ae, v, void 0), i ||= ee;
180
182
  }
181
- let b = ve([], o), C = Date.now() + (me[l] ?? he), w = Date.now();
182
- for (; Date.now() < C && (b = ve(await c(M, e, v, n, y, 50), o), H(f, x, { content: _e(b.content) }), !b.done);) Date.now() - w > 3e4 && (await a(M, e, v, 600, y).catch(() => void 0), w = Date.now()), await new Promise((e) => setTimeout(e, 1500));
183
- if (!b.done && l !== "vibe-plugins") throw Error("Assistant response timed out while streaming progress");
184
- let T = l === "vibe-plugins" ? await s(M, e, v, n, y).catch(() => []) : void 0;
185
- if (b.done || (b = {
186
- ...b,
187
- content: `${b.content}\n\n_Still building in the background — any artifacts below will finish shortly. Re-open this conversation to pick up the completed plugin._`
188
- }), i && (b = {
189
- ...b,
190
- content: `${b.content}\n\n${A("healthybowl.assistant.attachments.imagesNotSent", "_Your photo was too large to include with this message, so the answer above is from the text and the file link only. Try a smaller or more tightly cropped photo._")}`
191
- }), S(b.content, T, n, e), b.tokens) {
192
- H(f, x, { tokens: b.tokens });
183
+ let y = Se([], o), S = Date.now() + (ve[l] ?? ye), C = Date.now();
184
+ for (; Date.now() < S && (y = Se(await c(A, e, h, n, v, 50), o), B(f, b, { content: xe(y.content) }), !y.done);) Date.now() - C > 3e4 && (await a(A, e, h, 600, v).catch(() => void 0), C = Date.now()), await new Promise((e) => setTimeout(e, 1500));
185
+ if (!y.done && l !== "vibe-plugins") throw Error("Assistant response timed out while streaming progress");
186
+ let w = l === "vibe-plugins" ? await s(A, e, h, n, v).catch(() => []) : void 0;
187
+ if (y.done || (y = {
188
+ ...y,
189
+ content: `${y.content}\n\n_Still building in the background — any artifacts below will finish shortly. Re-open this conversation to pick up the completed plugin._`
190
+ }), i && (y = {
191
+ ...y,
192
+ content: `${y.content}\n\n${O("healthybowl.assistant.attachments.imagesNotSent", "_Your photo was too large to include with this message, so the answer above is from the text and the file link only. Try a smaller or more tightly cropped photo._")}`
193
+ }), x(y.content, w, n, e), y.tokens) {
194
+ B(f, b, { tokens: y.tokens });
193
195
  try {
194
- await u(M, v, n, b.tokens, y), ae();
196
+ await u(A, h, n, y.tokens, v), se();
195
197
  } catch {}
196
198
  }
197
- U(f, "complete", x, null);
199
+ V(f, "complete", b, null);
198
200
  } catch (t) {
199
- if (e === 1 && ce(t)) return G(f), Te(l), C(2);
201
+ if (e === 1 && ue(t)) return U(f), je(l), S(2);
200
202
  throw t;
201
203
  }
202
- }, E = f;
203
- Fe.current.add(E);
204
+ }, C = f;
205
+ X.current.add(C);
204
206
  try {
205
- if (!v) throw Error("Assistant backend is unavailable without an active workspace context.");
206
- await C();
207
+ if (!h) throw Error("Assistant backend is unavailable without an active workspace context.");
208
+ await S();
207
209
  } catch (e) {
208
210
  if (w(e)) {
209
- T("sandbox"), S("You've reached your sandbox limit on the current plan. Upgrade to start the AI assistant."), U(f, "error", x, null);
211
+ oe("sandbox"), x("You've reached your sandbox limit on the current plan. Upgrade to start the AI assistant."), V(f, "error", b, null);
210
212
  return;
211
213
  }
212
214
  let t = e instanceof Error ? e.message : "Something went wrong";
213
- U(f, "error", x, t), V(f, x, `Sorry, an error occurred: ${t}. Please try again.`);
215
+ V(f, "error", b, t), z(f, b, `Sorry, an error occurred: ${t}. Please try again.`);
214
216
  } finally {
215
- Fe.current.delete(E);
217
+ X.current.delete(C);
216
218
  }
217
219
  }, [
218
- F,
219
- B,
220
- M,
221
- G,
222
- Te,
223
- xe,
224
- z,
225
- Ie,
226
220
  N,
227
- P,
228
- H,
229
- W,
230
221
  R,
231
- U,
232
222
  A,
233
- X,
223
+ U,
224
+ je,
225
+ De,
226
+ L,
227
+ ze,
228
+ j,
229
+ M,
230
+ B,
231
+ Ee,
232
+ H,
233
+ I,
234
234
  V,
235
- be
236
- ]), Le = E((e) => {
237
- Z(e);
238
- }, [Z]), Re = E(() => {
239
- let e = [...q].reverse().find((e) => e.role === "user"), t = F ? Pe.current[F] ?? [] : [];
240
- e && Z(e.content, t);
241
- }, [
242
- q,
235
+ O,
243
236
  Z,
244
- F
245
- ]), Q = O(Z);
246
- D(() => {
247
- Q.current = Z;
248
- }, [Z]), D(() => {
237
+ z,
238
+ we
239
+ ]), Be = T((e) => {
240
+ Q(e);
241
+ }, [Q]), Ve = T(() => {
242
+ let e = [...G].reverse().find((e) => e.role === "user"), t = N ? Re.current[N] ?? [] : [];
243
+ e && Q(e.content, t);
244
+ }, [
245
+ G,
246
+ Q,
247
+ N
248
+ ]), He = E(Q);
249
+ de(() => {
250
+ He.current = Q;
251
+ }, [Q]), de(() => {
249
252
  let t = e.getState().consumePendingPrompt();
250
- return t && Q.current(t), e.subscribe((t, n) => {
253
+ return t && He.current(t), e.subscribe((t, n) => {
251
254
  if (t.pendingPrompt && t.pendingPrompt !== n.pendingPrompt) {
252
255
  let t = e.getState().consumePendingPrompt();
253
- t && Q.current(t);
256
+ t && He.current(t);
254
257
  }
255
258
  });
256
259
  }, []);
257
- let $ = E((t) => {
258
- let n = F ? e.getState().conversations.find((e) => e.id === F) : void 0;
260
+ let $ = T((t) => {
261
+ let n = N ? e.getState().conversations.find((e) => e.id === N) : void 0;
259
262
  if (n && (n.messages.length > 0 || n.backendSessionId)) {
260
263
  if (n.mode !== t) {
261
264
  let n = e.getState().conversations.find((n) => n.mode === t && n.messages.length === 0 && !n.backendSessionId && !e.getState().processingByConversationId[n.id]);
262
- n ? Ce(n.id) : z(void 0, t);
265
+ n ? ke(n.id) : L(void 0, t);
263
266
  }
264
- } else F && R(F, t);
265
- L(t);
267
+ } else N && I(N, t);
268
+ F(t);
266
269
  }, [
267
- F,
268
- z,
269
- Ce,
270
- R,
271
- L
272
- ]), ze = E((t) => {
270
+ N,
271
+ L,
272
+ ke,
273
+ I,
274
+ F
275
+ ]), Ue = T((t) => {
273
276
  if (b.find((e) => e.id === t)?.writeCapable && !e.getState().apiCallsAcknowledged) {
274
- Ne(t);
277
+ Y(t);
275
278
  return;
276
279
  }
277
280
  $(t);
278
- }, [$]), Be = E(() => {
279
- let e = Me;
280
- Ne(null), Ee(), e && $(e);
281
+ }, [$]), We = T(() => {
282
+ let e = J;
283
+ Y(null), Me(), e && $(e);
281
284
  }, [
285
+ J,
282
286
  Me,
283
- Ee,
284
287
  $
285
- ]), Ve = E(() => {
286
- Ne(null);
288
+ ]), Ge = T(() => {
289
+ Y(null);
287
290
  }, []);
288
- return /* @__PURE__ */ de("div", {
291
+ return /* @__PURE__ */ he("div", {
289
292
  className: "flex flex-1 flex-col overflow-hidden",
290
293
  children: [
291
- q.length === 0 ? /* @__PURE__ */ k(x, {
292
- mode: I,
293
- onSuggestionClick: Le
294
- }) : /* @__PURE__ */ k("div", {
294
+ G.length === 0 ? /* @__PURE__ */ D(x, {
295
+ mode: P,
296
+ onSuggestionClick: Be
297
+ }) : /* @__PURE__ */ D("div", {
295
298
  className: "flex min-h-0 flex-1 flex-col",
296
- children: /* @__PURE__ */ k(v, {
297
- messages: q,
298
- streamingMessageId: Oe,
299
- failedMessageId: ke,
300
- onRetry: Re
299
+ children: /* @__PURE__ */ D(v, {
300
+ messages: G,
301
+ streamingMessageId: Pe,
302
+ failedMessageId: Fe,
303
+ onRetry: Ve
301
304
  })
302
305
  }),
303
- /* @__PURE__ */ k(S, {
304
- onSend: (e, t) => void Z(e, t),
305
- disabled: De,
306
- placeholder: I === "api-calls" ? A("healthybowl.assistant.chatArea.placeholderActions", "What would you like me to do?") : A("healthybowl.assistant.chatArea.placeholderGeneral", "Ask HealthyBowl anything…"),
307
- mode: I,
308
- availableModes: je,
309
- onModeChange: ze
306
+ /* @__PURE__ */ D(S, {
307
+ onSend: (e, t) => void Q(e, t),
308
+ disabled: Ne,
309
+ placeholder: P === "api-calls" ? O("healthybowl.assistant.chatArea.placeholderActions", "What would you like me to do?") : O("healthybowl.assistant.chatArea.placeholderGeneral", "Ask HealthyBowl anything…"),
310
+ mode: P,
311
+ availableModes: Le,
312
+ onModeChange: Ue
310
313
  }),
311
- /* @__PURE__ */ k(y, {
312
- open: Me !== null,
313
- onConfirm: Be,
314
- onCancel: Ve
314
+ /* @__PURE__ */ D(y, {
315
+ open: J !== null,
316
+ onConfirm: We,
317
+ onCancel: Ge
315
318
  })
316
319
  ]
317
320
  });
318
321
  };
319
322
  //#endregion
320
- export { P as AssistantChatArea };
323
+ export { M as AssistantChatArea };
321
324
 
322
325
  //# sourceMappingURL=AssistantChatArea.js.map