@useago/sdk 1.0.11 → 1.1.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.
package/dist/react.js CHANGED
@@ -1,19 +1,19 @@
1
- import { t as q } from "./AgoClient-QcTtrN7u.js";
2
- import { i as J, n as Me, r as z, t as W } from "./createFormCollector-CFt1_QSL.js";
3
- import { t as Re } from "./createMockClient-DwdxNwEn.js";
4
- import G, { createContext as V, useCallback as I, useContext as $, useEffect as k, useId as j, useMemo as T, useRef as A, useState as M, useSyncExternalStore as Y } from "react";
5
- import { Fragment as X, jsx as a, jsxs as R } from "react/jsx-runtime";
6
- import Q from "react-markdown";
7
- import Z from "remark-gfm";
8
- function ee(e) {
9
- const [t, r] = M(!1), n = A(null), s = T(() => {
1
+ import { a as J, i as j, o as G, s as V, t as Y } from "./AgoClient-Cwx_eYSu.js";
2
+ import { i as X, n as Fe, r as H, t as L } from "./createFormCollector-CyWisAkI.js";
3
+ import { t as _e } from "./createMockClient-DwdxNwEn.js";
4
+ import Q, { createContext as Z, useCallback as R, useContext as $, useEffect as k, useId as ee, useMemo as _, useRef as A, useState as M, useSyncExternalStore as te } from "react";
5
+ import { Fragment as O, jsx as o, jsxs as I } from "react/jsx-runtime";
6
+ import ne from "react-markdown";
7
+ import re from "remark-gfm";
8
+ function oe(e) {
9
+ const [t, r] = M(!1), n = A(null), a = _(() => {
10
10
  if (n.current && (n.current.destroy(), n.current = null), !e) return null;
11
- const i = new q(e);
11
+ const i = new Y(e);
12
12
  return n.current = i, i;
13
13
  }, [e?.baseUrl, e?.widgetId]);
14
14
  return k(() => (r(!0), () => {
15
15
  n.current?.destroy(), n.current = null;
16
- }), [s]), k(() => {
16
+ }), [a]), k(() => {
17
17
  n.current && e && n.current.updateConfig({
18
18
  agent: e.agent,
19
19
  defaultAgentId: e.defaultAgentId,
@@ -32,12 +32,12 @@ function ee(e) {
32
32
  e?.debug,
33
33
  e?.warnOnEmptyReply
34
34
  ]), {
35
- client: s,
35
+ client: a,
36
36
  isReady: t
37
37
  };
38
38
  }
39
- var D = V(null), Te = ({ children: e, client: t, tools: r, helpers: n, pageContext: s, ...i }) => {
40
- const { client: u } = ee(t ? null : i), l = t || u;
39
+ var D = Z(null), Pe = ({ children: e, client: t, tools: r, helpers: n, pageContext: a, ...i }) => {
40
+ const { client: u } = oe(t ? null : i), l = t || u;
41
41
  return k(() => {
42
42
  if (!(!r || r.length === 0)) {
43
43
  for (const f of r) l.register(f);
@@ -48,11 +48,11 @@ var D = V(null), Te = ({ children: e, client: t, tools: r, helpers: n, pageConte
48
48
  }, [l, r]), k(() => {
49
49
  if (!n) return;
50
50
  const f = [];
51
- return import("./functions-CApuQZ2b.js").then((d) => d.n).then((d) => {
52
- for (const [y, m] of Object.entries(n)) {
53
- const C = d[y];
51
+ return import("./functions-CApuQZ2b.js").then((c) => c.n).then((c) => {
52
+ for (const [b, m] of Object.entries(n)) {
53
+ const C = c[b];
54
54
  if (!C) {
55
- console.warn(`[AGO] Unknown helper: "${y}"`);
55
+ console.warn(`[AGO] Unknown helper: "${b}"`);
56
56
  continue;
57
57
  }
58
58
  const g = m === !0 ? C : {
@@ -62,91 +62,92 @@ var D = V(null), Te = ({ children: e, client: t, tools: r, helpers: n, pageConte
62
62
  l.register(g), f.push(g.name);
63
63
  }
64
64
  }), () => {
65
- for (const d of f) l.unregisterFunction(d);
65
+ for (const c of f) l.unregisterFunction(c);
66
66
  };
67
67
  }, [l, n]), k(() => {
68
- s === "auto" && l.enableAutoPageContext();
69
- }, [l, s]), /* @__PURE__ */ a(D.Provider, {
68
+ a === "auto" && l.enableAutoPageContext();
69
+ }, [l, a]), /* @__PURE__ */ o(D.Provider, {
70
70
  value: l,
71
71
  children: e
72
72
  });
73
73
  };
74
- function P() {
74
+ function T() {
75
75
  const e = $(D);
76
76
  if (!e) throw new Error('useAgoClient must be used within an <AgoProvider>. Wrap your component tree with <AgoProvider baseUrl="...">.');
77
77
  return e;
78
78
  }
79
- function L() {
79
+ function W() {
80
80
  return $(D);
81
81
  }
82
- function O({ client: e, conversationId: t } = {}) {
83
- const r = L(), n = e || r;
82
+ function B({ client: e, conversationId: t } = {}) {
83
+ const r = W(), n = e || r;
84
84
  if (!n) throw new Error("useMessages requires an AgoClient. Either pass it as options.client or wrap your app in <AgoProvider>.");
85
- const [s, i] = M([]), [u, l] = M(t), [f, d] = M(!1), [y, m] = M(null);
85
+ const [a, i] = M([]), [u, l] = M(t), [f, c] = M(!1), [b, m] = M(null);
86
86
  k(() => {
87
87
  t && t !== u && (l(t), C(t));
88
88
  }, [t]);
89
89
  const C = async (g) => {
90
90
  try {
91
91
  i(await n.getMessages(g));
92
- } catch (b) {
93
- m(b instanceof Error ? b : /* @__PURE__ */ new Error("Failed to load messages"));
92
+ } catch (x) {
93
+ m(x instanceof Error ? x : /* @__PURE__ */ new Error("Failed to load messages"));
94
94
  }
95
95
  };
96
96
  return k(() => {
97
97
  const g = (p) => {
98
98
  u || l(p.conversationId);
99
- }, b = (p) => {
100
- i((c) => {
101
- const x = c[c.length - 1];
102
- return x && x.id === p.messageId ? [...c.slice(0, -1), {
103
- ...x,
104
- content: x.content + p.content
105
- }] : c;
99
+ }, x = (p) => {
100
+ i((d) => {
101
+ const h = d[d.length - 1];
102
+ return h && h.id === p.messageId ? [...d.slice(0, -1), {
103
+ ...h,
104
+ content: h.content + p.content
105
+ }] : d;
106
106
  });
107
107
  }, v = (p) => {
108
- i((c) => {
109
- let x = -1;
110
- for (let S = c.length - 1; S >= 0; S--) if (c[S].role === "assistant" && c[S].status === "IN_PROGRESS") {
111
- x = S;
108
+ i((d) => {
109
+ let h = -1;
110
+ for (let S = d.length - 1; S >= 0; S--) if (d[S].role === "assistant" && d[S].status === "IN_PROGRESS") {
111
+ h = S;
112
112
  break;
113
113
  }
114
- return x < 0 ? c : [
115
- ...c.slice(0, x),
114
+ return h < 0 ? d : [
115
+ ...d.slice(0, h),
116
116
  {
117
- ...c[x],
117
+ ...d[h],
118
118
  ...p
119
119
  },
120
- ...c.slice(x + 1)
120
+ ...d.slice(h + 1)
121
121
  ];
122
122
  });
123
123
  }, w = (p) => {
124
- i((c) => {
125
- const x = c.findIndex((S) => S.id === p.id);
126
- return x >= 0 ? [
127
- ...c.slice(0, x),
124
+ i((d) => {
125
+ const h = d.findIndex((S) => S.id === p.id);
126
+ return h >= 0 ? [
127
+ ...d.slice(0, h),
128
128
  p,
129
- ...c.slice(x + 1)
130
- ] : [...c, p];
131
- }), d(!1);
132
- }, o = (p) => {
133
- m(new Error(p.error)), d(!1);
129
+ ...d.slice(h + 1)
130
+ ] : [...d, p];
131
+ }), c(!1);
132
+ }, s = (p) => {
133
+ m(new Error(p.error)), c(!1);
134
134
  };
135
- return n.on("message:start", g), n.on("message:chunk", b), n.on("message:answer-complete", v), n.on("message:complete", w), n.on("message:error", o), () => {
136
- n.off("message:start", g), n.off("message:chunk", b), n.off("message:answer-complete", v), n.off("message:complete", w), n.off("message:error", o);
135
+ return n.on("message:start", g), n.on("message:chunk", x), n.on("message:answer-complete", v), n.on("message:complete", w), n.on("message:error", s), () => {
136
+ n.off("message:start", g), n.off("message:chunk", x), n.off("message:answer-complete", v), n.off("message:complete", w), n.off("message:error", s);
137
137
  };
138
138
  }, [n, u]), {
139
- messages: s,
139
+ messages: a,
140
140
  isLoading: f,
141
- error: y,
142
- sendMessage: I(async (g, b) => {
143
- d(!0), m(null);
141
+ error: b,
142
+ sendMessage: R(async (g, x) => {
143
+ c(!0), m(null);
144
144
  const v = {
145
145
  id: `temp-${Date.now()}`,
146
146
  conversationId: u || "",
147
147
  content: g,
148
148
  role: "user",
149
149
  status: "DONE",
150
+ attachments: x && x.length > 0 ? j(x) : void 0,
150
151
  createdAt: /* @__PURE__ */ new Date()
151
152
  }, w = {
152
153
  id: `temp-assistant-${Date.now()}`,
@@ -156,62 +157,62 @@ function O({ client: e, conversationId: t } = {}) {
156
157
  status: "IN_PROGRESS",
157
158
  createdAt: /* @__PURE__ */ new Date()
158
159
  };
159
- i((o) => [
160
- ...o,
160
+ i((s) => [
161
+ ...s,
161
162
  v,
162
163
  w
163
164
  ]);
164
165
  try {
165
- const o = await n.sendMessage(g, {
166
+ const s = await n.sendMessage(g, {
166
167
  conversationId: u,
167
- files: b
168
+ files: x
168
169
  });
169
- return o.conversationId && !u && l(o.conversationId), i((p) => {
170
- const c = p.filter((S) => !S.id.startsWith("temp-")), x = {
170
+ return s.conversationId && !u && l(s.conversationId), i((p) => {
171
+ const d = p.filter((S) => !S.id.startsWith("temp-")), h = {
171
172
  ...v,
172
173
  id: v.id.replace("temp-", "user-"),
173
- conversationId: o.conversationId
174
+ conversationId: s.conversationId
174
175
  };
175
- return c.some((S) => S.id === o.id) ? [...c, x].sort((S, _) => new Date(S.createdAt).getTime() - new Date(_.createdAt).getTime()) : [
176
- ...c,
177
- x,
178
- o
176
+ return d.some((S) => S.id === s.id) ? [...d, h].sort((S, z) => new Date(S.createdAt).getTime() - new Date(z.createdAt).getTime()) : [
177
+ ...d,
178
+ h,
179
+ s
179
180
  ];
180
- }), o;
181
- } catch (o) {
182
- return m(o instanceof Error ? o : /* @__PURE__ */ new Error("Failed to send message")), d(!1), i((p) => p.filter((c) => !c.id.startsWith("temp-"))), null;
181
+ }), s;
182
+ } catch (s) {
183
+ return m(s instanceof Error ? s : /* @__PURE__ */ new Error("Failed to send message")), c(!1), i((p) => p.filter((d) => !d.id.startsWith("temp-"))), null;
183
184
  }
184
185
  }, [n, u]),
185
- clearMessages: I(() => {
186
+ clearMessages: R(() => {
186
187
  i([]), l(void 0), m(null);
187
188
  }, []),
188
189
  conversationId: u
189
190
  };
190
191
  }
191
- var te = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", allowFiles: n = !1, className: s = "" }) => {
192
- const [i, u] = M(""), [l, f] = M([]), d = A(null), y = A(null), m = I(() => {
193
- const o = y.current;
194
- if (!o) return;
192
+ var ae = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", allowFiles: n = !1, className: a = "" }) => {
193
+ const [i, u] = M(""), [l, f] = M([]), c = A(null), b = A(null), m = R(() => {
194
+ const s = b.current;
195
+ if (!s) return;
195
196
  const p = 110;
196
- o.style.height = "auto", o.style.height = `${Math.min(o.scrollHeight + 2, p)}px`, o.style.overflowY = o.scrollHeight + 2 > p ? "auto" : "hidden";
197
- }, []), C = I((o) => {
198
- o.preventDefault(), (i.trim() || l.length > 0) && (e(i.trim(), l.length > 0 ? l : void 0), u(""), f([]), requestAnimationFrame(m));
197
+ s.style.height = "auto", s.style.height = `${Math.min(s.scrollHeight + 2, p)}px`, s.style.overflowY = s.scrollHeight + 2 > p ? "auto" : "hidden";
198
+ }, []), C = R((s) => {
199
+ s.preventDefault(), (i.trim() || l.length > 0) && (e(i.trim(), l.length > 0 ? l : void 0), u(""), f([]), requestAnimationFrame(m));
199
200
  }, [
200
201
  i,
201
202
  l,
202
203
  e,
203
204
  m
204
- ]), g = I((o) => {
205
- o.key === "Enter" && !o.shiftKey && (o.preventDefault(), C(o));
206
- }, [C]), b = I((o) => {
207
- const p = Array.from(o.target.files || []);
208
- f((c) => [...c, ...p]);
209
- }, []), v = I((o) => {
210
- f((p) => p.filter((c, x) => x !== o));
205
+ ]), g = R((s) => {
206
+ s.key === "Enter" && !s.shiftKey && (s.preventDefault(), C(s));
207
+ }, [C]), x = R((s) => {
208
+ const p = Array.from(s.target.files || []);
209
+ f((d) => [...d, ...p]);
210
+ }, []), v = R((s) => {
211
+ f((p) => p.filter((d, h) => h !== s));
211
212
  }, []), w = i.trim() || l.length > 0;
212
- return /* @__PURE__ */ R("form", {
213
+ return /* @__PURE__ */ I("form", {
213
214
  onSubmit: C,
214
- className: `ago-chat-input ${s}`,
215
+ className: `ago-chat-input ${a}`,
215
216
  style: {
216
217
  display: "flex",
217
218
  flexDirection: "column",
@@ -220,14 +221,14 @@ var te = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
220
221
  borderTop: "1px solid #dee3e8",
221
222
  backgroundColor: "#fff"
222
223
  },
223
- children: [l.length > 0 && /* @__PURE__ */ a("div", {
224
+ children: [l.length > 0 && /* @__PURE__ */ o("div", {
224
225
  className: "ago-chat-input__files",
225
226
  style: {
226
227
  display: "flex",
227
228
  flexWrap: "wrap",
228
229
  gap: "6px"
229
230
  },
230
- children: l.map((o, p) => /* @__PURE__ */ R("div", {
231
+ children: l.map((s, p) => /* @__PURE__ */ I("div", {
231
232
  style: {
232
233
  display: "flex",
233
234
  alignItems: "center",
@@ -238,18 +239,18 @@ var te = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
238
239
  fontSize: "12px",
239
240
  color: "#30373e"
240
241
  },
241
- children: [/* @__PURE__ */ a("span", {
242
+ children: [/* @__PURE__ */ o("span", {
242
243
  style: {
243
244
  maxWidth: "120px",
244
245
  overflow: "hidden",
245
246
  textOverflow: "ellipsis",
246
247
  whiteSpace: "nowrap"
247
248
  },
248
- children: o.name
249
- }), /* @__PURE__ */ a("button", {
249
+ children: s.name
250
+ }), /* @__PURE__ */ o("button", {
250
251
  type: "button",
251
252
  onClick: () => v(p),
252
- "aria-label": `Remove ${o.name}`,
253
+ "aria-label": `Remove ${s.name}`,
253
254
  style: {
254
255
  border: "none",
255
256
  background: "none",
@@ -262,16 +263,16 @@ var te = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
262
263
  children: "×"
263
264
  })]
264
265
  }, p))
265
- }), /* @__PURE__ */ R("div", {
266
+ }), /* @__PURE__ */ I("div", {
266
267
  style: {
267
268
  display: "flex",
268
269
  gap: "8px",
269
270
  alignItems: "flex-end"
270
271
  },
271
272
  children: [
272
- n && /* @__PURE__ */ R(X, { children: [/* @__PURE__ */ a("button", {
273
+ n && /* @__PURE__ */ I(O, { children: [/* @__PURE__ */ o("button", {
273
274
  type: "button",
274
- onClick: () => d.current?.click(),
275
+ onClick: () => c.current?.click(),
275
276
  disabled: t,
276
277
  "aria-label": "Attach file",
277
278
  style: {
@@ -285,18 +286,18 @@ var te = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
285
286
  lineHeight: 1
286
287
  },
287
288
  children: "+"
288
- }), /* @__PURE__ */ a("input", {
289
- ref: d,
289
+ }), /* @__PURE__ */ o("input", {
290
+ ref: c,
290
291
  type: "file",
291
292
  multiple: !0,
292
- onChange: b,
293
+ onChange: x,
293
294
  style: { display: "none" }
294
295
  })] }),
295
- /* @__PURE__ */ a("textarea", {
296
- ref: y,
296
+ /* @__PURE__ */ o("textarea", {
297
+ ref: b,
297
298
  value: i,
298
- onChange: (o) => {
299
- u(o.target.value), m();
299
+ onChange: (s) => {
300
+ u(s.target.value), m();
300
301
  },
301
302
  onKeyDown: g,
302
303
  placeholder: r,
@@ -320,14 +321,14 @@ var te = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
320
321
  backgroundColor: "#f8f8f8",
321
322
  transition: "border-color 0.15s"
322
323
  },
323
- onFocus: (o) => {
324
- o.currentTarget.style.borderColor = "#1b5fc4";
324
+ onFocus: (s) => {
325
+ s.currentTarget.style.borderColor = "#1b5fc4";
325
326
  },
326
- onBlur: (o) => {
327
- o.currentTarget.style.borderColor = "#dee3e8";
327
+ onBlur: (s) => {
328
+ s.currentTarget.style.borderColor = "#dee3e8";
328
329
  }
329
330
  }),
330
- /* @__PURE__ */ a("button", {
331
+ /* @__PURE__ */ o("button", {
331
332
  type: "submit",
332
333
  disabled: t || !w,
333
334
  style: {
@@ -346,7 +347,7 @@ var te = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
346
347
  ]
347
348
  })]
348
349
  });
349
- }, ne = ({ href: e, children: t, ...r }) => /* @__PURE__ */ a("a", {
350
+ }, se = ({ href: e, children: t, ...r }) => /* @__PURE__ */ o("a", {
350
351
  href: e,
351
352
  target: "_blank",
352
353
  rel: "noopener noreferrer",
@@ -356,7 +357,7 @@ var te = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
356
357
  },
357
358
  ...r,
358
359
  children: t
359
- }), re = ({ children: e, ...t }) => /* @__PURE__ */ a("p", {
360
+ }), ie = ({ children: e, ...t }) => /* @__PURE__ */ o("p", {
360
361
  style: {
361
362
  margin: "0 0 8px 0",
362
363
  lineHeight: "1.6"
@@ -364,17 +365,17 @@ var te = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
364
365
  ...t,
365
366
  children: e
366
367
  }), N = (e, t) => {
367
- const r = ({ children: n, ...s }) => G.createElement(`h${e}`, {
368
+ const r = ({ children: n, ...a }) => Q.createElement(`h${e}`, {
368
369
  style: {
369
370
  margin: "16px 0 8px 0",
370
371
  fontSize: t,
371
372
  fontWeight: 600,
372
373
  lineHeight: "1.3"
373
374
  },
374
- ...s
375
+ ...a
375
376
  }, n);
376
377
  return r.displayName = `MarkdownHeading${e}`, r;
377
- }, oe = ({ children: e, ...t }) => /* @__PURE__ */ a("ul", {
378
+ }, le = ({ children: e, ...t }) => /* @__PURE__ */ o("ul", {
378
379
  style: {
379
380
  margin: "0 0 8px 0",
380
381
  paddingLeft: "20px",
@@ -383,7 +384,7 @@ var te = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
383
384
  },
384
385
  ...t,
385
386
  children: e
386
- }), se = ({ children: e, ...t }) => /* @__PURE__ */ a("ol", {
387
+ }), de = ({ children: e, ...t }) => /* @__PURE__ */ o("ol", {
387
388
  style: {
388
389
  margin: "0 0 8px 0",
389
390
  paddingLeft: "20px",
@@ -392,7 +393,7 @@ var te = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
392
393
  },
393
394
  ...t,
394
395
  children: e
395
- }), ae = ({ children: e, ...t }) => /* @__PURE__ */ a("li", {
396
+ }), ce = ({ children: e, ...t }) => /* @__PURE__ */ o("li", {
396
397
  style: {
397
398
  display: "list-item",
398
399
  margin: "2px 0",
@@ -400,8 +401,8 @@ var te = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
400
401
  },
401
402
  ...t,
402
403
  children: e
403
- }), ie = ({ className: e, children: t, ...r }) => e !== void 0 || String(t).includes(`
404
- `) ? /* @__PURE__ */ a("code", {
404
+ }), ue = ({ className: e, children: t, ...r }) => e !== void 0 || String(t).includes(`
405
+ `) ? /* @__PURE__ */ o("code", {
405
406
  style: {
406
407
  display: "block",
407
408
  background: "#f5f5f5",
@@ -413,7 +414,7 @@ var te = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
413
414
  },
414
415
  ...r,
415
416
  children: t
416
- }) : /* @__PURE__ */ a("code", {
417
+ }) : /* @__PURE__ */ o("code", {
417
418
  style: {
418
419
  background: "#f0f2f5",
419
420
  padding: "2px 5px",
@@ -423,11 +424,11 @@ var te = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
423
424
  },
424
425
  ...r,
425
426
  children: t
426
- }), le = ({ children: e, ...t }) => /* @__PURE__ */ a("pre", {
427
+ }), pe = ({ children: e, ...t }) => /* @__PURE__ */ o("pre", {
427
428
  style: { margin: "0 0 8px 0" },
428
429
  ...t,
429
430
  children: e
430
- }), ce = ({ children: e, ...t }) => /* @__PURE__ */ a("blockquote", {
431
+ }), fe = ({ children: e, ...t }) => /* @__PURE__ */ o("blockquote", {
431
432
  style: {
432
433
  borderLeft: "4px solid #dee3e8",
433
434
  paddingLeft: "12px",
@@ -437,12 +438,12 @@ var te = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
437
438
  },
438
439
  ...t,
439
440
  children: e
440
- }), de = ({ children: e, ...t }) => /* @__PURE__ */ a("div", {
441
+ }), ge = ({ children: e, ...t }) => /* @__PURE__ */ o("div", {
441
442
  style: {
442
443
  overflowX: "auto",
443
444
  margin: "0 0 8px 0"
444
445
  },
445
- children: /* @__PURE__ */ a("table", {
446
+ children: /* @__PURE__ */ o("table", {
446
447
  style: {
447
448
  borderCollapse: "collapse",
448
449
  width: "100%",
@@ -451,7 +452,7 @@ var te = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
451
452
  ...t,
452
453
  children: e
453
454
  })
454
- }), ue = ({ children: e, ...t }) => /* @__PURE__ */ a("th", {
455
+ }), me = ({ children: e, ...t }) => /* @__PURE__ */ o("th", {
455
456
  style: {
456
457
  border: "1px solid #dee3e8",
457
458
  padding: "6px 10px",
@@ -461,14 +462,14 @@ var te = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
461
462
  },
462
463
  ...t,
463
464
  children: e
464
- }), pe = ({ children: e, ...t }) => /* @__PURE__ */ a("td", {
465
+ }), xe = ({ children: e, ...t }) => /* @__PURE__ */ o("td", {
465
466
  style: {
466
467
  border: "1px solid #dee3e8",
467
468
  padding: "6px 10px"
468
469
  },
469
470
  ...t,
470
471
  children: e
471
- }), fe = ({ alt: e, ...t }) => /* @__PURE__ */ a("img", {
472
+ }), he = ({ alt: e, ...t }) => /* @__PURE__ */ o("img", {
472
473
  alt: e ?? "",
473
474
  style: {
474
475
  maxWidth: "100%",
@@ -476,39 +477,116 @@ var te = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
476
477
  margin: "4px 0"
477
478
  },
478
479
  ...t
479
- }), ge = (e) => /* @__PURE__ */ a("hr", {
480
+ }), ye = (e) => /* @__PURE__ */ o("hr", {
480
481
  style: {
481
482
  border: "none",
482
483
  borderTop: "1px solid #dee3e8",
483
484
  margin: "12px 0"
484
485
  },
485
486
  ...e
486
- }), me = {
487
- a: ne,
488
- p: re,
487
+ }), be = {
488
+ a: se,
489
+ p: ie,
489
490
  h1: N(1, "20px"),
490
491
  h2: N(2, "18px"),
491
492
  h3: N(3, "16px"),
492
493
  h4: N(4, "15px"),
493
494
  h5: N(5, "14px"),
494
495
  h6: N(6, "13px"),
495
- ul: oe,
496
- ol: se,
497
- li: ae,
498
- code: ie,
499
- pre: le,
500
- blockquote: ce,
501
- table: de,
502
- th: ue,
503
- td: pe,
504
- img: fe,
505
- hr: ge
506
- }, xe = [Z], he = ({ content: e }) => /* @__PURE__ */ a(Q, {
507
- remarkPlugins: xe,
508
- components: me,
496
+ ul: le,
497
+ ol: de,
498
+ li: ce,
499
+ code: ue,
500
+ pre: pe,
501
+ blockquote: fe,
502
+ table: ge,
503
+ th: me,
504
+ td: xe,
505
+ img: he,
506
+ hr: ye
507
+ }, ve = [re], we = ({ content: e }) => /* @__PURE__ */ o(ne, {
508
+ remarkPlugins: ve,
509
+ components: be,
509
510
  children: e
510
- }), ye = ({ source: e, index: t }) => {
511
- const r = /* @__PURE__ */ R("div", {
511
+ }), Ce = ({ attachment: e, isUser: t }) => {
512
+ const r = V(e.url);
513
+ if (J(e)) return /* @__PURE__ */ o("a", {
514
+ href: r,
515
+ target: "_blank",
516
+ rel: "noopener noreferrer",
517
+ style: {
518
+ display: "inline-block",
519
+ textDecoration: "none"
520
+ },
521
+ children: /* @__PURE__ */ o("img", {
522
+ src: r,
523
+ alt: e.name,
524
+ loading: "lazy",
525
+ style: {
526
+ maxWidth: "180px",
527
+ maxHeight: "160px",
528
+ objectFit: "cover",
529
+ borderRadius: "10px",
530
+ border: "1px solid #dee3e8",
531
+ display: "block"
532
+ }
533
+ })
534
+ });
535
+ const n = G(e.fileSize), a = /* @__PURE__ */ I(O, { children: [/* @__PURE__ */ o("span", {
536
+ style: {
537
+ fontSize: "16px",
538
+ lineHeight: 1,
539
+ flexShrink: 0
540
+ },
541
+ "aria-hidden": !0,
542
+ children: "📄"
543
+ }), /* @__PURE__ */ I("span", {
544
+ style: {
545
+ display: "flex",
546
+ flexDirection: "column",
547
+ minWidth: 0
548
+ },
549
+ children: [/* @__PURE__ */ o("span", {
550
+ style: {
551
+ overflow: "hidden",
552
+ textOverflow: "ellipsis",
553
+ whiteSpace: "nowrap",
554
+ maxWidth: "160px"
555
+ },
556
+ title: e.name,
557
+ children: e.name
558
+ }), n && /* @__PURE__ */ o("span", {
559
+ style: {
560
+ fontSize: "11px",
561
+ color: "#6b6d6f"
562
+ },
563
+ children: n
564
+ })]
565
+ })] }), i = {
566
+ display: "inline-flex",
567
+ alignItems: "center",
568
+ gap: "8px",
569
+ padding: "8px 12px",
570
+ borderRadius: "10px",
571
+ border: "1px solid #dee3e8",
572
+ backgroundColor: t ? "rgba(255,255,255,0.12)" : "#fff",
573
+ color: t ? "#fff" : "#30373e",
574
+ fontSize: "13px",
575
+ textDecoration: "none",
576
+ maxWidth: "220px"
577
+ };
578
+ return r ? /* @__PURE__ */ o("a", {
579
+ href: r,
580
+ target: "_blank",
581
+ rel: "noopener noreferrer",
582
+ style: i,
583
+ children: a
584
+ }) : /* @__PURE__ */ o("div", {
585
+ style: i,
586
+ children: a
587
+ });
588
+ }, Se = ({ source: e, index: t }) => {
589
+ const r = /* @__PURE__ */ I("div", {
512
590
  style: {
513
591
  display: "flex",
514
592
  alignItems: "center",
@@ -516,7 +594,7 @@ var te = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
516
594
  width: "100%",
517
595
  minWidth: 0
518
596
  },
519
- children: [/* @__PURE__ */ a("div", {
597
+ children: [/* @__PURE__ */ o("div", {
520
598
  style: {
521
599
  flexShrink: 0,
522
600
  width: "18px",
@@ -532,7 +610,7 @@ var te = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
532
610
  backgroundColor: "#f0f4ff"
533
611
  },
534
612
  children: t + 1
535
- }), /* @__PURE__ */ a("div", {
613
+ }), /* @__PURE__ */ o("div", {
536
614
  style: {
537
615
  fontSize: "12px",
538
616
  overflow: "hidden",
@@ -556,23 +634,23 @@ var te = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
556
634
  minWidth: 0,
557
635
  transition: "border-color 0.15s"
558
636
  };
559
- return e.url ? /* @__PURE__ */ a("a", {
637
+ return e.url ? /* @__PURE__ */ o("a", {
560
638
  href: e.url,
561
639
  target: "_blank",
562
640
  rel: "noopener noreferrer",
563
641
  style: n,
564
- onMouseEnter: (s) => {
565
- s.currentTarget.style.borderColor = "#1b5fc4";
642
+ onMouseEnter: (a) => {
643
+ a.currentTarget.style.borderColor = "#1b5fc4";
566
644
  },
567
- onMouseLeave: (s) => {
568
- s.currentTarget.style.borderColor = "#dee3e8";
645
+ onMouseLeave: (a) => {
646
+ a.currentTarget.style.borderColor = "#dee3e8";
569
647
  },
570
648
  children: r
571
- }) : /* @__PURE__ */ a("div", {
649
+ }) : /* @__PURE__ */ o("div", {
572
650
  style: n,
573
651
  children: r
574
652
  });
575
- }, be = () => /* @__PURE__ */ R("div", {
653
+ }, ke = () => /* @__PURE__ */ I("div", {
576
654
  style: {
577
655
  display: "flex",
578
656
  gap: "4px",
@@ -582,22 +660,22 @@ var te = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
582
660
  0,
583
661
  1,
584
662
  2
585
- ].map((e) => /* @__PURE__ */ a("div", { style: {
663
+ ].map((e) => /* @__PURE__ */ o("div", { style: {
586
664
  width: "6px",
587
665
  height: "6px",
588
666
  borderRadius: "50%",
589
667
  backgroundColor: "#b5bfc8",
590
668
  animation: "ago-pulse 1.2s ease-in-out infinite",
591
669
  animationDelay: `${e * 0.2}s`
592
- } }, e)), /* @__PURE__ */ a("style", { children: `
670
+ } }, e)), /* @__PURE__ */ o("style", { children: `
593
671
  @keyframes ago-pulse {
594
672
  0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
595
673
  40% { opacity: 1; transform: scale(1); }
596
674
  }
597
675
  ` })]
598
- }), ve = ({ message: e, className: t = "", showAgentName: r = !1, isLast: n = !1, onFollowUpClick: s }) => {
676
+ }), Me = ({ message: e, className: t = "", showAgentName: r = !1, isLast: n = !1, onFollowUpClick: a }) => {
599
677
  const i = e.role === "user", u = e.status === "IN_PROGRESS";
600
- return /* @__PURE__ */ R("div", {
678
+ return /* @__PURE__ */ I("div", {
601
679
  className: `ago-message ago-message--${e.role} ${t}`,
602
680
  style: {
603
681
  display: "flex",
@@ -606,7 +684,7 @@ var te = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
606
684
  marginBottom: "16px"
607
685
  },
608
686
  children: [
609
- !i && r && e.agent && /* @__PURE__ */ a("div", {
687
+ !i && r && e.agent && /* @__PURE__ */ o("div", {
610
688
  className: "ago-message__agent",
611
689
  style: {
612
690
  display: "flex",
@@ -620,7 +698,7 @@ var te = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
620
698
  },
621
699
  children: e.agent.displayName || e.agent.name
622
700
  }),
623
- !i && e.sources && e.sources.length > 0 && /* @__PURE__ */ a("div", {
701
+ !i && e.sources && e.sources.length > 0 && /* @__PURE__ */ o("div", {
624
702
  className: "ago-message__sources",
625
703
  style: {
626
704
  display: "grid",
@@ -630,12 +708,27 @@ var te = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
630
708
  width: "100%",
631
709
  maxWidth: "85%"
632
710
  },
633
- children: e.sources.map((l, f) => /* @__PURE__ */ a(ye, {
711
+ children: e.sources.map((l, f) => /* @__PURE__ */ o(Se, {
634
712
  source: l,
635
713
  index: f
636
714
  }, l.id))
637
715
  }),
638
- /* @__PURE__ */ a("div", {
716
+ e.attachments && e.attachments.length > 0 && /* @__PURE__ */ o("div", {
717
+ className: "ago-message__attachments",
718
+ style: {
719
+ display: "flex",
720
+ flexWrap: "wrap",
721
+ gap: "6px",
722
+ marginBottom: "6px",
723
+ justifyContent: i ? "flex-end" : "flex-start",
724
+ maxWidth: "75%"
725
+ },
726
+ children: e.attachments.map((l) => /* @__PURE__ */ o(Ce, {
727
+ attachment: l,
728
+ isUser: i
729
+ }, l.id))
730
+ }),
731
+ (e.content || u) && /* @__PURE__ */ o("div", {
639
732
  className: "ago-message__content",
640
733
  style: {
641
734
  maxWidth: i ? "75%" : "100%",
@@ -647,9 +740,9 @@ var te = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
647
740
  fontSize: "16px",
648
741
  lineHeight: "1.6"
649
742
  },
650
- children: e.content ? /* @__PURE__ */ a(he, { content: e.content }) : u && /* @__PURE__ */ a(be, {})
743
+ children: e.content ? /* @__PURE__ */ o(we, { content: e.content }) : u && /* @__PURE__ */ o(ke, {})
651
744
  }),
652
- n && e.followUpReplies && e.followUpReplies.length > 0 && /* @__PURE__ */ a("div", {
745
+ n && e.followUpReplies && e.followUpReplies.length > 0 && /* @__PURE__ */ o("div", {
653
746
  className: "ago-message__followups",
654
747
  style: {
655
748
  display: "flex",
@@ -657,11 +750,11 @@ var te = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
657
750
  gap: "8px",
658
751
  marginTop: "10px"
659
752
  },
660
- children: e.followUpReplies.map((l, f) => /* @__PURE__ */ a("button", {
753
+ children: e.followUpReplies.map((l, f) => /* @__PURE__ */ o("button", {
661
754
  type: "button",
662
755
  className: "ago-message__followup-btn",
663
- disabled: !s,
664
- onClick: s ? () => s(l) : void 0,
756
+ disabled: !a,
757
+ onClick: a ? () => a(l) : void 0,
665
758
  style: {
666
759
  minHeight: "36px",
667
760
  padding: "6px 14px",
@@ -670,54 +763,54 @@ var te = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
670
763
  border: "1px solid #dee3e8",
671
764
  backgroundColor: "#fff",
672
765
  color: "#30373e",
673
- cursor: s ? "pointer" : "default",
766
+ cursor: a ? "pointer" : "default",
674
767
  transition: "border-color 0.15s"
675
768
  },
676
- onMouseEnter: (d) => {
677
- d.currentTarget.style.borderColor = "#1b5fc4";
769
+ onMouseEnter: (c) => {
770
+ c.currentTarget.style.borderColor = "#1b5fc4";
678
771
  },
679
- onMouseLeave: (d) => {
680
- d.currentTarget.style.borderColor = "#dee3e8";
772
+ onMouseLeave: (c) => {
773
+ c.currentTarget.style.borderColor = "#dee3e8";
681
774
  },
682
775
  children: l
683
776
  }, f))
684
777
  })
685
778
  ]
686
779
  });
687
- }, _e = ({ client: e, conversationId: t, title: r = "Chat", welcomeMessage: n = "Hello! How can I help you today?", placeholder: s = "Type a message...", allowFiles: i = !1, height: u = 500, logoUrl: l, showAgentName: f = !1, forms: d, onFollowUpClick: y, className: m = "", onMessageSent: C, onMessageReceived: g }) => {
688
- const b = A(null), v = L(), w = e ?? v, { messages: o, isLoading: p, error: c, sendMessage: x } = O({
780
+ }, He = ({ client: e, conversationId: t, title: r = "Chat", welcomeMessage: n = "Hello! How can I help you today?", placeholder: a = "Type a message...", allowFiles: i = !1, height: u = 500, logoUrl: l, showAgentName: f = !1, forms: c, onFollowUpClick: b, className: m = "", onMessageSent: C, onMessageReceived: g }) => {
781
+ const x = A(null), v = W(), w = e ?? v, { messages: s, isLoading: p, error: d, sendMessage: h } = B({
689
782
  client: e,
690
783
  conversationId: t
691
784
  });
692
785
  k(() => {
693
- if (!w || !d || d.length === 0) return;
694
- let h = !1;
786
+ if (!w || !c || c.length === 0) return;
787
+ let y = !1;
695
788
  const F = [];
696
- return Promise.all(d.map((E) => E.schema != null ? Promise.resolve(W(E)) : z(w, E))).then((E) => {
697
- if (!h)
698
- for (const U of E) F.push(U.install(w));
789
+ return Promise.all(c.map((E) => E.schema != null ? Promise.resolve(L(E)) : H(w, E))).then((E) => {
790
+ if (!y)
791
+ for (const q of E) F.push(q.install(w));
699
792
  }).catch(() => {
700
793
  }), () => {
701
- h = !0, F.forEach((E) => E());
794
+ y = !0, F.forEach((E) => E());
702
795
  };
703
- }, [w, d ? JSON.stringify(d.map((h) => [
704
- h.name,
705
- h.schema ?? null,
706
- h.submit ?? !1,
707
- h.description ?? null
796
+ }, [w, c ? JSON.stringify(c.map((y) => [
797
+ y.name,
798
+ y.schema ?? null,
799
+ y.submit ?? !1,
800
+ y.description ?? null
708
801
  ])) : ""]), k(() => {
709
- b.current?.scrollIntoView({ behavior: "smooth" });
710
- }, [o]), k(() => {
711
- const h = o[o.length - 1];
712
- h && h.role === "assistant" && h.status === "DONE" && g && g({
713
- id: h.id,
714
- content: h.content
802
+ x.current?.scrollIntoView({ behavior: "smooth" });
803
+ }, [s]), k(() => {
804
+ const y = s[s.length - 1];
805
+ y && y.role === "assistant" && y.status === "DONE" && g && g({
806
+ id: y.id,
807
+ content: y.content
715
808
  });
716
- }, [o, g]);
717
- const S = async (h, F) => {
718
- C?.(h), await x(h, F);
719
- }, _ = o[o.length - 1], B = p && _?.role === "assistant" && _.status === "IN_PROGRESS", K = y === !1 ? void 0 : y ?? ((h) => S(h));
720
- return /* @__PURE__ */ R("div", {
809
+ }, [s, g]);
810
+ const S = async (y, F) => {
811
+ C?.(y), await h(y, F);
812
+ }, z = s[s.length - 1], K = p && z?.role === "assistant" && z.status === "IN_PROGRESS", U = b === !1 ? void 0 : b ?? ((y) => S(y));
813
+ return /* @__PURE__ */ I("div", {
721
814
  className: `ago-chat-widget ${m}`,
722
815
  style: {
723
816
  display: "flex",
@@ -732,7 +825,7 @@ var te = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
732
825
  boxShadow: "rgba(15, 15, 15, 0.08) 0px 2px 16px 0px"
733
826
  },
734
827
  children: [
735
- /* @__PURE__ */ R("div", {
828
+ /* @__PURE__ */ I("div", {
736
829
  className: "ago-chat-widget__header",
737
830
  style: {
738
831
  padding: "14px 16px",
@@ -743,14 +836,14 @@ var te = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
743
836
  alignItems: "center",
744
837
  gap: "10px"
745
838
  },
746
- children: [l && /* @__PURE__ */ a("img", {
839
+ children: [l && /* @__PURE__ */ o("img", {
747
840
  src: l,
748
841
  alt: "Logo",
749
842
  style: {
750
843
  height: "24px",
751
844
  width: "auto"
752
845
  }
753
- }), /* @__PURE__ */ a("h3", {
846
+ }), /* @__PURE__ */ o("h3", {
754
847
  style: {
755
848
  margin: 0,
756
849
  fontSize: "15px",
@@ -759,7 +852,7 @@ var te = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
759
852
  children: r
760
853
  })]
761
854
  }),
762
- /* @__PURE__ */ R("div", {
855
+ /* @__PURE__ */ I("div", {
763
856
  className: "ago-chat-widget__messages",
764
857
  role: "log",
765
858
  "aria-live": "polite",
@@ -772,7 +865,7 @@ var te = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
772
865
  backgroundColor: "#fbfbfb"
773
866
  },
774
867
  children: [
775
- o.length === 0 ? /* @__PURE__ */ a("div", {
868
+ s.length === 0 ? /* @__PURE__ */ o("div", {
776
869
  style: {
777
870
  textAlign: "center",
778
871
  color: "#6b6d6f",
@@ -781,13 +874,13 @@ var te = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
781
874
  lineHeight: "1.5"
782
875
  },
783
876
  children: n
784
- }) : o.map((h, F) => /* @__PURE__ */ a(ve, {
785
- message: h,
877
+ }) : s.map((y, F) => /* @__PURE__ */ o(Me, {
878
+ message: y,
786
879
  showAgentName: f,
787
- isLast: F === o.length - 1,
788
- onFollowUpClick: K
789
- }, h.id)),
790
- c && /* @__PURE__ */ a("div", {
880
+ isLast: F === s.length - 1,
881
+ onFollowUpClick: U
882
+ }, y.id)),
883
+ d && /* @__PURE__ */ o("div", {
791
884
  role: "alert",
792
885
  style: {
793
886
  padding: "10px 14px",
@@ -798,90 +891,90 @@ var te = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
798
891
  fontSize: "13px",
799
892
  border: "1px solid #fecaca"
800
893
  },
801
- children: c.message
894
+ children: d.message
802
895
  }),
803
- /* @__PURE__ */ a("div", { ref: b })
896
+ /* @__PURE__ */ o("div", { ref: x })
804
897
  ]
805
898
  }),
806
- /* @__PURE__ */ a(te, {
899
+ /* @__PURE__ */ o(ae, {
807
900
  onSend: S,
808
- disabled: B,
809
- placeholder: s,
901
+ disabled: K,
902
+ placeholder: a,
810
903
  allowFiles: i
811
904
  })
812
905
  ]
813
906
  });
814
907
  };
815
- function we({ client: e, autoLoad: t = !0 } = {}) {
816
- const r = L(), n = e || r;
908
+ function Ie({ client: e, autoLoad: t = !0 } = {}) {
909
+ const r = W(), n = e || r;
817
910
  if (!n) throw new Error("useConversation requires an AgoClient. Either pass it as options.client or wrap your app in <AgoProvider>.");
818
- const [s, i] = M([]), [u, l] = M(null), [f, d] = M(!1), [y, m] = M(null), C = I(async () => {
819
- d(!0), m(null);
911
+ const [a, i] = M([]), [u, l] = M(null), [f, c] = M(!1), [b, m] = M(null), C = R(async () => {
912
+ c(!0), m(null);
820
913
  try {
821
914
  i(await n.getConversations());
822
915
  } catch (v) {
823
916
  m(v instanceof Error ? v : /* @__PURE__ */ new Error("Failed to load conversations"));
824
917
  } finally {
825
- d(!1);
918
+ c(!1);
826
919
  }
827
- }, [n]), g = I(async (v) => {
828
- d(!0), m(null);
920
+ }, [n]), g = R(async (v) => {
921
+ c(!0), m(null);
829
922
  try {
830
923
  l(await n.getConversation(v));
831
924
  } catch (w) {
832
925
  m(w instanceof Error ? w : /* @__PURE__ */ new Error("Failed to load conversation"));
833
926
  } finally {
834
- d(!1);
927
+ c(!1);
835
928
  }
836
- }, [n]), b = I(() => {
929
+ }, [n]), x = R(() => {
837
930
  l(null);
838
931
  }, []);
839
932
  return k(() => {
840
933
  t && C();
841
934
  }, [t, C]), {
842
- conversations: s,
935
+ conversations: a,
843
936
  currentConversation: u,
844
937
  isLoading: f,
845
- error: y,
938
+ error: b,
846
939
  selectConversation: g,
847
- startNewConversation: b,
940
+ startNewConversation: x,
848
941
  refreshConversations: C
849
942
  };
850
943
  }
851
- function Pe(e = {}) {
852
- const t = L(), r = e.client || t;
944
+ function Le(e = {}) {
945
+ const t = W(), r = e.client || t;
853
946
  if (!r) throw new Error("useChat requires an AgoClient. Either pass it as options.client or wrap your app in <AgoProvider>.");
854
- const n = O({
947
+ const n = B({
855
948
  client: r,
856
949
  conversationId: e.conversationId
857
- }), s = we({
950
+ }), a = Ie({
858
951
  client: r,
859
952
  autoLoad: e.autoLoad
860
953
  });
861
954
  return {
862
955
  messages: n.messages,
863
956
  isLoading: n.isLoading,
864
- error: n.error || s.error,
957
+ error: n.error || a.error,
865
958
  sendMessage: n.sendMessage,
866
959
  clearMessages: n.clearMessages,
867
960
  conversationId: n.conversationId,
868
- conversations: s.conversations,
869
- currentConversation: s.currentConversation,
870
- isConversationsLoading: s.isLoading,
871
- selectConversation: s.selectConversation,
872
- startNewConversation: s.startNewConversation,
873
- refreshConversations: s.refreshConversations
961
+ conversations: a.conversations,
962
+ currentConversation: a.currentConversation,
963
+ isConversationsLoading: a.isLoading,
964
+ selectConversation: a.selectConversation,
965
+ startNewConversation: a.startNewConversation,
966
+ refreshConversations: a.refreshConversations
874
967
  };
875
968
  }
876
- function Le(e, t) {
877
- const r = P(), { name: n, description: s, parameters: i, handler: u } = typeof e == "string" ? {
969
+ function $e(e, t) {
970
+ const r = T(), { name: n, description: a, parameters: i, handler: u } = typeof e == "string" ? {
878
971
  name: e,
879
972
  ...t
880
973
  } : e, l = A(u);
881
974
  l.current = u, k(() => {
882
- const f = (d) => l.current(d);
975
+ const f = (c) => l.current(c);
883
976
  return r.registerFunction(n, f, {
884
- description: s,
977
+ description: a,
885
978
  parameters: i
886
979
  }), () => {
887
980
  r.unregisterFunction(n);
@@ -889,53 +982,53 @@ function Le(e, t) {
889
982
  }, [
890
983
  r,
891
984
  n,
892
- s,
985
+ a,
893
986
  i
894
987
  ]);
895
988
  }
896
- function De(e, t) {
897
- const r = P(), n = A(e);
898
- n.current = e, k(() => (r.registerNavigationFunction((s) => n.current(s), t), () => {
989
+ function Oe(e, t) {
990
+ const r = T(), n = A(e);
991
+ n.current = e, k(() => (r.registerNavigationFunction((a) => n.current(a), t), () => {
899
992
  r.unregisterFunction("navigateToPage");
900
993
  }), [r, t]);
901
994
  }
902
- function He(e, t) {
903
- const r = P(), n = j(), s = t ?? n, i = A(e);
995
+ function Be(e, t) {
996
+ const r = T(), n = ee(), a = t ?? n, i = A(e);
904
997
  i.current = e;
905
998
  const u = typeof e == "function";
906
999
  k(() => {
907
1000
  if (typeof i.current == "function") {
908
1001
  const l = () => i.current();
909
- return r.addDynamicContext(s, l), () => {
910
- r.removeDynamicContext(s);
1002
+ return r.addDynamicContext(a, l), () => {
1003
+ r.removeDynamicContext(a);
911
1004
  };
912
1005
  }
913
- return r.setContext(s, i.current), () => {
914
- r.removeContext(s);
1006
+ return r.setContext(a, i.current), () => {
1007
+ r.removeContext(a);
915
1008
  };
916
1009
  }, [
917
1010
  r,
918
- s,
1011
+ a,
919
1012
  u,
920
1013
  u ? "" : JSON.stringify(e)
921
1014
  ]);
922
1015
  }
923
- function Ce(e) {
924
- return Y(e.subscribe, e.get, e.get);
1016
+ function Re(e) {
1017
+ return te(e.subscribe, e.get, e.get);
925
1018
  }
926
- var H = {
1019
+ var P = {
927
1020
  missing: [],
928
1021
  complete: !1
929
1022
  };
930
- function ze(e) {
931
- const t = P(), r = e.schema != null, n = JSON.stringify(e.schema ?? null), s = e.submit, i = s ? typeof s == "string" ? `client:${s}` : s.via === "backend" ? "backend" : "handler" in s ? "client:handler" : `client:${s.url}` : "none", u = JSON.stringify(e.initialValues ?? null), l = T(() => r ? W(e) : null, [
1023
+ function Ke(e) {
1024
+ const t = T(), r = e.schema != null, n = JSON.stringify(e.schema ?? null), a = e.submit, i = a ? typeof a == "string" ? `client:${a}` : a.via === "backend" ? "backend" : "handler" in a ? "client:handler" : `client:${a.url}` : "none", u = JSON.stringify(e.initialValues ?? null), l = _(() => r ? L(e) : null, [
932
1025
  r,
933
1026
  e.name,
934
1027
  n,
935
1028
  i,
936
1029
  u,
937
1030
  e.autoSubmit
938
- ]), [f, d] = M({
1031
+ ]), [f, c] = M({
939
1032
  collector: null,
940
1033
  loading: !r,
941
1034
  error: null
@@ -943,21 +1036,21 @@ function ze(e) {
943
1036
  k(() => {
944
1037
  if (r) return;
945
1038
  let p = !1;
946
- return d({
1039
+ return c({
947
1040
  collector: null,
948
1041
  loading: !0,
949
1042
  error: null
950
- }), z(t, e).then((c) => {
951
- p || d({
952
- collector: c,
1043
+ }), H(t, e).then((d) => {
1044
+ p || c({
1045
+ collector: d,
953
1046
  loading: !1,
954
1047
  error: null
955
1048
  });
956
- }).catch((c) => {
957
- p || d({
1049
+ }).catch((d) => {
1050
+ p || c({
958
1051
  collector: null,
959
1052
  loading: !1,
960
- error: c instanceof Error ? c : new Error(String(c))
1053
+ error: d instanceof Error ? d : new Error(String(d))
961
1054
  });
962
1055
  }), () => {
963
1056
  p = !0;
@@ -970,18 +1063,18 @@ function ze(e) {
970
1063
  u,
971
1064
  e.autoSubmit
972
1065
  ]);
973
- const y = r ? l : f.collector, m = r ? !1 : f.loading, C = r ? null : f.error;
1066
+ const b = r ? l : f.collector, m = r ? !1 : f.loading, C = r ? null : f.error;
974
1067
  k(() => {
975
- if (y)
976
- return y.install(t);
977
- }, [t, y]);
978
- const g = T(() => J({
1068
+ if (b)
1069
+ return b.install(t);
1070
+ }, [t, b]);
1071
+ const g = _(() => X({
979
1072
  values: e.initialValues ?? {},
980
1073
  submitted: !1
981
- }), [u]), b = Ce(y?.store ?? g), v = T(() => y?.getStatus() ?? H, [b, y]), w = T(() => ({
982
- ...b,
1074
+ }), [u]), x = Re(b?.store ?? g), v = _(() => b?.getStatus() ?? P, [x, b]), w = _(() => ({
1075
+ ...x,
983
1076
  ...v
984
- }), [b, v]), o = T(() => ({
1077
+ }), [x, v]), s = _(() => ({
985
1078
  name: e.name,
986
1079
  store: g,
987
1080
  functions: [],
@@ -1003,34 +1096,34 @@ function ze(e) {
1003
1096
  },
1004
1097
  reset: () => {
1005
1098
  },
1006
- getStatus: () => H
1099
+ getStatus: () => P
1007
1100
  }), [e.name, g]);
1008
1101
  return {
1009
- ...y ?? o,
1102
+ ...b ?? s,
1010
1103
  state: w,
1011
1104
  loading: m,
1012
1105
  error: C
1013
1106
  };
1014
1107
  }
1015
1108
  export {
1016
- Te as AgoProvider,
1017
- te as ChatInput,
1018
- _e as ChatWidget,
1019
- he as Markdown,
1020
- ve as Message,
1021
- W as createFormCollector,
1022
- Re as createMockClient,
1023
- Me as deriveFormStatus,
1024
- z as loadFormCollector,
1025
- ee as useAgo,
1026
- P as useAgoClient,
1027
- He as useAgoContext,
1028
- Le as useAgoFunction,
1029
- De as useAgoNavigation,
1030
- Ce as useAgoStore,
1031
- Pe as useChat,
1032
- we as useConversation,
1033
- ze as useFormCollector,
1034
- O as useMessages,
1035
- L as useOptionalAgoClient
1109
+ Pe as AgoProvider,
1110
+ ae as ChatInput,
1111
+ He as ChatWidget,
1112
+ we as Markdown,
1113
+ Me as Message,
1114
+ L as createFormCollector,
1115
+ _e as createMockClient,
1116
+ Fe as deriveFormStatus,
1117
+ H as loadFormCollector,
1118
+ oe as useAgo,
1119
+ T as useAgoClient,
1120
+ Be as useAgoContext,
1121
+ $e as useAgoFunction,
1122
+ Oe as useAgoNavigation,
1123
+ Re as useAgoStore,
1124
+ Le as useChat,
1125
+ Ie as useConversation,
1126
+ Ke as useFormCollector,
1127
+ B as useMessages,
1128
+ W as useOptionalAgoClient
1036
1129
  };