@useago/sdk 1.5.2 → 1.5.3

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 (50) hide show
  1. package/dist/AgoClient-BGkFSNZF.cjs +8 -0
  2. package/dist/AgoClient-CW-BLT1_.js +1542 -0
  3. package/dist/angular.cjs +1 -1
  4. package/dist/angular.d.cts +311 -0
  5. package/dist/angular.d.ts +311 -0
  6. package/dist/angular.js +2 -2
  7. package/dist/createConversationSession-BCb0D6bt.cjs +1 -0
  8. package/dist/{createConversationSession-DPrrr70o.js → createConversationSession-C7cnnWKW.js} +3 -3
  9. package/dist/createFormCollector-iCDwAwYJ.js +279 -0
  10. package/dist/createFormCollector-t_fGyuTD.cjs +1 -0
  11. package/dist/createMockClient-Br0TWgLO.js +97 -0
  12. package/dist/createMockClient-BwNLPjeT.cjs +1 -0
  13. package/dist/devtools.d.cts +311 -0
  14. package/dist/devtools.d.ts +311 -0
  15. package/dist/functions-IGSjjvF4.cjs +1 -0
  16. package/dist/helpers.cjs +1 -1
  17. package/dist/helpers.js +1 -1
  18. package/dist/index.cjs +1 -1
  19. package/dist/index.d.cts +510 -0
  20. package/dist/index.d.ts +510 -0
  21. package/dist/index.js +95 -90
  22. package/dist/react.cjs +3 -3
  23. package/dist/react.d.cts +375 -0
  24. package/dist/react.d.ts +375 -0
  25. package/dist/react.js +559 -422
  26. package/dist/rolldown-runtime-16Nf8qvH.cjs +1 -0
  27. package/dist/testing.cjs +1 -1
  28. package/dist/testing.d.cts +311 -0
  29. package/dist/testing.d.ts +311 -0
  30. package/dist/testing.js +1 -1
  31. package/dist/vue.cjs +1 -1
  32. package/dist/vue.d.cts +332 -0
  33. package/dist/vue.d.ts +332 -0
  34. package/dist/vue.js +133 -110
  35. package/dist/widget.cjs +1 -1
  36. package/dist/widget.d.cts +308 -0
  37. package/dist/widget.d.ts +308 -0
  38. package/dist/widget.js +7 -7
  39. package/package.json +1 -1
  40. package/dist/AgoClient-5VGybmvz.cjs +0 -8
  41. package/dist/AgoClient-DXrH2AMi.js +0 -964
  42. package/dist/createConversationSession-0WTqcCLK.cjs +0 -1
  43. package/dist/createFormCollector-1GKKwQV_.cjs +0 -1
  44. package/dist/createFormCollector-DYh90kiG.js +0 -305
  45. package/dist/createMockClient-C-wrjb2C.cjs +0 -1
  46. package/dist/createMockClient-we-XoPom.js +0 -79
  47. package/dist/functions-CPs7omgM.cjs +0 -1
  48. /package/dist/{autoContinue-CP9pJR-V.cjs → autoContinue-CcCTva-D.cjs} +0 -0
  49. /package/dist/{autoContinue-CC8K9mBU.js → autoContinue-D3Mmaaca.js} +0 -0
  50. /package/dist/{functions-tzyOZNp6.js → functions-CApuQZ2b.js} +0 -0
package/dist/react.js CHANGED
@@ -1,20 +1,20 @@
1
- import { a as V, i as Y, m as X, o as Z, s as Q, t as ee } from "./AgoClient-DXrH2AMi.js";
2
- import { t as te } from "./autoContinue-CC8K9mBU.js";
3
- import { i as ne, n as He, r as O, t as j } from "./createFormCollector-DYh90kiG.js";
4
- import { t as qe } from "./createMockClient-we-XoPom.js";
5
- import re, { createContext as oe, useCallback as R, useContext as B, useEffect as N, useId as ae, useMemo as D, useRef as T, useState as E, useSyncExternalStore as se } from "react";
6
- import { Fragment as G, jsx as l, jsxs as F } from "react/jsx-runtime";
1
+ import { a as Y, b as q, h as X, i as Z, o as Q, s as ee, t as te } from "./AgoClient-CW-BLT1_.js";
2
+ import { t as ne } from "./autoContinue-D3Mmaaca.js";
3
+ import { n as He, r as j, t as B } from "./createFormCollector-iCDwAwYJ.js";
4
+ import { t as qe } from "./createMockClient-Br0TWgLO.js";
5
+ import re, { createContext as oe, useCallback as R, useContext as G, useEffect as A, useId as ae, useMemo as W, useRef as _, useState as E, useSyncExternalStore as se } from "react";
6
+ import { Fragment as U, jsx as l, jsxs as M } from "react/jsx-runtime";
7
7
  import ie from "react-markdown";
8
8
  import le from "remark-gfm";
9
9
  function ce(e) {
10
- const [t, r] = E(!1), o = T(null), n = D(() => {
10
+ const [r, t] = E(!1), o = _(null), n = W(() => {
11
11
  if (o.current && (o.current.destroy(), o.current = null), !e) return null;
12
- const s = new ee(e);
12
+ const s = new te(e);
13
13
  return o.current = s, s;
14
14
  }, [e?.baseUrl, e?.widgetId]);
15
- return N(() => (r(!0), () => {
15
+ return A(() => (n && o.current === null && (o.current = n, n.reviveAfterDestroy()), t(!0), () => {
16
16
  o.current?.destroy(), o.current = null;
17
- }), [n]), N(() => {
17
+ }), [n]), A(() => {
18
18
  o.current && e && o.current.updateConfig({
19
19
  agent: e.agent,
20
20
  defaultAgentId: e.defaultAgentId,
@@ -34,91 +34,91 @@ function ce(e) {
34
34
  e?.warnOnEmptyReply
35
35
  ]), {
36
36
  client: n,
37
- isReady: t
37
+ isReady: r
38
38
  };
39
39
  }
40
- var z = oe(null), Ke = ({ children: e, client: t, tools: r, helpers: o, pageContext: n, ...s }) => {
41
- const { client: f } = ce(t ? null : s), i = t || f;
42
- return N(() => {
43
- if (!(!r || r.length === 0)) {
44
- for (const m of r) i.register(m);
40
+ var L = oe(null), Ke = ({ children: e, client: r, tools: t, helpers: o, pageContext: n, ...s }) => {
41
+ const { client: c } = ce(r ? null : s), a = r || c;
42
+ return A(() => {
43
+ if (!(!t || t.length === 0)) {
44
+ for (const f of t) a.register(f);
45
45
  return () => {
46
- for (const m of r) i.unregisterFunction(m.name);
46
+ for (const f of t) a.unregisterFunction(f.name);
47
47
  };
48
48
  }
49
- }, [i, r]), N(() => {
49
+ }, [a, t]), A(() => {
50
50
  if (!o) return;
51
- const m = [];
52
- return import("./functions-tzyOZNp6.js").then((u) => u.n).then((u) => {
51
+ const f = [];
52
+ return import("./functions-CApuQZ2b.js").then((d) => d.n).then((d) => {
53
53
  for (const [g, C] of Object.entries(o)) {
54
- const A = u[g];
55
- if (!A) {
54
+ const N = d[g];
55
+ if (!N) {
56
56
  console.warn(`[AGO] Unknown helper: "${g}"`);
57
57
  continue;
58
58
  }
59
- const S = C === !0 ? A : {
60
- ...A,
59
+ const S = C === !0 ? N : {
60
+ ...N,
61
61
  handler: C
62
62
  };
63
- i.register(S), m.push(S.name);
63
+ a.register(S), f.push(S.name);
64
64
  }
65
65
  }), () => {
66
- for (const u of m) i.unregisterFunction(u);
66
+ for (const d of f) a.unregisterFunction(d);
67
67
  };
68
- }, [i, o]), N(() => {
69
- n === "auto" && i.enableAutoPageContext();
70
- }, [i, n]), /* @__PURE__ */ l(z.Provider, {
71
- value: i,
68
+ }, [a, o]), A(() => {
69
+ n === "auto" && a.enableAutoPageContext();
70
+ }, [a, n]), /* @__PURE__ */ l(L.Provider, {
71
+ value: a,
72
72
  children: e
73
73
  });
74
74
  };
75
- function W() {
76
- const e = B(z);
75
+ function D() {
76
+ const e = G(L);
77
77
  if (!e) throw new Error('useAgoClient must be used within an <AgoProvider>. Wrap your component tree with <AgoProvider baseUrl="...">.');
78
78
  return e;
79
79
  }
80
- function L() {
81
- return B(z);
80
+ function z() {
81
+ return G(L);
82
82
  }
83
- function K({ client: e, conversationId: t } = {}) {
84
- const r = L(), o = e || r;
83
+ function K({ client: e, conversationId: r } = {}) {
84
+ const t = z(), o = e || t;
85
85
  if (!o) throw new Error("useMessages requires an AgoClient. Either pass it as options.client or wrap your app in <AgoProvider>.");
86
- const [n, s] = E([]), [f, i] = E(t), [m, u] = E(!1), [g, C] = E(null);
87
- N(() => {
88
- t && t !== f && (i(t), A(t));
89
- }, [t]);
90
- const A = async (S) => {
86
+ const [n, s] = E([]), [c, a] = E(r), [f, d] = E(!1), [g, C] = E(null);
87
+ A(() => {
88
+ r && r !== c && (a(r), N(r));
89
+ }, [r]);
90
+ const N = async (S) => {
91
91
  try {
92
92
  s((await o.getMessages(S)).filter((k) => !k.hidden));
93
93
  } catch (k) {
94
94
  C(k instanceof Error ? k : /* @__PURE__ */ new Error("Failed to load messages"));
95
95
  }
96
96
  };
97
- return N(() => {
98
- const S = (c) => c === "IN_PROGRESS" || c === "WAITING_CLIENT", k = (c) => {
99
- f || i(c.conversationId), u(!0), s((h) => {
100
- const w = h.findIndex((b) => b.id === c.messageId);
101
- return w >= 0 ? h.map((b, _) => _ === w ? {
97
+ return A(() => {
98
+ const S = (u) => u === "IN_PROGRESS" || u === "WAITING_CLIENT", k = (u) => {
99
+ c || a(u.conversationId), d(!0), s((h) => {
100
+ const w = h.findIndex((b) => b.id === u.messageId);
101
+ return w >= 0 ? h.map((b, T) => T === w ? {
102
102
  ...b,
103
103
  status: "IN_PROGRESS"
104
104
  } : b) : h.some((b) => b.role === "assistant" && S(b.status)) ? h : [...h, {
105
- id: c.messageId,
106
- conversationId: c.conversationId,
105
+ id: u.messageId,
106
+ conversationId: u.conversationId,
107
107
  content: "",
108
108
  role: "assistant",
109
109
  status: "IN_PROGRESS",
110
110
  createdAt: /* @__PURE__ */ new Date()
111
111
  }];
112
112
  });
113
- }, d = (c) => {
113
+ }, p = (u) => {
114
114
  s((h) => {
115
- const w = h.findIndex((b) => b.id === c.messageId);
116
- return w < 0 ? h : h.map((b, _) => _ === w ? {
115
+ const w = h.findIndex((b) => b.id === u.messageId);
116
+ return w < 0 ? h : h.map((b, T) => T === w ? {
117
117
  ...b,
118
- content: b.content + c.content
118
+ content: b.content + u.content
119
119
  } : b);
120
120
  });
121
- }, x = (c) => {
121
+ }, x = (u) => {
122
122
  s((h) => {
123
123
  let w = -1;
124
124
  for (let b = h.length - 1; b >= 0; b--) if (h[b].role === "assistant" && S(h[b].status)) {
@@ -129,103 +129,103 @@ function K({ client: e, conversationId: t } = {}) {
129
129
  ...h.slice(0, w),
130
130
  {
131
131
  ...h[w],
132
- ...c
132
+ ...u
133
133
  },
134
134
  ...h.slice(w + 1)
135
135
  ];
136
136
  });
137
- }, a = (c) => {
137
+ }, i = (u) => {
138
138
  s((h) => {
139
- const w = h.findIndex((b) => b.id === c.id);
139
+ const w = h.findIndex((b) => b.id === u.id);
140
140
  return w >= 0 ? [
141
141
  ...h.slice(0, w),
142
- c,
142
+ u,
143
143
  ...h.slice(w + 1)
144
- ] : [...h, c];
145
- }), u(!1);
146
- }, v = (c) => {
147
- C(new Error(c.error)), u(!1);
144
+ ] : [...h, u];
145
+ }), d(!1);
146
+ }, v = (u) => {
147
+ C(new Error(u.error)), d(!1);
148
148
  };
149
- return o.on("message:start", k), o.on("message:chunk", d), o.on("message:answer-complete", x), o.on("message:complete", a), o.on("message:error", v), () => {
150
- o.off("message:start", k), o.off("message:chunk", d), o.off("message:answer-complete", x), o.off("message:complete", a), o.off("message:error", v);
149
+ return o.on("message:start", k), o.on("message:chunk", p), o.on("message:answer-complete", x), o.on("message:complete", i), o.on("message:error", v), () => {
150
+ o.off("message:start", k), o.off("message:chunk", p), o.off("message:answer-complete", x), o.off("message:complete", i), o.off("message:error", v);
151
151
  };
152
- }, [o, f]), {
152
+ }, [o, c]), {
153
153
  messages: n,
154
- isLoading: m,
154
+ isLoading: f,
155
155
  error: g,
156
156
  sendMessage: R(async (S, k) => {
157
- u(!0), C(null);
158
- const d = {
157
+ d(!0), C(null);
158
+ const p = {
159
159
  id: `temp-${Date.now()}`,
160
- conversationId: f || "",
160
+ conversationId: c || "",
161
161
  content: S,
162
162
  role: "user",
163
163
  status: "DONE",
164
- attachments: k && k.length > 0 ? Y(k) : void 0,
164
+ attachments: k && k.length > 0 ? Z(k) : void 0,
165
165
  createdAt: /* @__PURE__ */ new Date()
166
166
  }, x = {
167
167
  id: `temp-assistant-${Date.now()}`,
168
- conversationId: f || "",
168
+ conversationId: c || "",
169
169
  content: "",
170
170
  role: "assistant",
171
171
  status: "IN_PROGRESS",
172
172
  createdAt: /* @__PURE__ */ new Date()
173
173
  };
174
- s((a) => [
175
- ...a,
176
- d,
174
+ s((i) => [
175
+ ...i,
176
+ p,
177
177
  x
178
178
  ]);
179
179
  try {
180
- const a = await o.sendMessage(S, {
181
- conversationId: f,
180
+ const i = await o.sendMessage(S, {
181
+ conversationId: c,
182
182
  files: k
183
183
  });
184
- return a.conversationId && !f && i(a.conversationId), s((v) => {
185
- const c = v.filter((w) => !w.id.startsWith("temp-")), h = {
186
- ...d,
187
- id: d.id.replace("temp-", "user-"),
188
- conversationId: a.conversationId
184
+ return i.conversationId && !c && a(i.conversationId), s((v) => {
185
+ const u = v.filter((w) => !w.id.startsWith("temp-")), h = {
186
+ ...p,
187
+ id: p.id.replace("temp-", "user-"),
188
+ conversationId: i.conversationId
189
189
  };
190
- return c.some((w) => w.id === a.id) ? [...c, h].sort((w, b) => new Date(w.createdAt).getTime() - new Date(b.createdAt).getTime()) : [
191
- ...c,
190
+ return u.some((w) => w.id === i.id) ? [...u, h].sort((w, b) => new Date(w.createdAt).getTime() - new Date(b.createdAt).getTime()) : [
191
+ ...u,
192
192
  h,
193
- a
193
+ i
194
194
  ];
195
- }), a;
196
- } catch (a) {
197
- return C(a instanceof Error ? a : /* @__PURE__ */ new Error("Failed to send message")), u(!1), s((v) => v.filter((c) => !c.id.startsWith("temp-"))), null;
195
+ }), i;
196
+ } catch (i) {
197
+ return C(i instanceof Error ? i : /* @__PURE__ */ new Error("Failed to send message")), d(!1), s((v) => v.filter((u) => !u.id.startsWith("temp-"))), null;
198
198
  }
199
- }, [o, f]),
199
+ }, [o, c]),
200
200
  clearMessages: R(() => {
201
- s([]), i(void 0), C(null);
201
+ s([]), a(void 0), C(null);
202
202
  }, []),
203
- conversationId: f
203
+ conversationId: c
204
204
  };
205
205
  }
206
- var de = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", allowFiles: o = !1, className: n = "" }) => {
207
- const [s, f] = E(""), [i, m] = E([]), u = T(null), g = T(null), C = R(() => {
208
- const a = g.current;
209
- if (!a) return;
206
+ var de = ({ onSend: e, disabled: r = !1, placeholder: t = "Type a message...", allowFiles: o = !1, className: n = "" }) => {
207
+ const [s, c] = E(""), [a, f] = E([]), d = _(null), g = _(null), C = R(() => {
208
+ const i = g.current;
209
+ if (!i) return;
210
210
  const v = 110;
211
- a.style.height = "auto", a.style.height = `${Math.min(a.scrollHeight + 2, v)}px`, a.style.overflowY = a.scrollHeight + 2 > v ? "auto" : "hidden";
212
- }, []), A = R((a) => {
213
- a.preventDefault(), (s.trim() || i.length > 0) && (e(s.trim(), i.length > 0 ? i : void 0), f(""), m([]), requestAnimationFrame(C));
211
+ i.style.height = "auto", i.style.height = `${Math.min(i.scrollHeight + 2, v)}px`, i.style.overflowY = i.scrollHeight + 2 > v ? "auto" : "hidden";
212
+ }, []), N = R((i) => {
213
+ i.preventDefault(), (s.trim() || a.length > 0) && (e(s.trim(), a.length > 0 ? a : void 0), c(""), f([]), requestAnimationFrame(C));
214
214
  }, [
215
215
  s,
216
- i,
216
+ a,
217
217
  e,
218
218
  C
219
- ]), S = R((a) => {
220
- a.key === "Enter" && !a.shiftKey && (a.preventDefault(), A(a));
221
- }, [A]), k = R((a) => {
222
- const v = Array.from(a.target.files || []);
223
- m((c) => [...c, ...v]);
224
- }, []), d = R((a) => {
225
- m((v) => v.filter((c, h) => h !== a));
226
- }, []), x = s.trim() || i.length > 0;
227
- return /* @__PURE__ */ F("form", {
228
- onSubmit: A,
219
+ ]), S = R((i) => {
220
+ i.key === "Enter" && !i.shiftKey && (i.preventDefault(), N(i));
221
+ }, [N]), k = R((i) => {
222
+ const v = Array.from(i.target.files || []);
223
+ f((u) => [...u, ...v]);
224
+ }, []), p = R((i) => {
225
+ f((v) => v.filter((u, h) => h !== i));
226
+ }, []), x = s.trim() || a.length > 0;
227
+ return /* @__PURE__ */ M("form", {
228
+ onSubmit: N,
229
229
  className: `ago-chat-input ${n}`,
230
230
  style: {
231
231
  display: "flex",
@@ -235,14 +235,14 @@ var de = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
235
235
  borderTop: "1px solid #dee3e8",
236
236
  backgroundColor: "#fff"
237
237
  },
238
- children: [i.length > 0 && /* @__PURE__ */ l("div", {
238
+ children: [a.length > 0 && /* @__PURE__ */ l("div", {
239
239
  className: "ago-chat-input__files",
240
240
  style: {
241
241
  display: "flex",
242
242
  flexWrap: "wrap",
243
243
  gap: "6px"
244
244
  },
245
- children: i.map((a, v) => /* @__PURE__ */ F("div", {
245
+ children: a.map((i, v) => /* @__PURE__ */ M("div", {
246
246
  style: {
247
247
  display: "flex",
248
248
  alignItems: "center",
@@ -260,11 +260,11 @@ var de = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
260
260
  textOverflow: "ellipsis",
261
261
  whiteSpace: "nowrap"
262
262
  },
263
- children: a.name
263
+ children: i.name
264
264
  }), /* @__PURE__ */ l("button", {
265
265
  type: "button",
266
- onClick: () => d(v),
267
- "aria-label": `Remove ${a.name}`,
266
+ onClick: () => p(v),
267
+ "aria-label": `Remove ${i.name}`,
268
268
  style: {
269
269
  border: "none",
270
270
  background: "none",
@@ -277,31 +277,31 @@ var de = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
277
277
  children: "×"
278
278
  })]
279
279
  }, v))
280
- }), /* @__PURE__ */ F("div", {
280
+ }), /* @__PURE__ */ M("div", {
281
281
  style: {
282
282
  display: "flex",
283
283
  gap: "8px",
284
284
  alignItems: "flex-end"
285
285
  },
286
286
  children: [
287
- o && /* @__PURE__ */ F(G, { children: [/* @__PURE__ */ l("button", {
287
+ o && /* @__PURE__ */ M(U, { children: [/* @__PURE__ */ l("button", {
288
288
  type: "button",
289
- onClick: () => u.current?.click(),
290
- disabled: t,
289
+ onClick: () => d.current?.click(),
290
+ disabled: r,
291
291
  "aria-label": "Attach file",
292
292
  style: {
293
293
  padding: "8px",
294
294
  border: "1px solid #dee3e8",
295
295
  borderRadius: "8px",
296
296
  backgroundColor: "#fff",
297
- cursor: t ? "not-allowed" : "pointer",
297
+ cursor: r ? "not-allowed" : "pointer",
298
298
  color: "#6b6d6f",
299
299
  fontSize: "16px",
300
300
  lineHeight: 1
301
301
  },
302
302
  children: "+"
303
303
  }), /* @__PURE__ */ l("input", {
304
- ref: u,
304
+ ref: d,
305
305
  type: "file",
306
306
  multiple: !0,
307
307
  onChange: k,
@@ -310,13 +310,13 @@ var de = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
310
310
  /* @__PURE__ */ l("textarea", {
311
311
  ref: g,
312
312
  value: s,
313
- onChange: (a) => {
314
- f(a.target.value), C();
313
+ onChange: (i) => {
314
+ c(i.target.value), C();
315
315
  },
316
316
  onKeyDown: S,
317
- placeholder: r,
318
- "aria-label": r,
319
- disabled: t,
317
+ placeholder: t,
318
+ "aria-label": t,
319
+ disabled: r,
320
320
  rows: 1,
321
321
  style: {
322
322
  flex: 1,
@@ -335,23 +335,23 @@ var de = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
335
335
  backgroundColor: "#f8f8f8",
336
336
  transition: "border-color 0.15s"
337
337
  },
338
- onFocus: (a) => {
339
- a.currentTarget.style.borderColor = "#1b5fc4";
338
+ onFocus: (i) => {
339
+ i.currentTarget.style.borderColor = "#1b5fc4";
340
340
  },
341
- onBlur: (a) => {
342
- a.currentTarget.style.borderColor = "#dee3e8";
341
+ onBlur: (i) => {
342
+ i.currentTarget.style.borderColor = "#dee3e8";
343
343
  }
344
344
  }),
345
345
  /* @__PURE__ */ l("button", {
346
346
  type: "submit",
347
- disabled: t || !x,
347
+ disabled: r || !x,
348
348
  style: {
349
349
  padding: "10px 18px",
350
350
  border: "none",
351
351
  borderRadius: "20px",
352
- backgroundColor: t || !x ? "#b5bfc8" : "#03182f",
352
+ backgroundColor: r || !x ? "#b5bfc8" : "#03182f",
353
353
  color: "#fff",
354
- cursor: t || !x ? "not-allowed" : "pointer",
354
+ cursor: r || !x ? "not-allowed" : "pointer",
355
355
  fontWeight: 500,
356
356
  fontSize: "16px",
357
357
  transition: "background-color 0.15s"
@@ -361,7 +361,7 @@ var de = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
361
361
  ]
362
362
  })]
363
363
  });
364
- }, ue = ({ href: e, children: t, ...r }) => /* @__PURE__ */ l("a", {
364
+ }, ue = ({ href: e, children: r, ...t }) => /* @__PURE__ */ l("a", {
365
365
  href: e,
366
366
  target: "_blank",
367
367
  rel: "noopener noreferrer",
@@ -369,53 +369,53 @@ var de = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
369
369
  color: "#1b5fc4",
370
370
  textDecoration: "underline"
371
371
  },
372
- ...r,
373
- children: t
374
- }), fe = ({ children: e, ...t }) => /* @__PURE__ */ l("p", {
372
+ ...t,
373
+ children: r
374
+ }), fe = ({ children: e, ...r }) => /* @__PURE__ */ l("p", {
375
375
  style: {
376
376
  margin: "0 0 8px 0",
377
377
  lineHeight: "1.6"
378
378
  },
379
- ...t,
379
+ ...r,
380
380
  children: e
381
- }), P = (e, t) => {
382
- const r = ({ children: o, ...n }) => re.createElement(`h${e}`, {
381
+ }), P = (e, r) => {
382
+ const t = ({ children: o, ...n }) => re.createElement(`h${e}`, {
383
383
  style: {
384
384
  margin: "16px 0 8px 0",
385
- fontSize: t,
385
+ fontSize: r,
386
386
  fontWeight: 600,
387
387
  lineHeight: "1.3"
388
388
  },
389
389
  ...n
390
390
  }, o);
391
- return r.displayName = `MarkdownHeading${e}`, r;
392
- }, pe = ({ children: e, ...t }) => /* @__PURE__ */ l("ul", {
391
+ return t.displayName = `MarkdownHeading${e}`, t;
392
+ }, pe = ({ children: e, ...r }) => /* @__PURE__ */ l("ul", {
393
393
  style: {
394
394
  margin: "0 0 8px 0",
395
395
  paddingLeft: "20px",
396
396
  listStyleType: "disc",
397
397
  listStylePosition: "outside"
398
398
  },
399
- ...t,
399
+ ...r,
400
400
  children: e
401
- }), ge = ({ children: e, ...t }) => /* @__PURE__ */ l("ol", {
401
+ }), ge = ({ children: e, ...r }) => /* @__PURE__ */ l("ol", {
402
402
  style: {
403
403
  margin: "0 0 8px 0",
404
404
  paddingLeft: "20px",
405
405
  listStyleType: "decimal",
406
406
  listStylePosition: "outside"
407
407
  },
408
- ...t,
408
+ ...r,
409
409
  children: e
410
- }), me = ({ children: e, ...t }) => /* @__PURE__ */ l("li", {
410
+ }), me = ({ children: e, ...r }) => /* @__PURE__ */ l("li", {
411
411
  style: {
412
412
  display: "list-item",
413
413
  margin: "2px 0",
414
414
  lineHeight: "1.6"
415
415
  },
416
- ...t,
416
+ ...r,
417
417
  children: e
418
- }), xe = ({ className: e, children: t, ...r }) => e !== void 0 || String(t).includes(`
418
+ }), xe = ({ className: e, children: r, ...t }) => e !== void 0 || String(r).includes(`
419
419
  `) ? /* @__PURE__ */ l("code", {
420
420
  style: {
421
421
  display: "block",
@@ -426,8 +426,8 @@ var de = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
426
426
  overflowX: "auto",
427
427
  fontFamily: '"IBM Plex Mono", monospace'
428
428
  },
429
- ...r,
430
- children: t
429
+ ...t,
430
+ children: r
431
431
  }) : /* @__PURE__ */ l("code", {
432
432
  style: {
433
433
  background: "#f0f2f5",
@@ -436,13 +436,13 @@ var de = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
436
436
  fontSize: "13px",
437
437
  fontFamily: '"IBM Plex Mono", monospace'
438
438
  },
439
- ...r,
440
- children: t
441
- }), he = ({ children: e, ...t }) => /* @__PURE__ */ l("pre", {
442
- style: { margin: "0 0 8px 0" },
443
439
  ...t,
440
+ children: r
441
+ }), he = ({ children: e, ...r }) => /* @__PURE__ */ l("pre", {
442
+ style: { margin: "0 0 8px 0" },
443
+ ...r,
444
444
  children: e
445
- }), ye = ({ children: e, ...t }) => /* @__PURE__ */ l("blockquote", {
445
+ }), ye = ({ children: e, ...r }) => /* @__PURE__ */ l("blockquote", {
446
446
  style: {
447
447
  borderLeft: "4px solid #dee3e8",
448
448
  paddingLeft: "12px",
@@ -450,9 +450,9 @@ var de = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
450
450
  fontStyle: "italic",
451
451
  color: "#6b6d6f"
452
452
  },
453
- ...t,
453
+ ...r,
454
454
  children: e
455
- }), ve = ({ children: e, ...t }) => /* @__PURE__ */ l("div", {
455
+ }), ve = ({ children: e, ...r }) => /* @__PURE__ */ l("div", {
456
456
  style: {
457
457
  overflowX: "auto",
458
458
  margin: "0 0 8px 0"
@@ -463,10 +463,10 @@ var de = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
463
463
  width: "100%",
464
464
  fontSize: "13px"
465
465
  },
466
- ...t,
466
+ ...r,
467
467
  children: e
468
468
  })
469
- }), be = ({ children: e, ...t }) => /* @__PURE__ */ l("th", {
469
+ }), be = ({ children: e, ...r }) => /* @__PURE__ */ l("th", {
470
470
  style: {
471
471
  border: "1px solid #dee3e8",
472
472
  padding: "6px 10px",
@@ -474,23 +474,23 @@ var de = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
474
474
  backgroundColor: "#f5f7fa",
475
475
  fontWeight: 600
476
476
  },
477
- ...t,
477
+ ...r,
478
478
  children: e
479
- }), we = ({ children: e, ...t }) => /* @__PURE__ */ l("td", {
479
+ }), we = ({ children: e, ...r }) => /* @__PURE__ */ l("td", {
480
480
  style: {
481
481
  border: "1px solid #dee3e8",
482
482
  padding: "6px 10px"
483
483
  },
484
- ...t,
484
+ ...r,
485
485
  children: e
486
- }), Ce = ({ alt: e, ...t }) => /* @__PURE__ */ l("img", {
486
+ }), Ce = ({ alt: e, ...r }) => /* @__PURE__ */ l("img", {
487
487
  alt: e ?? "",
488
488
  style: {
489
489
  maxWidth: "100%",
490
490
  borderRadius: "8px",
491
491
  margin: "4px 0"
492
492
  },
493
- ...t
493
+ ...r
494
494
  }), Se = (e) => /* @__PURE__ */ l("hr", {
495
495
  style: {
496
496
  border: "none",
@@ -522,10 +522,10 @@ var de = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
522
522
  remarkPlugins: Ie,
523
523
  components: ke,
524
524
  children: e
525
- }), Ne = ({ attachment: e, isUser: t }) => {
526
- const r = Q(e.url);
527
- if (V(e)) return /* @__PURE__ */ l("a", {
528
- href: r,
525
+ }), Ne = ({ attachment: e, isUser: r }) => {
526
+ const t = ee(e.url);
527
+ if (Y(e)) return /* @__PURE__ */ l("a", {
528
+ href: t,
529
529
  target: "_blank",
530
530
  rel: "noopener noreferrer",
531
531
  style: {
@@ -533,7 +533,7 @@ var de = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
533
533
  textDecoration: "none"
534
534
  },
535
535
  children: /* @__PURE__ */ l("img", {
536
- src: r,
536
+ src: t,
537
537
  alt: e.name,
538
538
  loading: "lazy",
539
539
  style: {
@@ -546,7 +546,7 @@ var de = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
546
546
  }
547
547
  })
548
548
  });
549
- const o = Z(e.fileSize), n = /* @__PURE__ */ F(G, { children: [/* @__PURE__ */ l("span", {
549
+ const o = Q(e.fileSize), n = /* @__PURE__ */ M(U, { children: [/* @__PURE__ */ l("span", {
550
550
  style: {
551
551
  fontSize: "16px",
552
552
  lineHeight: 1,
@@ -554,7 +554,7 @@ var de = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
554
554
  },
555
555
  "aria-hidden": !0,
556
556
  children: "📄"
557
- }), /* @__PURE__ */ F("span", {
557
+ }), /* @__PURE__ */ M("span", {
558
558
  style: {
559
559
  display: "flex",
560
560
  flexDirection: "column",
@@ -583,14 +583,14 @@ var de = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
583
583
  padding: "8px 12px",
584
584
  borderRadius: "10px",
585
585
  border: "1px solid #dee3e8",
586
- backgroundColor: t ? "rgba(255,255,255,0.12)" : "#fff",
587
- color: t ? "#fff" : "#30373e",
586
+ backgroundColor: r ? "rgba(255,255,255,0.12)" : "#fff",
587
+ color: r ? "#fff" : "#30373e",
588
588
  fontSize: "13px",
589
589
  textDecoration: "none",
590
590
  maxWidth: "220px"
591
591
  };
592
- return r ? /* @__PURE__ */ l("a", {
593
- href: r,
592
+ return t ? /* @__PURE__ */ l("a", {
593
+ href: t,
594
594
  target: "_blank",
595
595
  rel: "noopener noreferrer",
596
596
  style: s,
@@ -599,8 +599,8 @@ var de = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
599
599
  style: s,
600
600
  children: n
601
601
  });
602
- }, Re = ({ source: e, index: t }) => {
603
- const r = /* @__PURE__ */ F("div", {
602
+ }, Re = ({ source: e, index: r }) => {
603
+ const t = /* @__PURE__ */ M("div", {
604
604
  style: {
605
605
  display: "flex",
606
606
  alignItems: "center",
@@ -623,7 +623,7 @@ var de = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
623
623
  justifyContent: "center",
624
624
  backgroundColor: "#f0f4ff"
625
625
  },
626
- children: t + 1
626
+ children: r + 1
627
627
  }), /* @__PURE__ */ l("div", {
628
628
  style: {
629
629
  fontSize: "12px",
@@ -659,12 +659,12 @@ var de = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
659
659
  onMouseLeave: (n) => {
660
660
  n.currentTarget.style.borderColor = "#dee3e8";
661
661
  },
662
- children: r
662
+ children: t
663
663
  }) : /* @__PURE__ */ l("div", {
664
664
  style: o,
665
- children: r
665
+ children: t
666
666
  });
667
- }, Me = () => /* @__PURE__ */ F("div", {
667
+ }, Ee = () => /* @__PURE__ */ M("div", {
668
668
  style: {
669
669
  display: "flex",
670
670
  gap: "4px",
@@ -687,10 +687,10 @@ var de = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
687
687
  40% { opacity: 1; transform: scale(1); }
688
688
  }
689
689
  ` })]
690
- }), Ee = ({ message: e, className: t = "", showAgentName: r = !1, isLast: o = !1, onFollowUpClick: n }) => {
691
- const s = e.role === "user", f = e.status === "IN_PROGRESS" || e.status === "WAITING_CLIENT";
692
- return /* @__PURE__ */ F("div", {
693
- className: `ago-message ago-message--${e.role} ${t}`,
690
+ }), Me = ({ message: e, className: r = "", showAgentName: t = !1, isLast: o = !1, onFollowUpClick: n }) => {
691
+ const s = e.role === "user", c = e.status === "IN_PROGRESS" || e.status === "WAITING_CLIENT";
692
+ return /* @__PURE__ */ M("div", {
693
+ className: `ago-message ago-message--${e.role} ${r}`,
694
694
  style: {
695
695
  display: "flex",
696
696
  flexDirection: "column",
@@ -698,7 +698,7 @@ var de = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
698
698
  marginBottom: "16px"
699
699
  },
700
700
  children: [
701
- !s && r && e.agent && /* @__PURE__ */ l("div", {
701
+ !s && t && e.agent && /* @__PURE__ */ l("div", {
702
702
  className: "ago-message__agent",
703
703
  style: {
704
704
  display: "flex",
@@ -722,10 +722,10 @@ var de = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
722
722
  width: "100%",
723
723
  maxWidth: "85%"
724
724
  },
725
- children: e.sources.map((i, m) => /* @__PURE__ */ l(Re, {
726
- source: i,
727
- index: m
728
- }, i.id))
725
+ children: e.sources.map((a, f) => /* @__PURE__ */ l(Re, {
726
+ source: a,
727
+ index: f
728
+ }, a.id))
729
729
  }),
730
730
  e.attachments && e.attachments.length > 0 && /* @__PURE__ */ l("div", {
731
731
  className: "ago-message__attachments",
@@ -737,12 +737,12 @@ var de = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
737
737
  justifyContent: s ? "flex-end" : "flex-start",
738
738
  maxWidth: "75%"
739
739
  },
740
- children: e.attachments.map((i) => /* @__PURE__ */ l(Ne, {
741
- attachment: i,
740
+ children: e.attachments.map((a) => /* @__PURE__ */ l(Ne, {
741
+ attachment: a,
742
742
  isUser: s
743
- }, i.id))
743
+ }, a.id))
744
744
  }),
745
- (e.content || f) && /* @__PURE__ */ l("div", {
745
+ (e.content || c) && /* @__PURE__ */ l("div", {
746
746
  className: "ago-message__content",
747
747
  style: {
748
748
  maxWidth: s ? "75%" : "100%",
@@ -754,7 +754,7 @@ var de = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
754
754
  fontSize: "16px",
755
755
  lineHeight: "1.6"
756
756
  },
757
- children: e.content ? /* @__PURE__ */ l(Ae, { content: e.content }) : f && /* @__PURE__ */ l(Me, {})
757
+ children: e.content ? /* @__PURE__ */ l(Ae, { content: e.content }) : c && /* @__PURE__ */ l(Ee, {})
758
758
  }),
759
759
  o && e.followUpReplies && e.followUpReplies.length > 0 && /* @__PURE__ */ l("div", {
760
760
  className: "ago-message__followups",
@@ -764,11 +764,11 @@ var de = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
764
764
  gap: "8px",
765
765
  marginTop: "10px"
766
766
  },
767
- children: e.followUpReplies.map((i, m) => /* @__PURE__ */ l("button", {
767
+ children: e.followUpReplies.map((a, f) => /* @__PURE__ */ l("button", {
768
768
  type: "button",
769
769
  className: "ago-message__followup-btn",
770
770
  disabled: !n,
771
- onClick: n ? () => n(i) : void 0,
771
+ onClick: n ? () => n(a) : void 0,
772
772
  style: {
773
773
  minHeight: "36px",
774
774
  padding: "6px 14px",
@@ -780,56 +780,56 @@ var de = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
780
780
  cursor: n ? "pointer" : "default",
781
781
  transition: "border-color 0.15s"
782
782
  },
783
- onMouseEnter: (u) => {
784
- u.currentTarget.style.borderColor = "#1b5fc4";
783
+ onMouseEnter: (d) => {
784
+ d.currentTarget.style.borderColor = "#1b5fc4";
785
785
  },
786
- onMouseLeave: (u) => {
787
- u.currentTarget.style.borderColor = "#dee3e8";
786
+ onMouseLeave: (d) => {
787
+ d.currentTarget.style.borderColor = "#dee3e8";
788
788
  },
789
- children: i
790
- }, m))
789
+ children: a
790
+ }, f))
791
791
  })
792
792
  ]
793
793
  });
794
- }, Ue = ({ client: e, conversationId: t, title: r = "Chat", welcomeMessage: o = "Hello! How can I help you today?", placeholder: n = "Type a message...", allowFiles: s = !1, height: f = 500, logoUrl: i, showAgentName: m = !1, forms: u, onFollowUpClick: g, className: C = "", onMessageSent: A, onMessageReceived: S }) => {
795
- const k = T(null), d = L(), x = e ?? d, { messages: a, isLoading: v, error: c, sendMessage: h } = K({
794
+ }, Je = ({ client: e, conversationId: r, title: t = "Chat", welcomeMessage: o = "Hello! How can I help you today?", placeholder: n = "Type a message...", allowFiles: s = !1, height: c = 500, logoUrl: a, showAgentName: f = !1, forms: d, onFollowUpClick: g, className: C = "", onMessageSent: N, onMessageReceived: S }) => {
795
+ const k = _(null), p = z(), x = e ?? p, { messages: i, isLoading: v, error: u, sendMessage: h } = K({
796
796
  client: e,
797
- conversationId: t
797
+ conversationId: r
798
798
  });
799
- N(() => {
800
- if (!x || !u || u.length === 0) return;
801
- let p = !1;
799
+ A(() => {
800
+ if (!x || !d || d.length === 0) return;
801
+ let m = !1;
802
802
  const I = [];
803
- return Promise.all(u.map((M) => M.schema != null ? Promise.resolve(j(M)) : O(x, M))).then((M) => {
804
- if (!p)
805
- for (const J of M) I.push(J.install(x));
803
+ return Promise.all(d.map((F) => F.schema != null ? Promise.resolve(B(F)) : j(x, F))).then((F) => {
804
+ if (!m)
805
+ for (const V of F) I.push(V.install(x));
806
806
  }).catch(() => {
807
807
  }), () => {
808
- p = !0, I.forEach((M) => M());
808
+ m = !0, I.forEach((F) => F());
809
809
  };
810
- }, [x, u ? JSON.stringify(u.map((p) => [
811
- p.name,
812
- p.schema ?? null,
813
- p.submit ?? !1,
814
- p.description ?? null
815
- ])) : ""]), N(() => {
810
+ }, [x, d ? JSON.stringify(d.map((m) => [
811
+ m.name,
812
+ m.schema ?? null,
813
+ m.submit ?? !1,
814
+ m.description ?? null
815
+ ])) : ""]), A(() => {
816
816
  k.current?.scrollIntoView({ behavior: "smooth" });
817
- }, [a]), N(() => {
818
- const p = a[a.length - 1];
819
- p && p.role === "assistant" && p.status === "DONE" && S && S({
820
- id: p.id,
821
- content: p.content
817
+ }, [i]), A(() => {
818
+ const m = i[i.length - 1];
819
+ m && m.role === "assistant" && m.status === "DONE" && S && S({
820
+ id: m.id,
821
+ content: m.content
822
822
  });
823
- }, [a, S]);
824
- const w = async (p, I) => {
825
- A?.(p), await h(p, I);
826
- }, b = a[a.length - 1], _ = v && b?.role === "assistant" && (b.status === "IN_PROGRESS" || b.status === "WAITING_CLIENT"), y = g === !1 ? void 0 : g ?? ((p) => w(p));
827
- return /* @__PURE__ */ F("div", {
823
+ }, [i, S]);
824
+ const w = async (m, I) => {
825
+ N?.(m), await h(m, I);
826
+ }, b = i[i.length - 1], T = v && b?.role === "assistant" && (b.status === "IN_PROGRESS" || b.status === "WAITING_CLIENT"), y = g === !1 ? void 0 : g ?? ((m) => w(m));
827
+ return /* @__PURE__ */ M("div", {
828
828
  className: `ago-chat-widget ${C}`,
829
829
  style: {
830
830
  display: "flex",
831
831
  flexDirection: "column",
832
- height: typeof f == "number" ? `${f}px` : f,
832
+ height: typeof c == "number" ? `${c}px` : c,
833
833
  border: "1px solid #dee3e8",
834
834
  borderRadius: "16px",
835
835
  overflow: "hidden",
@@ -839,7 +839,7 @@ var de = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
839
839
  boxShadow: "rgba(15, 15, 15, 0.08) 0px 2px 16px 0px"
840
840
  },
841
841
  children: [
842
- /* @__PURE__ */ F("div", {
842
+ /* @__PURE__ */ M("div", {
843
843
  className: "ago-chat-widget__header",
844
844
  style: {
845
845
  padding: "14px 16px",
@@ -850,8 +850,8 @@ var de = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
850
850
  alignItems: "center",
851
851
  gap: "10px"
852
852
  },
853
- children: [i && /* @__PURE__ */ l("img", {
854
- src: i,
853
+ children: [a && /* @__PURE__ */ l("img", {
854
+ src: a,
855
855
  alt: "Logo",
856
856
  style: {
857
857
  height: "24px",
@@ -863,10 +863,10 @@ var de = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
863
863
  fontSize: "15px",
864
864
  fontWeight: 600
865
865
  },
866
- children: r
866
+ children: t
867
867
  })]
868
868
  }),
869
- /* @__PURE__ */ F("div", {
869
+ /* @__PURE__ */ M("div", {
870
870
  className: "ago-chat-widget__messages",
871
871
  role: "log",
872
872
  "aria-live": "polite",
@@ -879,7 +879,7 @@ var de = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
879
879
  backgroundColor: "#fbfbfb"
880
880
  },
881
881
  children: [
882
- a.length === 0 ? /* @__PURE__ */ l("div", {
882
+ i.length === 0 ? /* @__PURE__ */ l("div", {
883
883
  style: {
884
884
  textAlign: "center",
885
885
  color: "#6b6d6f",
@@ -888,13 +888,13 @@ var de = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
888
888
  lineHeight: "1.5"
889
889
  },
890
890
  children: o
891
- }) : a.map((p, I) => /* @__PURE__ */ l(Ee, {
892
- message: p,
893
- showAgentName: m,
894
- isLast: I === a.length - 1,
891
+ }) : i.map((m, I) => /* @__PURE__ */ l(Me, {
892
+ message: m,
893
+ showAgentName: f,
894
+ isLast: I === i.length - 1,
895
895
  onFollowUpClick: y
896
- }, p.id)),
897
- c && /* @__PURE__ */ l("div", {
896
+ }, m.id)),
897
+ u && /* @__PURE__ */ l("div", {
898
898
  role: "alert",
899
899
  style: {
900
900
  padding: "10px 14px",
@@ -905,64 +905,199 @@ var de = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
905
905
  fontSize: "13px",
906
906
  border: "1px solid #fecaca"
907
907
  },
908
- children: c.message
908
+ children: u.message
909
909
  }),
910
910
  /* @__PURE__ */ l("div", { ref: k })
911
911
  ]
912
912
  }),
913
913
  /* @__PURE__ */ l(de, {
914
914
  onSend: w,
915
- disabled: _,
915
+ disabled: T,
916
916
  placeholder: n,
917
917
  allowFiles: s
918
918
  })
919
919
  ]
920
920
  });
921
921
  };
922
- function Fe({ client: e, autoLoad: t = !0 } = {}) {
923
- const r = L(), o = e || r;
922
+ function _e(e = {}) {
923
+ const r = z(), t = e.client ?? r;
924
+ if (!t) throw new q("useProactiveNudge: no AgoClient. Pass one via options.client or wrap your tree with <AgoProvider>.", "proactive_missing_client");
925
+ const [o, n] = E(null), s = _(o);
926
+ s.current = o;
927
+ const c = _(e.onExpand);
928
+ return c.current = e.onExpand, A(() => {
929
+ const a = (d) => {
930
+ n(d), t.proactive?.shown(d);
931
+ }, f = ({ nudge: d }) => {
932
+ n((g) => g?.id === d.id ? null : g);
933
+ };
934
+ return t.on("nudge:ready", a), t.on("nudge:accepted", f), t.on("nudge:dismissed", f), () => {
935
+ t.off("nudge:ready", a), t.off("nudge:accepted", f), t.off("nudge:dismissed", f);
936
+ };
937
+ }, [t]), {
938
+ nudge: o,
939
+ accept: R(async () => {
940
+ const a = s.current;
941
+ a && (n(null), await t.proactive?.accept(a), (a.source === "agent" || a.goal) && c.current?.(a));
942
+ }, [t]),
943
+ dismiss: R(() => {
944
+ const a = s.current;
945
+ a && (n(null), t.proactive?.dismiss(a));
946
+ }, [t])
947
+ };
948
+ }
949
+ var Ve = ({ client: e, onExpand: r, autoHideMs: t, position: o = "bottom-right", openChatLabel: n = "Open chat", className: s = "" }) => {
950
+ const { nudge: c, accept: a, dismiss: f } = _e({
951
+ client: e,
952
+ onExpand: r
953
+ });
954
+ if (A(() => {
955
+ if (!c || !t) return;
956
+ const g = setTimeout(() => f(), t);
957
+ return () => clearTimeout(g);
958
+ }, [
959
+ c,
960
+ t,
961
+ f
962
+ ]), !c) return null;
963
+ const d = c.source === "agent" || !!c.goal;
964
+ return /* @__PURE__ */ M("div", {
965
+ className: `ago-nudge ${s}`,
966
+ role: "status",
967
+ "aria-live": "polite",
968
+ style: {
969
+ position: "fixed",
970
+ bottom: "90px",
971
+ ...o === "bottom-left" ? { left: "20px" } : { right: "20px" },
972
+ zIndex: 2147483e3,
973
+ maxWidth: "320px",
974
+ padding: "14px 16px",
975
+ backgroundColor: "#fff",
976
+ color: "#03182f",
977
+ border: "1px solid #dee3e8",
978
+ borderRadius: "16px",
979
+ boxShadow: "rgba(15, 15, 15, 0.12) 0px 4px 20px 0px",
980
+ fontFamily: '"IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',
981
+ fontSize: "14px",
982
+ lineHeight: 1.5,
983
+ textAlign: "left"
984
+ },
985
+ children: [
986
+ /* @__PURE__ */ l("button", {
987
+ type: "button",
988
+ className: "ago-nudge__close",
989
+ "aria-label": "Dismiss",
990
+ onClick: f,
991
+ style: {
992
+ position: "absolute",
993
+ top: "6px",
994
+ right: "8px",
995
+ border: "none",
996
+ background: "transparent",
997
+ color: "#6b6d6f",
998
+ fontSize: "16px",
999
+ lineHeight: 1,
1000
+ cursor: "pointer",
1001
+ padding: "4px"
1002
+ },
1003
+ children: "×"
1004
+ }),
1005
+ /* @__PURE__ */ l("div", {
1006
+ className: "ago-nudge__message",
1007
+ style: { paddingRight: "16px" },
1008
+ children: c.message
1009
+ }),
1010
+ (c.action || d) && /* @__PURE__ */ M("div", {
1011
+ className: "ago-nudge__actions",
1012
+ style: {
1013
+ display: "flex",
1014
+ gap: "8px",
1015
+ marginTop: "10px",
1016
+ flexWrap: "wrap"
1017
+ },
1018
+ children: [c.action && /* @__PURE__ */ l("button", {
1019
+ type: "button",
1020
+ className: "ago-nudge__action",
1021
+ onClick: () => {
1022
+ a();
1023
+ },
1024
+ style: {
1025
+ border: "none",
1026
+ borderRadius: "10px",
1027
+ padding: "6px 12px",
1028
+ backgroundColor: "#03182f",
1029
+ color: "#e8f0fe",
1030
+ fontSize: "13px",
1031
+ fontWeight: 600,
1032
+ cursor: "pointer"
1033
+ },
1034
+ children: c.action.label
1035
+ }), d && /* @__PURE__ */ l("button", {
1036
+ type: "button",
1037
+ className: "ago-nudge__expand",
1038
+ onClick: () => {
1039
+ a();
1040
+ },
1041
+ style: {
1042
+ border: "1px solid #dee3e8",
1043
+ borderRadius: "10px",
1044
+ padding: "6px 12px",
1045
+ backgroundColor: "#fff",
1046
+ color: "#03182f",
1047
+ fontSize: "13px",
1048
+ fontWeight: 600,
1049
+ cursor: "pointer"
1050
+ },
1051
+ children: n
1052
+ })]
1053
+ })
1054
+ ]
1055
+ });
1056
+ };
1057
+ function Fe({ client: e, autoLoad: r = !0 } = {}) {
1058
+ const t = z(), o = e || t;
924
1059
  if (!o) throw new Error("useConversation requires an AgoClient. Either pass it as options.client or wrap your app in <AgoProvider>.");
925
- const [n, s] = E([]), [f, i] = E(null), [m, u] = E(!1), [g, C] = E(null), A = R(async () => {
926
- u(!0), C(null);
1060
+ const [n, s] = E([]), [c, a] = E(null), [f, d] = E(!1), [g, C] = E(null), N = R(async () => {
1061
+ d(!0), C(null);
927
1062
  try {
928
1063
  s(await o.getConversations());
929
- } catch (d) {
930
- C(d instanceof Error ? d : /* @__PURE__ */ new Error("Failed to load conversations"));
1064
+ } catch (p) {
1065
+ C(p instanceof Error ? p : /* @__PURE__ */ new Error("Failed to load conversations"));
931
1066
  } finally {
932
- u(!1);
1067
+ d(!1);
933
1068
  }
934
- }, [o]), S = R(async (d) => {
935
- u(!0), C(null);
1069
+ }, [o]), S = R(async (p) => {
1070
+ d(!0), C(null);
936
1071
  try {
937
- i(await o.getConversation(d));
1072
+ a(await o.getConversation(p));
938
1073
  } catch (x) {
939
1074
  C(x instanceof Error ? x : /* @__PURE__ */ new Error("Failed to load conversation"));
940
1075
  } finally {
941
- u(!1);
1076
+ d(!1);
942
1077
  }
943
1078
  }, [o]), k = R(() => {
944
- i(null);
1079
+ a(null);
945
1080
  }, []);
946
- return N(() => {
947
- t && A();
948
- }, [t, A]), {
1081
+ return A(() => {
1082
+ r && N();
1083
+ }, [r, N]), {
949
1084
  conversations: n,
950
- currentConversation: f,
951
- isLoading: m,
1085
+ currentConversation: c,
1086
+ isLoading: f,
952
1087
  error: g,
953
1088
  selectConversation: S,
954
1089
  startNewConversation: k,
955
- refreshConversations: A
1090
+ refreshConversations: N
956
1091
  };
957
1092
  }
958
- function Je(e = {}) {
959
- const t = L(), r = e.client || t;
960
- if (!r) throw new Error("useChat requires an AgoClient. Either pass it as options.client or wrap your app in <AgoProvider>.");
1093
+ function Ye(e = {}) {
1094
+ const r = z(), t = e.client || r;
1095
+ if (!t) throw new Error("useChat requires an AgoClient. Either pass it as options.client or wrap your app in <AgoProvider>.");
961
1096
  const o = K({
962
- client: r,
1097
+ client: t,
963
1098
  conversationId: e.conversationId
964
1099
  }), n = Fe({
965
- client: r,
1100
+ client: t,
966
1101
  autoLoad: e.autoLoad
967
1102
  });
968
1103
  return {
@@ -980,67 +1115,67 @@ function Je(e = {}) {
980
1115
  refreshConversations: n.refreshConversations
981
1116
  };
982
1117
  }
983
- function Ve(e, t) {
984
- const r = W(), { name: o, description: n, parameters: s, handler: f, maxResultBytes: i, requiresApproval: m } = typeof e == "string" ? {
1118
+ function Xe(e, r) {
1119
+ const t = D(), { name: o, description: n, parameters: s, handler: c, maxResultBytes: a, requiresApproval: f } = typeof e == "string" ? {
985
1120
  name: e,
986
- ...t
987
- } : e, u = T(f);
988
- u.current = f, N(() => {
989
- const g = (C) => u.current(C);
990
- return r.registerFunction(o, g, {
1121
+ ...r
1122
+ } : e, d = _(c);
1123
+ d.current = c, A(() => {
1124
+ const g = (C) => d.current(C);
1125
+ return t.registerFunction(o, g, {
991
1126
  description: n,
992
1127
  parameters: s,
993
- maxResultBytes: i,
994
- requiresApproval: m
1128
+ maxResultBytes: a,
1129
+ requiresApproval: f
995
1130
  }), () => {
996
- r.unregisterFunction(o);
1131
+ t.unregisterFunction(o);
997
1132
  };
998
1133
  }, [
999
- r,
1134
+ t,
1000
1135
  o,
1001
1136
  n,
1002
1137
  s,
1003
- i,
1004
- m
1138
+ a,
1139
+ f
1005
1140
  ]);
1006
1141
  }
1007
- function Ye(e, t) {
1008
- const r = W(), o = T(e);
1009
- o.current = e, N(() => (r.registerNavigationFunction((n) => o.current(n), t), () => {
1010
- r.unregisterNavigationFunction();
1011
- }), [r, t]);
1142
+ function Ze(e, r) {
1143
+ const t = D(), o = _(e);
1144
+ o.current = e, A(() => (t.registerNavigationFunction((n) => o.current(n), r), () => {
1145
+ t.unregisterNavigationFunction();
1146
+ }), [t, r]);
1012
1147
  }
1013
- function Xe(e, t) {
1014
- const r = W(), o = t?.functionName ?? "setPageState", n = t?.requiresApproval, s = T(e);
1015
- s.current = e, N(() => {
1016
- const f = s.current.map((i) => {
1017
- const m = () => s.current.find((u) => u.name === i.name) ?? i;
1148
+ function Qe(e, r) {
1149
+ const t = D(), o = r?.functionName ?? "setPageState", n = r?.requiresApproval, s = _(e);
1150
+ s.current = e, A(() => {
1151
+ const c = s.current.map((a) => {
1152
+ const f = () => s.current.find((d) => d.name === a.name) ?? a;
1018
1153
  return {
1019
- name: i.name,
1020
- description: i.description,
1021
- schema: i.schema,
1022
- get: i.get ? () => m().get?.() : void 0,
1023
- set: (u) => m().set(u)
1154
+ name: a.name,
1155
+ description: a.description,
1156
+ schema: a.schema,
1157
+ get: a.get ? () => f().get?.() : void 0,
1158
+ set: (d) => f().set(d)
1024
1159
  };
1025
1160
  });
1026
- return r.registerPageStateFunction(f, {
1161
+ return t.registerPageStateFunction(c, {
1027
1162
  functionName: o,
1028
1163
  requiresApproval: n
1029
1164
  }), () => {
1030
- r.unregisterPageStateFunction(o);
1165
+ t.unregisterPageStateFunction(o);
1031
1166
  };
1032
1167
  }, [
1033
- r,
1168
+ t,
1034
1169
  o,
1035
1170
  n
1036
1171
  ]);
1037
1172
  }
1038
- function Ze(e) {
1039
- const t = W(), r = T(e);
1040
- r.current = e, N(() => te(t, () => r.current), [t]);
1173
+ function et(e) {
1174
+ const r = D(), t = _(e);
1175
+ t.current = e, A(() => ne(r, () => t.current), [r]);
1041
1176
  }
1042
1177
  var Te = /* @__PURE__ */ new Set(["awaiting-approval"]);
1043
- function U(e) {
1178
+ function J(e) {
1044
1179
  switch (e) {
1045
1180
  case "progress_indicator":
1046
1181
  return "progress";
@@ -1054,22 +1189,22 @@ function U(e) {
1054
1189
  return "status";
1055
1190
  }
1056
1191
  }
1057
- function _e(e) {
1058
- return e.type === "client_function" ? e.functionName === "navigateToPage" ? "navigation" : "action" : U(e.type);
1192
+ function Pe(e) {
1193
+ return e.type === "client_function" ? e.functionName === "navigateToPage" ? "navigation" : "action" : J(e.type);
1059
1194
  }
1060
- function H(e, t) {
1061
- const r = (e ?? "").toLowerCase();
1062
- return r.includes("reject") ? "rejected" : r.includes("error") || r.includes("fail") ? "error" : r.includes("done") || r.includes("complet") ? "done" : (r.includes("waiting") || r.includes("pending")) && (t === "confirmation" || t === "form") ? "awaiting-approval" : "running";
1195
+ function $(e, r) {
1196
+ const t = (e ?? "").toLowerCase();
1197
+ 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";
1063
1198
  }
1064
- function $(e) {
1065
- return typeof e != "string" || !e ? "page" : e.replace(/[-_]+/g, " ").replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/\b\w/g, (t) => t.toUpperCase()).trim();
1199
+ function H(e) {
1200
+ 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();
1066
1201
  }
1067
- function Pe(e) {
1202
+ function We(e) {
1068
1203
  switch (e.kind) {
1069
1204
  case "navigation":
1070
- return `Navigating to ${$(e.arguments?.page)}`;
1205
+ return `Navigating to ${H(e.arguments?.page)}`;
1071
1206
  case "action":
1072
- return e.functionName === "setPageState" ? "Updating the page" : e.functionName === "openFilteredConversations" ? "Opening conversations" : e.toolDisplayName || e.message || $(e.functionName) || "Working";
1207
+ return e.functionName === "setPageState" ? "Updating the page" : e.functionName === "openFilteredConversations" ? "Opening conversations" : e.toolDisplayName || e.message || H(e.functionName) || "Working";
1073
1208
  case "progress":
1074
1209
  return e.message || "Working";
1075
1210
  case "reasoning":
@@ -1082,16 +1217,16 @@ function Pe(e) {
1082
1217
  return e.message || e.toolDisplayName || e.toolName || "Working";
1083
1218
  }
1084
1219
  }
1085
- function Qe(e = {}) {
1086
- const { includeReasoning: t = !1, labelFor: r } = e, o = L(), n = e.client || o;
1087
- if (!n) throw new X("useAgoActivity requires an AgoClient. Either pass it as options.client or wrap your app in <AgoProvider>.", "provider_missing_client");
1088
- const [s, f] = E([]), i = T(/* @__PURE__ */ new Set()), m = T(void 0), u = T(r);
1089
- u.current = r;
1090
- const g = R((d, x) => {
1091
- f((a) => {
1092
- const v = a.findIndex((h) => h.id === d), c = {
1093
- ...v >= 0 ? a[v] : {
1094
- id: d,
1220
+ function tt(e = {}) {
1221
+ const { includeReasoning: r = !1, labelFor: t } = e, o = z(), n = e.client || o;
1222
+ if (!n) throw new q("useAgoActivity requires an AgoClient. Either pass it as options.client or wrap your app in <AgoProvider>.", "provider_missing_client");
1223
+ const [s, c] = E([]), a = _(/* @__PURE__ */ new Set()), f = _(void 0), d = _(t);
1224
+ d.current = t;
1225
+ const g = R((p, x) => {
1226
+ c((i) => {
1227
+ const v = i.findIndex((h) => h.id === p), u = {
1228
+ ...v >= 0 ? i[v] : {
1229
+ id: p,
1095
1230
  kind: "status",
1096
1231
  label: "",
1097
1232
  status: "running",
@@ -1100,34 +1235,34 @@ function Qe(e = {}) {
1100
1235
  },
1101
1236
  ...x
1102
1237
  };
1103
- return c.label = u.current?.(c) ?? Pe(c), v >= 0 ? [
1104
- ...a.slice(0, v),
1105
- c,
1106
- ...a.slice(v + 1)
1107
- ] : [...a, c];
1238
+ return u.label = d.current?.(u) ?? We(u), v >= 0 ? [
1239
+ ...i.slice(0, v),
1240
+ u,
1241
+ ...i.slice(v + 1)
1242
+ ] : [...i, u];
1108
1243
  });
1109
1244
  }, []);
1110
- N(() => {
1111
- const d = (y) => {
1112
- m.current = y.messageId;
1245
+ A(() => {
1246
+ const p = (y) => {
1247
+ f.current = y.messageId;
1113
1248
  }, x = (y) => {
1114
- const p = U(y.type);
1115
- p === "reasoning" && !t || g(y.id, {
1116
- kind: p,
1117
- status: H(y.status, p),
1118
- messageId: m.current,
1249
+ const m = J(y.type);
1250
+ m === "reasoning" && !r || g(y.id, {
1251
+ kind: m,
1252
+ status: $(y.status, m),
1253
+ messageId: f.current,
1119
1254
  toolName: y.toolName,
1120
1255
  toolDisplayName: y.toolDisplayName,
1121
1256
  message: y.message,
1122
1257
  data: y.data,
1123
1258
  formSchema: y.formSchema,
1124
- requiresApproval: p === "confirmation" || p === "form"
1259
+ requiresApproval: m === "confirmation" || m === "form"
1125
1260
  });
1126
- }, a = (y) => {
1261
+ }, i = (y) => {
1127
1262
  y.invocationId && g(y.invocationId, {
1128
1263
  kind: y.functionName === "navigateToPage" ? "navigation" : "action",
1129
1264
  status: "running",
1130
- messageId: m.current,
1265
+ messageId: f.current,
1131
1266
  functionName: y.functionName,
1132
1267
  arguments: y.arguments
1133
1268
  });
@@ -1135,27 +1270,27 @@ function Qe(e = {}) {
1135
1270
  y.invocationId && g(y.invocationId, {
1136
1271
  kind: y.functionName === "navigateToPage" ? "navigation" : "action",
1137
1272
  status: "awaiting-approval",
1138
- messageId: m.current,
1273
+ messageId: f.current,
1139
1274
  functionName: y.functionName,
1140
1275
  arguments: y.arguments,
1141
1276
  requiresApproval: !0
1142
1277
  });
1143
- }, c = (y) => {
1278
+ }, u = (y) => {
1144
1279
  if (!y.invocationId) return;
1145
- const p = y.result, I = typeof y.result == "object" && p !== null && p.approved === !1 && p.reason === "user_rejected";
1280
+ const m = y.result, I = typeof y.result == "object" && m !== null && m.approved === !1 && m.reason === "user_rejected";
1146
1281
  g(y.invocationId, {
1147
1282
  status: y.error ? "error" : I ? "rejected" : "done",
1148
1283
  requiresApproval: !1
1149
1284
  });
1150
1285
  }, h = (y) => {
1151
- for (const p of y.messages ?? [])
1152
- if (p.role === "assistant")
1153
- for (const I of p.toolCalls ?? []) {
1154
- const M = _e(I);
1155
- M === "reasoning" && !t || /waiting/i.test(I.status ?? "") || g(I.id, {
1156
- kind: M,
1157
- status: H(I.status, M),
1158
- messageId: p.id,
1286
+ for (const m of y.messages ?? [])
1287
+ if (m.role === "assistant")
1288
+ for (const I of m.toolCalls ?? []) {
1289
+ const F = Pe(I);
1290
+ F === "reasoning" && !r || /waiting/i.test(I.status ?? "") || g(I.id, {
1291
+ kind: F,
1292
+ status: $(I.status, F),
1293
+ messageId: m.id,
1159
1294
  toolName: I.toolName,
1160
1295
  toolDisplayName: I.toolDisplayName,
1161
1296
  functionName: I.functionName,
@@ -1163,144 +1298,144 @@ function Qe(e = {}) {
1163
1298
  message: I.message,
1164
1299
  data: I.data,
1165
1300
  formSchema: I.formSchema,
1166
- requiresApproval: M === "confirmation" || M === "form"
1301
+ requiresApproval: F === "confirmation" || F === "form"
1167
1302
  });
1168
1303
  }
1169
1304
  }, w = (y) => {
1170
- f((p) => p.map((I) => I.status === "running" || I.status === "awaiting-approval" ? {
1305
+ c((m) => m.map((I) => I.status === "running" || I.status === "awaiting-approval" ? {
1171
1306
  ...I,
1172
1307
  status: y
1173
1308
  } : I));
1174
- }, b = () => w("done"), _ = () => w("error");
1175
- return n.on("message:start", d), n.on("toolCall:received", x), n.on("function:invoke", a), n.on("function:awaiting-approval", v), n.on("function:result", c), n.on("conversation:loaded", h), n.on("message:complete", b), n.on("message:error", _), () => {
1176
- n.off("message:start", d), n.off("toolCall:received", x), n.off("function:invoke", a), n.off("function:awaiting-approval", v), n.off("function:result", c), n.off("conversation:loaded", h), n.off("message:complete", b), n.off("message:error", _);
1309
+ }, b = () => w("done"), T = () => w("error");
1310
+ return n.on("message:start", p), n.on("toolCall:received", x), n.on("function:invoke", i), n.on("function:awaiting-approval", v), n.on("function:result", u), n.on("conversation:loaded", h), n.on("message:complete", b), n.on("message:error", T), () => {
1311
+ n.off("message:start", p), n.off("toolCall:received", x), n.off("function:invoke", i), n.off("function:awaiting-approval", v), n.off("function:result", u), n.off("conversation:loaded", h), n.off("message:complete", b), n.off("message:error", T);
1177
1312
  };
1178
1313
  }, [
1179
1314
  n,
1180
- t,
1315
+ r,
1181
1316
  g
1182
1317
  ]);
1183
- const C = R(async (d) => {
1184
- const x = s.find((a) => a.id === d);
1185
- !x || x.status !== "awaiting-approval" || i.current.has(d) || x.kind !== "form" && (i.current.add(d), g(d, {
1318
+ const C = R(async (p) => {
1319
+ const x = s.find((i) => i.id === p);
1320
+ !x || x.status !== "awaiting-approval" || a.current.has(p) || x.kind !== "form" && (a.current.add(p), g(p, {
1186
1321
  status: "running",
1187
1322
  requiresApproval: !1
1188
- }), x.functionName ? await n.approveFunction(d) : await n.confirmToolCall(d));
1323
+ }), x.functionName ? await n.approveFunction(p) : await n.confirmToolCall(p));
1189
1324
  }, [
1190
1325
  n,
1191
1326
  s,
1192
1327
  g
1193
- ]), A = R(async (d) => {
1194
- const x = s.find((a) => a.id === d);
1195
- !x || x.status !== "awaiting-approval" || i.current.has(d) || (i.current.add(d), g(d, {
1328
+ ]), N = R(async (p) => {
1329
+ const x = s.find((i) => i.id === p);
1330
+ !x || x.status !== "awaiting-approval" || a.current.has(p) || (a.current.add(p), g(p, {
1196
1331
  status: "rejected",
1197
1332
  requiresApproval: !1
1198
- }), x.functionName ? await n.rejectFunction(d) : await n.rejectToolCall(d));
1333
+ }), x.functionName ? await n.rejectFunction(p) : await n.rejectToolCall(p));
1199
1334
  }, [
1200
1335
  n,
1201
1336
  s,
1202
1337
  g
1203
- ]), S = R(async (d, x) => {
1204
- g(d, {
1338
+ ]), S = R(async (p, x) => {
1339
+ g(p, {
1205
1340
  status: "running",
1206
1341
  requiresApproval: !1
1207
- }), await n.submitToolCallForm(d, x), g(d, { status: "done" });
1342
+ }), await n.submitToolCallForm(p, x), g(p, { status: "done" });
1208
1343
  }, [n, g]), k = R(() => {
1209
- i.current.clear(), f([]);
1344
+ a.current.clear(), c([]);
1210
1345
  }, []);
1211
1346
  return {
1212
1347
  items: s,
1213
1348
  latest: s.length > 0 ? s[s.length - 1] : void 0,
1214
- isAwaitingApproval: s.some((d) => Te.has(d.status)),
1349
+ isAwaitingApproval: s.some((p) => Te.has(p.status)),
1215
1350
  approve: C,
1216
- reject: A,
1351
+ reject: N,
1217
1352
  submitForm: S,
1218
1353
  clear: k
1219
1354
  };
1220
1355
  }
1221
- function et(e, t) {
1222
- const r = W(), o = ae(), n = t ?? o, s = T(e);
1356
+ function nt(e, r) {
1357
+ const t = D(), o = ae(), n = r ?? o, s = _(e);
1223
1358
  s.current = e;
1224
- const f = typeof e == "function";
1225
- N(() => {
1359
+ const c = typeof e == "function";
1360
+ A(() => {
1226
1361
  if (typeof s.current == "function") {
1227
- const i = () => s.current();
1228
- return r.addDynamicContext(n, i), () => {
1229
- r.removeDynamicContext(n);
1362
+ const a = () => s.current();
1363
+ return t.addDynamicContext(n, a), () => {
1364
+ t.removeDynamicContext(n);
1230
1365
  };
1231
1366
  }
1232
- return r.setContext(n, s.current), () => {
1233
- r.removeContext(n);
1367
+ return t.setContext(n, s.current), () => {
1368
+ t.removeContext(n);
1234
1369
  };
1235
1370
  }, [
1236
- r,
1371
+ t,
1237
1372
  n,
1238
- f,
1239
- f ? "" : JSON.stringify(e)
1373
+ c,
1374
+ c ? "" : JSON.stringify(e)
1240
1375
  ]);
1241
1376
  }
1242
1377
  function De(e) {
1243
1378
  return se(e.subscribe, e.get, e.get);
1244
1379
  }
1245
- var q = {
1380
+ var O = {
1246
1381
  missing: [],
1247
1382
  complete: !1
1248
1383
  };
1249
- function tt(e) {
1250
- const t = W(), r = e.schema != null, o = JSON.stringify(e.schema ?? null), n = e.submit, s = n ? typeof n == "string" ? `client:${n}` : n.via === "backend" ? "backend" : "handler" in n ? "client:handler" : `client:${n.url}` : "none", f = JSON.stringify(e.initialValues ?? null), i = D(() => r ? j(e) : null, [
1251
- r,
1384
+ function rt(e) {
1385
+ const r = D(), t = e.schema != null, o = JSON.stringify(e.schema ?? null), n = e.submit, s = n ? typeof n == "string" ? `client:${n}` : n.via === "backend" ? "backend" : "handler" in n ? "client:handler" : `client:${n.url}` : "none", c = JSON.stringify(e.initialValues ?? null), a = W(() => t ? B(e) : null, [
1386
+ t,
1252
1387
  e.name,
1253
1388
  o,
1254
1389
  s,
1255
- f,
1390
+ c,
1256
1391
  e.autoSubmit
1257
- ]), [m, u] = E({
1392
+ ]), [f, d] = E({
1258
1393
  collector: null,
1259
- loading: !r,
1394
+ loading: !t,
1260
1395
  error: null
1261
1396
  });
1262
- N(() => {
1263
- if (r) return;
1397
+ A(() => {
1398
+ if (t) return;
1264
1399
  let v = !1;
1265
- return u({
1400
+ return d({
1266
1401
  collector: null,
1267
1402
  loading: !0,
1268
1403
  error: null
1269
- }), O(t, e).then((c) => {
1270
- v || u({
1271
- collector: c,
1404
+ }), j(r, e).then((u) => {
1405
+ v || d({
1406
+ collector: u,
1272
1407
  loading: !1,
1273
1408
  error: null
1274
1409
  });
1275
- }).catch((c) => {
1276
- v || u({
1410
+ }).catch((u) => {
1411
+ v || d({
1277
1412
  collector: null,
1278
1413
  loading: !1,
1279
- error: c instanceof Error ? c : new Error(String(c))
1414
+ error: u instanceof Error ? u : new Error(String(u))
1280
1415
  });
1281
1416
  }), () => {
1282
1417
  v = !0;
1283
1418
  };
1284
1419
  }, [
1285
- t,
1286
1420
  r,
1421
+ t,
1287
1422
  e.name,
1288
1423
  s,
1289
- f,
1424
+ c,
1290
1425
  e.autoSubmit
1291
1426
  ]);
1292
- const g = r ? i : m.collector, C = r ? !1 : m.loading, A = r ? null : m.error;
1293
- N(() => {
1427
+ const g = t ? a : f.collector, C = t ? !1 : f.loading, N = t ? null : f.error;
1428
+ A(() => {
1294
1429
  if (g)
1295
- return g.install(t);
1296
- }, [t, g]);
1297
- const S = D(() => ne({
1430
+ return g.install(r);
1431
+ }, [r, g]);
1432
+ const S = W(() => X({
1298
1433
  values: e.initialValues ?? {},
1299
1434
  submitted: !1
1300
- }), [f]), k = De(g?.store ?? S), d = D(() => g?.getStatus() ?? q, [k, g]), x = D(() => ({
1435
+ }), [c]), k = De(g?.store ?? S), p = W(() => g?.getStatus() ?? O, [k, g]), x = W(() => ({
1301
1436
  ...k,
1302
- ...d
1303
- }), [k, d]), a = D(() => ({
1437
+ ...p
1438
+ }), [k, p]), i = W(() => ({
1304
1439
  name: e.name,
1305
1440
  store: S,
1306
1441
  functions: [],
@@ -1328,37 +1463,39 @@ function tt(e) {
1328
1463
  },
1329
1464
  reset: () => {
1330
1465
  },
1331
- getStatus: () => q
1466
+ getStatus: () => O
1332
1467
  }), [e.name, S]);
1333
1468
  return {
1334
- ...g ?? a,
1469
+ ...g ?? i,
1335
1470
  state: x,
1336
1471
  loading: C,
1337
- error: A
1472
+ error: N
1338
1473
  };
1339
1474
  }
1340
1475
  export {
1476
+ Ve as AgoNudge,
1341
1477
  Ke as AgoProvider,
1342
1478
  de as ChatInput,
1343
- Ue as ChatWidget,
1479
+ Je as ChatWidget,
1344
1480
  Ae as Markdown,
1345
- Ee as Message,
1346
- j as createFormCollector,
1481
+ Me as Message,
1482
+ B as createFormCollector,
1347
1483
  qe as createMockClient,
1348
1484
  He as deriveFormStatus,
1349
- O as loadFormCollector,
1485
+ j as loadFormCollector,
1350
1486
  ce as useAgo,
1351
- Qe as useAgoActivity,
1352
- Ze as useAgoAutoContinueAfterNavigation,
1353
- W as useAgoClient,
1354
- et as useAgoContext,
1355
- Ve as useAgoFunction,
1356
- Ye as useAgoNavigation,
1357
- Xe as useAgoPageState,
1487
+ tt as useAgoActivity,
1488
+ et as useAgoAutoContinueAfterNavigation,
1489
+ D as useAgoClient,
1490
+ nt as useAgoContext,
1491
+ Xe as useAgoFunction,
1492
+ Ze as useAgoNavigation,
1493
+ Qe as useAgoPageState,
1358
1494
  De as useAgoStore,
1359
- Je as useChat,
1495
+ Ye as useChat,
1360
1496
  Fe as useConversation,
1361
- tt as useFormCollector,
1497
+ rt as useFormCollector,
1362
1498
  K as useMessages,
1363
- L as useOptionalAgoClient
1499
+ z as useOptionalAgoClient,
1500
+ _e as useProactiveNudge
1364
1501
  };