@opentiny/tiny-robot 0.3.0-alpha.8 → 0.3.0-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.
@@ -1,286 +1,284 @@
1
- import { ref as F, watch as Q, reactive as at, computed as E, nextTick as G, defineComponent as ge, createElementBlock as O, openBlock as S, createCommentVNode as A, normalizeStyle as Fe, createBlock as X, unref as b, withCtx as ce, createElementVNode as N, createVNode as z, normalizeClass as Y, toDisplayString as le, useAttrs as lt, resolveComponent as it, mergeProps as pe, Fragment as de, renderList as he, mergeModels as rt, useModel as ut, Transition as De, withModifiers as ct, useSlots as dt, renderSlot as ae, isRef as ft, createTextVNode as Ue } from "vue";
2
- import { I as pt } from "../index6.js";
3
- import { d as ht } from "../index3.js";
4
- import { T as Be } from "../index2.js";
5
- import { d as gt, o as vt, j as yt, a as mt, S as St, K as wt, u as _t } from "../tiny-robot-svgs.js";
1
+ import { ref as E, watch as Z, reactive as et, computed as D, nextTick as q, defineComponent as ge, createElementBlock as R, openBlock as m, createCommentVNode as K, normalizeStyle as De, createBlock as X, unref as k, withCtx as pe, createElementVNode as A, createVNode as j, normalizeClass as ee, toDisplayString as le, useAttrs as tt, resolveComponent as nt, mergeProps as fe, Fragment as ce, renderList as he, mergeModels as st, useModel as ot, Transition as Ee, withModifiers as at, useSlots as lt, renderSlot as ae, isRef as it, createTextVNode as Ne } from "vue";
2
+ import { I as rt } from "../index6.js";
3
+ import { T as Me } from "../index5.js";
4
+ import { I as ut, L as ct, v as dt, t as ft, w as pt, P as ht, _ as gt } from "../tiny-robot-svgs.js";
6
5
  import { _ as be } from "../_plugin-vue_export-helper.js";
7
- import { t as bt } from "../utils.js";
8
- function Ct(i, u) {
9
- const s = F(i.modelValue || i.defaultValue || ""), r = F(null);
10
- Q(
6
+ import { t as vt } from "../utils.js";
7
+ function yt(i, r) {
8
+ const a = E(i.modelValue || i.defaultValue || ""), c = E(null);
9
+ Z(
11
10
  () => i.modelValue,
12
- (p) => {
13
- p !== void 0 && p !== s.value && (s.value = p);
11
+ (h) => {
12
+ h !== void 0 && h !== a.value && (a.value = h);
14
13
  }
15
- ), Q(
16
- () => s.value,
17
- (p) => {
18
- u("update:modelValue", p);
14
+ ), Z(
15
+ () => a.value,
16
+ (h) => {
17
+ r("update:modelValue", h);
19
18
  }
20
19
  );
21
- const y = (p) => {
22
- s.value = p, u("update:modelValue", p);
23
- }, w = (p) => {
24
- p == null || p.preventDefault();
25
- const k = s.value;
26
- !i.disabled && !i.loading && k.trim() && u("submit", k);
27
- }, a = () => {
28
- s.value = "", u("update:modelValue", ""), u("clear");
29
- }, h = F(!1);
20
+ const y = (h) => {
21
+ a.value = h, r("update:modelValue", h);
22
+ }, w = (h) => {
23
+ h == null || h.preventDefault();
24
+ const _ = a.value;
25
+ !i.disabled && !i.loading && _.trim() && r("submit", _);
26
+ }, n = () => {
27
+ a.value = "", r("update:modelValue", ""), r("clear");
28
+ }, p = E(!1);
30
29
  return {
31
- inputValue: s,
32
- inputWrapper: r,
33
- isComposing: h,
30
+ inputValue: a,
31
+ inputWrapper: c,
32
+ isComposing: p,
34
33
  handleChange: y,
35
34
  handleSubmit: w,
36
- handleClear: a,
35
+ handleClear: n,
37
36
  clearInput: () => {
38
- a();
37
+ n();
39
38
  }
40
39
  };
41
40
  }
42
- function kt(i, u, s, r, y, w, a, h, _, p, k, g, T, m, L, M) {
43
- const B = () => {
44
- g.value && (L != null && L.value && (M == null || M()), u("submit", s.value.trim()));
45
- }, v = (f, K) => {
46
- if (!(f.key === "Enter")) return !1;
47
- switch (K) {
41
+ function mt(i, r, a, c, y, w, n, p, C, h, _, g, I, d, L, U) {
42
+ const $ = () => {
43
+ g.value && (L != null && L.value && (U == null || U()), r("submit", a.value.trim()));
44
+ }, z = (v, F) => {
45
+ if (!(v.key === "Enter")) return !1;
46
+ switch (F) {
48
47
  case "enter":
49
- return !f.shiftKey && !f.ctrlKey && !f.metaKey;
48
+ return !v.shiftKey && !v.ctrlKey && !v.metaKey;
50
49
  case "ctrlEnter":
51
- return (f.ctrlKey || f.metaKey) && !f.shiftKey;
50
+ return (v.ctrlKey || v.metaKey) && !v.shiftKey;
52
51
  case "shiftEnter":
53
- return f.shiftKey && !f.ctrlKey && !f.metaKey;
52
+ return v.shiftKey && !v.ctrlKey && !v.metaKey;
54
53
  default:
55
54
  return !1;
56
55
  }
57
56
  };
58
57
  return {
59
- handleKeyPress: (f) => {
60
- if (r.value) return;
61
- if (f.key === "Enter" && f.shiftKey && (T == null ? void 0 : T.value) === "single" && m) {
62
- f.preventDefault(), m();
63
- const q = f.target, V = q.selectionStart, Z = s.value;
64
- s.value = Z.substring(0, V) + `
65
- ` + Z.substring(V), setTimeout(() => {
66
- q.selectionStart = q.selectionEnd = V + 1;
58
+ handleKeyPress: (v) => {
59
+ if (c.value) return;
60
+ if (v.key === "Enter" && v.shiftKey && (I == null ? void 0 : I.value) === "single" && d) {
61
+ v.preventDefault(), d();
62
+ const V = v.target, W = V.selectionStart, G = a.value;
63
+ a.value = G.substring(0, W) + `
64
+ ` + G.substring(W), setTimeout(() => {
65
+ V.selectionStart = V.selectionEnd = W + 1;
67
66
  }, 0);
68
67
  return;
69
68
  }
70
- if (f.key === "Tab" && w.value && a.value) {
71
- f.preventDefault(), h();
69
+ if (v.key === "Tab" && w.value && n.value) {
70
+ v.preventDefault(), p();
72
71
  return;
73
72
  }
74
73
  if (w.value) {
75
- if (f.key === "ArrowDown") {
76
- f.preventDefault(), p("down");
74
+ if (v.key === "ArrowDown") {
75
+ v.preventDefault(), h("down");
77
76
  return;
78
77
  }
79
- if (f.key === "ArrowUp") {
80
- f.preventDefault(), p("up");
78
+ if (v.key === "ArrowUp") {
79
+ v.preventDefault(), h("up");
81
80
  return;
82
81
  }
83
- if (f.key === "Enter" && a.value) {
84
- f.preventDefault(), h();
82
+ if (v.key === "Enter" && n.value) {
83
+ v.preventDefault(), p();
85
84
  return;
86
85
  }
87
86
  }
88
- if (f.key === "Escape") {
89
- w.value ? (_(), f.preventDefault()) : y.isRecording && (k(), f.preventDefault()), u("escape-press");
87
+ if (v.key === "Escape") {
88
+ w.value ? (C(), v.preventDefault()) : y.isRecording && (_(), v.preventDefault()), r("escape-press");
90
89
  return;
91
90
  }
92
- v(f, i.submitType) && (f.preventDefault(), g.value && B());
91
+ z(v, i.submitType) && (v.preventDefault(), g.value && $());
93
92
  },
94
- triggerSubmit: B
93
+ triggerSubmit: $
95
94
  };
96
95
  }
97
- function xt(i) {
98
- const u = at({
96
+ function wt(i) {
97
+ const r = et({
99
98
  isRecording: !1,
100
99
  isSupported: typeof window < "u" && "webkitSpeechRecognition" in window || "SpeechRecognition" in window,
101
100
  error: void 0
102
- }), s = u.isSupported ? new (window.webkitSpeechRecognition || window.SpeechRecognition)() : void 0;
103
- s !== void 0 && (s.continuous = i.continuous ?? !1, s.interimResults = i.interimResults ?? !0, s.lang = i.lang ?? navigator.language, s.onstart = () => {
104
- var a;
105
- u.isRecording = !0, u.error = void 0, (a = i.onStart) == null || a.call(i);
106
- }, s.onend = () => {
107
- var a;
108
- u.isRecording = !1, (a = i.onEnd) == null || a.call(i);
109
- }, s.onresult = (a) => {
110
- var _, p;
111
- const h = Array.from(a.results).map((k) => k[0].transcript).join("");
112
- a.results[0].isFinal ? (_ = i.onFinal) == null || _.call(i, h) : (p = i.onInterim) == null || p.call(i, h);
113
- }, s.onerror = (a) => {
114
- var h;
115
- u.error = new Error(a.error), u.isRecording = !1, (h = i.onError) == null || h.call(i, u.error);
101
+ }), a = r.isSupported ? new (window.webkitSpeechRecognition || window.SpeechRecognition)() : void 0;
102
+ a !== void 0 && (a.continuous = i.continuous ?? !1, a.interimResults = i.interimResults ?? !0, a.lang = i.lang ?? navigator.language, a.onstart = () => {
103
+ var n;
104
+ r.isRecording = !0, r.error = void 0, (n = i.onStart) == null || n.call(i);
105
+ }, a.onend = () => {
106
+ var n;
107
+ r.isRecording = !1, (n = i.onEnd) == null || n.call(i);
108
+ }, a.onresult = (n) => {
109
+ var C, h;
110
+ const p = Array.from(n.results).map((_) => _[0].transcript).join("");
111
+ n.results[0].isFinal ? (C = i.onFinal) == null || C.call(i, p) : (h = i.onInterim) == null || h.call(i, p);
112
+ }, a.onerror = (n) => {
113
+ var p;
114
+ r.error = new Error(n.error), r.isRecording = !1, (p = i.onError) == null || p.call(i, r.error);
116
115
  });
117
- const r = () => {
118
- var a;
119
- if (!s) {
120
- const h = new Error("浏览器不支持语音识别");
121
- u.error = h, (a = i.onError) == null || a.call(i, h);
116
+ const c = () => {
117
+ var n;
118
+ if (!a) {
119
+ const p = new Error("浏览器不支持语音识别");
120
+ r.error = p, (n = i.onError) == null || n.call(i, p);
122
121
  return;
123
122
  }
124
- if (u.isRecording) {
123
+ if (r.isRecording) {
125
124
  try {
126
- s.stop(), setTimeout(() => {
125
+ a.stop(), setTimeout(() => {
127
126
  try {
128
- s.start();
129
- } catch (h) {
130
- w(h);
127
+ a.start();
128
+ } catch (p) {
129
+ w(p);
131
130
  }
132
131
  }, 100);
133
- } catch (h) {
134
- w(h);
132
+ } catch (p) {
133
+ w(p);
135
134
  }
136
135
  return;
137
136
  }
138
137
  try {
139
- s.start();
140
- } catch (h) {
141
- w(h);
138
+ a.start();
139
+ } catch (p) {
140
+ w(p);
142
141
  }
143
142
  }, y = () => {
144
- if (s && u.isRecording)
143
+ if (a && r.isRecording)
145
144
  try {
146
- s.stop();
147
- } catch (a) {
148
- w(a);
145
+ a.stop();
146
+ } catch (n) {
147
+ w(n);
149
148
  }
150
- }, w = (a) => {
151
- var h;
152
- u.error = a instanceof Error ? a : new Error("语音识别操作失败"), u.isRecording = !1, (h = i.onError) == null || h.call(i, u.error);
149
+ }, w = (n) => {
150
+ var p;
151
+ r.error = n instanceof Error ? n : new Error("语音识别操作失败"), r.isRecording = !1, (p = i.onError) == null || p.call(i, r.error);
153
152
  };
154
153
  return {
155
- speechState: u,
156
- start: r,
154
+ speechState: r,
155
+ start: c,
157
156
  stop: y
158
157
  };
159
158
  }
160
- const It = (i, u) => {
161
- if (!u || !i)
159
+ const St = (i, r) => {
160
+ if (!r || !i)
162
161
  return [{ text: i, isMatch: !1 }];
163
- const s = i.toLowerCase(), r = u.toLowerCase(), y = [];
162
+ const a = i.toLowerCase(), c = r.toLowerCase(), y = [];
164
163
  let w = 0;
165
- for (; w < s.length; ) {
166
- const p = s.indexOf(r, w);
167
- if (p === -1) break;
164
+ for (; w < a.length; ) {
165
+ const h = a.indexOf(c, w);
166
+ if (h === -1) break;
168
167
  y.push({
169
- start: p,
170
- end: p + u.length
171
- }), w = p + 1;
168
+ start: h,
169
+ end: h + r.length
170
+ }), w = h + 1;
172
171
  }
173
172
  if (y.length === 0)
174
173
  return [{ text: i, isMatch: !1 }];
175
- const a = [];
176
- for (const p of y)
177
- if (a.length === 0)
178
- a.push(p);
174
+ const n = [];
175
+ for (const h of y)
176
+ if (n.length === 0)
177
+ n.push(h);
179
178
  else {
180
- const k = a[a.length - 1];
181
- p.start <= k.end ? k.end = Math.max(k.end, p.end) : a.push(p);
179
+ const _ = n[n.length - 1];
180
+ h.start <= _.end ? _.end = Math.max(_.end, h.end) : n.push(h);
182
181
  }
183
- const h = [];
184
- let _ = 0;
185
- for (const p of a)
186
- _ < p.start && h.push({
187
- text: i.substring(_, p.start),
182
+ const p = [];
183
+ let C = 0;
184
+ for (const h of n)
185
+ C < h.start && p.push({
186
+ text: i.substring(C, h.start),
188
187
  isMatch: !1
189
- }), h.push({
190
- text: i.substring(p.start, p.end),
188
+ }), p.push({
189
+ text: i.substring(h.start, h.end),
191
190
  isMatch: !0
192
- }), _ = p.end;
193
- return _ < i.length && h.push({
194
- text: i.substring(_),
191
+ }), C = h.end;
192
+ return C < i.length && p.push({
193
+ text: i.substring(C),
195
194
  isMatch: !1
196
- }), h;
195
+ }), p;
197
196
  };
198
- function Rt(i, u, s, r, y) {
199
- const w = F(!1), a = F(-1), h = F(-1), _ = F(""), p = F(!1), k = F(null), g = F(!1), T = F(null), m = E(() => {
200
- if (!i.suggestions || !s.value || y.value) return [];
201
- const R = s.value.toLowerCase();
202
- return i.suggestions.filter((U) => U.toLowerCase().includes(R));
203
- }), L = E(() => {
204
- let R = -1;
205
- return T.value === "mouse" && h.value !== -1 ? R = h.value : T.value === "keyboard" && a.value !== -1 && (R = a.value), m.value[R] || null;
206
- }), M = (R) => R === a.value || R === h.value, B = (R) => {
207
- if (T.value === null) {
208
- _.value = "", p.value = !1;
197
+ function _t(i, r, a, c, y) {
198
+ const w = E(!1), n = E(-1), p = E(-1), C = E(""), h = E(!1), _ = E(null), g = E(!1), I = E(null), d = D(() => {
199
+ if (!i.suggestions || !a.value || y.value) return [];
200
+ const x = a.value.toLowerCase();
201
+ return i.suggestions.filter((N) => N.toLowerCase().includes(x));
202
+ }), L = D(() => {
203
+ let x = -1;
204
+ return I.value === "mouse" && p.value !== -1 ? x = p.value : I.value === "keyboard" && n.value !== -1 && (x = n.value), d.value[x] || null;
205
+ }), U = (x) => x === n.value || x === p.value, $ = (x) => {
206
+ if (I.value === null) {
207
+ C.value = "", h.value = !1;
209
208
  return;
210
209
  }
211
- const U = R || L.value;
212
- U && s.value && U.toLowerCase().startsWith(s.value.toLowerCase()) ? (_.value = U.substring(s.value.length), p.value = !0) : (_.value = "", p.value = !1);
210
+ const N = x || L.value;
211
+ N && a.value && N.toLowerCase().startsWith(a.value.toLowerCase()) ? (C.value = N.substring(a.value.length), h.value = !0) : (C.value = "", h.value = !1);
212
+ }, z = () => {
213
+ w.value = !1, n.value = -1, p.value = -1, I.value = null, C.value = "", h.value = !1;
214
+ }, te = () => {
215
+ w.value = !0, n.value = -1, p.value = -1, I.value = null, $();
213
216
  }, v = () => {
214
- w.value = !1, a.value = -1, h.value = -1, T.value = null, _.value = "", p.value = !1;
215
- }, H = () => {
216
- w.value = !0, a.value = -1, h.value = -1, T.value = null, B();
217
- }, f = () => {
218
- r.value || g.value || G(() => {
219
- s.value && i.suggestions && i.suggestions.length > 0 && !y.value && m.value.length > 0 ? H() : v();
217
+ c.value || g.value || q(() => {
218
+ a.value && i.suggestions && i.suggestions.length > 0 && !y.value && d.value.length > 0 ? te() : z();
220
219
  });
221
220
  };
222
- Q(s, f), Q(() => i.suggestions, f);
223
- const K = (R) => {
224
- g.value = !0, s.value = R, u("update:modelValue", R), u("suggestion-select", R), V(), G(() => {
221
+ Z(a, v), Z(() => i.suggestions, v);
222
+ const F = (x) => {
223
+ g.value = !0, a.value = x, r("update:modelValue", x), r("suggestion-select", x), W(), q(() => {
225
224
  g.value = !1;
226
225
  });
227
- }, q = () => {
228
- L.value && K(L.value);
229
226
  }, V = () => {
230
- v();
227
+ L.value && F(L.value);
228
+ }, W = () => {
229
+ z();
231
230
  };
232
231
  return {
233
232
  showSuggestionsPopup: w,
234
- completionPlaceholder: _,
235
- showTabHint: p,
236
- suggestionsListRef: k,
237
- filteredSuggestions: m,
233
+ completionPlaceholder: C,
234
+ showTabHint: h,
235
+ suggestionsListRef: _,
236
+ filteredSuggestions: d,
238
237
  activeSuggestion: L,
239
- isItemHighlighted: M,
240
- updateCompletionPlaceholder: B,
241
- updateSuggestionsState: f,
242
- selectSuggestion: K,
243
- acceptCurrentSuggestion: q,
244
- closeSuggestionsPopup: V,
245
- navigateSuggestions: (R) => {
246
- if (!w.value || m.value.length === 0) return;
247
- T.value = "keyboard", a.value === -1 ? a.value = R === "down" ? 0 : m.value.length - 1 : R === "down" ? a.value = (a.value + 1) % m.value.length : a.value = (a.value - 1 + m.value.length) % m.value.length;
248
- const U = m.value[a.value];
249
- U && B(U);
250
- const j = k.value;
251
- if (j) {
252
- const ne = j.children[a.value];
238
+ isItemHighlighted: U,
239
+ updateCompletionPlaceholder: $,
240
+ updateSuggestionsState: v,
241
+ selectSuggestion: F,
242
+ acceptCurrentSuggestion: V,
243
+ closeSuggestionsPopup: W,
244
+ navigateSuggestions: (x) => {
245
+ if (!w.value || d.value.length === 0) return;
246
+ I.value = "keyboard", n.value === -1 ? n.value = x === "down" ? 0 : d.value.length - 1 : x === "down" ? n.value = (n.value + 1) % d.value.length : n.value = (n.value - 1 + d.value.length) % d.value.length;
247
+ const N = d.value[n.value];
248
+ N && $(N);
249
+ const M = _.value;
250
+ if (M) {
251
+ const ne = M.children[n.value];
253
252
  ne && ne.scrollIntoView({ block: "nearest" });
254
253
  }
255
254
  },
256
- handleSuggestionItemHover: (R) => {
257
- T.value = "mouse", h.value = R, B(m.value[R]);
255
+ handleSuggestionItemHover: (x) => {
256
+ I.value = "mouse", p.value = x, $(d.value[x]);
258
257
  },
259
258
  handleSuggestionItemLeave: () => {
260
- if (h.value = -1, a.value !== -1) {
261
- T.value = "keyboard";
262
- const R = m.value[a.value];
263
- R && B(R);
259
+ if (p.value = -1, n.value !== -1) {
260
+ I.value = "keyboard";
261
+ const x = d.value[n.value];
262
+ x && $(x);
264
263
  } else
265
- T.value = null, B();
264
+ I.value = null, $();
266
265
  },
267
266
  handleClickOutside: () => {
268
- V();
267
+ W();
269
268
  },
270
- highlightSuggestionText: It
269
+ highlightSuggestionText: St
271
270
  };
272
271
  }
273
- const Tt = { class: "action-buttons" }, Ot = { class: "action-buttons__submit-content" }, $t = {
272
+ const bt = { class: "action-buttons" }, Ct = { class: "action-buttons__button" }, kt = { class: "action-buttons__submit-content" }, xt = {
274
273
  key: 0,
275
274
  class: "action-buttons__cancel-text"
276
- }, Bt = /* @__PURE__ */ ge({
275
+ }, It = /* @__PURE__ */ ge({
277
276
  __name: "ActionButtons",
278
277
  props: {
279
278
  loading: { type: Boolean, default: !1 },
280
279
  disabled: { type: Boolean, default: !1 },
281
280
  showClear: { type: Boolean, default: !0 },
282
281
  hasContent: { type: Boolean, default: !1 },
283
- buttonGroup: {},
284
282
  allowSpeech: { type: Boolean, default: !1 },
285
283
  speechStatus: { default: () => ({
286
284
  isRecording: !1,
@@ -292,134 +290,97 @@ const Tt = { class: "action-buttons" }, Ot = { class: "action-buttons__submit-co
292
290
  isOverLimit: { type: Boolean, default: !1 },
293
291
  stopText: { default: void 0 }
294
292
  },
295
- emits: ["clear", "toggle-speech", "submit", "cancel", "trigger-select"],
296
- setup(i, { emit: u }) {
297
- const s = i, r = u, y = E(() => {
298
- var H, f;
299
- const v = (f = (H = s.buttonGroup) == null ? void 0 : H.file) == null ? void 0 : f.tooltips;
300
- if (typeof v == "string" && v)
301
- return () => v;
302
- if (typeof v == "function")
303
- return v;
304
- }), w = E(() => {
305
- var H, f;
306
- const v = (f = (H = s.buttonGroup) == null ? void 0 : H.submit) == null ? void 0 : f.tooltips;
307
- if (typeof v == "string" && v)
308
- return () => v;
309
- if (typeof v == "function")
310
- return v;
311
- }), a = E(() => s.allowSpeech), h = E(() => s.speechStatus.isRecording), _ = E(() => s.disabled), p = E(() => {
312
- var v, H;
313
- return _.value || s.isOverLimit || ((H = (v = s.buttonGroup) == null ? void 0 : v.submit) == null ? void 0 : H.disabled);
314
- }), k = E(() => s.allowFiles || s.allowSpeech || s.showClear), g = () => {
315
- _.value || r("clear");
316
- }, T = () => {
317
- if (!_.value) {
318
- const v = !s.speechStatus.isRecording;
319
- r("toggle-speech", v);
293
+ emits: ["clear", "toggle-speech", "submit", "cancel"],
294
+ setup(i, { emit: r }) {
295
+ const a = i, c = r, y = D(() => a.allowSpeech), w = D(() => a.speechStatus.isRecording), n = D(() => a.disabled), p = D(() => n.value || a.isOverLimit), C = D(() => a.allowFiles || a.allowSpeech || a.showClear), h = () => {
296
+ n.value || c("clear");
297
+ }, _ = () => {
298
+ if (!n.value) {
299
+ const d = !a.speechStatus.isRecording;
300
+ c("toggle-speech", d);
320
301
  }
321
- }, m = () => {
322
- p.value || r("submit");
323
- }, L = () => {
324
- _.value || r("cancel");
325
- }, M = E(() => {
326
- var v, H;
327
- return _.value || ((H = (v = s.buttonGroup) == null ? void 0 : v.file) == null ? void 0 : H.disabled);
328
- }), B = () => {
329
- M.value || r("trigger-select");
302
+ }, g = () => {
303
+ p.value || c("submit");
304
+ }, I = () => {
305
+ n.value || c("cancel");
330
306
  };
331
- return (v, H) => (S(), O("div", Tt, [
332
- k.value ? (S(), O("div", {
307
+ return (d, L) => (m(), R("div", bt, [
308
+ C.value ? (m(), R("div", {
333
309
  key: 0,
334
310
  class: "action-buttons__utility",
335
- style: Fe({ "padding-right": v.hasContent || v.loading ? "0" : "6px" })
311
+ style: De({ "padding-right": d.hasContent || d.loading ? "0" : "6px" })
336
312
  }, [
337
- v.allowFiles && !v.loading ? (S(), X(b(Be), {
313
+ d.allowFiles && !d.loading ? (m(), X(k(Me), {
338
314
  key: 0,
339
- effect: "light",
340
- placement: "top",
341
- "render-content": y.value,
342
- "visible-arrow": !1
315
+ content: "上传文件",
316
+ placement: "top"
343
317
  }, {
344
- default: ce(() => [
345
- N("div", {
346
- class: "action-buttons__button",
347
- onClick: B
348
- }, [
349
- z(b(gt), {
350
- class: Y(["action-buttons__icon", "action-buttons__icon--upload", { "is-disabled": M.value }]),
318
+ default: pe(() => [
319
+ A("div", Ct, [
320
+ j(k(ut), {
321
+ class: "action-buttons__icon",
351
322
  alt: "上传文件"
352
- }, null, 8, ["class"])
323
+ })
353
324
  ])
354
325
  ]),
355
326
  _: 1
356
- }, 8, ["render-content"])) : A("", !0),
357
- a.value && !v.loading ? (S(), O("div", {
327
+ })) : K("", !0),
328
+ y.value && !d.loading ? (m(), R("div", {
358
329
  key: 1,
359
- class: Y(["action-buttons__button", { "is-recording": h.value }]),
360
- onClick: T
330
+ class: ee(["action-buttons__button", { "is-recording": w.value }]),
331
+ onClick: _
361
332
  }, [
362
- h.value ? (S(), X(b(yt), {
333
+ w.value ? (m(), X(k(dt), {
363
334
  key: 1,
364
335
  class: "action-buttons__icon action-buttons__icon--recording",
365
336
  alt: "语音中"
366
- })) : (S(), X(b(vt), {
337
+ })) : (m(), X(k(ct), {
367
338
  key: 0,
368
339
  class: "action-buttons__icon",
369
340
  alt: "录音"
370
341
  }))
371
- ], 2)) : A("", !0),
372
- v.showClear ? (S(), X(b(Be), {
342
+ ], 2)) : K("", !0),
343
+ d.showClear ? (m(), X(k(Me), {
373
344
  key: 2,
374
345
  content: "清空内容",
375
346
  placement: "top"
376
347
  }, {
377
- default: ce(() => [
378
- N("div", {
348
+ default: pe(() => [
349
+ A("div", {
379
350
  class: "action-buttons__button",
380
- onClick: g
351
+ onClick: h
381
352
  }, [
382
- z(b(mt), { class: "action-buttons__icon action-buttons__icon--clear" })
353
+ j(k(ft), { class: "action-buttons__icon action-buttons__icon--clear" })
383
354
  ])
384
355
  ]),
385
356
  _: 1
386
- })) : A("", !0)
387
- ], 4)) : A("", !0),
388
- v.hasContent || v.loading ? (S(), O("div", {
357
+ })) : K("", !0)
358
+ ], 4)) : K("", !0),
359
+ d.hasContent || d.loading ? (m(), R("div", {
389
360
  key: 1,
390
361
  class: "action-buttons__button action-buttons__submit",
391
- onClick: H[0] || (H[0] = (f) => v.loading ? L() : m())
362
+ onClick: L[0] || (L[0] = (U) => d.loading ? I() : g())
392
363
  }, [
393
- N("div", Ot, [
394
- v.loading ? (S(), O("div", {
364
+ A("div", kt, [
365
+ d.loading ? (m(), R("div", {
395
366
  key: 1,
396
- class: Y(["action-buttons__cancel", { "action-buttons__cancel--icon-only": !v.stopText }])
367
+ class: ee(["action-buttons__cancel", { "action-buttons__cancel--icon-only": !d.stopText }])
397
368
  }, [
398
- z(b(wt), {
369
+ j(k(ht), {
399
370
  class: "action-buttons__icon action-buttons__icon--cancel",
400
371
  alt: "停止"
401
372
  }),
402
- v.stopText ? (S(), O("span", $t, le(v.stopText), 1)) : A("", !0)
403
- ], 2)) : (S(), X(b(Be), {
373
+ d.stopText ? (m(), R("span", xt, le(d.stopText), 1)) : K("", !0)
374
+ ], 2)) : (m(), X(k(pt), {
404
375
  key: 0,
405
- effect: "light",
406
- placement: "top",
407
- "render-content": w.value,
408
- "visible-arrow": !1
409
- }, {
410
- default: ce(() => [
411
- z(b(St), {
412
- class: Y(["action-buttons__icon", "action-buttons__icon--send", { "is-disabled": p.value }]),
413
- alt: "发送"
414
- }, null, 8, ["class"])
415
- ]),
416
- _: 1
417
- }, 8, ["render-content"]))
376
+ class: ee(["action-buttons__icon", "action-buttons__icon--send", { "is-disabled": p.value }]),
377
+ alt: "发送"
378
+ }, null, 8, ["class"]))
418
379
  ])
419
- ])) : A("", !0)
380
+ ])) : K("", !0)
420
381
  ]));
421
382
  }
422
- }), je = /* @__PURE__ */ be(Bt, [["__scopeId", "data-v-2b573a4e"]]), Lt = ["data-id", "data-type"], Et = ["data-id", "data-type"], Dt = /* @__PURE__ */ ge({
383
+ }), qe = /* @__PURE__ */ be(It, [["__scopeId", "data-v-f811794c"]]), Rt = ["data-id", "data-type"], Ot = ["data-id", "data-type"], Tt = /* @__PURE__ */ ge({
423
384
  inheritAttrs: !1,
424
385
  __name: "Block",
425
386
  props: {
@@ -430,60 +391,60 @@ const Tt = { class: "action-buttons" }, Ot = { class: "action-buttons__submit-co
430
391
  asChild: { type: Boolean }
431
392
  },
432
393
  setup(i) {
433
- const u = i, s = lt();
434
- return (r, y) => {
435
- const w = it("Block", !0);
436
- return u.type !== "block" ? (S(), O("span", pe({
394
+ const r = i, a = tt();
395
+ return (c, y) => {
396
+ const w = nt("Block", !0);
397
+ return r.type !== "block" ? (m(), R("span", fe({
437
398
  key: 0,
438
- "data-id": u.id,
439
- "data-type": u.type
440
- }, b(s)), le(u.content), 17, Lt)) : (S(), O(de, { key: 1 }, [
441
- u.asChild ? (S(!0), O(de, { key: 0 }, he(u.content, (a) => (S(), X(w, pe({
442
- key: `${a.id}-${a.type}`
443
- }, { ref_for: !0 }, a), null, 16))), 128)) : (S(), O("span", pe({
399
+ "data-id": r.id,
400
+ "data-type": r.type
401
+ }, k(a)), le(r.content), 17, Rt)) : (m(), R(ce, { key: 1 }, [
402
+ r.asChild ? (m(!0), R(ce, { key: 0 }, he(r.content, (n) => (m(), X(w, fe({
403
+ key: `${n.id}-${n.type}`
404
+ }, { ref_for: !0 }, n), null, 16))), 128)) : (m(), R("span", fe({
444
405
  key: 1,
445
- "data-id": u.id,
446
- "data-type": u.type
447
- }, b(s)), [
448
- (S(!0), O(de, null, he(u.content, (a) => (S(), X(w, pe({
449
- key: `${a.id}-${a.type}`
450
- }, { ref_for: !0 }, a), null, 16))), 128))
451
- ], 16, Et))
406
+ "data-id": r.id,
407
+ "data-type": r.type
408
+ }, k(a)), [
409
+ (m(!0), R(ce, null, he(r.content, (n) => (m(), X(w, fe({
410
+ key: `${n.id}-${n.type}`
411
+ }, { ref_for: !0 }, n), null, 16))), 128))
412
+ ], 16, Ot))
452
413
  ], 64));
453
414
  };
454
415
  }
455
- }), Ft = /* @__PURE__ */ be(Dt, [["__scopeId", "data-v-13862606"]]);
456
- function Ht(i, u = {}) {
457
- let s = [], r = [], y = i;
458
- return { commit: (k) => {
416
+ }), $t = /* @__PURE__ */ be(Tt, [["__scopeId", "data-v-13862606"]]);
417
+ function Lt(i, r = {}) {
418
+ let a = [], c = [], y = i;
419
+ return { commit: (_) => {
459
420
  var g;
460
- s.push(y), y = k, r.length && ((g = u.onRemoveHistory) == null || g.call(u, r)), r = [];
461
- }, undo: () => s.length ? (r.push(y), y = s.pop(), y) : null, redo: () => r.length ? (s.push(y), y = r.pop(), y) : null, clear: () => {
462
- var k, g;
463
- s.length && ((k = u.onRemoveHistory) == null || k.call(u, s)), r.length && ((g = u.onRemoveHistory) == null || g.call(u, r)), s = [], r = [];
421
+ a.push(y), y = _, c.length && ((g = r.onRemoveHistory) == null || g.call(r, c)), c = [];
422
+ }, undo: () => a.length ? (c.push(y), y = a.pop(), y) : null, redo: () => c.length ? (a.push(y), y = c.pop(), y) : null, clear: () => {
423
+ var _, g;
424
+ a.length && ((_ = r.onRemoveHistory) == null || _.call(r, a)), c.length && ((g = r.onRemoveHistory) == null || g.call(r, c)), a = [], c = [];
464
425
  }, get: () => y };
465
426
  }
466
- const Kt = { class: "editor-container" }, Le = "​", Ee = "​", Pt = /* @__PURE__ */ ge({
427
+ const Bt = { class: "editor-container" }, Le = "​", Be = "​", Et = /* @__PURE__ */ ge({
467
428
  __name: "TemplateEditor",
468
429
  props: {
469
430
  modelValue: { default: () => [] },
470
431
  modelModifiers: {}
471
432
  },
472
- emits: /* @__PURE__ */ rt(["submit"], ["update:modelValue"]),
473
- setup(i, { expose: u, emit: s }) {
474
- const r = typeof window.ShadowRoot.prototype.getSelection == "function", y = typeof window.Selection.prototype.getComposedRanges == "function";
433
+ emits: /* @__PURE__ */ st(["submit"], ["update:modelValue"]),
434
+ setup(i, { expose: r, emit: a }) {
435
+ const c = typeof window.ShadowRoot.prototype.getSelection == "function", y = typeof window.Selection.prototype.getComposedRanges == "function";
475
436
  function w() {
476
437
  const e = navigator.userAgent;
477
438
  return e.includes("Safari") && !e.includes("Chrome") && !e.includes("Chromium") && !e.includes("CriOS");
478
439
  }
479
- const a = w(), h = () => Math.random().toString(36).substring(2, 15), _ = ut(i, "modelValue"), p = s, k = F(0), g = (e) => e.map((t, o) => ({
440
+ const n = w(), p = () => Math.random().toString(36).substring(2, 15), C = ot(i, "modelValue"), h = a, _ = E(0), g = (e) => e.map((t, o) => ({
480
441
  id: `id-${o}`,
481
- ...t.type === "template" ? { ...t, prefix: Le, suffix: Ee } : t
482
- })), T = (e) => e.map((t) => ({ type: t.type, content: t.content })), m = F(g(_.value || [])), L = E(() => m.value.map((e) => e.type === "template" ? [
442
+ ...t.type === "template" ? { ...t, prefix: Le, suffix: Be } : t
443
+ })), I = (e) => e.map((t) => ({ type: t.type, content: t.content })), d = E(g(C.value || [])), L = D(() => d.value.map((e) => e.type === "template" ? [
483
444
  { id: e.id, type: "prefix", content: e.prefix },
484
445
  { id: e.id, type: "template", content: e.content },
485
446
  { id: e.id, type: "suffix", content: e.suffix }
486
- ] : [e]).flat()), M = E(() => m.value.map((e) => e.type === "text" ? e : a ? {
447
+ ] : [e]).flat()), U = D(() => d.value.map((e) => e.type === "text" ? e : n ? {
487
448
  id: e.id,
488
449
  type: "block",
489
450
  asChild: !0,
@@ -513,86 +474,86 @@ const Kt = { class: "editor-container" }, Le = "​", Ee = "​", Pt = /* @__PUR
513
474
  },
514
475
  { id: e.id, type: "suffix", content: e.suffix }
515
476
  ]
516
- })), B = F(null), v = (e) => {
477
+ })), $ = E(null), z = (e) => {
517
478
  const t = Date.now(), o = JSON.stringify(e);
518
479
  return `${t}:${o}`;
519
- }, H = (e) => {
480
+ }, te = (e) => {
520
481
  const t = parseInt(e.slice(0, 13)), o = JSON.parse(e.slice(14));
521
482
  return {
522
483
  timestamp: t,
523
484
  data: o
524
485
  };
525
- }, f = /* @__PURE__ */ new Map(), K = Ht(v(m.value), {
486
+ }, v = /* @__PURE__ */ new Map(), F = Lt(z(d.value), {
526
487
  onRemoveHistory: (e) => {
527
488
  for (const t of e)
528
- f.delete(t);
489
+ v.delete(t);
529
490
  }
530
491
  });
531
- Q(
532
- () => _.value,
492
+ Z(
493
+ () => C.value,
533
494
  (e) => {
534
- m.value = g(e || []), K.commit(v(m.value));
495
+ d.value = g(e || []), F.commit(z(d.value));
535
496
  },
536
497
  { deep: !0 }
537
498
  );
538
- const q = (e, t = document.body) => t.contains(e) ? e instanceof HTMLElement && e.dataset.id ? e : e.parentElement ? q(e.parentElement, t) : null : null, V = (e) => e === B.value, Z = (e) => {
499
+ const V = (e, t = document.body) => t.contains(e) ? e instanceof HTMLElement && e.dataset.id ? e : e.parentElement ? V(e.parentElement, t) : null : null, W = (e) => e === $.value, G = (e) => {
539
500
  const t = window.getSelection();
540
501
  if (!t)
541
502
  return null;
542
- const o = t.rangeCount > 0 ? t.getRangeAt(0) : null, c = e.getRootNode();
543
- if (!(c instanceof ShadowRoot))
503
+ const o = t.rangeCount > 0 ? t.getRangeAt(0) : null, u = e.getRootNode();
504
+ if (!(u instanceof ShadowRoot))
544
505
  return o;
545
506
  if (y) {
546
- const l = t.getComposedRanges(a ? c : { shadowRoots: [c] });
507
+ const l = t.getComposedRanges(n ? u : { shadowRoots: [u] });
547
508
  return (l == null ? void 0 : l[0]) ?? null;
548
509
  }
549
- if (r) {
550
- const l = c.getSelection();
510
+ if (c) {
511
+ const l = u.getSelection();
551
512
  return l.rangeCount > 0 ? l.getRangeAt(0) : null;
552
513
  }
553
514
  return o;
554
- }, fe = (e, t) => {
555
- var c;
515
+ }, de = (e, t) => {
516
+ var u;
556
517
  if (!e.firstChild || e.firstChild.nodeType !== Node.TEXT_NODE)
557
518
  return console.warn("el.firstChild is not a text node. set anchor and focus to the element with offset 0", e), { node: e, offset: 0 };
558
- const o = ((c = e.firstChild.textContent) == null ? void 0 : c.length) ?? 0;
519
+ const o = ((u = e.firstChild.textContent) == null ? void 0 : u.length) ?? 0;
559
520
  return t > o && console.warn("offset is too large", { offset: t, el: e }), { node: e.firstChild, offset: Math.min(t, o) };
560
- }, ee = (e, t, o, c) => {
521
+ }, Q = (e, t, o, u) => {
561
522
  const l = window.getSelection();
562
523
  if (!l)
563
524
  return;
564
- const { node: d, offset: x } = fe(e, t);
525
+ const { node: f, offset: b } = de(e, t);
565
526
  if (!o) {
566
- l.setBaseAndExtent(d, x, d, x);
527
+ l.setBaseAndExtent(f, b, f, b);
567
528
  return;
568
529
  }
569
- const { node: C, offset: $ } = fe(o, c ?? 0);
570
- l.setBaseAndExtent(d, x, C, $);
530
+ const { node: S, offset: O } = de(o, u ?? 0);
531
+ l.setBaseAndExtent(f, b, S, O);
571
532
  }, J = (e, t) => {
572
- const o = h(), c = { id: o, type: "text", content: e };
533
+ const o = p(), u = { id: o, type: "text", content: e };
573
534
  if (t) {
574
- const l = m.value.findIndex((d) => d.id === t);
575
- l !== -1 ? m.value = m.value.slice(0, l + 1).concat(c).concat(m.value.slice(l + 1)) : console.warn(`can not find item with id: ${t}`);
535
+ const l = d.value.findIndex((f) => f.id === t);
536
+ l !== -1 ? d.value = d.value.slice(0, l + 1).concat(u).concat(d.value.slice(l + 1)) : console.warn(`can not find item with id: ${t}`);
576
537
  } else
577
- m.value.unshift(c);
578
- G(() => {
579
- var d;
580
- const l = (d = B.value) == null ? void 0 : d.querySelector(`[data-id="${o}"][data-type="text"]`);
581
- l && ee(l, e.length);
582
- }), _.value = T(m.value);
583
- }, R = F({
538
+ d.value.unshift(u);
539
+ q(() => {
540
+ var f;
541
+ const l = (f = $.value) == null ? void 0 : f.querySelector(`[data-id="${o}"][data-type="text"]`);
542
+ l && Q(l, e.length);
543
+ }), C.value = I(d.value);
544
+ }, x = E({
584
545
  hasStarted: !1,
585
546
  range: null
586
- }), U = (e) => {
587
- var C;
547
+ }), N = (e) => {
548
+ var S;
588
549
  const t = e;
589
550
  e.preventDefault();
590
- const { inputType: o } = t, c = (t.data || ((C = t.dataTransfer) == null ? void 0 : C.getData("text/plain")) || "").replace(Le, "").replace(Ee, ""), l = t.getTargetRanges()[0];
551
+ const { inputType: o } = t, u = (t.data || ((S = t.dataTransfer) == null ? void 0 : S.getData("text/plain")) || "").replace(Le, "").replace(Be, ""), l = t.getTargetRanges()[0];
591
552
  if (!l) {
592
553
  console.warn("range is null", l);
593
554
  return;
594
555
  }
595
- const d = [
556
+ const f = [
596
557
  "insertText",
597
558
  "insertFromPaste",
598
559
  "insertReplacementText",
@@ -603,17 +564,17 @@ const Kt = { class: "editor-container" }, Le = "​", Ee = "​", Pt = /* @__PUR
603
564
  "deleteSoftLineBackward",
604
565
  "deleteSoftLineForward",
605
566
  "deleteByCut"
606
- ], x = Z(B.value);
607
- if (d.includes(o)) {
608
- if (c && V(l.startContainer) && V(l.endContainer)) {
609
- J(c), x && f.set(K.get(), j(x));
567
+ ], b = G($.value);
568
+ if (f.includes(o)) {
569
+ if (u && W(l.startContainer) && W(l.endContainer)) {
570
+ J(u), b && v.set(F.get(), M(b));
610
571
  return;
611
572
  }
612
- const $ = j(l);
613
- $.startId && $.endId ? (P($, o, c), x && f.set(K.get(), j(x))) : console.warn("range is not valid, range:", $);
614
- } else o === "insertCompositionText" && R.value.hasStarted && (R.value = { hasStarted: !1, range: j(l) });
615
- }, j = (e) => {
616
- const t = q(e.startContainer, B.value), o = q(e.endContainer, B.value);
573
+ const O = M(l);
574
+ O.startId && O.endId ? (P(O, o, u), b && v.set(F.get(), M(b))) : console.warn("range is not valid, range:", O);
575
+ } else o === "insertCompositionText" && x.value.hasStarted && (x.value = { hasStarted: !1, range: M(l) });
576
+ }, M = (e) => {
577
+ const t = V(e.startContainer, $.value), o = V(e.endContainer, $.value);
617
578
  return {
618
579
  collapsed: e.collapsed,
619
580
  endContainer: e.endContainer,
@@ -625,137 +586,137 @@ const Kt = { class: "editor-container" }, Le = "​", Ee = "​", Pt = /* @__PUR
625
586
  startOffset: e.startOffset,
626
587
  startType: t == null ? void 0 : t.dataset.type
627
588
  };
628
- }, ne = (e, t, o, c) => e.slice(0, o) + t + e.slice(c), P = (e, t, o) => {
629
- const c = Ce(e);
630
- if (!Array.isArray(c) || c.length === 0)
589
+ }, ne = (e, t, o, u) => e.slice(0, o) + t + e.slice(u), P = (e, t, o) => {
590
+ const u = Ce(e);
591
+ if (!Array.isArray(u) || u.length === 0)
631
592
  return;
632
- const l = ke(c, e, t, o);
633
- if (l.some((C) => C.tag === "new")) {
634
- const { afterId: C, content: $ } = l[0];
635
- J($, C);
593
+ const l = ke(u, e, t, o);
594
+ if (l.some((S) => S.tag === "new")) {
595
+ const { afterId: S, content: O } = l[0];
596
+ J(O, S);
636
597
  return;
637
598
  }
638
- const d = l, x = [];
639
- for (const [C, $] of d.entries()) {
640
- const W = m.value.find((Oe) => Oe.id === $.id), te = C === 0 ? o : "";
641
- W ? W.type === "text" ? W.content = ne(W.content, te, $.startOffset, $.endOffset) : W.type === "template" ? $.type === "prefix" || $.type === "suffix" ? $.startOffset === 0 && $.endOffset === 1 && te.length === 0 ? W[$.type] = "" : console.warn(`${$.type} can not be inserted text. it only can be deleted`, $) : $.startOffset < 0 || $.endOffset > W.content.length ? x.push(W.id) : W.content = ne(W.content, te, $.startOffset, $.endOffset) : console.warn("dataItem.type is not text or template", W) : console.warn("can not find dataItem", $);
599
+ const f = l, b = [];
600
+ for (const [S, O] of f.entries()) {
601
+ const H = d.value.find((Te) => Te.id === O.id), Y = S === 0 ? o : "";
602
+ H ? H.type === "text" ? H.content = ne(H.content, Y, O.startOffset, O.endOffset) : H.type === "template" ? O.type === "prefix" || O.type === "suffix" ? O.startOffset === 0 && O.endOffset === 1 && Y.length === 0 ? H[O.type] = "" : console.warn(`${O.type} can not be inserted text. it only can be deleted`, O) : O.startOffset < 0 || O.endOffset > H.content.length ? b.push(H.id) : H.content = ne(H.content, Y, O.startOffset, O.endOffset) : console.warn("dataItem.type is not text or template", H) : console.warn("can not find dataItem", O);
642
603
  }
643
- m.value = m.value.filter((C) => !x.includes(C.id)), m.value = m.value.filter((C) => C.type === "text" ? C.content.length > 0 : [C.prefix, C.suffix, C.content].join("").length > 0);
644
- for (const C of m.value.filter(($) => $.type === "template"))
645
- C.prefix.length === 0 && (C.prefix = Le), C.suffix.length === 0 && (C.suffix = Ee);
646
- d.length > 0 && se(d, o), _.value = T(m.value);
604
+ d.value = d.value.filter((S) => !b.includes(S.id)), d.value = d.value.filter((S) => S.type === "text" ? S.content.length > 0 : [S.prefix, S.suffix, S.content].join("").length > 0);
605
+ for (const S of d.value.filter((O) => O.type === "template"))
606
+ S.prefix.length === 0 && (S.prefix = Le), S.suffix.length === 0 && (S.suffix = Be);
607
+ f.length > 0 && se(f, o), C.value = I(d.value);
647
608
  }, se = (e, t) => {
648
- const o = e[0], c = `[data-id="${o.id}"][data-type="${o.type}"]`, l = e.slice(1).map((d) => `[data-id="${d.id}"][data-type="${d.type}"]`);
649
- G(() => {
650
- var x, C;
651
- const d = (x = B.value) == null ? void 0 : x.querySelector(c);
652
- if (d)
653
- ee(d, o.startOffset + t.length);
609
+ const o = e[0], u = `[data-id="${o.id}"][data-type="${o.type}"]`, l = e.slice(1).map((f) => `[data-id="${f.id}"][data-type="${f.type}"]`);
610
+ q(() => {
611
+ var b, S;
612
+ const f = (b = $.value) == null ? void 0 : b.querySelector(u);
613
+ if (f)
614
+ Q(f, o.startOffset + t.length);
654
615
  else if (t.length === 0)
655
- for (const $ of l) {
656
- const W = (C = B.value) == null ? void 0 : C.querySelector($);
657
- if (W) {
658
- ee(W, 0);
616
+ for (const O of l) {
617
+ const H = (S = $.value) == null ? void 0 : S.querySelector(O);
618
+ if (H) {
619
+ Q(H, 0);
659
620
  break;
660
621
  }
661
622
  }
662
623
  else
663
- console.warn(`can not find el with selector: ${c}`);
624
+ console.warn(`can not find el with selector: ${u}`);
664
625
  });
665
626
  }, Ce = (e) => {
666
- const t = L.value.findIndex((x) => x.id === e.startId && x.type === e.startType), o = L.value.findIndex((x) => x.id === e.endId && x.type === e.endType);
627
+ const t = L.value.findIndex((b) => b.id === e.startId && b.type === e.startType), o = L.value.findIndex((b) => b.id === e.endId && b.type === e.endType);
667
628
  if (t === -1 || o === -1 || t > o)
668
629
  return console.warn("startIndex or endIndex is -1, or startIndex > endIndex. ", { range: e }), null;
669
- const c = L.value[t], l = L.value[o];
630
+ const u = L.value[t], l = L.value[o];
670
631
  if (t === o)
671
632
  return [
672
633
  {
673
- id: c.id,
674
- type: c.type,
634
+ id: u.id,
635
+ type: u.type,
675
636
  startOffset: e.startOffset,
676
637
  endOffset: e.endOffset
677
638
  }
678
639
  ];
679
- const d = [
640
+ const f = [
680
641
  {
681
- id: c.id,
682
- type: c.type,
642
+ id: u.id,
643
+ type: u.type,
683
644
  startOffset: e.startOffset,
684
- endOffset: c.content.length
645
+ endOffset: u.content.length
685
646
  }
686
647
  ];
687
- for (let x = t + 1; x < o; x++) {
688
- const C = L.value[x];
689
- d.push({
690
- id: C.id,
691
- type: C.type,
648
+ for (let b = t + 1; b < o; b++) {
649
+ const S = L.value[b];
650
+ f.push({
651
+ id: S.id,
652
+ type: S.type,
692
653
  startOffset: 0,
693
- endOffset: C.content.length
654
+ endOffset: S.content.length
694
655
  });
695
656
  }
696
- return d.push({
657
+ return f.push({
697
658
  id: l.id,
698
659
  type: l.type,
699
660
  startOffset: 0,
700
661
  endOffset: e.endOffset
701
- }), d;
702
- }, ke = (e, t, o, c) => {
662
+ }), f;
663
+ }, ke = (e, t, o, u) => {
703
664
  const l = e[0];
704
665
  if (l.type !== "prefix" && l.type !== "suffix")
705
666
  return e;
706
667
  if (e.length === 1) {
707
668
  if (t.collapsed)
708
669
  if (t.startOffset === 0) {
709
- const d = ie(l, c);
710
- return d ? [d] : [];
670
+ const f = ie(l, u);
671
+ return f ? [f] : [];
711
672
  } else {
712
- const d = re(l, c);
713
- return d ? [d] : [];
673
+ const f = re(l, u);
674
+ return f ? [f] : [];
714
675
  }
715
676
  if (o.startsWith("insert"))
716
- if (a) {
717
- const d = ie(l, c);
718
- return d ? [d] : [];
677
+ if (n) {
678
+ const f = ie(l, u);
679
+ return f ? [f] : [];
719
680
  } else {
720
- const d = re(l, c);
721
- return d ? [d] : [];
681
+ const f = re(l, u);
682
+ return f ? [f] : [];
722
683
  }
723
684
  if (o.startsWith("delete")) {
724
685
  if (o.includes("Backward")) {
725
- const d = ie(l, c, 1);
726
- return d ? [d] : [];
686
+ const f = ie(l, u, 1);
687
+ return f ? [f] : [];
727
688
  } else if (o.includes("Forward")) {
728
- const d = re(l, c, 1);
729
- return d ? [d] : [];
689
+ const f = re(l, u, 1);
690
+ return f ? [f] : [];
730
691
  }
731
692
  }
732
693
  }
733
- return c.length > 0 ? e.slice(1) : e;
694
+ return u.length > 0 ? e.slice(1) : e;
734
695
  }, ie = (e, t, o = 0) => {
735
- const c = L.value.findIndex((l) => l.id === e.id && l.type === e.type);
736
- if (c > 0) {
737
- const l = L.value[c - 1], { id: d, type: x, content: C } = l;
738
- if (x === "text" || x === "template")
696
+ const u = L.value.findIndex((l) => l.id === e.id && l.type === e.type);
697
+ if (u > 0) {
698
+ const l = L.value[u - 1], { id: f, type: b, content: S } = l;
699
+ if (b === "text" || b === "template")
739
700
  return {
740
- id: d,
741
- type: x,
742
- startOffset: C.length - o,
743
- endOffset: C.length
701
+ id: f,
702
+ type: b,
703
+ startOffset: S.length - o,
704
+ endOffset: S.length
744
705
  };
745
706
  if (t.length > 0)
746
- return { tag: "new", afterId: d, type: "text", content: t };
707
+ return { tag: "new", afterId: f, type: "text", content: t };
747
708
  if (console.warn("the previous item is not text or template", { current: e, previous: l }), o === 1)
748
709
  return { ...e, endOffset: e.startOffset };
749
710
  } else return t.length > 0 ? { tag: "new", type: "text", content: t } : (console.warn("the previous item of current is not found", { current: e }), null);
750
711
  return e;
751
712
  }, re = (e, t, o = 0) => {
752
- const c = L.value.findIndex((l) => l.id === e.id && l.type === e.type);
753
- if (c < L.value.length - 1) {
754
- const l = L.value[c + 1], { id: d, type: x } = l;
755
- if (x === "text" || x === "template")
713
+ const u = L.value.findIndex((l) => l.id === e.id && l.type === e.type);
714
+ if (u < L.value.length - 1) {
715
+ const l = L.value[u + 1], { id: f, type: b } = l;
716
+ if (b === "text" || b === "template")
756
717
  return {
757
- id: d,
758
- type: x,
718
+ id: f,
719
+ type: b,
759
720
  startOffset: 0,
760
721
  endOffset: 0 + o
761
722
  };
@@ -766,76 +727,76 @@ const Kt = { class: "editor-container" }, Le = "​", Ee = "​", Pt = /* @__PUR
766
727
  } else return t.length > 0 ? { tag: "new", afterId: e.id, type: "text", content: t } : (console.warn("the next item of current is not found", { current: e }), null);
767
728
  return e;
768
729
  }, xe = () => {
769
- R.value = { hasStarted: !0, range: null };
730
+ x.value = { hasStarted: !0, range: null };
770
731
  }, ve = (e) => {
771
- const t = R.value.range;
772
- t ? (e.data && V(t.startContainer) && V(t.endContainer) ? (J(e.data), f.set(K.get(), j(t))) : t.startId && t.endId ? (P(t, "insertCompositionText", e.data), f.set(K.get(), j(t))) : console.warn("range is not valid, range:", t), k.value++) : console.warn("range is null, compositionEnd:", e), R.value = { hasStarted: !1, range: null };
732
+ const t = x.value.range;
733
+ t ? (e.data && W(t.startContainer) && W(t.endContainer) ? (J(e.data), v.set(F.get(), M(t))) : t.startId && t.endId ? (P(t, "insertCompositionText", e.data), v.set(F.get(), M(t))) : console.warn("range is not valid, range:", t), _.value++) : console.warn("range is null, compositionEnd:", e), x.value = { hasStarted: !1, range: null };
773
734
  }, ue = (() => {
774
735
  const e = navigator.userAgent.toLowerCase();
775
736
  return /macintosh|mac os x|iphone|ipad|ipod/.test(e);
776
737
  })(), Ie = (e) => {
777
738
  const t = ue && e.metaKey && !e.shiftKey && e.key.toLowerCase() === "z" || // Cmd+Z
778
739
  !ue && e.ctrlKey && !e.shiftKey && e.key.toLowerCase() === "z", o = ue && e.metaKey && e.shiftKey && e.key.toLowerCase() === "z" || // Cmd+Shift+z
779
- !ue && e.ctrlKey && (e.key.toLowerCase() === "y" || e.shiftKey && e.key.toLowerCase() === "z"), c = e.key.toLowerCase() === "enter";
740
+ !ue && e.ctrlKey && (e.key.toLowerCase() === "y" || e.shiftKey && e.key.toLowerCase() === "z"), u = e.key.toLowerCase() === "enter";
780
741
  if (t) {
781
742
  e.preventDefault();
782
- const l = Z(B.value);
783
- l && f.set(K.get(), j(l));
784
- const d = K.undo();
785
- d && oe(d);
743
+ const l = G($.value);
744
+ l && v.set(F.get(), M(l));
745
+ const f = F.undo();
746
+ f && oe(f);
786
747
  }
787
748
  if (o) {
788
749
  e.preventDefault();
789
- const l = K.redo();
750
+ const l = F.redo();
790
751
  l && oe(l);
791
752
  }
792
- c && (e.preventDefault(), p("submit"));
753
+ u && (e.preventDefault(), h("submit"));
793
754
  }, oe = (e) => {
794
- const { data: t } = H(e);
795
- if (m.value = t, f.has(e)) {
796
- const o = f.get(e);
797
- G(() => {
798
- const c = B.value.querySelector(`[data-id="${o.startId}"][data-type="${o.startType}"]`), l = B.value.querySelector(`[data-id="${o.endId}"][data-type="${o.endType}"]`);
799
- c && ee(c, o.startOffset, l, o.endOffset);
755
+ const { data: t } = te(e);
756
+ if (d.value = t, v.has(e)) {
757
+ const o = v.get(e);
758
+ q(() => {
759
+ const u = $.value.querySelector(`[data-id="${o.startId}"][data-type="${o.startType}"]`), l = $.value.querySelector(`[data-id="${o.endId}"][data-type="${o.endType}"]`);
760
+ u && Q(u, o.startOffset, l, o.endOffset);
800
761
  });
801
762
  }
802
763
  };
803
- return u({
764
+ return r({
804
765
  clearHistory: () => {
805
- K.clear(), f.clear();
766
+ F.clear(), v.clear();
806
767
  },
807
768
  activateFirstField: () => {
808
- if (!B.value)
769
+ if (!$.value)
809
770
  return;
810
- const e = m.value.find((t) => t.type === "template");
811
- e && G(() => {
812
- var o, c;
813
- const t = (o = B.value) == null ? void 0 : o.querySelector(`[data-id="${e.id}"][data-type="template"]`);
771
+ const e = d.value.find((t) => t.type === "template");
772
+ e && q(() => {
773
+ var o, u;
774
+ const t = (o = $.value) == null ? void 0 : o.querySelector(`[data-id="${e.id}"][data-type="template"]`);
814
775
  if (t) {
815
- const l = ((c = t.textContent) == null ? void 0 : c.length) || 0;
816
- ee(t, l);
776
+ const l = ((u = t.textContent) == null ? void 0 : u.length) || 0;
777
+ Q(t, l);
817
778
  }
818
779
  });
819
780
  }
820
- }), (e, t) => (S(), O("div", Kt, [
821
- (S(), O("div", {
781
+ }), (e, t) => (m(), R("div", Bt, [
782
+ (m(), R("div", {
822
783
  contenteditable: "true",
823
784
  ref_key: "editorRef",
824
- ref: B,
825
- key: k.value,
785
+ ref: $,
786
+ key: _.value,
826
787
  class: "editor",
827
- onBeforeinput: U,
788
+ onBeforeinput: N,
828
789
  onCompositionstart: xe,
829
790
  onCompositionend: ve,
830
791
  onKeydown: Ie
831
792
  }, [
832
- (S(!0), O(de, null, he(M.value, (o) => (S(), X(Ft, pe({
793
+ (m(!0), R(ce, null, he(U.value, (o) => (m(), X($t, fe({
833
794
  key: `${o.id}-${o.type}`
834
795
  }, { ref_for: !0 }, o), null, 16))), 128))
835
796
  ], 32))
836
797
  ]));
837
798
  }
838
- }), Wt = /* @__PURE__ */ be(Pt, [["__scopeId", "data-v-b0269a2a"]]), At = ["onMouseenter", "onMousedown"], Vt = { class: "suggestion-list__text" }, Nt = /* @__PURE__ */ ge({
799
+ }), Dt = /* @__PURE__ */ be(Et, [["__scopeId", "data-v-b0269a2a"]]), Ft = ["onMouseenter", "onMousedown"], Pt = { class: "suggestion-list__text" }, Ht = /* @__PURE__ */ ge({
839
800
  __name: "SuggestionList",
840
801
  props: {
841
802
  show: { type: Boolean },
@@ -846,71 +807,71 @@ const Kt = { class: "editor-container" }, Le = "​", Ee = "​", Pt = /* @__PUR
846
807
  inputValue: {}
847
808
  },
848
809
  emits: ["item-hover", "item-leave", "select"],
849
- setup(i, { emit: u }) {
850
- const s = i, r = u, y = F(null), w = (_) => {
851
- r("item-hover", _);
852
- }, a = () => {
853
- r("item-leave");
854
- }, h = (_) => {
855
- r("select", _);
810
+ setup(i, { emit: r }) {
811
+ const a = i, c = r, y = E(null), w = (C) => {
812
+ c("item-hover", C);
813
+ }, n = () => {
814
+ c("item-leave");
815
+ }, p = (C) => {
816
+ c("select", C);
856
817
  };
857
- return (_, p) => (S(), X(De, { name: "tiny-sender-slide-up" }, {
858
- default: ce(() => [
859
- s.show && s.suggestions.length ? (S(), O("div", {
818
+ return (C, h) => (m(), X(Ee, { name: "tiny-sender-slide-up" }, {
819
+ default: pe(() => [
820
+ a.show && a.suggestions.length ? (m(), R("div", {
860
821
  key: 0,
861
822
  ref_key: "suggestionsListRef",
862
823
  ref: y,
863
824
  class: "suggestion-list",
864
- style: Fe(s.popupStyle)
825
+ style: De(a.popupStyle)
865
826
  }, [
866
- (S(!0), O(de, null, he(s.suggestions, (k, g) => (S(), O("div", {
827
+ (m(!0), R(ce, null, he(a.suggestions, (_, g) => (m(), R("div", {
867
828
  key: g,
868
- class: Y(["suggestion-list__item", { highlighted: s.isItemHighlighted(g) }]),
869
- onMouseenter: (T) => w(g),
870
- onMouseleave: a,
871
- onMousedown: ct((T) => h(k), ["prevent"])
829
+ class: ee(["suggestion-list__item", { highlighted: a.isItemHighlighted(g) }]),
830
+ onMouseenter: (I) => w(g),
831
+ onMouseleave: n,
832
+ onMousedown: at((I) => p(_), ["prevent"])
872
833
  }, [
873
- z(b(_t), { class: "suggestion-list__icon" }),
874
- N("span", Vt, [
875
- (S(!0), O(de, null, he(s.highlightSuggestionText(k, s.inputValue), (T, m) => (S(), O("span", {
876
- key: m,
877
- class: Y({
878
- "suggestion-list__text--match": T.isMatch,
879
- "suggestion-list__text--normal": !T.isMatch
834
+ j(k(gt), { class: "suggestion-list__icon" }),
835
+ A("span", Pt, [
836
+ (m(!0), R(ce, null, he(a.highlightSuggestionText(_, a.inputValue), (I, d) => (m(), R("span", {
837
+ key: d,
838
+ class: ee({
839
+ "suggestion-list__text--match": I.isMatch,
840
+ "suggestion-list__text--normal": !I.isMatch
880
841
  })
881
- }, le(T.text), 3))), 128))
842
+ }, le(I.text), 3))), 128))
882
843
  ])
883
- ], 42, At))), 128))
884
- ], 4)) : A("", !0)
844
+ ], 42, Ft))), 128))
845
+ ], 4)) : K("", !0)
885
846
  ]),
886
847
  _: 1
887
848
  }));
888
849
  }
889
- }), Mt = /* @__PURE__ */ be(Nt, [["__scopeId", "data-v-238fcdfd"]]), qt = ["data-theme"], Ut = { class: "tiny-sender__container" }, jt = {
850
+ }), Kt = /* @__PURE__ */ be(Ht, [["__scopeId", "data-v-238fcdfd"]]), Wt = ["data-theme"], At = { class: "tiny-sender__container" }, Vt = {
890
851
  key: 0,
891
852
  class: "tiny-sender__header-slot"
892
- }, zt = {
853
+ }, Nt = {
893
854
  key: 0,
894
855
  class: "tiny-sender__prefix-slot"
895
- }, Gt = { class: "tiny-sender__content-area" }, Xt = {
856
+ }, Mt = { class: "tiny-sender__content-area" }, qt = {
896
857
  key: 0,
897
858
  class: "tiny-sender__decorative-content"
898
- }, Jt = {
859
+ }, Ut = {
899
860
  key: 2,
900
861
  class: "tiny-sender__input-field-wrapper"
901
- }, Qt = {
862
+ }, zt = {
902
863
  key: 0,
903
864
  class: "tiny-sender__completion-placeholder"
904
- }, Yt = { class: "user-input-mirror" }, Zt = {
865
+ }, jt = { class: "user-input-mirror" }, Xt = {
905
866
  key: 0,
906
867
  class: "tiny-sender__tab-hint"
907
- }, en = {
868
+ }, Jt = {
908
869
  key: 1,
909
870
  class: "tiny-sender__actions-slot"
910
- }, tn = { class: "tiny-sender__footer-left" }, nn = { class: "tiny-sender__footer-right" }, sn = { class: "real-word-length" }, on = {
871
+ }, Gt = { class: "tiny-sender__footer-left" }, Qt = { class: "tiny-sender__footer-right" }, Yt = { class: "real-word-length" }, Zt = {
911
872
  key: 1,
912
873
  class: "tiny-sender__toolbar"
913
- }, an = { class: "tiny-sender__buttons-container" }, ln = {
874
+ }, en = { class: "tiny-sender__buttons-container" }, tn = {
914
875
  key: 1,
915
876
  class: "tiny-sender__footer-slot"
916
877
  }, _e = /* @__PURE__ */ ge({
@@ -927,7 +888,6 @@ const Kt = { class: "editor-container" }, Le = "​", Ee = "​", Pt = /* @__PUR
927
888
  modelValue: { default: "" },
928
889
  mode: { default: "single" },
929
890
  maxLength: { default: 1 / 0 },
930
- buttonGroup: {},
931
891
  submitType: { default: "enter" },
932
892
  speech: { type: [Boolean, Object] },
933
893
  placeholder: { default: "请输入内容..." },
@@ -938,354 +898,344 @@ const Kt = { class: "editor-container" }, Le = "​", Ee = "​", Pt = /* @__PUR
938
898
  templateData: { default: () => [] },
939
899
  stopText: { default: "" }
940
900
  },
941
- emits: ["update:modelValue", "update:templateData", "submit", "clear", "speech-start", "speech-end", "speech-interim", "speech-error", "suggestion-select", "focus", "blur", "escape-press", "cancel", "reset-template", "files-selected"],
942
- setup(i, { expose: u, emit: s }) {
943
- var Pe;
944
- const r = i, y = s, w = F(null), a = F(null), h = F(null), _ = F(null), p = F(null), k = E(() => r.templateData && r.templateData.length > 0), { inputValue: g, isComposing: T, clearInput: m } = Ct(r, y), L = E(() => !!g.value.trim()), M = E(() => {
945
- var n, I;
946
- return !(r.disabled || r.loading || !L.value || t.value || (I = (n = r.buttonGroup) == null ? void 0 : n.submit) != null && I.disabled);
947
- }), {
948
- showSuggestionsPopup: B,
949
- completionPlaceholder: v,
950
- showTabHint: H,
951
- suggestionsListRef: f,
952
- filteredSuggestions: K,
953
- activeSuggestion: q,
954
- isItemHighlighted: V,
955
- updateSuggestionsState: Z,
956
- selectSuggestion: fe,
957
- acceptCurrentSuggestion: ee,
901
+ emits: ["update:modelValue", "update:templateData", "submit", "clear", "speech-start", "speech-end", "speech-interim", "speech-error", "suggestion-select", "focus", "blur", "escape-press", "cancel", "reset-template"],
902
+ setup(i, { expose: r, emit: a }) {
903
+ const c = i, y = a, w = E(null), n = E(null), p = E(null), C = E(null), h = E(null), _ = D(() => c.templateData && c.templateData.length > 0), { inputValue: g, isComposing: I, clearInput: d } = yt(c, y), L = D(() => !!g.value.trim()), U = D(() => !(c.disabled || c.loading || !L.value || t.value)), {
904
+ showSuggestionsPopup: $,
905
+ completionPlaceholder: z,
906
+ showTabHint: te,
907
+ suggestionsListRef: v,
908
+ filteredSuggestions: F,
909
+ activeSuggestion: V,
910
+ isItemHighlighted: W,
911
+ updateSuggestionsState: G,
912
+ selectSuggestion: de,
913
+ acceptCurrentSuggestion: Q,
958
914
  closeSuggestionsPopup: J,
959
- navigateSuggestions: R,
960
- handleSuggestionItemHover: U,
961
- handleSuggestionItemLeave: j,
915
+ navigateSuggestions: x,
916
+ handleSuggestionItemHover: N,
917
+ handleSuggestionItemLeave: M,
962
918
  highlightSuggestionText: ne
963
- } = Rt(r, y, g, T, k), P = F(r.mode), se = F(!1), Ce = () => {
964
- P.value === "single" && (P.value = "multiple", G(() => {
919
+ } = _t(c, y, g, I, _), P = E(c.mode), se = E(!1), Ce = () => {
920
+ P.value === "single" && (P.value = "multiple", q(() => {
965
921
  setTimeout(() => {
966
- const n = document.querySelector(".tiny-textarea__inner");
967
- if (n) {
968
- n.style.whiteSpace = "pre-wrap";
969
- const I = g.value.length;
970
- n.focus(), n.setSelectionRange(I, I);
922
+ const s = document.querySelector(".tiny-textarea__inner");
923
+ if (s) {
924
+ s.style.whiteSpace = "pre-wrap";
925
+ const T = g.value.length;
926
+ s.focus(), s.setSelectionRange(T, T);
971
927
  }
972
928
  }, 50);
973
929
  }));
974
- }, ke = (n, I) => {
975
- const D = document.createElement("span");
976
- D.style.visibility = "hidden", D.style.position = "absolute", D.style.whiteSpace = "nowrap", D.style.font = I, D.textContent = n, document.body.appendChild(D);
977
- const me = D.offsetWidth;
978
- return document.body.removeChild(D), me;
930
+ }, ke = (s, T) => {
931
+ const B = document.createElement("span");
932
+ B.style.visibility = "hidden", B.style.position = "absolute", B.style.whiteSpace = "nowrap", B.style.font = T, B.textContent = s, document.body.appendChild(B);
933
+ const me = B.offsetWidth;
934
+ return document.body.removeChild(B), me;
979
935
  }, ie = () => {
980
- var Se, Ve, Ne;
981
- if (r.mode !== "single" || !w.value || se.value || !a.value || !_.value) return;
982
- const n = a.value.querySelector(".tiny-sender__content-area");
983
- if (!n) return;
984
- const I = ((Ve = (Se = w.value) == null ? void 0 : Se.querySelector) == null ? void 0 : Ve.call(Se, ".tiny-input__inner")) || n.querySelector(".tiny-input__inner"), D = p.value || a.value.querySelector(".tiny-sender__buttons-container");
985
- if (!I) {
936
+ var we, Ke, We;
937
+ if (c.mode !== "single" || !w.value || se.value || !n.value || !C.value) return;
938
+ const s = n.value.querySelector(".tiny-sender__content-area");
939
+ if (!s) return;
940
+ const T = ((Ke = (we = w.value) == null ? void 0 : we.querySelector) == null ? void 0 : Ke.call(we, ".tiny-input__inner")) || s.querySelector(".tiny-input__inner"), B = h.value || n.value.querySelector(".tiny-sender__buttons-container");
941
+ if (!T) {
986
942
  console.warn("Cannot find input element for overflow check");
987
943
  return;
988
944
  }
989
- const me = I.getBoundingClientRect(), $e = D == null ? void 0 : D.getBoundingClientRect();
945
+ const me = T.getBoundingClientRect(), $e = B == null ? void 0 : B.getBoundingClientRect();
990
946
  if (me.width === 0) {
991
947
  setTimeout(() => ie(), 50);
992
948
  return;
993
949
  }
994
- const Ze = window.getComputedStyle(I).font, et = ke(g.value, Ze), We = (Ne = a.value) == null ? void 0 : Ne.classList.contains("tr-sender-compact"), tt = We ? 12 : 20, nt = me.width, st = ($e == null ? void 0 : $e.width) || 0, Ae = nt - st - tt, ot = We ? 50 : 80;
995
- et > Ae && Ae > ot && P.value === "single" && (se.value = !0, P.value = "multiple", G(() => {
950
+ const Xe = window.getComputedStyle(T).font, Je = ke(g.value, Xe), Pe = (We = n.value) == null ? void 0 : We.classList.contains("tr-sender-compact"), Ge = Pe ? 12 : 20, Qe = me.width, Ye = ($e == null ? void 0 : $e.width) || 0, He = Qe - Ye - Ge, Ze = Pe ? 50 : 80;
951
+ Je > He && He > Ze && P.value === "single" && (se.value = !0, P.value = "multiple", q(() => {
996
952
  w.value ? setTimeout(() => {
997
- var Me;
998
- const we = (Me = a.value) == null ? void 0 : Me.querySelector(".tiny-textarea__inner");
999
- if (we) {
1000
- we.style.whiteSpace = "pre-wrap";
1001
- const qe = g.value.length;
1002
- we.focus(), we.setSelectionRange(qe, qe);
953
+ var Ae;
954
+ const Se = (Ae = n.value) == null ? void 0 : Ae.querySelector(".tiny-textarea__inner");
955
+ if (Se) {
956
+ Se.style.whiteSpace = "pre-wrap";
957
+ const Ve = g.value.length;
958
+ Se.focus(), Se.setSelectionRange(Ve, Ve);
1003
959
  }
1004
960
  se.value = !1;
1005
961
  }, 300) : se.value = !1;
1006
962
  }));
1007
963
  }, re = () => {
1008
- if (k.value && h.value)
1009
- He();
964
+ if (_.value && p.value)
965
+ Fe();
1010
966
  else if (w.value)
1011
967
  w.value.focus();
1012
968
  else {
1013
- const n = document.querySelector(".tiny-input__inner");
1014
- n == null || n.focus();
969
+ const s = document.querySelector(".tiny-input__inner");
970
+ s == null || s.focus();
1015
971
  }
1016
972
  }, xe = () => {
1017
973
  if (w.value)
1018
974
  w.value.blur();
1019
975
  else {
1020
- const n = document.querySelector(".tiny-input__inner");
1021
- n == null || n.blur();
976
+ const s = document.querySelector(".tiny-input__inner");
977
+ s == null || s.blur();
1022
978
  }
1023
979
  }, ve = () => {
1024
- var n;
1025
- y("update:templateData", []), (n = h.value) == null || n.clearHistory(), G(() => {
1026
- g.value === "" && (P.value = r.mode || "single"), setTimeout(() => {
980
+ var s;
981
+ y("update:templateData", []), (s = p.value) == null || s.clearHistory(), q(() => {
982
+ g.value === "" && (P.value = c.mode || "single"), setTimeout(() => {
1027
983
  re();
1028
984
  }, 50);
1029
985
  }), J();
1030
986
  }, ye = () => {
1031
- var n;
1032
- m(), k.value ? ve() : (n = a.value) == null || n.focus(), G(() => {
1033
- g.value === "" && (P.value = r.mode || "single");
987
+ var s;
988
+ d(), _.value ? ve() : (s = n.value) == null || s.focus(), q(() => {
989
+ g.value === "" && (P.value = c.mode || "single");
1034
990
  }), J();
1035
- }, ue = (n) => {
1036
- y("update:templateData", n);
991
+ }, ue = (s) => {
992
+ y("update:templateData", s);
1037
993
  };
1038
- Q(
1039
- () => r.templateData,
994
+ Z(
995
+ () => c.templateData,
1040
996
  () => {
1041
- g.value = r.templateData.map((n) => n.content).join("");
997
+ g.value = c.templateData.map((s) => s.content).join("");
1042
998
  },
1043
999
  { deep: !0 }
1044
1000
  );
1045
- const Ie = E(() => {
1046
- const n = typeof r.speech == "object" ? r.speech : {};
1001
+ const Ie = D(() => {
1002
+ const s = typeof c.speech == "object" ? c.speech : {};
1047
1003
  return {
1048
- ...n,
1004
+ ...s,
1049
1005
  onStart: () => y("speech-start"),
1050
- onEnd: (I) => y("speech-end", I),
1051
- onInterim: (I) => y("speech-interim", I),
1052
- onFinal: (I) => {
1053
- if (n.autoReplace)
1054
- g.value = I;
1006
+ onEnd: (T) => y("speech-end", T),
1007
+ onInterim: (T) => y("speech-interim", T),
1008
+ onFinal: (T) => {
1009
+ if (s.autoReplace)
1010
+ g.value = T;
1055
1011
  else {
1056
- const D = g.value;
1057
- D && I && !D.endsWith(" ") && !I.startsWith(" ") && D.length > 0 ? g.value = D + " " + I : g.value = D + I;
1012
+ const B = g.value;
1013
+ B && T && !B.endsWith(" ") && !T.startsWith(" ") && B.length > 0 ? g.value = B + " " + T : g.value = B + T;
1058
1014
  }
1059
- y("speech-end", I);
1015
+ y("speech-end", T);
1060
1016
  },
1061
- onError: (I) => {
1062
- y("speech-error", I);
1017
+ onError: (T) => {
1018
+ y("speech-error", T);
1063
1019
  }
1064
1020
  };
1065
- }), { speechState: oe, start: Re, stop: Te } = xt(Ie.value), e = () => {
1066
- oe.isRecording ? Te() : Re();
1067
- }, t = E(() => r.maxLength !== 1 / 0 && g.value.length > r.maxLength), { handleKeyPress: o, triggerSubmit: c } = kt(
1068
- r,
1021
+ }), { speechState: oe, start: Re, stop: Oe } = wt(Ie.value), e = () => {
1022
+ oe.isRecording ? Oe() : Re();
1023
+ }, t = D(() => c.maxLength !== 1 / 0 && g.value.length > c.maxLength), { handleKeyPress: o, triggerSubmit: u } = mt(
1024
+ c,
1069
1025
  y,
1070
1026
  g,
1071
- T,
1027
+ I,
1072
1028
  oe,
1073
- B,
1074
- q,
1075
- ee,
1029
+ $,
1030
+ V,
1031
+ Q,
1076
1032
  J,
1077
- R,
1033
+ x,
1078
1034
  e,
1079
- M,
1035
+ U,
1080
1036
  P,
1081
1037
  Ce,
1082
- k,
1038
+ _,
1083
1039
  ve
1084
- ), l = (n) => {
1085
- y("focus", n), g.value && K.value.length > 0 && !k.value && (B.value = !0, H.value = !0);
1086
- }, d = (n) => {
1087
- y("blur", n), J();
1088
- }, x = E(() => P.value === "multiple" ? "textarea" : "text"), C = E(
1040
+ ), l = (s) => {
1041
+ y("focus", s), g.value && F.value.length > 0 && !_.value && ($.value = !0, te.value = !0);
1042
+ }, f = (s) => {
1043
+ y("blur", s), J();
1044
+ }, b = D(() => P.value === "multiple" ? "textarea" : "text"), S = D(
1089
1045
  () => ({
1090
1046
  display: "flex",
1091
- justifyContent: r.showWordLimit && r.maxLength !== 1 / 0 ? "space-between" : "flex-end",
1047
+ justifyContent: c.showWordLimit && c.maxLength !== 1 / 0 ? "space-between" : "flex-end",
1092
1048
  alignItems: "center"
1093
1049
  })
1094
- ), $ = dt(), W = E(() => !!$.decorativeContent), te = E(() => r.disabled || W.value), Oe = E(() => r.loading), ze = E(() => ({
1095
- "is-disabled": te.value,
1096
- "is-loading": Oe.value,
1050
+ ), O = lt(), H = D(() => !!O.decorativeContent), Y = D(() => c.disabled || H.value), Te = D(() => c.loading), Ue = D(() => ({
1051
+ "is-disabled": Y.value,
1052
+ "is-loading": Te.value,
1097
1053
  "is-auto-switching": se.value
1098
- })), Ge = E(() => ({
1099
- width: bt(r.suggestionPopupWidth),
1054
+ })), ze = D(() => ({
1055
+ width: vt(c.suggestionPopupWidth),
1100
1056
  maxWidth: "100%"
1101
1057
  // 确保不超出父容器宽度
1102
- })), Xe = () => {
1103
- T.value = !1, setTimeout(() => {
1104
- T.value = !1, Z();
1058
+ })), je = () => {
1059
+ I.value = !1, setTimeout(() => {
1060
+ I.value = !1, G();
1105
1061
  }, 50);
1106
1062
  };
1107
- Q(g, () => {
1108
- G(ie), g.value === "" && r.mode === "single" && (P.value = "single");
1109
- }), Q(
1110
- () => k.value,
1111
- (n) => {
1112
- n && (P.value = "multiple");
1063
+ Z(g, () => {
1064
+ q(ie), g.value === "" && c.mode === "single" && (P.value = "single");
1065
+ }), Z(
1066
+ () => _.value,
1067
+ (s) => {
1068
+ s && (P.value = "multiple");
1113
1069
  }
1114
1070
  );
1115
- const He = () => {
1116
- h.value && h.value.activateFirstField();
1117
- }, { accept: Je = "*", multiple: Qe = !0 } = ((Pe = r.buttonGroup) == null ? void 0 : Pe.file) || {}, { open: Ke, files: Ye } = ht({ accept: Je, multiple: Qe });
1118
- return Q(Ye, (n) => {
1119
- n && n.length > 0 && y("files-selected", Array.from(n));
1120
- }), u({
1071
+ const Fe = () => {
1072
+ p.value && p.value.activateFirstField();
1073
+ };
1074
+ return r({
1121
1075
  focus: re,
1122
1076
  blur: xe,
1123
1077
  clear: ye,
1124
- submit: c,
1078
+ submit: u,
1125
1079
  startSpeech: Re,
1126
- stopSpeech: Te,
1127
- activateTemplateFirstField: He
1128
- }), (n, I) => (S(), O("div", {
1080
+ stopSpeech: Oe,
1081
+ activateTemplateFirstField: Fe
1082
+ }), (s, T) => (m(), R("div", {
1129
1083
  ref_key: "senderRef",
1130
- ref: a,
1131
- class: Y(["tiny-sender", [ze.value, `theme-${n.theme}`, `mode-${P.value}`]]),
1132
- "data-theme": n.theme
1084
+ ref: n,
1085
+ class: ee(["tiny-sender", [Ue.value, `theme-${s.theme}`, `mode-${P.value}`]]),
1086
+ "data-theme": s.theme
1133
1087
  }, [
1134
- N("div", Ut, [
1135
- N("div", {
1088
+ A("div", At, [
1089
+ A("div", {
1136
1090
  class: "tiny-sender__input-wrapper",
1137
1091
  ref_key: "inputWrapperRef",
1138
- ref: _
1092
+ ref: C
1139
1093
  }, [
1140
- z(De, { name: "tiny-sender-slide-down" }, {
1141
- default: ce(() => [
1142
- n.$slots.header ? (S(), O("div", jt, [
1143
- ae(n.$slots, "header")
1144
- ])) : A("", !0)
1094
+ j(Ee, { name: "tiny-sender-slide-down" }, {
1095
+ default: pe(() => [
1096
+ s.$slots.header ? (m(), R("div", Vt, [
1097
+ ae(s.$slots, "header")
1098
+ ])) : K("", !0)
1145
1099
  ]),
1146
1100
  _: 3
1147
1101
  }),
1148
- N("div", {
1149
- class: Y(["tiny-sender__input-row", { "has-prefix": n.$slots.prefix, "has-header": n.$slots.header }])
1102
+ A("div", {
1103
+ class: ee(["tiny-sender__input-row", { "has-prefix": s.$slots.prefix, "has-header": s.$slots.header }])
1150
1104
  }, [
1151
- n.$slots.prefix ? (S(), O("div", zt, [
1152
- ae(n.$slots, "prefix")
1153
- ])) : A("", !0),
1154
- N("div", Gt, [
1155
- n.$slots.decorativeContent ? (S(), O("div", Xt, [
1156
- ae(n.$slots, "decorativeContent")
1157
- ])) : A("", !0),
1158
- k.value ? (S(), X(Wt, {
1105
+ s.$slots.prefix ? (m(), R("div", Nt, [
1106
+ ae(s.$slots, "prefix")
1107
+ ])) : K("", !0),
1108
+ A("div", Mt, [
1109
+ s.$slots.decorativeContent ? (m(), R("div", qt, [
1110
+ ae(s.$slots, "decorativeContent")
1111
+ ])) : K("", !0),
1112
+ _.value ? (m(), X(Dt, {
1159
1113
  key: 1,
1160
1114
  ref_key: "templateEditorRef",
1161
- ref: h,
1162
- "model-value": r.templateData,
1115
+ ref: p,
1116
+ "model-value": c.templateData,
1163
1117
  "onUpdate:modelValue": ue,
1164
- onSubmit: b(c)
1165
- }, null, 8, ["model-value", "onSubmit"])) : (S(), O("div", Jt, [
1166
- z(b(pt), {
1118
+ onSubmit: k(u)
1119
+ }, null, 8, ["model-value", "onSubmit"])) : (m(), R("div", Ut, [
1120
+ j(k(rt), {
1167
1121
  ref_key: "inputRef",
1168
1122
  ref: w,
1169
- autosize: n.autoSize,
1170
- type: x.value,
1123
+ autosize: s.autoSize,
1124
+ type: b.value,
1171
1125
  resize: "none",
1172
- modelValue: b(g),
1173
- "onUpdate:modelValue": I[0] || (I[0] = (D) => ft(g) ? g.value = D : null),
1174
- disabled: te.value,
1175
- placeholder: n.placeholder,
1176
- autofocus: n.autofocus,
1177
- onKeydown: b(o),
1178
- onCompositionstart: I[1] || (I[1] = (D) => T.value = !0),
1179
- onCompositionend: Xe,
1126
+ modelValue: k(g),
1127
+ "onUpdate:modelValue": T[0] || (T[0] = (B) => it(g) ? g.value = B : null),
1128
+ disabled: Y.value,
1129
+ placeholder: s.placeholder,
1130
+ autofocus: s.autofocus,
1131
+ onKeydown: k(o),
1132
+ onCompositionstart: T[1] || (T[1] = (B) => I.value = !0),
1133
+ onCompositionend: je,
1180
1134
  onFocus: l,
1181
- onBlur: d
1135
+ onBlur: f
1182
1136
  }, null, 8, ["autosize", "type", "modelValue", "disabled", "placeholder", "autofocus", "onKeydown"]),
1183
- b(v) && !b(T) ? (S(), O("div", Qt, [
1184
- N("span", Yt, le(b(g)), 1),
1185
- Ue(le(b(v)) + " ", 1),
1186
- b(H) ? (S(), O("div", Zt, "TAB")) : A("", !0)
1187
- ])) : A("", !0)
1137
+ k(z) && !k(I) ? (m(), R("div", zt, [
1138
+ A("span", jt, le(k(g)), 1),
1139
+ Ne(le(k(z)) + " ", 1),
1140
+ k(te) ? (m(), R("div", Xt, "TAB")) : K("", !0)
1141
+ ])) : K("", !0)
1188
1142
  ]))
1189
1143
  ]),
1190
- P.value === "single" ? (S(), O("div", en, [
1191
- N("div", {
1144
+ P.value === "single" ? (m(), R("div", Jt, [
1145
+ A("div", {
1192
1146
  class: "tiny-sender__buttons-container",
1193
1147
  ref_key: "buttonsContainerRef",
1194
- ref: p
1148
+ ref: h
1195
1149
  }, [
1196
- ae(n.$slots, "actions"),
1197
- z(je, {
1198
- "allow-speech": n.allowSpeech,
1199
- "allow-files": n.allowFiles,
1200
- loading: n.loading,
1201
- disabled: te.value,
1202
- "show-clear": n.clearable,
1150
+ ae(s.$slots, "actions"),
1151
+ j(qe, {
1152
+ "allow-speech": s.allowSpeech,
1153
+ "allow-files": s.allowFiles,
1154
+ loading: s.loading,
1155
+ disabled: Y.value,
1156
+ "show-clear": s.clearable,
1203
1157
  "has-content": L.value,
1204
- "speech-status": b(oe),
1205
- "button-group": n.buttonGroup,
1206
- "submit-type": n.submitType,
1158
+ "speech-status": k(oe),
1159
+ "submit-type": s.submitType,
1207
1160
  "is-over-limit": t.value,
1208
- "stop-text": n.stopText,
1161
+ "stop-text": s.stopText,
1209
1162
  onClear: ye,
1210
1163
  onToggleSpeech: e,
1211
- onSubmit: b(c),
1212
- onCancel: I[2] || (I[2] = (D) => n.$emit("cancel")),
1213
- onTriggerSelect: b(Ke)
1214
- }, null, 8, ["allow-speech", "allow-files", "loading", "disabled", "show-clear", "has-content", "speech-status", "button-group", "submit-type", "is-over-limit", "stop-text", "onSubmit", "onTriggerSelect"])
1164
+ onSubmit: k(u),
1165
+ onCancel: T[2] || (T[2] = (B) => s.$emit("cancel"))
1166
+ }, null, 8, ["allow-speech", "allow-files", "loading", "disabled", "show-clear", "has-content", "speech-status", "submit-type", "is-over-limit", "stop-text", "onSubmit"])
1215
1167
  ], 512)
1216
- ])) : A("", !0)
1168
+ ])) : K("", !0)
1217
1169
  ], 2),
1218
- z(De, { name: "tiny-sender-slide-up" }, {
1219
- default: ce(() => [
1220
- P.value === "multiple" ? (S(), O("div", {
1170
+ j(Ee, { name: "tiny-sender-slide-up" }, {
1171
+ default: pe(() => [
1172
+ P.value === "multiple" ? (m(), R("div", {
1221
1173
  key: 0,
1222
- style: Fe(C.value),
1174
+ style: De(S.value),
1223
1175
  class: "tiny-sender__footer-slot tiny-sender__bottom-row"
1224
1176
  }, [
1225
- N("div", tn, [
1226
- ae(n.$slots, "footer-left")
1177
+ A("div", Gt, [
1178
+ ae(s.$slots, "footer-left")
1227
1179
  ]),
1228
- N("div", nn, [
1229
- ae(n.$slots, "footer-right"),
1230
- n.showWordLimit && n.maxLength !== 1 / 0 ? (S(), O("div", {
1180
+ A("div", Qt, [
1181
+ ae(s.$slots, "footer-right"),
1182
+ s.showWordLimit && s.maxLength !== 1 / 0 ? (m(), R("div", {
1231
1183
  key: 0,
1232
- class: Y(["tiny-sender__word-limit", { "is-over-limit": t.value }])
1184
+ class: ee(["tiny-sender__word-limit", { "is-over-limit": t.value }])
1233
1185
  }, [
1234
- N("span", sn, le(b(g).length), 1),
1235
- Ue("/" + le(n.maxLength), 1)
1236
- ], 2)) : A("", !0),
1237
- P.value === "multiple" ? (S(), O("div", on, [
1238
- N("div", an, [
1239
- z(je, {
1240
- "allow-speech": n.allowSpeech,
1241
- "allow-files": n.allowFiles,
1242
- loading: n.loading,
1243
- disabled: te.value,
1244
- "show-clear": n.clearable,
1186
+ A("span", Yt, le(k(g).length), 1),
1187
+ Ne("/" + le(s.maxLength), 1)
1188
+ ], 2)) : K("", !0),
1189
+ P.value === "multiple" ? (m(), R("div", Zt, [
1190
+ A("div", en, [
1191
+ j(qe, {
1192
+ "allow-speech": s.allowSpeech,
1193
+ "allow-files": s.allowFiles,
1194
+ loading: s.loading,
1195
+ disabled: Y.value,
1196
+ "show-clear": s.clearable,
1245
1197
  "has-content": L.value,
1246
- "speech-status": b(oe),
1247
- "button-group": n.buttonGroup,
1248
- "submit-type": n.submitType,
1198
+ "speech-status": k(oe),
1199
+ "submit-type": s.submitType,
1249
1200
  "is-over-limit": t.value,
1250
- "stop-text": n.stopText,
1201
+ "stop-text": s.stopText,
1251
1202
  onClear: ye,
1252
1203
  onToggleSpeech: e,
1253
- onSubmit: b(c),
1254
- onCancel: I[3] || (I[3] = (D) => n.$emit("cancel")),
1255
- onTriggerSelect: b(Ke)
1256
- }, null, 8, ["allow-speech", "allow-files", "loading", "disabled", "show-clear", "has-content", "speech-status", "button-group", "submit-type", "is-over-limit", "stop-text", "onSubmit", "onTriggerSelect"])
1204
+ onSubmit: k(u),
1205
+ onCancel: T[3] || (T[3] = (B) => s.$emit("cancel"))
1206
+ }, null, 8, ["allow-speech", "allow-files", "loading", "disabled", "show-clear", "has-content", "speech-status", "submit-type", "is-over-limit", "stop-text", "onSubmit"])
1257
1207
  ])
1258
- ])) : A("", !0)
1208
+ ])) : K("", !0)
1259
1209
  ])
1260
- ], 4)) : n.$slots.footer ? (S(), O("div", ln, [
1261
- ae(n.$slots, "footer")
1262
- ])) : A("", !0)
1210
+ ], 4)) : s.$slots.footer ? (m(), R("div", tn, [
1211
+ ae(s.$slots, "footer")
1212
+ ])) : K("", !0)
1263
1213
  ]),
1264
1214
  _: 3
1265
1215
  })
1266
1216
  ], 512)
1267
1217
  ]),
1268
- z(Mt, {
1218
+ j(Kt, {
1269
1219
  ref_key: "suggestionsListRef",
1270
- ref: f,
1271
- show: b(B),
1272
- suggestions: b(K),
1273
- "popup-style": Ge.value,
1274
- "is-item-highlighted": b(V),
1275
- "highlight-suggestion-text": b(ne),
1276
- "input-value": b(g),
1277
- onItemHover: b(U),
1278
- onItemLeave: b(j),
1279
- onSelect: b(fe)
1220
+ ref: v,
1221
+ show: k($),
1222
+ suggestions: k(F),
1223
+ "popup-style": ze.value,
1224
+ "is-item-highlighted": k(W),
1225
+ "highlight-suggestion-text": k(ne),
1226
+ "input-value": k(g),
1227
+ onItemHover: k(N),
1228
+ onItemLeave: k(M),
1229
+ onSelect: k(de)
1280
1230
  }, null, 8, ["show", "suggestions", "popup-style", "is-item-highlighted", "highlight-suggestion-text", "input-value", "onItemHover", "onItemLeave", "onSelect"])
1281
- ], 10, qt));
1231
+ ], 10, Wt));
1282
1232
  }
1283
1233
  });
1284
1234
  _e.name = "TrSender";
1285
- const rn = function(i) {
1235
+ const nn = function(i) {
1286
1236
  i.component(_e.name, _e);
1287
1237
  };
1288
- _e.install = rn;
1238
+ _e.install = nn;
1289
1239
  export {
1290
1240
  _e as default
1291
1241
  };