@opentiny/tiny-robot 0.3.0-alpha.15 → 0.3.0-alpha.17

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