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