@opentiny/tiny-robot 0.4.0-alpha.6 → 0.4.0-alpha.7

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/index2.js CHANGED
@@ -1,7 +1,7 @@
1
- import { defineComponent as E, createElementBlock as x, openBlock as b, renderSlot as B, ref as T, computed as v, watch as H, unref as R, normalizeClass as U, createVNode as z, watchEffect as Z, nextTick as ne, Fragment as D, createElementVNode as h, createBlock as k, withDirectives as ee, toDisplayString as V, vShow as te, resolveDynamicComponent as J, normalizeProps as F, guardReactiveProps as G, createCommentVNode as le, useCssModule as Je, renderList as j, mergeProps as P, markRaw as w, inject as L, provide as $, toValue as S, reactive as We, readonly as je, withCtx as M, onMounted as ye, onUnmounted as ze } from "vue";
1
+ import { defineComponent as k, openBlock as _, createElementBlock as R, renderSlot as B, ref as T, computed as h, watch as H, unref as C, normalizeClass as U, createVNode as V, watchEffect as Q, nextTick as se, Fragment as w, createElementVNode as y, toDisplayString as X, withDirectives as te, vShow as ne, createBlock as S, resolveDynamicComponent as J, normalizeProps as D, guardReactiveProps as G, createCommentVNode as le, useCssModule as Je, renderList as z, mergeProps as F, markRaw as O, inject as L, provide as $, toValue as I, reactive as We, readonly as je, withCtx as M, onMounted as ye, onUnmounted as ze } from "vue";
2
2
  import { _ as A } from "./_plugin-vue_export-helper.js";
3
- import { IconLoading as Re, IconAtom as Ve, IconArrowDown as xe, IconPlugin as _e, IconError as Xe, IconCancelled as qe } from "@opentiny/tiny-robot-svgs";
4
- import { u as Ze, a as Qe, w as et, b as tt } from "./index5.js";
3
+ import { IconLoading as xe, IconAtom as Ve, IconArrowDown as Re, IconPlugin as me, IconError as Xe, IconCancelled as qe } from "@opentiny/tiny-robot-svgs";
4
+ import { u as Ze, w as Qe, a as et, b as tt } from "./index5.js";
5
5
  const Be = Symbol("bubble-message-group"), Ce = Symbol("bubble-box-renderer-matches"), Ee = Symbol("bubble-box-fallback-renderer"), ke = Symbol(
6
6
  "bubble-box-prop-fallback-renderer"
7
7
  ), Ie = Symbol("bubble-content-renderer-matches"), Se = Symbol(
@@ -16,26 +16,26 @@ const Be = Symbol("bubble-message-group"), Ce = Symbol("bubble-box-renderer-matc
16
16
  }, nt = {
17
17
  class: "tr-bubble__box",
18
18
  "data-box-type": "box"
19
- }, st = /* @__PURE__ */ E({
19
+ }, st = /* @__PURE__ */ k({
20
20
  __name: "Box",
21
21
  props: {
22
22
  placement: {},
23
23
  shape: {}
24
24
  },
25
- setup(e) {
26
- return (t, n) => (b(), x("div", nt, [
27
- B(t.$slots, "default", {}, void 0, !0)
25
+ setup(t) {
26
+ return (e, n) => (_(), R("div", nt, [
27
+ B(e.$slots, "default", {}, void 0, !0)
28
28
  ]));
29
29
  }
30
- }), ce = /* @__PURE__ */ A(st, [["__scopeId", "data-v-98101726"]]), ot = ["src", "alt"], rt = /* @__PURE__ */ E({
30
+ }), ce = /* @__PURE__ */ A(st, [["__scopeId", "data-v-98101726"]]), ot = ["src", "alt"], rt = /* @__PURE__ */ k({
31
31
  __name: "Image",
32
32
  props: {
33
33
  message: {},
34
34
  contentIndex: {}
35
35
  },
36
- setup(e) {
37
- const t = e, n = T(!1), s = T(!1), { contentItem: r } = pe(t), u = v(() => r.value ? typeof r.value.image_url == "string" ? r.value.image_url : r.value.image_url.url : null);
38
- H(u, () => {
36
+ setup(t) {
37
+ const e = t, n = T(!1), s = T(!1), { content: r } = pe(e), f = h(() => r.value ? typeof r.value.image_url == "string" ? r.value.image_url : r.value.image_url.url : null);
38
+ H(f, () => {
39
39
  n.value = !1, s.value = !1;
40
40
  });
41
41
  const o = () => {
@@ -43,12 +43,12 @@ const Be = Symbol("bubble-message-group"), Ce = Symbol("bubble-box-renderer-matc
43
43
  }, a = () => {
44
44
  s.value = !0, n.value = !0;
45
45
  };
46
- return (d, g) => {
47
- var y;
48
- return b(), x("img", {
46
+ return (i, b) => {
47
+ var g;
48
+ return _(), R("img", {
49
49
  class: U(["tr-bubble__image", { loading: !n.value }]),
50
- src: u.value,
51
- alt: (y = R(r)) == null ? void 0 : y.text,
50
+ src: f.value,
51
+ alt: (g = C(r)) == null ? void 0 : g.text,
52
52
  loading: "lazy",
53
53
  onLoad: o,
54
54
  onError: a,
@@ -56,83 +56,83 @@ const Be = Symbol("bubble-message-group"), Ce = Symbol("bubble-box-renderer-matc
56
56
  }, null, 42, ot);
57
57
  };
58
58
  }
59
- }), $e = /* @__PURE__ */ A(rt, [["__scopeId", "data-v-02161cd1"]]), at = {
59
+ }), $e = /* @__PURE__ */ A(rt, [["__scopeId", "data-v-e59794cb"]]), at = {
60
60
  class: "tr-bubble__loading",
61
61
  "data-type": "loading"
62
- }, lt = /* @__PURE__ */ E({
62
+ }, lt = /* @__PURE__ */ k({
63
63
  __name: "Loading",
64
64
  props: {
65
65
  message: {},
66
66
  contentIndex: {}
67
67
  },
68
- setup(e) {
69
- return (t, n) => (b(), x("div", at, [
70
- z(R(Re))
68
+ setup(t) {
69
+ return (e, n) => (_(), R("div", at, [
70
+ V(C(xe))
71
71
  ]));
72
72
  }
73
73
  }), Ae = /* @__PURE__ */ A(lt, [["__scopeId", "data-v-bc1b5ff4"]]), ct = {
74
74
  class: "tr-bubble__reasoning",
75
75
  "data-type": "reasoning"
76
- }, ut = { class: "title" }, it = { class: "detail" }, dt = /* @__PURE__ */ E({
76
+ }, ut = { class: "title" }, it = { class: "detail" }, dt = /* @__PURE__ */ k({
77
77
  __name: "Reasoning",
78
78
  props: {
79
79
  message: {},
80
80
  contentIndex: {}
81
81
  },
82
- setup(e) {
83
- const t = e, { restMessage: n, restProps: s } = Ye(t, ["reasoning_content"]), r = ie(n, t.contentIndex), u = T(!1);
84
- Z(() => {
85
- var g;
86
- u.value = ((g = t.message.state) == null ? void 0 : g.open) ?? !1;
82
+ setup(t) {
83
+ const e = t, { restMessage: n, restProps: s } = Ye(e, ["reasoning_content"]), r = ie(n, e.contentIndex), f = T(!1);
84
+ Q(() => {
85
+ var b;
86
+ f.value = ((b = e.message.state) == null ? void 0 : b.open) ?? !1;
87
87
  });
88
88
  const o = Ke(), a = () => {
89
- u.value = !u.value, o("open", u.value);
90
- }, d = T(null);
89
+ f.value = !f.value, o("open", f.value);
90
+ }, i = T(null);
91
91
  return H(
92
- () => t.message.reasoning_content,
92
+ () => e.message.reasoning_content,
93
93
  () => {
94
- ne(() => {
95
- d.value && d.value.scrollTo({
96
- top: d.value.scrollHeight,
94
+ se(() => {
95
+ i.value && i.value.scrollTo({
96
+ top: i.value.scrollHeight,
97
97
  behavior: "smooth"
98
98
  });
99
99
  });
100
100
  }
101
- ), (g, y) => {
102
- var C, f;
103
- return b(), x(D, null, [
104
- h("div", ct, [
105
- h("div", {
101
+ ), (b, g) => {
102
+ var x, m;
103
+ return _(), R(w, null, [
104
+ y("div", ct, [
105
+ y("div", {
106
106
  class: "header",
107
107
  onClick: a
108
108
  }, [
109
- h("div", {
110
- class: U(["icon-and-text", { thinking: (C = t.message.state) == null ? void 0 : C.thinking }])
109
+ y("div", {
110
+ class: U(["icon-and-text", { thinking: (x = e.message.state) == null ? void 0 : x.thinking }])
111
111
  }, [
112
- z(R(Ve)),
113
- h("span", ut, V((f = t.message.state) != null && f.thinking ? "正在思考" : "已思考"), 1)
112
+ V(C(Ve)),
113
+ y("span", ut, X((m = e.message.state) != null && m.thinking ? "正在思考" : "已思考"), 1)
114
114
  ], 2),
115
- z(R(xe), {
116
- class: U(["expand-icon", { "-rotate-90": !u.value }])
115
+ V(C(Re), {
116
+ class: U(["expand-icon", { "-rotate-90": !f.value }])
117
117
  }, null, 8, ["class"])
118
118
  ]),
119
- ee(h("div", it, [
120
- y[0] || (y[0] = h("div", { class: "side-border" }, [
121
- h("div", { class: "dot-wrapper" }, [
122
- h("div", { class: "dot" })
119
+ te(y("div", it, [
120
+ g[0] || (g[0] = y("div", { class: "side-border" }, [
121
+ y("div", { class: "dot-wrapper" }, [
122
+ y("div", { class: "dot" })
123
123
  ]),
124
- h("div", { class: "border-line" })
124
+ y("div", { class: "border-line" })
125
125
  ], -1)),
126
- h("p", {
126
+ y("p", {
127
127
  class: "detail-content",
128
128
  ref_key: "detailRef",
129
- ref: d
130
- }, V(t.message.reasoning_content), 513)
129
+ ref: i
130
+ }, X(e.message.reasoning_content), 513)
131
131
  ], 512), [
132
- [te, u.value]
132
+ [ne, f.value]
133
133
  ])
134
134
  ]),
135
- (b(), k(J(R(r)), F(G(R(s))), null, 16))
135
+ (_(), S(J(C(r)), D(G(C(s))), null, 16))
136
136
  ], 64);
137
137
  };
138
138
  }
@@ -140,291 +140,288 @@ const Be = Symbol("bubble-message-group"), Ce = Symbol("bubble-box-renderer-matc
140
140
  key: 0,
141
141
  class: "tr-bubble__text",
142
142
  "data-type": "text"
143
- }, pt = /* @__PURE__ */ E({
143
+ }, pt = /* @__PURE__ */ k({
144
144
  __name: "Text",
145
145
  props: {
146
146
  message: {},
147
147
  contentIndex: {}
148
148
  },
149
- setup(e) {
150
- const t = e, { contentText: n } = pe(t);
151
- return (s, r) => R(n) ? (b(), x("p", ft, V(R(n)), 1)) : le("", !0);
149
+ setup(t) {
150
+ const e = t, { contentText: n } = pe(e);
151
+ return (s, r) => C(n) ? (_(), R("p", ft, X(C(n)), 1)) : le("", !0);
152
152
  }
153
- }), ue = /* @__PURE__ */ A(pt, [["__scopeId", "data-v-93592ecb"]]), Oe = /* @__PURE__ */ E({
153
+ }), ue = /* @__PURE__ */ A(pt, [["__scopeId", "data-v-93592ecb"]]), Oe = /* @__PURE__ */ k({
154
154
  __name: "ToolRole",
155
155
  props: {
156
156
  message: {},
157
157
  contentIndex: {}
158
158
  },
159
- setup(e) {
160
- const t = e, n = fe();
161
- return Z(() => {
162
- t.message.tool_call_id && (n.toolCallResults || (n.toolCallResults = {}), n.toolCallResults[t.message.tool_call_id] = t.message.content ?? "");
159
+ setup(t) {
160
+ const e = t, n = fe();
161
+ return Q(() => {
162
+ e.message.tool_call_id && (n.toolCallResults || (n.toolCallResults = {}), n.toolCallResults[e.message.tool_call_id] = e.message.content ?? "");
163
163
  }), (s, r) => le("", !0);
164
164
  }
165
165
  }), mt = {
166
166
  class: "tr-bubble__tool-call",
167
167
  "data-type": "tool-call"
168
- }, _t = { class: "header" }, bt = { class: "header-left" }, gt = { class: "title" }, vt = { class: "header-right" }, ht = { class: "divider" }, yt = ["innerHTML"], Rt = /* @__PURE__ */ E({
168
+ }, _t = { class: "header" }, bt = { class: "header-left" }, gt = { class: "title" }, vt = { class: "header-right" }, ht = { class: "divider" }, yt = ["innerHTML"], xt = /* @__PURE__ */ k({
169
169
  __name: "Tool",
170
170
  props: {
171
171
  message: {},
172
172
  contentIndex: {},
173
173
  toolCallIndex: {}
174
174
  },
175
- setup(e) {
176
- const t = e, { toolCall: n, toolCallWithResult: s, state: r } = Ft(t), u = /* @__PURE__ */ new Map([
177
- ["running", { text: "正在调用", icon: Re }],
178
- ["success", { text: "已调用", icon: _e }],
175
+ setup(t) {
176
+ const e = t, { toolCall: n, toolCallWithResult: s, state: r } = Ft(e), f = /* @__PURE__ */ new Map([
177
+ ["running", { text: "正在调用", icon: xe }],
178
+ ["success", { text: "已调用", icon: me }],
179
179
  ["failed", { text: "调用失败", icon: Xe }],
180
180
  ["cancelled", { text: "已取消", icon: qe }]
181
- ]), o = v(() => {
182
- var c;
183
- return u.get(((c = r.value) == null ? void 0 : c.status) || "") || { text: "", icon: _e };
184
- }), a = (c, l = 2) => {
185
- let m = "";
181
+ ]), o = h(() => {
182
+ var l;
183
+ return f.get(((l = r.value) == null ? void 0 : l.status) || "") || { text: "", icon: me };
184
+ }), a = (l, c = 2) => {
185
+ let p = "";
186
186
  try {
187
- typeof c == "string" ? m = JSON.stringify(JSON.parse(c), null, l) : m = JSON.stringify(c, null, l);
187
+ typeof l == "string" ? p = JSON.stringify(JSON.parse(l), null, c) : p = JSON.stringify(l, null, c);
188
188
  } catch {
189
189
  }
190
- return m;
191
- }, d = Je(), g = (c) => {
192
- if (!c)
190
+ return p;
191
+ }, i = Je(), b = (l) => {
192
+ if (!l)
193
193
  return "";
194
- let l = c;
195
- return l = l.replace(
194
+ let c = l;
195
+ return c = c.replace(
196
196
  /("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?)/g,
197
- (m) => {
198
- let I = "number";
199
- return /^"/.test(m) ? I = /:$/.test(m) ? "key" : "string" : /true|false/.test(m) ? I = "boolean" : /null/.test(m) && (I = "null"), `<span class="${d[I]}">${m}</span>`;
197
+ (p) => {
198
+ let E = "number";
199
+ return /^"/.test(p) ? E = /:$/.test(p) ? "key" : "string" : /true|false/.test(p) ? E = "boolean" : /null/.test(p) && (E = "null"), `<span class="${i[E]}">${p}</span>`;
200
200
  }
201
- ), l;
202
- }, y = v(() => a(s.value, 2)), C = v(() => g(y.value)), f = T(null);
203
- H(y, (c, l) => {
204
- l === "" || l === "{}" || ne(() => {
205
- f.value && f.value.scrollTo({
206
- top: f.value.scrollHeight,
201
+ ), c;
202
+ }, g = h(() => a(s.value, 2)), x = h(() => b(g.value)), m = T(null);
203
+ H(g, (l, c) => {
204
+ c === "" || c === "{}" || se(() => {
205
+ m.value && m.value.scrollTo({
206
+ top: m.value.scrollHeight,
207
207
  behavior: "smooth"
208
208
  });
209
209
  });
210
210
  });
211
- const p = T(!1);
212
- Z(() => {
213
- p.value = r.value.open ?? !1;
211
+ const d = T(!1);
212
+ Q(() => {
213
+ d.value = r.value.open ?? !1;
214
214
  });
215
- const i = Ke(), _ = () => {
216
- var l, m;
217
- p.value = !p.value;
218
- const c = (l = n.value) == null ? void 0 : l.id;
219
- c && i("toolCall", {
220
- ...(m = t.message.state) == null ? void 0 : m.toolCall,
221
- [c]: { ...r.value, open: p.value }
215
+ const u = Ke(), v = () => {
216
+ var c, p;
217
+ d.value = !d.value;
218
+ const l = (c = n.value) == null ? void 0 : c.id;
219
+ l && u("toolCall", {
220
+ ...(p = e.message.state) == null ? void 0 : p.toolCall,
221
+ [l]: { ...r.value, open: d.value }
222
222
  });
223
223
  };
224
- return (c, l) => {
225
- var m;
226
- return b(), x("div", mt, [
227
- h("div", _t, [
228
- h("div", bt, [
229
- (b(), k(J(o.value.icon), {
230
- class: U(["header-icon", `icon-${R(r).status}`])
224
+ return (l, c) => {
225
+ var p;
226
+ return _(), R("div", mt, [
227
+ y("div", _t, [
228
+ y("div", bt, [
229
+ (_(), S(J(o.value.icon), {
230
+ class: U(["header-icon", `icon-${C(r).status}`])
231
231
  }, null, 8, ["class"])),
232
- h("span", null, [
233
- h("span", null, V(o.value.text) + " ", 1),
234
- h("span", gt, V(((m = R(n)) == null ? void 0 : m.function.name) || "Untitled"), 1)
232
+ y("span", null, [
233
+ y("span", null, X(o.value.text) + " ", 1),
234
+ y("span", gt, X(((p = C(n)) == null ? void 0 : p.function.name) || "Untitled"), 1)
235
235
  ])
236
236
  ]),
237
- h("div", vt, [
238
- z(R(xe), {
239
- class: U(["expand-icon", { "-rotate-90": !p.value }]),
240
- onClick: _
237
+ y("div", vt, [
238
+ V(C(Re), {
239
+ class: U(["expand-icon", { "-rotate-90": !d.value }]),
240
+ onClick: v
241
241
  }, null, 8, ["class"])
242
242
  ])
243
243
  ]),
244
- ee(h("div", ht, null, 512), [
245
- [te, p.value]
244
+ te(y("div", ht, null, 512), [
245
+ [ne, d.value]
246
246
  ]),
247
- ee(h("div", {
247
+ te(y("div", {
248
248
  class: "detail",
249
- innerHTML: C.value,
249
+ innerHTML: x.value,
250
250
  ref_key: "detailRef",
251
- ref: f
251
+ ref: m
252
252
  }, null, 8, yt), [
253
- [te, p.value]
253
+ [ne, d.value]
254
254
  ])
255
255
  ]);
256
256
  };
257
257
  }
258
- }), xt = "_key_1b448_2", Bt = "_number_1b448_6", Ct = "_string_1b448_10", Et = "_boolean_1b448_14", kt = {
259
- key: xt,
258
+ }), Rt = "_key_1b448_2", Bt = "_number_1b448_6", Ct = "_string_1b448_10", Et = "_boolean_1b448_14", kt = {
259
+ key: Rt,
260
260
  number: Bt,
261
261
  string: Ct,
262
262
  boolean: Et,
263
263
  null: "_null_1b448_18"
264
264
  }, It = {
265
265
  $style: kt
266
- }, we = /* @__PURE__ */ A(Rt, [["__cssModules", It], ["__scopeId", "data-v-9d7f5409"]]), De = /* @__PURE__ */ E({
266
+ }, we = /* @__PURE__ */ A(xt, [["__cssModules", It], ["__scopeId", "data-v-9d7f5409"]]), De = /* @__PURE__ */ k({
267
267
  __name: "Tools",
268
268
  props: {
269
269
  message: {},
270
270
  contentIndex: {}
271
271
  },
272
- setup(e) {
273
- const t = e, { restMessage: n, restProps: s } = Ye(t, ["tool_calls"]), r = ie(n, t.contentIndex);
274
- return (u, o) => (b(), x(D, null, [
275
- (b(), k(J(R(r)), F(G(R(s))), null, 16)),
276
- (b(!0), x(D, null, j(t.message.tool_calls, (a, d) => (b(), k(we, P({
272
+ setup(t) {
273
+ const e = t, { restMessage: n, restProps: s } = Ye(e, ["tool_calls"]), r = ie(n, e.contentIndex);
274
+ return (f, o) => (_(), R(w, null, [
275
+ (_(), S(J(C(r)), D(G(C(s))), null, 16)),
276
+ (_(!0), R(w, null, z(e.message.tool_calls, (a, i) => (_(), S(we, F({
277
277
  key: a.id
278
- }, { ref_for: !0 }, t, { "tool-call-index": d }), null, 16, ["tool-call-index"]))), 128))
278
+ }, { ref_for: !0 }, e, { "tool-call-index": i }), null, 16, ["tool-call-index"]))), 128))
279
279
  ], 64));
280
280
  }
281
281
  }), Fe = [
282
282
  {
283
- find: (e, t, n) => {
284
- const s = t.at(0);
285
- return t.length === 1 && Array.isArray(s) && typeof n == "number" && s[n].type === "image_url";
286
- },
287
- renderer: w(ce),
283
+ find: (t, e) => (e == null ? void 0 : e.type) === "image_url",
284
+ renderer: O(ce),
288
285
  priority: K.NORMAL,
289
286
  attributes: { "data-box-type": "image" }
290
287
  }
291
288
  ], Pe = [
292
289
  {
293
- find: (e) => !!e.loading,
294
- renderer: w(Ae),
290
+ find: (t) => !!t.loading,
291
+ renderer: O(Ae),
295
292
  priority: K.LOADING
296
293
  },
297
294
  {
298
- find: (e) => typeof e.reasoning_content == "string",
299
- renderer: w(Ne),
295
+ find: (t) => typeof t.reasoning_content == "string",
296
+ renderer: O(Ne),
300
297
  priority: K.NORMAL
301
298
  },
302
299
  {
303
- find: (e) => Array.isArray(e.tool_calls) && e.tool_calls.length > 0,
304
- renderer: w(De),
300
+ find: (t) => Array.isArray(t.tool_calls) && t.tool_calls.length > 0,
301
+ renderer: O(De),
305
302
  priority: K.NORMAL
306
303
  },
307
304
  {
308
- find: (e, t, n) => Array.isArray(t) && typeof n == "number" && t[n].type === "image_url",
309
- renderer: w($e),
305
+ find: (t, e) => e.type === "image_url",
306
+ renderer: O($e),
310
307
  priority: K.CONTENT
311
308
  },
312
309
  {
313
- find: (e) => e.role === "tool",
314
- renderer: w(Oe),
310
+ find: (t) => t.role === "tool",
311
+ renderer: O(Oe),
315
312
  priority: K.ROLE
316
313
  }
317
- ], Ge = w(ce), He = w(ue), be = Symbol("BUBBLE_CONTENT_RESOLVER_KEY"), Q = (e) => {
318
- const t = L(be, void 0), n = t ?? e;
319
- return !t && e && $(be, e), n ? (r) => {
320
- const u = S(n);
321
- return u == null ? void 0 : u(r);
314
+ ], Ge = O(ce), He = O(ue), _e = Symbol("BUBBLE_CONTENT_RESOLVER_KEY"), ee = (t) => {
315
+ const e = L(_e, void 0), n = e ?? t;
316
+ return !e && t && $(_e, t), n ? (r) => {
317
+ const f = I(n);
318
+ return f == null ? void 0 : f(r);
322
319
  } : (r) => r.content;
323
320
  };
324
- function St(e) {
325
- const { boxRendererMatches: t, fallbackBoxRenderer: n } = e;
326
- t && $(Ce, t), n && $(Ee, n);
321
+ function St(t) {
322
+ const { boxRendererMatches: e, fallbackBoxRenderer: n } = t;
323
+ e && $(Ce, e), n && $(Ee, n);
327
324
  }
328
- function Lt(e) {
329
- const { fallbackBoxRenderer: t } = e;
330
- t && $(ke, t);
325
+ function Lt(t) {
326
+ const { fallbackBoxRenderer: e } = t;
327
+ e && $(ke, e);
331
328
  }
332
- function Tt(e, t) {
333
- const n = L(Ce, Fe), s = L(Ee, void 0), r = L(ke, void 0), u = Q();
334
- return v(() => {
335
- const o = S(e), a = S(n).find(
336
- (d) => d.find(
337
- o,
338
- o.map((g) => u(g)),
339
- t
340
- )
341
- );
342
- return a ? {
343
- renderer: a.renderer,
344
- attributes: a.attributes
329
+ function Tt(t, e) {
330
+ const n = L(Ce, Fe), s = L(Ee, void 0), r = L(ke, void 0), f = ee();
331
+ if (typeof e == "number" && I(t).length !== 1)
332
+ throw new Error("[BubbleBoxRenderer] When contentIndex is a number, messages array length must be 1");
333
+ const o = (a) => {
334
+ if (a.length !== 1)
335
+ return { content: void 0, index: void 0 };
336
+ const i = f(a.at(0));
337
+ return {
338
+ content: Array.isArray(i) ? i.at(e ?? 0) : { type: "text", text: i || "" },
339
+ index: e ?? 0
340
+ };
341
+ };
342
+ return h(() => {
343
+ const a = I(t), { content: i, index: b } = o(a), g = I(n).find((x) => x.find(a, i, b));
344
+ return g ? {
345
+ renderer: g.renderer,
346
+ attributes: g.attributes
345
347
  } : {
346
- renderer: S(r) || S(s) || Ge
348
+ renderer: I(r) || I(s) || Ge
347
349
  };
348
350
  });
349
351
  }
350
- function Mt(e) {
351
- const { contentRendererMatches: t, fallbackContentRenderer: n } = e;
352
- t && $(Ie, t), n && $(Se, n);
352
+ function Mt(t) {
353
+ const { contentRendererMatches: e, fallbackContentRenderer: n } = t;
354
+ e && $(Ie, e), n && $(Se, n);
353
355
  }
354
- function $t(e) {
355
- const { fallbackContentRenderer: t } = e;
356
- t && $(Le, t);
356
+ function $t(t) {
357
+ const { fallbackContentRenderer: e } = t;
358
+ e && $(Le, e);
357
359
  }
358
- function ie(e, t) {
359
- const n = L(Ie, Pe), s = L(Se, void 0), r = L(Le, void 0), u = Q();
360
- return v(() => {
361
- const o = S(e), a = S(n).find((d) => d.find(o, u(o), t));
362
- return a ? a.renderer : S(r) || S(s) || He;
360
+ function ie(t, e) {
361
+ const n = L(Ie, Pe), s = L(Se, void 0), r = L(Le, void 0), f = ee();
362
+ return h(() => {
363
+ const o = I(t), a = f(o), i = Array.isArray(a) ? a.at(e ?? 0) : { type: "text", text: a || "" }, b = I(n).find((g) => g.find(o, i, e));
364
+ return b ? b.renderer : I(r) || I(s) || He;
363
365
  });
364
366
  }
365
- function At(e) {
366
- $(Te, e);
367
+ function At(t) {
368
+ $(Te, t);
367
369
  }
368
370
  function Ke() {
369
- return L(Te, (e, t) => {
370
- console.warn(`[Bubble] State change function not found for key: ${e}`);
371
+ return L(Te, (t, e) => {
372
+ console.warn(`[Bubble] State change function not found for key: ${t}`);
371
373
  });
372
374
  }
373
- function de(e) {
374
- const t = L(ae, void 0);
375
- if (t)
376
- return t;
377
- const n = We(e || {});
375
+ function de(t) {
376
+ const e = L(ae, void 0);
377
+ if (e)
378
+ return e;
379
+ const n = We(t || {});
378
380
  return $(ae, n), n;
379
381
  }
380
382
  function fe() {
381
383
  return L(ae, {});
382
384
  }
383
- function Ue(e) {
384
- let t = null;
385
- t = H(
386
- e,
385
+ function Ue(t) {
386
+ let e = null;
387
+ e = H(
388
+ t,
387
389
  (n) => {
388
- t && (t(), t = null), n && n.addEventListener("copy", (s) => {
390
+ e && (e(), e = null), n && n.addEventListener("copy", (s) => {
389
391
  var o;
390
392
  const r = window.getSelection();
391
393
  if (!n.contains((r == null ? void 0 : r.anchorNode) || null)) return;
392
394
  s.preventDefault();
393
- const u = (r == null ? void 0 : r.toString().replace(/\n{2,}/g, `
395
+ const f = (r == null ? void 0 : r.toString().replace(/\n{2,}/g, `
394
396
  `)) || "";
395
- (o = s.clipboardData) == null || o.setData("text/plain", u);
397
+ (o = s.clipboardData) == null || o.setData("text/plain", f);
396
398
  });
397
399
  },
398
400
  { immediate: !0, flush: "post" }
399
401
  );
400
402
  }
401
- const pe = (e) => {
402
- const t = Q(), n = v(() => t(e.message)), s = v(() => {
403
- const u = n.value;
404
- return Array.isArray(u) ? u.at(e.contentIndex ?? 0) : void 0;
405
- }), r = v(() => {
406
- var o;
407
- const u = n.value;
408
- return Array.isArray(u) ? String(((o = u.at(e.contentIndex ?? 0)) == null ? void 0 : o.text) || "") : u || "";
409
- });
403
+ const pe = (t) => {
404
+ const e = ee(), n = h(() => {
405
+ const r = e(t.message);
406
+ return Array.isArray(r) ? r.at(t.contentIndex) : { type: "text", text: r || "" };
407
+ }), s = h(() => n.value.type === "text" ? String(n.value.text) : "");
410
408
  return {
411
409
  content: n,
412
- contentItem: s,
413
- contentText: r
410
+ contentText: s
414
411
  };
415
412
  };
416
- function Nt(e) {
417
- $(Be, e);
413
+ function Nt(t) {
414
+ $(Be, t);
418
415
  }
419
416
  function Ot() {
420
417
  return L(Be, void 0);
421
418
  }
422
- function Ye(e, t) {
423
- const n = v(() => {
424
- const r = Object.entries(e.message).filter(([u]) => !t.includes(u));
419
+ function Ye(t, e) {
420
+ const n = h(() => {
421
+ const r = Object.entries(t.message).filter(([f]) => !e.includes(f));
425
422
  return Object.fromEntries(r);
426
- }), s = v(() => ({
427
- ...e,
423
+ }), s = h(() => ({
424
+ ...t,
428
425
  message: n.value
429
426
  }));
430
427
  return {
@@ -432,64 +429,64 @@ function Ye(e, t) {
432
429
  restProps: s
433
430
  };
434
431
  }
435
- let oe = null;
436
- const wt = () => (oe || (oe = import("./index4.js")), oe);
437
- let W = null;
432
+ let re = null;
433
+ const wt = () => (re || (re = import("./index4.js")), re);
434
+ let j = null;
438
435
  const Dt = async () => {
439
- if (W)
440
- return W;
436
+ if (j)
437
+ return j;
441
438
  try {
442
- const [e, t] = await Promise.all([import("markdown-it"), import("dompurify")]);
443
- return W = { markdown: e.default, dompurify: t.default }, W;
439
+ const [t, e] = await Promise.all([import("markdown-it"), import("dompurify")]);
440
+ return j = { markdown: t.default, dompurify: e.default }, j;
444
441
  } catch {
445
- return console.warn("[BubbleMarkdownRenderer] install markdown-it and dompurify to use markdown renderer"), W = null, null;
442
+ return console.warn("[BubbleMarkdownRenderer] install markdown-it and dompurify to use markdown renderer"), j = null, null;
446
443
  }
447
- }, ge = ["running", "success", "failed", "cancelled"], Ft = (e) => {
448
- const t = v(() => {
444
+ }, be = ["running", "success", "failed", "cancelled"], Ft = (t) => {
445
+ const e = h(() => {
449
446
  var o, a;
450
- return (a = (o = e.message) == null ? void 0 : o.tool_calls) == null ? void 0 : a[e.toolCallIndex];
451
- }), n = fe(), s = v(() => {
452
- var y, C, f;
447
+ return (a = (o = t.message) == null ? void 0 : o.tool_calls) == null ? void 0 : a[t.toolCallIndex];
448
+ }), n = fe(), s = h(() => {
449
+ var g, x, m;
453
450
  let o = n.toolCallDefaultStatus;
454
- o && !ge.includes(o) && (o = void 0);
451
+ o && !be.includes(o) && (o = void 0);
455
452
  const a = n.toolCallDefaultOpen;
456
- let d = {
453
+ let i = {
457
454
  status: o,
458
455
  open: a
459
456
  };
460
- const g = (y = t.value) == null ? void 0 : y.id;
461
- if (g) {
462
- const p = (f = (C = e.message.state) == null ? void 0 : C.toolCall) == null ? void 0 : f[g];
463
- if (p) {
464
- const { status: i, open: _, ...c } = p;
465
- i && ge.includes(i) && (d.status = i), _ !== void 0 && (d.open = _), d = { ...d, ...c };
457
+ const b = (g = e.value) == null ? void 0 : g.id;
458
+ if (b) {
459
+ const d = (m = (x = t.message.state) == null ? void 0 : x.toolCall) == null ? void 0 : m[b];
460
+ if (d) {
461
+ const { status: u, open: v, ...l } = d;
462
+ u && be.includes(u) && (i.status = u), v !== void 0 && (i.open = v), i = { ...i, ...l };
466
463
  }
467
464
  }
468
- return d;
469
- }), r = v(() => {
470
- var a, d;
471
- const o = (a = t.value) == null ? void 0 : a.id;
465
+ return i;
466
+ }), r = h(() => {
467
+ var a, i;
468
+ const o = (a = e.value) == null ? void 0 : a.id;
472
469
  if (o)
473
- return (d = n.toolCallResults) == null ? void 0 : d[o];
474
- }), u = T({});
475
- return Z(() => {
476
- var d;
477
- const o = (d = t.value) == null ? void 0 : d.function.arguments, a = r.value;
478
- wt().then(({ jsonrepair: g }) => {
479
- const y = g(typeof o == "string" ? o || "{}" : JSON.stringify(o));
480
- u.value = {
481
- arguments: JSON.parse(y),
482
- result: a ? JSON.parse(g(a || "{}")) : void 0
470
+ return (i = n.toolCallResults) == null ? void 0 : i[o];
471
+ }), f = T({});
472
+ return Q(() => {
473
+ var i;
474
+ const o = (i = e.value) == null ? void 0 : i.function.arguments, a = r.value;
475
+ wt().then(({ jsonrepair: b }) => {
476
+ const g = b(typeof o == "string" ? o || "{}" : JSON.stringify(o));
477
+ f.value = {
478
+ arguments: JSON.parse(g),
479
+ result: a ? JSON.parse(b(a || "{}")) : void 0
483
480
  };
484
- }).catch((g) => {
485
- console.warn(g);
481
+ }).catch((b) => {
482
+ console.warn(b);
486
483
  });
487
484
  }), {
488
- toolCall: t,
489
- toolCallWithResult: je(u),
485
+ toolCall: e,
486
+ toolCallWithResult: je(f),
490
487
  state: s
491
488
  };
492
- }, ve = /* @__PURE__ */ E({
489
+ }, ge = /* @__PURE__ */ k({
493
490
  __name: "BubbleBoxWrapper",
494
491
  props: {
495
492
  role: {},
@@ -498,37 +495,37 @@ const Dt = async () => {
498
495
  messages: {},
499
496
  contentIndex: {}
500
497
  },
501
- setup(e) {
502
- const t = e, n = Tt(() => t.messages, t.contentIndex);
503
- return (s, r) => (b(), k(J(R(n).renderer), P({
504
- "data-role": t.role,
505
- "data-placement": t.placement,
506
- "data-shape": t.shape
507
- }, R(n).attributes), {
498
+ setup(t) {
499
+ const e = t, n = Tt(() => e.messages, e.contentIndex);
500
+ return (s, r) => (_(), S(J(C(n).renderer), F({
501
+ "data-role": e.role,
502
+ "data-placement": e.placement,
503
+ "data-shape": e.shape
504
+ }, C(n).attributes), {
508
505
  default: M(() => [
509
506
  B(s.$slots, "default")
510
507
  ]),
511
508
  _: 3
512
509
  }, 16, ["data-role", "data-placement", "data-shape"]));
513
510
  }
514
- }), re = /* @__PURE__ */ E({
511
+ }), ve = /* @__PURE__ */ k({
515
512
  __name: "BubbleContentWrapper",
516
513
  props: {
517
514
  message: {},
518
515
  contentIndex: {}
519
516
  },
520
517
  emits: ["state-change"],
521
- setup(e, { emit: t }) {
522
- const n = e, s = ie(() => n.message, n.contentIndex), r = t;
518
+ setup(t, { emit: e }) {
519
+ const n = t, s = ie(() => n.message, n.contentIndex), r = e;
523
520
  return At((o, a) => {
524
521
  r("state-change", {
525
522
  key: o,
526
523
  value: a,
527
524
  contentIndex: n.contentIndex
528
525
  });
529
- }), (o, a) => (b(), k(J(R(s)), F(G(n)), null, 16));
526
+ }), (o, a) => (_(), S(J(C(s)), D(G(n)), null, 16));
530
527
  }
531
- }), Pt = ["data-role", "data-placement"], Gt = { class: "tr-bubble__body" }, Ht = { class: "tr-bubble__content" }, Kt = { class: "tr-bubble__after" }, Ut = /* @__PURE__ */ E({
528
+ }), Pt = ["data-role", "data-placement"], Gt = { class: "tr-bubble__body" }, Ht = { class: "tr-bubble__content" }, Kt = { class: "tr-bubble__after" }, Ut = /* @__PURE__ */ k({
532
529
  __name: "Bubble",
533
530
  props: {
534
531
  content: {},
@@ -545,70 +542,73 @@ const Dt = async () => {
545
542
  placement: { default: "start" },
546
543
  shape: { default: "corner" },
547
544
  contentRenderMode: { default: "single" },
548
- contentResolver: { type: Function, default: (e) => e.content },
545
+ contentResolver: { type: Function, default: (t) => t.content },
549
546
  fallbackBoxRenderer: {},
550
547
  fallbackContentRenderer: {}
551
548
  },
552
549
  emits: ["state-change"],
553
- setup(e, { emit: t }) {
554
- const n = e, s = Q(() => n.contentResolver), r = t;
550
+ setup(t, { emit: e }) {
551
+ const n = t, s = ee(() => n.contentResolver), r = e;
555
552
  de();
556
- const u = Ot(), o = v(() => S(u)), a = v(() => {
557
- var O;
558
- if ((O = o.value) != null && O.messages.length)
553
+ const f = Ot(), o = h(() => I(f)), a = h(() => {
554
+ var W;
555
+ if ((W = o.value) != null && W.messages.length)
559
556
  return o.value.messages;
560
- const { role: f, content: p, reasoning_content: i, tool_calls: _, tool_call_id: c, name: l, id: m, loading: I, state: N } = n;
561
- return [{ role: f, content: p, reasoning_content: i, tool_calls: _, tool_call_id: c, name: l, id: m, loading: I, state: N }];
562
- });
557
+ const { role: d, content: u, reasoning_content: v, tool_calls: l, tool_call_id: c, name: p, id: E, loading: N, state: P } = n;
558
+ return [{ role: d, content: u, reasoning_content: v, tool_calls: l, tool_call_id: c, name: p, id: E, loading: N, state: P }];
559
+ }), i = (d) => {
560
+ const u = s(d);
561
+ return Array.isArray(u) ? u : [{ type: "text", text: u || "" }];
562
+ };
563
563
  Lt({ fallbackBoxRenderer: () => n.fallbackBoxRenderer }), $t({ fallbackContentRenderer: () => n.fallbackContentRenderer });
564
- const d = v(() => a.value.length === 0 ? !0 : n.hidden), g = v(() => {
564
+ const b = h(() => a.value.length === 0 ? !0 : n.hidden), g = h(() => {
565
565
  if (n.contentRenderMode === "split" && a.value.length === 1) {
566
- const f = s(a.value.at(0));
567
- if (Array.isArray(f))
568
- return f;
566
+ const d = s(a.value.at(0));
567
+ if (Array.isArray(d))
568
+ return d;
569
569
  }
570
570
  return null;
571
- }), y = L(Me, !1), C = T(null);
572
- return y || Ue(C), (f, p) => ee((b(), x("div", {
571
+ }), x = L(Me, !1), m = T(null);
572
+ return x || Ue(m), (d, u) => te((_(), R("div", {
573
573
  class: "tr-bubble",
574
574
  ref_key: "bubbleRef",
575
- ref: C,
575
+ ref: m,
576
576
  "data-role": n.role,
577
577
  "data-placement": n.placement
578
578
  }, [
579
- B(f.$slots, "prefix", {
579
+ B(d.$slots, "prefix", {
580
580
  messages: a.value,
581
- role: e.role
581
+ role: t.role
582
582
  }, void 0, !0),
583
- h("div", Gt, [
584
- n.avatar ? (b(), k(J(n.avatar), {
583
+ y("div", Gt, [
584
+ n.avatar ? (_(), S(J(n.avatar), {
585
585
  key: 0,
586
- class: U(["tr-bubble__avatar", f.$style["tr-bubble__avatar"]])
586
+ class: U(["tr-bubble__avatar", d.$style["tr-bubble__avatar"]])
587
587
  }, null, 8, ["class"])) : le("", !0),
588
- h("div", Ht, [
589
- g.value ? (b(!0), x(D, { key: 0 }, j(g.value, (i, _) => (b(), k(ve, {
590
- key: _,
588
+ y("div", Ht, [
589
+ g.value ? (_(!0), R(w, { key: 0 }, z(g.value, (v, l) => (_(), S(ge, {
590
+ key: l,
591
591
  class: "tr-bubble__box",
592
592
  role: n.role,
593
593
  placement: n.placement,
594
594
  shape: n.shape,
595
595
  messages: a.value,
596
- "content-index": _
596
+ "content-index": l
597
597
  }, {
598
598
  default: M(() => [
599
- z(re, {
599
+ V(ve, {
600
600
  message: a.value.at(0),
601
- "content-index": _,
602
- onStateChange: p[0] || (p[0] = (c) => r("state-change", { ...c, messageIndex: 0 }))
601
+ "content-index": l,
602
+ onStateChange: u[0] || (u[0] = (c) => r("state-change", { ...c, messageIndex: 0 }))
603
603
  }, null, 8, ["message", "content-index"]),
604
- B(f.$slots, "content-footer", {
604
+ B(d.$slots, "content-footer", {
605
605
  messages: a.value,
606
606
  role: n.role,
607
- contentIndex: _
607
+ contentIndex: l
608
608
  }, void 0, !0)
609
609
  ]),
610
610
  _: 2
611
- }, 1032, ["role", "placement", "shape", "messages", "content-index"]))), 128)) : (b(), k(ve, {
611
+ }, 1032, ["role", "placement", "shape", "messages", "content-index"]))), 128)) : (_(), S(ge, {
612
612
  key: 1,
613
613
  role: n.role,
614
614
  placement: n.placement,
@@ -616,21 +616,17 @@ const Dt = async () => {
616
616
  messages: a.value
617
617
  }, {
618
618
  default: M(() => [
619
- (b(!0), x(D, null, j(a.value, (i, _) => (b(), x(D, {
620
- key: `message-${_}`
619
+ (_(!0), R(w, null, z(a.value, (v, l) => (_(), R(w, {
620
+ key: `message-${l}`
621
621
  }, [
622
- Array.isArray(R(s)(i)) ? (b(!0), x(D, { key: 0 }, j(R(s)(i), (c, l) => (b(), k(re, {
623
- key: `content-${l}`,
624
- message: i,
625
- "content-index": l,
626
- onStateChange: (m) => r("state-change", { ...m, messageIndex: _ })
627
- }, null, 8, ["message", "content-index", "onStateChange"]))), 128)) : (b(), k(re, {
628
- key: 1,
629
- message: i,
630
- onStateChange: (c) => r("state-change", { ...c, messageIndex: _ })
631
- }, null, 8, ["message", "onStateChange"]))
622
+ (_(!0), R(w, null, z(i(v), (c, p) => (_(), S(ve, {
623
+ key: `content-${p}`,
624
+ message: v,
625
+ "content-index": p,
626
+ onStateChange: (E) => r("state-change", { ...E, messageIndex: l })
627
+ }, null, 8, ["message", "content-index", "onStateChange"]))), 128))
632
628
  ], 64))), 128)),
633
- B(f.$slots, "content-footer", {
629
+ B(d.$slots, "content-footer", {
634
630
  messages: a.value,
635
631
  role: n.role
636
632
  }, void 0, !0)
@@ -638,80 +634,80 @@ const Dt = async () => {
638
634
  _: 3
639
635
  }, 8, ["role", "placement", "shape", "messages"]))
640
636
  ]),
641
- h("div", Kt, [
642
- B(f.$slots, "after", {
637
+ y("div", Kt, [
638
+ B(d.$slots, "after", {
643
639
  messages: a.value,
644
- role: e.role
640
+ role: t.role
645
641
  }, void 0, !0)
646
642
  ])
647
643
  ]),
648
- B(f.$slots, "suffix", {
644
+ B(d.$slots, "suffix", {
649
645
  messages: a.value,
650
- role: e.role
646
+ role: t.role
651
647
  }, void 0, !0)
652
648
  ], 8, Pt)), [
653
- [te, !d.value]
649
+ [ne, !b.value]
654
650
  ]);
655
651
  }
656
652
  }), Yt = {
657
653
  "tr-bubble__avatar": "_tr-bubble__avatar_1r87c_2"
658
654
  }, Jt = {
659
655
  $style: Yt
660
- }, Y = /* @__PURE__ */ A(Ut, [["__cssModules", Jt], ["__scopeId", "data-v-9468260c"]]);
661
- function he(e, t) {
662
- const n = H(e, (s, r) => {
663
- r === !0 && s === !1 && (t(), n());
656
+ }, Y = /* @__PURE__ */ A(Ut, [["__cssModules", Jt], ["__scopeId", "data-v-2d927bba"]]);
657
+ function he(t, e) {
658
+ const n = H(t, (s, r) => {
659
+ r === !0 && s === !1 && (e(), n());
664
660
  });
665
661
  return n;
666
662
  }
667
- function Wt(e, t, n) {
668
- const { scrollOnMount: s = !0, bottomThreshold: r = 20, scrollThrottle: u = 0 } = n ?? {}, o = T(!0);
663
+ function Wt(t, e, n) {
664
+ const { scrollOnMount: s = !0, bottomThreshold: r = 20, scrollThrottle: f = 0 } = n ?? {}, o = T(!0);
669
665
  let a = !1;
670
- const d = /* @__PURE__ */ new Set(), g = () => Qe(e), { y, isScrolling: C, arrivedState: f } = Ze(g, { throttle: u }), p = (c) => c.scrollHeight - c.scrollTop - c.clientHeight <= r, i = async (c = "auto") => {
671
- const l = S(g);
672
- if (l && (await ne(), l.scrollTo({ top: l.scrollHeight, behavior: c }), c === "smooth" && !p(l))) {
673
- const m = he(C, () => {
674
- l.scrollTo({ top: l.scrollHeight, behavior: "auto" }), d.delete(m);
666
+ const i = /* @__PURE__ */ new Set(), b = () => tt(t), { y: g, isScrolling: x, arrivedState: m } = Ze(b, { throttle: f }), d = (l) => l.scrollHeight - l.scrollTop - l.clientHeight <= r, u = async (l = "auto") => {
667
+ const c = I(b);
668
+ if (c && (await se(), c.scrollTo({ top: c.scrollHeight, behavior: l }), l === "smooth" && !d(c))) {
669
+ const p = he(x, () => {
670
+ c.scrollTo({ top: c.scrollHeight, behavior: "auto" }), i.delete(p);
675
671
  });
676
- d.add(m);
672
+ i.add(p);
677
673
  }
678
- }, _ = () => {
674
+ }, v = () => {
679
675
  a || !o.value || (a = !0, requestAnimationFrame(async () => {
680
- a = !1, await i("auto");
676
+ a = !1, await u("auto");
681
677
  }));
682
678
  };
683
679
  return H(
684
- y,
680
+ g,
685
681
  () => {
686
- const c = S(g);
687
- c && (o.value = p(c));
682
+ const l = I(b);
683
+ l && (o.value = d(l));
688
684
  },
689
685
  { flush: "post" }
690
- ), et(
691
- t,
686
+ ), Qe(
687
+ e,
692
688
  () => {
693
- _();
689
+ v();
694
690
  },
695
691
  { flush: "post", throttle: 100 }
696
692
  ), ye(() => {
697
- s && i("smooth");
693
+ s && u("smooth");
698
694
  }), ze(() => {
699
- d.forEach((c) => {
700
- c();
701
- }), d.clear();
702
- }), tt("keydown", (c) => {
703
- if (c.key === "End" && !o.value) {
704
- const l = he(C, () => {
705
- i("auto"), d.delete(l);
695
+ i.forEach((l) => {
696
+ l();
697
+ }), i.clear();
698
+ }), et("keydown", (l) => {
699
+ if (l.key === "End" && !o.value) {
700
+ const c = he(x, () => {
701
+ u("auto"), i.delete(c);
706
702
  });
707
- d.add(l);
703
+ i.add(c);
708
704
  }
709
705
  }), {
710
- scrollToBottom: i,
711
- arrivedState: f
706
+ scrollToBottom: u,
707
+ arrivedState: m
712
708
  };
713
709
  }
714
- const jt = /* @__PURE__ */ E({
710
+ const jt = /* @__PURE__ */ k({
715
711
  __name: "BubbleItem",
716
712
  props: {
717
713
  messageGroup: {},
@@ -720,30 +716,30 @@ const jt = /* @__PURE__ */ E({
720
716
  contentResolver: { type: Function }
721
717
  },
722
718
  emits: ["state-change"],
723
- setup(e, { emit: t }) {
724
- const n = e, s = t;
725
- return Nt(() => n.messageGroup), (r, u) => (b(), k(Y, P(e.roleConfig, {
726
- role: e.messageGroup.role,
727
- "content-render-mode": e.contentRenderMode,
728
- "content-resolver": e.contentResolver,
729
- onStateChange: u[0] || (u[0] = (o) => s("state-change", o))
719
+ setup(t, { emit: e }) {
720
+ const n = t, s = e;
721
+ return Nt(() => n.messageGroup), (r, f) => (_(), S(Y, F(t.roleConfig, {
722
+ role: t.messageGroup.role,
723
+ "content-render-mode": t.contentRenderMode,
724
+ "content-resolver": t.contentResolver,
725
+ onStateChange: f[0] || (f[0] = (o) => s("state-change", o))
730
726
  }), {
731
727
  prefix: M((o) => [
732
- B(r.$slots, "prefix", F(G(o)))
728
+ B(r.$slots, "prefix", D(G(o)))
733
729
  ]),
734
730
  suffix: M((o) => [
735
- B(r.$slots, "suffix", F(G(o)))
731
+ B(r.$slots, "suffix", D(G(o)))
736
732
  ]),
737
733
  "content-footer": M((o) => [
738
- B(r.$slots, "content-footer", F(G(o)))
734
+ B(r.$slots, "content-footer", D(G(o)))
739
735
  ]),
740
736
  after: M((o) => [
741
- B(r.$slots, "after", F(G(o)))
737
+ B(r.$slots, "after", D(G(o)))
742
738
  ]),
743
739
  _: 3
744
740
  }, 16, ["role", "content-render-mode", "content-resolver"]));
745
741
  }
746
- }), zt = /* @__PURE__ */ E({
742
+ }), zt = /* @__PURE__ */ k({
747
743
  __name: "BubbleList",
748
744
  props: {
749
745
  messages: {},
@@ -752,112 +748,112 @@ const jt = /* @__PURE__ */ E({
752
748
  fallbackRole: { default: "assistant" },
753
749
  roleConfigs: {},
754
750
  contentRenderMode: {},
755
- contentResolver: { type: Function, default: (e) => e.content },
751
+ contentResolver: { type: Function, default: (t) => t.content },
756
752
  autoScroll: { type: Boolean }
757
753
  },
758
754
  emits: ["state-change"],
759
- setup(e, { expose: t, emit: n }) {
760
- const s = e, r = n;
755
+ setup(t, { expose: e, emit: n }) {
756
+ const s = t, r = n;
761
757
  de(), $(Me, !0);
762
- const u = Q(() => s.contentResolver), o = (f) => {
763
- var p, i;
764
- return f ? !!((i = (p = s.roleConfigs) == null ? void 0 : p[f]) != null && i.hidden) : !1;
758
+ const f = ee(() => s.contentResolver), o = (m) => {
759
+ var d, u;
760
+ return m ? !!((u = (d = s.roleConfigs) == null ? void 0 : d[m]) != null && u.hidden) : !1;
765
761
  }, a = T(null);
766
- let d = async () => {
762
+ let i = async () => {
767
763
  };
768
764
  if (s.autoScroll) {
769
- const f = v(() => s.messages.at(-1)), { scrollToBottom: p } = Wt(a, () => {
770
- var i, _;
765
+ const m = h(() => s.messages.at(-1)), { scrollToBottom: d } = Wt(a, () => {
766
+ var u, v;
771
767
  return [
772
768
  s.messages.length,
773
- (i = f.value) == null ? void 0 : i.content,
774
- (_ = f.value) == null ? void 0 : _.reasoning_content
769
+ (u = m.value) == null ? void 0 : u.content,
770
+ (v = m.value) == null ? void 0 : v.reasoning_content
775
771
  ];
776
772
  });
777
- d = p, H(
773
+ i = d, H(
778
774
  () => {
779
- var i;
780
- return (i = f.value) == null ? void 0 : i.role;
775
+ var u;
776
+ return (u = m.value) == null ? void 0 : u.role;
781
777
  },
782
- async (i) => {
783
- i === "user" && (await ne(), p("smooth"));
778
+ async (u) => {
779
+ u === "user" && (await se(), d("smooth"));
784
780
  }
785
781
  );
786
782
  }
787
783
  Ue(a);
788
- const g = (f) => {
789
- const p = [];
790
- let i = !1, _ = !1;
791
- for (const [c, l] of f.entries()) {
792
- const m = p[p.length - 1], I = Array.isArray(u(l)), N = l.role || "", O = o(l.role);
793
- I ? (p.push({
784
+ const b = (m) => {
785
+ const d = [];
786
+ let u = !1, v = !1;
787
+ for (const [l, c] of m.entries()) {
788
+ const p = d[d.length - 1], E = Array.isArray(f(c)), N = c.role || "", P = o(c.role);
789
+ E ? (d.push({
794
790
  role: N,
795
- messages: [l],
796
- messageIndexes: [c],
797
- startIndex: c
798
- }), i = !0) : m && !i && (_ && O || m.role === N && _ === O) ? (m.messages.push(l), m.messageIndexes.push(c)) : (p.push({
799
- role: N,
800
- messages: [l],
801
- messageIndexes: [c],
802
- startIndex: c
803
- }), i = !1), _ = O;
804
- }
805
- return p;
806
- }, y = (f, p) => {
807
- const i = [];
808
- let _ = !1, c = !1;
809
- for (const [l, m] of f.entries()) {
810
- const I = i[i.length - 1], N = m.role === p, O = Array.isArray(u(m)), me = m.role || "", se = o(m.role);
811
- O ? (i.push({
812
- role: me,
813
- messages: [m],
791
+ messages: [c],
814
792
  messageIndexes: [l],
815
793
  startIndex: l
816
- }), _ = !0) : I && !_ && (c && se || I.role === p === N && c === se) ? (I.messages.push(m), I.messageIndexes.push(l)) : (i.push({
817
- role: N ? p : me,
818
- messages: [m],
794
+ }), u = !0) : p && !u && (v && P || p.role === N && v === P) ? (p.messages.push(c), p.messageIndexes.push(l)) : (d.push({
795
+ role: N,
796
+ messages: [c],
819
797
  messageIndexes: [l],
820
798
  startIndex: l
821
- }), _ = !1), c = se;
799
+ }), u = !1), v = P;
800
+ }
801
+ return d;
802
+ }, g = (m, d) => {
803
+ const u = [];
804
+ let v = !1, l = !1;
805
+ for (const [c, p] of m.entries()) {
806
+ const E = u[u.length - 1], N = p.role === d, P = Array.isArray(f(p)), W = p.role || "", oe = o(p.role);
807
+ P ? (u.push({
808
+ role: W,
809
+ messages: [p],
810
+ messageIndexes: [c],
811
+ startIndex: c
812
+ }), v = !0) : E && !v && (l && oe || E.role === d === N && l === oe) ? (E.messages.push(p), E.messageIndexes.push(c)) : (u.push({
813
+ role: N ? d : W,
814
+ messages: [p],
815
+ messageIndexes: [c],
816
+ startIndex: c
817
+ }), v = !1), l = oe;
822
818
  }
823
- return i;
824
- }, C = v(() => s.messages.length === 0 ? [] : typeof s.groupStrategy == "function" ? s.groupStrategy(s.messages, s.dividerRole) : s.groupStrategy === "consecutive" ? g(s.messages) : y(s.messages, s.dividerRole));
825
- return t({
826
- scrollToBottom: d
827
- }), (f, p) => (b(), x("div", {
819
+ return u;
820
+ }, x = h(() => s.messages.length === 0 ? [] : typeof s.groupStrategy == "function" ? s.groupStrategy(s.messages, s.dividerRole) : s.groupStrategy === "consecutive" ? b(s.messages) : g(s.messages, s.dividerRole));
821
+ return e({
822
+ scrollToBottom: i
823
+ }), (m, d) => (_(), R("div", {
828
824
  class: "tr-bubble-list",
829
825
  ref_key: "listRef",
830
826
  ref: a
831
827
  }, [
832
- (b(!0), x(D, null, j(C.value, (i, _) => {
833
- var c;
834
- return b(), k(jt, {
835
- key: _,
836
- role: i.role || s.fallbackRole,
837
- "role-config": (c = s.roleConfigs) == null ? void 0 : c[i.role || s.fallbackRole],
838
- "message-group": i,
828
+ (_(!0), R(w, null, z(x.value, (u, v) => {
829
+ var l;
830
+ return _(), S(jt, {
831
+ key: v,
832
+ role: u.role || s.fallbackRole,
833
+ "role-config": (l = s.roleConfigs) == null ? void 0 : l[u.role || s.fallbackRole],
834
+ "message-group": u,
839
835
  "content-render-mode": s.contentRenderMode,
840
836
  "content-resolver": s.contentResolver,
841
- onStateChange: (l) => r("state-change", { ...l, messageIndex: i.startIndex + l.messageIndex })
837
+ onStateChange: (c) => r("state-change", { ...c, messageIndex: u.startIndex + c.messageIndex })
842
838
  }, {
843
- prefix: M((l) => [
844
- B(f.$slots, "prefix", P({ ref_for: !0 }, l, {
845
- messageIndexes: i.messageIndexes
839
+ prefix: M((c) => [
840
+ B(m.$slots, "prefix", F({ ref_for: !0 }, c, {
841
+ messageIndexes: u.messageIndexes
846
842
  }), void 0, !0)
847
843
  ]),
848
- suffix: M((l) => [
849
- B(f.$slots, "suffix", P({ ref_for: !0 }, l, {
850
- messageIndexes: i.messageIndexes
844
+ suffix: M((c) => [
845
+ B(m.$slots, "suffix", F({ ref_for: !0 }, c, {
846
+ messageIndexes: u.messageIndexes
851
847
  }), void 0, !0)
852
848
  ]),
853
- "content-footer": M((l) => [
854
- B(f.$slots, "content-footer", P({ ref_for: !0 }, l, {
855
- messageIndexes: i.messageIndexes
849
+ "content-footer": M((c) => [
850
+ B(m.$slots, "content-footer", F({ ref_for: !0 }, c, {
851
+ messageIndexes: u.messageIndexes
856
852
  }), void 0, !0)
857
853
  ]),
858
- after: M((l) => [
859
- B(f.$slots, "after", P({ ref_for: !0 }, l, {
860
- messageIndexes: i.messageIndexes
854
+ after: M((c) => [
855
+ B(m.$slots, "after", F({ ref_for: !0 }, c, {
856
+ messageIndexes: u.messageIndexes
861
857
  }), void 0, !0)
862
858
  ]),
863
859
  _: 2
@@ -865,7 +861,7 @@ const jt = /* @__PURE__ */ E({
865
861
  }), 128))
866
862
  ], 512));
867
863
  }
868
- }), X = /* @__PURE__ */ A(zt, [["__scopeId", "data-v-e6f64f99"]]), q = /* @__PURE__ */ E({
864
+ }), q = /* @__PURE__ */ A(zt, [["__scopeId", "data-v-ff5526c3"]]), Z = /* @__PURE__ */ k({
869
865
  __name: "BubbleProvider",
870
866
  props: {
871
867
  boxRendererMatches: {},
@@ -874,35 +870,35 @@ const jt = /* @__PURE__ */ E({
874
870
  fallbackContentRenderer: { type: [Object, Function] },
875
871
  store: {}
876
872
  },
877
- setup(e) {
878
- const t = e;
879
- de(t.store);
880
- const n = v(() => (t.boxRendererMatches || []).concat(Fe).sort((o, a) => (o.priority ?? 0) - (a.priority ?? 0))), s = v(() => (t.contentRendererMatches || []).concat(Pe).sort((o, a) => (o.priority ?? 0) - (a.priority ?? 0))), r = v(() => t.fallbackBoxRenderer || Ge), u = v(() => t.fallbackContentRenderer || He);
881
- return St({ boxRendererMatches: n, fallbackBoxRenderer: r }), Mt({ contentRendererMatches: s, fallbackContentRenderer: u }), (o, a) => B(o.$slots, "default");
873
+ setup(t) {
874
+ const e = t;
875
+ de(e.store);
876
+ const n = h(() => (e.boxRendererMatches || []).concat(Fe).sort((o, a) => (o.priority ?? 0) - (a.priority ?? 0))), s = h(() => (e.contentRendererMatches || []).concat(Pe).sort((o, a) => (o.priority ?? 0) - (a.priority ?? 0))), r = h(() => e.fallbackBoxRenderer || Ge), f = h(() => e.fallbackContentRenderer || He);
877
+ return St({ boxRendererMatches: n, fallbackBoxRenderer: r }), Mt({ contentRendererMatches: s, fallbackContentRenderer: f }), (o, a) => B(o.$slots, "default");
882
878
  }
883
- }), Vt = ["innerHTML"], Xt = /* @__PURE__ */ E({
879
+ }), Vt = ["innerHTML"], Xt = /* @__PURE__ */ k({
884
880
  __name: "Markdown",
885
881
  props: {
886
882
  message: {},
887
883
  contentIndex: {}
888
884
  },
889
- setup(e) {
890
- const t = e, { contentText: n } = pe(t), s = T(null);
885
+ setup(t) {
886
+ const e = t, { contentText: n } = pe(e), s = T(null);
891
887
  ye(async () => {
892
888
  s.value = await Dt();
893
889
  });
894
- const { mdConfig: r, dompurifyConfig: u } = fe(), o = T("");
895
- return Z(() => {
890
+ const { mdConfig: r, dompurifyConfig: f } = fe(), o = T("");
891
+ return Q(() => {
896
892
  if (s.value) {
897
- const { markdown: a, dompurify: d } = s.value;
898
- o.value = a(r || {}).render(n.value), d.sanitize(o.value, u);
893
+ const { markdown: a, dompurify: i } = s.value;
894
+ o.value = a(r || {}).render(n.value), i.sanitize(o.value, f);
899
895
  }
900
- }), (a, d) => o.value ? (b(), x("div", {
896
+ }), (a, i) => o.value ? (_(), R("div", {
901
897
  key: 0,
902
898
  class: "tr-bubble__markdown markdown-body",
903
899
  "data-type": "markdown",
904
900
  innerHTML: o.value
905
- }, null, 8, Vt)) : (b(), k(ue, F(P({ key: 1 }, t)), null, 16));
901
+ }, null, 8, Vt)) : (_(), S(ue, D(F({ key: 1 }, e)), null, 16));
906
902
  }
907
903
  }), qt = /* @__PURE__ */ A(Xt, [["__scopeId", "data-v-a7de666c"]]), rn = {
908
904
  Box: ce,
@@ -916,34 +912,34 @@ const jt = /* @__PURE__ */ E({
916
912
  Tools: De
917
913
  };
918
914
  Y.name = "TrBubble";
919
- const Zt = function(e) {
920
- e.component(Y.name, Y);
915
+ const Zt = function(t) {
916
+ t.component(Y.name, Y);
921
917
  };
922
918
  Y.install = Zt;
923
919
  const an = Y;
924
- X.name = "TrBubbleList";
925
- const Qt = function(e) {
926
- e.component(X.name, X);
920
+ q.name = "TrBubbleList";
921
+ const Qt = function(t) {
922
+ t.component(q.name, q);
927
923
  };
928
- X.install = Qt;
929
- const ln = X;
930
- q.name = "TrBubbleProvider";
931
- const en = function(e) {
932
- e.component(q.name, q);
924
+ q.install = Qt;
925
+ const ln = q;
926
+ Z.name = "TrBubbleProvider";
927
+ const en = function(t) {
928
+ t.component(Z.name, Z);
933
929
  };
934
- q.install = en;
935
- const cn = q;
930
+ Z.install = en;
931
+ const cn = Z;
936
932
  export {
937
933
  an as B,
938
934
  ln as a,
939
935
  cn as b,
940
936
  K as c,
941
937
  rn as d,
942
- ie as e,
943
- Ke as f,
944
- pe as g,
945
- Ye as h,
946
- Ft as i,
947
- Wt as j,
948
- Tt as u
938
+ Tt as e,
939
+ ie as f,
940
+ Ke as g,
941
+ pe as h,
942
+ Ye as i,
943
+ Ft as j,
944
+ Wt as u
949
945
  };