@useago/sdk 1.13.3 → 1.14.0

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/CHANGELOG.md +6 -0
  2. package/dist/angular.cjs +1 -1
  3. package/dist/angular.d.cts +7 -0
  4. package/dist/angular.d.ts +7 -0
  5. package/dist/angular.js +1 -1
  6. package/dist/{createConversationSession-DrmOaZdO.js → createConversationSession-CybQdMpK.js} +1 -1
  7. package/dist/{createConversationSession-Digvn0GQ.cjs → createConversationSession-jwSXhTLe.cjs} +1 -1
  8. package/dist/{createFormCollector-D_5SDuk9.cjs → createFormCollector-B_hSKcLd.cjs} +1 -1
  9. package/dist/{createFormCollector-D6_N8wYq.js → createFormCollector-DJjms78E.js} +1 -1
  10. package/dist/devtools.d.cts +7 -0
  11. package/dist/devtools.d.ts +7 -0
  12. package/dist/index.cjs +1 -1
  13. package/dist/index.d.cts +7 -0
  14. package/dist/index.d.ts +7 -0
  15. package/dist/index.js +6 -6
  16. package/dist/react.cjs +4 -4
  17. package/dist/react.d.cts +8 -1
  18. package/dist/react.d.ts +8 -1
  19. package/dist/react.js +901 -912
  20. package/dist/speechToText-BB25_zVM.cjs +7 -0
  21. package/dist/speechToText-BLvTis4S.js +1496 -0
  22. package/dist/testing.d.cts +7 -0
  23. package/dist/testing.d.ts +7 -0
  24. package/dist/{types-D1ZrqVhr.js → types-C39MJUE3.js} +284 -259
  25. package/dist/{types-DNr6XEwI.cjs → types-PGXnhAmQ.cjs} +7 -7
  26. package/dist/vue.cjs +1 -1
  27. package/dist/vue.d.cts +7 -0
  28. package/dist/vue.d.ts +7 -0
  29. package/dist/vue.js +1 -1
  30. package/dist/widget.cjs +5 -6
  31. package/dist/widget.d.cts +12 -4
  32. package/dist/widget.d.ts +12 -4
  33. package/dist/widget.js +1868 -1841
  34. package/llms-full.txt +23 -3
  35. package/package.json +1 -1
  36. package/dist/speechToText-BV7qxqPF.js +0 -704
  37. package/dist/speechToText-ZciRyyJE.cjs +0 -1
package/dist/react.js CHANGED
@@ -1,23 +1,23 @@
1
- import { a as De, c as ze, g as Le, n as Pe, o as Be, s as He, t as Oe } from "./types-D1ZrqVhr.js";
2
- import { n as Q } from "./errors-BLfjXnLB.js";
3
- import { t as $e } from "./autoContinue-Cb4_iEbO.js";
4
- import { n as jt, r as he, t as xe } from "./createFormCollector-D6_N8wYq.js";
5
- import { t as Kt } from "./createMockClient-YoYr3pQr.js";
6
- import { C as je, dt as qe, n as Ke, t as Jt, ut as Ue } from "./speechToText-BV7qxqPF.js";
7
- import Ge, { createContext as Je, forwardRef as Ve, useCallback as T, useContext as be, useEffect as E, useId as Xe, useImperativeHandle as Ye, useLayoutEffect as Ze, useMemo as $, useRef as W, useState as M, useSyncExternalStore as ye } from "react";
8
- import { Fragment as ve, jsx as a, jsxs as F } from "react/jsx-runtime";
9
- import Qe from "react-markdown";
10
- import et from "remark-gfm";
11
- function tt(e) {
12
- const [r, t] = M(!1), o = W(null), n = $(() => {
13
- if (o.current && (o.current.destroy(), o.current = null), !e) return null;
14
- const s = new Pe(e);
15
- return o.current = s, s;
1
+ import { a as Oe, c as $e, g as je, n as qe, o as Ue, s as Ke, t as Ge } from "./types-C39MJUE3.js";
2
+ import { n as ae } from "./errors-BLfjXnLB.js";
3
+ import { t as Je } from "./autoContinue-Cb4_iEbO.js";
4
+ import { n as Yt, r as Ce, t as Se } from "./createFormCollector-DJjms78E.js";
5
+ import { t as Qt } from "./createMockClient-YoYr3pQr.js";
6
+ import { C as Ve, dt as Xe, ft as Ye, mt as Ze, n as Qe, pt as re, t as nn, ut as et } from "./speechToText-BLvTis4S.js";
7
+ import tt, { createContext as nt, forwardRef as ot, useCallback as R, useContext as Ae, useEffect as _, useId as rt, useImperativeHandle as at, useLayoutEffect as st, useMemo as U, useRef as D, useState as E, useSyncExternalStore as ce } from "react";
8
+ import { Fragment as Ne, jsx as a, jsxs as W } from "react/jsx-runtime";
9
+ import it from "react-markdown";
10
+ import lt from "remark-gfm";
11
+ function ct(e) {
12
+ const [o, t] = E(!1), r = D(null), n = U(() => {
13
+ if (r.current && (r.current.destroy(), r.current = null), !e) return null;
14
+ const s = new qe(e);
15
+ return r.current = s, s;
16
16
  }, [e?.baseUrl, e?.widgetId]);
17
- return E(() => (n && o.current === null && (o.current = n, n.reviveAfterDestroy()), t(!0), () => {
18
- o.current?.destroy(), o.current = null;
19
- }), [n]), E(() => {
20
- o.current && e && o.current.updateConfig({
17
+ return _(() => (n && r.current === null && (r.current = n, n.reviveAfterDestroy()), t(!0), () => {
18
+ r.current?.destroy(), r.current = null;
19
+ }), [n]), _(() => {
20
+ r.current && e && r.current.updateConfig({
21
21
  agent: e.agent,
22
22
  defaultAgentId: e.defaultAgentId,
23
23
  permission: e.permission,
@@ -40,54 +40,60 @@ function tt(e) {
40
40
  e?.warnOnEmptyReply
41
41
  ]), {
42
42
  client: n,
43
- isReady: r
43
+ isReady: o
44
44
  };
45
45
  }
46
- var ne = Je(null), Qt = ({ children: e, client: r, tools: t, helpers: o, pageContext: n, ...s }) => {
47
- const { client: l } = tt(r ? null : s), i = r || l;
48
- return E(() => {
46
+ var de = nt(null), ln = ({ children: e, client: o, tools: t, helpers: r, pageContext: n, ...s }) => {
47
+ const { client: c } = ct(o ? null : s), i = o || c;
48
+ return _(() => {
49
49
  if (!(!t || t.length === 0)) {
50
- for (const g of t) i.register(g);
50
+ for (const u of t) i.register(u);
51
51
  return () => {
52
- for (const g of t) i.unregisterFunction(g.name);
52
+ for (const u of t) i.unregisterFunction(u.name);
53
53
  };
54
54
  }
55
- }, [i, t]), E(() => {
56
- if (!o) return;
57
- const g = [];
55
+ }, [i, t]), _(() => {
56
+ if (!r) return;
57
+ const u = [];
58
58
  return import("./functions-tzyOZNp6.js").then((d) => d.n).then((d) => {
59
- for (const [f, w] of Object.entries(o)) {
60
- const m = d[f];
61
- if (!m) {
62
- console.warn(`[AGO] Unknown helper: "${f}"`);
59
+ for (const [p, m] of Object.entries(r)) {
60
+ const x = d[p];
61
+ if (!x) {
62
+ console.warn(`[AGO] Unknown helper: "${p}"`);
63
63
  continue;
64
64
  }
65
- const u = w === !0 ? m : {
66
- ...m,
67
- handler: w
65
+ const f = m === !0 ? x : {
66
+ ...x,
67
+ handler: m
68
68
  };
69
- i.register(u), g.push(u.name);
69
+ i.register(f), u.push(f.name);
70
70
  }
71
71
  }), () => {
72
- for (const d of g) i.unregisterFunction(d);
72
+ for (const d of u) i.unregisterFunction(d);
73
73
  };
74
- }, [i, o]), E(() => {
74
+ }, [i, r]), _(() => {
75
75
  n === "auto" && i.enableAutoPageContext();
76
- }, [i, n]), /* @__PURE__ */ a(ne.Provider, {
76
+ }, [i, n]), /* @__PURE__ */ a(de.Provider, {
77
77
  value: i,
78
78
  children: e
79
79
  });
80
80
  };
81
- function U() {
82
- const e = be(ne);
81
+ function V() {
82
+ const e = Ae(de);
83
83
  if (!e) throw new Error('useAgoClient must be used within an <AgoProvider>. Wrap your component tree with <AgoProvider baseUrl="...">.');
84
84
  return e;
85
85
  }
86
- function O() {
87
- return be(ne);
86
+ function $() {
87
+ return Ae(de);
88
+ }
89
+ function Q(e) {
90
+ const o = $(), t = e ?? o, r = R((s) => (t?.on("config:changed", s), () => {
91
+ t?.off("config:changed", s);
92
+ }), [t]), n = () => t?.getLanguage?.() ?? null;
93
+ return Ye(ce(r, n, n));
88
94
  }
89
- var nt = /* @__PURE__ */ new Set(["awaiting-approval"]);
90
- function we(e) {
95
+ var dt = /* @__PURE__ */ new Set(["awaiting-approval"]);
96
+ function _e(e) {
91
97
  switch (e) {
92
98
  case "progress_indicator":
93
99
  return "progress";
@@ -101,22 +107,22 @@ function we(e) {
101
107
  return "status";
102
108
  }
103
109
  }
104
- function rt(e) {
105
- return e.type === "client_function" ? e.functionName === "navigateToPage" ? "navigation" : "action" : we(e.type);
110
+ function ut(e) {
111
+ return e.type === "client_function" ? e.functionName === "navigateToPage" ? "navigation" : "action" : _e(e.type);
106
112
  }
107
- function de(e, r) {
113
+ function be(e, o) {
108
114
  const t = (e ?? "").toLowerCase();
109
- return t.includes("reject") ? "rejected" : t.includes("error") || t.includes("fail") ? "error" : t.includes("done") || t.includes("complet") ? "done" : (t.includes("waiting") || t.includes("pending")) && (r === "confirmation" || r === "form") ? "awaiting-approval" : "running";
115
+ return t.includes("reject") ? "rejected" : t.includes("error") || t.includes("fail") ? "error" : t.includes("done") || t.includes("complet") ? "done" : (t.includes("waiting") || t.includes("pending")) && (o === "confirmation" || o === "form") ? "awaiting-approval" : "running";
110
116
  }
111
- function ue(e) {
112
- return typeof e != "string" || !e ? "page" : e.replace(/[-_]+/g, " ").replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/\b\w/g, (r) => r.toUpperCase()).trim();
117
+ function ye(e) {
118
+ return typeof e != "string" || !e ? "page" : e.replace(/[-_]+/g, " ").replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/\b\w/g, (o) => o.toUpperCase()).trim();
113
119
  }
114
- function ot(e) {
120
+ function pt(e) {
115
121
  switch (e.kind) {
116
122
  case "navigation":
117
- return `Navigating to ${ue(e.arguments?.page)}`;
123
+ return `Navigating to ${ye(e.arguments?.page)}`;
118
124
  case "action":
119
- return e.functionName === "setPageState" ? "Updating the page" : e.functionName === "openFilteredConversations" ? "Opening conversations" : e.toolDisplayName || e.message || ue(e.functionName) || "Working";
125
+ return e.functionName === "setPageState" ? "Updating the page" : e.functionName === "openFilteredConversations" ? "Opening conversations" : e.toolDisplayName || e.message || ye(e.functionName) || "Working";
120
126
  case "progress":
121
127
  return e.message || "Working";
122
128
  case "reasoning":
@@ -129,281 +135,281 @@ function ot(e) {
129
135
  return e.message || e.toolDisplayName || e.toolName || "Working";
130
136
  }
131
137
  }
132
- function at(e = {}) {
133
- const { includeReasoning: r = !1, labelFor: t } = e, o = O(), n = e.client || o;
134
- if (!n) throw new Q("useAgoActivity requires an AgoClient. Either pass it as options.client or wrap your app in <AgoProvider>.", "provider_missing_client");
135
- const [s, l] = M([]), i = W(/* @__PURE__ */ new Set()), g = W(void 0), d = W(t);
138
+ function ft(e = {}) {
139
+ const { includeReasoning: o = !1, labelFor: t } = e, r = $(), n = e.client || r;
140
+ if (!n) throw new ae("useAgoActivity requires an AgoClient. Either pass it as options.client or wrap your app in <AgoProvider>.", "provider_missing_client");
141
+ const [s, c] = E([]), i = D(/* @__PURE__ */ new Set()), u = D(void 0), d = D(t);
136
142
  d.current = t;
137
- const f = T((p, k) => {
138
- l((x) => {
139
- const R = x.findIndex((b) => b.id === p), _ = {
140
- ...R >= 0 ? x[R] : {
141
- id: p,
143
+ const p = R((l, h) => {
144
+ c((b) => {
145
+ const I = b.findIndex((g) => g.id === l), N = {
146
+ ...I >= 0 ? b[I] : {
147
+ id: l,
142
148
  kind: "status",
143
149
  label: "",
144
150
  status: "running",
145
151
  requiresApproval: !1,
146
152
  createdAt: /* @__PURE__ */ new Date()
147
153
  },
148
- ...k
154
+ ...h
149
155
  };
150
- return _.label = d.current?.(_) ?? ot(_), R >= 0 ? [
151
- ...x.slice(0, R),
152
- _,
153
- ...x.slice(R + 1)
154
- ] : [...x, _];
156
+ return N.label = d.current?.(N) ?? pt(N), I >= 0 ? [
157
+ ...b.slice(0, I),
158
+ N,
159
+ ...b.slice(I + 1)
160
+ ] : [...b, N];
155
161
  });
156
162
  }, []);
157
- E(() => {
158
- const p = (h) => {
159
- g.current = h.messageId;
160
- }, k = (h) => {
161
- const D = we(h.type);
162
- D === "reasoning" && !r || f(h.id, {
163
- kind: D,
164
- status: de(h.status, D),
165
- messageId: g.current,
166
- toolName: h.toolName,
167
- toolDisplayName: h.toolDisplayName,
168
- message: h.message,
169
- data: h.data,
170
- formSchema: h.formSchema,
171
- requiresApproval: D === "confirmation" || D === "form"
163
+ _(() => {
164
+ const l = (C) => {
165
+ u.current = C.messageId;
166
+ }, h = (C) => {
167
+ const L = _e(C.type);
168
+ L === "reasoning" && !o || p(C.id, {
169
+ kind: L,
170
+ status: be(C.status, L),
171
+ messageId: u.current,
172
+ toolName: C.toolName,
173
+ toolDisplayName: C.toolDisplayName,
174
+ message: C.message,
175
+ data: C.data,
176
+ formSchema: C.formSchema,
177
+ requiresApproval: L === "confirmation" || L === "form"
172
178
  });
173
- }, x = (h) => {
174
- h.invocationId && f(h.invocationId, {
175
- kind: h.functionName === "navigateToPage" ? "navigation" : "action",
179
+ }, b = (C) => {
180
+ C.invocationId && p(C.invocationId, {
181
+ kind: C.functionName === "navigateToPage" ? "navigation" : "action",
176
182
  status: "running",
177
- messageId: g.current,
178
- functionName: h.functionName,
179
- arguments: h.arguments
183
+ messageId: u.current,
184
+ functionName: C.functionName,
185
+ arguments: C.arguments
180
186
  });
181
- }, R = (h) => {
182
- h.invocationId && f(h.invocationId, {
183
- kind: h.functionName === "navigateToPage" ? "navigation" : "action",
187
+ }, I = (C) => {
188
+ C.invocationId && p(C.invocationId, {
189
+ kind: C.functionName === "navigateToPage" ? "navigation" : "action",
184
190
  status: "awaiting-approval",
185
- messageId: g.current,
186
- functionName: h.functionName,
187
- arguments: h.arguments,
191
+ messageId: u.current,
192
+ functionName: C.functionName,
193
+ arguments: C.arguments,
188
194
  requiresApproval: !0
189
195
  });
190
- }, _ = (h) => {
191
- if (!h.invocationId) return;
192
- const D = h.result, c = typeof h.result == "object" && D !== null && D.approved === !1 && D.reason === "user_rejected";
193
- f(h.invocationId, {
194
- status: h.error ? "error" : c ? "rejected" : "done",
196
+ }, N = (C) => {
197
+ if (!C.invocationId) return;
198
+ const L = C.result, F = typeof C.result == "object" && L !== null && L.approved === !1 && L.reason === "user_rejected";
199
+ p(C.invocationId, {
200
+ status: C.error ? "error" : F ? "rejected" : "done",
195
201
  requiresApproval: !1
196
202
  });
197
- }, b = (h) => {
198
- for (const D of h.messages ?? [])
199
- if (D.role === "assistant")
200
- for (const c of D.toolCalls ?? []) {
201
- const S = rt(c);
202
- S === "reasoning" && !r || /waiting/i.test(c.status ?? "") || f(c.id, {
203
- kind: S,
204
- status: de(c.status, S),
205
- messageId: D.id,
206
- toolName: c.toolName,
207
- toolDisplayName: c.toolDisplayName,
208
- functionName: c.functionName,
209
- arguments: c.arguments,
210
- message: c.message,
211
- data: c.data,
212
- formSchema: c.formSchema,
213
- requiresApproval: S === "confirmation" || S === "form"
203
+ }, g = (C) => {
204
+ for (const L of C.messages ?? [])
205
+ if (L.role === "assistant")
206
+ for (const F of L.toolCalls ?? []) {
207
+ const M = ut(F);
208
+ M === "reasoning" && !o || /waiting/i.test(F.status ?? "") || p(F.id, {
209
+ kind: M,
210
+ status: be(F.status, M),
211
+ messageId: L.id,
212
+ toolName: F.toolName,
213
+ toolDisplayName: F.toolDisplayName,
214
+ functionName: F.functionName,
215
+ arguments: F.arguments,
216
+ message: F.message,
217
+ data: F.data,
218
+ formSchema: F.formSchema,
219
+ requiresApproval: M === "confirmation" || M === "form"
214
220
  });
215
221
  }
216
- }, C = (h) => {
217
- l((D) => D.map((c) => c.status === "running" || c.status === "awaiting-approval" ? {
218
- ...c,
219
- status: h
220
- } : c));
221
- }, A = () => C("done"), N = () => C("error");
222
- return n.on("message:start", p), n.on("toolCall:received", k), n.on("function:invoke", x), n.on("function:awaiting-approval", R), n.on("function:result", _), n.on("conversation:loaded", b), n.on("message:complete", A), n.on("message:error", N), () => {
223
- n.off("message:start", p), n.off("toolCall:received", k), n.off("function:invoke", x), n.off("function:awaiting-approval", R), n.off("function:result", _), n.off("conversation:loaded", b), n.off("message:complete", A), n.off("message:error", N);
222
+ }, k = (C) => {
223
+ c((L) => L.map((F) => F.status === "running" || F.status === "awaiting-approval" ? {
224
+ ...F,
225
+ status: C
226
+ } : F));
227
+ }, A = () => k("done"), S = () => k("error");
228
+ return n.on("message:start", l), n.on("toolCall:received", h), n.on("function:invoke", b), n.on("function:awaiting-approval", I), n.on("function:result", N), n.on("conversation:loaded", g), n.on("message:complete", A), n.on("message:error", S), () => {
229
+ n.off("message:start", l), n.off("toolCall:received", h), n.off("function:invoke", b), n.off("function:awaiting-approval", I), n.off("function:result", N), n.off("conversation:loaded", g), n.off("message:complete", A), n.off("message:error", S);
224
230
  };
225
231
  }, [
226
232
  n,
227
- r,
228
- f
233
+ o,
234
+ p
229
235
  ]);
230
- const w = T(async (p) => {
231
- const k = s.find((x) => x.id === p);
232
- !k || k.status !== "awaiting-approval" || i.current.has(p) || k.kind !== "form" && (i.current.add(p), f(p, {
236
+ const m = R(async (l) => {
237
+ const h = s.find((b) => b.id === l);
238
+ !h || h.status !== "awaiting-approval" || i.current.has(l) || h.kind !== "form" && (i.current.add(l), p(l, {
233
239
  status: "running",
234
240
  requiresApproval: !1
235
- }), k.functionName ? await n.approveFunction(p) : await n.confirmToolCall(p));
241
+ }), h.functionName ? await n.approveFunction(l) : await n.confirmToolCall(l));
236
242
  }, [
237
243
  n,
238
244
  s,
239
- f
240
- ]), m = T(async (p) => {
241
- const k = s.find((x) => x.id === p);
242
- !k || k.status !== "awaiting-approval" || i.current.has(p) || (i.current.add(p), f(p, {
245
+ p
246
+ ]), x = R(async (l) => {
247
+ const h = s.find((b) => b.id === l);
248
+ !h || h.status !== "awaiting-approval" || i.current.has(l) || (i.current.add(l), p(l, {
243
249
  status: "rejected",
244
250
  requiresApproval: !1
245
- }), k.functionName ? await n.rejectFunction(p) : await n.rejectToolCall(p));
251
+ }), h.functionName ? await n.rejectFunction(l) : await n.rejectToolCall(l));
246
252
  }, [
247
253
  n,
248
254
  s,
249
- f
250
- ]), u = T(async (p, k) => {
251
- f(p, {
255
+ p
256
+ ]), f = R(async (l, h) => {
257
+ p(l, {
252
258
  status: "running",
253
259
  requiresApproval: !1
254
- }), await n.submitToolCallForm(p, k), f(p, { status: "done" });
255
- }, [n, f]), y = T(() => {
256
- i.current.clear(), l([]);
260
+ }), await n.submitToolCallForm(l, h), p(l, { status: "done" });
261
+ }, [n, p]), v = R(() => {
262
+ i.current.clear(), c([]);
257
263
  }, []);
258
264
  return {
259
265
  items: s,
260
266
  latest: s.length > 0 ? s[s.length - 1] : void 0,
261
- isAwaitingApproval: s.some((p) => nt.has(p.status)),
262
- approve: w,
263
- reject: m,
264
- submitForm: u,
265
- clear: y
267
+ isAwaitingApproval: s.some((l) => dt.has(l.status)),
268
+ approve: m,
269
+ reject: x,
270
+ submitForm: f,
271
+ clear: v
266
272
  };
267
273
  }
268
- function ke({ client: e, conversationId: r } = {}) {
269
- const t = O(), o = e || t;
270
- if (!o) throw new Error("useMessages requires an AgoClient. Either pass it as options.client or wrap your app in <AgoProvider>.");
271
- const [n, s] = M([]), [l, i] = M(r), [g, d] = M(!1), [f, w] = M(null);
272
- E(() => {
273
- r && r !== l && (i(r), m(r));
274
- }, [r]);
275
- const m = async (u) => {
274
+ function Re({ client: e, conversationId: o } = {}) {
275
+ const t = $(), r = e || t;
276
+ if (!r) throw new Error("useMessages requires an AgoClient. Either pass it as options.client or wrap your app in <AgoProvider>.");
277
+ const [n, s] = E([]), [c, i] = E(o), [u, d] = E(!1), [p, m] = E(null);
278
+ _(() => {
279
+ o && o !== c && (i(o), x(o));
280
+ }, [o]);
281
+ const x = async (f) => {
276
282
  try {
277
- s((await o.getMessages(u)).filter((y) => !y.hidden));
278
- } catch (y) {
279
- w(y instanceof Error ? y : /* @__PURE__ */ new Error("Failed to load messages"));
283
+ s((await r.getMessages(f)).filter((v) => !v.hidden));
284
+ } catch (v) {
285
+ m(v instanceof Error ? v : /* @__PURE__ */ new Error("Failed to load messages"));
280
286
  }
281
287
  };
282
- return E(() => {
283
- const u = (b) => b === "IN_PROGRESS" || b === "WAITING_CLIENT", y = (b) => {
284
- l || i(b.conversationId), d(!0), s((C) => {
285
- const A = C.findIndex((N) => N.id === b.messageId);
286
- return A >= 0 ? C.map((N, h) => h === A ? {
287
- ...N,
288
+ return _(() => {
289
+ const f = (g) => g === "IN_PROGRESS" || g === "WAITING_CLIENT", v = (g) => {
290
+ c || i(g.conversationId), d(!0), s((k) => {
291
+ const A = k.findIndex((S) => S.id === g.messageId);
292
+ return A >= 0 ? k.map((S, C) => C === A ? {
293
+ ...S,
288
294
  status: "IN_PROGRESS"
289
- } : N) : C.some((N) => N.role === "assistant" && u(N.status)) ? C : [...C, {
290
- id: b.messageId,
291
- conversationId: b.conversationId,
295
+ } : S) : k.some((S) => S.role === "assistant" && f(S.status)) ? k : [...k, {
296
+ id: g.messageId,
297
+ conversationId: g.conversationId,
292
298
  content: "",
293
299
  role: "assistant",
294
300
  status: "IN_PROGRESS",
295
301
  createdAt: /* @__PURE__ */ new Date()
296
302
  }];
297
303
  });
298
- }, p = (b) => {
299
- s((C) => {
300
- const A = C.findIndex((N) => N.id === b.messageId);
301
- return A < 0 ? C : C.map((N, h) => h === A ? {
302
- ...N,
303
- content: N.content + b.content
304
- } : N);
304
+ }, l = (g) => {
305
+ s((k) => {
306
+ const A = k.findIndex((S) => S.id === g.messageId);
307
+ return A < 0 ? k : k.map((S, C) => C === A ? {
308
+ ...S,
309
+ content: S.content + g.content
310
+ } : S);
305
311
  });
306
- }, k = (b) => {
307
- s((C) => {
312
+ }, h = (g) => {
313
+ s((k) => {
308
314
  let A = -1;
309
- for (let N = C.length - 1; N >= 0; N--) if (C[N].role === "assistant" && u(C[N].status)) {
310
- A = N;
315
+ for (let S = k.length - 1; S >= 0; S--) if (k[S].role === "assistant" && f(k[S].status)) {
316
+ A = S;
311
317
  break;
312
318
  }
313
- return A < 0 ? C : [
314
- ...C.slice(0, A),
319
+ return A < 0 ? k : [
320
+ ...k.slice(0, A),
315
321
  {
316
- ...C[A],
317
- ...b
322
+ ...k[A],
323
+ ...g
318
324
  },
319
- ...C.slice(A + 1)
325
+ ...k.slice(A + 1)
320
326
  ];
321
327
  });
322
- }, x = (b) => {
323
- s((C) => {
324
- const A = C.findIndex((N) => N.id === b.id);
328
+ }, b = (g) => {
329
+ s((k) => {
330
+ const A = k.findIndex((S) => S.id === g.id);
325
331
  return A >= 0 ? [
326
- ...C.slice(0, A),
327
- b,
328
- ...C.slice(A + 1)
329
- ] : [...C, b];
332
+ ...k.slice(0, A),
333
+ g,
334
+ ...k.slice(A + 1)
335
+ ] : [...k, g];
330
336
  }), d(!1);
331
- }, R = (b) => {
332
- w(new Error(b.error)), d(!1);
333
- }, _ = () => {
334
- s((b) => {
335
- let C = -1;
336
- for (let A = b.length - 1; A >= 0; A--) if (b[A].role === "assistant" && u(b[A].status)) {
337
- C = A;
337
+ }, I = (g) => {
338
+ m(new Error(g.error)), d(!1);
339
+ }, N = () => {
340
+ s((g) => {
341
+ let k = -1;
342
+ for (let A = g.length - 1; A >= 0; A--) if (g[A].role === "assistant" && f(g[A].status)) {
343
+ k = A;
338
344
  break;
339
345
  }
340
- return C < 0 ? b : b[C].content ? b.map((A, N) => N === C ? {
346
+ return k < 0 ? g : g[k].content ? g.map((A, S) => S === k ? {
341
347
  ...A,
342
348
  status: "CANCELED"
343
- } : A) : b.filter((A, N) => N !== C);
349
+ } : A) : g.filter((A, S) => S !== k);
344
350
  }), d(!1);
345
351
  };
346
- return o.on("message:start", y), o.on("message:chunk", p), o.on("message:answer-complete", k), o.on("message:complete", x), o.on("message:error", R), o.on("message:stopped", _), () => {
347
- o.off("message:start", y), o.off("message:chunk", p), o.off("message:answer-complete", k), o.off("message:complete", x), o.off("message:error", R), o.off("message:stopped", _);
352
+ return r.on("message:start", v), r.on("message:chunk", l), r.on("message:answer-complete", h), r.on("message:complete", b), r.on("message:error", I), r.on("message:stopped", N), () => {
353
+ r.off("message:start", v), r.off("message:chunk", l), r.off("message:answer-complete", h), r.off("message:complete", b), r.off("message:error", I), r.off("message:stopped", N);
348
354
  };
349
- }, [o, l]), {
355
+ }, [r, c]), {
350
356
  messages: n,
351
- isLoading: g,
352
- error: f,
353
- sendMessage: T(async (u, y) => {
354
- d(!0), w(null);
355
- const p = {
357
+ isLoading: u,
358
+ error: p,
359
+ sendMessage: R(async (f, v) => {
360
+ d(!0), m(null);
361
+ const l = {
356
362
  id: `temp-${Date.now()}`,
357
- conversationId: l || "",
358
- content: u,
363
+ conversationId: c || "",
364
+ content: f,
359
365
  role: "user",
360
366
  status: "DONE",
361
- attachments: y && y.length > 0 ? De(y) : void 0,
367
+ attachments: v && v.length > 0 ? Oe(v) : void 0,
362
368
  createdAt: /* @__PURE__ */ new Date()
363
- }, k = {
369
+ }, h = {
364
370
  id: `temp-assistant-${Date.now()}`,
365
- conversationId: l || "",
371
+ conversationId: c || "",
366
372
  content: "",
367
373
  role: "assistant",
368
374
  status: "IN_PROGRESS",
369
375
  createdAt: /* @__PURE__ */ new Date()
370
376
  };
371
- s((x) => [
372
- ...x,
373
- p,
374
- k
377
+ s((b) => [
378
+ ...b,
379
+ l,
380
+ h
375
381
  ]);
376
382
  try {
377
- const x = await o.sendMessage(u, {
378
- conversationId: l,
379
- files: y
383
+ const b = await r.sendMessage(f, {
384
+ conversationId: c,
385
+ files: v
380
386
  });
381
- return x.conversationId && !l && i(x.conversationId), s((R) => {
382
- const _ = R.filter((C) => !C.id.startsWith("temp-")), b = {
383
- ...p,
384
- id: p.id.replace("temp-", "user-"),
385
- conversationId: x.conversationId
387
+ return b.conversationId && !c && i(b.conversationId), s((I) => {
388
+ const N = I.filter((k) => !k.id.startsWith("temp-")), g = {
389
+ ...l,
390
+ id: l.id.replace("temp-", "user-"),
391
+ conversationId: b.conversationId
386
392
  };
387
- return _.some((C) => C.id === x.id) ? [..._, b].sort((C, A) => new Date(C.createdAt).getTime() - new Date(A.createdAt).getTime()) : [
388
- ..._,
389
- b,
390
- x
393
+ return N.some((k) => k.id === b.id) ? [...N, g].sort((k, A) => new Date(k.createdAt).getTime() - new Date(A.createdAt).getTime()) : [
394
+ ...N,
395
+ g,
396
+ b
391
397
  ];
392
- }), x;
393
- } catch (x) {
394
- return w(x instanceof Error ? x : /* @__PURE__ */ new Error("Failed to send message")), d(!1), s((R) => R.filter((_) => !_.id.startsWith("temp-"))), null;
398
+ }), b;
399
+ } catch (b) {
400
+ return m(b instanceof Error ? b : /* @__PURE__ */ new Error("Failed to send message")), d(!1), s((I) => I.filter((N) => !N.id.startsWith("temp-"))), null;
395
401
  }
396
- }, [o, l]),
397
- stop: T(async () => {
398
- await o.stop();
399
- }, [o]),
400
- clearMessages: T(() => {
401
- s([]), i(void 0), w(null);
402
+ }, [r, c]),
403
+ stop: R(async () => {
404
+ await r.stop();
405
+ }, [r]),
406
+ clearMessages: R(() => {
407
+ s([]), i(void 0), m(null);
402
408
  }, []),
403
- conversationId: l
409
+ conversationId: c
404
410
  };
405
411
  }
406
- var pe = {
412
+ var ve = {
407
413
  compact: !1,
408
414
  state: "peek",
409
415
  isModal: !1,
@@ -411,49 +417,49 @@ var pe = {
411
417
  style: {},
412
418
  attrs: {}
413
419
  }
414
- }, it = { tabindex: "tabIndex" };
415
- function st(e) {
416
- const r = {};
417
- for (const [t, o] of Object.entries(e)) r[it[t] ?? t] = o;
418
- return r;
420
+ }, gt = { tabindex: "tabIndex" };
421
+ function mt(e) {
422
+ const o = {};
423
+ for (const [t, r] of Object.entries(e)) o[gt[t] ?? t] = r;
424
+ return o;
419
425
  }
420
- function lt(e) {
421
- const r = e !== !1, t = r ? e ?? {} : void 0, o = W(t?.onStateChange);
422
- o.current = t?.onStateChange;
423
- const n = $(() => {
424
- if (r)
425
- return je({
426
+ function ht(e) {
427
+ const o = e !== !1, t = o ? e ?? {} : void 0, r = D(t?.onStateChange);
428
+ r.current = t?.onStateChange;
429
+ const n = U(() => {
430
+ if (o)
431
+ return Ve({
426
432
  breakpoint: t?.breakpoint,
427
433
  initialState: t?.initialState,
428
434
  bottomOffset: t?.bottomOffset,
429
435
  peekHeight: t?.peekHeight,
430
- onStateChange: (l, i) => o.current?.(l, i)
436
+ onStateChange: (c, i) => r.current?.(c, i)
431
437
  });
432
438
  }, [
433
- r,
439
+ o,
434
440
  t?.breakpoint,
435
441
  t?.initialState,
436
442
  t?.bottomOffset,
437
443
  t?.peekHeight
438
- ]), s = ye(T((l) => n?.subscribe(l) ?? (() => {
439
- }), [n]), T(() => n?.getSnapshot() ?? pe, [n]), T(() => n?.getServerSnapshot() ?? pe, [n]));
444
+ ]), s = ce(R((c) => n?.subscribe(c) ?? (() => {
445
+ }), [n]), R(() => n?.getSnapshot() ?? ve, [n]), R(() => n?.getServerSnapshot() ?? ve, [n]));
440
446
  return {
441
- sheet: $(() => ({
447
+ sheet: U(() => ({
442
448
  ...s,
443
449
  surface: {
444
450
  ...s.surface,
445
- attrs: st(s.surface.attrs)
451
+ attrs: mt(s.surface.attrs)
446
452
  }
447
453
  }), [s]),
448
- expand: T((l) => n?.expand(l), [n]),
449
- collapse: T((l) => n?.collapse(l), [n]),
450
- toggle: T((l) => n?.toggle(l), [n])
454
+ expand: R((c) => n?.expand(c), [n]),
455
+ collapse: R((c) => n?.collapse(c), [n]),
456
+ toggle: R((c) => n?.toggle(c), [n])
451
457
  };
452
458
  }
453
- var ct = /(`[^`\n]+`|\*\*[^*\n]+\*\*|\*[^*\n]+\*|_[^_\n]+_)/g;
454
- function Ce(e) {
455
- const r = e.split(ct);
456
- return r.length === 1 ? e : r.map((t, o) => o % 2 === 0 || !t ? t : t.startsWith("`") ? /* @__PURE__ */ a("code", {
459
+ var xt = /(`[^`\n]+`|\*\*[^*\n]+\*\*|\*[^*\n]+\*|_[^_\n]+_)/g;
460
+ function Ie(e) {
461
+ const o = e.split(xt);
462
+ return o.length === 1 ? e : o.map((t, r) => r % 2 === 0 || !t ? t : t.startsWith("`") ? /* @__PURE__ */ a("code", {
457
463
  style: {
458
464
  fontFamily: "ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",
459
465
  fontSize: "0.92em",
@@ -462,12 +468,12 @@ function Ce(e) {
462
468
  backgroundColor: "rgba(0, 0, 0, 0.06)"
463
469
  },
464
470
  children: t.slice(1, -1)
465
- }, o) : t.startsWith("**") ? /* @__PURE__ */ a("strong", {
471
+ }, r) : t.startsWith("**") ? /* @__PURE__ */ a("strong", {
466
472
  style: { fontWeight: 600 },
467
473
  children: t.slice(2, -2)
468
- }, o) : /* @__PURE__ */ a("em", { children: t.slice(1, -1) }, o));
474
+ }, r) : /* @__PURE__ */ a("em", { children: t.slice(1, -1) }, r));
469
475
  }
470
- var dt = `
476
+ var bt = `
471
477
  @keyframes ago-activity-enter {
472
478
  from { opacity: 0; transform: translateY(4px); }
473
479
  to { opacity: 1; transform: none; }
@@ -504,7 +510,7 @@ var dt = `
504
510
  color: var(--ago-activity-color, #5b5d5f);
505
511
  }
506
512
  }
507
- `, ut = ({ label: e }) => /* @__PURE__ */ F("div", {
513
+ `, yt = ({ label: e }) => /* @__PURE__ */ W("div", {
508
514
  className: "ago-activity",
509
515
  role: "status",
510
516
  "aria-live": "polite",
@@ -525,105 +531,105 @@ var dt = `
525
531
  },
526
532
  children: [/* @__PURE__ */ a("span", {
527
533
  className: "ago-activity__label",
528
- children: Ce(e)
529
- }, e), /* @__PURE__ */ a("style", { children: dt })]
530
- }), V = typeof window > "u" ? E : Ze;
531
- function pt(e) {
532
- const r = O(), t = e.client ?? r, o = W(null), n = W(), s = W(e), [l, i] = M(!1), [g, d] = M(""), [f, w] = M(!1);
533
- return V(() => {
534
- s.current = e;
535
- }), V(() => {
536
- if (w(!1), i(!1), s.current.onBusyChange?.(!1), !t || !o.current) return;
537
- let m = !0;
538
- const u = Ke({
539
- transcribe: (y, p) => t.transcribeAudio(y, p),
540
- onText: (y) => {
541
- m && s.current.onTranscript(y);
534
+ children: Ie(e)
535
+ }, e), /* @__PURE__ */ a("style", { children: bt })]
536
+ }), Z = typeof window > "u" ? _ : st;
537
+ function vt(e) {
538
+ const o = $(), t = e.client ?? o, r = Q(t), n = D(null), s = D(), c = D(e), [i, u] = E(!1), [d, p] = E(""), [m, x] = E(!1);
539
+ return Z(() => {
540
+ c.current = e;
541
+ }), Z(() => {
542
+ if (x(!1), u(!1), c.current.onBusyChange?.(!1), !t || !n.current) return;
543
+ let f = !0;
544
+ const v = Qe({
545
+ transcribe: (l, h) => t.transcribeAudio(l, h),
546
+ onText: (l) => {
547
+ f && c.current.onTranscript(l);
542
548
  },
543
- onBusy: (y) => {
544
- m && (i(y), y && d(""), s.current.onBusyChange?.(y));
549
+ onBusy: (l) => {
550
+ f && (u(l), l && p(""), c.current.onBusyChange?.(l));
545
551
  },
546
- onError: (y) => {
547
- m && d(y);
552
+ onError: (l) => {
553
+ f && p(l);
548
554
  },
549
- labels: s.current.labels
555
+ labels: re(r.speech, c.current.labels)
550
556
  });
551
- return o.current.append(u.el), n.current = u, u.setDisabled(!!s.current.disabled), t.getConfig().then(({ permissions: y }) => {
552
- if (!m) return;
553
- const p = y.some((k) => k.speechToTextEnabled) && typeof MediaRecorder < "u" && !!navigator.mediaDevices?.getUserMedia;
554
- u.setEnabled(p), w(p);
557
+ return n.current.append(v.el), s.current = v, v.setDisabled(!!c.current.disabled), t.getConfig().then(({ permissions: l }) => {
558
+ if (!f) return;
559
+ const h = l.some((b) => b.speechToTextEnabled) && typeof MediaRecorder < "u" && !!navigator.mediaDevices?.getUserMedia;
560
+ v.setEnabled(h), x(h);
555
561
  }).catch(() => {
556
562
  }), () => {
557
- m = !1, u.destroy(), s.current.onBusyChange?.(!1), u.el.remove(), n.current = void 0;
563
+ f = !1, v.destroy(), c.current.onBusyChange?.(!1), v.el.remove(), s.current = void 0;
558
564
  };
559
- }, [t]), V(() => {
560
- n.current?.setDisabled(!!e.disabled);
561
- }, [e.disabled]), V(() => {
562
- n.current?.cancel();
563
- }, [e.scopeKey, t]), V(() => {
564
- n.current?.setLabels(e.labels);
565
- }, [e.labels]), /* @__PURE__ */ F("div", {
565
+ }, [t]), Z(() => {
566
+ s.current?.setDisabled(!!e.disabled);
567
+ }, [e.disabled]), Z(() => {
568
+ s.current?.cancel();
569
+ }, [e.scopeKey, t]), Z(() => {
570
+ s.current?.setLabels(re(r.speech, e.labels));
571
+ }, [r, e.labels]), /* @__PURE__ */ W("div", {
566
572
  className: `ago-speech-to-text ${e.className ?? ""}`,
567
573
  style: {
568
- display: f ? "flex" : "none",
574
+ display: m ? "flex" : "none",
569
575
  flexDirection: "column",
570
576
  minWidth: 0,
571
- flex: l ? 1 : void 0
577
+ flex: i ? 1 : void 0
572
578
  },
573
- children: [/* @__PURE__ */ a("div", { ref: o }), g && /* @__PURE__ */ a("span", {
579
+ children: [/* @__PURE__ */ a("div", { ref: n }), d && /* @__PURE__ */ a("span", {
574
580
  role: "alert",
575
581
  style: {
576
582
  color: "var(--ago-muted-text-color, #6b6d6f)",
577
583
  fontSize: "13px"
578
584
  },
579
- children: g
585
+ children: d
580
586
  })]
581
587
  });
582
588
  }
583
- var ft = ({ onSend: e, onStop: r, disabled: t = !1, placeholder: o = "Type a message...", allowFiles: n = !1, speechToText: s = !1, client: l, scopeKey: i, className: g = "" }) => {
584
- const [d, f] = M(""), [w, m] = M([]), [u, y] = M(!1), p = W(null), k = W(null), x = !!s;
585
- E(() => {
586
- x || y(!1);
587
- }, [x]);
588
- const R = T(() => {
589
- const c = k.current;
590
- if (!c) return;
591
- const S = 110;
592
- c.style.height = "auto", c.style.height = `${Math.min(c.scrollHeight + 2, S)}px`, c.style.overflowY = c.scrollHeight + 2 > S ? "auto" : "hidden";
593
- }, []), _ = W(!1);
594
- E(() => {
595
- _.current && !u && !t && (R(), k.current?.focus()), _.current = u;
589
+ var wt = ({ onSend: e, onStop: o, disabled: t = !1, placeholder: r, allowFiles: n = !1, speechToText: s = !1, client: c, scopeKey: i, className: u = "" }) => {
590
+ const d = Q(c), p = r ?? d.common.placeholder, [m, x] = E(""), [f, v] = E([]), [l, h] = E(!1), b = D(null), I = D(null), N = !!s;
591
+ _(() => {
592
+ N || h(!1);
593
+ }, [N]);
594
+ const g = R(() => {
595
+ const w = I.current;
596
+ if (!w) return;
597
+ const T = 110;
598
+ w.style.height = "auto", w.style.height = `${Math.min(w.scrollHeight + 2, T)}px`, w.style.overflowY = w.scrollHeight + 2 > T ? "auto" : "hidden";
599
+ }, []), k = D(!1);
600
+ _(() => {
601
+ k.current && !l && !t && (g(), I.current?.focus()), k.current = l;
596
602
  }, [
597
- u,
603
+ l,
598
604
  t,
599
- R
605
+ g
600
606
  ]);
601
- const b = T(async (c) => {
602
- if (c.preventDefault(), t || u || !d.trim()) return;
603
- const S = d.trim(), I = w.length > 0 ? w : void 0;
604
- f(""), m([]), requestAnimationFrame(R), await e(S, I) === !1 && (f((B) => B.trim() ? B : S), I && m((B) => [...I, ...B]), requestAnimationFrame(R));
607
+ const A = R(async (w) => {
608
+ if (w.preventDefault(), t || l || !m.trim()) return;
609
+ const T = m.trim(), q = f.length > 0 ? f : void 0;
610
+ x(""), v([]), requestAnimationFrame(g), await e(T, q) === !1 && (x((O) => O.trim() ? O : T), q && v((O) => [...q, ...O]), requestAnimationFrame(g));
605
611
  }, [
606
- d,
607
- w,
612
+ m,
613
+ f,
608
614
  e,
609
- R,
615
+ g,
610
616
  t,
611
- u
612
- ]), C = T((c) => {
613
- c.key === "Enter" && !c.shiftKey && (c.preventDefault(), b(c));
614
- }, [b]), A = T((c) => {
615
- const S = Array.from(c.target.files || []);
616
- m((I) => [...I, ...S]);
617
- }, []), N = T((c) => {
618
- m((S) => S.filter((I, B) => B !== c));
619
- }, []), h = d.trim().length > 0, D = (c) => {
620
- f((S) => `${S}${S && !/\s$/.test(S) ? " " : ""}${c}`);
617
+ l
618
+ ]), S = R((w) => {
619
+ w.key === "Enter" && !w.shiftKey && (w.preventDefault(), A(w));
620
+ }, [A]), C = R((w) => {
621
+ const T = Array.from(w.target.files || []);
622
+ v((q) => [...q, ...T]);
623
+ }, []), L = R((w) => {
624
+ v((T) => T.filter((q, O) => O !== w));
625
+ }, []), F = m.trim().length > 0, M = (w) => {
626
+ x((T) => `${T}${T && !/\s$/.test(T) ? " " : ""}${w}`);
621
627
  };
622
- return /* @__PURE__ */ F("form", {
623
- onSubmit: (c) => {
624
- b(c);
628
+ return /* @__PURE__ */ W("form", {
629
+ onSubmit: (w) => {
630
+ A(w);
625
631
  },
626
- className: `ago-chat-input ${g}`,
632
+ className: `ago-chat-input ${u}`,
627
633
  style: {
628
634
  display: "flex",
629
635
  flexDirection: "column",
@@ -632,14 +638,14 @@ var ft = ({ onSend: e, onStop: r, disabled: t = !1, placeholder: o = "Type a mes
632
638
  borderTop: "1px solid #dee3e8",
633
639
  backgroundColor: "#fff"
634
640
  },
635
- children: [w.length > 0 && !u && /* @__PURE__ */ a("div", {
641
+ children: [f.length > 0 && !l && /* @__PURE__ */ a("div", {
636
642
  className: "ago-chat-input__files",
637
643
  style: {
638
644
  display: "flex",
639
645
  flexWrap: "wrap",
640
646
  gap: "6px"
641
647
  },
642
- children: w.map((c, S) => /* @__PURE__ */ F("div", {
648
+ children: f.map((w, T) => /* @__PURE__ */ W("div", {
643
649
  style: {
644
650
  display: "flex",
645
651
  alignItems: "center",
@@ -657,11 +663,11 @@ var ft = ({ onSend: e, onStop: r, disabled: t = !1, placeholder: o = "Type a mes
657
663
  textOverflow: "ellipsis",
658
664
  whiteSpace: "nowrap"
659
665
  },
660
- children: c.name
666
+ children: w.name
661
667
  }), /* @__PURE__ */ a("button", {
662
668
  type: "button",
663
- onClick: () => N(S),
664
- "aria-label": `Remove ${c.name}`,
669
+ onClick: () => L(T),
670
+ "aria-label": d.form.removeFile.replace("{filename}", () => w.name),
665
671
  style: {
666
672
  flexShrink: 0,
667
673
  width: "44px",
@@ -680,19 +686,19 @@ var ft = ({ onSend: e, onStop: r, disabled: t = !1, placeholder: o = "Type a mes
680
686
  },
681
687
  children: "×"
682
688
  })]
683
- }, S))
684
- }), /* @__PURE__ */ F("div", {
689
+ }, T))
690
+ }), /* @__PURE__ */ W("div", {
685
691
  style: {
686
692
  display: "flex",
687
693
  gap: "8px",
688
694
  alignItems: "flex-end"
689
695
  },
690
696
  children: [
691
- n && !u && /* @__PURE__ */ F(ve, { children: [/* @__PURE__ */ a("button", {
697
+ n && !l && /* @__PURE__ */ W(Ne, { children: [/* @__PURE__ */ a("button", {
692
698
  type: "button",
693
- onClick: () => p.current?.click(),
699
+ onClick: () => b.current?.click(),
694
700
  disabled: t,
695
- "aria-label": "Attach file",
701
+ "aria-label": d.common.attachFile,
696
702
  style: {
697
703
  flexShrink: 0,
698
704
  minWidth: "44px",
@@ -711,26 +717,26 @@ var ft = ({ onSend: e, onStop: r, disabled: t = !1, placeholder: o = "Type a mes
711
717
  },
712
718
  children: "+"
713
719
  }), /* @__PURE__ */ a("input", {
714
- ref: p,
720
+ ref: b,
715
721
  type: "file",
716
722
  multiple: !0,
717
- onChange: A,
723
+ onChange: C,
718
724
  style: { display: "none" }
719
725
  })] }),
720
726
  /* @__PURE__ */ a("textarea", {
721
- ref: k,
727
+ ref: I,
722
728
  className: "ago-chat-input__field",
723
- value: d,
724
- onChange: (c) => {
725
- f(c.target.value), R();
729
+ value: m,
730
+ onChange: (w) => {
731
+ x(w.target.value), g();
726
732
  },
727
- onKeyDown: C,
728
- placeholder: o,
729
- "aria-label": o,
730
- disabled: t || u,
733
+ onKeyDown: S,
734
+ placeholder: p,
735
+ "aria-label": p,
736
+ disabled: t || l,
731
737
  rows: 1,
732
738
  style: {
733
- display: u ? "none" : void 0,
739
+ display: l ? "none" : void 0,
734
740
  flex: 1,
735
741
  padding: "10px 14px",
736
742
  border: "1px solid #dee3e8",
@@ -747,25 +753,25 @@ var ft = ({ onSend: e, onStop: r, disabled: t = !1, placeholder: o = "Type a mes
747
753
  backgroundColor: "#f8f8f8",
748
754
  transition: "border-color 0.15s"
749
755
  },
750
- onFocus: (c) => {
751
- c.currentTarget.style.borderColor = "#1b5fc4";
756
+ onFocus: (w) => {
757
+ w.currentTarget.style.borderColor = "#1b5fc4";
752
758
  },
753
- onBlur: (c) => {
754
- c.currentTarget.style.borderColor = "#dee3e8";
759
+ onBlur: (w) => {
760
+ w.currentTarget.style.borderColor = "#dee3e8";
755
761
  }
756
762
  }),
757
- s && /* @__PURE__ */ a(pt, {
758
- client: l,
763
+ s && /* @__PURE__ */ a(vt, {
764
+ client: c,
759
765
  disabled: t,
760
766
  scopeKey: i,
761
767
  labels: typeof s == "object" ? s.labels : void 0,
762
- onTranscript: D,
763
- onBusyChange: y
768
+ onTranscript: M,
769
+ onBusyChange: h
764
770
  }),
765
- !u && (t && r ? /* @__PURE__ */ a("button", {
771
+ !l && (t && o ? /* @__PURE__ */ a("button", {
766
772
  type: "button",
767
- onClick: r,
768
- "aria-label": "Stop generating",
773
+ onClick: o,
774
+ "aria-label": d.common.stop,
769
775
  style: {
770
776
  minHeight: "44px",
771
777
  padding: "10px 18px",
@@ -778,28 +784,28 @@ var ft = ({ onSend: e, onStop: r, disabled: t = !1, placeholder: o = "Type a mes
778
784
  fontSize: "16px",
779
785
  transition: "background-color 0.15s"
780
786
  },
781
- children: "Stop"
787
+ children: d.common.stopButton
782
788
  }) : /* @__PURE__ */ a("button", {
783
789
  type: "submit",
784
- disabled: t || !h,
790
+ disabled: t || !F,
785
791
  style: {
786
792
  minHeight: "44px",
787
793
  padding: "10px 18px",
788
794
  border: "none",
789
795
  borderRadius: "20px",
790
- backgroundColor: t || !h ? "#b5bfc8" : "#03182f",
796
+ backgroundColor: t || !F ? "#b5bfc8" : "#03182f",
791
797
  color: "#fff",
792
- cursor: t || !h ? "not-allowed" : "pointer",
798
+ cursor: t || !F ? "not-allowed" : "pointer",
793
799
  fontWeight: 500,
794
800
  fontSize: "16px",
795
801
  transition: "background-color 0.15s"
796
802
  },
797
- children: "Send"
803
+ children: d.common.send
798
804
  }))
799
805
  ]
800
806
  })]
801
807
  });
802
- }, gt = ({ href: e, children: r, ...t }) => /* @__PURE__ */ a("a", {
808
+ }, kt = ({ href: e, children: o, ...t }) => /* @__PURE__ */ a("a", {
803
809
  href: e,
804
810
  target: "_blank",
805
811
  rel: "noopener noreferrer",
@@ -808,52 +814,52 @@ var ft = ({ onSend: e, onStop: r, disabled: t = !1, placeholder: o = "Type a mes
808
814
  textDecoration: "underline"
809
815
  },
810
816
  ...t,
811
- children: r
812
- }), mt = ({ children: e, ...r }) => /* @__PURE__ */ a("p", {
817
+ children: o
818
+ }), Ct = ({ children: e, ...o }) => /* @__PURE__ */ a("p", {
813
819
  style: {
814
820
  margin: "0 0 8px 0",
815
821
  lineHeight: "1.6"
816
822
  },
817
- ...r,
823
+ ...o,
818
824
  children: e
819
- }), K = (e, r) => {
820
- const t = ({ children: o, ...n }) => Ge.createElement(`h${e}`, {
825
+ }), J = (e, o) => {
826
+ const t = ({ children: r, ...n }) => tt.createElement(`h${e}`, {
821
827
  style: {
822
828
  margin: "16px 0 8px 0",
823
- fontSize: r,
829
+ fontSize: o,
824
830
  fontWeight: 600,
825
831
  lineHeight: "1.3"
826
832
  },
827
833
  ...n
828
- }, o);
834
+ }, r);
829
835
  return t.displayName = `MarkdownHeading${e}`, t;
830
- }, ht = ({ children: e, ...r }) => /* @__PURE__ */ a("ul", {
836
+ }, St = ({ children: e, ...o }) => /* @__PURE__ */ a("ul", {
831
837
  style: {
832
838
  margin: "0 0 8px 0",
833
839
  paddingLeft: "20px",
834
840
  listStyleType: "disc",
835
841
  listStylePosition: "outside"
836
842
  },
837
- ...r,
843
+ ...o,
838
844
  children: e
839
- }), xt = ({ children: e, ...r }) => /* @__PURE__ */ a("ol", {
845
+ }), At = ({ children: e, ...o }) => /* @__PURE__ */ a("ol", {
840
846
  style: {
841
847
  margin: "0 0 8px 0",
842
848
  paddingLeft: "20px",
843
849
  listStyleType: "decimal",
844
850
  listStylePosition: "outside"
845
851
  },
846
- ...r,
852
+ ...o,
847
853
  children: e
848
- }), bt = ({ children: e, ...r }) => /* @__PURE__ */ a("li", {
854
+ }), Nt = ({ children: e, ...o }) => /* @__PURE__ */ a("li", {
849
855
  style: {
850
856
  display: "list-item",
851
857
  margin: "2px 0",
852
858
  lineHeight: "1.6"
853
859
  },
854
- ...r,
860
+ ...o,
855
861
  children: e
856
- }), yt = ({ className: e, children: r, ...t }) => e !== void 0 || String(r).includes(`
862
+ }), _t = ({ className: e, children: o, ...t }) => e !== void 0 || String(o).includes(`
857
863
  `) ? /* @__PURE__ */ a("code", {
858
864
  style: {
859
865
  display: "block",
@@ -865,7 +871,7 @@ var ft = ({ onSend: e, onStop: r, disabled: t = !1, placeholder: o = "Type a mes
865
871
  fontFamily: '"IBM Plex Mono", monospace'
866
872
  },
867
873
  ...t,
868
- children: r
874
+ children: o
869
875
  }) : /* @__PURE__ */ a("code", {
870
876
  style: {
871
877
  background: "#f0f2f5",
@@ -875,12 +881,12 @@ var ft = ({ onSend: e, onStop: r, disabled: t = !1, placeholder: o = "Type a mes
875
881
  fontFamily: '"IBM Plex Mono", monospace'
876
882
  },
877
883
  ...t,
878
- children: r
879
- }), vt = ({ children: e, ...r }) => /* @__PURE__ */ a("pre", {
884
+ children: o
885
+ }), Rt = ({ children: e, ...o }) => /* @__PURE__ */ a("pre", {
880
886
  style: { margin: "0 0 8px 0" },
881
- ...r,
887
+ ...o,
882
888
  children: e
883
- }), wt = ({ children: e, ...r }) => /* @__PURE__ */ a("blockquote", {
889
+ }), It = ({ children: e, ...o }) => /* @__PURE__ */ a("blockquote", {
884
890
  style: {
885
891
  borderLeft: "4px solid #dee3e8",
886
892
  paddingLeft: "12px",
@@ -888,9 +894,9 @@ var ft = ({ onSend: e, onStop: r, disabled: t = !1, placeholder: o = "Type a mes
888
894
  fontStyle: "italic",
889
895
  color: "#6b6d6f"
890
896
  },
891
- ...r,
897
+ ...o,
892
898
  children: e
893
- }), kt = ({ children: e, ...r }) => /* @__PURE__ */ a("div", {
899
+ }), Et = ({ children: e, ...o }) => /* @__PURE__ */ a("div", {
894
900
  style: {
895
901
  overflowX: "auto",
896
902
  margin: "0 0 8px 0"
@@ -901,10 +907,10 @@ var ft = ({ onSend: e, onStop: r, disabled: t = !1, placeholder: o = "Type a mes
901
907
  width: "100%",
902
908
  fontSize: "13px"
903
909
  },
904
- ...r,
910
+ ...o,
905
911
  children: e
906
912
  })
907
- }), Ct = ({ children: e, ...r }) => /* @__PURE__ */ a("th", {
913
+ }), Mt = ({ children: e, ...o }) => /* @__PURE__ */ a("th", {
908
914
  style: {
909
915
  border: "1px solid #dee3e8",
910
916
  padding: "6px 10px",
@@ -912,57 +918,57 @@ var ft = ({ onSend: e, onStop: r, disabled: t = !1, placeholder: o = "Type a mes
912
918
  backgroundColor: "#f5f7fa",
913
919
  fontWeight: 600
914
920
  },
915
- ...r,
921
+ ...o,
916
922
  children: e
917
- }), St = ({ children: e, ...r }) => /* @__PURE__ */ a("td", {
923
+ }), Tt = ({ children: e, ...o }) => /* @__PURE__ */ a("td", {
918
924
  style: {
919
925
  border: "1px solid #dee3e8",
920
926
  padding: "6px 10px"
921
927
  },
922
- ...r,
928
+ ...o,
923
929
  children: e
924
- }), At = ({ alt: e, ...r }) => /* @__PURE__ */ a("img", {
930
+ }), Ft = ({ alt: e, ...o }) => /* @__PURE__ */ a("img", {
925
931
  alt: e ?? "",
926
932
  style: {
927
933
  maxWidth: "100%",
928
934
  borderRadius: "8px",
929
935
  margin: "4px 0"
930
936
  },
931
- ...r
932
- }), Nt = (e) => /* @__PURE__ */ a("hr", {
937
+ ...o
938
+ }), Lt = (e) => /* @__PURE__ */ a("hr", {
933
939
  style: {
934
940
  border: "none",
935
941
  borderTop: "1px solid #dee3e8",
936
942
  margin: "12px 0"
937
943
  },
938
944
  ...e
939
- }), _t = {
940
- a: gt,
941
- p: mt,
942
- h1: K(1, "20px"),
943
- h2: K(2, "18px"),
944
- h3: K(3, "16px"),
945
- h4: K(4, "15px"),
946
- h5: K(5, "14px"),
947
- h6: K(6, "13px"),
948
- ul: ht,
949
- ol: xt,
950
- li: bt,
951
- code: yt,
952
- pre: vt,
953
- blockquote: wt,
954
- table: kt,
955
- th: Ct,
956
- td: St,
957
- img: At,
958
- hr: Nt
959
- }, It = [et], Rt = ({ content: e }) => /* @__PURE__ */ a(Qe, {
960
- remarkPlugins: It,
961
- components: _t,
945
+ }), Wt = {
946
+ a: kt,
947
+ p: Ct,
948
+ h1: J(1, "20px"),
949
+ h2: J(2, "18px"),
950
+ h3: J(3, "16px"),
951
+ h4: J(4, "15px"),
952
+ h5: J(5, "14px"),
953
+ h6: J(6, "13px"),
954
+ ul: St,
955
+ ol: At,
956
+ li: Nt,
957
+ code: _t,
958
+ pre: Rt,
959
+ blockquote: It,
960
+ table: Et,
961
+ th: Mt,
962
+ td: Tt,
963
+ img: Ft,
964
+ hr: Lt
965
+ }, Dt = [lt], zt = ({ content: e }) => /* @__PURE__ */ a(it, {
966
+ remarkPlugins: Dt,
967
+ components: Wt,
962
968
  children: e
963
- }), Et = ({ attachment: e, isUser: r }) => {
964
- const t = ze(e.url);
965
- if (Be(e)) return /* @__PURE__ */ a("a", {
969
+ }), Bt = ({ attachment: e, isUser: o }) => {
970
+ const t = $e(e.url);
971
+ if (Ue(e)) return /* @__PURE__ */ a("a", {
966
972
  href: t,
967
973
  target: "_blank",
968
974
  rel: "noopener noreferrer",
@@ -984,7 +990,7 @@ var ft = ({ onSend: e, onStop: r, disabled: t = !1, placeholder: o = "Type a mes
984
990
  }
985
991
  })
986
992
  });
987
- const o = He(e.fileSize), n = /* @__PURE__ */ F(ve, { children: [/* @__PURE__ */ a("span", {
993
+ const r = Ke(e.fileSize), n = /* @__PURE__ */ W(Ne, { children: [/* @__PURE__ */ a("span", {
988
994
  style: {
989
995
  fontSize: "16px",
990
996
  lineHeight: 1,
@@ -992,7 +998,7 @@ var ft = ({ onSend: e, onStop: r, disabled: t = !1, placeholder: o = "Type a mes
992
998
  },
993
999
  "aria-hidden": !0,
994
1000
  children: "📄"
995
- }), /* @__PURE__ */ F("span", {
1001
+ }), /* @__PURE__ */ W("span", {
996
1002
  style: {
997
1003
  display: "flex",
998
1004
  flexDirection: "column",
@@ -1007,12 +1013,12 @@ var ft = ({ onSend: e, onStop: r, disabled: t = !1, placeholder: o = "Type a mes
1007
1013
  },
1008
1014
  title: e.name,
1009
1015
  children: e.name
1010
- }), o && /* @__PURE__ */ a("span", {
1016
+ }), r && /* @__PURE__ */ a("span", {
1011
1017
  style: {
1012
1018
  fontSize: "11px",
1013
1019
  color: "#6b6d6f"
1014
1020
  },
1015
- children: o
1021
+ children: r
1016
1022
  })]
1017
1023
  })] }), s = {
1018
1024
  display: "inline-flex",
@@ -1021,8 +1027,8 @@ var ft = ({ onSend: e, onStop: r, disabled: t = !1, placeholder: o = "Type a mes
1021
1027
  padding: "8px 12px",
1022
1028
  borderRadius: "10px",
1023
1029
  border: "1px solid #dee3e8",
1024
- backgroundColor: r ? "rgba(255,255,255,0.12)" : "#fff",
1025
- color: r ? "#fff" : "#30373e",
1030
+ backgroundColor: o ? "rgba(255,255,255,0.12)" : "#fff",
1031
+ color: o ? "#fff" : "#30373e",
1026
1032
  fontSize: "13px",
1027
1033
  textDecoration: "none",
1028
1034
  maxWidth: "220px"
@@ -1037,8 +1043,8 @@ var ft = ({ onSend: e, onStop: r, disabled: t = !1, placeholder: o = "Type a mes
1037
1043
  style: s,
1038
1044
  children: n
1039
1045
  });
1040
- }, Tt = ({ source: e, index: r }) => {
1041
- const t = /* @__PURE__ */ F("div", {
1046
+ }, Pt = ({ source: e, index: o }) => {
1047
+ const t = /* @__PURE__ */ W("div", {
1042
1048
  style: {
1043
1049
  display: "flex",
1044
1050
  alignItems: "center",
@@ -1061,7 +1067,7 @@ var ft = ({ onSend: e, onStop: r, disabled: t = !1, placeholder: o = "Type a mes
1061
1067
  justifyContent: "center",
1062
1068
  backgroundColor: "#f0f4ff"
1063
1069
  },
1064
- children: r + 1
1070
+ children: o + 1
1065
1071
  }), /* @__PURE__ */ a("div", {
1066
1072
  style: {
1067
1073
  fontSize: "12px",
@@ -1073,7 +1079,7 @@ var ft = ({ onSend: e, onStop: r, disabled: t = !1, placeholder: o = "Type a mes
1073
1079
  title: e.title,
1074
1080
  children: e.title
1075
1081
  })]
1076
- }), o = {
1082
+ }), r = {
1077
1083
  display: "flex",
1078
1084
  alignItems: "center",
1079
1085
  padding: "8px 10px",
@@ -1090,7 +1096,7 @@ var ft = ({ onSend: e, onStop: r, disabled: t = !1, placeholder: o = "Type a mes
1090
1096
  href: e.url,
1091
1097
  target: "_blank",
1092
1098
  rel: "noopener noreferrer",
1093
- style: o,
1099
+ style: r,
1094
1100
  onMouseEnter: (n) => {
1095
1101
  n.currentTarget.style.borderColor = "#1b5fc4";
1096
1102
  },
@@ -1099,10 +1105,10 @@ var ft = ({ onSend: e, onStop: r, disabled: t = !1, placeholder: o = "Type a mes
1099
1105
  },
1100
1106
  children: t
1101
1107
  }) : /* @__PURE__ */ a("div", {
1102
- style: o,
1108
+ style: r,
1103
1109
  children: t
1104
1110
  });
1105
- }, Se = () => /* @__PURE__ */ F("div", {
1111
+ }, Ee = () => /* @__PURE__ */ W("div", {
1106
1112
  style: {
1107
1113
  display: "flex",
1108
1114
  gap: "4px",
@@ -1126,10 +1132,10 @@ var ft = ({ onSend: e, onStop: r, disabled: t = !1, placeholder: o = "Type a mes
1126
1132
  40% { opacity: 1; transform: scale(1); }
1127
1133
  }
1128
1134
  ` })]
1129
- }), Mt = ({ message: e, className: r = "", showAgentName: t = !1, isLast: o = !1, onFollowUpClick: n, showStreamingDots: s = !0, feedback: l }) => {
1130
- const i = e.role === "user", g = e.status === "IN_PROGRESS" || e.status === "WAITING_CLIENT";
1131
- return /* @__PURE__ */ F("div", {
1132
- className: `ago-message ago-message--${e.role} ${r}`,
1135
+ }), Ht = ({ message: e, className: o = "", showAgentName: t = !1, isLast: r = !1, onFollowUpClick: n, showStreamingDots: s = !0, feedback: c }) => {
1136
+ const i = e.role === "user", u = e.status === "IN_PROGRESS" || e.status === "WAITING_CLIENT";
1137
+ return /* @__PURE__ */ W("div", {
1138
+ className: `ago-message ago-message--${e.role} ${o}`,
1133
1139
  style: {
1134
1140
  display: "flex",
1135
1141
  flexDirection: "column",
@@ -1161,9 +1167,9 @@ var ft = ({ onSend: e, onStop: r, disabled: t = !1, placeholder: o = "Type a mes
1161
1167
  width: "100%",
1162
1168
  maxWidth: "85%"
1163
1169
  },
1164
- children: e.sources.map((d, f) => /* @__PURE__ */ a(Tt, {
1170
+ children: e.sources.map((d, p) => /* @__PURE__ */ a(Pt, {
1165
1171
  source: d,
1166
- index: f
1172
+ index: p
1167
1173
  }, d.id))
1168
1174
  }),
1169
1175
  e.attachments && e.attachments.length > 0 && /* @__PURE__ */ a("div", {
@@ -1176,12 +1182,12 @@ var ft = ({ onSend: e, onStop: r, disabled: t = !1, placeholder: o = "Type a mes
1176
1182
  justifyContent: i ? "flex-end" : "flex-start",
1177
1183
  maxWidth: "75%"
1178
1184
  },
1179
- children: e.attachments.map((d) => /* @__PURE__ */ a(Et, {
1185
+ children: e.attachments.map((d) => /* @__PURE__ */ a(Bt, {
1180
1186
  attachment: d,
1181
1187
  isUser: i
1182
1188
  }, d.id))
1183
1189
  }),
1184
- (e.content || g && s) && /* @__PURE__ */ a("div", {
1190
+ (e.content || u && s) && /* @__PURE__ */ a("div", {
1185
1191
  className: "ago-message__content",
1186
1192
  style: {
1187
1193
  maxWidth: i ? "75%" : "100%",
@@ -1193,10 +1199,10 @@ var ft = ({ onSend: e, onStop: r, disabled: t = !1, placeholder: o = "Type a mes
1193
1199
  fontSize: "16px",
1194
1200
  lineHeight: "1.6"
1195
1201
  },
1196
- children: e.content ? /* @__PURE__ */ a(Rt, { content: e.content }) : g && s && /* @__PURE__ */ a(Se, {})
1202
+ children: e.content ? /* @__PURE__ */ a(zt, { content: e.content }) : u && s && /* @__PURE__ */ a(Ee, {})
1197
1203
  }),
1198
- !i && l,
1199
- o && e.followUpReplies && e.followUpReplies.length > 0 && /* @__PURE__ */ a("div", {
1204
+ !i && c,
1205
+ r && e.followUpReplies && e.followUpReplies.length > 0 && /* @__PURE__ */ a("div", {
1200
1206
  className: "ago-message__followups",
1201
1207
  style: {
1202
1208
  display: "flex",
@@ -1204,7 +1210,7 @@ var ft = ({ onSend: e, onStop: r, disabled: t = !1, placeholder: o = "Type a mes
1204
1210
  gap: "8px",
1205
1211
  marginTop: "10px"
1206
1212
  },
1207
- children: e.followUpReplies.map((d, f) => /* @__PURE__ */ a("button", {
1213
+ children: e.followUpReplies.map((d, p) => /* @__PURE__ */ a("button", {
1208
1214
  type: "button",
1209
1215
  className: "ago-message__followup-btn",
1210
1216
  disabled: !n,
@@ -1220,76 +1226,63 @@ var ft = ({ onSend: e, onStop: r, disabled: t = !1, placeholder: o = "Type a mes
1220
1226
  cursor: n ? "pointer" : "default",
1221
1227
  transition: "border-color 0.15s"
1222
1228
  },
1223
- onMouseEnter: (w) => {
1224
- w.currentTarget.style.borderColor = "#1b5fc4";
1229
+ onMouseEnter: (m) => {
1230
+ m.currentTarget.style.borderColor = "#1b5fc4";
1225
1231
  },
1226
- onMouseLeave: (w) => {
1227
- w.currentTarget.style.borderColor = "#dee3e8";
1232
+ onMouseLeave: (m) => {
1233
+ m.currentTarget.style.borderColor = "#dee3e8";
1228
1234
  },
1229
1235
  children: d
1230
- }, f))
1236
+ }, p))
1231
1237
  })
1232
1238
  ]
1233
1239
  });
1234
1240
  };
1235
- function Ft({ client: e } = {}) {
1236
- const r = O(), t = e || r;
1237
- if (!t) throw new Q("useFeedback requires an AgoClient. Either pass it as options.client or wrap your app in <AgoProvider>.", "missing_client");
1238
- const [o, n] = M({}), [s, l] = M(!1), [i, g] = M(null), d = W(/* @__PURE__ */ new Map()), f = (m) => {
1239
- const u = (d.current.get(m) ?? 0) + 1;
1240
- return d.current.set(m, u), u;
1241
- }, w = (m, u) => d.current.get(m) === u;
1241
+ function Ot({ client: e } = {}) {
1242
+ const o = $(), t = e || o;
1243
+ if (!t) throw new ae("useFeedback requires an AgoClient. Either pass it as options.client or wrap your app in <AgoProvider>.", "missing_client");
1244
+ const [r, n] = E({}), [s, c] = E(!1), [i, u] = E(null), d = D(/* @__PURE__ */ new Map()), p = (x) => {
1245
+ const f = (d.current.get(x) ?? 0) + 1;
1246
+ return d.current.set(x, f), f;
1247
+ }, m = (x, f) => d.current.get(x) === f;
1242
1248
  return {
1243
- ratings: o,
1244
- submitFeedback: T(async (m, u, y) => {
1245
- const p = f(m);
1246
- l(!0), g(null);
1249
+ ratings: r,
1250
+ submitFeedback: R(async (x, f, v) => {
1251
+ const l = p(x);
1252
+ c(!0), u(null);
1247
1253
  try {
1248
- await t.submitFeedback(m, u, y), w(m, p) && n((k) => ({
1249
- ...k,
1250
- [m]: u
1254
+ await t.submitFeedback(x, f, v), m(x, l) && n((h) => ({
1255
+ ...h,
1256
+ [x]: f
1251
1257
  }));
1252
- } catch (k) {
1253
- const x = k instanceof Error ? k : /* @__PURE__ */ new Error("Failed to submit feedback");
1254
- throw g(x), x;
1258
+ } catch (h) {
1259
+ const b = h instanceof Error ? h : /* @__PURE__ */ new Error("Failed to submit feedback");
1260
+ throw u(b), b;
1255
1261
  } finally {
1256
- l(!1);
1262
+ c(!1);
1257
1263
  }
1258
1264
  }, [t]),
1259
- submitConversationFeedback: T(async (m, u, y) => {
1260
- const p = f(m);
1261
- l(!0), g(null);
1265
+ submitConversationFeedback: R(async (x, f, v) => {
1266
+ const l = p(x);
1267
+ c(!0), u(null);
1262
1268
  try {
1263
- const k = await t.submitConversationFeedback(m, u, y);
1264
- return w(m, p) && n((x) => ({
1265
- ...x,
1266
- [k]: u
1267
- })), k;
1268
- } catch (k) {
1269
- const x = k instanceof Error ? k : /* @__PURE__ */ new Error("Failed to submit feedback");
1270
- throw g(x), x;
1269
+ const h = await t.submitConversationFeedback(x, f, v);
1270
+ return m(x, l) && n((b) => ({
1271
+ ...b,
1272
+ [h]: f
1273
+ })), h;
1274
+ } catch (h) {
1275
+ const b = h instanceof Error ? h : /* @__PURE__ */ new Error("Failed to submit feedback");
1276
+ throw u(b), b;
1271
1277
  } finally {
1272
- l(!1);
1278
+ c(!1);
1273
1279
  }
1274
1280
  }, [t]),
1275
1281
  isSubmitting: s,
1276
1282
  error: i
1277
1283
  };
1278
1284
  }
1279
- var fe = {
1280
- helpful: "Helpful",
1281
- notHelpful: "Not helpful",
1282
- whatWentWrong: "What went wrong?",
1283
- reasons: {
1284
- inaccurate: "Inaccurate",
1285
- incomplete: "Incomplete",
1286
- information_not_found: "Information not found",
1287
- technical_issue: "Technical issue"
1288
- },
1289
- commentPlaceholder: "Anything else? (optional)",
1290
- send: "Send",
1291
- thanks: "Thanks, this was reported."
1292
- }, Wt = {
1285
+ var cn = Ze.feedback, $t = {
1293
1286
  display: "inline-flex",
1294
1287
  alignItems: "center",
1295
1288
  justifyContent: "center",
@@ -1302,65 +1295,61 @@ var fe = {
1302
1295
  background: "transparent",
1303
1296
  cursor: "pointer",
1304
1297
  lineHeight: 1
1305
- }, Dt = ({ messageId: e, client: r, askWhy: t = !0, labels: o, onSubmit: n, onError: s, className: l = "" }) => {
1306
- const i = {
1307
- ...fe,
1308
- ...o,
1309
- reasons: {
1310
- ...fe.reasons,
1311
- ...o?.reasons
1312
- }
1313
- }, { ratings: g, submitFeedback: d } = Ft({ client: r }), f = g[e], [w, m] = M(!1), [u, y] = M([]), [p, k] = M(""), [x, R] = M(!1), [_, b] = M(!1), C = async (c, S) => {
1298
+ }, jt = ({ messageId: e, client: o, askWhy: t = !0, labels: r, onSubmit: n, onError: s, className: c = "" }) => {
1299
+ const i = Q(o), u = {
1300
+ ...re(i.feedback, r),
1301
+ reasons: re(i.feedback.reasons, r?.reasons)
1302
+ }, { ratings: d, submitFeedback: p } = Ot({ client: o }), m = d[e], [x, f] = E(!1), [v, l] = E([]), [h, b] = E(""), [I, N] = E(!1), [g, k] = E(!1), A = async (M, w) => {
1314
1303
  try {
1315
- return await d(e, c, S), n?.({
1304
+ return await p(e, M, w), n?.({
1316
1305
  messageId: e,
1317
- rating: c,
1318
- reasons: S?.reasons ?? [],
1319
- comment: S?.comment || void 0
1306
+ rating: M,
1307
+ reasons: w?.reasons ?? [],
1308
+ comment: w?.comment || void 0
1320
1309
  }), !0;
1321
- } catch (I) {
1322
- return s?.(I instanceof Error ? I : new Error(String(I))), !1;
1310
+ } catch (T) {
1311
+ return s?.(T instanceof Error ? T : new Error(String(T))), !1;
1323
1312
  }
1324
- }, A = (c) => {
1325
- C(c), m(c === "negative" && t && !x);
1326
- }, N = (c) => {
1327
- y((S) => S.includes(c) ? S.filter((I) => I !== c) : [...S, c]);
1328
- }, h = u.length > 0 || p.trim().length > 0, D = () => {
1329
- !h || _ || (b(!0), C(f ?? "negative", {
1330
- reasons: u,
1331
- comment: p.trim()
1332
- }).then((c) => {
1333
- b(!1), c && (R(!0), m(!1));
1313
+ }, S = (M) => {
1314
+ A(M), f(M === "negative" && t && !I);
1315
+ }, C = (M) => {
1316
+ l((w) => w.includes(M) ? w.filter((T) => T !== M) : [...w, M]);
1317
+ }, L = v.length > 0 || h.trim().length > 0, F = () => {
1318
+ !L || g || (k(!0), A(m ?? "negative", {
1319
+ reasons: v,
1320
+ comment: h.trim()
1321
+ }).then((M) => {
1322
+ k(!1), M && (N(!0), f(!1));
1334
1323
  }));
1335
1324
  };
1336
- return /* @__PURE__ */ F("div", {
1337
- className: `ago-feedback ${l}`,
1325
+ return /* @__PURE__ */ W("div", {
1326
+ className: `ago-feedback ${c}`,
1338
1327
  style: {
1339
1328
  marginTop: "6px",
1340
1329
  width: "100%",
1341
1330
  maxWidth: "85%"
1342
1331
  },
1343
1332
  children: [
1344
- /* @__PURE__ */ F("div", {
1333
+ /* @__PURE__ */ W("div", {
1345
1334
  className: "ago-feedback__actions",
1346
1335
  style: {
1347
1336
  display: "flex",
1348
1337
  alignItems: "center",
1349
1338
  gap: "2px"
1350
1339
  },
1351
- children: [/* @__PURE__ */ a(ge, {
1340
+ children: [/* @__PURE__ */ a(we, {
1352
1341
  direction: "up",
1353
- label: i.helpful,
1354
- selected: f === "positive",
1355
- onClick: () => A("positive")
1356
- }), /* @__PURE__ */ a(ge, {
1342
+ label: u.helpful,
1343
+ selected: m === "positive",
1344
+ onClick: () => S("positive")
1345
+ }), /* @__PURE__ */ a(we, {
1357
1346
  direction: "down",
1358
- label: i.notHelpful,
1359
- selected: f === "negative",
1360
- onClick: () => A("negative")
1347
+ label: u.notHelpful,
1348
+ selected: m === "negative",
1349
+ onClick: () => S("negative")
1361
1350
  })]
1362
1351
  }),
1363
- x && /* @__PURE__ */ a("div", {
1352
+ I && /* @__PURE__ */ a("div", {
1364
1353
  className: "ago-feedback__thanks",
1365
1354
  role: "status",
1366
1355
  style: {
@@ -1368,12 +1357,12 @@ var fe = {
1368
1357
  fontSize: "13px",
1369
1358
  color: "#6b6d6f"
1370
1359
  },
1371
- children: i.thanks
1360
+ children: u.thanks
1372
1361
  }),
1373
- w && !x && /* @__PURE__ */ F("div", {
1362
+ x && !I && /* @__PURE__ */ W("div", {
1374
1363
  className: "ago-feedback__panel",
1375
1364
  role: "group",
1376
- "aria-label": i.whatWentWrong,
1365
+ "aria-label": u.whatWentWrong,
1377
1366
  style: {
1378
1367
  marginTop: "8px",
1379
1368
  padding: "12px",
@@ -1389,7 +1378,7 @@ var fe = {
1389
1378
  color: "#30373e",
1390
1379
  marginBottom: "8px"
1391
1380
  },
1392
- children: i.whatWentWrong
1381
+ children: u.whatWentWrong
1393
1382
  }),
1394
1383
  /* @__PURE__ */ a("div", {
1395
1384
  className: "ago-feedback__reasons",
@@ -1399,35 +1388,35 @@ var fe = {
1399
1388
  gap: "6px",
1400
1389
  marginBottom: "8px"
1401
1390
  },
1402
- children: Oe.map((c) => {
1403
- const S = u.includes(c);
1391
+ children: Ge.map((M) => {
1392
+ const w = v.includes(M);
1404
1393
  return /* @__PURE__ */ a("button", {
1405
1394
  type: "button",
1406
1395
  className: "ago-feedback__reason",
1407
- "aria-pressed": S,
1408
- onClick: () => N(c),
1396
+ "aria-pressed": w,
1397
+ onClick: () => C(M),
1409
1398
  style: {
1410
1399
  minHeight: "44px",
1411
1400
  padding: "4px 12px",
1412
1401
  fontSize: "13px",
1413
1402
  fontFamily: "inherit",
1414
1403
  borderRadius: "999px",
1415
- border: `1px solid ${S ? "#1b5fc4" : "#dee3e8"}`,
1404
+ border: `1px solid ${w ? "#1b5fc4" : "#dee3e8"}`,
1416
1405
  backgroundColor: "transparent",
1417
- color: S ? "#1b5fc4" : "#30373e",
1406
+ color: w ? "#1b5fc4" : "#30373e",
1418
1407
  cursor: "pointer"
1419
1408
  },
1420
- children: i.reasons[c]
1421
- }, c);
1409
+ children: u.reasons[M]
1410
+ }, M);
1422
1411
  })
1423
1412
  }),
1424
1413
  /* @__PURE__ */ a("textarea", {
1425
1414
  className: "ago-feedback__comment",
1426
1415
  rows: 2,
1427
- value: p,
1428
- placeholder: i.commentPlaceholder,
1429
- "aria-label": i.commentPlaceholder,
1430
- onChange: (c) => k(c.target.value),
1416
+ value: h,
1417
+ placeholder: u.commentPlaceholder,
1418
+ "aria-label": u.commentPlaceholder,
1419
+ onChange: (M) => b(M.target.value),
1431
1420
  style: {
1432
1421
  width: "100%",
1433
1422
  boxSizing: "border-box",
@@ -1444,8 +1433,8 @@ var fe = {
1444
1433
  /* @__PURE__ */ a("button", {
1445
1434
  type: "button",
1446
1435
  className: "ago-feedback__send",
1447
- onClick: D,
1448
- disabled: !h || _,
1436
+ onClick: F,
1437
+ disabled: !L || g,
1449
1438
  style: {
1450
1439
  marginTop: "8px",
1451
1440
  minHeight: "44px",
@@ -1454,29 +1443,29 @@ var fe = {
1454
1443
  fontFamily: "inherit",
1455
1444
  borderRadius: "10px",
1456
1445
  border: "none",
1457
- backgroundColor: h ? "#03182f" : "#b5bfc8",
1446
+ backgroundColor: L ? "#03182f" : "#b5bfc8",
1458
1447
  color: "#fff",
1459
- opacity: _ ? 0.6 : 1,
1460
- cursor: h && !_ ? "pointer" : "default"
1448
+ opacity: g ? 0.6 : 1,
1449
+ cursor: L && !g ? "pointer" : "default"
1461
1450
  },
1462
- children: i.send
1451
+ children: u.send
1463
1452
  })
1464
1453
  ]
1465
1454
  })
1466
1455
  ]
1467
1456
  });
1468
- }, ge = ({ direction: e, label: r, selected: t, onClick: o }) => /* @__PURE__ */ a("button", {
1457
+ }, we = ({ direction: e, label: o, selected: t, onClick: r }) => /* @__PURE__ */ a("button", {
1469
1458
  type: "button",
1470
1459
  className: `ago-feedback__thumb ago-feedback__thumb--${e}`,
1471
- "aria-label": r,
1460
+ "aria-label": o,
1472
1461
  "aria-pressed": t,
1473
- title: r,
1474
- onClick: o,
1462
+ title: o,
1463
+ onClick: r,
1475
1464
  style: {
1476
- ...Wt,
1465
+ ...$t,
1477
1466
  color: t ? "#1b5fc4" : "#6b6d6f"
1478
1467
  },
1479
- children: /* @__PURE__ */ F("svg", {
1468
+ children: /* @__PURE__ */ W("svg", {
1480
1469
  width: "16",
1481
1470
  height: "16",
1482
1471
  viewBox: "0 0 24 24",
@@ -1495,106 +1484,106 @@ var fe = {
1495
1484
  strokeLinejoin: "round"
1496
1485
  })]
1497
1486
  })
1498
- }), en = Ve(function({ client: r, conversationId: t, title: o = "Chat", welcomeMessage: n = "Hello! How can I help you today?", placeholder: s = "Type a message...", allowFiles: l = !1, speechToText: i = !1, allowStop: g = !0, height: d = 500, logoUrl: f, showAgentName: w = !1, forms: m, feedback: u = !1, onFollowUpClick: y, className: p = "", onMessageSent: k, onMessageReceived: x, sheet: R = !1, thinkingLabel: _ = "Thinking...", functionLabels: b, showReasoning: C = !0 }, A) {
1499
- const N = W(null), h = W(!0), [D, c] = M(!0), S = W(null), { sheet: I, expand: B, collapse: G, toggle: re } = lt(R), [Ae, ee] = M(!1), te = I.compact && I.state === "peek", Ne = O(), q = r ?? Ne, { messages: P, isLoading: _e, error: oe, sendMessage: Ie, stop: Re } = ke({
1500
- client: r,
1487
+ }), dn = ot(function({ client: o, conversationId: t, title: r, welcomeMessage: n, placeholder: s, allowFiles: c = !1, speechToText: i = !1, allowStop: u = !0, height: d = 500, logoUrl: p, showAgentName: m = !1, forms: x, feedback: f = !1, onFollowUpClick: v, className: l = "", onMessageSent: h, onMessageReceived: b, sheet: I = !1, thinkingLabel: N, functionLabels: g, showReasoning: k = !0 }, A) {
1488
+ const S = Q(o), C = r ?? S.common.chat, L = n ?? S.common.welcome, F = s ?? S.common.placeholder, M = N ?? S.common.thinking, w = D(null), T = D(!0), [q, O] = E(!0), ee = D(null), { sheet: B, expand: se, collapse: X, toggle: ue } = ht(I), [Me, ie] = E(!1), le = B.compact && B.state === "peek", Te = $(), G = o ?? Te, { messages: H, isLoading: Fe, error: pe, sendMessage: Le, stop: We } = Re({
1489
+ client: o,
1501
1490
  conversationId: t
1502
1491
  });
1503
- E(() => {
1504
- if (!q || !m || m.length === 0) return;
1505
- let v = !1;
1506
- const L = [];
1507
- return Promise.all(m.map((z) => z.schema != null ? Promise.resolve(xe(z)) : he(q, z))).then((z) => {
1508
- if (!v)
1509
- for (const H of z) L.push(H.install(q));
1492
+ _(() => {
1493
+ if (!G || !x || x.length === 0) return;
1494
+ let y = !1;
1495
+ const P = [];
1496
+ return Promise.all(x.map((z) => z.schema != null ? Promise.resolve(Se(z)) : Ce(G, z))).then((z) => {
1497
+ if (!y)
1498
+ for (const j of z) P.push(j.install(G));
1510
1499
  }).catch(() => {
1511
1500
  }), () => {
1512
- v = !0, L.forEach((z) => z());
1501
+ y = !0, P.forEach((z) => z());
1513
1502
  };
1514
- }, [q, m ? JSON.stringify(m.map((v) => [
1515
- v.name,
1516
- v.schema ?? null,
1517
- v.submit ?? !1,
1518
- v.description ?? null
1519
- ])) : ""]), E(() => {
1520
- const v = N.current;
1521
- !v || !h.current || (v.scrollTop = v.scrollHeight);
1522
- }, [P]);
1523
- const Ee = () => {
1524
- const v = N.current;
1525
- v && (h.current = !0, c(!0), v.scrollTop = v.scrollHeight);
1503
+ }, [G, x ? JSON.stringify(x.map((y) => [
1504
+ y.name,
1505
+ y.schema ?? null,
1506
+ y.submit ?? !1,
1507
+ y.description ?? null
1508
+ ])) : ""]), _(() => {
1509
+ const y = w.current;
1510
+ !y || !T.current || (y.scrollTop = y.scrollHeight);
1511
+ }, [H]);
1512
+ const De = () => {
1513
+ const y = w.current;
1514
+ y && (T.current = !0, O(!0), y.scrollTop = y.scrollHeight);
1526
1515
  };
1527
- E(() => {
1528
- const v = P[P.length - 1];
1529
- v && v.role === "assistant" && v.status === "DONE" && x && x({
1530
- id: v.id,
1531
- content: v.content
1516
+ _(() => {
1517
+ const y = H[H.length - 1];
1518
+ y && y.role === "assistant" && y.status === "DONE" && b && b({
1519
+ id: y.id,
1520
+ content: y.content
1532
1521
  });
1533
- }, [P, x]), E(() => {
1534
- ee(!!te);
1535
- }, [P.length]), E(() => {
1536
- const v = S.current;
1537
- if (!I.compact || !v) return;
1538
- const L = document.documentElement;
1539
- if (I.state !== "peek") return;
1522
+ }, [H, b]), _(() => {
1523
+ ie(!!le);
1524
+ }, [H.length]), _(() => {
1525
+ const y = ee.current;
1526
+ if (!B.compact || !y) return;
1527
+ const P = document.documentElement;
1528
+ if (B.state !== "peek") return;
1540
1529
  const z = () => {
1541
- L.style.setProperty("--ago-sheet-height", `${Math.round(v.getBoundingClientRect().height)}px`);
1530
+ P.style.setProperty("--ago-sheet-height", `${Math.round(y.getBoundingClientRect().height)}px`);
1542
1531
  };
1543
1532
  z();
1544
- const H = typeof ResizeObserver == "function" ? new ResizeObserver(z) : null;
1545
- return H?.observe(v), () => H?.disconnect();
1546
- }, [I.compact, I.state]), E(() => {
1547
- I.compact || document.documentElement.style.removeProperty("--ago-sheet-height");
1548
- }, [I.compact]), E(() => () => {
1533
+ const j = typeof ResizeObserver == "function" ? new ResizeObserver(z) : null;
1534
+ return j?.observe(y), () => j?.disconnect();
1535
+ }, [B.compact, B.state]), _(() => {
1536
+ B.compact || document.documentElement.style.removeProperty("--ago-sheet-height");
1537
+ }, [B.compact]), _(() => () => {
1549
1538
  document.documentElement.style.removeProperty("--ago-sheet-height");
1550
- }, []), Ye(A, () => ({
1551
- expand: B,
1552
- collapse: G,
1553
- toggle: re,
1554
- state: I.state
1539
+ }, []), at(A, () => ({
1540
+ expand: se,
1541
+ collapse: X,
1542
+ toggle: ue,
1543
+ state: B.state
1555
1544
  }), [
1556
- B,
1557
- G,
1558
- re,
1559
- I.state
1560
- ]), E(() => {
1561
- if (!I.isModal) return;
1562
- const v = /* @__PURE__ */ Symbol("ago-react-sheet");
1563
- Ue(v);
1564
- const L = (z) => {
1545
+ se,
1546
+ X,
1547
+ ue,
1548
+ B.state
1549
+ ]), _(() => {
1550
+ if (!B.isModal) return;
1551
+ const y = /* @__PURE__ */ Symbol("ago-react-sheet");
1552
+ et(y);
1553
+ const P = (z) => {
1565
1554
  if (z.key === "Escape") {
1566
- G("user");
1555
+ X("user");
1567
1556
  return;
1568
1557
  }
1569
1558
  if (z.key !== "Tab") return;
1570
- const H = S.current;
1571
- if (!H) return;
1572
- const Y = Array.from(H.querySelectorAll('a[href],button:not([disabled]),textarea:not([disabled]),input:not([disabled]),select:not([disabled]),[tabindex]:not([tabindex="-1"])')).filter((We) => We.getClientRects().length > 0);
1573
- if (Y.length === 0) {
1559
+ const j = ee.current;
1560
+ if (!j) return;
1561
+ const ne = Array.from(j.querySelectorAll('a[href],button:not([disabled]),textarea:not([disabled]),input:not([disabled]),select:not([disabled]),[tabindex]:not([tabindex="-1"])')).filter((He) => He.getClientRects().length > 0);
1562
+ if (ne.length === 0) {
1574
1563
  z.preventDefault();
1575
1564
  return;
1576
1565
  }
1577
- const le = Y[0], ce = Y[Y.length - 1], Z = document.activeElement;
1578
- z.shiftKey && (Z === le || !H.contains(Z)) ? (z.preventDefault(), ce.focus()) : !z.shiftKey && (Z === ce || !H.contains(Z)) && (z.preventDefault(), le.focus());
1566
+ const he = ne[0], xe = ne[ne.length - 1], oe = document.activeElement;
1567
+ z.shiftKey && (oe === he || !j.contains(oe)) ? (z.preventDefault(), xe.focus()) : !z.shiftKey && (oe === xe || !j.contains(oe)) && (z.preventDefault(), he.focus());
1579
1568
  };
1580
- return document.addEventListener("keydown", L), S.current?.focus({ preventScroll: !0 }), () => {
1581
- document.removeEventListener("keydown", L), qe(v);
1569
+ return document.addEventListener("keydown", P), ee.current?.focus({ preventScroll: !0 }), () => {
1570
+ document.removeEventListener("keydown", P), Xe(y);
1582
1571
  };
1583
- }, [I.isModal, G]);
1584
- const ae = async (v, L) => (h.current = !0, c(!0), k?.(v), await Ie(v, L) !== null), j = P[P.length - 1], X = _e && j?.role === "assistant" && (j.status === "IN_PROGRESS" || j.status === "WAITING_CLIENT"), Te = T((v) => {
1585
- const L = v.functionName;
1586
- if (!(!b || !L))
1587
- return typeof b == "function" ? b(L, v.arguments ?? {}) : b[L];
1588
- }, [b]), { items: Me } = at({
1589
- client: q ?? void 0,
1590
- labelFor: Te,
1591
- includeReasoning: C
1592
- }), ie = Me.filter((v) => j?.id !== void 0 && v.messageId === j.id), J = b === !1 ? void 0 : ie[ie.length - 1]?.label, se = !!(X && J), Fe = y === !1 ? void 0 : y ?? ((v) => ae(v));
1593
- return /* @__PURE__ */ F("div", {
1594
- ref: S,
1595
- className: `ago-chat-widget ${p}`,
1596
- ...I.surface.attrs,
1597
- "data-ago-sheet-state": I.compact ? I.state : void 0,
1572
+ }, [B.isModal, X]);
1573
+ const fe = async (y, P) => (T.current = !0, O(!0), h?.(y), await Le(y, P) !== null), K = H[H.length - 1], te = Fe && K?.role === "assistant" && (K.status === "IN_PROGRESS" || K.status === "WAITING_CLIENT"), ze = R((y) => {
1574
+ const P = y.functionName;
1575
+ if (!(!g || !P))
1576
+ return typeof g == "function" ? g(P, y.arguments ?? {}) : g[P];
1577
+ }, [g]), { items: Be } = ft({
1578
+ client: G ?? void 0,
1579
+ labelFor: ze,
1580
+ includeReasoning: k
1581
+ }), ge = Be.filter((y) => K?.id !== void 0 && y.messageId === K.id), Y = g === !1 ? void 0 : ge[ge.length - 1]?.label, me = !!(te && Y), Pe = v === !1 ? void 0 : v ?? ((y) => fe(y));
1582
+ return /* @__PURE__ */ W("div", {
1583
+ ref: ee,
1584
+ className: `ago-chat-widget ${l}`,
1585
+ ...B.surface.attrs,
1586
+ "data-ago-sheet-state": B.compact ? B.state : void 0,
1598
1587
  style: {
1599
1588
  display: "flex",
1600
1589
  flexDirection: "column",
@@ -1606,10 +1595,10 @@ var fe = {
1606
1595
  fontFamily: '"IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',
1607
1596
  textAlign: "left",
1608
1597
  boxShadow: "rgba(15, 15, 15, 0.08) 0px 2px 16px 0px",
1609
- ...I.surface.style
1598
+ ...B.surface.style
1610
1599
  },
1611
1600
  children: [
1612
- !I.compact && /* @__PURE__ */ F("div", {
1601
+ !B.compact && /* @__PURE__ */ W("div", {
1613
1602
  className: "ago-chat-widget__header",
1614
1603
  style: {
1615
1604
  padding: "14px 16px",
@@ -1620,8 +1609,8 @@ var fe = {
1620
1609
  alignItems: "center",
1621
1610
  gap: "10px"
1622
1611
  },
1623
- children: [f && /* @__PURE__ */ a("img", {
1624
- src: f,
1612
+ children: [p && /* @__PURE__ */ a("img", {
1613
+ src: p,
1625
1614
  alt: "Logo",
1626
1615
  style: {
1627
1616
  height: "24px",
@@ -1633,16 +1622,16 @@ var fe = {
1633
1622
  fontSize: "15px",
1634
1623
  fontWeight: 600
1635
1624
  },
1636
- children: o
1625
+ children: C
1637
1626
  })]
1638
1627
  }),
1639
- te && /* @__PURE__ */ F("button", {
1628
+ le && /* @__PURE__ */ W("button", {
1640
1629
  type: "button",
1641
1630
  className: "ago-chat-widget__peek",
1642
1631
  "aria-expanded": !1,
1643
- "aria-label": "Open the conversation",
1632
+ "aria-label": S.common.openConversation,
1644
1633
  onClick: () => {
1645
- ee(!1), B("user");
1634
+ ie(!1), se("user");
1646
1635
  },
1647
1636
  style: {
1648
1637
  display: "flex",
@@ -1659,7 +1648,7 @@ var fe = {
1659
1648
  font: "inherit",
1660
1649
  color: "inherit"
1661
1650
  },
1662
- children: [/* @__PURE__ */ F("span", {
1651
+ children: [/* @__PURE__ */ W("span", {
1663
1652
  style: {
1664
1653
  display: "flex",
1665
1654
  alignItems: "center",
@@ -1672,9 +1661,9 @@ var fe = {
1672
1661
  opacity: 0.7
1673
1662
  },
1674
1663
  children: [
1675
- o,
1676
- Ae && /* @__PURE__ */ a("span", {
1677
- "aria-label": "New message",
1664
+ C,
1665
+ Me && /* @__PURE__ */ a("span", {
1666
+ "aria-label": S.common.newMessage,
1678
1667
  style: {
1679
1668
  width: "6px",
1680
1669
  height: "6px",
@@ -1691,13 +1680,13 @@ var fe = {
1691
1680
  children: "↑"
1692
1681
  })
1693
1682
  ]
1694
- }), X && !j?.content ? /* @__PURE__ */ F("span", {
1683
+ }), te && !K?.content ? /* @__PURE__ */ W("span", {
1695
1684
  style: {
1696
1685
  display: "flex",
1697
1686
  alignItems: "center",
1698
1687
  gap: "8px"
1699
1688
  },
1700
- children: [!J && /* @__PURE__ */ a(Se, {}), /* @__PURE__ */ a("span", {
1689
+ children: [!Y && /* @__PURE__ */ a(Ee, {}), /* @__PURE__ */ a("span", {
1701
1690
  style: {
1702
1691
  fontSize: "13px",
1703
1692
  opacity: 0.7,
@@ -1705,7 +1694,7 @@ var fe = {
1705
1694
  textOverflow: "ellipsis",
1706
1695
  whiteSpace: "nowrap"
1707
1696
  },
1708
- children: J ? Ce(J) : _
1697
+ children: Y ? Ie(Y) : M
1709
1698
  })]
1710
1699
  }) : /* @__PURE__ */ a("span", {
1711
1700
  style: {
@@ -1718,10 +1707,10 @@ var fe = {
1718
1707
  color: "inherit",
1719
1708
  minHeight: "calc(2 * 1.5 * 13px)"
1720
1709
  },
1721
- children: j?.content || n
1710
+ children: K?.content || L
1722
1711
  })]
1723
1712
  }),
1724
- I.compact && I.state === "full" && /* @__PURE__ */ F("div", {
1713
+ B.compact && B.state === "full" && /* @__PURE__ */ W("div", {
1725
1714
  className: "ago-chat-widget__sheet-header",
1726
1715
  style: {
1727
1716
  display: "flex",
@@ -1743,11 +1732,11 @@ var fe = {
1743
1732
  whiteSpace: "nowrap",
1744
1733
  textOverflow: "ellipsis"
1745
1734
  },
1746
- children: o
1735
+ children: C
1747
1736
  }), /* @__PURE__ */ a("button", {
1748
1737
  type: "button",
1749
- "aria-label": "Collapse the conversation",
1750
- onClick: () => G("user"),
1738
+ "aria-label": S.common.collapseConversation,
1739
+ onClick: () => X("user"),
1751
1740
  style: {
1752
1741
  marginLeft: "auto",
1753
1742
  flexShrink: 0,
@@ -1775,25 +1764,25 @@ var fe = {
1775
1764
  })
1776
1765
  })]
1777
1766
  }),
1778
- /* @__PURE__ */ F("div", {
1767
+ /* @__PURE__ */ W("div", {
1779
1768
  style: {
1780
1769
  position: "relative",
1781
1770
  flex: 1,
1782
- display: te ? "none" : "flex",
1771
+ display: le ? "none" : "flex",
1783
1772
  minHeight: 0
1784
1773
  },
1785
- children: [/* @__PURE__ */ F("div", {
1786
- ref: N,
1774
+ children: [/* @__PURE__ */ W("div", {
1775
+ ref: w,
1787
1776
  className: "ago-chat-widget__messages",
1788
- onScroll: (v) => {
1789
- const L = v.currentTarget, z = L.scrollHeight - L.scrollTop - L.clientHeight <= 48;
1790
- h.current = z, c(z);
1777
+ onScroll: (y) => {
1778
+ const P = y.currentTarget, z = P.scrollHeight - P.scrollTop - P.clientHeight <= 48;
1779
+ T.current = z, O(z);
1791
1780
  },
1792
1781
  role: "log",
1793
1782
  "aria-live": "polite",
1794
1783
  "aria-relevant": "additions text",
1795
1784
  "aria-atomic": !1,
1796
- "aria-busy": X,
1785
+ "aria-busy": te,
1797
1786
  style: {
1798
1787
  flex: 1,
1799
1788
  overflow: "auto",
@@ -1802,7 +1791,7 @@ var fe = {
1802
1791
  backgroundColor: "#fbfbfb"
1803
1792
  },
1804
1793
  children: [
1805
- P.length === 0 ? /* @__PURE__ */ a("div", {
1794
+ H.length === 0 ? /* @__PURE__ */ a("div", {
1806
1795
  style: {
1807
1796
  textAlign: "center",
1808
1797
  color: "#6b6d6f",
@@ -1810,21 +1799,21 @@ var fe = {
1810
1799
  fontSize: "16px",
1811
1800
  lineHeight: "1.5"
1812
1801
  },
1813
- children: n
1814
- }) : P.map((v, L) => /* @__PURE__ */ a(Mt, {
1815
- message: v,
1816
- showAgentName: w,
1817
- isLast: L === P.length - 1,
1818
- onFollowUpClick: Fe,
1819
- showStreamingDots: !se,
1820
- feedback: u && v.role === "assistant" && v.status === "DONE" && v.content ? /* @__PURE__ */ a(Dt, {
1821
- messageId: v.id,
1822
- client: r,
1823
- ...u === !0 ? {} : u
1802
+ children: L
1803
+ }) : H.map((y, P) => /* @__PURE__ */ a(Ht, {
1804
+ message: y,
1805
+ showAgentName: m,
1806
+ isLast: P === H.length - 1,
1807
+ onFollowUpClick: Pe,
1808
+ showStreamingDots: !me,
1809
+ feedback: f && y.role === "assistant" && y.status === "DONE" && y.content ? /* @__PURE__ */ a(jt, {
1810
+ messageId: y.id,
1811
+ client: o,
1812
+ ...f === !0 ? {} : f
1824
1813
  }) : void 0
1825
- }, v.id)),
1826
- se && /* @__PURE__ */ a(ut, { label: J ?? "" }),
1827
- oe && /* @__PURE__ */ a("div", {
1814
+ }, y.id)),
1815
+ me && /* @__PURE__ */ a(yt, { label: Y ?? "" }),
1816
+ pe && /* @__PURE__ */ a("div", {
1828
1817
  role: "alert",
1829
1818
  style: {
1830
1819
  padding: "10px 14px",
@@ -1835,15 +1824,15 @@ var fe = {
1835
1824
  fontSize: "13px",
1836
1825
  border: "1px solid #fecaca"
1837
1826
  },
1838
- children: oe.message
1827
+ children: pe.message
1839
1828
  }),
1840
1829
  /* @__PURE__ */ a("div", {})
1841
1830
  ]
1842
- }), !D && /* @__PURE__ */ a("button", {
1831
+ }), !q && /* @__PURE__ */ a("button", {
1843
1832
  type: "button",
1844
1833
  className: "ago-chat-widget__jump",
1845
- "aria-label": "Jump to latest message",
1846
- onClick: Ee,
1834
+ "aria-label": S.common.jumpToLatest,
1835
+ onClick: De,
1847
1836
  style: {
1848
1837
  position: "absolute",
1849
1838
  left: "50%",
@@ -1876,71 +1865,71 @@ var fe = {
1876
1865
  })
1877
1866
  })]
1878
1867
  }),
1879
- /* @__PURE__ */ a(ft, {
1880
- onSend: ae,
1881
- onStop: g ? () => {
1882
- Re();
1868
+ /* @__PURE__ */ a(wt, {
1869
+ onSend: fe,
1870
+ onStop: u ? () => {
1871
+ We();
1883
1872
  } : void 0,
1884
- disabled: X,
1885
- placeholder: s,
1886
- allowFiles: l,
1873
+ disabled: te,
1874
+ placeholder: F,
1875
+ allowFiles: c,
1887
1876
  speechToText: i,
1888
- client: q ?? void 0,
1889
- scopeKey: `${t ?? P[0]?.conversationId ?? ""}:${I.state}`
1877
+ client: G ?? void 0,
1878
+ scopeKey: `${t ?? H[0]?.conversationId ?? ""}:${B.state}`
1890
1879
  })
1891
1880
  ]
1892
1881
  });
1893
1882
  });
1894
- function zt(e = {}) {
1895
- const r = O(), t = e.client ?? r;
1896
- if (!t) throw new Q("useProactiveNudge: no AgoClient. Pass one via options.client or wrap your tree with <AgoProvider>.", "proactive_missing_client");
1897
- const [o, n] = M(null), s = W(o);
1898
- s.current = o;
1899
- const l = W(e.onExpand);
1900
- return l.current = e.onExpand, E(() => {
1883
+ function qt(e = {}) {
1884
+ const o = $(), t = e.client ?? o;
1885
+ if (!t) throw new ae("useProactiveNudge: no AgoClient. Pass one via options.client or wrap your tree with <AgoProvider>.", "proactive_missing_client");
1886
+ const [r, n] = E(null), s = D(r);
1887
+ s.current = r;
1888
+ const c = D(e.onExpand);
1889
+ return c.current = e.onExpand, _(() => {
1901
1890
  const i = (d) => {
1902
1891
  n(d), t.proactive?.shown(d);
1903
- }, g = ({ nudge: d }) => {
1904
- n((f) => f?.id === d.id ? null : f);
1892
+ }, u = ({ nudge: d }) => {
1893
+ n((p) => p?.id === d.id ? null : p);
1905
1894
  };
1906
- return t.on("nudge:ready", i), t.on("nudge:accepted", g), t.on("nudge:dismissed", g), () => {
1907
- t.off("nudge:ready", i), t.off("nudge:accepted", g), t.off("nudge:dismissed", g);
1895
+ return t.on("nudge:ready", i), t.on("nudge:accepted", u), t.on("nudge:dismissed", u), () => {
1896
+ t.off("nudge:ready", i), t.off("nudge:accepted", u), t.off("nudge:dismissed", u);
1908
1897
  };
1909
1898
  }, [t]), {
1910
- nudge: o,
1911
- accept: T(async () => {
1899
+ nudge: r,
1900
+ accept: R(async () => {
1912
1901
  const i = s.current;
1913
- i && (n(null), await t.proactive?.accept(i), (i.source === "agent" || i.goal) && l.current?.(i));
1902
+ i && (n(null), await t.proactive?.accept(i), (i.source === "agent" || i.goal) && c.current?.(i));
1914
1903
  }, [t]),
1915
- dismiss: T(() => {
1904
+ dismiss: R(() => {
1916
1905
  const i = s.current;
1917
1906
  i && (n(null), t.proactive?.dismiss(i));
1918
1907
  }, [t])
1919
1908
  };
1920
1909
  }
1921
- var tn = ({ client: e, onExpand: r, autoHideMs: t, position: o = "bottom-right", openChatLabel: n = "Open chat", className: s = "" }) => {
1922
- const { nudge: l, accept: i, dismiss: g } = zt({
1910
+ var un = ({ client: e, onExpand: o, autoHideMs: t, position: r = "bottom-right", openChatLabel: n, className: s = "" }) => {
1911
+ const c = Q(e), i = n ?? c.common.openChat, { nudge: u, accept: d, dismiss: p } = qt({
1923
1912
  client: e,
1924
- onExpand: r
1913
+ onExpand: o
1925
1914
  });
1926
- if (E(() => {
1927
- if (!l || !t) return;
1928
- const f = setTimeout(() => g(), t);
1929
- return () => clearTimeout(f);
1915
+ if (_(() => {
1916
+ if (!u || !t) return;
1917
+ const x = setTimeout(() => p(), t);
1918
+ return () => clearTimeout(x);
1930
1919
  }, [
1931
- l,
1920
+ u,
1932
1921
  t,
1933
- g
1934
- ]), !l) return null;
1935
- const d = l.source === "agent" || !!l.goal;
1936
- return /* @__PURE__ */ F("div", {
1922
+ p
1923
+ ]), !u) return null;
1924
+ const m = u.source === "agent" || !!u.goal;
1925
+ return /* @__PURE__ */ W("div", {
1937
1926
  className: `ago-nudge ${s}`,
1938
1927
  role: "status",
1939
1928
  "aria-live": "polite",
1940
1929
  style: {
1941
1930
  position: "fixed",
1942
1931
  bottom: "90px",
1943
- ...o === "bottom-left" ? { left: "20px" } : { right: "20px" },
1932
+ ...r === "bottom-left" ? { left: "20px" } : { right: "20px" },
1944
1933
  zIndex: 2147483e3,
1945
1934
  maxWidth: "320px",
1946
1935
  padding: "14px 16px",
@@ -1958,8 +1947,8 @@ var tn = ({ client: e, onExpand: r, autoHideMs: t, position: o = "bottom-right",
1958
1947
  /* @__PURE__ */ a("button", {
1959
1948
  type: "button",
1960
1949
  className: "ago-nudge__close",
1961
- "aria-label": "Dismiss",
1962
- onClick: g,
1950
+ "aria-label": c.widget.dismiss,
1951
+ onClick: p,
1963
1952
  style: {
1964
1953
  position: "absolute",
1965
1954
  top: "6px",
@@ -1977,9 +1966,9 @@ var tn = ({ client: e, onExpand: r, autoHideMs: t, position: o = "bottom-right",
1977
1966
  /* @__PURE__ */ a("div", {
1978
1967
  className: "ago-nudge__message",
1979
1968
  style: { paddingRight: "16px" },
1980
- children: l.message
1969
+ children: u.message
1981
1970
  }),
1982
- (l.action || d) && /* @__PURE__ */ F("div", {
1971
+ (u.action || m) && /* @__PURE__ */ W("div", {
1983
1972
  className: "ago-nudge__actions",
1984
1973
  style: {
1985
1974
  display: "flex",
@@ -1987,11 +1976,11 @@ var tn = ({ client: e, onExpand: r, autoHideMs: t, position: o = "bottom-right",
1987
1976
  marginTop: "10px",
1988
1977
  flexWrap: "wrap"
1989
1978
  },
1990
- children: [l.action && /* @__PURE__ */ a("button", {
1979
+ children: [u.action && /* @__PURE__ */ a("button", {
1991
1980
  type: "button",
1992
1981
  className: "ago-nudge__action",
1993
1982
  onClick: () => {
1994
- i();
1983
+ d();
1995
1984
  },
1996
1985
  style: {
1997
1986
  border: "none",
@@ -2003,12 +1992,12 @@ var tn = ({ client: e, onExpand: r, autoHideMs: t, position: o = "bottom-right",
2003
1992
  fontWeight: 600,
2004
1993
  cursor: "pointer"
2005
1994
  },
2006
- children: l.action.label
2007
- }), d && /* @__PURE__ */ a("button", {
1995
+ children: u.action.label
1996
+ }), m && /* @__PURE__ */ a("button", {
2008
1997
  type: "button",
2009
1998
  className: "ago-nudge__expand",
2010
1999
  onClick: () => {
2011
- i();
2000
+ d();
2012
2001
  },
2013
2002
  style: {
2014
2003
  border: "1px solid #dee3e8",
@@ -2020,67 +2009,67 @@ var tn = ({ client: e, onExpand: r, autoHideMs: t, position: o = "bottom-right",
2020
2009
  fontWeight: 600,
2021
2010
  cursor: "pointer"
2022
2011
  },
2023
- children: n
2012
+ children: i
2024
2013
  })]
2025
2014
  })
2026
2015
  ]
2027
2016
  });
2028
2017
  };
2029
- function Lt({ client: e, autoLoad: r = !0 } = {}) {
2030
- const t = O(), o = e || t;
2031
- if (!o) throw new Error("useConversation requires an AgoClient. Either pass it as options.client or wrap your app in <AgoProvider>.");
2032
- const [n, s] = M([]), [l, i] = M(null), [g, d] = M(!1), [f, w] = M(null), m = T(async () => {
2033
- d(!0), w(null);
2018
+ function Ut({ client: e, autoLoad: o = !0 } = {}) {
2019
+ const t = $(), r = e || t;
2020
+ if (!r) throw new Error("useConversation requires an AgoClient. Either pass it as options.client or wrap your app in <AgoProvider>.");
2021
+ const [n, s] = E([]), [c, i] = E(null), [u, d] = E(!1), [p, m] = E(null), x = R(async () => {
2022
+ d(!0), m(null);
2034
2023
  try {
2035
- const { data: p } = await o.getConversations();
2036
- s(p);
2037
- } catch (p) {
2038
- w(p instanceof Error ? p : /* @__PURE__ */ new Error("Failed to load conversations"));
2024
+ const { data: l } = await r.getConversations();
2025
+ s(l);
2026
+ } catch (l) {
2027
+ m(l instanceof Error ? l : /* @__PURE__ */ new Error("Failed to load conversations"));
2039
2028
  } finally {
2040
2029
  d(!1);
2041
2030
  }
2042
- }, [o]), u = T(async (p) => {
2043
- d(!0), w(null);
2031
+ }, [r]), f = R(async (l) => {
2032
+ d(!0), m(null);
2044
2033
  try {
2045
- i(await o.getConversation(p));
2046
- } catch (k) {
2047
- w(k instanceof Error ? k : /* @__PURE__ */ new Error("Failed to load conversation"));
2034
+ i(await r.getConversation(l));
2035
+ } catch (h) {
2036
+ m(h instanceof Error ? h : /* @__PURE__ */ new Error("Failed to load conversation"));
2048
2037
  } finally {
2049
2038
  d(!1);
2050
2039
  }
2051
- }, [o]), y = T(() => {
2040
+ }, [r]), v = R(() => {
2052
2041
  i(null);
2053
2042
  }, []);
2054
- return E(() => {
2055
- r && m();
2056
- }, [r, m]), {
2043
+ return _(() => {
2044
+ o && x();
2045
+ }, [o, x]), {
2057
2046
  conversations: n,
2058
- currentConversation: l,
2059
- isLoading: g,
2060
- error: f,
2061
- selectConversation: u,
2062
- startNewConversation: y,
2063
- refreshConversations: m
2047
+ currentConversation: c,
2048
+ isLoading: u,
2049
+ error: p,
2050
+ selectConversation: f,
2051
+ startNewConversation: v,
2052
+ refreshConversations: x
2064
2053
  };
2065
2054
  }
2066
- function nn(e = {}) {
2067
- const r = O(), t = e.client || r;
2055
+ function pn(e = {}) {
2056
+ const o = $(), t = e.client || o;
2068
2057
  if (!t) throw new Error("useChat requires an AgoClient. Either pass it as options.client or wrap your app in <AgoProvider>.");
2069
- const o = ke({
2058
+ const r = Re({
2070
2059
  client: t,
2071
2060
  conversationId: e.conversationId
2072
- }), n = Lt({
2061
+ }), n = Ut({
2073
2062
  client: t,
2074
2063
  autoLoad: e.autoLoad
2075
2064
  });
2076
2065
  return {
2077
- messages: o.messages,
2078
- isLoading: o.isLoading,
2079
- error: o.error || n.error,
2080
- sendMessage: o.sendMessage,
2081
- stop: o.stop,
2082
- clearMessages: o.clearMessages,
2083
- conversationId: o.conversationId,
2066
+ messages: r.messages,
2067
+ isLoading: r.isLoading,
2068
+ error: r.error || n.error,
2069
+ sendMessage: r.sendMessage,
2070
+ stop: r.stop,
2071
+ clearMessages: r.clearMessages,
2072
+ conversationId: r.conversationId,
2084
2073
  conversations: n.conversations,
2085
2074
  currentConversation: n.currentConversation,
2086
2075
  isConversationsLoading: n.isLoading,
@@ -2089,117 +2078,117 @@ function nn(e = {}) {
2089
2078
  refreshConversations: n.refreshConversations
2090
2079
  };
2091
2080
  }
2092
- function rn(e, r) {
2093
- const t = U(), { name: o, description: n, parameters: s, handler: l, maxResultBytes: i, requiresApproval: g, webmcp: d } = typeof e == "string" ? {
2081
+ function fn(e, o) {
2082
+ const t = V(), { name: r, description: n, parameters: s, handler: c, maxResultBytes: i, requiresApproval: u, webmcp: d } = typeof e == "string" ? {
2094
2083
  name: e,
2095
- ...r
2096
- } : e, f = W(l);
2097
- f.current = l, E(() => {
2098
- const w = (m) => f.current(m);
2099
- return t.registerFunction(o, w, {
2084
+ ...o
2085
+ } : e, p = D(c);
2086
+ p.current = c, _(() => {
2087
+ const m = (x) => p.current(x);
2088
+ return t.registerFunction(r, m, {
2100
2089
  description: n,
2101
2090
  parameters: s,
2102
2091
  maxResultBytes: i,
2103
- requiresApproval: g,
2092
+ requiresApproval: u,
2104
2093
  webmcp: d
2105
2094
  }), () => {
2106
- t.unregisterFunction(o);
2095
+ t.unregisterFunction(r);
2107
2096
  };
2108
2097
  }, [
2109
2098
  t,
2110
- o,
2099
+ r,
2111
2100
  n,
2112
2101
  JSON.stringify(s),
2113
2102
  i,
2114
- g,
2103
+ u,
2115
2104
  JSON.stringify(d ?? null)
2116
2105
  ]);
2117
2106
  }
2118
- function on(e, r, t) {
2119
- const o = U(), n = W(e);
2107
+ function gn(e, o, t) {
2108
+ const r = V(), n = D(e);
2120
2109
  n.current = e;
2121
2110
  const s = t?.catalogue;
2122
- E(() => (o.registerNavigationFunction((l) => n.current(l), r, { catalogue: s === "onDemand" ? "onDemand" : "inline" }), () => {
2123
- o.unregisterNavigationFunction();
2111
+ _(() => (r.registerNavigationFunction((c) => n.current(c), o, { catalogue: s === "onDemand" ? "onDemand" : "inline" }), () => {
2112
+ r.unregisterNavigationFunction();
2124
2113
  }), [
2125
- o,
2126
2114
  r,
2115
+ o,
2127
2116
  s
2128
2117
  ]);
2129
2118
  }
2130
- function an(e, r) {
2131
- const t = U(), o = r?.functionName ?? "setPageState", n = r?.requiresApproval, s = r?.data !== void 0, l = r?.data?.description, i = r?.data?.maxResultBytes, g = r?.settleTimeoutMs, d = W(e);
2119
+ function mn(e, o) {
2120
+ const t = V(), r = o?.functionName ?? "setPageState", n = o?.requiresApproval, s = o?.data !== void 0, c = o?.data?.description, i = o?.data?.maxResultBytes, u = o?.settleTimeoutMs, d = D(e);
2132
2121
  d.current = e;
2133
- const f = W(r);
2134
- f.current = r, E(() => {
2135
- const w = d.current.map((u) => {
2136
- const y = () => d.current.find((p) => p.name === u.name) ?? u;
2122
+ const p = D(o);
2123
+ p.current = o, _(() => {
2124
+ const m = d.current.map((f) => {
2125
+ const v = () => d.current.find((l) => l.name === f.name) ?? f;
2137
2126
  return {
2138
- name: u.name,
2139
- description: u.description,
2140
- schema: u.schema,
2141
- clearable: u.clearable,
2142
- get: u.get ? () => y().get?.() : void 0,
2143
- set: (p) => y().set(p)
2127
+ name: f.name,
2128
+ description: f.description,
2129
+ schema: f.schema,
2130
+ clearable: f.clearable,
2131
+ get: f.get ? () => v().get?.() : void 0,
2132
+ set: (l) => v().set(l)
2144
2133
  };
2145
- }), m = s ? {
2146
- description: l ?? "What the page is currently showing.",
2134
+ }), x = s ? {
2135
+ description: c ?? "What the page is currently showing.",
2147
2136
  maxResultBytes: i,
2148
- get: () => f.current?.data?.get(),
2149
- isLoading: () => f.current?.data?.isLoading?.() ?? !1
2137
+ get: () => p.current?.data?.get(),
2138
+ isLoading: () => p.current?.data?.isLoading?.() ?? !1
2150
2139
  } : void 0;
2151
- return t.registerPageStateFunction(w, {
2152
- functionName: o,
2140
+ return t.registerPageStateFunction(m, {
2141
+ functionName: r,
2153
2142
  requiresApproval: n,
2154
- data: m,
2155
- settleTimeoutMs: g
2143
+ data: x,
2144
+ settleTimeoutMs: u
2156
2145
  }), () => {
2157
- t.unregisterPageStateFunction(o);
2146
+ t.unregisterPageStateFunction(r);
2158
2147
  };
2159
2148
  }, [
2160
2149
  t,
2161
- o,
2150
+ r,
2162
2151
  n,
2163
2152
  s,
2164
- l,
2153
+ c,
2165
2154
  i,
2166
- g,
2167
- JSON.stringify(e.map((w) => ({
2168
- name: w.name,
2169
- description: w.description,
2170
- schema: w.schema,
2171
- clearable: w.clearable
2155
+ u,
2156
+ JSON.stringify(e.map((m) => ({
2157
+ name: m.name,
2158
+ description: m.description,
2159
+ schema: m.schema,
2160
+ clearable: m.clearable
2172
2161
  })))
2173
2162
  ]);
2174
2163
  }
2175
- function sn(e) {
2176
- const r = U(), t = W(e);
2177
- t.current = e, E(() => $e(r, () => t.current), [r]);
2164
+ function hn(e) {
2165
+ const o = V(), t = D(e);
2166
+ t.current = e, _(() => Je(o, () => t.current), [o]);
2178
2167
  }
2179
- function ln(e = {}) {
2180
- const r = O(), t = e.client || r;
2181
- if (!t) throw new Q("useAgoActivityLog requires an AgoClient. Either pass it as options.client or wrap your app in <AgoProvider>.", "provider_missing_client");
2182
- const [o, n] = M(() => t.getRecentActivity());
2183
- E(() => {
2168
+ function xn(e = {}) {
2169
+ const o = $(), t = e.client || o;
2170
+ if (!t) throw new ae("useAgoActivityLog requires an AgoClient. Either pass it as options.client or wrap your app in <AgoProvider>.", "provider_missing_client");
2171
+ const [r, n] = E(() => t.getRecentActivity());
2172
+ _(() => {
2184
2173
  n(t.getRecentActivity());
2185
2174
  const i = () => n(t.getRecentActivity());
2186
2175
  return t.on("activity:recorded", i), () => t.off("activity:recorded", i);
2187
2176
  }, [t]);
2188
- const s = T((i) => t.recordActivity(i), [t]), l = T(() => {
2177
+ const s = R((i) => t.recordActivity(i), [t]), c = R(() => {
2189
2178
  t.clearActivity(), n([]);
2190
2179
  }, [t]);
2191
2180
  return {
2192
- entries: o,
2193
- latest: o.length > 0 ? o[o.length - 1] : void 0,
2181
+ entries: r,
2182
+ latest: r.length > 0 ? r[r.length - 1] : void 0,
2194
2183
  record: s,
2195
- clear: l
2184
+ clear: c
2196
2185
  };
2197
2186
  }
2198
- function cn(e, r) {
2199
- const t = U(), o = Xe(), n = r ?? o, s = W(e);
2187
+ function bn(e, o) {
2188
+ const t = V(), r = rt(), n = o ?? r, s = D(e);
2200
2189
  s.current = e;
2201
- const l = typeof e == "function";
2202
- E(() => {
2190
+ const c = typeof e == "function";
2191
+ _(() => {
2203
2192
  if (typeof s.current == "function") {
2204
2193
  const i = () => s.current();
2205
2194
  return t.addDynamicContext(n, i), () => {
@@ -2212,74 +2201,74 @@ function cn(e, r) {
2212
2201
  }, [
2213
2202
  t,
2214
2203
  n,
2215
- l,
2216
- l ? "" : JSON.stringify(e)
2204
+ c,
2205
+ c ? "" : JSON.stringify(e)
2217
2206
  ]);
2218
2207
  }
2219
- function Pt(e) {
2220
- return ye(e.subscribe, e.get, e.get);
2208
+ function Kt(e) {
2209
+ return ce(e.subscribe, e.get, e.get);
2221
2210
  }
2222
- var me = {
2211
+ var ke = {
2223
2212
  missing: [],
2224
2213
  complete: !1
2225
2214
  };
2226
- function dn(e) {
2227
- const r = U(), t = e.schema != null, o = JSON.stringify(e.schema ?? null), n = e.submit, s = n ? typeof n == "string" ? `client:${n}` : n.via === "backend" ? "backend" : "handler" in n ? "client:handler" : `client:${n.url}` : "none", l = JSON.stringify(e.initialValues ?? null), i = $(() => t ? xe(e) : null, [
2215
+ function yn(e) {
2216
+ const o = V(), t = e.schema != null, r = JSON.stringify(e.schema ?? null), n = e.submit, s = n ? typeof n == "string" ? `client:${n}` : n.via === "backend" ? "backend" : "handler" in n ? "client:handler" : `client:${n.url}` : "none", c = JSON.stringify(e.initialValues ?? null), i = U(() => t ? Se(e) : null, [
2228
2217
  t,
2229
2218
  e.name,
2230
- o,
2219
+ r,
2231
2220
  s,
2232
- l,
2221
+ c,
2233
2222
  e.autoSubmit
2234
- ]), [g, d] = M({
2223
+ ]), [u, d] = E({
2235
2224
  collector: null,
2236
2225
  loading: !t,
2237
2226
  error: null
2238
2227
  });
2239
- E(() => {
2228
+ _(() => {
2240
2229
  if (t) return;
2241
- let R = !1;
2230
+ let I = !1;
2242
2231
  return d({
2243
2232
  collector: null,
2244
2233
  loading: !0,
2245
2234
  error: null
2246
- }), he(r, e).then((_) => {
2247
- R || d({
2248
- collector: _,
2235
+ }), Ce(o, e).then((N) => {
2236
+ I || d({
2237
+ collector: N,
2249
2238
  loading: !1,
2250
2239
  error: null
2251
2240
  });
2252
- }).catch((_) => {
2253
- R || d({
2241
+ }).catch((N) => {
2242
+ I || d({
2254
2243
  collector: null,
2255
2244
  loading: !1,
2256
- error: _ instanceof Error ? _ : new Error(String(_))
2245
+ error: N instanceof Error ? N : new Error(String(N))
2257
2246
  });
2258
2247
  }), () => {
2259
- R = !0;
2248
+ I = !0;
2260
2249
  };
2261
2250
  }, [
2262
- r,
2251
+ o,
2263
2252
  t,
2264
2253
  e.name,
2265
2254
  s,
2266
- l,
2255
+ c,
2267
2256
  e.autoSubmit
2268
2257
  ]);
2269
- const f = t ? i : g.collector, w = t ? !1 : g.loading, m = t ? null : g.error;
2270
- E(() => {
2271
- if (f)
2272
- return f.install(r);
2273
- }, [r, f]);
2274
- const u = $(() => Le({
2258
+ const p = t ? i : u.collector, m = t ? !1 : u.loading, x = t ? null : u.error;
2259
+ _(() => {
2260
+ if (p)
2261
+ return p.install(o);
2262
+ }, [o, p]);
2263
+ const f = U(() => je({
2275
2264
  values: e.initialValues ?? {},
2276
2265
  submitted: !1
2277
- }), [l]), y = Pt(f?.store ?? u), p = $(() => f?.getStatus() ?? me, [y, f]), k = $(() => ({
2278
- ...y,
2279
- ...p
2280
- }), [y, p]), x = $(() => ({
2266
+ }), [c]), v = Kt(p?.store ?? f), l = U(() => p?.getStatus() ?? ke, [v, p]), h = U(() => ({
2267
+ ...v,
2268
+ ...l
2269
+ }), [v, l]), b = U(() => ({
2281
2270
  name: e.name,
2282
- store: u,
2271
+ store: f,
2283
2272
  functions: [],
2284
2273
  contextKey: `form:${e.name}`,
2285
2274
  contextProvider: () => ({
@@ -2300,52 +2289,52 @@ function dn(e) {
2300
2289
  ok: !1,
2301
2290
  error: "Form definition not loaded yet."
2302
2291
  }),
2303
- getValues: () => u.get().values,
2292
+ getValues: () => f.get().values,
2304
2293
  setValues: () => {
2305
2294
  },
2306
2295
  reset: () => {
2307
2296
  },
2308
- getStatus: () => me
2309
- }), [e.name, u]);
2297
+ getStatus: () => ke
2298
+ }), [e.name, f]);
2310
2299
  return {
2311
- ...f ?? x,
2312
- state: k,
2313
- loading: w,
2314
- error: m
2300
+ ...p ?? b,
2301
+ state: h,
2302
+ loading: m,
2303
+ error: x
2315
2304
  };
2316
2305
  }
2317
2306
  export {
2318
- tn as AgoNudge,
2319
- Qt as AgoProvider,
2320
- ft as ChatInput,
2321
- en as ChatWidget,
2322
- fe as DEFAULT_MESSAGE_FEEDBACK_LABELS,
2323
- Jt as DEFAULT_SPEECH_TO_TEXT_LABELS,
2324
- Oe as FEEDBACK_REASONS,
2325
- Rt as Markdown,
2326
- Mt as Message,
2327
- Dt as MessageFeedback,
2328
- pt as SpeechToTextButton,
2329
- xe as createFormCollector,
2330
- Kt as createMockClient,
2331
- jt as deriveFormStatus,
2332
- he as loadFormCollector,
2333
- tt as useAgo,
2334
- at as useAgoActivity,
2335
- ln as useAgoActivityLog,
2336
- sn as useAgoAutoContinueAfterNavigation,
2337
- U as useAgoClient,
2338
- cn as useAgoContext,
2339
- rn as useAgoFunction,
2340
- on as useAgoNavigation,
2341
- an as useAgoPageState,
2342
- Pt as useAgoStore,
2343
- nn as useChat,
2344
- Lt as useConversation,
2345
- Ft as useFeedback,
2346
- dn as useFormCollector,
2347
- ke as useMessages,
2348
- O as useOptionalAgoClient,
2349
- zt as useProactiveNudge,
2350
- lt as useSheet
2307
+ un as AgoNudge,
2308
+ ln as AgoProvider,
2309
+ wt as ChatInput,
2310
+ dn as ChatWidget,
2311
+ cn as DEFAULT_MESSAGE_FEEDBACK_LABELS,
2312
+ nn as DEFAULT_SPEECH_TO_TEXT_LABELS,
2313
+ Ge as FEEDBACK_REASONS,
2314
+ zt as Markdown,
2315
+ Ht as Message,
2316
+ jt as MessageFeedback,
2317
+ vt as SpeechToTextButton,
2318
+ Se as createFormCollector,
2319
+ Qt as createMockClient,
2320
+ Yt as deriveFormStatus,
2321
+ Ce as loadFormCollector,
2322
+ ct as useAgo,
2323
+ ft as useAgoActivity,
2324
+ xn as useAgoActivityLog,
2325
+ hn as useAgoAutoContinueAfterNavigation,
2326
+ V as useAgoClient,
2327
+ bn as useAgoContext,
2328
+ fn as useAgoFunction,
2329
+ gn as useAgoNavigation,
2330
+ mn as useAgoPageState,
2331
+ Kt as useAgoStore,
2332
+ pn as useChat,
2333
+ Ut as useConversation,
2334
+ Ot as useFeedback,
2335
+ yn as useFormCollector,
2336
+ Re as useMessages,
2337
+ $ as useOptionalAgoClient,
2338
+ qt as useProactiveNudge,
2339
+ ht as useSheet
2351
2340
  };