@automattic/agenttic-ui 0.1.12 → 0.1.14

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/index.js CHANGED
@@ -1,86 +1,86 @@
1
- import { jsxs as _, jsx as n, Fragment as Ht } from "react/jsx-runtime";
2
- import * as te from "react";
3
- import ee, { useState as W, useEffect as E, useCallback as p, useRef as I, createContext as Ee, useContext as Ae, useId as Se, memo as xe, useMemo as Oe } from "react";
4
- import { motion as M, AnimatePresence as _t, useMotionValue as Mt, useDragControls as ne, animate as Pt } from "framer-motion";
5
- import { __ as Ct } from "@wordpress/i18n";
6
- import { Slot as Ne } from "@radix-ui/react-slot";
7
- import Re from "streamdown";
8
- import './index.css';function V(...e) {
9
- return e.flat().filter(Boolean).map((t) => typeof t == "string" ? t : typeof t == "object" && !Array.isArray(t) && t !== null ? Object.entries(t).filter(([a, i]) => i).map(([a]) => a).join(" ") : "").join(" ").trim();
1
+ import { jsxs as I, jsx as n, Fragment as Ht } from "react/jsx-runtime";
2
+ import * as oe from "react";
3
+ import ae, { useState as k, useEffect as E, useCallback as d, useRef as L, createContext as De, useContext as Oe, useId as Ne, memo as Me, useMemo as Pe } from "react";
4
+ import { motion as P, AnimatePresence as At, useMotionValue as Mt, useDragControls as ie, animate as Pt } from "framer-motion";
5
+ import { __ as ut } from "@wordpress/i18n";
6
+ import { Slot as Ve } from "@radix-ui/react-slot";
7
+ import He from "react-markdown";
8
+ import './index.css';function U(...e) {
9
+ return e.flat().filter(Boolean).map((t) => typeof t == "string" ? t : typeof t == "object" && !Array.isArray(t) && t !== null ? Object.entries(t).filter(([a, r]) => r).map(([a]) => a).join(" ") : "").join(" ").trim();
10
10
  }
11
- function oe(e) {
12
- const t = e || "collapsed", [a, i] = W(t);
11
+ function re(e) {
12
+ const t = e || "collapsed", [a, r] = k(t);
13
13
  E(() => {
14
- e !== void 0 && i(e);
14
+ e !== void 0 && r(e);
15
15
  }, [e]);
16
- const s = a !== "collapsed" && a !== "compact", o = p(() => {
17
- i("expanded");
18
- }, []), r = p(() => {
19
- i(t);
20
- }, [t]), g = p(() => {
21
- i(
16
+ const s = a !== "collapsed" && a !== "compact", i = d(() => {
17
+ r("expanded");
18
+ }, []), c = d(() => {
19
+ r(t);
20
+ }, [t]), h = d(() => {
21
+ r(
22
22
  (u) => u === "collapsed" ? "compact" : "collapsed"
23
23
  );
24
24
  }, []);
25
25
  return {
26
26
  state: a,
27
27
  initialState: t,
28
- setState: i,
28
+ setState: r,
29
29
  isOpen: s,
30
- open: o,
31
- close: r,
32
- toggle: g
30
+ open: i,
31
+ close: c,
32
+ toggle: h
33
33
  };
34
34
  }
35
- function ae({
35
+ function se({
36
36
  value: e,
37
37
  setValue: t,
38
38
  onSubmit: a,
39
- isProcessing: i
39
+ isProcessing: r
40
40
  }) {
41
- const s = I(null), o = p(() => {
41
+ const s = L(null), i = d(() => {
42
42
  t(""), s.current && (s.current.style.height = "auto", setTimeout(() => {
43
43
  var u;
44
44
  (u = s.current) == null || u.focus();
45
45
  }, 100));
46
- }, [t]), r = p(() => {
46
+ }, [t]), c = d(() => {
47
47
  const u = s.current;
48
48
  if (!u)
49
49
  return;
50
50
  u.style.height = "auto";
51
- const m = u.scrollHeight, f = 40, v = 200;
51
+ const m = u.scrollHeight, p = 40, g = 200;
52
52
  u.style.height = `${Math.min(
53
- Math.max(m, f),
54
- v
53
+ Math.max(m, p),
54
+ g
55
55
  )}px`;
56
- }, []), g = p(
56
+ }, []), h = d(
57
57
  (u) => {
58
- u.key === "Enter" && !u.shiftKey && !i && e.trim() && (u.preventDefault(), a(e.trim()), o());
58
+ u.key === "Enter" && !u.shiftKey && !r && e.trim() && (u.preventDefault(), a(e.trim()), i());
59
59
  },
60
- [e, i, a, o]
60
+ [e, r, a, i]
61
61
  );
62
62
  return E(() => {
63
- r();
64
- }, [e, r]), {
63
+ c();
64
+ }, [e, c]), {
65
65
  value: e,
66
66
  setValue: t,
67
- clear: o,
67
+ clear: i,
68
68
  textareaRef: s,
69
- handleKeyDown: g,
70
- adjustHeight: r
69
+ handleKeyDown: h,
70
+ adjustHeight: c
71
71
  };
72
72
  }
73
- const ie = Ct("Ask anything", "a8c-agenttic"), Zt = {
73
+ const ce = ut("Ask anything", "a8c-agenttic"), Yt = {
74
74
  type: "spring",
75
75
  stiffness: 300,
76
76
  damping: 30
77
- }, lt = {
77
+ }, dt = {
78
78
  type: "spring",
79
79
  damping: 40,
80
80
  stiffness: 500,
81
81
  mass: 0.8
82
82
  }, Vt = {
83
- ...lt,
83
+ ...dt,
84
84
  stiffness: 1e3,
85
85
  damping: 90
86
86
  }, $t = {
@@ -88,19 +88,19 @@ const ie = Ct("Ask anything", "a8c-agenttic"), Zt = {
88
88
  damping: 40,
89
89
  stiffness: 500,
90
90
  mass: 0.8
91
- }, re = {
91
+ }, le = {
92
92
  hidden: {
93
93
  opacity: 0
94
94
  },
95
95
  visible: {
96
96
  opacity: 1,
97
- transition: Zt
97
+ transition: Yt
98
98
  },
99
99
  exit: {
100
100
  opacity: 0,
101
- transition: { ...Zt, duration: 0.1 }
101
+ transition: { ...Yt, duration: 0.1 }
102
102
  }
103
- }, De = () => {
103
+ }, $e = () => {
104
104
  if (typeof window > "u")
105
105
  return { left: 0, right: 0, top: 0, bottom: 0 };
106
106
  const e = 20;
@@ -112,67 +112,67 @@ const ie = Ct("Ask anything", "a8c-agenttic"), Zt = {
112
112
  bottom: window.innerHeight - 60 - e
113
113
  // Assuming collapsed height of 60px
114
114
  };
115
- }, Me = {
115
+ }, Fe = {
116
116
  "0%": { backgroundPosition: "-200% 0" },
117
117
  "100%": { backgroundPosition: "200% 0" }
118
- }, Xn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
118
+ }, to = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
119
119
  __proto__: null,
120
- fadeVariants: re,
121
- fastSpring: lt,
120
+ fadeVariants: le,
121
+ fastSpring: dt,
122
122
  fastSpringWithDelay: Vt,
123
- getDragConstraints: De,
123
+ getDragConstraints: $e,
124
124
  morphSpring: $t,
125
- springConfig: Zt,
126
- thinkingGradientKeyframes: Me
127
- }, Symbol.toStringTag, { value: "Module" })), Pe = "button-module_button", Ve = "button-module_pressed", He = "button-module_primary", $e = "button-module_ghost", Fe = "button-module_outline", ke = "button-module_transparent", Ue = "button-module_link", Ge = "button-module_icon", We = "button-module_sm", Be = "button-module_lg", Ze = "button-module_withTextAndIcon", Lt = {
128
- button: Pe,
129
- pressed: Ve,
130
- primary: He,
131
- ghost: $e,
132
- outline: Fe,
133
- transparent: ke,
134
- link: Ue,
135
- icon: Ge,
136
- sm: We,
137
- lg: Be,
138
- withTextAndIcon: Ze
139
- }, Y = te.forwardRef(
125
+ springConfig: Yt,
126
+ thinkingGradientKeyframes: Fe
127
+ }, Symbol.toStringTag, { value: "Module" })), ke = "button-module_button", Ue = "button-module_pressed", We = "button-module_primary", Be = "button-module_ghost", Ge = "button-module_outline", Ze = "button-module_transparent", Ye = "button-module_link", Ke = "button-module_icon", Xe = "button-module_sm", je = "button-module_lg", ze = "button-module_withTextAndIcon", It = {
128
+ button: ke,
129
+ pressed: Ue,
130
+ primary: We,
131
+ ghost: Be,
132
+ outline: Ge,
133
+ transparent: Ze,
134
+ link: Ye,
135
+ icon: Ke,
136
+ sm: Xe,
137
+ lg: je,
138
+ withTextAndIcon: ze
139
+ }, X = oe.forwardRef(
140
140
  function({
141
141
  className: t,
142
142
  variant: a = "primary",
143
- size: i,
143
+ size: r,
144
144
  icon: s,
145
- children: o,
146
- asChild: r = !1,
147
- pressed: g = !1,
145
+ children: i,
146
+ asChild: c = !1,
147
+ pressed: h = !1,
148
148
  ...u
149
149
  }, m) {
150
- const f = r ? Ne : "button", v = !!s, y = i || (v && !o ? "icon" : void 0);
151
- return /* @__PURE__ */ _(
152
- f,
150
+ const p = c ? Ve : "button", g = !!s, w = r || (g && !i ? "icon" : void 0);
151
+ return /* @__PURE__ */ I(
152
+ p,
153
153
  {
154
154
  ref: m,
155
155
  "data-slot": "button",
156
- className: V(
157
- Lt.button,
158
- Lt[a],
159
- y && Lt[y],
160
- v && o ? Lt.withTextAndIcon : void 0,
161
- g ? Lt.pressed : void 0,
156
+ className: U(
157
+ It.button,
158
+ It[a],
159
+ w && It[w],
160
+ g && i ? It.withTextAndIcon : void 0,
161
+ h ? It.pressed : void 0,
162
162
  t
163
163
  ),
164
- "aria-pressed": g,
164
+ "aria-pressed": h,
165
165
  ...u,
166
166
  children: [
167
167
  s,
168
- o
168
+ i
169
169
  ]
170
170
  }
171
171
  );
172
172
  }
173
173
  );
174
- Y.displayName = "Button";
175
- function se({ className: e, size: t = 24 }) {
174
+ X.displayName = "Button";
175
+ function ue({ className: e, size: t = 24 }) {
176
176
  return /* @__PURE__ */ n(
177
177
  "svg",
178
178
  {
@@ -192,20 +192,20 @@ function se({ className: e, size: t = 24 }) {
192
192
  }
193
193
  );
194
194
  }
195
- const Ye = "CollapsedView-module_button", Ke = {
196
- button: Ye
195
+ const qe = "CollapsedView-module_button", Je = {
196
+ button: qe
197
197
  };
198
- function ce({
199
- icon: e = /* @__PURE__ */ n(se, { size: 36 }),
198
+ function de({
199
+ icon: e = /* @__PURE__ */ n(ue, { size: 36 }),
200
200
  onClick: t,
201
201
  onHover: a,
202
- focusOnMount: i = !1
202
+ focusOnMount: r = !1
203
203
  }) {
204
- const s = I(null), o = I(i);
204
+ const s = L(null), i = L(r);
205
205
  return E(() => {
206
- o.current && s.current && s.current.focus(), o.current = !1;
207
- }, [o, s]), /* @__PURE__ */ n(
208
- M.div,
206
+ i.current && s.current && s.current.focus(), i.current = !1;
207
+ }, [i, s]), /* @__PURE__ */ n(
208
+ P.div,
209
209
  {
210
210
  "data-slot": "collapsed-view",
211
211
  layout: "preserve-aspect",
@@ -230,35 +230,35 @@ function ce({
230
230
  }
231
231
  },
232
232
  children: /* @__PURE__ */ n(
233
- Y,
233
+ X,
234
234
  {
235
235
  ref: s,
236
236
  onClick: t,
237
237
  onMouseEnter: a,
238
238
  variant: "link",
239
- className: Ke.button,
239
+ className: Je.button,
240
240
  icon: e,
241
- "aria-label": Ct("Open chat", "a8c-agenttic")
241
+ "aria-label": ut("Open chat", "a8c-agenttic")
242
242
  }
243
243
  )
244
244
  }
245
245
  );
246
246
  }
247
- const Xe = "Textarea-module_textarea", je = {
248
- textarea: Xe
249
- }, le = te.forwardRef(
247
+ const Qe = "Textarea-module_textarea", tn = {
248
+ textarea: Qe
249
+ }, me = oe.forwardRef(
250
250
  ({ className: e, ...t }, a) => /* @__PURE__ */ n(
251
251
  "textarea",
252
252
  {
253
253
  "data-slot": "textarea",
254
- className: je.textarea,
254
+ className: tn.textarea,
255
255
  ref: a,
256
256
  ...t
257
257
  }
258
258
  )
259
259
  );
260
- le.displayName = "Textarea";
261
- function ze({ className: e, size: t = 24 }) {
260
+ me.displayName = "Textarea";
261
+ function en({ className: e, size: t = 24 }) {
262
262
  return /* @__PURE__ */ n(
263
263
  "svg",
264
264
  {
@@ -278,7 +278,7 @@ function ze({ className: e, size: t = 24 }) {
278
278
  }
279
279
  );
280
280
  }
281
- function qe({ className: e, size: t = 24 }) {
281
+ function nn({ className: e, size: t = 24 }) {
282
282
  return /* @__PURE__ */ n(
283
283
  "svg",
284
284
  {
@@ -302,13 +302,13 @@ function qe({ className: e, size: t = 24 }) {
302
302
  }
303
303
  );
304
304
  }
305
- const Je = "ChatInput-module_container", Qe = "ChatInput-module_textareaContainer", tn = "ChatInput-module_actions", en = "ChatInput-module_button", pt = {
306
- container: Je,
307
- textareaContainer: Qe,
308
- actions: tn,
309
- button: en
305
+ const on = "ChatInput-module_container", an = "ChatInput-module_textareaContainer", rn = "ChatInput-module_actions", sn = "ChatInput-module_button", vt = {
306
+ container: on,
307
+ textareaContainer: an,
308
+ actions: rn,
309
+ button: sn
310
310
  };
311
- function nn({ className: e, size: t = 24 }) {
311
+ function cn({ className: e, size: t = 24 }) {
312
312
  return /* @__PURE__ */ n(
313
313
  "svg",
314
314
  {
@@ -330,27 +330,27 @@ function nn({ className: e, size: t = 24 }) {
330
330
  }
331
331
  );
332
332
  }
333
- const on = "AnimatedPlaceholder-module_container", an = {
334
- container: on
333
+ const ln = "AnimatedPlaceholder-module_container", un = {
334
+ container: ln
335
335
  };
336
- function rn({
336
+ function dn({
337
337
  texts: e,
338
338
  interval: t = 3e3,
339
339
  className: a = ""
340
340
  }) {
341
- const [i, s] = W(0);
341
+ const [r, s] = k(0);
342
342
  return E(() => {
343
- const o = setInterval(() => {
343
+ const i = setInterval(() => {
344
344
  s(
345
- (r) => (r + 1) % e.length
345
+ (c) => (c + 1) % e.length
346
346
  );
347
347
  }, t);
348
- return () => clearInterval(o);
349
- }, [e.length, t]), /* @__PURE__ */ n(_t, { mode: "wait", children: /* @__PURE__ */ n(
350
- M.span,
348
+ return () => clearInterval(i);
349
+ }, [e.length, t]), /* @__PURE__ */ n(At, { mode: "wait", children: /* @__PURE__ */ n(
350
+ P.span,
351
351
  {
352
352
  "data-slot": "animated-placeholder",
353
- className: V(an.container, a),
353
+ className: U(un.container, a),
354
354
  initial: { opacity: 0, y: 8 },
355
355
  animate: { opacity: 1, y: 0 },
356
356
  exit: { opacity: 0, y: -8 },
@@ -359,305 +359,323 @@ function rn({
359
359
  ease: [0.4, 0, 0.2, 1]
360
360
  // Matches --transition-colors cubic-bezier
361
361
  },
362
- children: e[i]
362
+ children: e[r]
363
363
  },
364
- i
364
+ r
365
365
  ) });
366
366
  }
367
- const ue = Ee(null);
368
- function ut() {
369
- const e = Ae(ue);
367
+ const fe = De(null);
368
+ function mt() {
369
+ const e = Oe(fe);
370
370
  if (!e)
371
371
  throw new Error(
372
372
  "useAgentUIContext must be used within an AgentUIContainer"
373
373
  );
374
374
  return e;
375
375
  }
376
- function zt({ children: e, value: t }) {
377
- return /* @__PURE__ */ n(ue.Provider, { value: t, children: e });
376
+ function Qt({ children: e, value: t }) {
377
+ return /* @__PURE__ */ n(fe.Provider, { value: t, children: e });
378
378
  }
379
- function Kt({
379
+ function Xt({
380
380
  value: e,
381
381
  onChange: t,
382
382
  onSubmit: a,
383
- onKeyDown: i,
383
+ onKeyDown: r,
384
384
  textareaRef: s,
385
- placeholder: o = ie,
386
- isProcessing: r,
387
- onBlur: g,
385
+ placeholder: i = ce,
386
+ isProcessing: c,
387
+ onBlur: h,
388
388
  fromCompact: u = !1,
389
389
  onExpand: m,
390
- showExpandButton: f = !0,
391
- focusOnMount: v = !1,
392
- customActions: y = [],
393
- actionOrder: b = "before-submit",
394
- onStop: T,
395
- disabled: L = !1,
396
- className: O
390
+ showExpandButton: p = !0,
391
+ focusOnMount: g = !1,
392
+ customActions: w = [],
393
+ actionOrder: _ = "before-submit",
394
+ onStop: y,
395
+ disabled: S = !1,
396
+ className: O,
397
+ onMouseEnter: H,
398
+ onMouseLeave: A
397
399
  }) {
398
- const D = Se(), N = (e.trim() || r) && !L, { variant: H, floatingChatState: c } = ut(), $ = (d) => d.endsWith("…") ? d : `${d}…`, B = Array.isArray(o);
399
- let P;
400
- B ? P = o.map($) : o ? P = $(o) : P = "";
401
- const tt = I(v);
400
+ const $ = Ne(), l = (e.trim() || c) && !S, { variant: N, floatingChatState: ft } = mt(), B = (T) => T.endsWith("…") ? T : `${T}…`, et = Array.isArray(i);
401
+ let G;
402
+ et ? G = i.map(B) : i ? G = B(i) : G = "";
403
+ const M = L(g);
402
404
  E(() => {
403
- tt.current && s.current && s.current.focus(), tt.current = !1;
404
- }, [tt, s]);
405
- const K = () => y.map((d) => /* @__PURE__ */ n(
406
- Y,
405
+ M.current && s.current && s.current.focus(), M.current = !1;
406
+ }, [M, s]);
407
+ const nt = () => w.map((T) => /* @__PURE__ */ n(
408
+ X,
407
409
  {
408
- className: d.className || pt.button,
409
- onClick: d.onClick,
410
- disabled: d.disabled,
411
- variant: d.variant || "ghost",
412
- icon: d.icon,
413
- "aria-label": d["aria-label"]
410
+ className: T.className || vt.button,
411
+ onClick: T.onClick,
412
+ disabled: T.disabled,
413
+ variant: T.variant || "ghost",
414
+ icon: T.icon,
415
+ "aria-label": T["aria-label"]
414
416
  },
415
- d.id
416
- )), F = () => H === "embedded" || c === "expanded" ? null : f && m ? /* @__PURE__ */ n(
417
- Y,
417
+ T.id
418
+ )), o = () => N === "embedded" || ft === "expanded" ? null : p && m ? /* @__PURE__ */ n(
419
+ X,
418
420
  {
419
- className: pt.button,
421
+ className: vt.button,
420
422
  onClick: m,
421
423
  variant: "ghost",
422
- icon: /* @__PURE__ */ n(nn, {}),
423
- "aria-label": Ct("Expand conversation", "a8c-agenttic")
424
+ icon: /* @__PURE__ */ n(cn, {}),
425
+ "aria-label": ut("Expand conversation", "a8c-agenttic")
424
426
  }
425
- ) : null, l = () => {
426
- const d = () => {
427
- r && T ? T() : a();
427
+ ) : null, ot = () => {
428
+ if (c && !y)
429
+ return null;
430
+ const T = () => {
431
+ c && y ? y() : a();
428
432
  };
429
433
  return /* @__PURE__ */ n(
430
- Y,
434
+ X,
431
435
  {
432
- className: pt.button,
433
- onClick: d,
434
- disabled: !N,
436
+ className: vt.button,
437
+ onClick: T,
438
+ disabled: !l,
435
439
  variant: "primary",
436
- icon: r ? /* @__PURE__ */ n(qe, {}) : /* @__PURE__ */ n(ze, {}),
437
- "aria-label": r ? Ct("Stop processing", "a8c-agenttic") : Ct("Send message", "a8c-agenttic")
440
+ icon: c ? /* @__PURE__ */ n(nn, {}) : /* @__PURE__ */ n(en, {}),
441
+ "aria-label": c ? ut("Stop processing", "a8c-agenttic") : ut("Send message", "a8c-agenttic")
438
442
  }
439
443
  );
440
444
  };
441
- return /* @__PURE__ */ _("div", { "data-slot": "chat-input", className: pt.container, children: [
442
- /* @__PURE__ */ _(
443
- M.div,
444
- {
445
- className: pt.textareaContainer,
446
- initial: {
447
- opacity: 0
448
- },
449
- animate: {
450
- opacity: 1,
451
- scale: 1,
452
- transition: e.trim() ? { duration: 0 } : Vt
453
- },
454
- children: [
455
- !e && B && /* @__PURE__ */ n(
456
- rn,
457
- {
458
- texts: P
459
- }
460
- ),
461
- /* @__PURE__ */ n(
462
- le,
463
- {
464
- id: D,
465
- ref: s,
466
- value: e,
467
- onChange: (d) => t(d.target.value),
468
- onKeyDown: i,
469
- onBlur: g,
470
- placeholder: B ? "" : P,
471
- rows: 1
472
- }
473
- )
474
- ]
475
- }
476
- ),
477
- /* @__PURE__ */ _(
478
- M.div,
479
- {
480
- className: pt.actions,
481
- initial: {
482
- opacity: u ? 1 : 0,
483
- scale: u ? 1 : 0.5
484
- },
485
- animate: {
486
- opacity: 1,
487
- scale: 1,
488
- transition: e.trim() ? { duration: 0 } : lt
489
- },
490
- children: [
491
- F(),
492
- b === "before-submit" && K(),
493
- l(),
494
- b === "after-submit" && K()
495
- ]
496
- }
497
- )
498
- ] });
445
+ return /* @__PURE__ */ I(
446
+ "div",
447
+ {
448
+ "data-slot": "chat-input",
449
+ className: vt.container,
450
+ onMouseEnter: H,
451
+ onMouseLeave: A,
452
+ children: [
453
+ /* @__PURE__ */ I(
454
+ P.div,
455
+ {
456
+ className: vt.textareaContainer,
457
+ initial: {
458
+ opacity: 0
459
+ },
460
+ animate: {
461
+ opacity: 1,
462
+ scale: 1,
463
+ transition: e.trim() ? { duration: 0 } : Vt
464
+ },
465
+ children: [
466
+ !e && et && /* @__PURE__ */ n(
467
+ dn,
468
+ {
469
+ texts: G
470
+ }
471
+ ),
472
+ /* @__PURE__ */ n(
473
+ me,
474
+ {
475
+ id: $,
476
+ ref: s,
477
+ value: e,
478
+ onChange: (T) => t(T.target.value),
479
+ onKeyDown: r,
480
+ onBlur: h,
481
+ placeholder: et ? "" : G,
482
+ rows: 1
483
+ }
484
+ )
485
+ ]
486
+ }
487
+ ),
488
+ /* @__PURE__ */ I(
489
+ P.div,
490
+ {
491
+ className: vt.actions,
492
+ initial: {
493
+ opacity: u ? 1 : 0,
494
+ scale: u ? 1 : 0.5
495
+ },
496
+ animate: {
497
+ opacity: 1,
498
+ scale: 1,
499
+ transition: e.trim() ? { duration: 0 } : dt
500
+ },
501
+ children: [
502
+ o(),
503
+ _ === "before-submit" && nt(),
504
+ ot(),
505
+ _ === "after-submit" && nt()
506
+ ]
507
+ }
508
+ )
509
+ ]
510
+ }
511
+ );
499
512
  }
500
- const sn = "Suggestions-module_container", cn = "Suggestions-module_vertical", Gt = {
501
- container: sn,
502
- vertical: cn
503
- }, Xt = ({
513
+ const mn = "Suggestions-module_container", fn = "Suggestions-module_vertical", Bt = {
514
+ container: mn,
515
+ vertical: fn
516
+ }, jt = ({
504
517
  className: e,
505
518
  suggestions: t,
506
519
  onSubmit: a,
507
- layout: i = "horizontal",
508
- visible: s = !0
520
+ layout: r = "horizontal",
521
+ visible: s = !0,
522
+ onMouseEnter: i,
523
+ onMouseLeave: c
509
524
  }) => {
510
- const o = (r) => {
511
- a && a(r.prompt);
525
+ const h = (u) => {
526
+ a && a(u.prompt);
512
527
  };
513
- return !t || t.length === 0 ? null : /* @__PURE__ */ n(_t, { children: t && t.length > 0 && s && /* @__PURE__ */ n(
514
- M.div,
528
+ return !t || t.length === 0 ? null : /* @__PURE__ */ n(At, { children: t && t.length > 0 && s && /* @__PURE__ */ n(
529
+ P.div,
515
530
  {
516
- className: V(
517
- Gt.container,
518
- i === "vertical" ? Gt.vertical : "",
531
+ className: U(
532
+ Bt.container,
533
+ r === "vertical" ? Bt.vertical : "",
519
534
  e
520
535
  ),
521
536
  initial: { opacity: 0, y: "-80%" },
522
537
  animate: { opacity: 1, y: "-100%" },
523
538
  exit: { opacity: 0, y: "-80%" },
524
539
  transition: Vt,
540
+ onMouseEnter: i,
541
+ onMouseLeave: c,
525
542
  children: t.map(
526
- (r, g) => /* @__PURE__ */ n(
527
- M.div,
543
+ (u, m) => /* @__PURE__ */ n(
544
+ P.div,
528
545
  {
529
546
  initial: { opacity: 0, y: 10 },
530
547
  animate: { opacity: 1, y: 0 },
531
548
  exit: { opacity: 0, y: 10 },
532
549
  transition: {
533
550
  ...Vt,
534
- delay: g * 0.05
551
+ delay: m * 0.05
535
552
  },
536
553
  children: /* @__PURE__ */ n(
537
- Y,
554
+ X,
538
555
  {
539
- onClick: () => o(r),
540
- variant: i === "vertical" ? "transparent" : "outline",
541
- size: i === "vertical" ? "lg" : void 0,
542
- className: Gt.button,
543
- children: r.label
556
+ onClick: () => h(u),
557
+ variant: r === "vertical" ? "transparent" : "outline",
558
+ size: r === "vertical" ? "lg" : void 0,
559
+ className: Bt.button,
560
+ children: u.label
544
561
  }
545
562
  )
546
563
  },
547
- r.id
564
+ u.id
548
565
  )
549
566
  )
550
567
  }
551
568
  ) });
552
569
  };
553
- function ln() {
554
- const e = I(/* @__PURE__ */ new Map()), t = p((o) => {
555
- const r = e.current.get(o);
556
- r && (clearTimeout(r), e.current.delete(o));
557
- }, []), a = p(
558
- (o, r, g) => {
559
- t(o);
560
- const u = setTimeout(r, g);
561
- return e.current.set(o, u), u;
570
+ function hn() {
571
+ const e = L(/* @__PURE__ */ new Map()), t = d((i) => {
572
+ const c = e.current.get(i);
573
+ c && (clearTimeout(c), e.current.delete(i));
574
+ }, []), a = d(
575
+ (i, c, h) => {
576
+ t(i);
577
+ const u = setTimeout(c, h);
578
+ return e.current.set(i, u), u;
562
579
  },
563
580
  [t]
564
- ), i = p(() => {
565
- e.current.forEach((o) => {
566
- clearTimeout(o);
581
+ ), r = d(() => {
582
+ e.current.forEach((i) => {
583
+ clearTimeout(i);
567
584
  }), e.current.clear();
568
- }, []), s = p((o) => e.current.has(o), []);
569
- return E(() => i, [i]), {
585
+ }, []), s = d((i) => e.current.has(i), []);
586
+ return E(() => r, [r]), {
570
587
  setNamedTimeout: a,
571
588
  clearNamedTimeout: t,
572
- clearAllTimeouts: i,
589
+ clearAllTimeouts: r,
573
590
  hasTimeout: s
574
591
  };
575
592
  }
576
- const un = 4e3, dn = 400;
577
- function de({
593
+ const pn = 4e3;
594
+ function he({
578
595
  value: e,
579
596
  onChange: t,
580
597
  onSubmit: a,
581
- onKeyDown: i,
598
+ onKeyDown: r,
582
599
  textareaRef: s,
583
- placeholder: o,
584
- isProcessing: r,
585
- onBlur: g,
600
+ placeholder: i,
601
+ isProcessing: c,
602
+ onBlur: h,
586
603
  onExpand: u,
587
604
  showExpandButton: m = !0,
588
- focusOnMount: f = !1,
589
- customActions: v,
590
- actionOrder: y,
591
- onStop: b,
592
- suggestions: T,
593
- clearSuggestions: L
605
+ focusOnMount: p = !1,
606
+ customActions: g,
607
+ actionOrder: w,
608
+ onStop: _,
609
+ suggestions: y,
610
+ clearSuggestions: S,
611
+ handleSuggestionSubmit: O
594
612
  }) {
595
- const [O, D] = W(!1), { setNamedTimeout: N, clearAllTimeouts: H } = ln(), c = p(
596
- ($) => {
597
- t($), L == null || L();
598
- },
599
- [t, L]
600
- );
613
+ const [H, A] = k(!1), { setNamedTimeout: $, clearAllTimeouts: l } = hn(), N = d(() => {
614
+ $(
615
+ "hide-suggestions",
616
+ () => {
617
+ A(!1);
618
+ },
619
+ pn
620
+ );
621
+ }, [$]);
601
622
  return E(() => {
602
- if (H(), e) {
603
- D(!1);
623
+ if (l(), e) {
624
+ A(!1);
604
625
  return;
605
626
  }
606
- if (!T || T.length === 0) {
607
- D(!1);
627
+ if (!y || y.length === 0) {
628
+ A(!1);
608
629
  return;
609
630
  }
610
- D(!0), N(
611
- "hide-suggestions",
612
- () => {
613
- D(!1), N(
614
- "clear-suggestions",
615
- () => {
616
- L == null || L();
617
- },
618
- dn
619
- );
620
- },
621
- un
622
- );
631
+ A(!0), N();
623
632
  }, [
624
633
  e,
625
- T,
626
- H,
627
- N,
628
- L
629
- ]), /* @__PURE__ */ _(Ht, { children: [
634
+ y,
635
+ l,
636
+ $,
637
+ S,
638
+ N
639
+ ]), /* @__PURE__ */ I(Ht, { children: [
630
640
  /* @__PURE__ */ n(
631
- Kt,
641
+ Xt,
632
642
  {
633
643
  value: e,
634
644
  onChange: t,
635
645
  onSubmit: a,
636
- onKeyDown: i,
646
+ onKeyDown: r,
637
647
  textareaRef: s,
638
- placeholder: o,
639
- isProcessing: r,
640
- onBlur: g,
648
+ placeholder: i,
649
+ isProcessing: c,
650
+ onBlur: h,
641
651
  onExpand: u,
642
652
  showExpandButton: m,
643
- focusOnMount: f,
644
- customActions: v,
645
- actionOrder: y,
646
- onStop: b
653
+ focusOnMount: p,
654
+ customActions: g,
655
+ actionOrder: w,
656
+ onStop: _,
657
+ onMouseEnter: () => {
658
+ l(), A(!0);
659
+ },
660
+ onMouseLeave: () => N()
647
661
  }
648
662
  ),
649
663
  !e && /* @__PURE__ */ n(
650
- Xt,
664
+ jt,
651
665
  {
652
- suggestions: T,
653
- onSubmit: c,
666
+ suggestions: y,
667
+ onSubmit: O,
654
668
  layout: "vertical",
655
- visible: O
669
+ visible: H,
670
+ onMouseEnter: () => {
671
+ l(), A(!0);
672
+ },
673
+ onMouseLeave: () => N()
656
674
  }
657
675
  )
658
676
  ] });
659
677
  }
660
- function me({ className: e, size: t = 24 }) {
678
+ function pe({ className: e, size: t = 24 }) {
661
679
  return /* @__PURE__ */ n(
662
680
  "svg",
663
681
  {
@@ -677,77 +695,77 @@ function me({ className: e, size: t = 24 }) {
677
695
  }
678
696
  );
679
697
  }
680
- const mn = "ChatHeader-module_container", fn = {
681
- container: mn
698
+ const Cn = "ChatHeader-module_container", gn = {
699
+ container: Cn
682
700
  };
683
- function fe({ onClose: e, className: t }) {
701
+ function Ce({ onClose: e, className: t }) {
684
702
  return /* @__PURE__ */ n(
685
- M.div,
703
+ P.div,
686
704
  {
687
705
  "data-slot": "chat-header",
688
706
  "data-draggable": "true",
689
- className: fn.container,
707
+ className: gn.container,
690
708
  initial: { opacity: 0 },
691
709
  animate: { opacity: 1 },
692
- transition: { ...lt, delay: 0.1 },
710
+ transition: { ...dt, delay: 0.1 },
693
711
  children: e && /* @__PURE__ */ n(
694
- Y,
712
+ X,
695
713
  {
696
714
  variant: "ghost",
697
- icon: /* @__PURE__ */ n(me, {}),
715
+ icon: /* @__PURE__ */ n(pe, {}),
698
716
  onClick: e,
699
- "aria-label": Ct("Close conversation", "a8c-agenttic")
717
+ "aria-label": ut("Close conversation", "a8c-agenttic")
700
718
  }
701
719
  )
702
720
  }
703
721
  );
704
722
  }
705
- const hn = "Notice-module_container", pn = "Notice-module_containerWithIcon", Cn = "Notice-module_content", gn = "Notice-module_actions", vn = "Notice-module_icon", wn = "Notice-module_dismissible", J = {
706
- container: hn,
707
- containerWithIcon: pn,
708
- content: Cn,
709
- actions: gn,
710
- icon: vn,
711
- dismissible: wn
723
+ const vn = "Notice-module_container", wn = "Notice-module_containerWithIcon", Ln = "Notice-module_content", yn = "Notice-module_actions", bn = "Notice-module_icon", In = "Notice-module_dismissible", J = {
724
+ container: vn,
725
+ containerWithIcon: wn,
726
+ content: Ln,
727
+ actions: yn,
728
+ icon: bn,
729
+ dismissible: In
712
730
  };
713
- function he({
731
+ function ge({
714
732
  icon: e,
715
733
  message: t,
716
734
  action: a,
717
- dismissible: i = !0,
735
+ dismissible: r = !0,
718
736
  onDismiss: s,
719
- className: o,
720
- status: r
737
+ className: i,
738
+ status: c
721
739
  }) {
722
- return /* @__PURE__ */ _(
740
+ return /* @__PURE__ */ I(
723
741
  "div",
724
742
  {
725
743
  "data-slot": "notice",
726
- className: V(
744
+ className: U(
727
745
  J.container,
728
746
  {
729
747
  [J.containerWithIcon]: !!e,
730
- [J.isSuccess]: r === "success",
731
- [J.isWarning]: r === "warning",
732
- [J.isError]: r === "error"
748
+ [J.isSuccess]: c === "success",
749
+ [J.isWarning]: c === "warning",
750
+ [J.isError]: c === "error"
733
751
  },
734
- o
752
+ i
735
753
  ),
736
754
  children: [
737
- /* @__PURE__ */ _("div", { className: J.content, children: [
755
+ /* @__PURE__ */ I("div", { className: J.content, children: [
738
756
  e && /* @__PURE__ */ n("div", { className: J.icon, children: e }),
739
757
  /* @__PURE__ */ n("span", { children: t })
740
758
  ] }),
741
- /* @__PURE__ */ _("div", { className: J.actions, children: [
742
- a && /* @__PURE__ */ n(Y, { onClick: a.onClick, variant: "link", children: a.label }),
743
- i && s && /* @__PURE__ */ n(
744
- Y,
759
+ /* @__PURE__ */ I("div", { className: J.actions, children: [
760
+ a && /* @__PURE__ */ n(X, { onClick: a.onClick, variant: "link", children: a.label }),
761
+ r && s && /* @__PURE__ */ n(
762
+ X,
745
763
  {
746
764
  className: J.dismissible,
747
765
  onClick: s,
748
766
  variant: "ghost",
749
767
  size: "sm",
750
- icon: /* @__PURE__ */ n(me, {})
768
+ icon: /* @__PURE__ */ n(pe, {})
751
769
  }
752
770
  )
753
771
  ] })
@@ -755,99 +773,99 @@ function he({
755
773
  }
756
774
  );
757
775
  }
758
- const Ln = "ChatFooter-module_container", Yt = {
759
- container: Ln
776
+ const Tn = "ChatFooter-module_container", Kt = {
777
+ container: Tn
760
778
  };
761
- function yn({
779
+ function _n({
762
780
  inputValue: e,
763
781
  onInputChange: t,
764
782
  onSubmit: a,
765
- onKeyDown: i,
783
+ onKeyDown: r,
766
784
  textareaRef: s,
767
- placeholder: o,
768
- isProcessing: r,
769
- onStop: g,
785
+ placeholder: i,
786
+ isProcessing: c,
787
+ onStop: h,
770
788
  fromCompact: u = !1,
771
789
  onExpand: m,
772
- disabled: f,
773
- notice: v,
774
- suggestions: y,
775
- clearSuggestions: b,
776
- focusOnMount: T,
777
- customActions: L,
790
+ disabled: p,
791
+ notice: g,
792
+ suggestions: w,
793
+ clearSuggestions: _,
794
+ focusOnMount: y,
795
+ customActions: S,
778
796
  actionOrder: O
779
797
  }) {
780
- const D = p(
781
- (N) => {
782
- t(N), b == null || b();
798
+ const H = d(
799
+ (A) => {
800
+ t(A), _ == null || _();
783
801
  },
784
- [t, b]
802
+ [t, _]
785
803
  );
786
- return /* @__PURE__ */ _(
787
- M.div,
804
+ return /* @__PURE__ */ I(
805
+ P.div,
788
806
  {
789
807
  "data-slot": "chat-footer",
790
- className: Yt.container,
808
+ className: Kt.container,
791
809
  initial: { opacity: 0, scale: 1 },
792
810
  animate: { opacity: 1, scale: 1 },
793
- transition: { ...lt },
811
+ transition: { ...dt },
794
812
  children: [
795
813
  !e && /* @__PURE__ */ n(
796
- Xt,
814
+ jt,
797
815
  {
798
- suggestions: y,
799
- onSubmit: D
816
+ suggestions: w,
817
+ onSubmit: H
800
818
  }
801
819
  ),
802
- v && /* @__PURE__ */ n(
803
- he,
820
+ g && /* @__PURE__ */ n(
821
+ ge,
804
822
  {
805
- icon: v.icon,
806
- message: v.message,
807
- action: v.action,
808
- dismissible: v.dismissible,
809
- onDismiss: v.onDismiss
823
+ icon: g.icon,
824
+ message: g.message,
825
+ action: g.action,
826
+ dismissible: g.dismissible,
827
+ onDismiss: g.onDismiss
810
828
  }
811
829
  ),
812
830
  /* @__PURE__ */ n(
813
- Kt,
831
+ Xt,
814
832
  {
815
833
  value: e,
816
834
  onChange: t,
817
835
  onSubmit: a,
818
- onKeyDown: i,
836
+ onKeyDown: r,
819
837
  textareaRef: s,
820
- placeholder: o,
821
- isProcessing: r,
822
- onStop: g,
838
+ placeholder: i,
839
+ isProcessing: c,
840
+ onStop: h,
823
841
  fromCompact: u,
824
842
  onExpand: m,
825
843
  showExpandButton: !1,
826
- focusOnMount: T,
827
- customActions: L,
844
+ focusOnMount: y,
845
+ customActions: S,
828
846
  actionOrder: O,
829
- disabled: f
847
+ disabled: p
830
848
  }
831
849
  )
832
850
  ]
833
851
  }
834
852
  );
835
853
  }
836
- const In = "MessageActions-module_container", qt = {
837
- container: In
854
+ const Sn = "MessageActions-module_container", te = {
855
+ container: Sn
838
856
  };
839
- function Jt({ message: e }) {
857
+ function ee({ message: e }) {
840
858
  return !e.actions || e.actions.length === 0 ? null : /* @__PURE__ */ n(
841
859
  "div",
842
860
  {
843
- className: qt.container,
861
+ className: te.container,
844
862
  "data-visible": "true",
845
863
  role: "toolbar",
846
864
  "aria-label": "Message actions",
847
865
  children: e.actions.map((t) => /* @__PURE__ */ n(
848
- Y,
866
+ X,
849
867
  {
850
- className: qt.button,
868
+ className: te.button,
851
869
  icon: t.icon,
852
870
  onClick: () => t.onClick(e),
853
871
  variant: "ghost",
@@ -865,110 +883,125 @@ function Jt({ message: e }) {
865
883
  }
866
884
  );
867
885
  }
868
- const Tn = "Message-module_message", _n = "Message-module_user", bn = "Message-module_bubble", En = "Message-module_error", An = "Message-module_content", Dt = {
869
- message: Tn,
870
- user: _n,
871
- bubble: bn,
872
- error: En,
873
- content: An
874
- }, Sn = ee.forwardRef(
875
- function({ message: t, messageRenderer: a = Re }, i) {
876
- const s = () => /* @__PURE__ */ n(Ht, { children: t.content.map((o, r) => {
877
- if (o.type === "text" && o.text)
878
- return /* @__PURE__ */ n(a, { children: o.text }, r);
879
- if (o.type === "component" && o.component) {
880
- const g = o.component;
886
+ const En = "Message-module_message", An = "Message-module_user", xn = "Message-module_bubble", Rn = "Message-module_error", Dn = "Message-module_content", On = "Message-module_disabled", Tt = {
887
+ message: En,
888
+ user: An,
889
+ bubble: xn,
890
+ error: Rn,
891
+ content: Dn,
892
+ disabled: On
893
+ }, Nn = ae.forwardRef(
894
+ function({ message: t, messageRenderer: a = He }, r) {
895
+ const s = () => /* @__PURE__ */ n(Ht, { children: t.content.map((i, c) => {
896
+ if (i.type === "text" && i.text)
897
+ return /* @__PURE__ */ n(a, { children: i.text }, c);
898
+ if (i.type === "component" && i.component) {
899
+ const h = i.component;
881
900
  return /* @__PURE__ */ n(
882
- g,
901
+ h,
883
902
  {
884
- ...o.componentProps || {}
903
+ ...i.componentProps || {}
885
904
  },
886
- r
905
+ c
887
906
  );
888
907
  }
889
908
  return null;
890
909
  }) });
891
- return /* @__PURE__ */ _(
892
- M.div,
910
+ return /* @__PURE__ */ I(
911
+ P.div,
893
912
  {
894
- ref: i,
895
- variants: re,
913
+ ref: r,
914
+ variants: le,
896
915
  initial: "hidden",
897
916
  animate: "visible",
898
917
  "data-slot": "message",
899
918
  "data-role": t.role,
900
- className: V(Dt.message, Dt[t.role]),
919
+ className: U(
920
+ Tt.message,
921
+ Tt[t.role],
922
+ t.disabled ? Tt.disabled : void 0
923
+ ),
901
924
  children: [
902
- /* @__PURE__ */ _("div", { className: Dt.content, children: [
903
- /* @__PURE__ */ n("div", { className: Dt.bubble, children: s() }),
904
- t.role !== "user" && /* @__PURE__ */ n(Jt, { message: t })
905
- ] }),
906
- t.role === "user" && /* @__PURE__ */ n(Jt, { message: t })
925
+ /* @__PURE__ */ I(
926
+ "div",
927
+ {
928
+ className: Tt.content,
929
+ title: t.disabled ? ut(
930
+ "This action is no longer available or cannot be performed",
931
+ "a8c-agenttic"
932
+ ) : void 0,
933
+ children: [
934
+ /* @__PURE__ */ n("div", { className: Tt.bubble, children: s() }),
935
+ t.role !== "user" && /* @__PURE__ */ n(ee, { message: t })
936
+ ]
937
+ }
938
+ ),
939
+ t.role === "user" && /* @__PURE__ */ n(ee, { message: t })
907
940
  ]
908
941
  }
909
942
  );
910
943
  }
911
- ), xn = "Messages-module_container", On = "Messages-module_emptyState", Wt = {
912
- container: xn,
913
- emptyState: On
914
- }, Nn = "Thinking-module_container", Rn = "Thinking-module_icon", Dn = "Thinking-module_content", Bt = {
915
- container: Nn,
916
- icon: Rn,
917
- content: Dn
918
- }, Mn = xe(
919
- ee.forwardRef(
944
+ ), Mn = "Messages-module_container", Pn = "Messages-module_emptyState", Gt = {
945
+ container: Mn,
946
+ emptyState: Pn
947
+ }, Vn = "Thinking-module_container", Hn = "Thinking-module_icon", $n = "Thinking-module_content", Zt = {
948
+ container: Vn,
949
+ icon: Hn,
950
+ content: $n
951
+ }, Fn = Me(
952
+ ae.forwardRef(
920
953
  function({ content: t = "Thinking…" }, a) {
921
- const i = Oe(() => /* @__PURE__ */ n(se, {}), []);
922
- return /* @__PURE__ */ _(
954
+ const r = Pe(() => /* @__PURE__ */ n(ue, {}), []);
955
+ return /* @__PURE__ */ I(
923
956
  "div",
924
957
  {
925
958
  ref: a,
926
959
  "data-slot": "thinking",
927
- className: Bt.container,
960
+ className: Zt.container,
928
961
  children: [
929
- /* @__PURE__ */ n("div", { className: Bt.icon, children: i }),
930
- /* @__PURE__ */ n("span", { className: Bt.content, children: t })
962
+ /* @__PURE__ */ n("div", { className: Zt.icon, children: r }),
963
+ /* @__PURE__ */ n("span", { className: Zt.content, children: t })
931
964
  ]
932
965
  }
933
966
  );
934
967
  }
935
968
  )
936
969
  );
937
- function pe({
970
+ function ve({
938
971
  messages: e,
939
972
  isProcessing: t,
940
973
  error: a,
941
- emptyView: i,
974
+ emptyView: r,
942
975
  messageRenderer: s,
943
- className: o
976
+ className: i
944
977
  }) {
945
- const r = I(null), g = I([]), u = I(!0), m = I(null);
978
+ const c = L(null), h = L([]), u = L(!0), m = L(null);
946
979
  return E(() => {
947
- const f = e.length > g.current.length;
948
- if (u.current && e.length > 0 && r.current ? r.current.scrollTop = r.current.scrollHeight : f && !u.current && r.current && r.current.scrollTo({
949
- top: r.current.scrollHeight,
980
+ const p = e.length > h.current.length;
981
+ if (u.current && e.length > 0 && c.current ? c.current.scrollTop = c.current.scrollHeight : p && !u.current && c.current && c.current.scrollTo({
982
+ top: c.current.scrollHeight,
950
983
  behavior: "smooth"
951
- }), f && m.current) {
952
- const y = e.slice(
953
- g.current.length
984
+ }), p && m.current) {
985
+ const w = e.slice(
986
+ h.current.length
954
987
  ).filter(
955
- (b) => b.role === "agent"
988
+ (_) => _.role === "agent"
956
989
  );
957
- if (y.length > 0) {
958
- const T = y[y.length - 1].content.filter((L) => L.type === "text").map((L) => L.text).join(" ");
959
- T && (m.current.textContent = T);
990
+ if (w.length > 0) {
991
+ const y = w[w.length - 1].content.filter((S) => S.type === "text").map((S) => S.text).join(" ");
992
+ y && (m.current.textContent = y);
960
993
  }
961
994
  }
962
- u.current && (u.current = !1), g.current = e;
963
- }, [e]), e.length === 0 ? i ? /* @__PURE__ */ n(
995
+ u.current && (u.current = !1), h.current = e;
996
+ }, [e]), e.length === 0 ? r ? /* @__PURE__ */ n(
964
997
  "div",
965
998
  {
966
999
  "data-slot": "messages",
967
- className: `${Wt.container} ${Wt.emptyState}`,
968
- ref: r,
969
- children: i
1000
+ className: `${Gt.container} ${Gt.emptyState}`,
1001
+ ref: c,
1002
+ children: r
970
1003
  }
971
- ) : null : /* @__PURE__ */ _(Ht, { children: [
1004
+ ) : null : /* @__PURE__ */ I(Ht, { children: [
972
1005
  /* @__PURE__ */ n(
973
1006
  "div",
974
1007
  {
@@ -988,18 +1021,18 @@ function pe({
988
1021
  "div",
989
1022
  {
990
1023
  "data-slot": "messages",
991
- className: Wt.container,
992
- ref: r,
993
- children: /* @__PURE__ */ _(_t, { mode: "popLayout", children: [
994
- e.map((f) => /* @__PURE__ */ n(
995
- Sn,
1024
+ className: Gt.container,
1025
+ ref: c,
1026
+ children: /* @__PURE__ */ I(At, { mode: "popLayout", children: [
1027
+ e.map((p) => /* @__PURE__ */ n(
1028
+ Nn,
996
1029
  {
997
- message: f,
1030
+ message: p,
998
1031
  messageRenderer: s
999
1032
  },
1000
- f.id
1033
+ p.id
1001
1034
  )),
1002
- t && /* @__PURE__ */ n(Mn, {}),
1035
+ t && /* @__PURE__ */ n(Fn, {}),
1003
1036
  a && /* @__PURE__ */ n(
1004
1037
  "div",
1005
1038
  {
@@ -1017,83 +1050,83 @@ function pe({
1017
1050
  )
1018
1051
  ] });
1019
1052
  }
1020
- const Pn = "ConversationView-module_container", Vn = "ConversationView-module_withHeader", Tt = {
1021
- container: Pn,
1022
- withHeader: Vn
1053
+ const kn = "ConversationView-module_container", Un = "ConversationView-module_withHeader", Et = {
1054
+ container: kn,
1055
+ withHeader: Un
1023
1056
  };
1024
- function Qt({
1057
+ function ne({
1025
1058
  messages: e,
1026
1059
  error: t,
1027
1060
  inputValue: a,
1028
- onInputChange: i,
1061
+ onInputChange: r,
1029
1062
  onSubmit: s,
1030
- onKeyDown: o,
1031
- textareaRef: r,
1032
- placeholder: g,
1063
+ onKeyDown: i,
1064
+ textareaRef: c,
1065
+ placeholder: h,
1033
1066
  isProcessing: u,
1034
1067
  onStop: m,
1035
- fromCompact: f = !1,
1036
- showHeader: v = !1,
1037
- onClose: y,
1038
- onExpand: b,
1039
- notice: T,
1040
- emptyView: L,
1068
+ fromCompact: p = !1,
1069
+ showHeader: g = !1,
1070
+ onClose: w,
1071
+ onExpand: _,
1072
+ notice: y,
1073
+ emptyView: S,
1041
1074
  suggestions: O,
1042
- clearSuggestions: D,
1043
- messageRenderer: N,
1044
- focusOnMount: H = !1
1075
+ clearSuggestions: H,
1076
+ messageRenderer: A,
1077
+ focusOnMount: $ = !1
1045
1078
  }) {
1046
1079
  return E(() => {
1047
- const c = ($) => {
1048
- $.key === "Escape" && y && y();
1080
+ const l = (N) => {
1081
+ N.key === "Escape" && w && w();
1049
1082
  };
1050
- return document.addEventListener("keydown", c), () => document.removeEventListener("keydown", c);
1051
- }, [y]), /* @__PURE__ */ _(
1083
+ return document.addEventListener("keydown", l), () => document.removeEventListener("keydown", l);
1084
+ }, [w]), /* @__PURE__ */ I(
1052
1085
  "div",
1053
1086
  {
1054
1087
  "data-slot": "conversation-view",
1055
- className: `${Tt.container}${v ? ` ${Tt.withHeader}` : ""}`,
1088
+ className: `${Et.container}${g ? ` ${Et.withHeader}` : ""}`,
1056
1089
  children: [
1057
- v && /* @__PURE__ */ n(fe, { onClose: y }),
1090
+ g && /* @__PURE__ */ n(Ce, { onClose: w }),
1058
1091
  /* @__PURE__ */ n(
1059
- pe,
1092
+ ve,
1060
1093
  {
1061
1094
  messages: e,
1062
1095
  isProcessing: u,
1063
1096
  error: t,
1064
- emptyView: L,
1065
- messageRenderer: N
1097
+ emptyView: S,
1098
+ messageRenderer: A
1066
1099
  }
1067
1100
  ),
1068
1101
  /* @__PURE__ */ n(
1069
- yn,
1102
+ _n,
1070
1103
  {
1071
1104
  inputValue: a,
1072
- onInputChange: i,
1105
+ onInputChange: r,
1073
1106
  onSubmit: s,
1074
- onKeyDown: o,
1075
- textareaRef: r,
1076
- placeholder: g,
1107
+ onKeyDown: i,
1108
+ textareaRef: c,
1109
+ placeholder: h,
1077
1110
  isProcessing: u,
1078
1111
  onStop: m,
1079
- fromCompact: f,
1080
- onExpand: b,
1081
- notice: T,
1112
+ fromCompact: p,
1113
+ onExpand: _,
1114
+ notice: y,
1082
1115
  suggestions: O,
1083
- clearSuggestions: D,
1084
- focusOnMount: H
1116
+ clearSuggestions: H,
1117
+ focusOnMount: $
1085
1118
  }
1086
1119
  )
1087
1120
  ]
1088
1121
  }
1089
1122
  );
1090
1123
  }
1091
- const Hn = "Chat-module_container", $n = "Chat-module_embedded", Fn = "Chat-module_floating", kn = "Chat-module_content", Z = {
1092
- container: Hn,
1093
- embedded: $n,
1094
- floating: Fn,
1095
- content: kn
1096
- }, S = {
1124
+ const Wn = "Chat-module_container", Bn = "Chat-module_embedded", Gn = "Chat-module_floating", Zn = "Chat-module_content", K = {
1125
+ container: Wn,
1126
+ embedded: Bn,
1127
+ floating: Gn,
1128
+ content: Zn
1129
+ }, x = {
1097
1130
  COLLAPSED_SIZE: 56,
1098
1131
  COMPACT_WIDTH: 372,
1099
1132
  EXPANDED_HEIGHT: 520,
@@ -1101,7 +1134,7 @@ const Hn = "Chat-module_container", $n = "Chat-module_embedded", Fn = "Chat-modu
1101
1134
  BORDER_RADIUS: 24,
1102
1135
  PADDING: 16,
1103
1136
  VIEWPORT_OFFSET: 16
1104
- }, yt = {
1137
+ }, _t = {
1105
1138
  SPRING_CONFIG: {
1106
1139
  type: "spring",
1107
1140
  damping: 25,
@@ -1114,266 +1147,266 @@ const Hn = "Chat-module_container", $n = "Chat-module_embedded", Fn = "Chat-modu
1114
1147
  '[data-slot="chat-footer"]'
1115
1148
  ].join(", ")
1116
1149
  };
1117
- function jn({
1150
+ function eo({
1118
1151
  messages: e,
1119
1152
  isProcessing: t,
1120
1153
  error: a,
1121
- onSubmit: i,
1154
+ onSubmit: r,
1122
1155
  variant: s = "floating",
1123
- triggerIcon: o,
1124
- placeholder: r = ie,
1125
- notice: g,
1156
+ triggerIcon: i,
1157
+ placeholder: c = ce,
1158
+ notice: h,
1126
1159
  onOpen: u,
1127
1160
  onExpand: m,
1128
- onClose: f,
1129
- onStop: v,
1130
- emptyView: y,
1131
- floatingChatState: b,
1132
- suggestions: T,
1133
- clearSuggestions: L,
1161
+ onClose: p,
1162
+ onStop: g,
1163
+ emptyView: w,
1164
+ floatingChatState: _,
1165
+ suggestions: y,
1166
+ clearSuggestions: S,
1134
1167
  messageRenderer: O,
1135
- className: D
1168
+ className: H
1136
1169
  }) {
1137
- const [N, H] = W(""), c = oe(b), $ = I(!1), B = I(!1), P = I(!1), [tt, K] = W(!1);
1170
+ const [A, $] = k(""), l = re(_), N = L(!1), ft = L(!1), B = L(!1), [et, G] = k(!1);
1138
1171
  E(() => {
1139
- $.current = !1, B.current = !1, P.current = !1;
1140
- }, [c.state]);
1141
- const F = I(/* @__PURE__ */ new Set()), l = p(() => {
1142
- F.current.forEach((C) => {
1172
+ N.current = !1, ft.current = !1, B.current = !1;
1173
+ }, [l.state]);
1174
+ const M = L(/* @__PURE__ */ new Set()), nt = d(() => {
1175
+ M.current.forEach((C) => {
1143
1176
  clearTimeout(C);
1144
- }), F.current.clear();
1145
- }, []), d = ae({
1146
- value: N,
1147
- setValue: H,
1177
+ }), M.current.clear();
1178
+ }, []), o = se({
1179
+ value: A,
1180
+ setValue: $,
1148
1181
  onSubmit: async (C) => {
1149
- c.state !== "expanded" && (m == null || m()), c.setState("expanded"), await i(C);
1182
+ l.state !== "expanded" && (m == null || m()), l.setState("expanded"), await r(C);
1150
1183
  },
1151
1184
  isProcessing: t
1152
- }), [gt, vt] = W(56), [wt, bt] = W(
1185
+ }), [ot, T] = k(56), [at, Ft] = k(
1153
1186
  "left"
1154
- ), k = I(null), et = I(null), w = I(null), nt = Mt(0), ot = Mt(0), at = ne(), Ft = p(() => {
1155
- $.current = !0, c.open(), u == null || u();
1156
- }, [c, u]), X = p(() => {
1157
- var A, U, G;
1158
- const C = (U = (A = w.current) == null ? void 0 : A.ownerDocument) == null ? void 0 : U.activeElement;
1159
- return !(C && ((G = w.current) != null && G.contains(C)) || N.trim());
1160
- }, [N, w]), dt = (C) => C === "collapsed" ? S.COLLAPSED_SIZE : C === "compact" ? gt : S.EXPANDED_HEIGHT, j = p(() => {
1161
- if (c.state === "collapsed" && (c.setState("compact"), c.initialState === "collapsed")) {
1187
+ ), ht = L(null), pt = L(null), Z = L(null), V = Mt(0), Q = Mt(0), v = ie(), xt = d(() => {
1188
+ N.current = !0, l.open(), u == null || u();
1189
+ }, [l, u]), it = d(() => {
1190
+ var R, F, j;
1191
+ const C = (F = (R = Z.current) == null ? void 0 : R.ownerDocument) == null ? void 0 : F.activeElement;
1192
+ return !(C && ((j = Z.current) != null && j.contains(C)) || A.trim());
1193
+ }, [A, Z]), wt = (C) => C === "collapsed" ? x.COLLAPSED_SIZE : C === "compact" ? ot : x.EXPANDED_HEIGHT, kt = d(() => {
1194
+ if (l.state === "collapsed" && (l.setState("compact"), l.initialState === "collapsed")) {
1162
1195
  const C = setTimeout(() => {
1163
- c.state === "compact" && X() && c.setState("collapsed"), F.current.delete(C);
1164
- }, S.AUTO_COLLAPSE_DELAY);
1165
- F.current.add(C);
1196
+ l.state === "compact" && it() && l.setState("collapsed"), M.current.delete(C);
1197
+ }, x.AUTO_COLLAPSE_DELAY);
1198
+ M.current.add(C);
1166
1199
  }
1167
- }, [c, X]), Q = p(() => {
1168
- if (c.initialState === "collapsed" && c.state === "compact" && X()) {
1200
+ }, [l, it]), Ct = d(() => {
1201
+ if (l.initialState === "collapsed" && l.state === "compact" && it()) {
1169
1202
  const C = setTimeout(() => {
1170
- c.state === "compact" && X() && c.setState("collapsed"), F.current.delete(C);
1171
- }, S.AUTO_COLLAPSE_DELAY);
1172
- F.current.add(C);
1203
+ l.state === "compact" && it() && l.setState("collapsed"), M.current.delete(C);
1204
+ }, x.AUTO_COLLAPSE_DELAY);
1205
+ M.current.add(C);
1173
1206
  }
1174
- }, [c, X]), z = p(async () => {
1175
- if (d.value.trim()) {
1176
- const C = d.value.trim();
1177
- d.clear(), c.state !== "expanded" && (m == null || m()), c.setState("expanded"), await i(C);
1207
+ }, [l, it]), tt = d(async () => {
1208
+ if (o.value.trim()) {
1209
+ const C = o.value.trim();
1210
+ o.clear(), l.state !== "expanded" && (m == null || m()), l.setState("expanded"), await r(C);
1178
1211
  }
1179
- }, [d, i, c, m]), it = p(() => {
1180
- P.current = !0, m == null || m(), c.setState("expanded");
1181
- }, [m, c]), kt = p(() => {
1182
- B.current = !0, d.clear(), c.close(), f && f();
1183
- }, [d, c, f]), rt = p(
1212
+ }, [o, r, l, m]), W = d(() => {
1213
+ B.current = !0, m == null || m(), l.setState("expanded");
1214
+ }, [m, l]), rt = d(() => {
1215
+ ft.current = !0, o.clear(), l.close(), p && p();
1216
+ }, [o, l, p]), Y = d(
1184
1217
  (C) => {
1185
- if (!w.current || !et.current)
1218
+ if (!Z.current || !pt.current)
1186
1219
  return null;
1187
- const A = w.current.getBoundingClientRect(), U = et.current.getBoundingClientRect(), G = window.getComputedStyle(w.current), mt = new DOMMatrixReadOnly(G.transform), St = A.x - mt.e, ct = A.y - mt.f, xt = (C ?? wt) === "left" ? U.left : U.right - S.COMPACT_WIDTH, h = U.bottom - S.EXPANDED_HEIGHT;
1220
+ const R = Z.current.getBoundingClientRect(), F = pt.current.getBoundingClientRect(), j = window.getComputedStyle(Z.current), ct = new DOMMatrixReadOnly(j.transform), Dt = R.x - ct.e, z = R.y - ct.f, Ut = (C ?? at) === "left" ? F.left : F.right - x.COMPACT_WIDTH, Wt = F.bottom - x.EXPANDED_HEIGHT;
1188
1221
  return {
1189
- x: xt - St,
1190
- y: h - ct
1222
+ x: Ut - Dt,
1223
+ y: Wt - z
1191
1224
  };
1192
1225
  },
1193
- [wt]
1194
- ), st = p(
1226
+ [at]
1227
+ ), Lt = d(
1195
1228
  (C) => {
1196
1229
  C.target.closest(
1197
- yt.NON_DRAGGABLE_SELECTORS
1198
- ) || at.start(C.nativeEvent);
1230
+ _t.NON_DRAGGABLE_SELECTORS
1231
+ ) || v.start(C.nativeEvent);
1199
1232
  },
1200
- [at]
1201
- ), Ut = p(
1202
- (C, A) => {
1203
- const U = A.point.x, G = S.COMPACT_WIDTH, mt = (window.innerWidth - G) / 2, ct = U < mt ? "left" : "right";
1204
- bt(ct);
1205
- const ft = rt(ct);
1206
- ft && (Pt(nt, ft.x, {
1207
- ...yt.SPRING_CONFIG,
1208
- velocity: A.velocity.x * yt.VELOCITY_MULTIPLIER
1209
- }), Pt(ot, ft.y, {
1210
- ...yt.SPRING_CONFIG,
1211
- velocity: A.velocity.y * yt.VELOCITY_MULTIPLIER
1233
+ [v]
1234
+ ), Rt = d(
1235
+ (C, R) => {
1236
+ const F = R.point.x, j = x.COMPACT_WIDTH, ct = (window.innerWidth - j) / 2, z = F < ct ? "left" : "right";
1237
+ Ft(z);
1238
+ const gt = Y(z);
1239
+ gt && (Pt(V, gt.x, {
1240
+ ..._t.SPRING_CONFIG,
1241
+ velocity: R.velocity.x * _t.VELOCITY_MULTIPLIER
1242
+ }), Pt(Q, gt.y, {
1243
+ ..._t.SPRING_CONFIG,
1244
+ velocity: R.velocity.y * _t.VELOCITY_MULTIPLIER
1212
1245
  }));
1213
1246
  },
1214
- [nt, ot, rt]
1215
- ), Et = I(c.state), At = Et.current === "compact" && c.state === "expanded";
1247
+ [V, Q, Y]
1248
+ ), yt = L(l.state), st = yt.current === "compact" && l.state === "expanded";
1216
1249
  return E(() => {
1217
- l(), Et.current = c.state;
1218
- }, [c.state, l]), E(() => {
1219
- if (c.state !== "expanded")
1250
+ nt(), yt.current = l.state;
1251
+ }, [l.state, nt]), E(() => {
1252
+ if (l.state !== "expanded")
1220
1253
  return;
1221
1254
  const C = () => {
1222
- const A = rt();
1223
- A && (nt.set(A.x), ot.set(A.y));
1255
+ const R = Y();
1256
+ R && (V.set(R.x), Q.set(R.y));
1224
1257
  };
1225
1258
  return window.addEventListener("resize", C), () => window.removeEventListener("resize", C);
1226
- }, [c.state, nt, ot, rt]), E(() => {
1227
- const C = F.current;
1259
+ }, [l.state, V, Q, Y]), E(() => {
1260
+ const C = M.current;
1228
1261
  return () => {
1229
- C.forEach((A) => {
1230
- clearTimeout(A);
1262
+ C.forEach((R) => {
1263
+ clearTimeout(R);
1231
1264
  }), C.clear();
1232
1265
  };
1233
1266
  }, []), E(() => {
1234
- if (c.state === "compact" && k.current) {
1235
- const C = k.current.scrollHeight + S.PADDING;
1236
- vt(C);
1267
+ if (l.state === "compact" && ht.current) {
1268
+ const C = ht.current.scrollHeight + x.PADDING;
1269
+ T(C);
1237
1270
  }
1238
- }, [c.state, d.value]), s === "embedded" ? /* @__PURE__ */ n(
1271
+ }, [l.state, o.value]), s === "embedded" ? /* @__PURE__ */ n(
1239
1272
  "div",
1240
1273
  {
1241
1274
  "data-slot": "chat-embedded",
1242
- className: V(D, Z.container, Z.embedded),
1275
+ className: U(H, K.container, K.embedded),
1243
1276
  children: /* @__PURE__ */ n(
1244
- Qt,
1277
+ ne,
1245
1278
  {
1246
1279
  messages: e,
1247
- inputValue: d.value,
1248
- onInputChange: d.setValue,
1249
- onSubmit: z,
1250
- onKeyDown: d.handleKeyDown,
1251
- textareaRef: d.textareaRef,
1252
- placeholder: r,
1280
+ inputValue: o.value,
1281
+ onInputChange: o.setValue,
1282
+ onSubmit: tt,
1283
+ onKeyDown: o.handleKeyDown,
1284
+ textareaRef: o.textareaRef,
1285
+ placeholder: c,
1253
1286
  isProcessing: t,
1254
- onStop: v,
1287
+ onStop: g,
1255
1288
  showHeader: !1,
1256
- notice: g,
1257
- suggestions: T,
1258
- clearSuggestions: L,
1289
+ notice: h,
1290
+ suggestions: y,
1291
+ clearSuggestions: S,
1259
1292
  error: a,
1260
- emptyView: y,
1293
+ emptyView: w,
1261
1294
  messageRenderer: O,
1262
- onExpand: it,
1263
- focusOnMount: P.current
1295
+ onExpand: W,
1296
+ focusOnMount: B.current
1264
1297
  }
1265
1298
  )
1266
1299
  }
1267
- ) : /* @__PURE__ */ _(Ht, { children: [
1300
+ ) : /* @__PURE__ */ I(Ht, { children: [
1268
1301
  /* @__PURE__ */ n(
1269
1302
  "div",
1270
1303
  {
1271
- ref: et,
1304
+ ref: pt,
1272
1305
  style: {
1273
1306
  position: "fixed",
1274
- top: S.VIEWPORT_OFFSET,
1275
- left: S.VIEWPORT_OFFSET,
1276
- right: S.VIEWPORT_OFFSET,
1277
- bottom: S.VIEWPORT_OFFSET,
1307
+ top: x.VIEWPORT_OFFSET,
1308
+ left: x.VIEWPORT_OFFSET,
1309
+ right: x.VIEWPORT_OFFSET,
1310
+ bottom: x.VIEWPORT_OFFSET,
1278
1311
  pointerEvents: "none"
1279
1312
  }
1280
1313
  }
1281
1314
  ),
1282
1315
  /* @__PURE__ */ n(
1283
- M.div,
1316
+ P.div,
1284
1317
  {
1285
- ref: w,
1318
+ ref: Z,
1286
1319
  "data-slot": "chat-floating",
1287
- className: V(D, Z.container, Z.floating, {
1288
- animating: tt
1320
+ className: U(H, K.container, K.floating, {
1321
+ animating: et
1289
1322
  }),
1290
- onMouseLeave: c.state === "compact" ? Q : void 0,
1291
- drag: c.state === "expanded",
1292
- dragControls: at,
1323
+ onMouseLeave: l.state === "compact" ? Ct : void 0,
1324
+ drag: l.state === "expanded",
1325
+ dragControls: v,
1293
1326
  dragListener: !1,
1294
- dragConstraints: et,
1327
+ dragConstraints: pt,
1295
1328
  dragMomentum: !1,
1296
1329
  dragElastic: 0.1,
1297
1330
  dragTransition: { power: 0.1, timeConstant: 100 },
1298
- onDragEnd: Ut,
1299
- onPointerDown: st,
1331
+ onDragEnd: Rt,
1332
+ onPointerDown: Lt,
1300
1333
  style: {
1301
- x: nt,
1302
- y: ot,
1303
- bottom: S.VIEWPORT_OFFSET,
1304
- left: S.VIEWPORT_OFFSET
1334
+ x: V,
1335
+ y: Q,
1336
+ bottom: x.VIEWPORT_OFFSET,
1337
+ left: x.VIEWPORT_OFFSET
1305
1338
  },
1306
1339
  children: /* @__PURE__ */ n(
1307
- M.div,
1340
+ P.div,
1308
1341
  {
1309
1342
  layout: !0,
1310
- className: Z.content,
1343
+ className: K.content,
1311
1344
  initial: !1,
1312
1345
  animate: {
1313
- width: c.state === "collapsed" ? S.COLLAPSED_SIZE : S.COMPACT_WIDTH,
1314
- height: dt(c.state),
1315
- x: c.state === "collapsed" && wt === "right" ? S.COMPACT_WIDTH - S.COLLAPSED_SIZE : 0,
1316
- transition: d.value.trim() ? { duration: 0 } : $t
1346
+ width: l.state === "collapsed" ? x.COLLAPSED_SIZE : x.COMPACT_WIDTH,
1347
+ height: wt(l.state),
1348
+ x: l.state === "collapsed" && at === "right" ? x.COMPACT_WIDTH - x.COLLAPSED_SIZE : 0,
1349
+ transition: o.value.trim() ? { duration: 0 } : $t
1317
1350
  },
1318
- onAnimationStart: () => K(!0),
1319
- onAnimationComplete: () => K(!1),
1351
+ onAnimationStart: () => G(!0),
1352
+ onAnimationComplete: () => G(!1),
1320
1353
  style: {
1321
- borderRadius: S.BORDER_RADIUS
1354
+ borderRadius: x.BORDER_RADIUS
1322
1355
  },
1323
- children: /* @__PURE__ */ _(_t, { mode: "wait", children: [
1324
- c.state === "collapsed" && /* @__PURE__ */ n(
1325
- ce,
1356
+ children: /* @__PURE__ */ I(At, { mode: "wait", children: [
1357
+ l.state === "collapsed" && /* @__PURE__ */ n(
1358
+ de,
1326
1359
  {
1327
- icon: o,
1328
- onClick: Ft,
1329
- onHover: j,
1330
- focusOnMount: B.current
1360
+ icon: i,
1361
+ onClick: xt,
1362
+ onHover: kt,
1363
+ focusOnMount: ft.current
1331
1364
  },
1332
1365
  "collapsed"
1333
1366
  ),
1334
- c.state === "compact" && /* @__PURE__ */ n("div", { ref: k, children: /* @__PURE__ */ n(
1335
- de,
1367
+ l.state === "compact" && /* @__PURE__ */ n("div", { ref: ht, children: /* @__PURE__ */ n(
1368
+ he,
1336
1369
  {
1337
- value: d.value,
1338
- onChange: d.setValue,
1339
- onSubmit: z,
1340
- onKeyDown: d.handleKeyDown,
1341
- textareaRef: d.textareaRef,
1342
- placeholder: r,
1370
+ value: o.value,
1371
+ onChange: o.setValue,
1372
+ onSubmit: tt,
1373
+ onKeyDown: o.handleKeyDown,
1374
+ textareaRef: o.textareaRef,
1375
+ placeholder: c,
1343
1376
  isProcessing: t,
1344
- onBlur: Q,
1345
- onExpand: it,
1346
- showExpandButton: !d.value.trim(),
1347
- focusOnMount: $.current,
1348
- onStop: v,
1349
- suggestions: T,
1350
- clearSuggestions: L
1377
+ onBlur: Ct,
1378
+ onExpand: W,
1379
+ showExpandButton: !o.value.trim(),
1380
+ focusOnMount: N.current,
1381
+ onStop: g,
1382
+ suggestions: y,
1383
+ clearSuggestions: S
1351
1384
  },
1352
1385
  "compact"
1353
1386
  ) }),
1354
- c.state === "expanded" && /* @__PURE__ */ n(
1355
- Qt,
1387
+ l.state === "expanded" && /* @__PURE__ */ n(
1388
+ ne,
1356
1389
  {
1357
1390
  messages: e,
1358
- inputValue: d.value,
1359
- onInputChange: d.setValue,
1360
- onSubmit: z,
1361
- onKeyDown: d.handleKeyDown,
1362
- textareaRef: d.textareaRef,
1363
- placeholder: r,
1391
+ inputValue: o.value,
1392
+ onInputChange: o.setValue,
1393
+ onSubmit: tt,
1394
+ onKeyDown: o.handleKeyDown,
1395
+ textareaRef: o.textareaRef,
1396
+ placeholder: c,
1364
1397
  isProcessing: t,
1365
- onStop: v,
1398
+ onStop: g,
1366
1399
  showHeader: !0,
1367
- onClose: kt,
1368
- fromCompact: At,
1369
- notice: g,
1370
- suggestions: T,
1371
- clearSuggestions: L,
1400
+ onClose: rt,
1401
+ fromCompact: st,
1402
+ notice: h,
1403
+ suggestions: y,
1404
+ clearSuggestions: S,
1372
1405
  error: a,
1373
- emptyView: y,
1406
+ emptyView: w,
1374
1407
  messageRenderer: O,
1375
- onExpand: it,
1376
- focusOnMount: P.current
1408
+ onExpand: W,
1409
+ focusOnMount: B.current
1377
1410
  },
1378
1411
  "expanded"
1379
1412
  )
@@ -1384,7 +1417,7 @@ function jn({
1384
1417
  )
1385
1418
  ] });
1386
1419
  }
1387
- const x = {
1420
+ const D = {
1388
1421
  COLLAPSED_SIZE: 56,
1389
1422
  COMPACT_WIDTH: 372,
1390
1423
  EXPANDED_HEIGHT: 520,
@@ -1392,7 +1425,7 @@ const x = {
1392
1425
  BORDER_RADIUS: 24,
1393
1426
  PADDING: 16,
1394
1427
  VIEWPORT_OFFSET: 16
1395
- }, It = {
1428
+ }, St = {
1396
1429
  SPRING_CONFIG: {
1397
1430
  type: "spring",
1398
1431
  damping: 25,
@@ -1405,273 +1438,313 @@ const x = {
1405
1438
  '[data-slot="chat-footer"]'
1406
1439
  ].join(", ")
1407
1440
  };
1408
- function Ce({
1441
+ function Yn() {
1442
+ return /* @__PURE__ */ n(
1443
+ "div",
1444
+ {
1445
+ style: {
1446
+ position: "fixed",
1447
+ top: 0,
1448
+ left: 0,
1449
+ right: 0,
1450
+ bottom: 0,
1451
+ zIndex: 9999,
1452
+ cursor: "grabbing",
1453
+ pointerEvents: "auto",
1454
+ userSelect: "none",
1455
+ WebkitUserSelect: "none",
1456
+ MozUserSelect: "none",
1457
+ msUserSelect: "none"
1458
+ }
1459
+ }
1460
+ );
1461
+ }
1462
+ function we({
1409
1463
  children: e,
1410
1464
  messages: t,
1411
1465
  isProcessing: a,
1412
- error: i,
1466
+ error: r,
1413
1467
  onSubmit: s,
1414
- variant: o = "floating",
1415
- triggerIcon: r,
1416
- placeholder: g,
1468
+ variant: i = "floating",
1469
+ triggerIcon: c,
1470
+ placeholder: h,
1417
1471
  notice: u,
1418
1472
  onOpen: m,
1419
- onExpand: f,
1420
- onClose: v,
1421
- onStop: y,
1422
- emptyView: b,
1423
- floatingChatState: T,
1424
- suggestions: L,
1473
+ onExpand: p,
1474
+ onClose: g,
1475
+ onStop: w,
1476
+ emptyView: _,
1477
+ floatingChatState: y,
1478
+ suggestions: S,
1425
1479
  clearSuggestions: O,
1426
- messageRenderer: D,
1427
- className: N,
1428
- inputValue: H,
1429
- onInputChange: c,
1430
- ...$
1480
+ messageRenderer: H,
1481
+ className: A,
1482
+ inputValue: $,
1483
+ onInputChange: l,
1484
+ draggableStates: N = ["expanded"],
1485
+ // Default to only expanded for backward compatibility
1486
+ ...ft
1431
1487
  }) {
1432
- const B = H !== void 0, [P, tt] = W(""), K = B ? H : P, F = B ? c : tt, l = oe(T), d = I(!1), gt = I(!1), vt = I(!1), [wt, bt] = W(!1);
1488
+ const B = $ !== void 0, [et, G] = k(""), M = B ? $ : et, nt = B ? l : G, o = re(y), ot = L(!1), T = L(!1), at = L(!1), [Ft, ht] = k(!1), [pt, Z] = k(!1);
1433
1489
  E(() => {
1434
- d.current = !1, gt.current = !1, vt.current = !1;
1435
- }, [l.state]);
1436
- const k = I(/* @__PURE__ */ new Set()), et = p(() => {
1437
- k.current.forEach((h) => {
1438
- clearTimeout(h);
1439
- }), k.current.clear();
1440
- }, []), w = ae({
1441
- value: K,
1442
- setValue: F,
1443
- onSubmit: async (h) => {
1444
- l.state !== "expanded" && (f == null || f()), l.setState("expanded"), await s(h);
1490
+ ot.current = !1, T.current = !1, at.current = !1;
1491
+ }, [o.state]);
1492
+ const V = L(/* @__PURE__ */ new Set()), Q = d(() => {
1493
+ V.current.forEach((f) => {
1494
+ clearTimeout(f);
1495
+ }), V.current.clear();
1496
+ }, []), v = se({
1497
+ value: M,
1498
+ setValue: nt,
1499
+ onSubmit: async (f) => {
1500
+ o.state !== "expanded" && (p == null || p()), o.setState("expanded"), await s(f);
1445
1501
  },
1446
1502
  isProcessing: a
1447
- }), [nt, ot] = W(56), [at, Ft] = W(
1503
+ }), [xt, it] = k(56), [wt, kt] = k(
1448
1504
  "left"
1449
- ), X = I(null), dt = I(null), j = I(null), Q = Mt(0), z = Mt(0), it = ne(), kt = p(
1450
- (h) => {
1451
- w.setValue(h), O == null || O();
1505
+ ), Ct = L(null), tt = L(null), W = L(null), rt = Mt(0), Y = Mt(0), Lt = ie(), Rt = d(
1506
+ (f) => {
1507
+ const b = f.endsWith(" ") ? f : `${f} `;
1508
+ v.setValue(b), O == null || O(), v.textareaRef.current && (v.textareaRef.current.focus(), v.textareaRef.current.setSelectionRange(
1509
+ b.length,
1510
+ b.length
1511
+ ));
1452
1512
  },
1453
- [w.setValue, O]
1454
- ), rt = p(() => {
1455
- d.current = !0, l.open(), m == null || m();
1456
- }, [l, m]), st = p(() => {
1457
- var R, q, ht;
1458
- const h = (q = (R = j.current) == null ? void 0 : R.ownerDocument) == null ? void 0 : q.activeElement;
1459
- return !(h && ((ht = j.current) != null && ht.contains(h)) || K.trim());
1460
- }, [K, j]), Ut = (h) => h === "collapsed" ? x.COLLAPSED_SIZE : h === "compact" ? nt : x.EXPANDED_HEIGHT, Et = p(() => {
1461
- if (l.state === "collapsed" && (l.setState("compact"), l.initialState === "collapsed")) {
1462
- const h = setTimeout(() => {
1463
- l.state === "compact" && st() && l.setState("collapsed"), k.current.delete(h);
1464
- }, x.AUTO_COLLAPSE_DELAY);
1465
- k.current.add(h);
1513
+ [v.setValue, O]
1514
+ ), yt = d(() => {
1515
+ ot.current = !0, o.open(), m == null || m();
1516
+ }, [o, m]), st = d(() => {
1517
+ var b, q, lt;
1518
+ const f = (q = (b = W.current) == null ? void 0 : b.ownerDocument) == null ? void 0 : q.activeElement;
1519
+ return !(f && ((lt = W.current) != null && lt.contains(f)) || M.trim());
1520
+ }, [M, W]), C = d(
1521
+ (f) => f === "collapsed" ? D.COLLAPSED_SIZE : f === "compact" ? xt : D.EXPANDED_HEIGHT,
1522
+ [xt]
1523
+ ), R = d(() => {
1524
+ if (o.state === "collapsed" && (o.setState("compact"), o.initialState === "collapsed")) {
1525
+ const f = setTimeout(() => {
1526
+ o.state === "compact" && st() && o.setState("collapsed"), V.current.delete(f);
1527
+ }, D.AUTO_COLLAPSE_DELAY);
1528
+ V.current.add(f);
1466
1529
  }
1467
- }, [l, st]), At = p(() => {
1468
- if (l.initialState === "collapsed" && l.state === "compact" && st()) {
1469
- const h = setTimeout(() => {
1470
- l.state === "compact" && st() && l.setState("collapsed"), k.current.delete(h);
1471
- }, x.AUTO_COLLAPSE_DELAY);
1472
- k.current.add(h);
1530
+ }, [o, st]), F = d(() => {
1531
+ if (o.initialState === "collapsed" && o.state === "compact" && st()) {
1532
+ const f = setTimeout(() => {
1533
+ o.state === "compact" && st() && o.setState("collapsed"), V.current.delete(f);
1534
+ }, D.AUTO_COLLAPSE_DELAY);
1535
+ V.current.add(f);
1473
1536
  }
1474
- }, [l, st]), C = p(async () => {
1475
- if (w.value.trim()) {
1476
- const h = w.value.trim();
1477
- w.clear(), l.state !== "expanded" && (f == null || f()), l.setState("expanded"), await s(h);
1537
+ }, [o, st]), j = d(async () => {
1538
+ if (v.value.trim()) {
1539
+ const f = v.value.trim();
1540
+ v.clear(), o.state !== "expanded" && (p == null || p()), o.setState("expanded"), await s(f);
1478
1541
  }
1479
- }, [w, s, l, f]), A = p(() => {
1480
- vt.current = !0, f == null || f(), l.setState("expanded");
1481
- }, [f, l]), U = p(() => {
1482
- gt.current = !0, w.clear(), l.close(), v && v();
1483
- }, [w, l, v]), G = p(
1484
- (h) => {
1485
- if (!j.current || !dt.current)
1542
+ }, [v, s, o, p]), ct = d(() => {
1543
+ at.current = !0, p == null || p(), o.setState("expanded");
1544
+ }, [p, o]), Dt = d(() => {
1545
+ T.current = !0, v.clear(), o.close(), g && g();
1546
+ }, [v, o, g]), z = d(
1547
+ (f) => {
1548
+ if (!W.current || !tt.current)
1486
1549
  return null;
1487
- const R = j.current.getBoundingClientRect(), q = dt.current.getBoundingClientRect(), ht = window.getComputedStyle(j.current), Ot = new DOMMatrixReadOnly(ht.transform), jt = R.x - Ot.e, Nt = R.y - Ot.f, _e = (h ?? at) === "left" ? q.left : q.right - x.COMPACT_WIDTH, be = q.bottom - x.EXPANDED_HEIGHT;
1550
+ const b = W.current.getBoundingClientRect(), q = tt.current.getBoundingClientRect(), lt = window.getComputedStyle(W.current), Ot = new DOMMatrixReadOnly(lt.transform), Jt = b.x - Ot.e, Nt = b.y - Ot.f, bt = f ?? wt, Ae = C(o.state), xe = bt === "left" ? q.left : q.right - D.COMPACT_WIDTH, Re = q.bottom - Ae;
1488
1551
  return {
1489
- x: _e - jt,
1490
- y: be - Nt
1552
+ x: xe - Jt,
1553
+ y: Re - Nt
1491
1554
  };
1492
1555
  },
1493
- [at]
1494
- ), mt = p(
1495
- (h) => {
1496
- h.target.closest(
1497
- It.NON_DRAGGABLE_SELECTORS
1498
- ) || it.start(h.nativeEvent);
1556
+ [wt, o.state, C]
1557
+ ), gt = d(
1558
+ (f) => {
1559
+ const b = f.target;
1560
+ if (b.ownerDocument !== document)
1561
+ return;
1562
+ b.closest(
1563
+ St.NON_DRAGGABLE_SELECTORS
1564
+ ) || (f.preventDefault(), Lt.start(f.nativeEvent));
1499
1565
  },
1500
- [it]
1501
- ), St = p(
1502
- (h, R) => {
1503
- const q = R.point.x, ht = x.COMPACT_WIDTH, Ot = (window.innerWidth - ht) / 2, Nt = q < Ot ? "left" : "right";
1504
- Ft(Nt);
1505
- const Rt = G(Nt);
1506
- Rt && (Pt(Q, Rt.x, {
1507
- ...It.SPRING_CONFIG,
1508
- velocity: R.velocity.x * It.VELOCITY_MULTIPLIER
1509
- }), Pt(z, Rt.y, {
1510
- ...It.SPRING_CONFIG,
1511
- velocity: R.velocity.y * It.VELOCITY_MULTIPLIER
1566
+ [Lt]
1567
+ ), Ut = d(() => {
1568
+ Z(!0);
1569
+ }, []), Wt = d(
1570
+ (f, b) => {
1571
+ Z(!1);
1572
+ const q = b.point.x, lt = D.COMPACT_WIDTH, Ot = (window.innerWidth - lt) / 2, Nt = q < Ot ? "left" : "right";
1573
+ kt(Nt);
1574
+ const bt = z(Nt);
1575
+ bt && (Pt(rt, bt.x, {
1576
+ ...St.SPRING_CONFIG,
1577
+ velocity: b.velocity.x * St.VELOCITY_MULTIPLIER
1578
+ }), Pt(Y, bt.y, {
1579
+ ...St.SPRING_CONFIG,
1580
+ velocity: b.velocity.y * St.VELOCITY_MULTIPLIER
1512
1581
  }));
1513
1582
  },
1514
- [Q, z, G]
1515
- ), ct = I(l.state), ft = ct.current === "compact" && l.state === "expanded";
1583
+ [rt, Y, z]
1584
+ ), zt = L(o.state), Ee = zt.current === "compact" && o.state === "expanded";
1516
1585
  E(() => {
1517
- et(), ct.current = l.state;
1518
- }, [l.state, et]), E(() => {
1519
- if (l.state !== "expanded")
1586
+ Q(), zt.current = o.state;
1587
+ }, [o.state, Q]), E(() => {
1588
+ if (o.state !== "expanded")
1520
1589
  return;
1521
- const h = () => {
1522
- const R = G();
1523
- R && (Q.set(R.x), z.set(R.y));
1590
+ const f = () => {
1591
+ const b = z();
1592
+ b && (rt.set(b.x), Y.set(b.y));
1524
1593
  };
1525
- return window.addEventListener("resize", h), () => window.removeEventListener("resize", h);
1526
- }, [l.state, Q, z, G]), E(() => {
1527
- const h = k.current;
1594
+ return window.addEventListener("resize", f), () => window.removeEventListener("resize", f);
1595
+ }, [o.state, rt, Y, z]), E(() => {
1596
+ const f = V.current;
1528
1597
  return () => {
1529
- h.forEach((R) => {
1530
- clearTimeout(R);
1531
- }), h.clear();
1598
+ f.forEach((b) => {
1599
+ clearTimeout(b);
1600
+ }), f.clear();
1532
1601
  };
1533
1602
  }, []), E(() => {
1534
- if (l.state === "compact" && X.current) {
1535
- const h = X.current.scrollHeight + x.PADDING;
1536
- ot(h);
1603
+ if (o.state === "compact" && Ct.current) {
1604
+ const f = Ct.current.scrollHeight + D.PADDING;
1605
+ it(f);
1537
1606
  }
1538
- }, [l.state, w.value]);
1539
- const xt = {
1607
+ }, [o.state, v.value]);
1608
+ const qt = {
1540
1609
  // Core data
1541
1610
  messages: t,
1542
1611
  isProcessing: a,
1543
- error: i,
1612
+ error: r,
1544
1613
  // Input state
1545
- inputValue: w.value,
1546
- setInputValue: w.setValue,
1547
- clearInput: w.clear,
1548
- textareaRef: w.textareaRef,
1549
- handleKeyDown: w.handleKeyDown,
1614
+ inputValue: v.value,
1615
+ setInputValue: v.setValue,
1616
+ clearInput: v.clear,
1617
+ textareaRef: v.textareaRef,
1618
+ handleKeyDown: v.handleKeyDown,
1550
1619
  // Actions
1551
1620
  onSubmit: s,
1552
- handleSubmit: C,
1553
- onStop: y,
1621
+ handleSubmit: j,
1622
+ onStop: w,
1554
1623
  // UI state
1555
- variant: o,
1556
- placeholder: g,
1557
- emptyView: b,
1558
- messageRenderer: D,
1624
+ variant: i,
1625
+ placeholder: h,
1626
+ emptyView: _,
1627
+ messageRenderer: H,
1559
1628
  // Floating chat specific
1560
- floatingChatState: l.state,
1561
- triggerIcon: r,
1562
- onOpen: rt,
1563
- onExpand: A,
1564
- onClose: U,
1629
+ floatingChatState: o.state,
1630
+ triggerIcon: c,
1631
+ onOpen: yt,
1632
+ onExpand: ct,
1633
+ onClose: Dt,
1565
1634
  // Suggestions
1566
- suggestions: L,
1635
+ suggestions: S,
1567
1636
  clearSuggestions: O,
1568
- handleSuggestionSubmit: kt,
1637
+ handleSuggestionSubmit: Rt,
1569
1638
  // Notice
1570
1639
  notice: u,
1571
1640
  // Internal state for components
1572
- focusOnMount: vt.current,
1573
- fromCompact: ft,
1574
- showExpandButton: !w.value.trim()
1641
+ focusOnMount: at.current,
1642
+ fromCompact: Ee,
1643
+ showExpandButton: !v.value.trim()
1575
1644
  };
1576
- return o === "embedded" ? /* @__PURE__ */ n(zt, { value: xt, children: /* @__PURE__ */ n(
1645
+ return i === "embedded" ? /* @__PURE__ */ n(Qt, { value: qt, children: /* @__PURE__ */ n(
1577
1646
  "div",
1578
1647
  {
1579
1648
  "data-slot": "chat-embedded",
1580
- className: V(
1581
- N,
1582
- Z.container,
1583
- Z.embedded
1649
+ className: U(
1650
+ A,
1651
+ K.container,
1652
+ K.embedded
1584
1653
  ),
1585
1654
  children: e
1586
1655
  }
1587
- ) }) : /* @__PURE__ */ _(zt, { value: xt, children: [
1656
+ ) }) : /* @__PURE__ */ I(Qt, { value: qt, children: [
1588
1657
  /* @__PURE__ */ n(
1589
1658
  "div",
1590
1659
  {
1591
- ref: dt,
1660
+ ref: tt,
1592
1661
  style: {
1593
1662
  position: "fixed",
1594
- top: x.VIEWPORT_OFFSET,
1595
- left: x.VIEWPORT_OFFSET,
1596
- right: x.VIEWPORT_OFFSET,
1597
- bottom: x.VIEWPORT_OFFSET,
1663
+ top: D.VIEWPORT_OFFSET,
1664
+ left: D.VIEWPORT_OFFSET,
1665
+ right: D.VIEWPORT_OFFSET,
1666
+ bottom: D.VIEWPORT_OFFSET,
1598
1667
  pointerEvents: "none"
1599
1668
  }
1600
1669
  }
1601
1670
  ),
1671
+ pt && /* @__PURE__ */ n(Yn, {}),
1602
1672
  /* @__PURE__ */ n(
1603
- M.div,
1673
+ P.div,
1604
1674
  {
1605
- ref: j,
1675
+ ref: W,
1606
1676
  "data-slot": "chat-floating",
1607
- className: V(N, Z.container, Z.floating, {
1608
- animating: wt
1677
+ className: U(A, K.container, K.floating, {
1678
+ animating: Ft
1609
1679
  }),
1610
- onMouseLeave: l.state === "compact" ? At : void 0,
1611
- drag: l.state === "expanded",
1612
- dragControls: it,
1680
+ onMouseLeave: o.state === "compact" ? F : void 0,
1681
+ drag: N.includes(o.state),
1682
+ dragControls: Lt,
1613
1683
  dragListener: !1,
1614
- dragConstraints: dt,
1684
+ dragConstraints: tt,
1615
1685
  dragMomentum: !1,
1616
1686
  dragElastic: 0.1,
1617
1687
  dragTransition: { power: 0.1, timeConstant: 100 },
1618
- onDragEnd: St,
1619
- onPointerDown: mt,
1688
+ onDragStart: Ut,
1689
+ onDragEnd: Wt,
1690
+ onPointerDown: gt,
1620
1691
  style: {
1621
- x: Q,
1622
- y: z,
1623
- bottom: x.VIEWPORT_OFFSET,
1624
- left: x.VIEWPORT_OFFSET
1692
+ x: rt,
1693
+ y: Y,
1694
+ bottom: D.VIEWPORT_OFFSET,
1695
+ left: D.VIEWPORT_OFFSET,
1696
+ cursor: N.includes(o.state) ? "grab" : "default"
1625
1697
  },
1626
1698
  children: /* @__PURE__ */ n(
1627
- M.div,
1699
+ P.div,
1628
1700
  {
1629
1701
  layout: !0,
1630
- className: Z.content,
1702
+ className: K.content,
1631
1703
  initial: !1,
1632
1704
  animate: {
1633
- width: l.state === "collapsed" ? x.COLLAPSED_SIZE : x.COMPACT_WIDTH,
1634
- height: Ut(l.state),
1635
- x: l.state === "collapsed" && at === "right" ? x.COMPACT_WIDTH - x.COLLAPSED_SIZE : 0,
1636
- transition: w.value.trim() ? { duration: 0 } : $t
1705
+ width: o.state === "collapsed" ? D.COLLAPSED_SIZE : D.COMPACT_WIDTH,
1706
+ height: C(o.state),
1707
+ x: o.state === "collapsed" && wt === "right" ? D.COMPACT_WIDTH - D.COLLAPSED_SIZE : 0,
1708
+ transition: v.value.trim() ? { duration: 0 } : $t
1637
1709
  },
1638
- onAnimationStart: () => bt(!0),
1639
- onAnimationComplete: () => bt(!1),
1710
+ onAnimationStart: () => ht(!0),
1711
+ onAnimationComplete: () => ht(!1),
1640
1712
  style: {
1641
- borderRadius: x.BORDER_RADIUS
1713
+ borderRadius: D.BORDER_RADIUS
1642
1714
  },
1643
- children: /* @__PURE__ */ _(_t, { mode: "wait", children: [
1644
- l.state === "collapsed" && /* @__PURE__ */ n(
1645
- ce,
1715
+ children: /* @__PURE__ */ I(At, { mode: "wait", children: [
1716
+ o.state === "collapsed" && /* @__PURE__ */ n(
1717
+ de,
1646
1718
  {
1647
- icon: r,
1648
- onClick: rt,
1649
- onHover: Et,
1650
- focusOnMount: gt.current
1719
+ icon: c,
1720
+ onClick: yt,
1721
+ onHover: R,
1722
+ focusOnMount: T.current
1651
1723
  },
1652
1724
  "collapsed"
1653
1725
  ),
1654
- l.state === "compact" && /* @__PURE__ */ n("div", { ref: X, children: /* @__PURE__ */ n(
1655
- de,
1726
+ o.state === "compact" && /* @__PURE__ */ n("div", { ref: Ct, children: /* @__PURE__ */ n(
1727
+ he,
1656
1728
  {
1657
- value: w.value,
1658
- onChange: w.setValue,
1659
- onSubmit: C,
1660
- onKeyDown: w.handleKeyDown,
1661
- textareaRef: w.textareaRef,
1662
- placeholder: g,
1729
+ value: v.value,
1730
+ onChange: v.setValue,
1731
+ onSubmit: j,
1732
+ onKeyDown: v.handleKeyDown,
1733
+ textareaRef: v.textareaRef,
1734
+ placeholder: h,
1663
1735
  isProcessing: a,
1664
- onBlur: At,
1665
- onExpand: A,
1666
- showExpandButton: !w.value.trim(),
1667
- focusOnMount: d.current,
1668
- onStop: y,
1669
- suggestions: L,
1670
- clearSuggestions: O
1736
+ onBlur: F,
1737
+ onExpand: ct,
1738
+ showExpandButton: !v.value.trim(),
1739
+ focusOnMount: ot.current,
1740
+ onStop: w,
1741
+ suggestions: S,
1742
+ clearSuggestions: O,
1743
+ handleSuggestionSubmit: Rt
1671
1744
  },
1672
1745
  "compact"
1673
1746
  ) }),
1674
- l.state === "expanded" && e
1747
+ o.state === "expanded" && e
1675
1748
  ] })
1676
1749
  }
1677
1750
  )
@@ -1679,84 +1752,95 @@ function Ce({
1679
1752
  )
1680
1753
  ] });
1681
1754
  }
1682
- function ge({ className: e } = {}) {
1683
- const { onClose: t } = ut();
1684
- return /* @__PURE__ */ n(fe, { onClose: t, className: e });
1755
+ function Le({ className: e } = {}) {
1756
+ const { onClose: t } = mt();
1757
+ return /* @__PURE__ */ n(Ce, { onClose: t, className: e });
1685
1758
  }
1686
- function ve({ className: e } = {}) {
1687
- const { messages: t, isProcessing: a, error: i, emptyView: s, messageRenderer: o } = ut();
1759
+ function ye({ className: e } = {}) {
1760
+ const { messages: t, isProcessing: a, error: r, emptyView: s, messageRenderer: i } = mt();
1688
1761
  return /* @__PURE__ */ n(
1689
- pe,
1762
+ ve,
1690
1763
  {
1691
1764
  messages: t,
1692
1765
  isProcessing: a,
1693
- error: i,
1766
+ error: r,
1694
1767
  emptyView: s,
1695
- messageRenderer: o,
1768
+ messageRenderer: i,
1696
1769
  className: e
1697
1770
  }
1698
1771
  );
1699
1772
  }
1700
- function we({
1773
+ function be({
1701
1774
  className: e,
1702
1775
  disabled: t,
1703
1776
  customActions: a,
1704
- actionOrder: i
1777
+ actionOrder: r
1705
1778
  } = {}) {
1706
1779
  const {
1707
1780
  inputValue: s,
1708
- setInputValue: o,
1709
- handleSubmit: r,
1710
- handleKeyDown: g,
1781
+ setInputValue: i,
1782
+ handleSubmit: c,
1783
+ handleKeyDown: h,
1711
1784
  textareaRef: u,
1712
1785
  placeholder: m,
1713
- isProcessing: f,
1714
- onStop: v,
1715
- fromCompact: y,
1716
- onExpand: b,
1717
- showExpandButton: T,
1718
- focusOnMount: L
1719
- } = ut();
1786
+ isProcessing: p,
1787
+ onStop: g,
1788
+ fromCompact: w,
1789
+ onExpand: _,
1790
+ showExpandButton: y,
1791
+ focusOnMount: S
1792
+ } = mt();
1720
1793
  return /* @__PURE__ */ n(
1721
- Kt,
1794
+ Xt,
1722
1795
  {
1723
1796
  value: s,
1724
- onChange: o,
1725
- onSubmit: r,
1726
- onKeyDown: g,
1797
+ onChange: i,
1798
+ onSubmit: c,
1799
+ onKeyDown: h,
1727
1800
  textareaRef: u,
1728
1801
  placeholder: m,
1729
- isProcessing: f,
1730
- onStop: v,
1731
- fromCompact: y,
1732
- onExpand: b,
1733
- showExpandButton: T,
1734
- focusOnMount: L,
1802
+ isProcessing: p,
1803
+ onStop: g,
1804
+ fromCompact: w,
1805
+ onExpand: _,
1806
+ showExpandButton: y,
1807
+ focusOnMount: S,
1735
1808
  disabled: t,
1736
1809
  customActions: a,
1737
- actionOrder: i,
1810
+ actionOrder: r,
1738
1811
  className: e
1739
1812
  }
1740
1813
  );
1741
1814
  }
1742
- function Le({
1815
+ function Ie({
1743
1816
  className: e,
1744
- showSuggestions: t
1817
+ showSuggestions: t,
1818
+ onSelect: a
1745
1819
  } = {}) {
1746
- const { suggestions: a, handleSuggestionSubmit: i, inputValue: s } = ut();
1747
- return s && !t ? null : /* @__PURE__ */ n(
1748
- Xt,
1820
+ const { suggestions: r, handleSuggestionSubmit: s, inputValue: i } = mt(), c = d(
1821
+ (h) => {
1822
+ try {
1823
+ a == null || a(h);
1824
+ } catch (u) {
1825
+ console.warn("Suggestions onSelect callback failed:", u);
1826
+ }
1827
+ s(h);
1828
+ },
1829
+ [a, s]
1830
+ );
1831
+ return i && !t ? null : /* @__PURE__ */ n(
1832
+ jt,
1749
1833
  {
1750
- suggestions: a,
1751
- onSubmit: i,
1834
+ suggestions: r,
1835
+ onSubmit: c,
1752
1836
  className: e
1753
1837
  }
1754
1838
  );
1755
1839
  }
1756
- function ye({ className: e } = {}) {
1757
- const { notice: t } = ut();
1840
+ function Te({ className: e } = {}) {
1841
+ const { notice: t } = mt();
1758
1842
  return t ? /* @__PURE__ */ n(
1759
- he,
1843
+ ge,
1760
1844
  {
1761
1845
  icon: t.icon,
1762
1846
  message: t.message,
@@ -1767,96 +1851,96 @@ function ye({ className: e } = {}) {
1767
1851
  }
1768
1852
  ) : null;
1769
1853
  }
1770
- function Ie({
1854
+ function _e({
1771
1855
  children: e,
1772
1856
  className: t
1773
1857
  } = {}) {
1774
1858
  return e ? /* @__PURE__ */ n(
1775
- M.div,
1859
+ P.div,
1776
1860
  {
1777
1861
  "data-slot": "chat-footer",
1778
- className: V(Yt.container, t),
1862
+ className: U(Kt.container, t),
1779
1863
  initial: { opacity: 0, scale: 1 },
1780
1864
  animate: { opacity: 1, scale: 1 },
1781
- transition: { ...lt },
1865
+ transition: { ...dt },
1782
1866
  children: e
1783
1867
  }
1784
- ) : /* @__PURE__ */ _(
1785
- M.div,
1868
+ ) : /* @__PURE__ */ I(
1869
+ P.div,
1786
1870
  {
1787
1871
  "data-slot": "chat-footer",
1788
- className: V(Yt.container, t),
1872
+ className: U(Kt.container, t),
1789
1873
  initial: { opacity: 0, scale: 1 },
1790
1874
  animate: { opacity: 1, scale: 1 },
1791
- transition: { ...lt },
1875
+ transition: { ...dt },
1792
1876
  children: [
1793
- /* @__PURE__ */ n(Le, {}),
1794
- /* @__PURE__ */ n(ye, {}),
1795
- /* @__PURE__ */ n(we, {})
1877
+ /* @__PURE__ */ n(Ie, {}),
1878
+ /* @__PURE__ */ n(Te, {}),
1879
+ /* @__PURE__ */ n(be, {})
1796
1880
  ]
1797
1881
  }
1798
1882
  );
1799
1883
  }
1800
- function Te({
1884
+ function Se({
1801
1885
  showHeader: e = !0,
1802
1886
  children: t,
1803
1887
  className: a
1804
1888
  } = {}) {
1805
- const { onClose: i } = ut();
1889
+ const { onClose: r } = mt();
1806
1890
  return E(() => {
1807
- const s = (o) => {
1808
- o.key === "Escape" && i && i();
1891
+ const s = (i) => {
1892
+ i.key === "Escape" && r && r();
1809
1893
  };
1810
1894
  return document.addEventListener("keydown", s), () => document.removeEventListener("keydown", s);
1811
- }, [i]), t ? /* @__PURE__ */ n(
1895
+ }, [r]), t ? /* @__PURE__ */ n(
1812
1896
  "div",
1813
1897
  {
1814
1898
  "data-slot": "conversation-view",
1815
- className: `${Tt.container}${a ? ` ${a}` : ""}`,
1899
+ className: `${Et.container}${a ? ` ${a}` : ""}`,
1816
1900
  children: t
1817
1901
  }
1818
- ) : /* @__PURE__ */ _(
1902
+ ) : /* @__PURE__ */ I(
1819
1903
  "div",
1820
1904
  {
1821
1905
  "data-slot": "conversation-view",
1822
- className: `${Tt.container}${e ? ` ${Tt.withHeader}` : ""}${a ? ` ${a}` : ""}`,
1906
+ className: `${Et.container}${e ? ` ${Et.withHeader}` : ""}${a ? ` ${a}` : ""}`,
1823
1907
  children: [
1824
- e && /* @__PURE__ */ n(ge, {}),
1825
- /* @__PURE__ */ n(ve, {}),
1826
- /* @__PURE__ */ n(Ie, {})
1908
+ e && /* @__PURE__ */ n(Le, {}),
1909
+ /* @__PURE__ */ n(ye, {}),
1910
+ /* @__PURE__ */ n(_e, {})
1827
1911
  ]
1828
1912
  }
1829
1913
  );
1830
1914
  }
1831
- const Un = {
1915
+ const Kn = {
1832
1916
  // Core container with state management
1833
- Container: Ce,
1917
+ Container: we,
1834
1918
  // Individual composable components
1835
- Header: ge,
1836
- Messages: ve,
1837
- Input: we,
1838
- Suggestions: Le,
1839
- Notice: ye,
1919
+ Header: Le,
1920
+ Messages: ye,
1921
+ Input: be,
1922
+ Suggestions: Ie,
1923
+ Notice: Te,
1840
1924
  // Convenience wrappers
1841
- Footer: Ie,
1842
- ConversationView: Te
1843
- }, zn = Object.assign(
1925
+ Footer: _e,
1926
+ ConversationView: Se
1927
+ }, no = Object.assign(
1844
1928
  (e) => /* @__PURE__ */ n(
1845
- Ce,
1929
+ we,
1846
1930
  {
1847
1931
  ...e,
1848
- className: V("agenttic", e.className),
1932
+ className: U("agenttic", e.className),
1849
1933
  children: /* @__PURE__ */ n(
1850
- Te,
1934
+ Se,
1851
1935
  {
1852
1936
  showHeader: e.variant === "floating"
1853
1937
  }
1854
1938
  )
1855
1939
  }
1856
1940
  ),
1857
- Un
1941
+ Kn
1858
1942
  );
1859
- function qn({ className: e, size: t = 24 }) {
1943
+ function oo({ className: e, size: t = 24 }) {
1860
1944
  return /* @__PURE__ */ n(
1861
1945
  "svg",
1862
1946
  {
@@ -1876,7 +1960,7 @@ function qn({ className: e, size: t = 24 }) {
1876
1960
  }
1877
1961
  );
1878
1962
  }
1879
- function Jn({ className: e, size: t = 24 }) {
1963
+ function ao({ className: e, size: t = 24 }) {
1880
1964
  return /* @__PURE__ */ n(
1881
1965
  "svg",
1882
1966
  {
@@ -1897,7 +1981,7 @@ function Jn({ className: e, size: t = 24 }) {
1897
1981
  }
1898
1982
  );
1899
1983
  }
1900
- function Qn({ className: e, size: t = 24 }) {
1984
+ function io({ className: e, size: t = 24 }) {
1901
1985
  return /* @__PURE__ */ n(
1902
1986
  "svg",
1903
1987
  {
@@ -1918,7 +2002,7 @@ function Qn({ className: e, size: t = 24 }) {
1918
2002
  }
1919
2003
  );
1920
2004
  }
1921
- function to({ className: e, size: t = 24 }) {
2005
+ function ro({ className: e, size: t = 24 }) {
1922
2006
  return /* @__PURE__ */ n(
1923
2007
  "svg",
1924
2008
  {
@@ -1941,7 +2025,7 @@ function to({ className: e, size: t = 24 }) {
1941
2025
  }
1942
2026
  );
1943
2027
  }
1944
- function eo({ className: e, size: t = 24 }) {
2028
+ function so({ className: e, size: t = 24 }) {
1945
2029
  return /* @__PURE__ */ n(
1946
2030
  "svg",
1947
2031
  {
@@ -1963,8 +2047,8 @@ function eo({ className: e, size: t = 24 }) {
1963
2047
  }
1964
2048
  );
1965
2049
  }
1966
- function no({ className: e, size: t = 24 }) {
1967
- return /* @__PURE__ */ _(
2050
+ function co({ className: e, size: t = 24 }) {
2051
+ return /* @__PURE__ */ I(
1968
2052
  "svg",
1969
2053
  {
1970
2054
  width: t,
@@ -1995,45 +2079,45 @@ function no({ className: e, size: t = 24 }) {
1995
2079
  );
1996
2080
  }
1997
2081
  export {
1998
- zn as AgentUI,
1999
- Ce as AgentUIContainer,
2000
- Te as AgentUIConversationView,
2001
- Ie as AgentUIFooter,
2002
- ge as AgentUIHeader,
2003
- we as AgentUIInput,
2004
- ve as AgentUIMessages,
2005
- ye as AgentUINotice,
2006
- zt as AgentUIProvider,
2007
- Le as AgentUISuggestions,
2008
- rn as AnimatedPlaceholder,
2009
- ze as ArrowUpIcon,
2010
- se as BigSkyIcon,
2011
- jn as Chat,
2012
- yn as ChatFooter,
2013
- fe as ChatHeader,
2014
- Kt as ChatInput,
2015
- nn as ChevronUpIcon,
2016
- ce as CollapsedView,
2017
- de as CompactView,
2018
- Qt as ConversationView,
2019
- Qn as CopyIcon,
2020
- Sn as Message,
2021
- Jt as MessageActions,
2022
- pe as Messages,
2023
- he as Notice,
2024
- qe as StopIcon,
2025
- to as StylesIcon,
2026
- Xt as Suggestions,
2027
- Mn as ThinkingMessage,
2028
- Jn as ThumbsDownIcon,
2029
- qn as ThumbsUpIcon,
2030
- me as XIcon,
2031
- eo as ZoomIcon,
2032
- no as ZoomIconFilled,
2033
- Xn as animations,
2034
- V as cn,
2035
- zn as default,
2036
- ut as useAgentUIContext,
2037
- oe as useChat,
2038
- ae as useInput
2082
+ no as AgentUI,
2083
+ we as AgentUIContainer,
2084
+ Se as AgentUIConversationView,
2085
+ _e as AgentUIFooter,
2086
+ Le as AgentUIHeader,
2087
+ be as AgentUIInput,
2088
+ ye as AgentUIMessages,
2089
+ Te as AgentUINotice,
2090
+ Qt as AgentUIProvider,
2091
+ Ie as AgentUISuggestions,
2092
+ dn as AnimatedPlaceholder,
2093
+ en as ArrowUpIcon,
2094
+ ue as BigSkyIcon,
2095
+ eo as Chat,
2096
+ _n as ChatFooter,
2097
+ Ce as ChatHeader,
2098
+ Xt as ChatInput,
2099
+ cn as ChevronUpIcon,
2100
+ de as CollapsedView,
2101
+ he as CompactView,
2102
+ ne as ConversationView,
2103
+ io as CopyIcon,
2104
+ Nn as Message,
2105
+ ee as MessageActions,
2106
+ ve as Messages,
2107
+ ge as Notice,
2108
+ nn as StopIcon,
2109
+ ro as StylesIcon,
2110
+ jt as Suggestions,
2111
+ Fn as ThinkingMessage,
2112
+ ao as ThumbsDownIcon,
2113
+ oo as ThumbsUpIcon,
2114
+ pe as XIcon,
2115
+ so as ZoomIcon,
2116
+ co as ZoomIconFilled,
2117
+ to as animations,
2118
+ U as cn,
2119
+ no as default,
2120
+ mt as useAgentUIContext,
2121
+ re as useChat,
2122
+ se as useInput
2039
2123
  };