@opentiny/tiny-robot 0.3.3 → 0.3.4

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,115 +1,115 @@
1
- var at = Object.defineProperty;
2
- var it = (n, i, l) => i in n ? at(n, i, { enumerable: !0, configurable: !0, writable: !0, value: l }) : n[i] = l;
3
- var Pe = (n, i, l) => it(n, typeof i != "symbol" ? i + "" : i, l);
4
- import { ref as K, watch as ne, reactive as lt, onUnmounted as tt, computed as E, defineComponent as Ce, isVNode as rt, openBlock as m, createElementBlock as I, normalizeStyle as Ue, createBlock as ee, unref as k, withCtx as ve, createElementVNode as U, createVNode as Z, normalizeClass as oe, createCommentVNode as P, resolveDynamicComponent as ct, toDisplayString as de, useAttrs as ut, resolveComponent as dt, mergeProps as Se, Fragment as ye, renderList as xe, useModel as ft, onMounted as pt, nextTick as q, mergeModels as Ze, Transition as ze, withModifiers as ht, useSlots as vt, toRef as Me, renderSlot as ie, isRef as yt, createTextVNode as Qe } from "vue";
5
- import { TinyTooltip as We, TinyInput as gt } from "@opentiny/vue";
6
- import { f as mt } from "../index4.js";
7
- import { IconVoice as wt, IconUpload as bt, IconRecordingWave as St, IconClear as xt, IconSend as Ct, IconStop as _t, IconAssociate as kt } from "@opentiny/tiny-robot-svgs";
1
+ var ft = Object.defineProperty;
2
+ var pt = (t, i, a) => i in t ? ft(t, i, { enumerable: !0, configurable: !0, writable: !0, value: a }) : t[i] = a;
3
+ var Ne = (t, i, a) => pt(t, typeof i != "symbol" ? i + "" : i, a);
4
+ import { ref as A, watch as ne, reactive as ht, onUnmounted as st, computed as B, defineComponent as Ce, isVNode as vt, openBlock as m, createElementBlock as R, normalizeStyle as Ae, createBlock as oe, unref as k, withCtx as me, createElementVNode as G, createVNode as ee, normalizeClass as se, createCommentVNode as M, resolveDynamicComponent as yt, toDisplayString as fe, useAttrs as gt, resolveComponent as mt, mergeProps as Se, Fragment as we, renderList as xe, useModel as wt, onMounted as bt, nextTick as q, mergeModels as tt, Transition as qe, withModifiers as St, useSlots as xt, onBeforeUnmount as Ct, toRef as ze, renderSlot as ce, isRef as _t, createTextVNode as nt } from "vue";
5
+ import { TinyTooltip as Ue, TinyInput as It } from "@opentiny/vue";
6
+ import { g as kt, f as Rt } from "../index4.js";
7
+ import { IconVoice as Tt, IconUpload as Et, IconRecordingWave as Ot, IconClear as $t, IconSend as Bt, IconStop as Lt, IconAssociate as Dt } from "@opentiny/tiny-robot-svgs";
8
8
  import { _ as _e } from "../_plugin-vue_export-helper.js";
9
- import { t as It } from "../utils.js";
10
- function Rt(n, i) {
11
- const l = K(n.modelValue || n.defaultValue || ""), r = K(null);
9
+ import { t as Pt } from "../utils.js";
10
+ function Kt(t, i) {
11
+ const a = A(t.modelValue || t.defaultValue || ""), l = A(null);
12
12
  ne(
13
- () => n.modelValue,
14
- (y) => {
15
- y !== void 0 && y !== l.value && (l.value = y);
13
+ () => t.modelValue,
14
+ (g) => {
15
+ g !== void 0 && g !== a.value && (a.value = g);
16
16
  }
17
17
  ), ne(
18
- () => l.value,
19
- (y) => {
20
- i("update:modelValue", y);
18
+ () => a.value,
19
+ (g) => {
20
+ i("update:modelValue", g);
21
21
  }
22
22
  );
23
- const f = (y) => {
24
- l.value = y, i("update:modelValue", y);
25
- }, _ = (y) => {
26
- y == null || y.preventDefault();
27
- const C = l.value;
28
- !n.disabled && !n.loading && C.trim() && i("submit", C);
29
- }, p = () => {
30
- l.value = "", i("update:modelValue", ""), i("clear");
31
- }, h = K(!1);
23
+ const p = (g) => {
24
+ a.value = g, i("update:modelValue", g);
25
+ }, I = (g) => {
26
+ g == null || g.preventDefault();
27
+ const T = a.value;
28
+ !t.disabled && !t.loading && T.trim() && i("submit", T);
29
+ }, h = () => {
30
+ a.value = "", i("update:modelValue", ""), i("clear");
31
+ }, v = A(!1);
32
32
  return {
33
- inputValue: l,
34
- inputWrapper: r,
35
- isComposing: h,
36
- handleChange: f,
37
- handleSubmit: _,
38
- handleClear: p,
33
+ inputValue: a,
34
+ inputWrapper: l,
35
+ isComposing: v,
36
+ handleChange: p,
37
+ handleSubmit: I,
38
+ handleClear: h,
39
39
  clearInput: () => {
40
- p();
40
+ h();
41
41
  }
42
42
  };
43
43
  }
44
- function Tt(n, i, l, r, f, _, p, h, v, y, C, g, O, V, H, F) {
45
- const M = () => {
46
- if (!g.value) return;
47
- const d = l.value.trim();
48
- if (H != null && H.value && Array.isArray(n.templateData)) {
49
- const b = n.templateData.map(({ id: z, ...j }) => j);
50
- i("submit", d, b), F == null || F();
44
+ function At(t, i, a, l, p, I, h, v, y, g, T, L, D, H, _, V) {
45
+ const j = () => {
46
+ if (!L.value) return;
47
+ const f = a.value.trim();
48
+ if (_ != null && _.value && Array.isArray(t.templateData)) {
49
+ const S = t.templateData.map(({ id: z, ...Z }) => Z);
50
+ i("submit", f, S), V == null || V();
51
51
  } else
52
- i("submit", d);
53
- }, R = (d, b) => {
54
- if (!(d.key === "Enter")) return !1;
55
- switch (b) {
52
+ i("submit", f);
53
+ }, E = (f, S) => {
54
+ if (!(f.key === "Enter")) return !1;
55
+ switch (S) {
56
56
  case "enter":
57
- return !d.shiftKey && !d.ctrlKey && !d.metaKey;
57
+ return !f.shiftKey && !f.ctrlKey && !f.metaKey;
58
58
  case "ctrlEnter":
59
- return (d.ctrlKey || d.metaKey) && !d.shiftKey;
59
+ return (f.ctrlKey || f.metaKey) && !f.shiftKey;
60
60
  case "shiftEnter":
61
- return d.shiftKey && !d.ctrlKey && !d.metaKey;
61
+ return f.shiftKey && !f.ctrlKey && !f.metaKey;
62
62
  default:
63
63
  return !1;
64
64
  }
65
- }, W = (d) => {
66
- const b = d.selectionStart ?? 0, z = d.selectionEnd ?? b, j = l.value;
67
- l.value = j.substring(0, b) + `
68
- ` + j.substring(z), setTimeout(() => {
69
- const B = b + 1;
70
- d.selectionStart = d.selectionEnd = B, d.scrollTop = d.scrollHeight;
65
+ }, W = (f) => {
66
+ const S = f.selectionStart ?? 0, z = f.selectionEnd ?? S, Z = a.value;
67
+ a.value = Z.substring(0, S) + `
68
+ ` + Z.substring(z), setTimeout(() => {
69
+ const K = S + 1;
70
+ f.selectionStart = f.selectionEnd = K, f.scrollTop = f.scrollHeight;
71
71
  }, 0);
72
- }, S = (d) => {
73
- if (n.submitType !== "enter" || d.key !== "Enter") return !1;
74
- const b = d.ctrlKey && !d.shiftKey, z = d.shiftKey && !d.ctrlKey;
75
- if (b || z) {
76
- d.preventDefault();
77
- const j = d.target;
78
- return (O == null ? void 0 : O.value) === "single" && V && V(), W(j), !0;
72
+ }, b = (f) => {
73
+ if (t.submitType !== "enter" || f.key !== "Enter") return !1;
74
+ const S = f.ctrlKey && !f.shiftKey, z = f.shiftKey && !f.ctrlKey;
75
+ if (S || z) {
76
+ f.preventDefault();
77
+ const Z = f.target;
78
+ return (D == null ? void 0 : D.value) === "single" && H && H(), W(Z), !0;
79
79
  }
80
80
  return !1;
81
81
  };
82
82
  return {
83
- handleKeyPress: (d) => {
84
- if (!r.value && !S(d)) {
85
- if (_.value) {
86
- if (d.key === "ArrowDown") {
87
- d.preventDefault(), y("down");
83
+ handleKeyPress: (f) => {
84
+ if (!l.value && !b(f)) {
85
+ if (I.value) {
86
+ if (f.key === "ArrowDown") {
87
+ f.preventDefault(), g("down");
88
88
  return;
89
89
  }
90
- if (d.key === "ArrowUp") {
91
- d.preventDefault(), y("up");
90
+ if (f.key === "ArrowUp") {
91
+ f.preventDefault(), g("up");
92
92
  return;
93
93
  }
94
- if (p.value && (n.activeSuggestionKeys || ["Enter", "Tab"]).includes(d.key)) {
95
- d.preventDefault(), h();
94
+ if (h.value && (t.activeSuggestionKeys || ["Enter", "Tab"]).includes(f.key)) {
95
+ f.preventDefault(), v();
96
96
  return;
97
97
  }
98
98
  }
99
- if (d.key === "Escape") {
100
- _.value ? (v(), d.preventDefault()) : f.isRecording && (C(), d.preventDefault()), i("escape-press");
99
+ if (f.key === "Escape") {
100
+ I.value ? (y(), f.preventDefault()) : p.isRecording && (T(), f.preventDefault()), i("escape-press");
101
101
  return;
102
102
  }
103
- R(d, n.submitType) && g.value && (d.preventDefault(), M());
103
+ E(f, t.submitType) && L.value && (f.preventDefault(), j());
104
104
  }
105
105
  },
106
- triggerSubmit: M
106
+ triggerSubmit: j
107
107
  };
108
108
  }
109
- class Le {
109
+ class Pe {
110
110
  constructor(i) {
111
- Pe(this, "recognition");
112
- Pe(this, "options");
111
+ Ne(this, "recognition");
112
+ Ne(this, "options");
113
113
  this.options = i, this.initialize();
114
114
  }
115
115
  /**
@@ -128,7 +128,7 @@ class Le {
128
128
  * 检查浏览器是否支持 Web Speech API(实例方法)
129
129
  */
130
130
  isSupported() {
131
- return Le.isSupported();
131
+ return Pe.isSupported();
132
132
  }
133
133
  /**
134
134
  * 设置语音识别事件处理器
@@ -139,11 +139,11 @@ class Le {
139
139
  i.onStart();
140
140
  }, this.recognition.onend = () => {
141
141
  i.onEnd();
142
- }, this.recognition.onresult = (l) => {
143
- const r = Array.from(l.results).map((_) => _[0].transcript).join(""), f = l.results[l.resultIndex];
144
- f != null && f.isFinal ? i.onFinal(r) : i.onInterim(r);
145
- }, this.recognition.onerror = (l) => {
146
- i.onError(new Error(l.error)), this.cleanup();
142
+ }, this.recognition.onresult = (a) => {
143
+ const l = Array.from(a.results).map((I) => I[0].transcript).join(""), p = a.results[a.resultIndex];
144
+ p != null && p.isFinal ? i.onFinal(l) : i.onInterim(l);
145
+ }, this.recognition.onerror = (a) => {
146
+ i.onError(new Error(a.error)), this.cleanup();
147
147
  });
148
148
  }
149
149
  /**
@@ -164,8 +164,8 @@ class Le {
164
164
  this.setupEventHandlers(i);
165
165
  try {
166
166
  this.recognition.start();
167
- } catch (l) {
168
- i.onError(l instanceof Error ? l : new Error("语音识别启动失败"));
167
+ } catch (a) {
168
+ i.onError(a instanceof Error ? a : new Error("语音识别启动失败"));
169
169
  }
170
170
  }
171
171
  /**
@@ -182,125 +182,125 @@ class Le {
182
182
  }
183
183
  }
184
184
  }
185
- function Et(n) {
186
- const i = lt({
185
+ function Ht(t) {
186
+ const i = ht({
187
187
  isRecording: !1,
188
188
  isSupported: !1,
189
189
  error: void 0
190
- }), l = {
190
+ }), a = {
191
191
  onStart: () => {
192
- var h;
193
- i.isRecording = !0, i.error = void 0, (h = n.onStart) == null || h.call(n);
194
- },
195
- onInterim: (h) => {
196
192
  var v;
197
- (v = n.onInterim) == null || v.call(n, h);
193
+ i.isRecording = !0, i.error = void 0, (v = t.onStart) == null || v.call(t);
198
194
  },
199
- onFinal: (h) => {
200
- var v;
201
- (v = n.onFinal) == null || v.call(n, h);
195
+ onInterim: (v) => {
196
+ var y;
197
+ (y = t.onInterim) == null || y.call(t, v);
202
198
  },
203
- onEnd: (h) => {
204
- var v;
205
- i.isRecording && (i.isRecording = !1, (v = n.onEnd) == null || v.call(n, h));
199
+ onFinal: (v) => {
200
+ var y;
201
+ (y = t.onFinal) == null || y.call(t, v);
206
202
  },
207
- onError: (h) => {
208
- var v;
209
- i.error = h, i.isRecording = !1, (v = n.onError) == null || v.call(n, h);
203
+ onEnd: (v) => {
204
+ var y;
205
+ i.isRecording && (i.isRecording = !1, (y = t.onEnd) == null || y.call(t, v));
206
+ },
207
+ onError: (v) => {
208
+ var y;
209
+ i.error = v, i.isRecording = !1, (y = t.onError) == null || y.call(t, v);
210
210
  }
211
- }, r = Le.isSupported();
212
- i.isSupported = n.customHandler ? n.customHandler.isSupported() : r;
213
- const f = n.customHandler ?? (r ? new Le(n) : null), _ = () => {
214
- var h;
215
- if (!i.isSupported || !f) {
216
- const v = new Error("语音识别不受支持");
217
- i.error = v, (h = n.onError) == null || h.call(n, v);
211
+ }, l = Pe.isSupported();
212
+ i.isSupported = t.customHandler ? t.customHandler.isSupported() : l;
213
+ const p = t.customHandler ?? (l ? new Pe(t) : null), I = () => {
214
+ var v;
215
+ if (!i.isSupported || !p) {
216
+ const y = new Error("语音识别不受支持");
217
+ i.error = y, (v = t.onError) == null || v.call(t, y);
218
218
  return;
219
219
  }
220
220
  if (i.isRecording) {
221
- f.stop(), i.isRecording = !1, setTimeout(() => {
222
- f.start(l);
221
+ p.stop(), i.isRecording = !1, setTimeout(() => {
222
+ p.start(a);
223
223
  }, 200);
224
224
  return;
225
225
  }
226
- f.start(l);
227
- }, p = () => {
228
- !i.isRecording || !f || (f.stop(), l.onEnd());
226
+ p.start(a);
227
+ }, h = () => {
228
+ !i.isRecording || !p || (p.stop(), a.onEnd());
229
229
  };
230
- return tt(() => {
231
- i.isRecording && f && (f.stop(), i.isRecording = !1);
230
+ return st(() => {
231
+ i.isRecording && p && (p.stop(), i.isRecording = !1);
232
232
  }), {
233
233
  speechState: i,
234
- start: _,
235
- stop: p
234
+ start: I,
235
+ stop: h
236
236
  };
237
237
  }
238
- function Ot(n, i, l, r, f, _) {
239
- const p = K(!1), h = K(-1), v = K(-1), y = K(null), C = K(""), g = K(!1), O = E(() => {
240
- var J, G;
241
- if (!((J = n.value) != null && J.length)) return "";
242
- const B = y.value === "mouse" ? v.value : h.value;
243
- return ((G = n.value[B]) == null ? void 0 : G.content) || "";
244
- }), V = (B) => {
245
- C.value = B, g.value = !0;
246
- }, H = () => {
247
- C.value = "", g.value = !1;
248
- }, F = (B) => {
249
- const J = B || O.value;
238
+ function Vt(t, i, a, l, p, I) {
239
+ const h = A(!1), v = A(-1), y = A(-1), g = A(null), T = A(""), L = A(!1), D = B(() => {
240
+ var J, X;
241
+ if (!((J = t.value) != null && J.length)) return "";
242
+ const K = g.value === "mouse" ? y.value : v.value;
243
+ return ((X = t.value[K]) == null ? void 0 : X.content) || "";
244
+ }), H = (K) => {
245
+ T.value = K, L.value = !0;
246
+ }, _ = () => {
247
+ T.value = "", L.value = !1;
248
+ }, V = (K) => {
249
+ const J = K || D.value;
250
250
  if (!J || !i.value) {
251
- H();
251
+ _();
252
252
  return;
253
253
  }
254
- const G = J.substring(i.value.length);
255
- J.toLowerCase().startsWith(i.value.toLowerCase()) && G ? V(G) : H();
256
- }, M = () => {
257
- h.value = -1, v.value = -1, y.value = null;
258
- }, R = () => {
259
- p.value = !0, F();
260
- }, W = () => {
261
- p.value = !1, M(), H();
262
- }, S = E(() => {
263
- var B;
264
- return l.value ? !0 : !!(i.value && ((B = n.value) == null ? void 0 : B.length) > 0 && !r.value);
265
- }), w = (B) => {
266
- W(), i.value = B, f(B), _(B);
267
- }, d = () => {
268
- O.value && w(O.value);
269
- }, b = (B) => {
270
- !p.value || !n.value || (y.value = "keyboard", h.value === -1 ? h.value = B === "down" ? 0 : n.value.length - 1 : B === "down" ? h.value = (h.value + 1) % n.value.length : h.value = (h.value - 1 + n.value.length) % n.value.length, F());
271
- }, z = (B) => {
272
- n.value && (y.value = "mouse", v.value = B, F());
254
+ const X = J.substring(i.value.length);
255
+ J.toLowerCase().startsWith(i.value.toLowerCase()) && X ? H(X) : _();
273
256
  }, j = () => {
274
- n.value && (v.value = -1, h.value !== -1 ? y.value = "keyboard" : y.value = null, F());
257
+ v.value = -1, y.value = -1, g.value = null;
258
+ }, E = () => {
259
+ h.value = !0, V();
260
+ }, W = () => {
261
+ h.value = !1, j(), _();
262
+ }, b = B(() => {
263
+ var K;
264
+ return a.value ? !0 : !!(i.value && ((K = t.value) == null ? void 0 : K.length) > 0 && !l.value);
265
+ }), x = (K) => {
266
+ W(), i.value = K, p(K), I(K);
267
+ }, f = () => {
268
+ D.value && x(D.value);
269
+ }, S = (K) => {
270
+ !h.value || !t.value || (g.value = "keyboard", v.value === -1 ? v.value = K === "down" ? 0 : t.value.length - 1 : K === "down" ? v.value = (v.value + 1) % t.value.length : v.value = (v.value - 1 + t.value.length) % t.value.length, V());
271
+ }, z = (K) => {
272
+ t.value && (g.value = "mouse", y.value = K, V());
273
+ }, Z = () => {
274
+ t.value && (y.value = -1, v.value !== -1 ? g.value = "keyboard" : g.value = null, V());
275
275
  };
276
- return ne(S, (B) => {
277
- B ? p.value || R() : p.value && W();
276
+ return ne(b, (K) => {
277
+ K ? h.value || E() : h.value && W();
278
278
  }), {
279
279
  // 弹窗控制
280
- isPopupVisible: p,
281
- openPopup: R,
280
+ isPopupVisible: h,
281
+ openPopup: E,
282
282
  closePopup: W,
283
283
  // 自动完成占位符
284
- autoCompleteText: C,
285
- showTabIndicator: g,
286
- syncAutoComplete: F,
284
+ autoCompleteText: T,
285
+ showTabIndicator: L,
286
+ syncAutoComplete: V,
287
287
  // 选中控制层
288
- activeSuggestion: O,
289
- activeKeyboardIndex: h,
290
- activeMouseIndex: v,
288
+ activeSuggestion: D,
289
+ activeKeyboardIndex: v,
290
+ activeMouseIndex: y,
291
291
  // 交互处理
292
- navigateWithKeyboard: b,
292
+ navigateWithKeyboard: S,
293
293
  handleMouseEnter: z,
294
- handleMouseLeave: j,
294
+ handleMouseLeave: Z,
295
295
  // 业务操作
296
- applySuggestion: w,
297
- confirmSelection: d
296
+ applySuggestion: x,
297
+ confirmSelection: f
298
298
  };
299
299
  }
300
- const $t = { class: "action-buttons" }, Bt = { class: "action-buttons__submit-content" }, Lt = {
300
+ const Ft = { class: "action-buttons" }, Mt = { class: "action-buttons__submit-content" }, Wt = {
301
301
  key: 0,
302
302
  class: "action-buttons__cancel-text"
303
- }, Dt = /* @__PURE__ */ Ce({
303
+ }, Nt = /* @__PURE__ */ Ce({
304
304
  __name: "ActionButtons",
305
305
  props: {
306
306
  loading: { type: Boolean, default: !1 },
@@ -320,150 +320,150 @@ const $t = { class: "action-buttons" }, Bt = { class: "action-buttons__submit-co
320
320
  stopText: { default: void 0 }
321
321
  },
322
322
  emits: ["clear", "submit", "cancel", "trigger-select", "voice-button-click"],
323
- setup(n, { emit: i }) {
324
- const l = n, r = i, f = E(() => {
325
- var w, d;
326
- const S = (d = (w = l.buttonGroup) == null ? void 0 : w.file) == null ? void 0 : d.tooltips;
327
- if (typeof S == "string" && S)
328
- return () => S;
329
- if (typeof S == "function")
330
- return S;
331
- }), _ = E(() => {
332
- var w, d;
333
- const S = (d = (w = l.buttonGroup) == null ? void 0 : w.submit) == null ? void 0 : d.tooltips;
334
- if (typeof S == "string" && S)
335
- return () => S;
336
- if (typeof S == "function")
337
- return S;
338
- }), p = E(() => l.allowSpeech), h = E(() => l.speechStatus.isRecording), v = E(() => l.disabled), y = E(() => {
339
- var S, w;
340
- return v.value || l.isOverLimit || ((w = (S = l.buttonGroup) == null ? void 0 : S.submit) == null ? void 0 : w.disabled);
341
- }), C = E(() => l.allowFiles || l.allowSpeech || l.showClear), g = E(() => {
342
- var w, d;
343
- const S = (d = (w = l.buttonGroup) == null ? void 0 : w.voice) == null ? void 0 : d.icon;
344
- return S ? rt(S) ? () => S : S : wt;
345
- }), O = () => {
346
- v.value || r("clear");
347
- }, V = () => {
348
- v.value || r("voice-button-click");
323
+ setup(t, { emit: i }) {
324
+ const a = t, l = i, p = B(() => {
325
+ var x, f;
326
+ const b = (f = (x = a.buttonGroup) == null ? void 0 : x.file) == null ? void 0 : f.tooltips;
327
+ if (typeof b == "string" && b)
328
+ return () => b;
329
+ if (typeof b == "function")
330
+ return b;
331
+ }), I = B(() => {
332
+ var x, f;
333
+ const b = (f = (x = a.buttonGroup) == null ? void 0 : x.submit) == null ? void 0 : f.tooltips;
334
+ if (typeof b == "string" && b)
335
+ return () => b;
336
+ if (typeof b == "function")
337
+ return b;
338
+ }), h = B(() => a.allowSpeech), v = B(() => a.speechStatus.isRecording), y = B(() => a.disabled), g = B(() => {
339
+ var b, x;
340
+ return y.value || a.isOverLimit || ((x = (b = a.buttonGroup) == null ? void 0 : b.submit) == null ? void 0 : x.disabled);
341
+ }), T = B(() => a.allowFiles || a.allowSpeech || a.showClear), L = B(() => {
342
+ var x, f;
343
+ const b = (f = (x = a.buttonGroup) == null ? void 0 : x.voice) == null ? void 0 : f.icon;
344
+ return b ? vt(b) ? () => b : b : Tt;
345
+ }), D = () => {
346
+ y.value || l("clear");
349
347
  }, H = () => {
350
- y.value || r("submit");
351
- }, F = () => {
352
- v.value || r("cancel");
353
- }, M = E(() => {
354
- var S, w;
355
- return v.value || ((w = (S = l.buttonGroup) == null ? void 0 : S.file) == null ? void 0 : w.disabled);
356
- }), R = () => {
357
- M.value || r("trigger-select");
358
- }, W = E(() => {
359
- var S, w;
360
- return ((w = (S = l.buttonGroup) == null ? void 0 : S.file) == null ? void 0 : w.tooltipPlacement) || "top";
348
+ y.value || l("voice-button-click");
349
+ }, _ = () => {
350
+ g.value || l("submit");
351
+ }, V = () => {
352
+ y.value || l("cancel");
353
+ }, j = B(() => {
354
+ var b, x;
355
+ return y.value || ((x = (b = a.buttonGroup) == null ? void 0 : b.file) == null ? void 0 : x.disabled);
356
+ }), E = () => {
357
+ j.value || l("trigger-select");
358
+ }, W = B(() => {
359
+ var b, x;
360
+ return ((x = (b = a.buttonGroup) == null ? void 0 : b.file) == null ? void 0 : x.tooltipPlacement) || "top";
361
361
  });
362
- return (S, w) => (m(), I("div", $t, [
363
- C.value ? (m(), I("div", {
362
+ return (b, x) => (m(), R("div", Ft, [
363
+ T.value ? (m(), R("div", {
364
364
  key: 0,
365
365
  class: "action-buttons__utility",
366
- style: Ue({ "padding-right": n.hasContent || n.loading ? "0" : "6px" })
366
+ style: Ae({ "padding-right": t.hasContent || t.loading ? "0" : "6px" })
367
367
  }, [
368
- n.allowFiles && !n.loading ? (m(), ee(k(We), {
368
+ t.allowFiles && !t.loading ? (m(), oe(k(Ue), {
369
369
  key: 0,
370
370
  effect: "light",
371
371
  placement: W.value,
372
- "render-content": f.value,
372
+ "render-content": p.value,
373
373
  "visible-arrow": !1,
374
374
  "popper-class": "tr-sender-actions-upload-button-popper"
375
375
  }, {
376
- default: ve(() => [
377
- U("div", {
376
+ default: me(() => [
377
+ G("div", {
378
378
  class: "action-buttons__button",
379
- onClick: R,
380
- onFocusCapture: w[0] || (w[0] = (d) => d.stopPropagation())
379
+ onClick: E,
380
+ onFocusCapture: x[0] || (x[0] = (f) => f.stopPropagation())
381
381
  }, [
382
- Z(k(bt), {
383
- class: oe(["action-buttons__icon", { "is-disabled": M.value }]),
382
+ ee(k(Et), {
383
+ class: se(["action-buttons__icon", { "is-disabled": j.value }]),
384
384
  alt: "上传文件"
385
385
  }, null, 8, ["class"])
386
386
  ], 32)
387
387
  ]),
388
388
  _: 1
389
- }, 8, ["placement", "render-content"])) : P("", !0),
390
- p.value && !n.loading ? (m(), I("div", {
389
+ }, 8, ["placement", "render-content"])) : M("", !0),
390
+ h.value && !t.loading ? (m(), R("div", {
391
391
  key: 1,
392
- class: oe(["action-buttons__button", { "is-recording": h.value }]),
393
- onClick: V
392
+ class: se(["action-buttons__button", { "is-recording": v.value }]),
393
+ onClick: H
394
394
  }, [
395
- h.value ? (m(), ee(k(St), {
395
+ v.value ? (m(), oe(k(Ot), {
396
396
  key: 1,
397
397
  class: "action-buttons__icon",
398
398
  alt: "语音中"
399
- })) : (m(), ee(ct(g.value), {
399
+ })) : (m(), oe(yt(L.value), {
400
400
  key: 0,
401
401
  class: "action-buttons__icon",
402
402
  alt: "录音"
403
403
  }))
404
- ], 2)) : P("", !0),
405
- n.showClear && n.hasContent ? (m(), ee(k(We), {
404
+ ], 2)) : M("", !0),
405
+ t.showClear && t.hasContent ? (m(), oe(k(Ue), {
406
406
  key: 2,
407
407
  content: "清空内容",
408
408
  placement: "top"
409
409
  }, {
410
- default: ve(() => [
411
- U("div", {
410
+ default: me(() => [
411
+ G("div", {
412
412
  class: "action-buttons__button",
413
- onClick: O
413
+ onClick: D
414
414
  }, [
415
- Z(k(xt), { class: "action-buttons__icon" })
415
+ ee(k($t), { class: "action-buttons__icon" })
416
416
  ])
417
417
  ]),
418
418
  _: 1
419
- })) : P("", !0)
420
- ], 4)) : P("", !0),
421
- n.hasContent || n.loading ? (m(), I("div", {
419
+ })) : M("", !0)
420
+ ], 4)) : M("", !0),
421
+ t.hasContent || t.loading ? (m(), R("div", {
422
422
  key: 1,
423
423
  class: "action-buttons__button action-buttons__submit",
424
- onClick: w[1] || (w[1] = (d) => n.loading ? F() : H())
424
+ onClick: x[1] || (x[1] = (f) => t.loading ? V() : _())
425
425
  }, [
426
- U("div", Bt, [
427
- n.loading ? (m(), I("div", {
426
+ G("div", Mt, [
427
+ t.loading ? (m(), R("div", {
428
428
  key: 1,
429
- class: oe(["action-buttons__cancel", { "action-buttons__cancel--icon-only": !n.stopText }])
429
+ class: se(["action-buttons__cancel", { "action-buttons__cancel--icon-only": !t.stopText }])
430
430
  }, [
431
- Z(k(_t), {
431
+ ee(k(Lt), {
432
432
  class: "action-buttons__icon action-buttons__icon--cancel",
433
433
  alt: "停止"
434
434
  }),
435
- n.stopText ? (m(), I("span", Lt, de(n.stopText), 1)) : P("", !0)
436
- ], 2)) : (m(), ee(k(We), {
435
+ t.stopText ? (m(), R("span", Wt, fe(t.stopText), 1)) : M("", !0)
436
+ ], 2)) : (m(), oe(k(Ue), {
437
437
  key: 0,
438
438
  effect: "light",
439
439
  placement: "top",
440
- "render-content": _.value,
440
+ "render-content": I.value,
441
441
  "visible-arrow": !1
442
442
  }, {
443
- default: ve(() => [
444
- Z(k(Ct), {
445
- class: oe(["action-buttons__icon", "action-buttons__icon--send", { "is-disabled": y.value }]),
443
+ default: me(() => [
444
+ ee(k(Bt), {
445
+ class: se(["action-buttons__icon", "action-buttons__icon--send", { "is-disabled": g.value }]),
446
446
  alt: "发送"
447
447
  }, null, 8, ["class"])
448
448
  ]),
449
449
  _: 1
450
450
  }, 8, ["render-content"]))
451
451
  ])
452
- ])) : P("", !0)
452
+ ])) : M("", !0)
453
453
  ]));
454
454
  }
455
- }), et = /* @__PURE__ */ _e(Dt, [["__scopeId", "data-v-f71ebb23"]]);
456
- function Kt(n, i = {}) {
457
- let l = [], r = [], f = n;
458
- return { commit: (C) => {
459
- var g;
460
- l.push(f), f = C, r.length && ((g = i.onRemoveHistory) == null || g.call(i, r)), r = [];
461
- }, undo: () => l.length ? (r.push(f), f = l.pop(), f) : null, redo: () => r.length ? (l.push(f), f = r.pop(), f) : null, clear: () => {
462
- var C, g;
463
- l.length && ((C = i.onRemoveHistory) == null || C.call(i, l)), r.length && ((g = i.onRemoveHistory) == null || g.call(i, r)), l = [], r = [];
464
- }, get: () => f };
455
+ }), ot = /* @__PURE__ */ _e(Nt, [["__scopeId", "data-v-f71ebb23"]]);
456
+ function zt(t, i = {}) {
457
+ let a = [], l = [], p = t;
458
+ return { commit: (T) => {
459
+ var L;
460
+ a.push(p), p = T, l.length && ((L = i.onRemoveHistory) == null || L.call(i, l)), l = [];
461
+ }, undo: () => a.length ? (l.push(p), p = a.pop(), p) : null, redo: () => l.length ? (a.push(p), p = l.pop(), p) : null, clear: () => {
462
+ var T, L;
463
+ a.length && ((T = i.onRemoveHistory) == null || T.call(i, a)), l.length && ((L = i.onRemoveHistory) == null || L.call(i, l)), a = [], l = [];
464
+ }, get: () => p };
465
465
  }
466
- const At = ["data-id", "data-type"], Ht = ["data-id", "data-type"], Vt = /* @__PURE__ */ Ce({
466
+ const Ut = ["data-id", "data-type"], Gt = ["data-id", "data-type"], qt = /* @__PURE__ */ Ce({
467
467
  inheritAttrs: !1,
468
468
  __name: "Block",
469
469
  props: {
@@ -473,65 +473,65 @@ const At = ["data-id", "data-type"], Ht = ["data-id", "data-type"], Vt = /* @__P
473
473
  readonly: { type: Boolean },
474
474
  asChild: { type: Boolean }
475
475
  },
476
- setup(n) {
477
- const i = n, l = ut();
478
- return (r, f) => {
479
- const _ = dt("Block", !0);
480
- return i.type !== "block" ? (m(), I("span", Se({
476
+ setup(t) {
477
+ const i = t, a = gt();
478
+ return (l, p) => {
479
+ const I = mt("Block", !0);
480
+ return i.type !== "block" ? (m(), R("span", Se({
481
481
  key: 0,
482
482
  "data-id": i.id,
483
483
  "data-type": i.type
484
- }, k(l)), de(i.content), 17, At)) : (m(), I(ye, { key: 1 }, [
485
- i.asChild ? (m(!0), I(ye, { key: 0 }, xe(i.content, (p) => (m(), ee(_, Se({
486
- key: `${p.id}-${p.type}`
487
- }, { ref_for: !0 }, p), null, 16))), 128)) : (m(), I("span", Se({
484
+ }, k(a)), fe(i.content), 17, Ut)) : (m(), R(we, { key: 1 }, [
485
+ i.asChild ? (m(!0), R(we, { key: 0 }, xe(i.content, (h) => (m(), oe(I, Se({
486
+ key: `${h.id}-${h.type}`
487
+ }, { ref_for: !0 }, h), null, 16))), 128)) : (m(), R("span", Se({
488
488
  key: 1,
489
489
  "data-id": i.id,
490
490
  "data-type": i.type
491
- }, k(l)), [
492
- (m(!0), I(ye, null, xe(i.content, (p) => (m(), ee(_, Se({
493
- key: `${p.id}-${p.type}`
494
- }, { ref_for: !0 }, p), null, 16))), 128))
495
- ], 16, Ht))
491
+ }, k(a)), [
492
+ (m(!0), R(we, null, xe(i.content, (h) => (m(), oe(I, Se({
493
+ key: `${h.id}-${h.type}`
494
+ }, { ref_for: !0 }, h), null, 16))), 128))
495
+ ], 16, Gt))
496
496
  ], 64));
497
497
  };
498
498
  }
499
- }), Ft = /* @__PURE__ */ _e(Vt, [["__scopeId", "data-v-13862606"]]), Pt = { class: "editor-container" }, Ne = "​", Mt = 40, Wt = /* @__PURE__ */ Ce({
499
+ }), jt = /* @__PURE__ */ _e(qt, [["__scopeId", "data-v-13862606"]]), Jt = { class: "editor-container" }, Ge = "​", Xt = 40, Yt = /* @__PURE__ */ Ce({
500
500
  __name: "TemplateEditor",
501
- props: /* @__PURE__ */ Ze({
501
+ props: /* @__PURE__ */ tt({
502
502
  autoSize: { type: [Boolean, Object] }
503
503
  }, {
504
504
  modelValue: { default: () => [] },
505
505
  modelModifiers: {}
506
506
  }),
507
- emits: /* @__PURE__ */ Ze(["submit"], ["update:modelValue"]),
508
- setup(n, { expose: i, emit: l }) {
509
- const r = typeof window.ShadowRoot.prototype.getSelection == "function", f = typeof window.Selection.prototype.getComposedRanges == "function";
510
- function _() {
507
+ emits: /* @__PURE__ */ tt(["submit"], ["update:modelValue"]),
508
+ setup(t, { expose: i, emit: a }) {
509
+ const l = typeof window.ShadowRoot.prototype.getSelection == "function", p = typeof window.Selection.prototype.getComposedRanges == "function";
510
+ function I() {
511
511
  const e = navigator.userAgent;
512
512
  return e.includes("Safari") && !e.includes("Chrome") && !e.includes("Chromium") && !e.includes("CriOS");
513
513
  }
514
- const p = _(), h = () => Math.random().toString(36).substring(2, 15), v = Ne, y = Ne, C = Ne, g = n, O = ft(n, "modelValue"), V = l, H = K(0), F = (e) => e.map((o) => ({
515
- id: o.id || h(),
516
- ...o.type === "template" ? { ...o, prefix: y, suffix: C } : o
517
- })), M = (e) => e.map((o) => ({ id: o.id, type: o.type, content: o.content })), R = K(F(O.value || [])), W = (e) => {
518
- R.value = e;
519
- }, S = E(() => {
520
- const e = [], o = [], s = R.value;
521
- if (s.length >= 2) {
522
- const t = s[0], a = s[1];
523
- t.type === "text" && t.content.length === 0 && a.type === "template" && e.push({ ...t, content: v });
524
- const u = s[s.length - 1], x = s[s.length - 2];
525
- u.type === "text" && u.content.length === 0 && x.type === "template" && o.push({ ...u, content: v });
514
+ const h = I(), v = () => Math.random().toString(36).substring(2, 15), y = Ge, g = Ge, T = Ge, L = t, D = wt(t, "modelValue"), H = a, _ = A(0), V = (e) => e.map((n) => ({
515
+ id: n.id || v(),
516
+ ...n.type === "template" ? { ...n, prefix: g, suffix: T } : n
517
+ })), j = (e) => e.map((n) => ({ id: n.id, type: n.type, content: n.content })), E = A(V(D.value || [])), W = (e) => {
518
+ E.value = e;
519
+ }, b = B(() => {
520
+ const e = [], n = [], o = E.value;
521
+ if (o.length >= 2) {
522
+ const c = o[0], d = o[1];
523
+ c.type === "text" && c.content.length === 0 && d.type === "template" && e.push({ ...c, content: y });
524
+ const w = o[o.length - 1], O = o[o.length - 2];
525
+ w.type === "text" && w.content.length === 0 && O.type === "template" && n.push({ ...w, content: y });
526
526
  }
527
- s.length > 0 && s[0].type === "template" && e.push({ type: "text", content: v, id: h() }), s.length > 0 && s[s.length - 1].type === "template" && o.push({ type: "text", content: v, id: h() });
528
- const c = new RegExp(v, "g");
529
- return s.length > 0 && (s[0].content !== v && (s[0].content = s[0].content.replace(c, "")), s[s.length - 1].content !== v && (s[s.length - 1].content = s[s.length - 1].content.replace(c, ""))), e.concat(s).concat(o);
530
- }), w = E(() => R.value.map((e) => e.type === "template" ? [
527
+ o.length > 0 && o[0].type === "template" && e.push({ type: "text", content: y, id: v() }), o.length > 0 && o[o.length - 1].type === "template" && n.push({ type: "text", content: y, id: v() });
528
+ const r = new RegExp(y, "g");
529
+ return o.length > 0 && (o[0].content !== y && (o[0].content = o[0].content.replace(r, "")), o[o.length - 1].content !== y && (o[o.length - 1].content = o[o.length - 1].content.replace(r, ""))), e.concat(o).concat(n);
530
+ }), x = B(() => E.value.map((e) => e.type === "template" ? [
531
531
  { id: e.id, type: "prefix", content: e.prefix },
532
532
  { id: e.id, type: "template", content: e.content },
533
533
  { id: e.id, type: "suffix", content: e.suffix }
534
- ] : [e]).flat()), d = E(() => S.value.map((e) => e.type === "text" ? e : p ? {
534
+ ] : [e]).flat()), f = B(() => b.value.map((e) => e.type === "text" ? e : h ? {
535
535
  id: e.id,
536
536
  type: "block",
537
537
  asChild: !0,
@@ -561,118 +561,118 @@ const At = ["data-id", "data-type"], Ht = ["data-id", "data-type"], Vt = /* @__P
561
561
  },
562
562
  { id: e.id, type: "suffix", content: e.suffix }
563
563
  ]
564
- })), b = K(null), z = K(Mt), j = () => {
565
- if (!b.value) return;
566
- const e = window.getComputedStyle(b.value), o = parseFloat(e.fontSize), s = parseFloat(e.lineHeight);
567
- z.value = isNaN(s) ? o * 2.5 : s;
568
- }, B = E(() => {
569
- if (!g.autoSize)
564
+ })), S = A(null), z = A(Xt), Z = () => {
565
+ if (!S.value) return;
566
+ const e = window.getComputedStyle(S.value), n = parseFloat(e.fontSize), o = parseFloat(e.lineHeight);
567
+ z.value = isNaN(o) ? n * 2.5 : o;
568
+ }, K = B(() => {
569
+ if (!L.autoSize)
570
570
  return {};
571
- const e = typeof g.autoSize == "boolean" ? { minRows: 1, maxRows: 3 } : g.autoSize, o = e.minRows * z.value, s = e.maxRows * z.value;
571
+ const e = typeof L.autoSize == "boolean" ? { minRows: 1, maxRows: 3 } : L.autoSize, n = e.minRows * z.value, o = e.maxRows * z.value;
572
572
  return {
573
- minHeight: `${o}px`,
574
- maxHeight: `${s}px`,
573
+ minHeight: `${n}px`,
574
+ maxHeight: `${o}px`,
575
575
  overflowY: "auto",
576
576
  overflowX: "hidden"
577
577
  };
578
578
  }), J = () => {
579
- if (!b.value) return;
579
+ if (!S.value) return;
580
580
  const e = window.getSelection();
581
581
  if (!e || e.rangeCount === 0) return;
582
- const s = e.getRangeAt(0).getBoundingClientRect(), c = b.value.getBoundingClientRect(), t = s.top - c.top, a = s.bottom - c.top, u = b.value.scrollTop, x = b.value.clientHeight;
583
- a > x ? b.value.scrollTop = u + (a - x) + 10 : t < 0 && (b.value.scrollTop = u + t - 10);
584
- }, G = (e) => {
585
- const o = Date.now(), s = JSON.stringify(e);
586
- return `${o}:${s}`;
587
- }, ke = (e) => {
588
- const o = parseInt(e.slice(0, 13)), s = JSON.parse(e.slice(14));
582
+ const o = e.getRangeAt(0).getBoundingClientRect(), r = S.value.getBoundingClientRect(), c = o.top - r.top, d = o.bottom - r.top, w = S.value.scrollTop, O = S.value.clientHeight;
583
+ d > O ? S.value.scrollTop = w + (d - O) + 10 : c < 0 && (S.value.scrollTop = w + c - 10);
584
+ }, X = (e) => {
585
+ const n = Date.now(), o = JSON.stringify(e);
586
+ return `${n}:${o}`;
587
+ }, Ie = (e) => {
588
+ const n = parseInt(e.slice(0, 13)), o = JSON.parse(e.slice(14));
589
589
  return {
590
- timestamp: o,
591
- data: s
590
+ timestamp: n,
591
+ data: o
592
592
  };
593
- }, L = /* @__PURE__ */ new Map(), A = Kt(G(R.value), {
593
+ }, Q = /* @__PURE__ */ new Map(), N = zt(X(E.value), {
594
594
  onRemoveHistory: (e) => {
595
- for (const o of e)
596
- L.delete(o);
595
+ for (const n of e)
596
+ Q.delete(n);
597
597
  }
598
598
  });
599
599
  ne(
600
- () => O.value,
600
+ () => D.value,
601
601
  (e) => {
602
- const o = F(e || []);
603
- if (JSON.stringify(o) !== JSON.stringify(R.value)) {
604
- if (b.value) {
605
- const c = le(b.value);
606
- c && L.set(A.get(), X(c));
602
+ const n = V(e || []);
603
+ if (JSON.stringify(n) !== JSON.stringify(E.value)) {
604
+ if (S.value) {
605
+ const r = te(S.value);
606
+ r && Q.set(N.get(), Y(r));
607
607
  }
608
- W(o), A.commit(G(R.value));
608
+ W(n), N.commit(X(E.value));
609
609
  }
610
610
  },
611
611
  { deep: !0 }
612
612
  );
613
- const ge = (e, o = document.body) => o.contains(e) ? e instanceof HTMLElement && e.dataset.id ? e : e.parentElement ? ge(e.parentElement, o) : null : null, fe = (e) => e === b.value, le = (e) => {
614
- const o = window.getSelection();
615
- if (!o)
613
+ const be = (e, n = document.body) => n.contains(e) ? e instanceof HTMLElement && e.dataset.id ? e : e.parentElement ? be(e.parentElement, n) : null : null, F = (e) => e === S.value, te = (e) => {
614
+ const n = window.getSelection();
615
+ if (!n)
616
616
  return null;
617
- const s = o.rangeCount > 0 ? o.getRangeAt(0) : null, c = e.getRootNode();
618
- if (!(c instanceof ShadowRoot))
619
- return s;
620
- if (f) {
621
- const t = o.getComposedRanges(p ? c : { shadowRoots: [c] });
622
- return (t == null ? void 0 : t[0]) ?? null;
617
+ const o = n.rangeCount > 0 ? n.getRangeAt(0) : null, r = e.getRootNode();
618
+ if (!(r instanceof ShadowRoot))
619
+ return o;
620
+ if (p) {
621
+ const c = n.getComposedRanges(h ? r : { shadowRoots: [r] });
622
+ return (c == null ? void 0 : c[0]) ?? null;
623
623
  }
624
- if (r) {
625
- const t = c.getSelection();
626
- return t.rangeCount > 0 ? t.getRangeAt(0) : null;
624
+ if (l) {
625
+ const c = r.getSelection();
626
+ return c.rangeCount > 0 ? c.getRangeAt(0) : null;
627
627
  }
628
- return s;
629
- }, me = (e, o) => {
630
- var c;
628
+ return o;
629
+ }, ke = (e, n) => {
630
+ var r;
631
631
  if (!e.firstChild || e.firstChild.nodeType !== Node.TEXT_NODE)
632
632
  return { node: e, offset: 0 };
633
- const s = ((c = e.firstChild.textContent) == null ? void 0 : c.length) ?? 0;
634
- return { node: e.firstChild, offset: Math.min(o, s) };
635
- }, te = (e, o, s, c) => {
636
- const t = window.getSelection();
637
- if (!t)
633
+ const o = ((r = e.firstChild.textContent) == null ? void 0 : r.length) ?? 0;
634
+ return { node: e.firstChild, offset: Math.min(n, o) };
635
+ }, ie = (e, n, o, r) => {
636
+ const c = window.getSelection();
637
+ if (!c)
638
638
  return;
639
- const { node: a, offset: u } = me(e, o);
640
- if (!s)
641
- t.setBaseAndExtent(a, u, a, u);
639
+ const { node: d, offset: w } = ke(e, n);
640
+ if (!o)
641
+ c.setBaseAndExtent(d, w, d, w);
642
642
  else {
643
- const { node: x, offset: N } = me(s, c ?? 0);
644
- t.setBaseAndExtent(a, u, x, N);
643
+ const { node: O, offset: U } = ke(o, r ?? 0);
644
+ c.setBaseAndExtent(d, w, O, U);
645
645
  }
646
646
  q(() => {
647
647
  J();
648
648
  });
649
- }, re = (e, o) => {
650
- const s = h(), c = { id: s, type: "text", content: e };
651
- if (o) {
652
- const t = R.value.findIndex((a) => a.id === o);
653
- t !== -1 ? (W(
654
- R.value.slice(0, t + 1).concat(c).concat(R.value.slice(t + 1))
655
- ), A.commit(G(R.value))) : console.warn(`can not find item with id: ${o}`);
649
+ }, pe = (e, n) => {
650
+ const o = v(), r = { id: o, type: "text", content: e };
651
+ if (n) {
652
+ const c = E.value.findIndex((d) => d.id === n);
653
+ c !== -1 ? (W(
654
+ E.value.slice(0, c + 1).concat(r).concat(E.value.slice(c + 1))
655
+ ), N.commit(X(E.value))) : console.warn(`can not find item with id: ${n}`);
656
656
  } else
657
- W([c].concat(R.value)), A.commit(G(R.value));
657
+ W([r].concat(E.value)), N.commit(X(E.value));
658
658
  q(() => {
659
- var a;
660
- const t = (a = b.value) == null ? void 0 : a.querySelector(`[data-id="${s}"][data-type="text"]`);
661
- t && te(t, e.length);
662
- }), O.value = M(R.value);
663
- }, Q = K({
659
+ var d;
660
+ const c = (d = S.value) == null ? void 0 : d.querySelector(`[data-id="${o}"][data-type="text"]`);
661
+ c && ie(c, e.length);
662
+ }), D.value = j(E.value);
663
+ }, ae = A({
664
664
  hasStarted: !1,
665
665
  range: null
666
- }), Ke = (e) => {
667
- var x;
668
- const o = e;
666
+ }), He = (e) => {
667
+ var O;
668
+ const n = e;
669
669
  e.preventDefault();
670
- const { inputType: s } = o, c = (o.data || ((x = o.dataTransfer) == null ? void 0 : x.getData("text/plain")) || "").replace(y, "").replace(C, ""), t = o.getTargetRanges()[0];
671
- if (!t) {
672
- console.warn("range is null", t);
670
+ const { inputType: o } = n, r = (n.data || ((O = n.dataTransfer) == null ? void 0 : O.getData("text/plain")) || "").replace(g, "").replace(T, ""), c = n.getTargetRanges()[0];
671
+ if (!c) {
672
+ console.warn("range is null", c);
673
673
  return;
674
674
  }
675
- const a = [
675
+ const d = [
676
676
  "insertText",
677
677
  "insertFromPaste",
678
678
  "insertReplacementText",
@@ -683,330 +683,330 @@ const At = ["data-id", "data-type"], Ht = ["data-id", "data-type"], Vt = /* @__P
683
683
  "deleteSoftLineBackward",
684
684
  "deleteSoftLineForward",
685
685
  "deleteByCut"
686
- ], u = le(b.value);
687
- if (a.includes(s)) {
688
- if (c && fe(t.startContainer) && fe(t.endContainer)) {
689
- u && L.set(A.get(), X(u)), re(c);
686
+ ], w = te(S.value);
687
+ if (d.includes(o)) {
688
+ if (r && F(c.startContainer) && F(c.endContainer)) {
689
+ w && Q.set(N.get(), Y(w)), pe(r);
690
690
  return;
691
691
  }
692
- const N = X(t);
693
- N.startId && N.endId ? (u && L.set(A.get(), X(u)), we(N, s, c)) : console.warn("range is not valid, range:", N);
694
- } else s === "insertCompositionText" && Q.value.hasStarted && (Q.value = { hasStarted: !1, range: X(t) });
695
- }, X = (e) => {
696
- const o = ge(e.startContainer, b.value), s = ge(e.endContainer, b.value);
692
+ const U = Y(c);
693
+ U.startId && U.endId ? (w && Q.set(N.get(), Y(w)), Re(U, o, r)) : console.warn("range is not valid, range:", U);
694
+ } else o === "insertCompositionText" && ae.value.hasStarted && (ae.value = { hasStarted: !1, range: Y(c) });
695
+ }, Y = (e) => {
696
+ const n = be(e.startContainer, S.value), o = be(e.endContainer, S.value);
697
697
  return {
698
698
  collapsed: e.collapsed,
699
699
  endContainer: e.endContainer,
700
- endId: s == null ? void 0 : s.dataset.id,
701
- endEl: s,
700
+ endId: o == null ? void 0 : o.dataset.id,
701
+ endEl: o,
702
702
  endOffset: e.endOffset,
703
- endType: s == null ? void 0 : s.dataset.type,
703
+ endType: o == null ? void 0 : o.dataset.type,
704
704
  startContainer: e.startContainer,
705
- startId: o == null ? void 0 : o.dataset.id,
706
- startEl: o,
705
+ startId: n == null ? void 0 : n.dataset.id,
706
+ startEl: n,
707
707
  startOffset: e.startOffset,
708
- startType: o == null ? void 0 : o.dataset.type
708
+ startType: n == null ? void 0 : n.dataset.type
709
709
  };
710
- }, se = (e, o, s, c) => e.slice(0, s) + o + e.slice(c), we = (e, o, s) => {
711
- const c = Re(e);
712
- if (!Array.isArray(c) || c.length === 0)
710
+ }, he = (e, n, o, r) => e.slice(0, o) + n + e.slice(r), Re = (e, n, o) => {
711
+ const r = ue(e);
712
+ if (!Array.isArray(r) || r.length === 0)
713
713
  return;
714
- const t = Te(c, e, o, s);
715
- if (t.some((T) => T.tag === "new")) {
716
- const { afterId: T, content: $ } = t[0];
717
- re($, T);
714
+ const c = Te(r, e, n, o);
715
+ if (c.some(($) => $.tag === "new")) {
716
+ const { afterId: $, content: P } = c[0];
717
+ pe(P, $);
718
718
  return;
719
719
  }
720
- const a = t, u = [];
721
- for (const [T, $] of a.entries()) {
722
- const D = R.value.find((ue) => ue.id === $.id), Y = T === 0 ? s : "";
723
- D ? D.type === "text" ? D.content = se(D.content, Y, $.startOffset, $.endOffset) : D.type === "template" ? $.type === "prefix" || $.type === "suffix" ? $.startOffset === 0 && $.endOffset === 1 && Y.length === 0 ? D[$.type] = "" : console.warn(`${$.type} can not be inserted text. it only can be deleted`, $) : $.startOffset < 0 || $.endOffset > D.content.length ? u.push(D.id) : D.content = se(D.content, Y, $.startOffset, $.endOffset) : console.warn("dataItem.type is not text or template", D) : console.warn("can not find dataItem", $);
720
+ const d = c, w = [];
721
+ for (const [$, P] of d.entries()) {
722
+ const s = E.value.find((C) => C.id === P.id), u = $ === 0 ? o : "";
723
+ s ? s.type === "text" ? s.content = he(s.content, u, P.startOffset, P.endOffset) : s.type === "template" ? P.type === "prefix" || P.type === "suffix" ? P.startOffset === 0 && P.endOffset === 1 && u.length === 0 ? s[P.type] = "" : console.warn(`${P.type} can not be inserted text. it only can be deleted`, P) : P.startOffset < 0 || P.endOffset > s.content.length ? w.push(s.id) : s.content = he(s.content, u, P.startOffset, P.endOffset) : console.warn("dataItem.type is not text or template", s) : console.warn("can not find dataItem", P);
724
724
  }
725
- let x = R.value.filter((T) => !u.includes(T.id));
726
- x = x.filter((T) => !(T.type === "template" && [T.prefix, T.suffix, T.content].join("").length === 0));
727
- const N = /* @__PURE__ */ new Set();
728
- x.forEach((T, $, D) => {
729
- if (D.length >= 2) {
730
- if ($ === 0 || $ === 1) {
731
- const Y = D[0], ue = D[1];
732
- if (Y.type === "text" && Y.content.length === 0 && ue.type === "template")
725
+ let O = E.value.filter(($) => !w.includes($.id));
726
+ O = O.filter(($) => !($.type === "template" && [$.prefix, $.suffix, $.content].join("").length === 0));
727
+ const U = /* @__PURE__ */ new Set();
728
+ O.forEach(($, P, s) => {
729
+ if (s.length >= 2) {
730
+ if (P === 0 || P === 1) {
731
+ const u = s[0], C = s[1];
732
+ if (u.type === "text" && u.content.length === 0 && C.type === "template")
733
733
  return;
734
734
  }
735
- if ($ === D.length - 2 || $ === D.length - 1) {
736
- const Y = D[D.length - 1], ue = D[D.length - 2];
737
- if (Y.type === "text" && Y.content.length === 0 && ue.type === "template")
735
+ if (P === s.length - 2 || P === s.length - 1) {
736
+ const u = s[s.length - 1], C = s[s.length - 2];
737
+ if (u.type === "text" && u.content.length === 0 && C.type === "template")
738
738
  return;
739
739
  }
740
740
  }
741
- T.type === "text" && T.content.length === 0 && N.add(T.id);
742
- }), x = x.filter((T) => !N.has(T.id));
743
- for (const T of x.filter(($) => $.type === "template"))
744
- T.prefix.length === 0 && (T.prefix = y), T.suffix.length === 0 && (T.suffix = C);
745
- W(x), A.commit(G(R.value)), a.length > 0 && Ie(a, s), O.value = M(R.value), q(() => {
741
+ $.type === "text" && $.content.length === 0 && U.add($.id);
742
+ }), O = O.filter(($) => !U.has($.id));
743
+ for (const $ of O.filter((P) => P.type === "template"))
744
+ $.prefix.length === 0 && ($.prefix = g), $.suffix.length === 0 && ($.suffix = T);
745
+ W(O), N.commit(X(E.value)), d.length > 0 && Ve(d, o), D.value = j(E.value), q(() => {
746
746
  J();
747
747
  });
748
- }, Ie = (e, o) => {
749
- const s = e[0], c = `[data-id="${s.id}"][data-type="${s.type}"]`, t = e.slice(1).map((a) => `[data-id="${a.id}"][data-type="${a.type}"]`);
748
+ }, Ve = (e, n) => {
749
+ const o = e[0], r = `[data-id="${o.id}"][data-type="${o.type}"]`, c = e.slice(1).map((d) => `[data-id="${d.id}"][data-type="${d.type}"]`);
750
750
  q(() => {
751
- var u, x;
752
- const a = (u = b.value) == null ? void 0 : u.querySelector(c);
753
- if (a)
754
- te(a, s.startOffset + o.length);
755
- else if (o.length === 0)
756
- for (const N of t) {
757
- const T = (x = b.value) == null ? void 0 : x.querySelector(N);
758
- if (T) {
759
- te(T, 0);
751
+ var w, O;
752
+ const d = (w = S.value) == null ? void 0 : w.querySelector(r);
753
+ if (d)
754
+ ie(d, o.startOffset + n.length);
755
+ else if (n.length === 0)
756
+ for (const U of c) {
757
+ const $ = (O = S.value) == null ? void 0 : O.querySelector(U);
758
+ if ($) {
759
+ ie($, 0);
760
760
  break;
761
761
  }
762
762
  }
763
763
  else
764
- console.warn(`can not find el with selector: ${c}`);
764
+ console.warn(`can not find el with selector: ${r}`);
765
765
  });
766
- }, Re = (e) => {
767
- const o = w.value.findIndex((u) => u.id === e.startId && u.type === e.startType), s = w.value.findIndex((u) => u.id === e.endId && u.type === e.endType);
768
- if (o === -1 || s === -1 || o > s)
766
+ }, ue = (e) => {
767
+ const n = x.value.findIndex((w) => w.id === e.startId && w.type === e.startType), o = x.value.findIndex((w) => w.id === e.endId && w.type === e.endType);
768
+ if (n === -1 || o === -1 || n > o)
769
769
  return console.warn("startIndex or endIndex is -1, or startIndex > endIndex. ", { range: e }), null;
770
- const c = w.value[o], t = w.value[s];
771
- if (o === s)
770
+ const r = x.value[n], c = x.value[o];
771
+ if (n === o)
772
772
  return [
773
773
  {
774
- id: c.id,
775
- type: c.type,
774
+ id: r.id,
775
+ type: r.type,
776
776
  startOffset: e.startOffset,
777
777
  endOffset: e.endOffset
778
778
  }
779
779
  ];
780
- const a = [
780
+ const d = [
781
781
  {
782
- id: c.id,
783
- type: c.type,
782
+ id: r.id,
783
+ type: r.type,
784
784
  startOffset: e.startOffset,
785
- endOffset: c.content.length
785
+ endOffset: r.content.length
786
786
  }
787
787
  ];
788
- for (let u = o + 1; u < s; u++) {
789
- const x = w.value[u];
790
- a.push({
791
- id: x.id,
792
- type: x.type,
788
+ for (let w = n + 1; w < o; w++) {
789
+ const O = x.value[w];
790
+ d.push({
791
+ id: O.id,
792
+ type: O.type,
793
793
  startOffset: 0,
794
- endOffset: x.content.length
794
+ endOffset: O.content.length
795
795
  });
796
796
  }
797
- return a.push({
798
- id: t.id,
799
- type: t.type,
797
+ return d.push({
798
+ id: c.id,
799
+ type: c.type,
800
800
  startOffset: 0,
801
801
  endOffset: e.endOffset
802
- }), a;
803
- }, Te = (e, o, s, c) => {
804
- const t = e[0];
805
- if (t.type !== "prefix" && t.type !== "suffix")
802
+ }), d;
803
+ }, Te = (e, n, o, r) => {
804
+ const c = e[0];
805
+ if (c.type !== "prefix" && c.type !== "suffix")
806
806
  return e;
807
807
  if (e.length === 1) {
808
- if (o.collapsed)
809
- if (o.startOffset === 0) {
810
- const a = ae(t, c);
811
- return a ? [a] : [];
808
+ if (n.collapsed)
809
+ if (n.startOffset === 0) {
810
+ const d = ve(c, r);
811
+ return d ? [d] : [];
812
812
  } else {
813
- const a = be(t, c);
814
- return a ? [a] : [];
813
+ const d = ye(c, r);
814
+ return d ? [d] : [];
815
815
  }
816
- if (s.startsWith("insert"))
817
- if (p) {
818
- const a = ae(t, c);
819
- return a ? [a] : [];
816
+ if (o.startsWith("insert"))
817
+ if (h) {
818
+ const d = ve(c, r);
819
+ return d ? [d] : [];
820
820
  } else {
821
- const a = be(t, c);
822
- return a ? [a] : [];
821
+ const d = ye(c, r);
822
+ return d ? [d] : [];
823
823
  }
824
- if (s.startsWith("delete")) {
825
- if (s.includes("Backward")) {
826
- const a = ae(t, c, 1);
827
- return a ? [a] : [];
828
- } else if (s.includes("Forward")) {
829
- const a = be(t, c, 1);
830
- return a ? [a] : [];
824
+ if (o.startsWith("delete")) {
825
+ if (o.includes("Backward")) {
826
+ const d = ve(c, r, 1);
827
+ return d ? [d] : [];
828
+ } else if (o.includes("Forward")) {
829
+ const d = ye(c, r, 1);
830
+ return d ? [d] : [];
831
831
  }
832
832
  }
833
833
  }
834
- return c.length > 0 ? e.slice(1) : e;
835
- }, ae = (e, o, s = 0) => {
836
- const c = w.value.findIndex((t) => t.id === e.id && t.type === e.type);
837
- if (c > 0) {
838
- const t = w.value[c - 1], { id: a, type: u, content: x } = t;
839
- if (u === "text" || u === "template")
834
+ return r.length > 0 ? e.slice(1) : e;
835
+ }, ve = (e, n, o = 0) => {
836
+ const r = x.value.findIndex((c) => c.id === e.id && c.type === e.type);
837
+ if (r > 0) {
838
+ const c = x.value[r - 1], { id: d, type: w, content: O } = c;
839
+ if (w === "text" || w === "template")
840
840
  return {
841
- id: a,
842
- type: u,
843
- startOffset: x.length - s,
844
- endOffset: x.length
841
+ id: d,
842
+ type: w,
843
+ startOffset: O.length - o,
844
+ endOffset: O.length
845
845
  };
846
- if (o.length > 0)
847
- return { tag: "new", afterId: a, type: "text", content: o };
848
- if (console.warn("the previous item is not text or template", { current: e, previous: t }), s === 1)
846
+ if (n.length > 0)
847
+ return { tag: "new", afterId: d, type: "text", content: n };
848
+ if (console.warn("the previous item is not text or template", { current: e, previous: c }), o === 1)
849
849
  return { ...e, endOffset: e.startOffset };
850
- } else return o.length > 0 ? { tag: "new", type: "text", content: o } : (console.warn("the previous item of current is not found", { current: e }), null);
850
+ } else return n.length > 0 ? { tag: "new", type: "text", content: n } : (console.warn("the previous item of current is not found", { current: e }), null);
851
851
  return e;
852
- }, be = (e, o, s = 0) => {
853
- const c = w.value.findIndex((t) => t.id === e.id && t.type === e.type);
854
- if (c < w.value.length - 1) {
855
- const t = w.value[c + 1], { id: a, type: u } = t;
856
- if (u === "text" || u === "template")
852
+ }, ye = (e, n, o = 0) => {
853
+ const r = x.value.findIndex((c) => c.id === e.id && c.type === e.type);
854
+ if (r < x.value.length - 1) {
855
+ const c = x.value[r + 1], { id: d, type: w } = c;
856
+ if (w === "text" || w === "template")
857
857
  return {
858
- id: a,
859
- type: u,
858
+ id: d,
859
+ type: w,
860
860
  startOffset: 0,
861
- endOffset: 0 + s
861
+ endOffset: 0 + o
862
862
  };
863
- if (o.length > 0)
864
- return { tag: "new", afterId: e.id, type: "text", content: o };
865
- if (console.warn("the next item is not text or template", { current: e, next: t }), s === 1)
863
+ if (n.length > 0)
864
+ return { tag: "new", afterId: e.id, type: "text", content: n };
865
+ if (console.warn("the next item is not text or template", { current: e, next: c }), o === 1)
866
866
  return { ...e, startOffset: e.endOffset };
867
- } else return o.length > 0 ? { tag: "new", afterId: e.id, type: "text", content: o } : (console.warn("the next item of current is not found", { current: e }), null);
867
+ } else return n.length > 0 ? { tag: "new", afterId: e.id, type: "text", content: n } : (console.warn("the next item of current is not found", { current: e }), null);
868
868
  return e;
869
- }, pe = () => {
870
- Q.value = { hasStarted: !0, range: null };
871
- }, Ae = (e) => {
872
- const o = Q.value.range;
873
- o ? (e.data && fe(o.startContainer) && fe(o.endContainer) ? (L.set(A.get(), X(o)), re(e.data)) : o.startId && o.endId ? (L.set(A.get(), X(o)), we(o, "insertCompositionText", e.data)) : console.warn("range is not valid, range:", o), H.value++, q(() => {
869
+ }, Ee = () => {
870
+ ae.value = { hasStarted: !0, range: null };
871
+ }, ge = (e) => {
872
+ const n = ae.value.range;
873
+ n ? (e.data && F(n.startContainer) && F(n.endContainer) ? (Q.set(N.get(), Y(n)), pe(e.data)) : n.startId && n.endId ? (Q.set(N.get(), Y(n)), Re(n, "insertCompositionText", e.data)) : console.warn("range is not valid, range:", n), _.value++, q(() => {
874
874
  J();
875
- })) : console.warn("range is null, compositionEnd:", e), Q.value = { hasStarted: !1, range: null };
876
- }, he = (() => {
875
+ })) : console.warn("range is null, compositionEnd:", e), ae.value = { hasStarted: !1, range: null };
876
+ }, le = (() => {
877
877
  const e = navigator.userAgent.toLowerCase();
878
878
  return /macintosh|mac os x|iphone|ipad|ipod/.test(e);
879
- })(), He = (e) => {
880
- const o = he && e.metaKey && !e.shiftKey && e.key.toLowerCase() === "z" || // Cmd+Z
881
- !he && e.ctrlKey && !e.shiftKey && e.key.toLowerCase() === "z", s = he && e.metaKey && e.shiftKey && e.key.toLowerCase() === "z" || // Cmd+Shift+z
882
- !he && e.ctrlKey && (e.key.toLowerCase() === "y" || e.shiftKey && e.key.toLowerCase() === "z"), c = e.key.toLowerCase() === "enter";
883
- if (o) {
879
+ })(), Fe = (e) => {
880
+ const n = le && e.metaKey && !e.shiftKey && e.key.toLowerCase() === "z" || // Cmd+Z
881
+ !le && e.ctrlKey && !e.shiftKey && e.key.toLowerCase() === "z", o = le && e.metaKey && e.shiftKey && e.key.toLowerCase() === "z" || // Cmd+Shift+z
882
+ !le && e.ctrlKey && (e.key.toLowerCase() === "y" || e.shiftKey && e.key.toLowerCase() === "z"), r = e.key.toLowerCase() === "enter";
883
+ if (n) {
884
884
  e.preventDefault();
885
- const t = le(b.value);
886
- t && L.set(A.get(), X(t));
887
- const a = A.undo();
888
- a && Ee(a);
885
+ const c = te(S.value);
886
+ c && Q.set(N.get(), Y(c));
887
+ const d = N.undo();
888
+ d && Oe(d);
889
889
  }
890
- if (s) {
890
+ if (o) {
891
891
  e.preventDefault();
892
- const t = A.redo();
893
- t && Ee(t);
892
+ const c = N.redo();
893
+ c && Oe(c);
894
894
  }
895
- c && (e.preventDefault(), V("submit"));
896
- }, Ee = (e) => {
897
- const { data: o } = ke(e);
898
- if (W(o), L.has(e)) {
899
- const s = L.get(e);
895
+ r && (e.preventDefault(), H("submit"));
896
+ }, Oe = (e) => {
897
+ const { data: n } = Ie(e);
898
+ if (W(n), Q.has(e)) {
899
+ const o = Q.get(e);
900
900
  q(() => {
901
- const c = b.value.querySelector(`[data-id="${s.startId}"][data-type="${s.startType}"]`), t = b.value.querySelector(`[data-id="${s.endId}"][data-type="${s.endType}"]`);
902
- c && te(c, s.startOffset, t, s.endOffset);
901
+ const r = S.value.querySelector(`[data-id="${o.startId}"][data-type="${o.startType}"]`), c = S.value.querySelector(`[data-id="${o.endId}"][data-type="${o.endType}"]`);
902
+ r && ie(r, o.startOffset, c, o.endOffset);
903
903
  });
904
904
  }
905
- O.value = M(R.value);
906
- }, ce = (e, o) => {
907
- var t, a;
908
- const s = (t = b.value) == null ? void 0 : t.querySelector(`[data-id="${e}"][data-type="${o}"]`);
909
- if (!s) return;
910
- const c = ((a = s.textContent) == null ? void 0 : a.length) || 0;
911
- te(s, c);
912
- }, Ve = () => {
913
- b.value && q(() => {
914
- const e = R.value, o = e.find((c) => c.type === "template");
915
- o && ce(o.id, "template"), e.every((c) => c.type === "text") && e.length === 1 && ce(e[0].id, "text");
905
+ D.value = j(E.value);
906
+ }, $e = (e, n) => {
907
+ var c, d;
908
+ const o = (c = S.value) == null ? void 0 : c.querySelector(`[data-id="${e}"][data-type="${n}"]`);
909
+ if (!o) return;
910
+ const r = ((d = o.textContent) == null ? void 0 : d.length) || 0;
911
+ ie(o, r);
912
+ }, Be = () => {
913
+ S.value && q(() => {
914
+ const e = E.value, n = e.find((r) => r.type === "template");
915
+ n && $e(n.id, "template"), e.every((r) => r.type === "text") && e.length === 1 && $e(e[0].id, "text");
916
916
  });
917
- }, Fe = () => {
918
- A.clear(), L.clear();
919
- }, Oe = () => {
920
- if (!b.value || Q.value.range)
917
+ }, Me = () => {
918
+ N.clear(), Q.clear();
919
+ }, de = () => {
920
+ if (!S.value || ae.value.range)
921
921
  return;
922
- const e = le(b.value);
923
- if (e != null && e.collapsed && S.value.length > 0) {
924
- const o = X(e), s = S.value[0];
925
- if (o.startEl && o.startId === s.id && o.startOffset === 0 && s.content === v && s.type === "text") {
926
- te(o.startEl, 1);
922
+ const e = te(S.value);
923
+ if (e != null && e.collapsed && b.value.length > 0) {
924
+ const n = Y(e), o = b.value[0];
925
+ if (n.startEl && n.startId === o.id && n.startOffset === 0 && o.content === y && o.type === "text") {
926
+ ie(n.startEl, 1);
927
927
  return;
928
928
  }
929
- const c = S.value[S.value.length - 1];
930
- if (o.endEl && o.endId === c.id && o.endOffset === 1 && c.content === v && c.type === "text") {
931
- te(o.endEl, 0);
929
+ const r = b.value[b.value.length - 1];
930
+ if (n.endEl && n.endId === r.id && n.endOffset === 1 && r.content === y && r.type === "text") {
931
+ ie(n.endEl, 0);
932
932
  return;
933
933
  }
934
934
  }
935
935
  };
936
- return pt(() => {
937
- document.addEventListener("selectionchange", Oe), q(() => {
938
- j();
936
+ return bt(() => {
937
+ document.addEventListener("selectionchange", de), q(() => {
938
+ Z();
939
939
  });
940
- }), tt(() => {
941
- document.removeEventListener("selectionchange", Oe);
940
+ }), st(() => {
941
+ document.removeEventListener("selectionchange", de);
942
942
  }), i({
943
- clearHistory: Fe,
944
- activateFirstField: Ve
945
- }), (e, o) => (m(), I("div", Pt, [
946
- (m(), I("div", {
943
+ clearHistory: Me,
944
+ activateFirstField: Be
945
+ }), (e, n) => (m(), R("div", Jt, [
946
+ (m(), R("div", {
947
947
  contenteditable: "true",
948
948
  ref_key: "editorRef",
949
- ref: b,
950
- key: H.value,
949
+ ref: S,
950
+ key: _.value,
951
951
  class: "editor",
952
- style: Ue(B.value),
953
- onBeforeinput: Ke,
954
- onCompositionstart: pe,
955
- onCompositionend: Ae,
956
- onKeydown: He
952
+ style: Ae(K.value),
953
+ onBeforeinput: He,
954
+ onCompositionstart: Ee,
955
+ onCompositionend: ge,
956
+ onKeydown: Fe
957
957
  }, [
958
- (m(!0), I(ye, null, xe(d.value, (s) => (m(), ee(Ft, Se({
959
- key: `${s.id}-${s.type}`
960
- }, { ref_for: !0 }, s), null, 16))), 128))
958
+ (m(!0), R(we, null, xe(f.value, (o) => (m(), oe(jt, Se({
959
+ key: `${o.id}-${o.type}`
960
+ }, { ref_for: !0 }, o), null, 16))), 128))
961
961
  ], 36))
962
962
  ]));
963
963
  }
964
- }), Nt = /* @__PURE__ */ _e(Wt, [["__scopeId", "data-v-b5c1a845"]]), nt = (n, i) => {
964
+ }), Zt = /* @__PURE__ */ _e(Yt, [["__scopeId", "data-v-b5c1a845"]]), it = (t, i) => {
965
965
  if (!i.length)
966
- return [{ text: n, isMatch: !1 }];
967
- const l = [];
968
- for (const p of i) {
969
- if (!p) continue;
970
- let h = 0;
971
- const v = n.toLowerCase(), y = p.toLowerCase();
966
+ return [{ text: t, isMatch: !1 }];
967
+ const a = [];
968
+ for (const h of i) {
969
+ if (!h) continue;
970
+ let v = 0;
971
+ const y = t.toLowerCase(), g = h.toLowerCase();
972
972
  for (; ; ) {
973
- const C = v.indexOf(y, h);
974
- if (C === -1) break;
975
- l.push({
976
- start: C,
977
- end: C + p.length
978
- }), h = C + 1;
973
+ const T = y.indexOf(g, v);
974
+ if (T === -1) break;
975
+ a.push({
976
+ start: T,
977
+ end: T + h.length
978
+ }), v = T + 1;
979
979
  }
980
980
  }
981
- if (l.length === 0)
982
- return [{ text: n, isMatch: !1 }];
983
- l.sort((p, h) => p.start - h.start);
984
- const r = [];
985
- for (const p of l)
986
- if (r.length === 0)
987
- r.push(p);
981
+ if (a.length === 0)
982
+ return [{ text: t, isMatch: !1 }];
983
+ a.sort((h, v) => h.start - v.start);
984
+ const l = [];
985
+ for (const h of a)
986
+ if (l.length === 0)
987
+ l.push(h);
988
988
  else {
989
- const h = r[r.length - 1];
990
- p.start <= h.end ? h.end = Math.max(h.end, p.end) : r.push(p);
989
+ const v = l[l.length - 1];
990
+ h.start <= v.end ? v.end = Math.max(v.end, h.end) : l.push(h);
991
991
  }
992
- const f = [];
993
- let _ = 0;
994
- for (const p of r)
995
- _ < p.start && f.push({
996
- text: n.substring(_, p.start),
992
+ const p = [];
993
+ let I = 0;
994
+ for (const h of l)
995
+ I < h.start && p.push({
996
+ text: t.substring(I, h.start),
997
997
  isMatch: !1
998
- }), f.push({
999
- text: n.substring(p.start, p.end),
998
+ }), p.push({
999
+ text: t.substring(h.start, h.end),
1000
1000
  isMatch: !0
1001
- }), _ = p.end;
1002
- return _ < n.length && f.push({
1003
- text: n.substring(_),
1001
+ }), I = h.end;
1002
+ return I < t.length && p.push({
1003
+ text: t.substring(I),
1004
1004
  isMatch: !1
1005
- }), f;
1006
- }, zt = (n, i) => !i || !n ? [{ text: n, isMatch: !1 }] : nt(n, [i]), Ut = (n, i) => {
1007
- const { content: l, highlights: r } = n;
1008
- return typeof r == "function" ? r(l, i) : Array.isArray(r) ? nt(l, r) : zt(l, i);
1009
- }, Gt = ["onMouseenter", "onMousedown"], qt = { class: "suggestion-list__text" }, jt = /* @__PURE__ */ Ce({
1005
+ }), p;
1006
+ }, Qt = (t, i) => !i || !t ? [{ text: t, isMatch: !1 }] : it(t, [i]), en = (t, i) => {
1007
+ const { content: a, highlights: l } = t;
1008
+ return typeof l == "function" ? l(a, i) : Array.isArray(l) ? it(a, l) : Qt(a, i);
1009
+ }, tn = ["onMouseenter", "onMousedown"], nn = { class: "suggestion-list__text" }, on = /* @__PURE__ */ Ce({
1010
1010
  __name: "SuggestionList",
1011
1011
  props: {
1012
1012
  show: { type: Boolean },
@@ -1017,85 +1017,82 @@ const At = ["data-id", "data-type"], Ht = ["data-id", "data-type"], Vt = /* @__P
1017
1017
  inputValue: {}
1018
1018
  },
1019
1019
  emits: ["select", "mouse-enter", "mouse-leave"],
1020
- setup(n, { emit: i }) {
1021
- const l = n, r = i, f = K(null), _ = (y) => y === l.activeKeyboardIndex || y === l.activeMouseIndex, p = (y) => {
1022
- r("mouse-enter", y);
1023
- }, h = () => {
1024
- r("mouse-leave");
1025
- }, v = (y) => {
1026
- r("select", y);
1020
+ setup(t, { emit: i }) {
1021
+ const a = t, l = i, p = A(null), I = (g) => g === a.activeKeyboardIndex || g === a.activeMouseIndex, h = (g) => {
1022
+ l("mouse-enter", g);
1023
+ }, v = () => {
1024
+ l("mouse-leave");
1025
+ }, y = (g) => {
1026
+ l("select", g);
1027
1027
  };
1028
1028
  return ne(
1029
- () => l.activeKeyboardIndex,
1030
- (y) => {
1031
- if (y !== -1 && f.value) {
1032
- const C = f.value.children[y];
1033
- C && C.scrollIntoView({ block: "nearest" });
1029
+ () => a.activeKeyboardIndex,
1030
+ (g) => {
1031
+ if (g !== -1 && p.value) {
1032
+ const T = p.value.children[g];
1033
+ T && T.scrollIntoView({ block: "nearest" });
1034
1034
  }
1035
1035
  }
1036
- ), (y, C) => (m(), ee(ze, { name: "tiny-sender-slide-up" }, {
1037
- default: ve(() => [
1038
- l.show && l.suggestions.length ? (m(), I("div", {
1036
+ ), (g, T) => (m(), oe(qe, { name: "tiny-sender-slide-up" }, {
1037
+ default: me(() => [
1038
+ a.show && a.suggestions.length ? (m(), R("div", {
1039
1039
  key: 0,
1040
1040
  ref_key: "suggestionsListRef",
1041
- ref: f,
1041
+ ref: p,
1042
1042
  class: "suggestion-list",
1043
- style: Ue(l.popupStyle)
1043
+ style: Ae(a.popupStyle)
1044
1044
  }, [
1045
- (m(!0), I(ye, null, xe(l.suggestions, (g, O) => (m(), I("div", {
1046
- key: O,
1047
- class: oe(["suggestion-list__item", { highlighted: _(O) }]),
1048
- onMouseenter: (V) => p(O),
1049
- onMouseleave: h,
1050
- onMousedown: ht((V) => v(g.content), ["prevent"])
1045
+ (m(!0), R(we, null, xe(a.suggestions, (L, D) => (m(), R("div", {
1046
+ key: D,
1047
+ class: se(["suggestion-list__item", { highlighted: I(D) }]),
1048
+ onMouseenter: (H) => h(D),
1049
+ onMouseleave: v,
1050
+ onMousedown: St((H) => y(L.content), ["prevent"])
1051
1051
  }, [
1052
- Z(k(kt), { class: "suggestion-list__icon" }),
1053
- U("span", qt, [
1054
- (m(!0), I(ye, null, xe(k(Ut)(g, l.inputValue), (V, H) => (m(), I("span", {
1055
- key: H,
1056
- class: oe({
1057
- "suggestion-list__text--match": V.isMatch,
1058
- "suggestion-list__text--normal": !V.isMatch
1052
+ ee(k(Dt), { class: "suggestion-list__icon" }),
1053
+ G("span", nn, [
1054
+ (m(!0), R(we, null, xe(k(en)(L, a.inputValue), (H, _) => (m(), R("span", {
1055
+ key: _,
1056
+ class: se({
1057
+ "suggestion-list__text--match": H.isMatch,
1058
+ "suggestion-list__text--normal": !H.isMatch
1059
1059
  })
1060
- }, de(V.text), 3))), 128))
1060
+ }, fe(H.text), 3))), 128))
1061
1061
  ])
1062
- ], 42, Gt))), 128))
1063
- ], 4)) : P("", !0)
1062
+ ], 42, tn))), 128))
1063
+ ], 4)) : M("", !0)
1064
1064
  ]),
1065
1065
  _: 1
1066
1066
  }));
1067
1067
  }
1068
- }), Jt = /* @__PURE__ */ _e(jt, [["__scopeId", "data-v-e0ec9fe3"]]), Xt = ["data-theme"], Yt = { class: "tiny-sender__container" }, Zt = {
1068
+ }), sn = /* @__PURE__ */ _e(on, [["__scopeId", "data-v-e0ec9fe3"]]), an = ["data-theme"], ln = { class: "tiny-sender__container" }, rn = {
1069
1069
  key: 0,
1070
1070
  class: "tiny-sender__header-slot"
1071
- }, Qt = {
1071
+ }, cn = {
1072
1072
  key: 0,
1073
1073
  class: "tiny-sender__prefix-slot"
1074
- }, en = { class: "tiny-sender__content-area" }, tn = {
1074
+ }, un = { class: "tiny-sender__content-area" }, dn = {
1075
1075
  key: 0,
1076
1076
  class: "tiny-sender__decorative-content"
1077
- }, nn = {
1078
- key: 2,
1079
- class: "tiny-sender__input-field-wrapper"
1080
- }, on = {
1081
- key: 0,
1077
+ }, fn = {
1078
+ key: 1,
1082
1079
  class: "tiny-sender__completion-placeholder"
1083
- }, sn = { class: "user-input-mirror" }, an = {
1080
+ }, pn = { class: "user-input-mirror" }, hn = {
1084
1081
  key: 0,
1085
1082
  class: "tiny-sender__tab-hint"
1086
- }, ln = {
1083
+ }, vn = {
1087
1084
  key: 1,
1088
1085
  class: "tiny-sender__actions-slot"
1089
- }, rn = {
1086
+ }, yn = {
1090
1087
  key: 0,
1091
1088
  class: "tiny-sender__footer-slot tiny-sender__bottom-row"
1092
- }, cn = { class: "tiny-sender__footer-left" }, un = { class: "tiny-sender__footer-right" }, dn = { class: "real-word-length" }, fn = {
1089
+ }, gn = { class: "tiny-sender__footer-left" }, mn = { class: "tiny-sender__footer-right" }, wn = { class: "real-word-length" }, bn = {
1093
1090
  key: 1,
1094
1091
  class: "tiny-sender__toolbar"
1095
- }, pn = { class: "tiny-sender__buttons-container" }, hn = {
1092
+ }, Sn = { class: "tiny-sender__buttons-container" }, xn = {
1096
1093
  key: 1,
1097
1094
  class: "tiny-sender__footer-slot"
1098
- }, vn = /* @__PURE__ */ Ce({
1095
+ }, Cn = /* @__PURE__ */ Ce({
1099
1096
  __name: "index",
1100
1097
  props: {
1101
1098
  autofocus: { type: Boolean, default: !1 },
@@ -1122,379 +1119,420 @@ const At = ["data-id", "data-type"], Ht = ["data-id", "data-type"], Vt = /* @__P
1122
1119
  stopText: { default: "" }
1123
1120
  },
1124
1121
  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"],
1125
- setup(n, { expose: i, emit: l }) {
1126
- const r = n, f = l, _ = K(null), p = K(null), h = K(null), v = K(null), y = K(null), C = E(() => r.templateData && r.templateData.length > 0), { inputValue: g, isComposing: O, clearInput: V } = Rt(r, f), H = E(() => !!g.value.trim()), F = E(() => {
1127
- var t, a;
1128
- return !(r.disabled || r.loading || !H.value || ae.value || (a = (t = r.buttonGroup) == null ? void 0 : t.submit) != null && a.disabled);
1122
+ setup(t, { expose: i, emit: a }) {
1123
+ const l = t, p = a, I = A(null), h = A(null), v = A(null), y = A(null), g = A(null), T = A(null), L = A(0);
1124
+ let D = null;
1125
+ const H = B(() => l.templateData && l.templateData.length > 0), { inputValue: _, isComposing: V, clearInput: j } = Kt(l, p), E = B(() => !!_.value.trim()), W = B(() => {
1126
+ var s, u;
1127
+ return !(l.disabled || l.loading || !E.value || ge.value || (u = (s = l.buttonGroup) == null ? void 0 : s.submit) != null && u.disabled);
1129
1128
  }), {
1130
- isPopupVisible: M,
1131
- activeSuggestion: R,
1132
- activeKeyboardIndex: W,
1129
+ isPopupVisible: b,
1130
+ activeSuggestion: x,
1131
+ activeKeyboardIndex: f,
1133
1132
  activeMouseIndex: S,
1134
- autoCompleteText: w,
1135
- showTabIndicator: d,
1136
- syncAutoComplete: b,
1137
- closePopup: z,
1138
- applySuggestion: j,
1139
- confirmSelection: B,
1140
- navigateWithKeyboard: J,
1141
- handleMouseEnter: G,
1142
- handleMouseLeave: ke
1143
- } = Ot(
1144
- E(() => r.suggestions),
1145
- g,
1146
- O,
1147
- C,
1148
- (t) => f("update:modelValue", t),
1149
- (t) => f("suggestion-select", t)
1150
- ), L = K(r.mode), A = K(!1), ge = () => {
1151
- L.value === "single" && (L.value = "multiple", q(() => {
1133
+ autoCompleteText: z,
1134
+ showTabIndicator: Z,
1135
+ syncAutoComplete: K,
1136
+ closePopup: J,
1137
+ applySuggestion: X,
1138
+ confirmSelection: Ie,
1139
+ navigateWithKeyboard: Q,
1140
+ handleMouseEnter: N,
1141
+ handleMouseLeave: be
1142
+ } = Vt(
1143
+ B(() => l.suggestions),
1144
+ _,
1145
+ V,
1146
+ H,
1147
+ (s) => p("update:modelValue", s),
1148
+ (s) => p("suggestion-select", s)
1149
+ ), F = A(l.mode), te = A(!1), ke = () => {
1150
+ F.value === "single" && (F.value = "multiple", q(() => {
1152
1151
  setTimeout(() => {
1153
- const t = document.querySelector(".tiny-textarea__inner");
1154
- if (t) {
1155
- t.style.whiteSpace = "pre-wrap";
1156
- const a = g.value.length;
1157
- t.focus(), t.setSelectionRange(a, a);
1152
+ const s = document.querySelector(".tiny-textarea__inner");
1153
+ if (s) {
1154
+ s.style.whiteSpace = "pre-wrap";
1155
+ const u = _.value.length;
1156
+ s.focus(), s.setSelectionRange(u, u);
1158
1157
  }
1159
1158
  }, 50);
1160
1159
  }));
1161
- }, fe = (t, a) => {
1162
- const u = document.createElement("span");
1163
- u.style.visibility = "hidden", u.style.position = "absolute", u.style.whiteSpace = "nowrap", u.style.font = a, u.textContent = t, document.body.appendChild(u);
1164
- const x = u.offsetWidth;
1165
- return document.body.removeChild(u), x;
1166
- }, le = () => {
1167
- var $e, je, Je;
1168
- if (r.mode !== "single" || !_.value || A.value || !p.value || !v.value) return;
1169
- const t = p.value.querySelector(".tiny-sender__content-area");
1170
- if (!t) return;
1171
- const a = ((je = ($e = _.value) == null ? void 0 : $e.querySelector) == null ? void 0 : je.call($e, ".tiny-input__inner")) || t.querySelector(".tiny-input__inner"), u = y.value || p.value.querySelector(".tiny-sender__buttons-container");
1172
- if (!a) {
1160
+ }, ie = (s, u) => {
1161
+ const C = document.createElement("span");
1162
+ C.style.visibility = "hidden", C.style.position = "absolute", C.style.whiteSpace = "nowrap", C.style.font = u, C.textContent = s, document.body.appendChild(C);
1163
+ const re = C.offsetWidth;
1164
+ return document.body.removeChild(C), re;
1165
+ }, pe = () => {
1166
+ var Le, Ye, Ze;
1167
+ if (l.mode !== "single" || !I.value || te.value || !h.value || !y.value) return;
1168
+ const s = h.value.querySelector(".tiny-sender__content-area");
1169
+ if (!s) return;
1170
+ const u = ((Ye = (Le = I.value) == null ? void 0 : Le.querySelector) == null ? void 0 : Ye.call(Le, ".tiny-input__inner")) || s.querySelector(".tiny-input__inner"), C = T.value || h.value.querySelector(".tiny-sender__buttons-container");
1171
+ if (!u) {
1173
1172
  console.warn("Cannot find input element for overflow check");
1174
1173
  return;
1175
1174
  }
1176
- const x = a.getBoundingClientRect(), N = u == null ? void 0 : u.getBoundingClientRect();
1177
- if (x.width === 0) {
1178
- setTimeout(() => le(), 50);
1175
+ const re = u.getBoundingClientRect(), We = C == null ? void 0 : C.getBoundingClientRect();
1176
+ if (re.width === 0) {
1177
+ setTimeout(() => pe(), 50);
1179
1178
  return;
1180
1179
  }
1181
- const T = window.getComputedStyle(a).font, $ = fe(g.value, T), D = (Je = p.value) == null ? void 0 : Je.classList.contains("tr-sender-compact"), Y = D ? 12 : 20, ue = x.width, ot = (N == null ? void 0 : N.width) || 0, qe = ue - ot - Y, st = D ? 50 : 80;
1182
- $ > qe && qe > st && L.value === "single" && (A.value = !0, L.value = "multiple", q(() => {
1183
- _.value ? setTimeout(() => {
1184
- var Xe;
1185
- const Be = (Xe = p.value) == null ? void 0 : Xe.querySelector(".tiny-textarea__inner");
1186
- if (Be) {
1187
- Be.style.whiteSpace = "pre-wrap";
1188
- const Ye = g.value.length;
1189
- Be.focus(), Be.setSelectionRange(Ye, Ye);
1180
+ const at = window.getComputedStyle(u).font, lt = ie(_.value, at), Je = (Ze = h.value) == null ? void 0 : Ze.classList.contains("tr-sender-compact"), rt = Je ? 12 : 20, ct = re.width, ut = (We == null ? void 0 : We.width) || 0, Xe = ct - ut - rt, dt = Je ? 50 : 80;
1181
+ lt > Xe && Xe > dt && F.value === "single" && (te.value = !0, F.value = "multiple", q(() => {
1182
+ I.value ? setTimeout(() => {
1183
+ var Qe;
1184
+ const De = (Qe = h.value) == null ? void 0 : Qe.querySelector(".tiny-textarea__inner");
1185
+ if (De) {
1186
+ De.style.whiteSpace = "pre-wrap";
1187
+ const et = _.value.length;
1188
+ De.focus(), De.setSelectionRange(et, et);
1190
1189
  }
1191
- A.value = !1;
1192
- }, 300) : A.value = !1;
1190
+ te.value = !1;
1191
+ }, 300) : te.value = !1;
1193
1192
  }));
1194
- }, me = () => {
1195
- if (C.value && h.value)
1196
- o();
1197
- else if (_.value)
1198
- _.value.focus();
1193
+ }, ae = () => {
1194
+ if (H.value && v.value)
1195
+ U();
1196
+ else if (I.value)
1197
+ I.value.focus();
1199
1198
  else {
1200
- const t = document.querySelector(".tiny-input__inner");
1201
- t == null || t.focus();
1199
+ const s = document.querySelector(".tiny-input__inner");
1200
+ s == null || s.focus();
1202
1201
  }
1203
- }, te = () => {
1204
- if (_.value)
1205
- _.value.blur();
1202
+ }, He = () => {
1203
+ if (I.value)
1204
+ I.value.blur();
1206
1205
  else {
1207
- const t = document.querySelector(".tiny-input__inner");
1208
- t == null || t.blur();
1206
+ const s = document.querySelector(".tiny-input__inner");
1207
+ s == null || s.blur();
1209
1208
  }
1210
- }, re = () => {
1211
- var t;
1212
- f("update:templateData", []), (t = h.value) == null || t.clearHistory(), q(() => {
1213
- g.value === "" && (L.value = r.mode || "single"), setTimeout(() => {
1214
- me();
1209
+ }, Y = () => {
1210
+ var s;
1211
+ p("update:templateData", []), (s = v.value) == null || s.clearHistory(), q(() => {
1212
+ _.value === "" && (F.value = l.mode || "single"), setTimeout(() => {
1213
+ ae();
1215
1214
  }, 50);
1216
1215
  });
1217
- }, Q = () => {
1218
- var t;
1219
- V(), C.value ? re() : (t = p.value) == null || t.focus(), q(() => {
1220
- g.value === "" && (L.value = r.mode || "single");
1216
+ }, he = () => {
1217
+ var s;
1218
+ j(), H.value ? Y() : (s = h.value) == null || s.focus(), q(() => {
1219
+ _.value === "" && (F.value = l.mode || "single");
1221
1220
  });
1222
- }, Ke = (t) => {
1223
- const a = (x) => x.type === "text" && x.content === "​";
1224
- if (t.length === 0 || t.every(a)) {
1225
- re();
1221
+ }, Re = (s) => {
1222
+ const u = (re) => re.type === "text" && re.content === "​";
1223
+ if (s.length === 0 || s.every(u)) {
1224
+ Y();
1226
1225
  return;
1227
1226
  }
1228
- f("update:templateData", t);
1227
+ p("update:templateData", s);
1229
1228
  };
1230
1229
  ne(
1231
- () => r.templateData,
1230
+ () => l.templateData,
1232
1231
  () => {
1233
- g.value = r.templateData.map((t) => t.content).join("");
1232
+ _.value = l.templateData.map((s) => s.content).join("");
1234
1233
  },
1235
1234
  { deep: !0 }
1236
1235
  );
1237
- const X = E(() => {
1238
- const t = typeof r.speech == "object" ? r.speech : {};
1236
+ const Ve = B(() => {
1237
+ const s = typeof l.speech == "object" ? l.speech : {};
1239
1238
  return {
1240
- ...t,
1241
- onStart: () => f("speech-start"),
1242
- onEnd: (a) => f("speech-end", a),
1243
- onInterim: (a) => f("speech-interim", a),
1244
- onFinal: (a) => {
1245
- if (t.autoReplace)
1246
- g.value = a;
1239
+ ...s,
1240
+ onStart: () => p("speech-start"),
1241
+ onEnd: (u) => p("speech-end", u),
1242
+ onInterim: (u) => p("speech-interim", u),
1243
+ onFinal: (u) => {
1244
+ if (s.autoReplace)
1245
+ _.value = u;
1247
1246
  else {
1248
- const u = g.value;
1249
- u && a && !u.endsWith(" ") && !a.startsWith(" ") && u.length > 0 ? g.value = u + " " + a : g.value = u + a;
1247
+ const C = _.value;
1248
+ C && u && !C.endsWith(" ") && !u.startsWith(" ") && C.length > 0 ? _.value = C + " " + u : _.value = C + u;
1250
1249
  }
1251
- f("speech-end", a);
1250
+ p("speech-end", u);
1252
1251
  },
1253
- onError: (a) => {
1254
- f("speech-error", a);
1252
+ onError: (u) => {
1253
+ p("speech-error", u);
1255
1254
  }
1256
1255
  };
1257
- }), { speechState: se, start: we, stop: Ie } = Et(X.value), Re = () => {
1258
- se.isRecording ? Ie() : we();
1259
- }, Te = async () => {
1260
- const t = typeof r.speech == "object" ? r.speech : {}, a = se.isRecording;
1261
- if (t.onVoiceButtonClick) {
1262
- let u = !1;
1256
+ }), { speechState: ue, start: Te, stop: ve } = Ht(Ve.value), ye = () => {
1257
+ ue.isRecording ? ve() : Te();
1258
+ }, Ee = async () => {
1259
+ const s = typeof l.speech == "object" ? l.speech : {}, u = ue.isRecording;
1260
+ if (s.onVoiceButtonClick) {
1261
+ let C = !1;
1263
1262
  try {
1264
- await t.onVoiceButtonClick(a, () => {
1265
- u = !0;
1263
+ await s.onVoiceButtonClick(u, () => {
1264
+ C = !0;
1266
1265
  });
1267
- } catch (x) {
1268
- console.error("语音按钮点击拦截器执行失败:", x);
1266
+ } catch (re) {
1267
+ console.error("语音按钮点击拦截器执行失败:", re);
1269
1268
  }
1270
- if (u)
1269
+ if (C)
1271
1270
  return;
1272
1271
  }
1273
- Re();
1274
- }, ae = E(() => r.maxLength !== 1 / 0 && g.value.length > r.maxLength), { handleKeyPress: be, triggerSubmit: pe } = Tt(
1275
- r,
1276
- f,
1277
- g,
1278
- O,
1279
- se,
1280
- M,
1281
- R,
1282
- B,
1283
- z,
1272
+ ye();
1273
+ }, ge = B(() => l.maxLength !== 1 / 0 && _.value.length > l.maxLength), { handleKeyPress: je, triggerSubmit: le } = At(
1274
+ l,
1275
+ p,
1276
+ _,
1277
+ V,
1278
+ ue,
1279
+ b,
1280
+ x,
1281
+ Ie,
1284
1282
  J,
1285
- Re,
1283
+ Q,
1284
+ ye,
1285
+ W,
1286
1286
  F,
1287
- L,
1288
- ge,
1289
- C,
1290
- re
1291
- ), Ae = (t) => {
1292
- f("focus", t), g.value && !C.value && (M.value = !0);
1293
- }, Ge = (t) => {
1294
- f("blur", t), z();
1295
- }, he = E(() => L.value === "multiple" ? "textarea" : "text"), He = vt(), Ee = E(() => !!He.decorativeContent), ce = E(() => r.disabled || Ee.value), Ve = E(() => r.loading), Fe = E(() => ({
1296
- "is-disabled": ce.value,
1297
- "is-loading": Ve.value,
1298
- "is-auto-switching": A.value
1299
- })), Oe = E(() => ({
1300
- width: It(r.suggestionPopupWidth),
1287
+ ke,
1288
+ H,
1289
+ Y
1290
+ ), Fe = (s) => {
1291
+ p("focus", s), _.value && !H.value && (b.value = !0);
1292
+ }, Oe = (s) => {
1293
+ p("blur", s), J();
1294
+ }, $e = B(() => F.value === "multiple" ? "textarea" : "text"), Be = xt(), Me = B(() => !!Be.decorativeContent), de = B(
1295
+ () => F.value === "multiple" && !!Be["input-prefix"] && !H.value
1296
+ );
1297
+ kt(g, ([s]) => {
1298
+ var u, C;
1299
+ (C = (u = g.value) == null ? void 0 : u.parentElement) == null || C.style.setProperty(
1300
+ "--tr-sender-input-prefix-width",
1301
+ `${s.contentRect.width}px`
1302
+ );
1303
+ });
1304
+ const e = (s) => {
1305
+ L.value = s.target.scrollTop;
1306
+ }, n = () => {
1307
+ D == null || D.removeEventListener("scroll", e), D = null, L.value = 0;
1308
+ }, o = async (s) => {
1309
+ var C;
1310
+ if (n(), !s || (await q(), !de.value)) return;
1311
+ const u = (C = h.value) == null ? void 0 : C.querySelector(".tiny-textarea__inner");
1312
+ u && (D = u, u.addEventListener("scroll", e), L.value = u.scrollTop);
1313
+ };
1314
+ ne(
1315
+ [de, I],
1316
+ ([s]) => {
1317
+ o(s);
1318
+ },
1319
+ { immediate: !0, flush: "post" }
1320
+ ), Ct(n);
1321
+ const r = B(() => l.disabled || Me.value), c = B(() => l.loading), d = B(() => ({
1322
+ "is-disabled": r.value,
1323
+ "is-loading": c.value,
1324
+ "is-auto-switching": te.value
1325
+ })), w = B(() => ({
1326
+ width: Pt(l.suggestionPopupWidth),
1301
1327
  maxWidth: "100%"
1302
1328
  // 确保不超出父容器宽度
1303
- })), e = () => {
1304
- O.value = !1;
1329
+ })), O = () => {
1330
+ V.value = !1;
1305
1331
  };
1306
- ne(g, () => {
1307
- q(le), g.value === "" && r.mode === "single" && (L.value = "single"), b();
1332
+ ne(_, () => {
1333
+ q(pe), _.value === "" && l.mode === "single" && (F.value = "single"), K();
1308
1334
  }), ne(
1309
- () => C.value,
1310
- (t) => {
1311
- t && (L.value = "multiple");
1335
+ () => H.value,
1336
+ (s) => {
1337
+ s && (F.value = "multiple");
1312
1338
  }
1313
1339
  );
1314
- const o = () => {
1315
- h.value && h.value.activateFirstField();
1316
- }, { open: s, files: c } = mt({
1317
- accept: Me(() => {
1318
- var t, a;
1319
- return ((a = (t = r.buttonGroup) == null ? void 0 : t.file) == null ? void 0 : a.accept) ?? "*";
1340
+ const U = () => {
1341
+ v.value && v.value.activateFirstField();
1342
+ }, { open: $, files: P } = Rt({
1343
+ accept: ze(() => {
1344
+ var s, u;
1345
+ return ((u = (s = l.buttonGroup) == null ? void 0 : s.file) == null ? void 0 : u.accept) ?? "*";
1320
1346
  }),
1321
- multiple: Me(() => {
1322
- var t, a;
1323
- return ((a = (t = r.buttonGroup) == null ? void 0 : t.file) == null ? void 0 : a.multiple) ?? !0;
1347
+ multiple: ze(() => {
1348
+ var s, u;
1349
+ return ((u = (s = l.buttonGroup) == null ? void 0 : s.file) == null ? void 0 : u.multiple) ?? !0;
1324
1350
  }),
1325
- reset: Me(() => {
1326
- var t, a;
1327
- return ((a = (t = r.buttonGroup) == null ? void 0 : t.file) == null ? void 0 : a.reset) ?? !0;
1351
+ reset: ze(() => {
1352
+ var s, u;
1353
+ return ((u = (s = l.buttonGroup) == null ? void 0 : s.file) == null ? void 0 : u.reset) ?? !0;
1328
1354
  })
1329
1355
  });
1330
- return ne(c, (t) => {
1331
- t && t.length > 0 && f("files-selected", Array.from(t));
1356
+ return ne(P, (s) => {
1357
+ s && s.length > 0 && p("files-selected", Array.from(s));
1332
1358
  }), i({
1333
- focus: me,
1334
- blur: te,
1335
- clear: Q,
1336
- submit: pe,
1337
- startSpeech: we,
1338
- stopSpeech: Ie,
1339
- activateTemplateFirstField: o
1340
- }), (t, a) => (m(), I("div", {
1359
+ focus: ae,
1360
+ blur: He,
1361
+ clear: he,
1362
+ submit: le,
1363
+ startSpeech: Te,
1364
+ stopSpeech: ve,
1365
+ activateTemplateFirstField: U
1366
+ }), (s, u) => (m(), R("div", {
1341
1367
  ref_key: "senderRef",
1342
- ref: p,
1343
- class: oe(["tiny-sender", [Fe.value, `theme-${n.theme}`, `mode-${L.value}`]]),
1344
- "data-theme": n.theme
1368
+ ref: h,
1369
+ class: se(["tiny-sender", [d.value, `theme-${t.theme}`, `mode-${F.value}`]]),
1370
+ "data-theme": t.theme
1345
1371
  }, [
1346
- U("div", Yt, [
1347
- U("div", {
1372
+ G("div", ln, [
1373
+ G("div", {
1348
1374
  class: "tiny-sender__input-wrapper",
1349
1375
  ref_key: "inputWrapperRef",
1350
- ref: v
1376
+ ref: y
1351
1377
  }, [
1352
- Z(ze, { name: "tiny-sender-slide-down" }, {
1353
- default: ve(() => [
1354
- t.$slots.header ? (m(), I("div", Zt, [
1355
- ie(t.$slots, "header", {}, void 0, !0)
1356
- ])) : P("", !0)
1378
+ ee(qe, { name: "tiny-sender-slide-down" }, {
1379
+ default: me(() => [
1380
+ s.$slots.header ? (m(), R("div", rn, [
1381
+ ce(s.$slots, "header", {}, void 0, !0)
1382
+ ])) : M("", !0)
1357
1383
  ]),
1358
1384
  _: 3
1359
1385
  }),
1360
- U("div", {
1361
- class: oe(["tiny-sender__input-row", { "has-prefix": t.$slots.prefix, "has-header": t.$slots.header }])
1386
+ G("div", {
1387
+ class: se(["tiny-sender__input-row", { "has-prefix": s.$slots.prefix, "has-header": s.$slots.header }])
1362
1388
  }, [
1363
- t.$slots.prefix ? (m(), I("div", Qt, [
1364
- ie(t.$slots, "prefix", {}, void 0, !0)
1365
- ])) : P("", !0),
1366
- U("div", en, [
1367
- ie(t.$slots, "content", {}, () => [
1368
- t.$slots.decorativeContent ? (m(), I("div", tn, [
1369
- ie(t.$slots, "decorativeContent", {}, void 0, !0)
1370
- ])) : P("", !0),
1371
- C.value ? (m(), ee(Nt, {
1389
+ s.$slots.prefix ? (m(), R("div", cn, [
1390
+ ce(s.$slots, "prefix", {}, void 0, !0)
1391
+ ])) : M("", !0),
1392
+ G("div", un, [
1393
+ ce(s.$slots, "content", {}, () => [
1394
+ s.$slots.decorativeContent ? (m(), R("div", dn, [
1395
+ ce(s.$slots, "decorativeContent", {}, void 0, !0)
1396
+ ])) : M("", !0),
1397
+ H.value ? (m(), oe(Zt, {
1372
1398
  key: 1,
1373
1399
  ref_key: "templateEditorRef",
1374
- ref: h,
1375
- "model-value": r.templateData,
1376
- "auto-size": n.autoSize,
1377
- "onUpdate:modelValue": Ke,
1378
- onSubmit: k(pe)
1379
- }, null, 8, ["model-value", "auto-size", "onSubmit"])) : (m(), I("div", nn, [
1380
- Z(k(gt), {
1400
+ ref: v,
1401
+ "model-value": l.templateData,
1402
+ "auto-size": t.autoSize,
1403
+ "onUpdate:modelValue": Re,
1404
+ onSubmit: k(le)
1405
+ }, null, 8, ["model-value", "auto-size", "onSubmit"])) : (m(), R("div", {
1406
+ key: 2,
1407
+ class: se(["tiny-sender__input-field-wrapper", { "has-input-prefix": de.value }])
1408
+ }, [
1409
+ de.value ? (m(), R("div", {
1410
+ key: 0,
1411
+ ref_key: "inputPrefixRef",
1412
+ ref: g,
1413
+ class: "tiny-sender__input-prefix",
1414
+ style: Ae({ transform: `translateY(-${L.value}px)` })
1415
+ }, [
1416
+ ce(s.$slots, "input-prefix", {}, void 0, !0)
1417
+ ], 4)) : M("", !0),
1418
+ ee(k(It), {
1381
1419
  ref_key: "inputRef",
1382
- ref: _,
1383
- autosize: n.autoSize,
1384
- type: he.value,
1420
+ ref: I,
1421
+ autosize: t.autoSize,
1422
+ type: $e.value,
1385
1423
  resize: "none",
1386
- modelValue: k(g),
1387
- "onUpdate:modelValue": a[0] || (a[0] = (u) => yt(g) ? g.value = u : null),
1388
- disabled: ce.value,
1389
- placeholder: n.placeholder,
1390
- autofocus: n.autofocus,
1391
- onKeydown: k(be),
1392
- onCompositionstart: a[1] || (a[1] = (u) => O.value = !0),
1393
- onCompositionend: e,
1394
- onFocus: Ae,
1395
- onBlur: Ge
1424
+ modelValue: k(_),
1425
+ "onUpdate:modelValue": u[0] || (u[0] = (C) => _t(_) ? _.value = C : null),
1426
+ disabled: r.value,
1427
+ placeholder: t.placeholder,
1428
+ autofocus: t.autofocus,
1429
+ onKeydown: k(je),
1430
+ onCompositionstart: u[1] || (u[1] = (C) => V.value = !0),
1431
+ onCompositionend: O,
1432
+ onFocus: Fe,
1433
+ onBlur: Oe
1396
1434
  }, null, 8, ["autosize", "type", "modelValue", "disabled", "placeholder", "autofocus", "onKeydown"]),
1397
- k(w) && !k(O) ? (m(), I("div", on, [
1398
- U("span", sn, de(k(g)), 1),
1399
- Qe(" " + de(k(w)) + " ", 1),
1400
- k(d) ? (m(), I("div", an, "TAB")) : P("", !0)
1401
- ])) : P("", !0)
1402
- ]))
1435
+ k(z) && !k(V) ? (m(), R("div", fn, [
1436
+ G("span", pn, fe(k(_)), 1),
1437
+ nt(" " + fe(k(z)) + " ", 1),
1438
+ k(Z) ? (m(), R("div", hn, "TAB")) : M("", !0)
1439
+ ])) : M("", !0)
1440
+ ], 2))
1403
1441
  ], !0)
1404
1442
  ]),
1405
- L.value === "single" ? (m(), I("div", ln, [
1406
- U("div", {
1443
+ F.value === "single" ? (m(), R("div", vn, [
1444
+ G("div", {
1407
1445
  class: "tiny-sender__buttons-container",
1408
1446
  ref_key: "buttonsContainerRef",
1409
- ref: y
1447
+ ref: T
1410
1448
  }, [
1411
- ie(t.$slots, "actions", {}, void 0, !0),
1412
- Z(et, {
1413
- "allow-speech": n.allowSpeech,
1414
- "allow-files": n.allowFiles,
1415
- loading: n.loading,
1416
- disabled: ce.value,
1417
- "show-clear": n.clearable,
1418
- "has-content": H.value,
1419
- "speech-status": k(se),
1420
- "button-group": n.buttonGroup,
1421
- "submit-type": n.submitType,
1422
- "is-over-limit": ae.value,
1423
- "stop-text": n.stopText,
1424
- onClear: Q,
1425
- onVoiceButtonClick: Te,
1426
- onSubmit: k(pe),
1427
- onCancel: a[2] || (a[2] = (u) => t.$emit("cancel")),
1428
- onTriggerSelect: k(s)
1449
+ ce(s.$slots, "actions", {}, void 0, !0),
1450
+ ee(ot, {
1451
+ "allow-speech": t.allowSpeech,
1452
+ "allow-files": t.allowFiles,
1453
+ loading: t.loading,
1454
+ disabled: r.value,
1455
+ "show-clear": t.clearable,
1456
+ "has-content": E.value,
1457
+ "speech-status": k(ue),
1458
+ "button-group": t.buttonGroup,
1459
+ "submit-type": t.submitType,
1460
+ "is-over-limit": ge.value,
1461
+ "stop-text": t.stopText,
1462
+ onClear: he,
1463
+ onVoiceButtonClick: Ee,
1464
+ onSubmit: k(le),
1465
+ onCancel: u[2] || (u[2] = (C) => s.$emit("cancel")),
1466
+ onTriggerSelect: k($)
1429
1467
  }, 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"])
1430
1468
  ], 512)
1431
- ])) : P("", !0)
1469
+ ])) : M("", !0)
1432
1470
  ], 2),
1433
- Z(ze, { name: "tiny-sender-slide-up" }, {
1434
- default: ve(() => [
1435
- L.value === "multiple" ? (m(), I("div", rn, [
1436
- U("div", cn, [
1437
- ie(t.$slots, "footer-left", {}, void 0, !0)
1471
+ ee(qe, { name: "tiny-sender-slide-up" }, {
1472
+ default: me(() => [
1473
+ F.value === "multiple" ? (m(), R("div", yn, [
1474
+ G("div", gn, [
1475
+ ce(s.$slots, "footer-left", {}, void 0, !0)
1438
1476
  ]),
1439
- U("div", un, [
1440
- ie(t.$slots, "footer-right", {}, void 0, !0),
1441
- n.showWordLimit && n.maxLength !== 1 / 0 ? (m(), I("div", {
1477
+ G("div", mn, [
1478
+ ce(s.$slots, "footer-right", {}, void 0, !0),
1479
+ t.showWordLimit && t.maxLength !== 1 / 0 ? (m(), R("div", {
1442
1480
  key: 0,
1443
- class: oe(["tiny-sender__word-limit", { "is-over-limit": ae.value }])
1481
+ class: se(["tiny-sender__word-limit", { "is-over-limit": ge.value }])
1444
1482
  }, [
1445
- U("span", dn, de(k(g).length), 1),
1446
- Qe("/" + de(n.maxLength), 1)
1447
- ], 2)) : P("", !0),
1448
- L.value === "multiple" ? (m(), I("div", fn, [
1449
- U("div", pn, [
1450
- Z(et, {
1451
- "allow-speech": n.allowSpeech,
1452
- "allow-files": n.allowFiles,
1453
- loading: n.loading,
1454
- disabled: ce.value,
1455
- "show-clear": n.clearable,
1456
- "has-content": H.value,
1457
- "speech-status": k(se),
1458
- "button-group": n.buttonGroup,
1459
- "submit-type": n.submitType,
1460
- "is-over-limit": ae.value,
1461
- "stop-text": n.stopText,
1462
- onClear: Q,
1463
- onVoiceButtonClick: Te,
1464
- onSubmit: k(pe),
1465
- onCancel: a[3] || (a[3] = (u) => t.$emit("cancel")),
1466
- onTriggerSelect: k(s)
1483
+ G("span", wn, fe(k(_).length), 1),
1484
+ nt("/" + fe(t.maxLength), 1)
1485
+ ], 2)) : M("", !0),
1486
+ F.value === "multiple" ? (m(), R("div", bn, [
1487
+ G("div", Sn, [
1488
+ ee(ot, {
1489
+ "allow-speech": t.allowSpeech,
1490
+ "allow-files": t.allowFiles,
1491
+ loading: t.loading,
1492
+ disabled: r.value,
1493
+ "show-clear": t.clearable,
1494
+ "has-content": E.value,
1495
+ "speech-status": k(ue),
1496
+ "button-group": t.buttonGroup,
1497
+ "submit-type": t.submitType,
1498
+ "is-over-limit": ge.value,
1499
+ "stop-text": t.stopText,
1500
+ onClear: he,
1501
+ onVoiceButtonClick: Ee,
1502
+ onSubmit: k(le),
1503
+ onCancel: u[3] || (u[3] = (C) => s.$emit("cancel")),
1504
+ onTriggerSelect: k($)
1467
1505
  }, 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"])
1468
1506
  ])
1469
- ])) : P("", !0)
1507
+ ])) : M("", !0)
1470
1508
  ])
1471
- ])) : t.$slots.footer ? (m(), I("div", hn, [
1472
- ie(t.$slots, "footer", {}, void 0, !0)
1473
- ])) : P("", !0)
1509
+ ])) : s.$slots.footer ? (m(), R("div", xn, [
1510
+ ce(s.$slots, "footer", {}, void 0, !0)
1511
+ ])) : M("", !0)
1474
1512
  ]),
1475
1513
  _: 3
1476
1514
  })
1477
1515
  ], 512)
1478
1516
  ]),
1479
- Z(Jt, {
1480
- show: k(M),
1481
- suggestions: n.suggestions,
1482
- "popup-style": Oe.value,
1483
- "active-keyboard-index": k(W),
1517
+ ee(sn, {
1518
+ show: k(b),
1519
+ suggestions: t.suggestions,
1520
+ "popup-style": w.value,
1521
+ "active-keyboard-index": k(f),
1484
1522
  "active-mouse-index": k(S),
1485
- "input-value": k(g),
1486
- onSelect: k(j),
1487
- onMouseEnter: k(G),
1488
- onMouseLeave: k(ke)
1523
+ "input-value": k(_),
1524
+ onSelect: k(X),
1525
+ onMouseEnter: k(N),
1526
+ onMouseLeave: k(be)
1489
1527
  }, null, 8, ["show", "suggestions", "popup-style", "active-keyboard-index", "active-mouse-index", "input-value", "onSelect", "onMouseEnter", "onMouseLeave"])
1490
- ], 10, Xt));
1528
+ ], 10, an));
1491
1529
  }
1492
- }), De = /* @__PURE__ */ _e(vn, [["__scopeId", "data-v-dcefe1f1"]]);
1493
- De.name = "TrSender";
1494
- const yn = function(n) {
1495
- n.component(De.name, De);
1530
+ }), Ke = /* @__PURE__ */ _e(Cn, [["__scopeId", "data-v-be921b04"]]);
1531
+ Ke.name = "TrSender";
1532
+ const _n = function(t) {
1533
+ t.component(Ke.name, Ke);
1496
1534
  };
1497
- De.install = yn;
1535
+ Ke.install = _n;
1498
1536
  export {
1499
- De as default
1537
+ Ke as default
1500
1538
  };