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