@opentiny/tiny-robot 0.3.1-alpha.8 → 0.3.1-alpha.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/dist/index5.js CHANGED
@@ -1,529 +1,301 @@
1
- import { defineComponent as k, openBlock as m, createElementBlock as y, renderSlot as g, unref as v, toDisplayString as be, createCommentVNode as X, markRaw as z, provide as S, inject as C, computed as _, toValue as B, reactive as fe, createBlock as E, resolveDynamicComponent as U, mergeProps as A, withCtx as R, normalizeProps as T, guardReactiveProps as $, withDirectives as me, createElementVNode as K, normalizeClass as pe, Fragment as N, renderList as G, createVNode as ge, vShow as _e, ref as q, watch as Y, onMounted as he, onUnmounted as Be, nextTick as J } from "vue";
2
- import { _ as P } from "./_plugin-vue_export-helper.js";
3
- import { i as Re, w as xe, g as ve, a as ye } from "./index4.js";
4
- const Q = Symbol("bubble-message-group"), Z = Symbol("bubble-box-renderer-matches"), ee = Symbol("bubble-box-fallback-renderer"), te = Symbol(
5
- "bubble-box-prop-fallback-renderer"
6
- ), ne = Symbol("bubble-content-renderer-matches"), se = Symbol(
7
- "bubble-content-fallback-renderer"
8
- ), oe = Symbol(
9
- "bubble-content-prop-fallback-renderer"
10
- ), j = Symbol("bubble-store"), re = Symbol("bubble-state-change-fn"), et = {
11
- LOADING: -1,
12
- NORMAL: 0,
13
- CONTENT: 10,
14
- ROLE: 20
15
- }, Ee = {
16
- class: "tr-bubble__box",
17
- "data-box-type": "box"
18
- }, Ce = /* @__PURE__ */ k({
19
- __name: "Box",
20
- props: {
21
- placement: {},
22
- shape: {}
23
- },
24
- setup(t) {
25
- return (n, e) => (m(), y("div", Ee, [
26
- g(n.$slots, "default", {}, void 0, !0)
27
- ]));
28
- }
29
- }), ae = /* @__PURE__ */ P(Ce, [["__scopeId", "data-v-98101726"]]), Se = {
30
- key: 0,
31
- class: "tr-bubble__text",
32
- "data-type": "text"
33
- }, ke = /* @__PURE__ */ k({
34
- __name: "Text",
35
- props: {
36
- message: {},
37
- contentIndex: {}
38
- },
39
- setup(t) {
40
- const n = t, e = Oe(() => n.message, n.contentIndex);
41
- return (a, c) => {
42
- var i;
43
- return v(e) ? (m(), y("p", Se, be(typeof v(e) == "string" ? v(e) : (i = v(e)) == null ? void 0 : i.text), 1)) : X("", !0);
44
- };
45
- }
46
- }), le = /* @__PURE__ */ P(ke, [["__scopeId", "data-v-53daeb22"]]), ce = [], ue = [], de = z(ae), ie = z(le);
47
- function Ie(t) {
48
- const { boxRendererMatches: n, fallbackBoxRenderer: e } = t;
49
- n && S(Z, n), e && S(ee, e);
50
- }
51
- function Me(t) {
52
- const { fallbackBoxRenderer: n } = t;
53
- n && S(te, n);
54
- }
55
- function Ae(t, n) {
56
- const e = C(Z, ce), a = C(ee, void 0), c = C(te, void 0);
57
- return _(() => {
58
- const i = B(t), s = B(e).find((b) => b.find(i, n));
59
- return s ? {
60
- renderer: s.renderer,
61
- attributes: s.attributes
62
- } : {
63
- renderer: B(c) || B(a) || de
64
- };
65
- });
66
- }
67
- function Le(t) {
68
- const { contentRendererMatches: n, fallbackContentRenderer: e } = t;
69
- n && S(ne, n), e && S(se, e);
70
- }
71
- function Te(t) {
72
- const { fallbackContentRenderer: n } = t;
73
- n && S(oe, n);
74
- }
75
- function $e(t, n) {
76
- const e = C(ne, ue), a = C(se, void 0), c = C(oe, void 0);
77
- return _(() => {
78
- const i = B(t), s = B(e).find((b) => b.find(i, n));
79
- return s ? s.renderer : B(c) || B(a) || ie;
80
- });
1
+ import { onMounted as ne, onBeforeUnmount as oe, ref as _, defineComponent as P, openBlock as r, createElementBlock as a, createElementVNode as w, createVNode as T, unref as n, toDisplayString as B, useModel as W, computed as I, normalizeStyle as ie, Fragment as S, renderList as V, createBlock as H, resolveDynamicComponent as Y, mergeModels as j, nextTick as se, normalizeClass as U, createCommentVNode as G, renderSlot as q, withDirectives as A, withKeys as F, isRef as le, withModifiers as J, vModelText as re, vShow as ae } from "vue";
2
+ import { IconEmptySearch as ue, IconEditPen as ce, IconDelete as de, IconCheck as me, IconClose as fe, IconMenu2 as pe } from "@opentiny/tiny-robot-svgs";
3
+ import { _ as z } from "./_plugin-vue_export-helper.js";
4
+ import { o as Z, d as ve, c as ge, b as ye } from "./index4.js";
5
+ import { t as O } from "./utils.js";
6
+ const D = _(!1);
7
+ let b = 0, $;
8
+ function _e() {
9
+ const s = window.matchMedia("(hover: none) and (pointer: coarse)"), m = () => {
10
+ D.value = s.matches;
11
+ };
12
+ m(), s.addEventListener("change", m);
13
+ const t = (c) => {
14
+ D.value = c.pointerType !== "mouse";
15
+ };
16
+ return window.addEventListener("pointerdown", t, !0), () => {
17
+ s.removeEventListener("change", m), window.removeEventListener("pointerdown", t, !0);
18
+ };
81
19
  }
82
- function Ne(t) {
83
- S(re, t);
20
+ function he() {
21
+ $ == null || $(), $ = void 0;
84
22
  }
85
- function tt() {
86
- return C(re, (t, n) => {
87
- console.warn(`[Bubble] State change function not found for key: ${t}`);
23
+ function Ce() {
24
+ return typeof window > "u" ? {
25
+ isTouchDevice: D
26
+ } : (ne(() => {
27
+ b++, b === 1 && ($ = _e());
28
+ }), oe(() => {
29
+ b = Math.max(0, b - 1), b === 0 && he();
30
+ }), {
31
+ isTouchDevice: D
88
32
  });
89
33
  }
90
- function H(t) {
91
- const n = C(j, void 0);
92
- if (n)
93
- return n;
94
- const e = fe(t || {});
95
- return S(j, e), e;
96
- }
97
- const M = (t) => {
98
- var n;
99
- return ((n = t.state) == null ? void 0 : n.content) ?? t.content;
100
- }, Oe = (t, n) => _(() => {
101
- const e = M(B(t));
102
- return Array.isArray(e) ? e.at(n ?? 0) : e;
103
- });
104
- function Fe(t) {
105
- S(Q, t);
106
- }
107
- function Ge() {
108
- return C(Q, void 0);
109
- }
110
- function nt(t, n) {
111
- const e = _(() => {
112
- const c = Object.entries(t.message).filter(([i]) => !n.includes(i));
113
- return Object.fromEntries(c);
114
- }), a = _(() => ({
115
- ...t,
116
- message: e.value
117
- }));
118
- return {
119
- restMessage: e,
120
- restProps: a
121
- };
122
- }
123
- const W = /* @__PURE__ */ k({
124
- __name: "BubbleBoxWrapper",
34
+ const ke = { class: "tr-history__empty" }, Le = { class: "tr-history__empty-icon" }, Ee = { class: "tr-history__empty-text" }, we = /* @__PURE__ */ P({
35
+ __name: "Empty",
125
36
  props: {
126
- role: {},
127
- placement: {},
128
- shape: {},
129
- messages: {},
130
- contentIndex: {}
37
+ text: { default: "暂无内容" }
131
38
  },
132
- setup(t) {
133
- const n = t, e = Ae(() => n.messages, n.contentIndex);
134
- return (a, c) => (m(), E(U(v(e).renderer), A({
135
- "data-role": n.role,
136
- "data-placement": n.placement,
137
- "data-shape": n.shape
138
- }, v(e).attributes), {
139
- default: R(() => [
140
- g(a.$slots, "default")
39
+ setup(s) {
40
+ const m = s;
41
+ return (t, c) => (r(), a("div", ke, [
42
+ w("span", Le, [
43
+ T(n(ue))
141
44
  ]),
142
- _: 3
143
- }, 16, ["data-role", "data-placement", "data-shape"]));
144
- }
145
- }), D = /* @__PURE__ */ k({
146
- __name: "BubbleContentWrapper",
147
- props: {
148
- message: {},
149
- contentIndex: {}
150
- },
151
- emits: ["state-change"],
152
- setup(t, { emit: n }) {
153
- const e = t, a = $e(() => e.message, e.contentIndex), c = n;
154
- return Ne((s, b) => {
155
- c("state-change", {
156
- key: s,
157
- value: b,
158
- contentIndex: e.contentIndex
159
- });
160
- }), (s, b) => (m(), E(U(v(a)), T($(e)), null, 16));
45
+ w("span", Ee, B(m.text), 1)
46
+ ]));
161
47
  }
162
- }), Pe = ["data-role", "data-placement"], we = { class: "tr-bubble__body" }, Ke = { class: "tr-bubble__content" }, De = { class: "tr-bubble__after" }, Ue = /* @__PURE__ */ k({
163
- __name: "Bubble",
164
- props: {
165
- content: {},
166
- reasoning_content: {},
167
- tool_calls: {},
168
- tool_call_id: {},
169
- name: {},
170
- role: {},
171
- id: {},
172
- loading: { type: Boolean },
173
- state: {},
174
- hidden: { type: Boolean },
175
- avatar: {},
176
- placement: { default: "start" },
177
- shape: { default: "corner" },
178
- contentRenderMode: { default: "single" },
179
- fallbackBoxRenderer: {},
180
- fallbackContentRenderer: {}
181
- },
182
- emits: ["state-change"],
183
- setup(t, { emit: n }) {
184
- const e = t, a = n;
185
- H();
186
- const c = Ge(), i = _(() => B(c)), s = _(() => {
187
- var w;
188
- if ((w = i.value) != null && w.messages.length)
189
- return i.value.messages;
190
- const { role: h, content: f, reasoning_content: u, tool_calls: r, tool_call_id: l, name: d, id: o, loading: p, state: I } = e;
191
- return [{ role: h, content: f, reasoning_content: u, tool_calls: r, tool_call_id: l, name: d, id: o, loading: p, state: I }];
192
- });
193
- Me({ fallbackBoxRenderer: () => e.fallbackBoxRenderer }), Te({ fallbackContentRenderer: () => e.fallbackContentRenderer });
194
- const b = _(() => s.value.length === 0 ? !0 : e.hidden), x = _(() => e.contentRenderMode === "split" && s.value.length === 1 && Array.isArray(M(s.value[0])));
195
- return (h, f) => me((m(), y("div", {
196
- class: "tr-bubble",
197
- "data-role": e.role,
198
- "data-placement": e.placement
48
+ }), Re = /* @__PURE__ */ z(we, [["__scopeId", "data-v-d0340c39"]]), Ie = ["onClick"], Q = 4, xe = /* @__PURE__ */ P({
49
+ __name: "MenuList",
50
+ props: /* @__PURE__ */ j({
51
+ items: {},
52
+ menuListGap: { default: 8 }
53
+ }, {
54
+ trigger: { default: null },
55
+ triggerModifiers: {},
56
+ data: { default: null },
57
+ dataModifiers: {}
58
+ }),
59
+ emits: /* @__PURE__ */ j(["item-click"], ["update:trigger", "update:data"]),
60
+ setup(s, { emit: m }) {
61
+ const t = W(s, "trigger"), c = W(s, "data"), h = s, C = m, E = _(null);
62
+ Z(
63
+ E,
64
+ () => {
65
+ t.value = null, c.value = null;
66
+ },
67
+ {
68
+ ignore: [t]
69
+ }
70
+ );
71
+ const { top: p, bottom: x, left: y } = ve(t), { width: M, height: k } = ge(E, void 0, { box: "border-box" }), { height: R } = ye(), o = I(() => {
72
+ const L = {
73
+ left: `min(${O(y.value)}, calc(100% - ${O(M.value + Q)}))`
74
+ }, g = x.value + h.menuListGap;
75
+ return g + k.value + Q > R.value ? L.bottom = `calc(100% - ${O(p.value - h.menuListGap)})` : L.top = O(g), L;
76
+ }), v = (L) => {
77
+ C("item-click", L), t.value = null, c.value = null;
78
+ };
79
+ return (L, g) => (r(), a("ul", {
80
+ class: "tr-history__menu-list",
81
+ ref_key: "menuRef",
82
+ ref: E,
83
+ style: ie(o.value)
199
84
  }, [
200
- g(h.$slots, "prefix", {
201
- messages: s.value,
202
- role: t.role
203
- }, void 0, !0),
204
- K("div", we, [
205
- e.avatar ? (m(), E(U(e.avatar), {
206
- key: 0,
207
- class: pe(["tr-bubble__avatar", h.$style["tr-bubble__avatar"]])
208
- }, null, 8, ["class"])) : X("", !0),
209
- K("div", Ke, [
210
- x.value ? (m(!0), y(N, { key: 0 }, G(v(M)(s.value[0]), (u, r) => (m(), E(W, {
211
- key: r,
212
- class: "tr-bubble__box",
213
- role: e.role,
214
- placement: e.placement,
215
- shape: e.shape,
216
- messages: s.value,
217
- "content-index": r
218
- }, {
219
- default: R(() => [
220
- ge(D, {
221
- message: s.value[0],
222
- "content-index": r,
223
- onStateChange: f[0] || (f[0] = (l) => a("state-change", { ...l, messageIndex: 0 }))
224
- }, null, 8, ["message", "content-index"]),
225
- g(h.$slots, "content-footer", {
226
- messages: s.value,
227
- role: e.role,
228
- contentIndex: r
229
- }, void 0, !0)
230
- ]),
231
- _: 2
232
- }, 1032, ["role", "placement", "shape", "messages", "content-index"]))), 128)) : (m(), E(W, {
233
- key: 1,
234
- role: e.role,
235
- placement: e.placement,
236
- shape: e.shape,
237
- messages: s.value
238
- }, {
239
- default: R(() => [
240
- (m(!0), y(N, null, G(s.value, (u, r) => (m(), y(N, {
241
- key: `message-${r}`
242
- }, [
243
- Array.isArray(v(M)(u)) ? (m(!0), y(N, { key: 0 }, G(v(M)(u), (l, d) => (m(), E(D, {
244
- key: `content-${d}`,
245
- message: u,
246
- "content-index": d,
247
- onStateChange: (o) => a("state-change", { ...o, messageIndex: r })
248
- }, null, 8, ["message", "content-index", "onStateChange"]))), 128)) : (m(), E(D, {
249
- key: 1,
250
- message: u,
251
- onStateChange: (l) => a("state-change", { ...l, messageIndex: r })
252
- }, null, 8, ["message", "onStateChange"]))
253
- ], 64))), 128)),
254
- g(h.$slots, "content-footer", {
255
- messages: s.value,
256
- role: e.role
257
- }, void 0, !0)
258
- ]),
259
- _: 3
260
- }, 8, ["role", "placement", "shape", "messages"]))
261
- ]),
262
- K("div", De, [
263
- g(h.$slots, "after", {
264
- messages: s.value,
265
- role: t.role
266
- }, void 0, !0)
267
- ])
268
- ]),
269
- g(h.$slots, "suffix", {
270
- messages: s.value,
271
- role: t.role
272
- }, void 0, !0)
273
- ], 8, Pe)), [
274
- [_e, !b.value]
275
- ]);
85
+ (r(!0), a(S, null, V(h.items, (u) => (r(), a("li", {
86
+ class: "tr-history__menu-list__item",
87
+ key: u.id,
88
+ onClick: (K) => v(u)
89
+ }, [
90
+ (r(), H(Y(u.icon))),
91
+ w("span", null, B(u.text), 1)
92
+ ], 8, Ie))), 128))
93
+ ], 4));
276
94
  }
277
- }), Ye = {
278
- "tr-bubble__avatar": "_tr-bubble__avatar_1r87c_2"
279
- }, He = {
280
- $style: Ye
281
- }, L = /* @__PURE__ */ P(Ue, [["__cssModules", He], ["__scopeId", "data-v-eb4c3985"]]);
282
- function V(t, n) {
283
- const e = Y(t, (a, c) => {
284
- c === !0 && a === !1 && (n(), e());
285
- });
286
- return e;
287
- }
288
- function je(t, n, e) {
289
- const { scrollOnMount: a = !0, bottomThreshold: c = 20, scrollThrottle: i = 0 } = e ?? {}, s = q(!0);
290
- let b = !1;
291
- const x = /* @__PURE__ */ new Set(), h = () => ye(t), { y: f, isScrolling: u } = Re(h, { throttle: i }), r = (o) => o.scrollHeight - o.scrollTop - o.clientHeight <= c, l = async (o = "auto") => {
292
- const p = B(h);
293
- if (p && (await J(), p.scrollTo({ top: p.scrollHeight, behavior: o }), o === "smooth" && !r(p))) {
294
- const I = V(u, () => {
295
- p.scrollTo({ top: p.scrollHeight, behavior: "auto" }), x.delete(I);
296
- });
297
- x.add(I);
298
- }
299
- }, d = () => {
300
- b || !s.value || (b = !0, requestAnimationFrame(async () => {
301
- b = !1, await l("auto");
302
- }));
95
+ }), Me = /* @__PURE__ */ z(xe, [["__scopeId", "data-v-89fdb41c"]]), be = ({
96
+ renameControlOnClickOutside: s,
97
+ onItemTitleChange: m
98
+ }) => {
99
+ const t = _(void 0), c = _(null), h = I(() => {
100
+ var o;
101
+ return (o = c.value) == null ? void 0 : o.at(0);
102
+ }), C = _(null), E = I(() => {
103
+ var o;
104
+ return (o = C.value) == null ? void 0 : o.at(0);
105
+ }), p = _(null), x = I(() => {
106
+ var o;
107
+ return (o = p.value) == null ? void 0 : o.at(0);
108
+ }), y = _(""), M = (o) => {
109
+ t.value = o, y.value = o.title, se(() => {
110
+ const v = h.value;
111
+ v && (v.focus(), v.select());
112
+ });
113
+ }, k = () => {
114
+ t.value = void 0, y.value = "";
115
+ }, R = () => {
116
+ t.value && m(y.value, t.value), t.value = void 0, y.value = "";
303
117
  };
304
- return Y(
305
- f,
306
- () => {
307
- const o = B(h);
308
- o && (s.value = r(o));
309
- },
310
- { flush: "post" }
311
- ), xe(
312
- n,
118
+ return (s === "confirm" || s === "cancel") && Z(
119
+ h,
313
120
  () => {
314
- d();
121
+ s === "confirm" ? R() : k();
315
122
  },
316
- { flush: "post", throttle: 100 }
317
- ), he(() => {
318
- a && l("smooth");
319
- }), Be(() => {
320
- x.forEach((o) => {
321
- o();
322
- }), x.clear();
323
- }), ve("keydown", (o) => {
324
- if (o.key === "End" && !s.value) {
325
- const p = V(u, () => {
326
- l("auto"), x.delete(p);
327
- });
328
- x.add(p);
329
- }
330
- }), {
331
- scrollToBottom: l
123
+ { ignore: [E, x] }
124
+ ), {
125
+ editingItem: t,
126
+ editorRefList: c,
127
+ editorConfirmRefList: C,
128
+ editorCancelRefList: p,
129
+ editorValue: y,
130
+ handleEdit: M,
131
+ handleEditCancel: k,
132
+ handleEditConfirm: R
332
133
  };
333
- }
334
- const We = /* @__PURE__ */ k({
335
- __name: "BubbleItem",
336
- props: {
337
- messageGroup: {},
338
- roleConfig: {},
339
- contentRenderMode: {}
340
- },
341
- emits: ["state-change"],
342
- setup(t, { emit: n }) {
343
- const e = t, a = n;
344
- return Fe(() => e.messageGroup), (c, i) => (m(), E(L, A(t.roleConfig, {
345
- role: t.messageGroup.role,
346
- "content-render-mode": t.contentRenderMode,
347
- onStateChange: i[0] || (i[0] = (s) => a("state-change", s))
348
- }), {
349
- prefix: R((s) => [
350
- g(c.$slots, "prefix", T($(s)))
351
- ]),
352
- suffix: R((s) => [
353
- g(c.$slots, "suffix", T($(s)))
354
- ]),
355
- "content-footer": R((s) => [
356
- g(c.$slots, "content-footer", T($(s)))
357
- ]),
358
- after: R((s) => [
359
- g(c.$slots, "after", T($(s)))
360
- ]),
361
- _: 3
362
- }, 16, ["role", "content-render-mode"]));
363
- }
364
- }), Ve = /* @__PURE__ */ k({
365
- __name: "BubbleList",
134
+ }, X = Symbol("NO_GROUP"), Te = {
135
+ key: 0,
136
+ class: "tr-history__group-title"
137
+ }, $e = { class: "tr-history__group-items" }, Ge = ["onClick"], Oe = ["title"], Se = ["onClick"], Be = /* @__PURE__ */ P({
138
+ __name: "index",
366
139
  props: {
367
- messages: {},
368
- groupStrategy: { type: [String, Function], default: "divider" },
369
- dividerRole: { default: "user" },
370
- fallbackRole: { default: "assistant" },
371
- roleConfigs: {},
372
- contentRenderMode: {},
373
- autoScroll: { type: Boolean }
140
+ data: {},
141
+ selected: {},
142
+ showRenameControls: { type: Boolean, default: !1 },
143
+ renameControlOnClickOutside: { default: "confirm" },
144
+ menuItems: { default: () => [
145
+ { id: "rename", text: "重命名", icon: ce },
146
+ { id: "delete", text: "删除", icon: de }
147
+ ] },
148
+ menuListGap: { default: 8 }
374
149
  },
375
- emits: ["state-change"],
376
- setup(t, { expose: n, emit: e }) {
377
- const a = t, c = e;
378
- H();
379
- const i = q(null);
380
- let s = async () => {
381
- };
382
- if (a.autoScroll) {
383
- const f = _(() => a.messages.at(-1)), { scrollToBottom: u } = je(i, () => {
384
- var r, l;
385
- return [
386
- a.messages.length,
387
- (r = f.value) == null ? void 0 : r.content,
388
- (l = f.value) == null ? void 0 : l.reasoning_content
389
- ];
390
- });
391
- s = u, Y(
392
- () => {
393
- var r;
394
- return (r = f.value) == null ? void 0 : r.role;
395
- },
396
- async (r) => {
397
- r === "user" && (await J(), u("smooth"));
398
- }
399
- );
400
- }
401
- const b = (f) => {
402
- const u = [];
403
- let r = !1;
404
- for (const [l, d] of f.entries()) {
405
- const o = u[u.length - 1];
406
- Array.isArray(M(d)) ? (u.push({
407
- role: d.role || "",
408
- messages: [d],
409
- messageIndexes: [l],
410
- startIndex: l
411
- }), r = !0) : o && o.role === d.role && !r ? (o.messages.push(d), o.messageIndexes.push(l)) : (u.push({
412
- role: d.role || "",
413
- messages: [d],
414
- messageIndexes: [l],
415
- startIndex: l
416
- }), r = !1);
417
- }
418
- return u;
419
- }, x = (f, u) => {
420
- const r = [];
421
- let l = !1;
422
- for (const [d, o] of f.entries()) {
423
- const p = r[r.length - 1], I = o.role === u;
424
- Array.isArray(M(o)) ? (r.push({
425
- role: o.role || "",
426
- messages: [o],
427
- messageIndexes: [d],
428
- startIndex: d
429
- }), l = !0) : p && p.role === u === I && !l ? (p.messages.push(o), p.messageIndexes.push(d)) : (r.push({
430
- role: I ? u : o.role || "",
431
- messages: [o],
432
- messageIndexes: [d],
433
- startIndex: d
434
- }), l = !1);
150
+ emits: ["item-click", "item-title-change", "item-action"],
151
+ setup(s, { emit: m }) {
152
+ const t = s, c = m, h = (i) => {
153
+ var f;
154
+ const e = typeof ((f = i[0]) == null ? void 0 : f.group);
155
+ return e === "string" || e === "symbol";
156
+ }, C = I(() => {
157
+ const i = t.data;
158
+ return h(i) ? i : [{ group: X, items: i }];
159
+ }), E = I(() => C.value.length === 0 || C.value.every((i) => i.items.length === 0)), {
160
+ editingItem: p,
161
+ editorRefList: x,
162
+ editorConfirmRefList: y,
163
+ editorCancelRefList: M,
164
+ editorValue: k,
165
+ handleEdit: R,
166
+ handleEditCancel: o,
167
+ handleEditConfirm: v
168
+ } = be({
169
+ renameControlOnClickOutside: t.renameControlOnClickOutside,
170
+ onItemTitleChange: (i, e) => {
171
+ c("item-title-change", i, e);
435
172
  }
436
- return r;
437
- }, h = _(() => a.messages.length === 0 ? [] : typeof a.groupStrategy == "function" ? a.groupStrategy(a.messages, a.dividerRole) : a.groupStrategy === "consecutive" ? b(a.messages) : x(a.messages, a.dividerRole));
438
- return n({
439
- scrollToBottom: s
440
- }), (f, u) => (m(), y("div", {
441
- class: "tr-bubble-list",
442
- ref_key: "listRef",
443
- ref: i
173
+ }), { isTouchDevice: L } = Ce(), g = _(null), u = _(null), K = (i, e) => {
174
+ if (i.currentTarget instanceof HTMLButtonElement) {
175
+ if (u.value === e) {
176
+ g.value = null, u.value = null;
177
+ return;
178
+ }
179
+ g.value = i.currentTarget, u.value = e;
180
+ } else
181
+ g.value = null, u.value = null;
182
+ }, ee = (i) => {
183
+ const e = u.value;
184
+ e && (i.id === "rename" && R(e), c("item-action", i, e));
185
+ };
186
+ return (i, e) => (r(), a("div", {
187
+ class: U(["tr-history", { "touch-device": n(L) }])
444
188
  }, [
445
- (m(!0), y(N, null, G(h.value, (r, l) => {
446
- var d;
447
- return m(), E(We, {
448
- key: l,
449
- role: r.role || a.fallbackRole,
450
- "role-config": (d = a.roleConfigs) == null ? void 0 : d[r.role || a.fallbackRole],
451
- "message-group": r,
452
- "content-render-mode": a.contentRenderMode,
453
- onStateChange: (o) => c("state-change", { ...o, messageIndex: r.startIndex + o.messageIndex })
454
- }, {
455
- prefix: R((o) => [
456
- g(f.$slots, "prefix", A({ ref_for: !0 }, o, {
457
- messageIndexes: r.messageIndexes
458
- }), void 0, !0)
459
- ]),
460
- suffix: R((o) => [
461
- g(f.$slots, "suffix", A({ ref_for: !0 }, o, {
462
- messageIndexes: r.messageIndexes
463
- }), void 0, !0)
464
- ]),
465
- "content-footer": R((o) => [
466
- g(f.$slots, "content-footer", A({ ref_for: !0 }, o, {
467
- messageIndexes: r.messageIndexes
468
- }), void 0, !0)
469
- ]),
470
- after: R((o) => [
471
- g(f.$slots, "after", A({ ref_for: !0 }, o, {
472
- messageIndexes: r.messageIndexes
473
- }), void 0, !0)
474
- ]),
475
- _: 2
476
- }, 1032, ["role", "role-config", "message-group", "content-render-mode", "onStateChange"]);
477
- }), 128))
478
- ], 512));
479
- }
480
- }), O = /* @__PURE__ */ P(Ve, [["__scopeId", "data-v-5336988b"]]), F = /* @__PURE__ */ k({
481
- __name: "BubbleProvider",
482
- props: {
483
- boxRendererMatches: {},
484
- contentRendererMatches: {},
485
- fallbackBoxRenderer: { type: [Object, Function] },
486
- fallbackContentRenderer: { type: [Object, Function] },
487
- store: {}
488
- },
489
- setup(t) {
490
- const n = t;
491
- H(n.store);
492
- const e = _(() => (n.boxRendererMatches || []).concat(ce).sort((s, b) => (s.priority ?? 0) - (b.priority ?? 0))), a = _(() => (n.contentRendererMatches || []).concat(ue).sort((s, b) => (s.priority ?? 0) - (b.priority ?? 0))), c = _(() => n.fallbackBoxRenderer || de), i = _(() => n.fallbackContentRenderer || ie);
493
- return Ie({ boxRendererMatches: e, fallbackBoxRenderer: c }), Le({ contentRendererMatches: a, fallbackContentRenderer: i }), (s, b) => g(s.$slots, "default");
189
+ E.value ? (r(), H(Re, { key: 1 })) : (r(), a(S, { key: 0 }, [
190
+ (r(!0), a(S, null, V(C.value, (f) => (r(), a("div", {
191
+ class: "tr-history__group",
192
+ key: f.group
193
+ }, [
194
+ f.group !== n(X) ? (r(), a("div", Te, B(f.group), 1)) : G("", !0),
195
+ w("div", $e, [
196
+ (r(!0), a(S, null, V(f.items, (l, te) => (r(), a("div", {
197
+ class: U(["tr-history__item", {
198
+ selected: l.id && l.id === t.selected,
199
+ editing: n(p) === l,
200
+ active: u.value === l
201
+ }]),
202
+ key: l.id || te,
203
+ onClick: (d) => c("item-click", l)
204
+ }, [
205
+ q(i.$slots, "item-prefix", { item: l }, void 0, !0),
206
+ l.icon ? (r(), H(Y(l.icon), { key: 0 })) : G("", !0),
207
+ n(p) === l ? A((r(), a("input", {
208
+ key: 1,
209
+ class: "tr-history__item-editor",
210
+ type: "text",
211
+ onClick: e[0] || (e[0] = J(() => {
212
+ }, ["stop"])),
213
+ ref_for: !0,
214
+ ref_key: "editorRefList",
215
+ ref: x,
216
+ "onUpdate:modelValue": e[1] || (e[1] = (d) => le(k) ? k.value = d : null),
217
+ onKeydown: [
218
+ e[2] || (e[2] = F(
219
+ //@ts-ignore
220
+ (...d) => n(v) && n(v)(...d),
221
+ ["enter"]
222
+ )),
223
+ e[3] || (e[3] = F(
224
+ //@ts-ignore
225
+ (...d) => n(o) && n(o)(...d),
226
+ ["escape"]
227
+ ))
228
+ ]
229
+ }, null, 544)), [
230
+ [re, n(k)]
231
+ ]) : q(i.$slots, "item-title", {
232
+ key: 2,
233
+ item: l
234
+ }, () => [
235
+ w("span", {
236
+ class: "text",
237
+ title: l.title
238
+ }, B(l.title), 9, Oe)
239
+ ], !0),
240
+ w("span", {
241
+ class: "tr-history__item-actions",
242
+ onClick: e[6] || (e[6] = J(() => {
243
+ }, ["stop"]))
244
+ }, [
245
+ t.showRenameControls && n(p) === l ? (r(), a("button", {
246
+ key: 0,
247
+ class: "editor-confirm",
248
+ ref_for: !0,
249
+ ref_key: "editorConfirmRefList",
250
+ ref: y,
251
+ onClick: e[4] || (e[4] = //@ts-ignore
252
+ (...d) => n(v) && n(v)(...d))
253
+ }, [
254
+ T(n(me))
255
+ ], 512)) : G("", !0),
256
+ t.showRenameControls && n(p) === l ? (r(), a("button", {
257
+ key: 1,
258
+ class: "editor-cancel",
259
+ ref_for: !0,
260
+ ref_key: "editorCancelRefList",
261
+ ref: M,
262
+ onClick: e[5] || (e[5] = //@ts-ignore
263
+ (...d) => n(o) && n(o)(...d))
264
+ }, [
265
+ T(n(fe))
266
+ ], 512)) : G("", !0),
267
+ w("button", {
268
+ class: U(["menu", { hidden: n(p) === l }]),
269
+ onClick: (d) => K(d, l)
270
+ }, [
271
+ T(n(pe))
272
+ ], 10, Se)
273
+ ])
274
+ ], 10, Ge))), 128))
275
+ ])
276
+ ]))), 128)),
277
+ A(T(Me, {
278
+ trigger: g.value,
279
+ "onUpdate:trigger": e[7] || (e[7] = (f) => g.value = f),
280
+ data: u.value,
281
+ "onUpdate:data": e[8] || (e[8] = (f) => u.value = f),
282
+ items: t.menuItems,
283
+ "menu-list-gap": t.menuListGap,
284
+ onItemClick: ee
285
+ }, null, 8, ["trigger", "data", "items", "menu-list-gap"]), [
286
+ [ae, g.value]
287
+ ])
288
+ ], 64))
289
+ ], 2));
494
290
  }
495
- }), st = {
496
- Box: ae,
497
- Text: le
291
+ }), N = /* @__PURE__ */ z(Be, [["__scopeId", "data-v-97a7e8a2"]]), De = function(s) {
292
+ s.component(N.name, N);
498
293
  };
499
- L.name = "TrBubble";
500
- const Xe = function(t) {
501
- t.component(L.name, L);
502
- };
503
- L.install = Xe;
504
- const ot = L;
505
- O.name = "TrBubbleList";
506
- const ze = function(t) {
507
- t.component(O.name, O);
508
- };
509
- O.install = ze;
510
- const rt = O;
511
- F.name = "TrBubbleProvider";
512
- const qe = function(t) {
513
- t.component(F.name, F);
514
- };
515
- F.install = qe;
516
- const at = F;
294
+ Object.assign(N, {
295
+ name: "TrHistory",
296
+ install: De
297
+ });
517
298
  export {
518
- ot as B,
519
- rt as a,
520
- at as b,
521
- et as c,
522
- st as d,
523
- Ae as e,
524
- $e as f,
525
- tt as g,
526
- Oe as h,
527
- nt as i,
528
- je as u
299
+ N as H,
300
+ Ce as u
529
301
  };