@object-ui/plugin-chatbot 4.0.7 → 4.0.9

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/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # @object-ui/plugin-chatbot
2
2
 
3
+ ## 4.0.9
4
+
5
+ ### Patch Changes
6
+
7
+ - @object-ui/types@4.0.9
8
+ - @object-ui/core@4.0.9
9
+ - @object-ui/react@4.0.9
10
+ - @object-ui/components@4.0.9
11
+
12
+ ## 4.0.8
13
+
14
+ ### Patch Changes
15
+
16
+ - @object-ui/components@4.0.8
17
+ - @object-ui/react@4.0.8
18
+ - @object-ui/types@4.0.8
19
+ - @object-ui/core@4.0.8
20
+
3
21
  ## 4.0.7
4
22
 
5
23
  ### Patch Changes
package/dist/index.js CHANGED
@@ -6,18 +6,19 @@ import { Fragment as C, jsx as w, jsxs as T } from "react/jsx-runtime";
6
6
  import { useChat as E } from "@ai-sdk/react";
7
7
  import { DefaultChatTransport as D } from "ai";
8
8
  import * as O from "react-dom";
9
- import k from "react-markdown";
10
- import { Prism as A } from "react-syntax-highlighter";
11
- import { oneDark as j } from "react-syntax-highlighter/dist/esm/styles/prism";
12
- import M from "remark-gfm";
13
- import { ComponentRegistry as N } from "@object-ui/core";
9
+ import { useObjectTranslation as k } from "@object-ui/react";
10
+ import A from "react-markdown";
11
+ import { Prism as j } from "react-syntax-highlighter";
12
+ import { oneDark as M } from "react-syntax-highlighter/dist/esm/styles/prism";
13
+ import N from "remark-gfm";
14
+ import { ComponentRegistry as P } from "@object-ui/core";
14
15
  //#region src/utils.ts
15
- function P(e = "msg") {
16
+ function F(e = "msg") {
16
17
  return typeof crypto < "u" && crypto.randomUUID ? crypto.randomUUID() : `${e}-${Date.now()}-${Math.random().toString(36).slice(2)}`;
17
18
  }
18
19
  //#endregion
19
20
  //#region src/useObjectChat.ts
20
- function F(e) {
21
+ function I(e) {
21
22
  return (e ?? []).map((e, t) => ({
22
23
  id: e.id || `msg-${t}`,
23
24
  role: e.role || "user",
@@ -28,8 +29,8 @@ function F(e) {
28
29
  toolInvocations: e.toolInvocations
29
30
  }));
30
31
  }
31
- function I(e = {}) {
32
- let { api: o, initialMessages: s, conversationId: c, systemPrompt: l, model: u, streamingEnabled: d = !0, headers: f, body: p, maxToolRoundtrips: m = 5, onError: h, showTimestamp: g, autoResponse: _, autoResponseText: v, autoResponseDelay: y = 1e3, onSend: b } = e, x = i(o ? "api" : "local").current === "api", S = r(() => F(s).map((e) => ({
32
+ function L(e = {}) {
33
+ let { api: o, initialMessages: s, conversationId: c, systemPrompt: l, model: u, streamingEnabled: d = !0, headers: f, body: p, maxToolRoundtrips: m = 5, onError: h, showTimestamp: g, autoResponse: _, autoResponseText: v, autoResponseDelay: y = 1e3, onSend: b } = e, x = i(o ? "api" : "local").current === "api", S = r(() => I(s).map((e) => ({
33
34
  id: e.id,
34
35
  role: e.role,
35
36
  parts: [{
@@ -63,9 +64,9 @@ function I(e = {}) {
63
64
  onError: x ? (e) => {
64
65
  h?.(e);
65
66
  } : void 0
66
- }), [w, T] = a(() => F(s)), [O, k] = a(!1), [A, j] = a(""), [M, N] = a(""), I = i(null);
67
+ }), [w, T] = a(() => I(s)), [O, k] = a(!1), [A, j] = a(""), [M, N] = a(""), P = i(null);
67
68
  if (n(() => () => {
68
- I.current &&= (clearTimeout(I.current), null);
69
+ P.current &&= (clearTimeout(P.current), null);
69
70
  }, []), x) {
70
71
  let { messages: e, status: n, error: r, sendMessage: i, regenerate: a, stop: o, setMessages: s } = C, c = n === "submitted" || n === "streaming", l = e.map((t) => {
71
72
  let n = typeof t.content == "string" ? t.content : Array.isArray(t.parts) ? t.parts.filter((e) => e?.type === "text").map((e) => e.text ?? "").join("") : "";
@@ -85,7 +86,7 @@ function I(e = {}) {
85
86
  let t = e.trim();
86
87
  if (!t) return;
87
88
  let n = [...l, {
88
- id: P("msg"),
89
+ id: F("msg"),
89
90
  role: "user",
90
91
  content: t
91
92
  }];
@@ -109,7 +110,7 @@ function I(e = {}) {
109
110
  };
110
111
  }
111
112
  let L = t(() => {
112
- I.current &&= (clearTimeout(I.current), null), k(!1);
113
+ P.current &&= (clearTimeout(P.current), null), k(!1);
113
114
  }, []);
114
115
  return {
115
116
  messages: w,
@@ -118,7 +119,7 @@ function I(e = {}) {
118
119
  sendMessage: t((e) => {
119
120
  if (!e.trim()) return;
120
121
  let t = {
121
- id: P("msg"),
122
+ id: F("msg"),
122
123
  role: "user",
123
124
  content: e.trim(),
124
125
  timestamp: g ? (/* @__PURE__ */ new Date()).toLocaleTimeString() : void 0
@@ -126,9 +127,9 @@ function I(e = {}) {
126
127
  T((n) => {
127
128
  let r = [...n, t];
128
129
  return b?.(e.trim(), r), r;
129
- }), j(""), _ && (k(!0), I.current = setTimeout(() => {
130
+ }), j(""), _ && (k(!0), P.current = setTimeout(() => {
130
131
  let e = {
131
- id: P("msg"),
132
+ id: F("msg"),
132
133
  role: "assistant",
133
134
  content: v || "Thank you for your message!",
134
135
  timestamp: g ? (/* @__PURE__ */ new Date()).toLocaleTimeString() : void 0
@@ -157,7 +158,7 @@ function I(e = {}) {
157
158
  }
158
159
  //#endregion
159
160
  //#region src/useAgents.ts
160
- function L(e) {
161
+ function R(e) {
161
162
  return e.filter((e) => typeof e?.name == "string" && e.name.length > 0).map((e) => ({
162
163
  name: e.name,
163
164
  label: e.label || e.name,
@@ -166,7 +167,7 @@ function L(e) {
166
167
  active: e.active !== !1
167
168
  }));
168
169
  }
169
- function R(e = {}) {
170
+ function z(e = {}) {
170
171
  let { apiBase: r, headers: o, enabled: s = !0, fallback: c = [] } = e, [l, u] = a(c), [d, f] = a(!1), [p, m] = a(void 0), [h, g] = a(0), _ = i(o);
171
172
  return _.current = o, n(() => {
172
173
  if (!s || !r) return;
@@ -186,7 +187,7 @@ function R(e = {}) {
186
187
  return e.json();
187
188
  }).then((e) => {
188
189
  if (t) return;
189
- let n = L(Array.isArray(e) ? e : e?.agents ?? []);
190
+ let n = R(Array.isArray(e) ? e : e?.agents ?? []);
190
191
  u(n.length > 0 ? n : c);
191
192
  }).catch((e) => {
192
193
  t || e.name === "AbortError" || (m(e), u(c));
@@ -208,8 +209,8 @@ function R(e = {}) {
208
209
  }
209
210
  //#endregion
210
211
  //#region src/FloatingChatbotProvider.tsx
211
- var z = e.createContext(null);
212
- function B({ defaultOpen: t = !1, children: n }) {
212
+ var B = e.createContext(null);
213
+ function V({ defaultOpen: t = !1, children: n }) {
213
214
  let [r, i] = e.useState(t), [a, o] = e.useState(!1), s = e.useMemo(() => ({
214
215
  isOpen: r,
215
216
  isFullscreen: a,
@@ -220,20 +221,31 @@ function B({ defaultOpen: t = !1, children: n }) {
220
221
  toggle: () => i((e) => !e),
221
222
  toggleFullscreen: () => o((e) => !e)
222
223
  }), [r, a]);
223
- return /* @__PURE__ */ w(z.Provider, {
224
+ return /* @__PURE__ */ w(B.Provider, {
224
225
  value: s,
225
226
  children: n
226
227
  });
227
228
  }
228
- function V() {
229
- let t = e.useContext(z);
229
+ function H() {
230
+ let t = e.useContext(B);
230
231
  if (!t) throw Error("useFloatingChatbot must be used within a <FloatingChatbotProvider>");
231
232
  return t;
232
233
  }
233
234
  //#endregion
234
235
  //#region src/FloatingChatbotTrigger.tsx
235
- function H({ position: e = "bottom-right", size: t = 56, className: n }) {
236
- let { isOpen: r, toggle: i } = V();
236
+ function U() {
237
+ try {
238
+ let { t: e } = k();
239
+ return (t, n) => {
240
+ let r = e(`common.${t}`);
241
+ return !r || r === `common.${t}` ? n : r;
242
+ };
243
+ } catch {
244
+ return (e, t) => t;
245
+ }
246
+ }
247
+ function W({ position: e = "bottom-right", size: t = 56, className: n }) {
248
+ let { isOpen: r, toggle: i } = H(), a = U();
237
249
  return /* @__PURE__ */ w(l, {
238
250
  onClick: i,
239
251
  className: f("fixed z-50 rounded-full shadow-lg transition-transform hover:scale-105", e === "bottom-right" ? "right-6 bottom-6" : "left-6 bottom-6", n),
@@ -242,15 +254,15 @@ function H({ position: e = "bottom-right", size: t = 56, className: n }) {
242
254
  height: t
243
255
  },
244
256
  size: "icon",
245
- "aria-label": r ? "Close chat" : "Open chat",
257
+ "aria-label": r ? a("closeChat", "Close chat") : a("openChat", "Open chat"),
246
258
  "data-testid": "floating-chatbot-trigger",
247
259
  children: w(r ? S : h, { className: "h-6 w-6" })
248
260
  });
249
261
  }
250
262
  //#endregion
251
263
  //#region src/FloatingChatbotPanel.tsx
252
- function U({ title: e = "Chat", position: t = "bottom-right", width: n = 400, height: r = 520, children: i, className: a, headerExtra: o }) {
253
- let { isOpen: s, isFullscreen: c, close: u, toggleFullscreen: d } = V();
264
+ function G({ title: e = "Chat", position: t = "bottom-right", width: n = 400, height: r = 520, children: i, className: a, headerExtra: o }) {
265
+ let { isOpen: s, isFullscreen: c, close: u, toggleFullscreen: d } = H();
254
266
  if (!s) return null;
255
267
  let p = c ? {
256
268
  inset: 0,
@@ -308,16 +320,16 @@ function U({ title: e = "Chat", position: t = "bottom-right", width: n = 400, he
308
320
  }
309
321
  //#endregion
310
322
  //#region src/ChatbotEnhanced.tsx
311
- function W({ content: e, enableMarkdown: t }) {
323
+ function K({ content: e, enableMarkdown: t }) {
312
324
  return t ? /* @__PURE__ */ w("div", {
313
325
  className: "prose prose-sm dark:prose-invert max-w-none",
314
- children: /* @__PURE__ */ w(k, {
315
- remarkPlugins: [M],
326
+ children: /* @__PURE__ */ w(A, {
327
+ remarkPlugins: [N],
316
328
  components: {
317
329
  code({ node: e, inline: t, className: n, children: r, ...i }) {
318
330
  let a = /language-(\w+)/.exec(n || "");
319
- return !t && a ? /* @__PURE__ */ w(A, {
320
- style: j,
331
+ return !t && a ? /* @__PURE__ */ w(j, {
332
+ style: M,
321
333
  language: a[1],
322
334
  PreTag: "div",
323
335
  className: "rounded-md my-2",
@@ -379,16 +391,16 @@ function W({ content: e, enableMarkdown: t }) {
379
391
  children: e
380
392
  });
381
393
  }
382
- var G = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type your message...", onSendMessage: i, onClear: a, onStop: m, onReload: h, disabled: g = !1, isLoading: E = !1, error: D, showTimestamp: O = !1, userAvatarUrl: k, userAvatarFallback: A = "You", assistantAvatarUrl: j, assistantAvatarFallback: M = "AI", maxHeight: N = "500px", enableMarkdown: P = !0, enableFileUpload: F = !1, acceptedFileTypes: I = "image/*,.pdf,.doc,.docx,.txt", maxFileSize: L = 10 * 1024 * 1024, ...R }, z) => {
383
- let [B, V] = e.useState(""), [H, U] = e.useState([]), G = e.useRef(null), K = e.useRef(null), q = e.useRef(null);
394
+ var q = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type your message...", onSendMessage: i, onClear: a, onStop: m, onReload: h, disabled: g = !1, isLoading: E = !1, error: D, showTimestamp: O = !1, userAvatarUrl: k, userAvatarFallback: A = "You", assistantAvatarUrl: j, assistantAvatarFallback: M = "AI", maxHeight: N = "500px", enableMarkdown: P = !0, enableFileUpload: F = !1, acceptedFileTypes: I = "image/*,.pdf,.doc,.docx,.txt", maxFileSize: L = 10 * 1024 * 1024, ...R }, z) => {
395
+ let [B, V] = e.useState(""), [H, U] = e.useState([]), W = e.useRef(null), G = e.useRef(null), q = e.useRef(null);
384
396
  e.useEffect(() => {
385
- if (G.current) {
386
- let e = G.current.querySelector("[data-radix-scroll-area-viewport]");
397
+ if (W.current) {
398
+ let e = W.current.querySelector("[data-radix-scroll-area-viewport]");
387
399
  e && (e.scrollTop = e.scrollHeight);
388
400
  }
389
401
  }, [n]);
390
402
  let J = () => {
391
- (B.trim() || H.length > 0) && i && (i(B.trim(), H), V(""), U([]), K.current?.focus());
403
+ (B.trim() || H.length > 0) && i && (i(B.trim(), H), V(""), U([]), G.current?.focus());
392
404
  }, Y = g || E, X = Y || !B.trim() && H.length === 0, Z = (e) => {
393
405
  e.key === "Enter" && !e.shiftKey && (e.preventDefault(), J());
394
406
  }, Q = (e) => {
@@ -430,7 +442,7 @@ var G = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type y
430
442
  })]
431
443
  }),
432
444
  /* @__PURE__ */ w(d, {
433
- ref: G,
445
+ ref: W,
434
446
  className: "flex-1 p-4",
435
447
  children: /* @__PURE__ */ w("div", {
436
448
  className: "space-y-4",
@@ -447,7 +459,7 @@ var G = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type y
447
459
  /* @__PURE__ */ T("div", {
448
460
  className: f("rounded-lg px-4 py-2 max-w-[80%]", e.role === "user" ? "bg-primary text-primary-foreground" : "bg-muted"),
449
461
  children: [
450
- /* @__PURE__ */ w(W, {
462
+ /* @__PURE__ */ w(K, {
451
463
  content: e.content,
452
464
  enableMarkdown: P
453
465
  }),
@@ -554,7 +566,7 @@ var G = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type y
554
566
  children: /* @__PURE__ */ w(_, { className: "h-4 w-4" })
555
567
  })] }),
556
568
  /* @__PURE__ */ w(u, {
557
- ref: K,
569
+ ref: G,
558
570
  value: B,
559
571
  onChange: (e) => V(e.target.value),
560
572
  onKeyDown: Z,
@@ -574,10 +586,10 @@ var G = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type y
574
586
  ]
575
587
  });
576
588
  });
577
- G.displayName = "ChatbotEnhanced";
589
+ q.displayName = "ChatbotEnhanced";
578
590
  //#endregion
579
591
  //#region src/FloatingChatbot.tsx
580
- function K({ floatingConfig: t, headerExtra: n, ...r }) {
592
+ function J({ floatingConfig: t, headerExtra: n, ...r }) {
581
593
  let { position: i = "bottom-right", defaultOpen: a = !1, panelWidth: o = 400, panelHeight: s = 520, title: c = "Chat", triggerSize: l = 56 } = t ?? {}, [u, d] = e.useState(null);
582
594
  e.useEffect(() => {
583
595
  let e = document.getElementById("floating-chatbot-portal");
@@ -585,18 +597,18 @@ function K({ floatingConfig: t, headerExtra: n, ...r }) {
585
597
  e && e.parentNode && !e.hasChildNodes() && e.parentNode.removeChild(e);
586
598
  };
587
599
  }, []);
588
- let f = /* @__PURE__ */ T(B, {
600
+ let f = /* @__PURE__ */ T(V, {
589
601
  defaultOpen: a,
590
- children: [/* @__PURE__ */ w(H, {
602
+ children: [/* @__PURE__ */ w(W, {
591
603
  position: i,
592
604
  size: l
593
- }), /* @__PURE__ */ w(U, {
605
+ }), /* @__PURE__ */ w(G, {
594
606
  title: c,
595
607
  position: i,
596
608
  width: o,
597
609
  height: s,
598
610
  headerExtra: n,
599
- children: /* @__PURE__ */ w(G, {
611
+ children: /* @__PURE__ */ w(q, {
600
612
  ...r,
601
613
  maxHeight: "100%",
602
614
  className: "h-full border-0 rounded-none"
@@ -605,8 +617,8 @@ function K({ floatingConfig: t, headerExtra: n, ...r }) {
605
617
  });
606
618
  return u ? O.createPortal(f, u) : f;
607
619
  }
608
- N.register("chatbot", ({ schema: e, className: t, ...n }) => {
609
- let { messages: r, isLoading: i, sendMessage: a } = I({
620
+ P.register("chatbot", ({ schema: e, className: t, ...n }) => {
621
+ let { messages: r, isLoading: i, sendMessage: a } = L({
610
622
  api: e.api,
611
623
  initialMessages: e.messages,
612
624
  conversationId: e.conversationId,
@@ -623,7 +635,7 @@ N.register("chatbot", ({ schema: e, className: t, ...n }) => {
623
635
  autoResponseDelay: e.autoResponseDelay,
624
636
  onSend: e.onSend
625
637
  });
626
- return /* @__PURE__ */ w(q, {
638
+ return /* @__PURE__ */ w(Y, {
627
639
  messages: r,
628
640
  placeholder: e.placeholder,
629
641
  onSendMessage: (e) => {
@@ -771,8 +783,8 @@ N.register("chatbot", ({ schema: e, className: t, ...n }) => {
771
783
  autoResponseDelay: 1e3,
772
784
  className: "w-full max-w-2xl"
773
785
  }
774
- }), N.register("chatbot-enhanced", ({ schema: e, className: t, ...n }) => {
775
- let { messages: r, isLoading: i, error: a, sendMessage: o, stop: s, reload: c, clear: l, isApiMode: u } = I({
786
+ }), P.register("chatbot-enhanced", ({ schema: e, className: t, ...n }) => {
787
+ let { messages: r, isLoading: i, error: a, sendMessage: o, stop: s, reload: c, clear: l, isApiMode: u } = L({
776
788
  api: e.api,
777
789
  initialMessages: e.messages,
778
790
  conversationId: e.conversationId,
@@ -789,7 +801,7 @@ N.register("chatbot", ({ schema: e, className: t, ...n }) => {
789
801
  autoResponseDelay: e.autoResponseDelay,
790
802
  onSend: e.onSend
791
803
  });
792
- return /* @__PURE__ */ w(G, {
804
+ return /* @__PURE__ */ w(q, {
793
805
  messages: r,
794
806
  placeholder: e.placeholder,
795
807
  onSendMessage: (e, t) => {
@@ -951,8 +963,8 @@ N.register("chatbot", ({ schema: e, className: t, ...n }) => {
951
963
  autoResponseDelay: 1e3,
952
964
  className: "w-full max-w-2xl"
953
965
  }
954
- }), N.register("chatbot-floating", ({ schema: e, className: t, ...n }) => {
955
- let { messages: r, isLoading: i, error: a, sendMessage: o, stop: s, reload: c, clear: l, isApiMode: u } = I({
966
+ }), P.register("chatbot-floating", ({ schema: e, className: t, ...n }) => {
967
+ let { messages: r, isLoading: i, error: a, sendMessage: o, stop: s, reload: c, clear: l, isApiMode: u } = L({
956
968
  api: e.api,
957
969
  initialMessages: e.messages,
958
970
  conversationId: e.conversationId,
@@ -969,7 +981,7 @@ N.register("chatbot", ({ schema: e, className: t, ...n }) => {
969
981
  autoResponseDelay: e.autoResponseDelay,
970
982
  onSend: e.onSend
971
983
  });
972
- return /* @__PURE__ */ w(K, {
984
+ return /* @__PURE__ */ w(J, {
973
985
  floatingConfig: e.floatingConfig,
974
986
  messages: r,
975
987
  placeholder: e.placeholder,
@@ -1141,7 +1153,7 @@ N.register("chatbot", ({ schema: e, className: t, ...n }) => {
1141
1153
  });
1142
1154
  //#endregion
1143
1155
  //#region src/index.tsx
1144
- var q = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type your message...", onSendMessage: i, disabled: a = !1, showTimestamp: o = !1, userAvatarUrl: s, userAvatarFallback: c = "You", assistantAvatarUrl: p, assistantAvatarFallback: m = "AI", maxHeight: h = "500px", ...g }, _) => {
1156
+ var Y = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type your message...", onSendMessage: i, disabled: a = !1, showTimestamp: o = !1, userAvatarUrl: s, userAvatarFallback: c = "You", assistantAvatarUrl: p, assistantAvatarFallback: m = "AI", maxHeight: h = "500px", ...g }, _) => {
1145
1157
  let [v, b] = e.useState(""), x = e.useRef(null), S = e.useRef(null);
1146
1158
  e.useEffect(() => {
1147
1159
  if (x.current) {
@@ -1167,7 +1179,7 @@ var q = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type y
1167
1179
  children: n.length === 0 ? /* @__PURE__ */ w("div", {
1168
1180
  className: "flex items-center justify-center h-32 text-muted-foreground text-sm",
1169
1181
  children: "No messages yet. Start a conversation!"
1170
- }) : n.map((e) => /* @__PURE__ */ w(J, {
1182
+ }) : n.map((e) => /* @__PURE__ */ w(X, {
1171
1183
  message: e,
1172
1184
  showTimestamp: o,
1173
1185
  userAvatarUrl: s,
@@ -1198,8 +1210,8 @@ var q = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type y
1198
1210
  })]
1199
1211
  });
1200
1212
  });
1201
- q.displayName = "Chatbot";
1202
- var J = ({ message: e, showTimestamp: t, userAvatarUrl: n, userAvatarFallback: r, assistantAvatarUrl: i, assistantAvatarFallback: a }) => {
1213
+ Y.displayName = "Chatbot";
1214
+ var X = ({ message: e, showTimestamp: t, userAvatarUrl: n, userAvatarFallback: r, assistantAvatarUrl: i, assistantAvatarFallback: a }) => {
1203
1215
  let l = e.role === "user";
1204
1216
  if (e.role === "system") return /* @__PURE__ */ w("div", {
1205
1217
  className: "flex justify-center",
@@ -1231,7 +1243,7 @@ var J = ({ message: e, showTimestamp: t, userAvatarUrl: n, userAvatarFallback: r
1231
1243
  })]
1232
1244
  })]
1233
1245
  });
1234
- }, Y = e.forwardRef(({ className: e, avatarSrc: t, avatarFallback: n = "AI", ...r }, i) => /* @__PURE__ */ T("div", {
1246
+ }, Z = e.forwardRef(({ className: e, avatarSrc: t, avatarFallback: n = "AI", ...r }, i) => /* @__PURE__ */ T("div", {
1235
1247
  ref: i,
1236
1248
  className: f("flex gap-3", e),
1237
1249
  ...r,
@@ -1253,6 +1265,6 @@ var J = ({ message: e, showTimestamp: t, userAvatarUrl: n, userAvatarFallback: r
1253
1265
  })
1254
1266
  })]
1255
1267
  }));
1256
- Y.displayName = "TypingIndicator";
1268
+ Z.displayName = "TypingIndicator";
1257
1269
  //#endregion
1258
- export { q as Chatbot, K as FloatingChatbot, U as FloatingChatbotPanel, B as FloatingChatbotProvider, H as FloatingChatbotTrigger, Y as TypingIndicator, R as useAgents, V as useFloatingChatbot, I as useObjectChat };
1270
+ export { Y as Chatbot, J as FloatingChatbot, G as FloatingChatbotPanel, V as FloatingChatbotProvider, W as FloatingChatbotTrigger, Z as TypingIndicator, z as useAgents, H as useFloatingChatbot, L as useObjectChat };
@@ -1 +1 @@
1
- (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require(`react`),require(`@object-ui/components`),require(`lucide-react`),require(`react/jsx-runtime`),require(`@ai-sdk/react`),require(`ai`),require(`react-dom`),require(`react-markdown`),require(`react-syntax-highlighter`),require(`react-syntax-highlighter/dist/esm/styles/prism`),require(`remark-gfm`),require(`@object-ui/core`)):typeof define==`function`&&define.amd?define([`exports`,`react`,`@object-ui/components`,`lucide-react`,`react/jsx-runtime`,`@ai-sdk/react`,`ai`,`react-dom`,`react-markdown`,`react-syntax-highlighter`,`react-syntax-highlighter/dist/esm/styles/prism`,`remark-gfm`,`@object-ui/core`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.ObjectUIPluginChatbot={},e.React,e.ObjectUIComponents,e.LucideReact,e.react_jsx_runtime,e._ai_sdk_react,e.ai,e.ReactDOM,e.react_markdown,e.react_syntax_highlighter,e.react_syntax_highlighter_dist_esm_styles_prism,e.remark_gfm,e.ObjectUICore))})(this,function(e,t,n,r,i,a,o,s,c,l,u,d,f){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var p=Object.create,m=Object.defineProperty,h=Object.getOwnPropertyDescriptor,g=Object.getOwnPropertyNames,_=Object.getPrototypeOf,v=Object.prototype.hasOwnProperty,y=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=g(t),a=0,o=i.length,s;a<o;a++)s=i[a],!v.call(e,s)&&s!==n&&m(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=h(t,s))||r.enumerable});return e},b=(e,t,n)=>(n=e==null?{}:p(_(e)),y(t||!e||!e.__esModule?m(n,`default`,{value:e,enumerable:!0}):n,e));t=b(t,1),s=b(s,1),c=b(c,1),d=b(d,1);function x(e=`msg`){return typeof crypto<`u`&&crypto.randomUUID?crypto.randomUUID():`${e}-${Date.now()}-${Math.random().toString(36).slice(2)}`}function S(e){return(e??[]).map((e,t)=>({id:e.id||`msg-${t}`,role:e.role||`user`,content:e.content||``,timestamp:typeof e.timestamp==`string`?e.timestamp:e.timestamp instanceof Date?e.timestamp.toISOString():void 0,metadata:e.metadata,streaming:e.streaming,toolInvocations:e.toolInvocations}))}function C(e={}){let{api:n,initialMessages:r,conversationId:i,systemPrompt:s,model:c,streamingEnabled:l=!0,headers:u,body:d,maxToolRoundtrips:f=5,onError:p,showTimestamp:m,autoResponse:h,autoResponseText:g,autoResponseDelay:_=1e3,onSend:v}=e,y=(0,t.useRef)(n?`api`:`local`).current===`api`,b=(0,t.useMemo)(()=>S(r).map(e=>({id:e.id,role:e.role,parts:[{type:`text`,text:e.content??``}]})),[]),C=(0,a.useChat)({transport:(0,t.useMemo)(()=>{if(y)return new o.DefaultChatTransport({api:n,headers:{...u},body:{...d,...i?{conversationId:i}:{},...c?{model:c}:{},...s?{systemPrompt:s}:{},...l===void 0?{}:{stream:l}}})},[y,n,u,d,c,s,l,i]),messages:y&&b.length>0?b:void 0,onError:y?e=>{p?.(e)}:void 0}),[w,T]=(0,t.useState)(()=>S(r)),[E,D]=(0,t.useState)(!1),[O,k]=(0,t.useState)(``),[A,j]=(0,t.useState)(``),M=(0,t.useRef)(null);if((0,t.useEffect)(()=>()=>{M.current&&=(clearTimeout(M.current),null)},[]),y){let{messages:e,status:n,error:r,sendMessage:i,regenerate:a,stop:o,setMessages:s}=C,c=n===`submitted`||n===`streaming`,l=e.map(t=>{let n=typeof t.content==`string`?t.content:Array.isArray(t.parts)?t.parts.filter(e=>e?.type===`text`).map(e=>e.text??``).join(``):``;return{id:t.id,role:t.role,content:n,toolInvocations:t.toolInvocations,streaming:c&&t.id===e[e.length-1]?.id&&t.role===`assistant`}});return{messages:l,isLoading:c,error:r,sendMessage:(0,t.useCallback)(e=>{let t=e.trim();if(!t)return;let n=[...l,{id:x(`msg`),role:`user`,content:t}];i({text:t}),j(``),v?.(t,n)},[i,v,l]),stop:o,reload:a,clear:(0,t.useCallback)(()=>{s([])},[s]),isApiMode:!0,input:A,setInput:j,handleInputChange:(0,t.useCallback)(e=>{j(e.target.value)},[])}}let N=(0,t.useCallback)(()=>{M.current&&=(clearTimeout(M.current),null),D(!1)},[]);return{messages:w,isLoading:E,error:void 0,sendMessage:(0,t.useCallback)(e=>{if(!e.trim())return;let t={id:x(`msg`),role:`user`,content:e.trim(),timestamp:m?new Date().toLocaleTimeString():void 0};T(n=>{let r=[...n,t];return v?.(e.trim(),r),r}),k(``),h&&(D(!0),M.current=setTimeout(()=>{let e={id:x(`msg`),role:`assistant`,content:g||`Thank you for your message!`,timestamp:m?new Date().toLocaleTimeString():void 0};T(t=>[...t,e]),D(!1)},_))},[m,h,g,_,v]),stop:N,reload:(0,t.useCallback)(()=>{},[]),clear:(0,t.useCallback)(()=>{N(),T([])},[N]),isApiMode:!1,input:O,setInput:k,handleInputChange:(0,t.useCallback)(e=>{k(e.target.value)},[])}}function w(e){return e.filter(e=>typeof e?.name==`string`&&e.name.length>0).map(e=>({name:e.name,label:e.label||e.name,description:e.description,role:e.role,active:e.active!==!1}))}function T(e={}){let{apiBase:n,headers:r,enabled:i=!0,fallback:a=[]}=e,[o,s]=(0,t.useState)(a),[c,l]=(0,t.useState)(!1),[u,d]=(0,t.useState)(void 0),[f,p]=(0,t.useState)(0),m=(0,t.useRef)(r);return m.current=r,(0,t.useEffect)(()=>{if(!i||!n)return;let e=new AbortController,t=!1;l(!0),d(void 0);let r=`${n.replace(/\/$/,``)}/agents`;return fetch(r,{method:`GET`,headers:{Accept:`application/json`,...m.current??{}},credentials:`include`,signal:e.signal}).then(async e=>{if(!e.ok)throw Error(`Failed to load agents (${e.status})`);return e.json()}).then(e=>{if(t)return;let n=w(Array.isArray(e)?e:e?.agents??[]);s(n.length>0?n:a)}).catch(e=>{t||e.name===`AbortError`||(d(e),s(a))}).finally(()=>{t||l(!1)}),()=>{t=!0,e.abort()}},[n,i,f]),{agents:o,isLoading:c,error:u,refetch:(0,t.useCallback)(()=>p(e=>e+1),[])}}var E=t.createContext(null);function D({defaultOpen:e=!1,children:n}){let[r,a]=t.useState(e),[o,s]=t.useState(!1),c=t.useMemo(()=>({isOpen:r,isFullscreen:o,open:()=>a(!0),close:()=>{a(!1),s(!1)},toggle:()=>a(e=>!e),toggleFullscreen:()=>s(e=>!e)}),[r,o]);return(0,i.jsx)(E.Provider,{value:c,children:n})}function O(){let e=t.useContext(E);if(!e)throw Error(`useFloatingChatbot must be used within a <FloatingChatbotProvider>`);return e}function k({position:e=`bottom-right`,size:t=56,className:a}){let{isOpen:o,toggle:s}=O();return(0,i.jsx)(n.Button,{onClick:s,className:(0,n.cn)(`fixed z-50 rounded-full shadow-lg transition-transform hover:scale-105`,e===`bottom-right`?`right-6 bottom-6`:`left-6 bottom-6`,a),style:{width:t,height:t},size:`icon`,"aria-label":o?`Close chat`:`Open chat`,"data-testid":`floating-chatbot-trigger`,children:o?(0,i.jsx)(r.X,{className:`h-6 w-6`}):(0,i.jsx)(r.MessageCircle,{className:`h-6 w-6`})})}function A({title:e=`Chat`,position:t=`bottom-right`,width:a=400,height:o=520,children:s,className:c,headerExtra:l}){let{isOpen:u,isFullscreen:d,close:f,toggleFullscreen:p}=O();if(!u)return null;let m=d?{inset:0,width:`100vw`,height:`100vh`}:{width:a,height:o,maxHeight:`calc(100vh - 100px)`};return(0,i.jsxs)(`div`,{className:(0,n.cn)(`fixed z-50 flex flex-col rounded-lg border bg-background shadow-xl overflow-hidden transition-all`,d?`inset-0 rounded-none`:t===`bottom-right`?`right-6 bottom-20`:`left-6 bottom-20`,c),style:m,role:`dialog`,"aria-label":e,"data-testid":`floating-chatbot-panel`,children:[(0,i.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-4 py-2 border-b bg-muted/40`,children:[(0,i.jsx)(`span`,{className:`text-sm font-medium truncate shrink-0`,children:e}),l?(0,i.jsx)(`div`,{className:`flex-1 min-w-0 flex items-center justify-end mr-1`,"data-testid":`floating-chatbot-header-extra`,children:l}):null,(0,i.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[(0,i.jsx)(n.Button,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:p,"aria-label":d?`Exit fullscreen`:`Fullscreen`,"data-testid":`floating-chatbot-fullscreen`,children:d?(0,i.jsx)(r.Minimize2,{className:`h-4 w-4`}):(0,i.jsx)(r.Maximize2,{className:`h-4 w-4`})}),(0,i.jsx)(n.Button,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:f,"aria-label":`Close chat`,"data-testid":`floating-chatbot-close`,children:(0,i.jsx)(r.X,{className:`h-4 w-4`})})]})]}),(0,i.jsx)(`div`,{className:`flex-1 overflow-hidden`,children:s})]})}function j({content:e,enableMarkdown:t}){return t?(0,i.jsx)(`div`,{className:`prose prose-sm dark:prose-invert max-w-none`,children:(0,i.jsx)(c.default,{remarkPlugins:[d.default],components:{code({node:e,inline:t,className:r,children:a,...o}){let s=/language-(\w+)/.exec(r||``);return!t&&s?(0,i.jsx)(l.Prism,{style:u.oneDark,language:s[1],PreTag:`div`,className:`rounded-md my-2`,...o,children:String(a).replace(/\n$/,``)}):(0,i.jsx)(`code`,{className:(0,n.cn)(`bg-muted px-1 py-0.5 rounded text-sm`,r),...o,children:a})},p:({children:e})=>(0,i.jsx)(`p`,{className:`mb-2 last:mb-0`,children:e}),ul:({children:e})=>(0,i.jsx)(`ul`,{className:`list-disc pl-4 mb-2`,children:e}),ol:({children:e})=>(0,i.jsx)(`ol`,{className:`list-decimal pl-4 mb-2`,children:e}),li:({children:e})=>(0,i.jsx)(`li`,{className:`mb-1`,children:e}),a:({href:e,children:t})=>(0,i.jsx)(`a`,{href:e,className:`text-primary hover:underline`,target:`_blank`,rel:`noopener noreferrer`,children:t}),blockquote:({children:e})=>(0,i.jsx)(`blockquote`,{className:`border-l-4 border-primary pl-4 italic my-2 text-muted-foreground`,children:e}),table:({children:e})=>(0,i.jsx)(`div`,{className:`overflow-x-auto my-2`,children:(0,i.jsx)(`table`,{className:`min-w-full divide-y divide-border`,children:e})}),th:({children:e})=>(0,i.jsx)(`th`,{className:`px-3 py-2 text-left text-xs font-medium uppercase tracking-wider bg-muted`,children:e}),td:({children:e})=>(0,i.jsx)(`td`,{className:`px-3 py-2 text-sm border-t border-border`,children:e})},children:e})}):(0,i.jsx)(`div`,{className:`whitespace-pre-wrap`,children:e})}var M=t.forwardRef(({className:e,messages:a=[],placeholder:o=`Type your message...`,onSendMessage:s,onClear:c,onStop:l,onReload:u,disabled:d=!1,isLoading:f=!1,error:p,showTimestamp:m=!1,userAvatarUrl:h,userAvatarFallback:g=`You`,assistantAvatarUrl:_,assistantAvatarFallback:v=`AI`,maxHeight:y=`500px`,enableMarkdown:b=!0,enableFileUpload:x=!1,acceptedFileTypes:S=`image/*,.pdf,.doc,.docx,.txt`,maxFileSize:C=10*1024*1024,...w},T)=>{let[E,D]=t.useState(``),[O,k]=t.useState([]),A=t.useRef(null),M=t.useRef(null),N=t.useRef(null);t.useEffect(()=>{if(A.current){let e=A.current.querySelector(`[data-radix-scroll-area-viewport]`);e&&(e.scrollTop=e.scrollHeight)}},[a]);let P=()=>{(E.trim()||O.length>0)&&s&&(s(E.trim(),O),D(``),k([]),M.current?.focus())},F=d||f,I=F||!E.trim()&&O.length===0,L=e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),P())},R=e=>{let t=Array.from(e.target.files||[]),n=t.filter(e=>e.size>C?(console.warn(`File ${e.name} exceeds ${C/1024/1024}MB limit`),!1):S.split(`,`).map(e=>e.trim()).some(t=>{if(t.startsWith(`.`))return e.name.toLowerCase().endsWith(t.toLowerCase());if(t.endsWith(`/*`)){let n=t.split(`/`)[0];return e.type.startsWith(n+`/`)}return e.type===t})?!0:(console.warn(`File ${e.name} type ${e.type} not accepted`),!1));n.length<t.length&&console.warn(`${t.length-n.length} file(s) were rejected`),k(e=>[...e,...n])},z=e=>{k(t=>t.filter((t,n)=>n!==e))},B=()=>{c&&c()};return(0,i.jsxs)(`div`,{ref:T,className:(0,n.cn)(`flex flex-col border rounded-lg bg-background overflow-hidden`,e),style:{maxHeight:y},...w,children:[c&&a.length>0&&(0,i.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-2 border-b bg-muted/30`,children:[(0,i.jsxs)(`span`,{className:`text-sm text-muted-foreground`,children:[a.length,` message`,a.length===1?``:`s`]}),(0,i.jsxs)(n.Button,{variant:`ghost`,size:`sm`,onClick:B,className:`h-8 text-xs`,children:[(0,i.jsx)(r.Trash2,{className:`h-3 w-3 mr-1`}),`Clear`]})]}),(0,i.jsx)(n.ScrollArea,{ref:A,className:`flex-1 p-4`,children:(0,i.jsx)(`div`,{className:`space-y-4`,children:a.length===0?(0,i.jsx)(`div`,{className:`flex items-center justify-center h-32 text-muted-foreground text-sm`,children:`Start a conversation...`}):a.map(e=>(0,i.jsxs)(`div`,{className:(0,n.cn)(`flex gap-3`,e.role===`user`?`justify-end`:`justify-start`),children:[e.role!==`user`&&(0,i.jsxs)(n.Avatar,{className:`h-8 w-8 shrink-0`,children:[(0,i.jsx)(n.AvatarImage,{src:e.avatar||_}),(0,i.jsx)(n.AvatarFallback,{children:e.avatarFallback||v})]}),(0,i.jsxs)(`div`,{className:(0,n.cn)(`rounded-lg px-4 py-2 max-w-[80%]`,e.role===`user`?`bg-primary text-primary-foreground`:`bg-muted`),children:[(0,i.jsx)(j,{content:e.content,enableMarkdown:b}),m&&e.timestamp&&(0,i.jsx)(`div`,{className:`text-xs opacity-70 mt-1`,children:e.timestamp}),e.streaming&&(0,i.jsxs)(`div`,{className:`flex gap-1 mt-2`,children:[(0,i.jsx)(`div`,{className:`w-2 h-2 bg-current rounded-full animate-bounce`,style:{animationDelay:`0ms`}}),(0,i.jsx)(`div`,{className:`w-2 h-2 bg-current rounded-full animate-bounce`,style:{animationDelay:`150ms`}}),(0,i.jsx)(`div`,{className:`w-2 h-2 bg-current rounded-full animate-bounce`,style:{animationDelay:`300ms`}})]})]}),e.role===`user`&&(0,i.jsxs)(n.Avatar,{className:`h-8 w-8 shrink-0`,children:[(0,i.jsx)(n.AvatarImage,{src:e.avatar||h}),(0,i.jsx)(n.AvatarFallback,{children:e.avatarFallback||g})]})]},e.id))})}),O.length>0&&(0,i.jsx)(`div`,{className:`px-4 py-2 border-t bg-muted/30`,children:(0,i.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:O.map((e,t)=>(0,i.jsxs)(`div`,{className:`flex items-center gap-2 bg-background border rounded px-2 py-1 text-xs`,children:[(0,i.jsx)(r.Paperclip,{className:`h-3 w-3`}),(0,i.jsx)(`span`,{className:`max-w-[150px] truncate`,children:e.name}),(0,i.jsx)(n.Button,{variant:`ghost`,size:`sm`,className:`h-4 w-4 p-0`,onClick:()=>z(t),children:(0,i.jsx)(r.X,{className:`h-3 w-3`})})]},t))})}),p&&(0,i.jsxs)(`div`,{className:`flex items-center gap-2 px-4 py-2 border-t bg-destructive/10 text-destructive text-sm`,role:`alert`,children:[(0,i.jsx)(r.AlertCircle,{className:`h-4 w-4 shrink-0`}),(0,i.jsx)(`span`,{className:`flex-1 truncate`,children:p.message||`An error occurred`}),u&&(0,i.jsxs)(n.Button,{variant:`ghost`,size:`sm`,onClick:u,className:`h-7 text-xs`,"aria-label":`Retry`,children:[(0,i.jsx)(r.RefreshCw,{className:`h-3 w-3 mr-1`}),`Retry`]})]}),f&&l&&(0,i.jsx)(`div`,{className:`flex items-center justify-center px-4 py-2 border-t`,children:(0,i.jsxs)(n.Button,{variant:`outline`,size:`sm`,onClick:l,className:`h-8 text-xs`,"aria-label":`Stop generating`,children:[(0,i.jsx)(r.Square,{className:`h-3 w-3 mr-1`}),`Stop generating`]})}),(0,i.jsxs)(`div`,{className:`flex items-center gap-2 p-4 border-t`,children:[x&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(`input`,{ref:N,type:`file`,multiple:!0,accept:S,onChange:R,className:`hidden`}),(0,i.jsx)(n.Button,{variant:`ghost`,size:`icon`,onClick:()=>N.current?.click(),disabled:F,"aria-label":`Attach file`,children:(0,i.jsx)(r.Paperclip,{className:`h-4 w-4`})})]}),(0,i.jsx)(n.Input,{ref:M,value:E,onChange:e=>D(e.target.value),onKeyDown:L,placeholder:o,disabled:F,className:`flex-1`}),(0,i.jsx)(n.Button,{onClick:P,disabled:I,size:`icon`,"aria-label":`Send message`,children:(0,i.jsx)(r.Send,{className:`h-4 w-4`})})]})]})});M.displayName=`ChatbotEnhanced`;function N({floatingConfig:e,headerExtra:n,...r}){let{position:a=`bottom-right`,defaultOpen:o=!1,panelWidth:c=400,panelHeight:l=520,title:u=`Chat`,triggerSize:d=56}=e??{},[f,p]=t.useState(null);t.useEffect(()=>{let e=document.getElementById(`floating-chatbot-portal`);return e||(e=document.createElement(`div`),e.id=`floating-chatbot-portal`,document.body.appendChild(e)),p(e),()=>{e&&e.parentNode&&!e.hasChildNodes()&&e.parentNode.removeChild(e)}},[]);let m=(0,i.jsxs)(D,{defaultOpen:o,children:[(0,i.jsx)(k,{position:a,size:d}),(0,i.jsx)(A,{title:u,position:a,width:c,height:l,headerExtra:n,children:(0,i.jsx)(M,{...r,maxHeight:`100%`,className:`h-full border-0 rounded-none`})})]});return f?s.createPortal(m,f):m}f.ComponentRegistry.register(`chatbot`,({schema:e,className:t,...n})=>{let{messages:r,isLoading:a,sendMessage:o}=C({api:e.api,initialMessages:e.messages,conversationId:e.conversationId,systemPrompt:e.systemPrompt,model:e.model,streamingEnabled:e.streamingEnabled,headers:e.headers,body:e.requestBody,maxToolRoundtrips:e.maxToolRoundtrips,onError:e.onError,showTimestamp:e.showTimestamp,autoResponse:e.autoResponse,autoResponseText:e.autoResponseText,autoResponseDelay:e.autoResponseDelay,onSend:e.onSend});return(0,i.jsx)(P,{messages:r,placeholder:e.placeholder,onSendMessage:e=>{o(e)},disabled:e.disabled||a,showTimestamp:e.showTimestamp,userAvatarUrl:e.userAvatarUrl,userAvatarFallback:e.userAvatarFallback,assistantAvatarUrl:e.assistantAvatarUrl,assistantAvatarFallback:e.assistantAvatarFallback,maxHeight:e.maxHeight,className:t,...n})},{namespace:`plugin-chatbot`,label:`Chatbot`,inputs:[{name:`messages`,type:`array`,label:`Initial Messages`,description:`Array of message objects with id, role, content, and optional timestamp`},{name:`placeholder`,type:`string`,label:`Input Placeholder`,defaultValue:`Type your message...`},{name:`showTimestamp`,type:`boolean`,label:`Show Timestamps`,defaultValue:!1},{name:`disabled`,type:`boolean`,label:`Disabled`,defaultValue:!1},{name:`userAvatarUrl`,type:`string`,label:`User Avatar URL`,description:`URL of the user avatar image`},{name:`userAvatarFallback`,type:`string`,label:`User Avatar Fallback`,defaultValue:`You`,description:`Fallback text shown when user avatar image is not available`},{name:`assistantAvatarUrl`,type:`string`,label:`Assistant Avatar URL`,description:`URL of the assistant avatar image`},{name:`assistantAvatarFallback`,type:`string`,label:`Assistant Avatar Fallback`,defaultValue:`AI`,description:`Fallback text shown when assistant avatar image is not available`},{name:`maxHeight`,type:`string`,label:`Max Height`,defaultValue:`500px`},{name:`api`,type:`string`,label:`API Endpoint`,description:`Backend SSE endpoint (e.g., /api/v1/ai/chat). When set, enables streaming AI mode.`},{name:`conversationId`,type:`string`,label:`Conversation ID`,description:`Multi-turn conversation identifier`},{name:`systemPrompt`,type:`string`,label:`System Prompt`,description:`System prompt to configure assistant behavior`},{name:`model`,type:`string`,label:`AI Model`,description:`AI model identifier (e.g., gpt-4o)`},{name:`streamingEnabled`,type:`boolean`,label:`Enable Streaming`,defaultValue:!0},{name:`autoResponse`,type:`boolean`,label:`Enable Auto Response (Demo)`,defaultValue:!1,description:`Automatically send a response after user message (for demo purposes, ignored when API is set)`},{name:`autoResponseText`,type:`string`,label:`Auto Response Text`,defaultValue:`Thank you for your message!`},{name:`autoResponseDelay`,type:`number`,label:`Auto Response Delay (ms)`,defaultValue:1e3},{name:`className`,type:`string`,label:`CSS Class`}],defaultProps:{messages:[{id:`welcome`,role:`assistant`,content:`Hello! How can I help you today?`}],placeholder:`Type your message...`,showTimestamp:!1,disabled:!1,userAvatarFallback:`You`,assistantAvatarFallback:`AI`,maxHeight:`500px`,autoResponse:!0,autoResponseText:`Thank you for your message! This is an automated response.`,autoResponseDelay:1e3,className:`w-full max-w-2xl`}}),f.ComponentRegistry.register(`chatbot-enhanced`,({schema:e,className:t,...n})=>{let{messages:r,isLoading:a,error:o,sendMessage:s,stop:c,reload:l,clear:u,isApiMode:d}=C({api:e.api,initialMessages:e.messages,conversationId:e.conversationId,systemPrompt:e.systemPrompt,model:e.model,streamingEnabled:e.streamingEnabled,headers:e.headers,body:e.requestBody,maxToolRoundtrips:e.maxToolRoundtrips,onError:e.onError,showTimestamp:e.showTimestamp,autoResponse:e.autoResponse,autoResponseText:e.autoResponseText,autoResponseDelay:e.autoResponseDelay,onSend:e.onSend});return(0,i.jsx)(M,{messages:r,placeholder:e.placeholder,onSendMessage:(e,t)=>{s(e,t)},onClear:()=>{u(),e.onClear?.()},onStop:d&&a?c:void 0,onReload:d?l:void 0,disabled:e.disabled,isLoading:a,error:o,showTimestamp:e.showTimestamp,userAvatarUrl:e.userAvatarUrl,userAvatarFallback:e.userAvatarFallback,assistantAvatarUrl:e.assistantAvatarUrl,assistantAvatarFallback:e.assistantAvatarFallback,maxHeight:e.maxHeight,enableMarkdown:e.enableMarkdown??!0,enableFileUpload:e.enableFileUpload??!1,className:t,...n})},{namespace:`plugin-chatbot`,label:`Chatbot (Enhanced)`,inputs:[{name:`messages`,type:`array`,label:`Initial Messages`},{name:`placeholder`,type:`string`,label:`Input Placeholder`,defaultValue:`Type your message...`},{name:`showTimestamp`,type:`boolean`,label:`Show Timestamps`,defaultValue:!1},{name:`disabled`,type:`boolean`,label:`Disabled`,defaultValue:!1},{name:`enableMarkdown`,type:`boolean`,label:`Enable Markdown`,defaultValue:!0},{name:`enableFileUpload`,type:`boolean`,label:`Enable File Upload`,defaultValue:!1},{name:`userAvatarUrl`,type:`string`,label:`User Avatar URL`},{name:`userAvatarFallback`,type:`string`,label:`User Avatar Fallback`,defaultValue:`You`},{name:`assistantAvatarUrl`,type:`string`,label:`Assistant Avatar URL`},{name:`assistantAvatarFallback`,type:`string`,label:`Assistant Avatar Fallback`,defaultValue:`AI`},{name:`maxHeight`,type:`string`,label:`Max Height`,defaultValue:`500px`},{name:`api`,type:`string`,label:`API Endpoint`,description:`Backend SSE endpoint for streaming AI mode`},{name:`conversationId`,type:`string`,label:`Conversation ID`},{name:`systemPrompt`,type:`string`,label:`System Prompt`},{name:`model`,type:`string`,label:`AI Model`},{name:`streamingEnabled`,type:`boolean`,label:`Enable Streaming`,defaultValue:!0},{name:`autoResponse`,type:`boolean`,label:`Enable Auto Response (Demo)`,defaultValue:!1},{name:`autoResponseText`,type:`string`,label:`Auto Response Text`,defaultValue:`Thank you for your message!`},{name:`autoResponseDelay`,type:`number`,label:`Auto Response Delay (ms)`,defaultValue:1e3},{name:`className`,type:`string`,label:`CSS Class`}],defaultProps:{messages:[{id:`welcome`,role:`assistant`,content:`Hello! How can I help you today?`}],placeholder:`Type your message...`,showTimestamp:!1,disabled:!1,enableMarkdown:!0,enableFileUpload:!1,userAvatarFallback:`You`,assistantAvatarFallback:`AI`,maxHeight:`500px`,autoResponse:!0,autoResponseText:`Thank you for your message! This is an automated response.`,autoResponseDelay:1e3,className:`w-full max-w-2xl`}}),f.ComponentRegistry.register(`chatbot-floating`,({schema:e,className:t,...n})=>{let{messages:r,isLoading:a,error:o,sendMessage:s,stop:c,reload:l,clear:u,isApiMode:d}=C({api:e.api,initialMessages:e.messages,conversationId:e.conversationId,systemPrompt:e.systemPrompt,model:e.model,streamingEnabled:e.streamingEnabled,headers:e.headers,body:e.requestBody,maxToolRoundtrips:e.maxToolRoundtrips,onError:e.onError,showTimestamp:e.showTimestamp,autoResponse:e.autoResponse,autoResponseText:e.autoResponseText,autoResponseDelay:e.autoResponseDelay,onSend:e.onSend});return(0,i.jsx)(N,{floatingConfig:e.floatingConfig,messages:r,placeholder:e.placeholder,onSendMessage:(e,t)=>{s(e,t)},onClear:()=>{u(),e.onClear?.()},onStop:d&&a?c:void 0,onReload:d?l:void 0,disabled:e.disabled,isLoading:a,error:o,showTimestamp:e.showTimestamp,userAvatarUrl:e.userAvatarUrl,userAvatarFallback:e.userAvatarFallback,assistantAvatarUrl:e.assistantAvatarUrl,assistantAvatarFallback:e.assistantAvatarFallback,enableMarkdown:e.enableMarkdown??!0,enableFileUpload:e.enableFileUpload??!1,className:t,...n})},{namespace:`plugin-chatbot`,label:`Chatbot (Floating)`,inputs:[{name:`displayMode`,type:`string`,label:`Display Mode`,defaultValue:`floating`,description:`Set to "floating" for FAB widget`},{name:`floatingConfig.position`,type:`string`,label:`FAB Position`,defaultValue:`bottom-right`,description:`bottom-right or bottom-left`},{name:`floatingConfig.defaultOpen`,type:`boolean`,label:`Default Open`,defaultValue:!1},{name:`floatingConfig.panelWidth`,type:`number`,label:`Panel Width`,defaultValue:400},{name:`floatingConfig.panelHeight`,type:`number`,label:`Panel Height`,defaultValue:520},{name:`floatingConfig.title`,type:`string`,label:`Panel Title`,defaultValue:`Chat`},{name:`floatingConfig.triggerSize`,type:`number`,label:`Trigger Size`,defaultValue:56},{name:`messages`,type:`array`,label:`Initial Messages`},{name:`placeholder`,type:`string`,label:`Input Placeholder`,defaultValue:`Type your message...`},{name:`enableMarkdown`,type:`boolean`,label:`Enable Markdown`,defaultValue:!0},{name:`enableFileUpload`,type:`boolean`,label:`Enable File Upload`,defaultValue:!1},{name:`api`,type:`string`,label:`API Endpoint`,description:`Backend SSE endpoint for streaming AI mode`},{name:`conversationId`,type:`string`,label:`Conversation ID`},{name:`systemPrompt`,type:`string`,label:`System Prompt`},{name:`model`,type:`string`,label:`AI Model`},{name:`streamingEnabled`,type:`boolean`,label:`Enable Streaming`,defaultValue:!0},{name:`autoResponse`,type:`boolean`,label:`Enable Auto Response (Demo)`,defaultValue:!1},{name:`autoResponseText`,type:`string`,label:`Auto Response Text`,defaultValue:`Thank you for your message!`},{name:`autoResponseDelay`,type:`number`,label:`Auto Response Delay (ms)`,defaultValue:1e3},{name:`className`,type:`string`,label:`CSS Class`}],defaultProps:{displayMode:`floating`,floatingConfig:{position:`bottom-right`,defaultOpen:!1,panelWidth:400,panelHeight:520,title:`Chat`,triggerSize:56},messages:[{id:`welcome`,role:`assistant`,content:`Hello! How can I help you today?`}],placeholder:`Type your message...`,enableMarkdown:!0,enableFileUpload:!1,autoResponse:!0,autoResponseText:`Thank you for your message! This is an automated response.`,autoResponseDelay:1e3}});var P=t.forwardRef(({className:e,messages:a=[],placeholder:o=`Type your message...`,onSendMessage:s,disabled:c=!1,showTimestamp:l=!1,userAvatarUrl:u,userAvatarFallback:d=`You`,assistantAvatarUrl:f,assistantAvatarFallback:p=`AI`,maxHeight:m=`500px`,...h},g)=>{let[_,v]=t.useState(``),y=t.useRef(null),b=t.useRef(null);t.useEffect(()=>{if(y.current){let e=y.current.querySelector(`[data-radix-scroll-area-viewport]`);e&&(e.scrollTop=e.scrollHeight)}},[a]);let x=()=>{_.trim()&&s&&(s(_.trim()),v(``),b.current?.focus())},S=e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),x())};return(0,i.jsxs)(`div`,{ref:g,className:(0,n.cn)(`flex flex-col border rounded-lg bg-background overflow-hidden`,e),style:{maxHeight:m},...h,children:[(0,i.jsx)(n.ScrollArea,{ref:y,className:`flex-1 p-4`,children:(0,i.jsx)(`div`,{className:`space-y-4`,children:a.length===0?(0,i.jsx)(`div`,{className:`flex items-center justify-center h-32 text-muted-foreground text-sm`,children:`No messages yet. Start a conversation!`}):a.map(e=>(0,i.jsx)(F,{message:e,showTimestamp:l,userAvatarUrl:u,userAvatarFallback:d,assistantAvatarUrl:f,assistantAvatarFallback:p},e.id))})}),(0,i.jsx)(`div`,{className:`border-t p-4`,children:(0,i.jsxs)(`div`,{className:`flex gap-2`,children:[(0,i.jsx)(n.Input,{ref:b,value:_,onChange:e=>v(e.target.value),onKeyDown:S,placeholder:o,disabled:c,className:`flex-1`}),(0,i.jsx)(n.Button,{onClick:x,disabled:c||!_.trim(),size:`icon`,children:(0,i.jsx)(r.Send,{className:`h-4 w-4`})})]})})]})});P.displayName=`Chatbot`;var F=({message:e,showTimestamp:t,userAvatarUrl:r,userAvatarFallback:a,assistantAvatarUrl:o,assistantAvatarFallback:s})=>{let c=e.role===`user`;if(e.role===`system`)return(0,i.jsx)(`div`,{className:`flex justify-center`,children:(0,i.jsx)(`div`,{className:`text-xs text-muted-foreground bg-muted px-3 py-1 rounded-full`,children:e.content})});let l=c?e.avatar||r:e.avatar||o,u=c?e.avatarFallback||a:e.avatarFallback||s;return(0,i.jsxs)(`div`,{className:(0,n.cn)(`flex gap-3`,c?`flex-row-reverse`:`flex-row`),children:[(0,i.jsxs)(n.Avatar,{className:`h-8 w-8`,children:[(0,i.jsx)(n.AvatarImage,{src:l}),(0,i.jsx)(n.AvatarFallback,{className:`text-xs`,children:u})]}),(0,i.jsxs)(`div`,{className:(0,n.cn)(`flex flex-col gap-1`,c?`items-end`:`items-start`),children:[(0,i.jsx)(`div`,{className:(0,n.cn)(`rounded-lg px-4 py-2 max-w-[70%] break-words`,c?`bg-primary text-primary-foreground`:`bg-muted`),children:(0,i.jsx)(`p`,{className:`text-sm whitespace-pre-wrap`,children:e.content})}),t&&e.timestamp&&(0,i.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.timestamp})]})]})},I=t.forwardRef(({className:e,avatarSrc:t,avatarFallback:r=`AI`,...a},o)=>(0,i.jsxs)(`div`,{ref:o,className:(0,n.cn)(`flex gap-3`,e),...a,children:[(0,i.jsxs)(n.Avatar,{className:`h-8 w-8`,children:[(0,i.jsx)(n.AvatarImage,{src:t}),(0,i.jsx)(n.AvatarFallback,{className:`text-xs`,children:r})]}),(0,i.jsx)(`div`,{className:`flex items-center bg-muted rounded-lg px-4 py-2`,children:(0,i.jsxs)(`div`,{className:`flex gap-1`,children:[(0,i.jsx)(`span`,{className:`w-2 h-2 bg-muted-foreground rounded-full animate-bounce [animation-delay:-0.3s]`}),(0,i.jsx)(`span`,{className:`w-2 h-2 bg-muted-foreground rounded-full animate-bounce [animation-delay:-0.15s]`}),(0,i.jsx)(`span`,{className:`w-2 h-2 bg-muted-foreground rounded-full animate-bounce`})]})})]}));I.displayName=`TypingIndicator`,e.Chatbot=P,e.FloatingChatbot=N,e.FloatingChatbotPanel=A,e.FloatingChatbotProvider=D,e.FloatingChatbotTrigger=k,e.TypingIndicator=I,e.useAgents=T,e.useFloatingChatbot=O,e.useObjectChat=C});
1
+ (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require(`react`),require(`@object-ui/components`),require(`lucide-react`),require(`react/jsx-runtime`),require(`@ai-sdk/react`),require(`ai`),require(`react-dom`),require(`@object-ui/react`),require(`react-markdown`),require(`react-syntax-highlighter`),require(`react-syntax-highlighter/dist/esm/styles/prism`),require(`remark-gfm`),require(`@object-ui/core`)):typeof define==`function`&&define.amd?define([`exports`,`react`,`@object-ui/components`,`lucide-react`,`react/jsx-runtime`,`@ai-sdk/react`,`ai`,`react-dom`,`@object-ui/react`,`react-markdown`,`react-syntax-highlighter`,`react-syntax-highlighter/dist/esm/styles/prism`,`remark-gfm`,`@object-ui/core`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.ObjectUIPluginChatbot={},e.React,e.ObjectUIComponents,e.LucideReact,e.react_jsx_runtime,e._ai_sdk_react,e.ai,e.ReactDOM,e.ObjectUIReact,e.react_markdown,e.react_syntax_highlighter,e.react_syntax_highlighter_dist_esm_styles_prism,e.remark_gfm,e.ObjectUICore))})(this,function(e,t,n,r,i,a,o,s,c,l,u,d,f,p){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var m=Object.create,h=Object.defineProperty,g=Object.getOwnPropertyDescriptor,_=Object.getOwnPropertyNames,v=Object.getPrototypeOf,y=Object.prototype.hasOwnProperty,b=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=_(t),a=0,o=i.length,s;a<o;a++)s=i[a],!y.call(e,s)&&s!==n&&h(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=g(t,s))||r.enumerable});return e},x=(e,t,n)=>(n=e==null?{}:m(v(e)),b(t||!e||!e.__esModule?h(n,`default`,{value:e,enumerable:!0}):n,e));t=x(t,1),s=x(s,1),l=x(l,1),f=x(f,1);function S(e=`msg`){return typeof crypto<`u`&&crypto.randomUUID?crypto.randomUUID():`${e}-${Date.now()}-${Math.random().toString(36).slice(2)}`}function C(e){return(e??[]).map((e,t)=>({id:e.id||`msg-${t}`,role:e.role||`user`,content:e.content||``,timestamp:typeof e.timestamp==`string`?e.timestamp:e.timestamp instanceof Date?e.timestamp.toISOString():void 0,metadata:e.metadata,streaming:e.streaming,toolInvocations:e.toolInvocations}))}function w(e={}){let{api:n,initialMessages:r,conversationId:i,systemPrompt:s,model:c,streamingEnabled:l=!0,headers:u,body:d,maxToolRoundtrips:f=5,onError:p,showTimestamp:m,autoResponse:h,autoResponseText:g,autoResponseDelay:_=1e3,onSend:v}=e,y=(0,t.useRef)(n?`api`:`local`).current===`api`,b=(0,t.useMemo)(()=>C(r).map(e=>({id:e.id,role:e.role,parts:[{type:`text`,text:e.content??``}]})),[]),x=(0,a.useChat)({transport:(0,t.useMemo)(()=>{if(y)return new o.DefaultChatTransport({api:n,headers:{...u},body:{...d,...i?{conversationId:i}:{},...c?{model:c}:{},...s?{systemPrompt:s}:{},...l===void 0?{}:{stream:l}}})},[y,n,u,d,c,s,l,i]),messages:y&&b.length>0?b:void 0,onError:y?e=>{p?.(e)}:void 0}),[w,T]=(0,t.useState)(()=>C(r)),[E,D]=(0,t.useState)(!1),[O,k]=(0,t.useState)(``),[A,j]=(0,t.useState)(``),M=(0,t.useRef)(null);if((0,t.useEffect)(()=>()=>{M.current&&=(clearTimeout(M.current),null)},[]),y){let{messages:e,status:n,error:r,sendMessage:i,regenerate:a,stop:o,setMessages:s}=x,c=n===`submitted`||n===`streaming`,l=e.map(t=>{let n=typeof t.content==`string`?t.content:Array.isArray(t.parts)?t.parts.filter(e=>e?.type===`text`).map(e=>e.text??``).join(``):``;return{id:t.id,role:t.role,content:n,toolInvocations:t.toolInvocations,streaming:c&&t.id===e[e.length-1]?.id&&t.role===`assistant`}});return{messages:l,isLoading:c,error:r,sendMessage:(0,t.useCallback)(e=>{let t=e.trim();if(!t)return;let n=[...l,{id:S(`msg`),role:`user`,content:t}];i({text:t}),j(``),v?.(t,n)},[i,v,l]),stop:o,reload:a,clear:(0,t.useCallback)(()=>{s([])},[s]),isApiMode:!0,input:A,setInput:j,handleInputChange:(0,t.useCallback)(e=>{j(e.target.value)},[])}}let N=(0,t.useCallback)(()=>{M.current&&=(clearTimeout(M.current),null),D(!1)},[]);return{messages:w,isLoading:E,error:void 0,sendMessage:(0,t.useCallback)(e=>{if(!e.trim())return;let t={id:S(`msg`),role:`user`,content:e.trim(),timestamp:m?new Date().toLocaleTimeString():void 0};T(n=>{let r=[...n,t];return v?.(e.trim(),r),r}),k(``),h&&(D(!0),M.current=setTimeout(()=>{let e={id:S(`msg`),role:`assistant`,content:g||`Thank you for your message!`,timestamp:m?new Date().toLocaleTimeString():void 0};T(t=>[...t,e]),D(!1)},_))},[m,h,g,_,v]),stop:N,reload:(0,t.useCallback)(()=>{},[]),clear:(0,t.useCallback)(()=>{N(),T([])},[N]),isApiMode:!1,input:O,setInput:k,handleInputChange:(0,t.useCallback)(e=>{k(e.target.value)},[])}}function T(e){return e.filter(e=>typeof e?.name==`string`&&e.name.length>0).map(e=>({name:e.name,label:e.label||e.name,description:e.description,role:e.role,active:e.active!==!1}))}function E(e={}){let{apiBase:n,headers:r,enabled:i=!0,fallback:a=[]}=e,[o,s]=(0,t.useState)(a),[c,l]=(0,t.useState)(!1),[u,d]=(0,t.useState)(void 0),[f,p]=(0,t.useState)(0),m=(0,t.useRef)(r);return m.current=r,(0,t.useEffect)(()=>{if(!i||!n)return;let e=new AbortController,t=!1;l(!0),d(void 0);let r=`${n.replace(/\/$/,``)}/agents`;return fetch(r,{method:`GET`,headers:{Accept:`application/json`,...m.current??{}},credentials:`include`,signal:e.signal}).then(async e=>{if(!e.ok)throw Error(`Failed to load agents (${e.status})`);return e.json()}).then(e=>{if(t)return;let n=T(Array.isArray(e)?e:e?.agents??[]);s(n.length>0?n:a)}).catch(e=>{t||e.name===`AbortError`||(d(e),s(a))}).finally(()=>{t||l(!1)}),()=>{t=!0,e.abort()}},[n,i,f]),{agents:o,isLoading:c,error:u,refetch:(0,t.useCallback)(()=>p(e=>e+1),[])}}var D=t.createContext(null);function O({defaultOpen:e=!1,children:n}){let[r,a]=t.useState(e),[o,s]=t.useState(!1),c=t.useMemo(()=>({isOpen:r,isFullscreen:o,open:()=>a(!0),close:()=>{a(!1),s(!1)},toggle:()=>a(e=>!e),toggleFullscreen:()=>s(e=>!e)}),[r,o]);return(0,i.jsx)(D.Provider,{value:c,children:n})}function k(){let e=t.useContext(D);if(!e)throw Error(`useFloatingChatbot must be used within a <FloatingChatbotProvider>`);return e}function A(){try{let{t:e}=(0,c.useObjectTranslation)();return(t,n)=>{let r=e(`common.${t}`);return!r||r===`common.${t}`?n:r}}catch{return(e,t)=>t}}function j({position:e=`bottom-right`,size:t=56,className:a}){let{isOpen:o,toggle:s}=k(),c=A();return(0,i.jsx)(n.Button,{onClick:s,className:(0,n.cn)(`fixed z-50 rounded-full shadow-lg transition-transform hover:scale-105`,e===`bottom-right`?`right-6 bottom-6`:`left-6 bottom-6`,a),style:{width:t,height:t},size:`icon`,"aria-label":o?c(`closeChat`,`Close chat`):c(`openChat`,`Open chat`),"data-testid":`floating-chatbot-trigger`,children:o?(0,i.jsx)(r.X,{className:`h-6 w-6`}):(0,i.jsx)(r.MessageCircle,{className:`h-6 w-6`})})}function M({title:e=`Chat`,position:t=`bottom-right`,width:a=400,height:o=520,children:s,className:c,headerExtra:l}){let{isOpen:u,isFullscreen:d,close:f,toggleFullscreen:p}=k();if(!u)return null;let m=d?{inset:0,width:`100vw`,height:`100vh`}:{width:a,height:o,maxHeight:`calc(100vh - 100px)`};return(0,i.jsxs)(`div`,{className:(0,n.cn)(`fixed z-50 flex flex-col rounded-lg border bg-background shadow-xl overflow-hidden transition-all`,d?`inset-0 rounded-none`:t===`bottom-right`?`right-6 bottom-20`:`left-6 bottom-20`,c),style:m,role:`dialog`,"aria-label":e,"data-testid":`floating-chatbot-panel`,children:[(0,i.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-4 py-2 border-b bg-muted/40`,children:[(0,i.jsx)(`span`,{className:`text-sm font-medium truncate shrink-0`,children:e}),l?(0,i.jsx)(`div`,{className:`flex-1 min-w-0 flex items-center justify-end mr-1`,"data-testid":`floating-chatbot-header-extra`,children:l}):null,(0,i.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[(0,i.jsx)(n.Button,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:p,"aria-label":d?`Exit fullscreen`:`Fullscreen`,"data-testid":`floating-chatbot-fullscreen`,children:d?(0,i.jsx)(r.Minimize2,{className:`h-4 w-4`}):(0,i.jsx)(r.Maximize2,{className:`h-4 w-4`})}),(0,i.jsx)(n.Button,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:f,"aria-label":`Close chat`,"data-testid":`floating-chatbot-close`,children:(0,i.jsx)(r.X,{className:`h-4 w-4`})})]})]}),(0,i.jsx)(`div`,{className:`flex-1 overflow-hidden`,children:s})]})}function N({content:e,enableMarkdown:t}){return t?(0,i.jsx)(`div`,{className:`prose prose-sm dark:prose-invert max-w-none`,children:(0,i.jsx)(l.default,{remarkPlugins:[f.default],components:{code({node:e,inline:t,className:r,children:a,...o}){let s=/language-(\w+)/.exec(r||``);return!t&&s?(0,i.jsx)(u.Prism,{style:d.oneDark,language:s[1],PreTag:`div`,className:`rounded-md my-2`,...o,children:String(a).replace(/\n$/,``)}):(0,i.jsx)(`code`,{className:(0,n.cn)(`bg-muted px-1 py-0.5 rounded text-sm`,r),...o,children:a})},p:({children:e})=>(0,i.jsx)(`p`,{className:`mb-2 last:mb-0`,children:e}),ul:({children:e})=>(0,i.jsx)(`ul`,{className:`list-disc pl-4 mb-2`,children:e}),ol:({children:e})=>(0,i.jsx)(`ol`,{className:`list-decimal pl-4 mb-2`,children:e}),li:({children:e})=>(0,i.jsx)(`li`,{className:`mb-1`,children:e}),a:({href:e,children:t})=>(0,i.jsx)(`a`,{href:e,className:`text-primary hover:underline`,target:`_blank`,rel:`noopener noreferrer`,children:t}),blockquote:({children:e})=>(0,i.jsx)(`blockquote`,{className:`border-l-4 border-primary pl-4 italic my-2 text-muted-foreground`,children:e}),table:({children:e})=>(0,i.jsx)(`div`,{className:`overflow-x-auto my-2`,children:(0,i.jsx)(`table`,{className:`min-w-full divide-y divide-border`,children:e})}),th:({children:e})=>(0,i.jsx)(`th`,{className:`px-3 py-2 text-left text-xs font-medium uppercase tracking-wider bg-muted`,children:e}),td:({children:e})=>(0,i.jsx)(`td`,{className:`px-3 py-2 text-sm border-t border-border`,children:e})},children:e})}):(0,i.jsx)(`div`,{className:`whitespace-pre-wrap`,children:e})}var P=t.forwardRef(({className:e,messages:a=[],placeholder:o=`Type your message...`,onSendMessage:s,onClear:c,onStop:l,onReload:u,disabled:d=!1,isLoading:f=!1,error:p,showTimestamp:m=!1,userAvatarUrl:h,userAvatarFallback:g=`You`,assistantAvatarUrl:_,assistantAvatarFallback:v=`AI`,maxHeight:y=`500px`,enableMarkdown:b=!0,enableFileUpload:x=!1,acceptedFileTypes:S=`image/*,.pdf,.doc,.docx,.txt`,maxFileSize:C=10*1024*1024,...w},T)=>{let[E,D]=t.useState(``),[O,k]=t.useState([]),A=t.useRef(null),j=t.useRef(null),M=t.useRef(null);t.useEffect(()=>{if(A.current){let e=A.current.querySelector(`[data-radix-scroll-area-viewport]`);e&&(e.scrollTop=e.scrollHeight)}},[a]);let P=()=>{(E.trim()||O.length>0)&&s&&(s(E.trim(),O),D(``),k([]),j.current?.focus())},F=d||f,I=F||!E.trim()&&O.length===0,L=e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),P())},R=e=>{let t=Array.from(e.target.files||[]),n=t.filter(e=>e.size>C?(console.warn(`File ${e.name} exceeds ${C/1024/1024}MB limit`),!1):S.split(`,`).map(e=>e.trim()).some(t=>{if(t.startsWith(`.`))return e.name.toLowerCase().endsWith(t.toLowerCase());if(t.endsWith(`/*`)){let n=t.split(`/`)[0];return e.type.startsWith(n+`/`)}return e.type===t})?!0:(console.warn(`File ${e.name} type ${e.type} not accepted`),!1));n.length<t.length&&console.warn(`${t.length-n.length} file(s) were rejected`),k(e=>[...e,...n])},z=e=>{k(t=>t.filter((t,n)=>n!==e))},B=()=>{c&&c()};return(0,i.jsxs)(`div`,{ref:T,className:(0,n.cn)(`flex flex-col border rounded-lg bg-background overflow-hidden`,e),style:{maxHeight:y},...w,children:[c&&a.length>0&&(0,i.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-2 border-b bg-muted/30`,children:[(0,i.jsxs)(`span`,{className:`text-sm text-muted-foreground`,children:[a.length,` message`,a.length===1?``:`s`]}),(0,i.jsxs)(n.Button,{variant:`ghost`,size:`sm`,onClick:B,className:`h-8 text-xs`,children:[(0,i.jsx)(r.Trash2,{className:`h-3 w-3 mr-1`}),`Clear`]})]}),(0,i.jsx)(n.ScrollArea,{ref:A,className:`flex-1 p-4`,children:(0,i.jsx)(`div`,{className:`space-y-4`,children:a.length===0?(0,i.jsx)(`div`,{className:`flex items-center justify-center h-32 text-muted-foreground text-sm`,children:`Start a conversation...`}):a.map(e=>(0,i.jsxs)(`div`,{className:(0,n.cn)(`flex gap-3`,e.role===`user`?`justify-end`:`justify-start`),children:[e.role!==`user`&&(0,i.jsxs)(n.Avatar,{className:`h-8 w-8 shrink-0`,children:[(0,i.jsx)(n.AvatarImage,{src:e.avatar||_}),(0,i.jsx)(n.AvatarFallback,{children:e.avatarFallback||v})]}),(0,i.jsxs)(`div`,{className:(0,n.cn)(`rounded-lg px-4 py-2 max-w-[80%]`,e.role===`user`?`bg-primary text-primary-foreground`:`bg-muted`),children:[(0,i.jsx)(N,{content:e.content,enableMarkdown:b}),m&&e.timestamp&&(0,i.jsx)(`div`,{className:`text-xs opacity-70 mt-1`,children:e.timestamp}),e.streaming&&(0,i.jsxs)(`div`,{className:`flex gap-1 mt-2`,children:[(0,i.jsx)(`div`,{className:`w-2 h-2 bg-current rounded-full animate-bounce`,style:{animationDelay:`0ms`}}),(0,i.jsx)(`div`,{className:`w-2 h-2 bg-current rounded-full animate-bounce`,style:{animationDelay:`150ms`}}),(0,i.jsx)(`div`,{className:`w-2 h-2 bg-current rounded-full animate-bounce`,style:{animationDelay:`300ms`}})]})]}),e.role===`user`&&(0,i.jsxs)(n.Avatar,{className:`h-8 w-8 shrink-0`,children:[(0,i.jsx)(n.AvatarImage,{src:e.avatar||h}),(0,i.jsx)(n.AvatarFallback,{children:e.avatarFallback||g})]})]},e.id))})}),O.length>0&&(0,i.jsx)(`div`,{className:`px-4 py-2 border-t bg-muted/30`,children:(0,i.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:O.map((e,t)=>(0,i.jsxs)(`div`,{className:`flex items-center gap-2 bg-background border rounded px-2 py-1 text-xs`,children:[(0,i.jsx)(r.Paperclip,{className:`h-3 w-3`}),(0,i.jsx)(`span`,{className:`max-w-[150px] truncate`,children:e.name}),(0,i.jsx)(n.Button,{variant:`ghost`,size:`sm`,className:`h-4 w-4 p-0`,onClick:()=>z(t),children:(0,i.jsx)(r.X,{className:`h-3 w-3`})})]},t))})}),p&&(0,i.jsxs)(`div`,{className:`flex items-center gap-2 px-4 py-2 border-t bg-destructive/10 text-destructive text-sm`,role:`alert`,children:[(0,i.jsx)(r.AlertCircle,{className:`h-4 w-4 shrink-0`}),(0,i.jsx)(`span`,{className:`flex-1 truncate`,children:p.message||`An error occurred`}),u&&(0,i.jsxs)(n.Button,{variant:`ghost`,size:`sm`,onClick:u,className:`h-7 text-xs`,"aria-label":`Retry`,children:[(0,i.jsx)(r.RefreshCw,{className:`h-3 w-3 mr-1`}),`Retry`]})]}),f&&l&&(0,i.jsx)(`div`,{className:`flex items-center justify-center px-4 py-2 border-t`,children:(0,i.jsxs)(n.Button,{variant:`outline`,size:`sm`,onClick:l,className:`h-8 text-xs`,"aria-label":`Stop generating`,children:[(0,i.jsx)(r.Square,{className:`h-3 w-3 mr-1`}),`Stop generating`]})}),(0,i.jsxs)(`div`,{className:`flex items-center gap-2 p-4 border-t`,children:[x&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(`input`,{ref:M,type:`file`,multiple:!0,accept:S,onChange:R,className:`hidden`}),(0,i.jsx)(n.Button,{variant:`ghost`,size:`icon`,onClick:()=>M.current?.click(),disabled:F,"aria-label":`Attach file`,children:(0,i.jsx)(r.Paperclip,{className:`h-4 w-4`})})]}),(0,i.jsx)(n.Input,{ref:j,value:E,onChange:e=>D(e.target.value),onKeyDown:L,placeholder:o,disabled:F,className:`flex-1`}),(0,i.jsx)(n.Button,{onClick:P,disabled:I,size:`icon`,"aria-label":`Send message`,children:(0,i.jsx)(r.Send,{className:`h-4 w-4`})})]})]})});P.displayName=`ChatbotEnhanced`;function F({floatingConfig:e,headerExtra:n,...r}){let{position:a=`bottom-right`,defaultOpen:o=!1,panelWidth:c=400,panelHeight:l=520,title:u=`Chat`,triggerSize:d=56}=e??{},[f,p]=t.useState(null);t.useEffect(()=>{let e=document.getElementById(`floating-chatbot-portal`);return e||(e=document.createElement(`div`),e.id=`floating-chatbot-portal`,document.body.appendChild(e)),p(e),()=>{e&&e.parentNode&&!e.hasChildNodes()&&e.parentNode.removeChild(e)}},[]);let m=(0,i.jsxs)(O,{defaultOpen:o,children:[(0,i.jsx)(j,{position:a,size:d}),(0,i.jsx)(M,{title:u,position:a,width:c,height:l,headerExtra:n,children:(0,i.jsx)(P,{...r,maxHeight:`100%`,className:`h-full border-0 rounded-none`})})]});return f?s.createPortal(m,f):m}p.ComponentRegistry.register(`chatbot`,({schema:e,className:t,...n})=>{let{messages:r,isLoading:a,sendMessage:o}=w({api:e.api,initialMessages:e.messages,conversationId:e.conversationId,systemPrompt:e.systemPrompt,model:e.model,streamingEnabled:e.streamingEnabled,headers:e.headers,body:e.requestBody,maxToolRoundtrips:e.maxToolRoundtrips,onError:e.onError,showTimestamp:e.showTimestamp,autoResponse:e.autoResponse,autoResponseText:e.autoResponseText,autoResponseDelay:e.autoResponseDelay,onSend:e.onSend});return(0,i.jsx)(I,{messages:r,placeholder:e.placeholder,onSendMessage:e=>{o(e)},disabled:e.disabled||a,showTimestamp:e.showTimestamp,userAvatarUrl:e.userAvatarUrl,userAvatarFallback:e.userAvatarFallback,assistantAvatarUrl:e.assistantAvatarUrl,assistantAvatarFallback:e.assistantAvatarFallback,maxHeight:e.maxHeight,className:t,...n})},{namespace:`plugin-chatbot`,label:`Chatbot`,inputs:[{name:`messages`,type:`array`,label:`Initial Messages`,description:`Array of message objects with id, role, content, and optional timestamp`},{name:`placeholder`,type:`string`,label:`Input Placeholder`,defaultValue:`Type your message...`},{name:`showTimestamp`,type:`boolean`,label:`Show Timestamps`,defaultValue:!1},{name:`disabled`,type:`boolean`,label:`Disabled`,defaultValue:!1},{name:`userAvatarUrl`,type:`string`,label:`User Avatar URL`,description:`URL of the user avatar image`},{name:`userAvatarFallback`,type:`string`,label:`User Avatar Fallback`,defaultValue:`You`,description:`Fallback text shown when user avatar image is not available`},{name:`assistantAvatarUrl`,type:`string`,label:`Assistant Avatar URL`,description:`URL of the assistant avatar image`},{name:`assistantAvatarFallback`,type:`string`,label:`Assistant Avatar Fallback`,defaultValue:`AI`,description:`Fallback text shown when assistant avatar image is not available`},{name:`maxHeight`,type:`string`,label:`Max Height`,defaultValue:`500px`},{name:`api`,type:`string`,label:`API Endpoint`,description:`Backend SSE endpoint (e.g., /api/v1/ai/chat). When set, enables streaming AI mode.`},{name:`conversationId`,type:`string`,label:`Conversation ID`,description:`Multi-turn conversation identifier`},{name:`systemPrompt`,type:`string`,label:`System Prompt`,description:`System prompt to configure assistant behavior`},{name:`model`,type:`string`,label:`AI Model`,description:`AI model identifier (e.g., gpt-4o)`},{name:`streamingEnabled`,type:`boolean`,label:`Enable Streaming`,defaultValue:!0},{name:`autoResponse`,type:`boolean`,label:`Enable Auto Response (Demo)`,defaultValue:!1,description:`Automatically send a response after user message (for demo purposes, ignored when API is set)`},{name:`autoResponseText`,type:`string`,label:`Auto Response Text`,defaultValue:`Thank you for your message!`},{name:`autoResponseDelay`,type:`number`,label:`Auto Response Delay (ms)`,defaultValue:1e3},{name:`className`,type:`string`,label:`CSS Class`}],defaultProps:{messages:[{id:`welcome`,role:`assistant`,content:`Hello! How can I help you today?`}],placeholder:`Type your message...`,showTimestamp:!1,disabled:!1,userAvatarFallback:`You`,assistantAvatarFallback:`AI`,maxHeight:`500px`,autoResponse:!0,autoResponseText:`Thank you for your message! This is an automated response.`,autoResponseDelay:1e3,className:`w-full max-w-2xl`}}),p.ComponentRegistry.register(`chatbot-enhanced`,({schema:e,className:t,...n})=>{let{messages:r,isLoading:a,error:o,sendMessage:s,stop:c,reload:l,clear:u,isApiMode:d}=w({api:e.api,initialMessages:e.messages,conversationId:e.conversationId,systemPrompt:e.systemPrompt,model:e.model,streamingEnabled:e.streamingEnabled,headers:e.headers,body:e.requestBody,maxToolRoundtrips:e.maxToolRoundtrips,onError:e.onError,showTimestamp:e.showTimestamp,autoResponse:e.autoResponse,autoResponseText:e.autoResponseText,autoResponseDelay:e.autoResponseDelay,onSend:e.onSend});return(0,i.jsx)(P,{messages:r,placeholder:e.placeholder,onSendMessage:(e,t)=>{s(e,t)},onClear:()=>{u(),e.onClear?.()},onStop:d&&a?c:void 0,onReload:d?l:void 0,disabled:e.disabled,isLoading:a,error:o,showTimestamp:e.showTimestamp,userAvatarUrl:e.userAvatarUrl,userAvatarFallback:e.userAvatarFallback,assistantAvatarUrl:e.assistantAvatarUrl,assistantAvatarFallback:e.assistantAvatarFallback,maxHeight:e.maxHeight,enableMarkdown:e.enableMarkdown??!0,enableFileUpload:e.enableFileUpload??!1,className:t,...n})},{namespace:`plugin-chatbot`,label:`Chatbot (Enhanced)`,inputs:[{name:`messages`,type:`array`,label:`Initial Messages`},{name:`placeholder`,type:`string`,label:`Input Placeholder`,defaultValue:`Type your message...`},{name:`showTimestamp`,type:`boolean`,label:`Show Timestamps`,defaultValue:!1},{name:`disabled`,type:`boolean`,label:`Disabled`,defaultValue:!1},{name:`enableMarkdown`,type:`boolean`,label:`Enable Markdown`,defaultValue:!0},{name:`enableFileUpload`,type:`boolean`,label:`Enable File Upload`,defaultValue:!1},{name:`userAvatarUrl`,type:`string`,label:`User Avatar URL`},{name:`userAvatarFallback`,type:`string`,label:`User Avatar Fallback`,defaultValue:`You`},{name:`assistantAvatarUrl`,type:`string`,label:`Assistant Avatar URL`},{name:`assistantAvatarFallback`,type:`string`,label:`Assistant Avatar Fallback`,defaultValue:`AI`},{name:`maxHeight`,type:`string`,label:`Max Height`,defaultValue:`500px`},{name:`api`,type:`string`,label:`API Endpoint`,description:`Backend SSE endpoint for streaming AI mode`},{name:`conversationId`,type:`string`,label:`Conversation ID`},{name:`systemPrompt`,type:`string`,label:`System Prompt`},{name:`model`,type:`string`,label:`AI Model`},{name:`streamingEnabled`,type:`boolean`,label:`Enable Streaming`,defaultValue:!0},{name:`autoResponse`,type:`boolean`,label:`Enable Auto Response (Demo)`,defaultValue:!1},{name:`autoResponseText`,type:`string`,label:`Auto Response Text`,defaultValue:`Thank you for your message!`},{name:`autoResponseDelay`,type:`number`,label:`Auto Response Delay (ms)`,defaultValue:1e3},{name:`className`,type:`string`,label:`CSS Class`}],defaultProps:{messages:[{id:`welcome`,role:`assistant`,content:`Hello! How can I help you today?`}],placeholder:`Type your message...`,showTimestamp:!1,disabled:!1,enableMarkdown:!0,enableFileUpload:!1,userAvatarFallback:`You`,assistantAvatarFallback:`AI`,maxHeight:`500px`,autoResponse:!0,autoResponseText:`Thank you for your message! This is an automated response.`,autoResponseDelay:1e3,className:`w-full max-w-2xl`}}),p.ComponentRegistry.register(`chatbot-floating`,({schema:e,className:t,...n})=>{let{messages:r,isLoading:a,error:o,sendMessage:s,stop:c,reload:l,clear:u,isApiMode:d}=w({api:e.api,initialMessages:e.messages,conversationId:e.conversationId,systemPrompt:e.systemPrompt,model:e.model,streamingEnabled:e.streamingEnabled,headers:e.headers,body:e.requestBody,maxToolRoundtrips:e.maxToolRoundtrips,onError:e.onError,showTimestamp:e.showTimestamp,autoResponse:e.autoResponse,autoResponseText:e.autoResponseText,autoResponseDelay:e.autoResponseDelay,onSend:e.onSend});return(0,i.jsx)(F,{floatingConfig:e.floatingConfig,messages:r,placeholder:e.placeholder,onSendMessage:(e,t)=>{s(e,t)},onClear:()=>{u(),e.onClear?.()},onStop:d&&a?c:void 0,onReload:d?l:void 0,disabled:e.disabled,isLoading:a,error:o,showTimestamp:e.showTimestamp,userAvatarUrl:e.userAvatarUrl,userAvatarFallback:e.userAvatarFallback,assistantAvatarUrl:e.assistantAvatarUrl,assistantAvatarFallback:e.assistantAvatarFallback,enableMarkdown:e.enableMarkdown??!0,enableFileUpload:e.enableFileUpload??!1,className:t,...n})},{namespace:`plugin-chatbot`,label:`Chatbot (Floating)`,inputs:[{name:`displayMode`,type:`string`,label:`Display Mode`,defaultValue:`floating`,description:`Set to "floating" for FAB widget`},{name:`floatingConfig.position`,type:`string`,label:`FAB Position`,defaultValue:`bottom-right`,description:`bottom-right or bottom-left`},{name:`floatingConfig.defaultOpen`,type:`boolean`,label:`Default Open`,defaultValue:!1},{name:`floatingConfig.panelWidth`,type:`number`,label:`Panel Width`,defaultValue:400},{name:`floatingConfig.panelHeight`,type:`number`,label:`Panel Height`,defaultValue:520},{name:`floatingConfig.title`,type:`string`,label:`Panel Title`,defaultValue:`Chat`},{name:`floatingConfig.triggerSize`,type:`number`,label:`Trigger Size`,defaultValue:56},{name:`messages`,type:`array`,label:`Initial Messages`},{name:`placeholder`,type:`string`,label:`Input Placeholder`,defaultValue:`Type your message...`},{name:`enableMarkdown`,type:`boolean`,label:`Enable Markdown`,defaultValue:!0},{name:`enableFileUpload`,type:`boolean`,label:`Enable File Upload`,defaultValue:!1},{name:`api`,type:`string`,label:`API Endpoint`,description:`Backend SSE endpoint for streaming AI mode`},{name:`conversationId`,type:`string`,label:`Conversation ID`},{name:`systemPrompt`,type:`string`,label:`System Prompt`},{name:`model`,type:`string`,label:`AI Model`},{name:`streamingEnabled`,type:`boolean`,label:`Enable Streaming`,defaultValue:!0},{name:`autoResponse`,type:`boolean`,label:`Enable Auto Response (Demo)`,defaultValue:!1},{name:`autoResponseText`,type:`string`,label:`Auto Response Text`,defaultValue:`Thank you for your message!`},{name:`autoResponseDelay`,type:`number`,label:`Auto Response Delay (ms)`,defaultValue:1e3},{name:`className`,type:`string`,label:`CSS Class`}],defaultProps:{displayMode:`floating`,floatingConfig:{position:`bottom-right`,defaultOpen:!1,panelWidth:400,panelHeight:520,title:`Chat`,triggerSize:56},messages:[{id:`welcome`,role:`assistant`,content:`Hello! How can I help you today?`}],placeholder:`Type your message...`,enableMarkdown:!0,enableFileUpload:!1,autoResponse:!0,autoResponseText:`Thank you for your message! This is an automated response.`,autoResponseDelay:1e3}});var I=t.forwardRef(({className:e,messages:a=[],placeholder:o=`Type your message...`,onSendMessage:s,disabled:c=!1,showTimestamp:l=!1,userAvatarUrl:u,userAvatarFallback:d=`You`,assistantAvatarUrl:f,assistantAvatarFallback:p=`AI`,maxHeight:m=`500px`,...h},g)=>{let[_,v]=t.useState(``),y=t.useRef(null),b=t.useRef(null);t.useEffect(()=>{if(y.current){let e=y.current.querySelector(`[data-radix-scroll-area-viewport]`);e&&(e.scrollTop=e.scrollHeight)}},[a]);let x=()=>{_.trim()&&s&&(s(_.trim()),v(``),b.current?.focus())},S=e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),x())};return(0,i.jsxs)(`div`,{ref:g,className:(0,n.cn)(`flex flex-col border rounded-lg bg-background overflow-hidden`,e),style:{maxHeight:m},...h,children:[(0,i.jsx)(n.ScrollArea,{ref:y,className:`flex-1 p-4`,children:(0,i.jsx)(`div`,{className:`space-y-4`,children:a.length===0?(0,i.jsx)(`div`,{className:`flex items-center justify-center h-32 text-muted-foreground text-sm`,children:`No messages yet. Start a conversation!`}):a.map(e=>(0,i.jsx)(L,{message:e,showTimestamp:l,userAvatarUrl:u,userAvatarFallback:d,assistantAvatarUrl:f,assistantAvatarFallback:p},e.id))})}),(0,i.jsx)(`div`,{className:`border-t p-4`,children:(0,i.jsxs)(`div`,{className:`flex gap-2`,children:[(0,i.jsx)(n.Input,{ref:b,value:_,onChange:e=>v(e.target.value),onKeyDown:S,placeholder:o,disabled:c,className:`flex-1`}),(0,i.jsx)(n.Button,{onClick:x,disabled:c||!_.trim(),size:`icon`,children:(0,i.jsx)(r.Send,{className:`h-4 w-4`})})]})})]})});I.displayName=`Chatbot`;var L=({message:e,showTimestamp:t,userAvatarUrl:r,userAvatarFallback:a,assistantAvatarUrl:o,assistantAvatarFallback:s})=>{let c=e.role===`user`;if(e.role===`system`)return(0,i.jsx)(`div`,{className:`flex justify-center`,children:(0,i.jsx)(`div`,{className:`text-xs text-muted-foreground bg-muted px-3 py-1 rounded-full`,children:e.content})});let l=c?e.avatar||r:e.avatar||o,u=c?e.avatarFallback||a:e.avatarFallback||s;return(0,i.jsxs)(`div`,{className:(0,n.cn)(`flex gap-3`,c?`flex-row-reverse`:`flex-row`),children:[(0,i.jsxs)(n.Avatar,{className:`h-8 w-8`,children:[(0,i.jsx)(n.AvatarImage,{src:l}),(0,i.jsx)(n.AvatarFallback,{className:`text-xs`,children:u})]}),(0,i.jsxs)(`div`,{className:(0,n.cn)(`flex flex-col gap-1`,c?`items-end`:`items-start`),children:[(0,i.jsx)(`div`,{className:(0,n.cn)(`rounded-lg px-4 py-2 max-w-[70%] break-words`,c?`bg-primary text-primary-foreground`:`bg-muted`),children:(0,i.jsx)(`p`,{className:`text-sm whitespace-pre-wrap`,children:e.content})}),t&&e.timestamp&&(0,i.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.timestamp})]})]})},R=t.forwardRef(({className:e,avatarSrc:t,avatarFallback:r=`AI`,...a},o)=>(0,i.jsxs)(`div`,{ref:o,className:(0,n.cn)(`flex gap-3`,e),...a,children:[(0,i.jsxs)(n.Avatar,{className:`h-8 w-8`,children:[(0,i.jsx)(n.AvatarImage,{src:t}),(0,i.jsx)(n.AvatarFallback,{className:`text-xs`,children:r})]}),(0,i.jsx)(`div`,{className:`flex items-center bg-muted rounded-lg px-4 py-2`,children:(0,i.jsxs)(`div`,{className:`flex gap-1`,children:[(0,i.jsx)(`span`,{className:`w-2 h-2 bg-muted-foreground rounded-full animate-bounce [animation-delay:-0.3s]`}),(0,i.jsx)(`span`,{className:`w-2 h-2 bg-muted-foreground rounded-full animate-bounce [animation-delay:-0.15s]`}),(0,i.jsx)(`span`,{className:`w-2 h-2 bg-muted-foreground rounded-full animate-bounce`})]})})]}));R.displayName=`TypingIndicator`,e.Chatbot=I,e.FloatingChatbot=F,e.FloatingChatbotPanel=M,e.FloatingChatbotProvider=O,e.FloatingChatbotTrigger=j,e.TypingIndicator=R,e.useAgents=E,e.useFloatingChatbot=k,e.useObjectChat=w});
@@ -1 +1 @@
1
- {"version":3,"file":"FloatingChatbotTrigger.d.ts","sourceRoot":"","sources":["../../../../src/FloatingChatbotTrigger.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAQH,MAAM,WAAW,2BAA2B;IAC1C,0BAA0B;IAC1B,QAAQ,CAAC,EAAE,cAAc,GAAG,aAAa,CAAA;IACzC,2CAA2C;IAC3C,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,uBAAuB;IACvB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,EACrC,QAAyB,EACzB,IAAS,EACT,SAAS,GACV,EAAE,2BAA2B,2CAuB7B"}
1
+ {"version":3,"file":"FloatingChatbotTrigger.d.ts","sourceRoot":"","sources":["../../../../src/FloatingChatbotTrigger.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAqBH,MAAM,WAAW,2BAA2B;IAC1C,0BAA0B;IAC1B,QAAQ,CAAC,EAAE,cAAc,GAAG,aAAa,CAAA;IACzC,2CAA2C;IAC3C,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,uBAAuB;IACvB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,EACrC,QAAyB,EACzB,IAAS,EACT,SAAS,GACV,EAAE,2BAA2B,2CAwB7B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@object-ui/plugin-chatbot",
3
- "version": "4.0.7",
3
+ "version": "4.0.9",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "description": "Chatbot interface plugin for Object UI",
@@ -24,16 +24,16 @@
24
24
  }
25
25
  },
26
26
  "dependencies": {
27
- "@ai-sdk/react": "^3.0.176",
28
- "ai": "^6.0.174",
27
+ "@ai-sdk/react": "^3.0.179",
28
+ "ai": "^6.0.177",
29
29
  "lucide-react": "^1.14.0",
30
30
  "react-markdown": "^10.1.0",
31
31
  "react-syntax-highlighter": "^16.1.1",
32
32
  "remark-gfm": "^4.0.1",
33
- "@object-ui/components": "4.0.7",
34
- "@object-ui/core": "4.0.7",
35
- "@object-ui/react": "4.0.7",
36
- "@object-ui/types": "4.0.7"
33
+ "@object-ui/components": "4.0.9",
34
+ "@object-ui/core": "4.0.9",
35
+ "@object-ui/react": "4.0.9",
36
+ "@object-ui/types": "4.0.9"
37
37
  },
38
38
  "peerDependencies": {
39
39
  "react": "^18.0.0 || ^19.0.0",
@@ -45,7 +45,7 @@
45
45
  "@types/react-syntax-highlighter": "^15.5.13",
46
46
  "@vitejs/plugin-react": "^6.0.1",
47
47
  "typescript": "^6.0.3",
48
- "vite": "^8.0.10",
48
+ "vite": "^8.0.12",
49
49
  "vite-plugin-dts": "^5.0.0"
50
50
  },
51
51
  "keywords": [