@opentiny/tiny-robot 0.2.0-alpha.8 → 0.2.0-alpha.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,329 +1,390 @@
1
- import { ref as I, watch as J, reactive as xe, computed as $, nextTick as V, defineComponent as he, createElementBlock as O, openBlock as R, createCommentVNode as B, createBlock as X, unref as w, withCtx as G, createVNode as U, normalizeClass as ne, resolveDynamicComponent as He, createElementVNode as W, mergeModels as Se, useModel as je, onMounted as qe, useSlots as Ue, Transition as fe, renderSlot as Z, isRef as _e, createTextVNode as Ee, toDisplayString as te, normalizeStyle as ze, Fragment as Te, renderList as Ne, withModifiers as Xe } from "vue";
2
- import { I as Ge } from "../index5.js";
3
- import { B as ie } from "../index3.js";
4
- import { T as pe } from "../index4.js";
5
- import { i as Je } from "../close.js";
6
- import { I as Qe, L as Ye, u as Ze, w as et, P as tt, _ as nt } from "../tiny-robot-svgs.js";
7
- function st(n, b) {
8
- const g = I(n.modelValue || n.defaultValue || ""), a = I(null);
9
- J(
10
- () => n.modelValue,
11
- (p) => {
12
- p !== void 0 && p !== g.value && (g.value = p);
1
+ import { ref as O, watch as Y, reactive as Le, computed as P, nextTick as W, defineComponent as ve, createElementBlock as M, openBlock as k, createCommentVNode as $, createBlock as Z, unref as T, withCtx as G, createVNode as U, normalizeClass as le, resolveDynamicComponent as Ue, createElementVNode as K, mergeModels as Ne, useModel as Ze, onMounted as Ge, useSlots as Je, Transition as ge, renderSlot as ne, isRef as Te, createTextVNode as xe, toDisplayString as se, normalizeStyle as Qe, Fragment as Re, renderList as ke, withModifiers as Ye } from "vue";
2
+ import { I as et } from "../index5.js";
3
+ import { B as ue } from "../index3.js";
4
+ import { T as me } from "../index4.js";
5
+ import { i as tt } from "../close.js";
6
+ import { I as nt, L as st, u as lt, w as ot, P as at, _ as it } from "../tiny-robot-svgs.js";
7
+ function rt(e, b) {
8
+ const f = O(e.modelValue || e.defaultValue || ""), o = O(null);
9
+ Y(
10
+ () => e.modelValue,
11
+ (v) => {
12
+ v !== void 0 && v !== f.value && (f.value = v);
13
13
  }
14
- ), J(
15
- () => g.value,
16
- (p) => {
17
- b("update:modelValue", p);
14
+ ), Y(
15
+ () => f.value,
16
+ (v) => {
17
+ b("update:modelValue", v);
18
18
  }
19
19
  );
20
- const C = (p) => {
21
- g.value = p, b("update:modelValue", p);
22
- }, i = (p) => {
23
- p == null || p.preventDefault();
24
- const S = g.value;
25
- !n.disabled && !n.loading && S.trim() && b("submit", S);
26
- }, f = () => {
27
- g.value = "", b("update:modelValue", ""), b("clear");
28
- }, r = I(!1);
20
+ const S = (v) => {
21
+ f.value = v, b("update:modelValue", v);
22
+ }, r = (v) => {
23
+ v == null || v.preventDefault();
24
+ const E = f.value;
25
+ !e.disabled && !e.loading && E.trim() && b("submit", E);
26
+ }, p = () => {
27
+ f.value = "", b("update:modelValue", ""), b("clear");
28
+ }, u = O(!1);
29
29
  return {
30
- inputValue: g,
31
- inputWrapper: a,
32
- isComposing: r,
33
- handleChange: C,
34
- handleSubmit: i,
35
- handleClear: f,
30
+ inputValue: f,
31
+ inputWrapper: o,
32
+ isComposing: u,
33
+ handleChange: S,
34
+ handleSubmit: r,
35
+ handleClear: p,
36
36
  clearInput: () => {
37
- f();
37
+ p();
38
38
  }
39
39
  };
40
40
  }
41
- function lt(n, b, g, a, C, i, f, r, s, p, S, t, E) {
42
- const F = (y) => !n.disabled && !n.loading && y.trim().length > 0, v = () => {
43
- F(g.value) && b("submit", g.value.trim());
44
- }, k = (y, K) => {
45
- if (!(y.key === "Enter")) return !1;
46
- switch (K) {
41
+ const Oe = "​", Q = (e) => e.split("").every((b) => b === Oe), J = (e) => e.replace(/\u200B/g, ""), he = () => document.createTextNode(Oe), ut = (e) => {
42
+ const b = e.textContent || "", f = J(b);
43
+ return !f || f.trim() === "";
44
+ }, De = (e) => {
45
+ const b = e.nextSibling;
46
+ if (b && b.nodeType === Node.TEXT_NODE && Q(b.textContent || ""))
47
+ return;
48
+ const f = he();
49
+ e.parentNode && e.parentNode.insertBefore(f, e.nextSibling);
50
+ }, ct = (e) => {
51
+ Array.from(e.childNodes).forEach((f) => {
52
+ if (f.nodeType === Node.TEXT_NODE && Q(f.textContent || "")) {
53
+ const o = f.previousSibling;
54
+ o && o.nodeType === Node.ELEMENT_NODE && o.classList.contains("template-field") || f.parentNode && f.parentNode.removeChild(f);
55
+ }
56
+ });
57
+ };
58
+ function dt(e, b, f, o, S, r, p, u, l, v, E, a, _) {
59
+ const F = (m) => !e.disabled && !e.loading && m.trim().length > 0, y = () => {
60
+ F(f.value) && b("submit", f.value.trim());
61
+ }, C = (m, L) => {
62
+ if (!(m.key === "Enter")) return !1;
63
+ switch (L) {
47
64
  case "enter":
48
- return !y.shiftKey && !y.ctrlKey && !y.metaKey;
65
+ return !m.shiftKey && !m.ctrlKey && !m.metaKey;
49
66
  case "ctrlEnter":
50
- return (y.ctrlKey || y.metaKey) && !y.shiftKey;
67
+ return (m.ctrlKey || m.metaKey) && !m.shiftKey;
51
68
  case "shiftEnter":
52
- return y.shiftKey && !y.ctrlKey && !y.metaKey;
69
+ return m.shiftKey && !m.ctrlKey && !m.metaKey;
53
70
  default:
54
71
  return !1;
55
72
  }
56
73
  };
57
74
  return {
58
- handleKeyPress: (y) => {
59
- if (a.value) return;
60
- if (y.key === "Enter" && y.shiftKey && (t == null ? void 0 : t.value) === "single" && E) {
61
- y.preventDefault(), E();
62
- const P = y.target, H = P.selectionStart, z = g.value;
63
- g.value = z.substring(0, H) + `
64
- ` + z.substring(H), setTimeout(() => {
65
- P.selectionStart = P.selectionEnd = H + 1;
75
+ handleKeyPress: (m) => {
76
+ if (o.value) return;
77
+ if (m.key === "Enter" && m.shiftKey && (a == null ? void 0 : a.value) === "single" && _) {
78
+ m.preventDefault(), _();
79
+ const A = m.target, z = A.selectionStart, j = f.value;
80
+ f.value = j.substring(0, z) + `
81
+ ` + j.substring(z), setTimeout(() => {
82
+ A.selectionStart = A.selectionEnd = z + 1;
66
83
  }, 0);
67
84
  return;
68
85
  }
69
- if (y.key === "Tab" && i.value && f.value) {
70
- y.preventDefault(), r();
86
+ if (m.key === "Tab" && r.value && p.value) {
87
+ m.preventDefault(), u();
71
88
  return;
72
89
  }
73
- if (i.value) {
74
- if (y.key === "ArrowDown") {
75
- y.preventDefault(), p("down");
90
+ if (r.value) {
91
+ if (m.key === "ArrowDown") {
92
+ m.preventDefault(), v("down");
76
93
  return;
77
94
  }
78
- if (y.key === "ArrowUp") {
79
- y.preventDefault(), p("up");
95
+ if (m.key === "ArrowUp") {
96
+ m.preventDefault(), v("up");
80
97
  return;
81
98
  }
82
- if (y.key === "Enter" && f.value) {
83
- y.preventDefault(), r();
99
+ if (m.key === "Enter" && p.value) {
100
+ m.preventDefault(), u();
84
101
  return;
85
102
  }
86
103
  }
87
- if (y.key === "Escape") {
88
- i.value ? (s(), y.preventDefault()) : C.isRecording && (S(), y.preventDefault()), b("escape-press");
104
+ if (m.key === "Escape") {
105
+ r.value ? (l(), m.preventDefault()) : S.isRecording && (E(), m.preventDefault()), b("escape-press");
89
106
  return;
90
107
  }
91
- k(y, n.submitType) && F(g.value) && (y.preventDefault(), v());
108
+ C(m, e.submitType) && F(f.value) && (m.preventDefault(), y());
92
109
  },
93
- triggerSubmit: v
110
+ triggerSubmit: y
94
111
  };
95
112
  }
96
- function at(n) {
97
- const b = (i, f, r) => {
113
+ function ft(e) {
114
+ const b = (r, p, u) => {
98
115
  var F;
99
- const { startContainer: s, startOffset: p, collapsed: S } = f;
100
- if (!S) return !1;
101
- const t = s.nodeType === Node.TEXT_NODE && p === 0 && i.key === "ArrowLeft", E = s.nodeType === Node.TEXT_NODE && p === (((F = s.textContent) == null ? void 0 : F.length) || 0) && i.key === "ArrowRight";
102
- if (t || E) {
103
- let v = null, k = "inside";
104
- if (t)
105
- if (s.parentNode && s.parentNode.classList.contains("template-field"))
106
- v = s.parentNode, k = "before";
116
+ const { startContainer: l, startOffset: v, collapsed: E } = p;
117
+ if (!E) return !1;
118
+ const a = l.nodeType === Node.TEXT_NODE && v === 0 && r.key === "ArrowLeft", _ = l.nodeType === Node.TEXT_NODE && v === (((F = l.textContent) == null ? void 0 : F.length) || 0) && r.key === "ArrowRight";
119
+ if (a || _) {
120
+ let y = null, C = "inside";
121
+ if (a)
122
+ if (l.parentNode && l.parentNode.classList.contains("template-field"))
123
+ y = l.parentNode, C = "before";
124
+ else {
125
+ let w = l.previousSibling;
126
+ !w && l.parentNode && l.parentNode !== u && (w = l.parentNode.previousSibling), w && w.nodeType === Node.ELEMENT_NODE && w.classList.contains("template-field") && (y = w, C = "inside");
127
+ }
128
+ else if (_)
129
+ if (l.parentNode && l.parentNode.classList.contains("template-field"))
130
+ y = l.parentNode, C = "after";
107
131
  else {
108
- let x = s.previousSibling;
109
- !x && s.parentNode && s.parentNode !== r && (x = s.parentNode.previousSibling), x && x.nodeType === Node.ELEMENT_NODE && x.classList.contains("template-field") && (v = x, k = "inside");
132
+ let w = l.nextSibling;
133
+ !w && l.parentNode && l.parentNode !== u && (w = l.parentNode.nextSibling), w && w.nodeType === Node.ELEMENT_NODE && w.classList.contains("template-field") && (y = w, C = "inside");
110
134
  }
111
- else if (E)
112
- if (s.parentNode && s.parentNode.classList.contains("template-field"))
113
- v = s.parentNode, k = "after";
135
+ if (y) {
136
+ r.preventDefault();
137
+ const w = document.createRange(), m = window.getSelection();
138
+ return m && (C === "before" ? w.setStartBefore(y) : C === "after" ? w.setStartAfter(y) : (w.selectNodeContents(y), w.collapse(r.key === "ArrowLeft")), m.removeAllRanges(), m.addRange(w)), !0;
139
+ }
140
+ }
141
+ if (l.nodeType === Node.ELEMENT_NODE && l.classList.contains("template-field")) {
142
+ const C = l.textContent || "", w = J(C);
143
+ if (!w || w.trim() === "") {
144
+ r.preventDefault();
145
+ const m = document.createRange(), L = window.getSelection();
146
+ if (!L) return !0;
147
+ if (r.key === "ArrowLeft")
148
+ m.setStartBefore(l);
114
149
  else {
115
- let x = s.nextSibling;
116
- !x && s.parentNode && s.parentNode !== r && (x = s.parentNode.nextSibling), x && x.nodeType === Node.ELEMENT_NODE && x.classList.contains("template-field") && (v = x, k = "inside");
150
+ const A = l.nextSibling;
151
+ A && A.nodeType === Node.TEXT_NODE && Q(A.textContent || "") ? (m.setStart(A, 0), m.setEnd(A, 0)) : m.setStartAfter(l);
117
152
  }
118
- if (v) {
119
- i.preventDefault();
120
- const x = document.createRange(), y = window.getSelection();
121
- return y && (k === "before" ? x.setStartBefore(v) : k === "after" ? x.setStartAfter(v) : (x.selectNodeContents(v), x.collapse(i.key === "ArrowLeft")), y.removeAllRanges(), y.addRange(x)), !0;
153
+ return m.collapse(!0), L.removeAllRanges(), L.addRange(m), !0;
122
154
  }
123
155
  }
124
- if (s.nodeType === Node.ELEMENT_NODE && s.classList.contains("template-field") && !s.textContent) {
125
- i.preventDefault();
126
- const v = document.createRange(), k = window.getSelection();
127
- return k && (i.key === "ArrowLeft" ? v.setStartBefore(s) : v.setStartAfter(s), v.collapse(!0), k.removeAllRanges(), k.addRange(v)), !0;
156
+ if (l.nodeType === Node.TEXT_NODE && Q(l.textContent || "")) {
157
+ const y = l.previousSibling, C = l.nextSibling;
158
+ r.preventDefault();
159
+ const w = document.createRange(), m = window.getSelection();
160
+ return m && (r.key === "ArrowLeft" ? y && y.nodeType === Node.ELEMENT_NODE && y.classList.contains("template-field") ? (w.selectNodeContents(y), w.collapse(!1)) : w.setStartBefore(l) : C && C.nodeType === Node.ELEMENT_NODE && C.classList.contains("template-field") ? (w.selectNodeContents(C), w.collapse(!0)) : w.setStartAfter(l), m.removeAllRanges(), m.addRange(w)), !0;
128
161
  }
129
162
  return !1;
130
- }, g = (i, f, r) => {
131
- if (!f.collapsed) return !1;
132
- const { startContainer: s, startOffset: p } = f;
133
- if (s.nodeType === Node.TEXT_NODE && s.parentNode && s.parentNode.classList.contains("template-field") && s.textContent && s.textContent.length === 1 && p === 1) {
134
- i.preventDefault(), s.textContent = "";
135
- const E = s.parentNode, F = window.getSelection();
136
- if (F) {
137
- const v = document.createRange();
138
- v.selectNodeContents(E), v.collapse(!0), F.removeAllRanges(), F.addRange(v);
163
+ }, f = (r, p, u) => {
164
+ if (!p.collapsed) return !1;
165
+ const { startContainer: l, startOffset: v } = p;
166
+ if (l.nodeType === Node.TEXT_NODE && Q(l.textContent || "")) {
167
+ const a = l.previousSibling;
168
+ if (a && a.nodeType === Node.ELEMENT_NODE && a.classList.contains("template-field")) {
169
+ const _ = a, F = _.textContent || "", y = J(F);
170
+ if (!y || y.trim() === "") {
171
+ r.preventDefault();
172
+ const C = _.previousSibling, w = l.nextSibling;
173
+ _.parentNode && _.parentNode.removeChild(_), l.parentNode && l.parentNode.removeChild(l);
174
+ const m = window.getSelection();
175
+ if (m) {
176
+ const L = document.createRange();
177
+ C ? C.nodeType === Node.ELEMENT_NODE && C.classList.contains("template-field") ? (L.selectNodeContents(C), L.collapse(!1)) : C.nodeType === Node.TEXT_NODE && Q(C.textContent || "") ? (L.setStart(C, 0), L.setEnd(C, 0)) : L.setStartAfter(C) : w ? L.setStartBefore(w) : L.setStart(u, 0), L.collapse(!0), m.removeAllRanges(), m.addRange(L);
178
+ }
179
+ return e.handleInput(), !0;
180
+ } else {
181
+ r.preventDefault();
182
+ const C = window.getSelection();
183
+ if (C) {
184
+ const w = document.createRange();
185
+ w.selectNodeContents(_), w.collapse(!1), C.removeAllRanges(), C.addRange(w);
186
+ }
187
+ return !0;
188
+ }
139
189
  }
140
- return n.handleInput(), !0;
141
190
  }
142
- if (p === 0) {
143
- let E = null;
144
- if (s.nodeType === Node.ELEMENT_NODE && s.classList.contains("template-field") ? E = s : s.nodeType === Node.TEXT_NODE && s.parentNode && s.parentNode.classList.contains("template-field") && (E = s.parentNode), E) {
145
- i.preventDefault();
146
- const F = window.getSelection();
147
- return F && (f.setStartBefore(E), f.collapse(!0), F.removeAllRanges(), F.addRange(f)), !0;
191
+ if (l.nodeType === Node.TEXT_NODE && l.parentNode && l.parentNode.classList.contains("template-field") && l.textContent) {
192
+ const a = l.textContent;
193
+ if (J(a).length === 1 && v === a.length) {
194
+ r.preventDefault(), l.textContent = "";
195
+ const F = l.parentNode, y = window.getSelection();
196
+ if (y) {
197
+ const C = document.createRange();
198
+ C.selectNodeContents(F), C.collapse(!0), y.removeAllRanges(), y.addRange(C);
199
+ }
200
+ return e.handleInput(), !0;
201
+ }
202
+ }
203
+ if (v === 0) {
204
+ let a = null;
205
+ if (l.nodeType === Node.ELEMENT_NODE && l.classList.contains("template-field") ? a = l : l.nodeType === Node.TEXT_NODE && l.parentNode && l.parentNode.classList.contains("template-field") && (a = l.parentNode), a) {
206
+ r.preventDefault();
207
+ const _ = window.getSelection();
208
+ return _ && (p.setStartBefore(a), p.collapse(!0), _.removeAllRanges(), _.addRange(p)), !0;
148
209
  }
149
210
  }
150
- let t = null;
151
- return s === r && p > 0 ? t = r.childNodes[p - 1] : s.nodeType === Node.TEXT_NODE && p === 0 && (t = s.previousSibling), t && t.nodeType === Node.ELEMENT_NODE && t.classList.contains("template-field") && t.textContent === "" ? (i.preventDefault(), t.parentNode && t.parentNode.removeChild(t), n.handleInput(), !0) : !1;
152
- }, a = (i, f, r) => {
153
- var E;
154
- if (!f.collapsed) return !1;
155
- const { startContainer: s, startOffset: p } = f;
156
- if (s.nodeType === Node.TEXT_NODE && s.parentNode && s.parentNode.classList.contains("template-field") && s.textContent && p === s.textContent.length && s.textContent.length === 1) {
157
- i.preventDefault(), s.textContent = "";
158
- const F = s.parentNode, v = window.getSelection();
159
- if (v) {
160
- const k = document.createRange();
161
- k.selectNodeContents(F), k.collapse(!0), v.removeAllRanges(), v.addRange(k);
211
+ return !1;
212
+ }, o = (r, p) => {
213
+ if (!p.collapsed) return !1;
214
+ const { startContainer: u, startOffset: l } = p;
215
+ if (u.nodeType === Node.TEXT_NODE && u.parentNode && u.parentNode.classList.contains("template-field") && u.textContent) {
216
+ const E = u.textContent, a = J(E);
217
+ if (l === E.length && a.length === 1) {
218
+ r.preventDefault(), u.textContent = "";
219
+ const _ = u.parentNode, F = window.getSelection();
220
+ if (F) {
221
+ const y = document.createRange();
222
+ y.selectNodeContents(_), y.collapse(!0), F.removeAllRanges(), F.addRange(y);
223
+ }
224
+ return e.handleInput(), !0;
162
225
  }
163
- return n.handleInput(), !0;
164
226
  }
165
- let t = null;
166
- return s === r && p < r.childNodes.length ? t = r.childNodes[p] : s.nodeType === Node.TEXT_NODE && p === (((E = s.textContent) == null ? void 0 : E.length) || 0) && (t = s.nextSibling), t && t.nodeType === Node.ELEMENT_NODE && t.classList.contains("template-field") && t.textContent === "" ? (i.preventDefault(), t.parentNode && t.parentNode.removeChild(t), n.handleInput(), !0) : !1;
227
+ return !1;
167
228
  };
168
229
  return {
169
- handleTemplateKeyDown: (i) => {
170
- if (n.isComposing.value) return;
171
- const f = n.editor.value;
172
- if (!f) return;
173
- const r = window.getSelection();
174
- if (!r || r.rangeCount === 0) return;
175
- const s = r.getRangeAt(0);
176
- if (i.key === "Enter") {
177
- i.preventDefault(), n.onSubmit(n.getValueFromDOM());
230
+ handleTemplateKeyDown: (r) => {
231
+ if (e.isComposing.value) return;
232
+ const p = e.editor.value;
233
+ if (!p) return;
234
+ const u = window.getSelection();
235
+ if (!u || u.rangeCount === 0) return;
236
+ const l = u.getRangeAt(0);
237
+ if (r.key === "Enter") {
238
+ r.preventDefault(), e.onSubmit(e.getValueFromDOM());
178
239
  return;
179
240
  }
180
- (i.key === "ArrowLeft" || i.key === "ArrowRight") && !i.shiftKey && b(i, s, f) || i.key === "Backspace" && g(i, s, f) || i.key === "Delete" && a(i, s, f);
241
+ (r.key === "ArrowLeft" || r.key === "ArrowRight") && !r.shiftKey && b(r, l, p) || r.key === "Backspace" && f(r, l, p) || r.key === "Delete" && o(r, l);
181
242
  }
182
243
  };
183
244
  }
184
- function ot(n) {
185
- const b = xe({
245
+ function pt(e) {
246
+ const b = Le({
186
247
  isRecording: !1,
187
248
  isSupported: typeof window < "u" && "webkitSpeechRecognition" in window || "SpeechRecognition" in window,
188
249
  error: void 0
189
- }), g = b.isSupported ? new (window.webkitSpeechRecognition || window.SpeechRecognition)() : void 0;
190
- g !== void 0 && (g.continuous = n.continuous ?? !1, g.interimResults = n.interimResults ?? !0, g.lang = n.lang ?? navigator.language, g.onstart = () => {
191
- var f;
192
- b.isRecording = !0, b.error = void 0, (f = n.onStart) == null || f.call(n);
193
- }, g.onend = () => {
194
- var f;
195
- b.isRecording = !1, (f = n.onEnd) == null || f.call(n);
196
- }, g.onresult = (f) => {
197
- var s, p;
198
- const r = Array.from(f.results).map((S) => S[0].transcript).join("");
199
- f.results[0].isFinal ? (s = n.onFinal) == null || s.call(n, r) : (p = n.onInterim) == null || p.call(n, r);
200
- }, g.onerror = (f) => {
201
- var r;
202
- b.error = new Error(f.error), b.isRecording = !1, (r = n.onError) == null || r.call(n, b.error);
250
+ }), f = b.isSupported ? new (window.webkitSpeechRecognition || window.SpeechRecognition)() : void 0;
251
+ f !== void 0 && (f.continuous = e.continuous ?? !1, f.interimResults = e.interimResults ?? !0, f.lang = e.lang ?? navigator.language, f.onstart = () => {
252
+ var p;
253
+ b.isRecording = !0, b.error = void 0, (p = e.onStart) == null || p.call(e);
254
+ }, f.onend = () => {
255
+ var p;
256
+ b.isRecording = !1, (p = e.onEnd) == null || p.call(e);
257
+ }, f.onresult = (p) => {
258
+ var l, v;
259
+ const u = Array.from(p.results).map((E) => E[0].transcript).join("");
260
+ p.results[0].isFinal ? (l = e.onFinal) == null || l.call(e, u) : (v = e.onInterim) == null || v.call(e, u);
261
+ }, f.onerror = (p) => {
262
+ var u;
263
+ b.error = new Error(p.error), b.isRecording = !1, (u = e.onError) == null || u.call(e, b.error);
203
264
  });
204
- const a = () => {
205
- var f;
206
- if (!g) {
207
- const r = new Error("浏览器不支持语音识别");
208
- b.error = r, (f = n.onError) == null || f.call(n, r);
265
+ const o = () => {
266
+ var p;
267
+ if (!f) {
268
+ const u = new Error("浏览器不支持语音识别");
269
+ b.error = u, (p = e.onError) == null || p.call(e, u);
209
270
  return;
210
271
  }
211
272
  if (b.isRecording) {
212
273
  try {
213
- g.stop(), setTimeout(() => {
274
+ f.stop(), setTimeout(() => {
214
275
  try {
215
- g.start();
216
- } catch (r) {
217
- i(r);
276
+ f.start();
277
+ } catch (u) {
278
+ r(u);
218
279
  }
219
280
  }, 100);
220
- } catch (r) {
221
- i(r);
281
+ } catch (u) {
282
+ r(u);
222
283
  }
223
284
  return;
224
285
  }
225
286
  try {
226
- g.start();
227
- } catch (r) {
228
- i(r);
287
+ f.start();
288
+ } catch (u) {
289
+ r(u);
229
290
  }
230
- }, C = () => {
231
- if (g && b.isRecording)
291
+ }, S = () => {
292
+ if (f && b.isRecording)
232
293
  try {
233
- g.stop();
234
- } catch (f) {
235
- i(f);
294
+ f.stop();
295
+ } catch (p) {
296
+ r(p);
236
297
  }
237
- }, i = (f) => {
238
- var r;
239
- b.error = f instanceof Error ? f : new Error("语音识别操作失败"), b.isRecording = !1, (r = n.onError) == null || r.call(n, b.error);
298
+ }, r = (p) => {
299
+ var u;
300
+ b.error = p instanceof Error ? p : new Error("语音识别操作失败"), b.isRecording = !1, (u = e.onError) == null || u.call(e, b.error);
240
301
  };
241
302
  return {
242
303
  speechState: b,
243
- start: a,
244
- stop: C
304
+ start: o,
305
+ stop: S
245
306
  };
246
307
  }
247
- const it = (n, b) => {
248
- if (!b || !n)
249
- return [{ text: n, isMatch: !1 }];
250
- const g = n.toLowerCase(), a = b.toLowerCase(), C = g.indexOf(a);
251
- if (C === -1)
252
- return [{ text: n, isMatch: !1 }];
253
- const i = [];
254
- return C > 0 && i.push({
255
- text: n.substring(0, C),
308
+ const gt = (e, b) => {
309
+ if (!b || !e)
310
+ return [{ text: e, isMatch: !1 }];
311
+ const f = e.toLowerCase(), o = b.toLowerCase(), S = f.indexOf(o);
312
+ if (S === -1)
313
+ return [{ text: e, isMatch: !1 }];
314
+ const r = [];
315
+ return S > 0 && r.push({
316
+ text: e.substring(0, S),
256
317
  isMatch: !1
257
- }), i.push({
258
- text: n.substring(C, C + b.length),
318
+ }), r.push({
319
+ text: e.substring(S, S + b.length),
259
320
  isMatch: !0
260
- }), C + b.length < n.length && i.push({
261
- text: n.substring(C + b.length),
321
+ }), S + b.length < e.length && r.push({
322
+ text: e.substring(S + b.length),
262
323
  isMatch: !1
263
- }), i;
324
+ }), r;
264
325
  };
265
- function rt(n, b, g, a) {
266
- const C = I(!1), i = I(-1), f = I(""), r = I(!1), s = I(null), p = I(!1), S = $(() => {
267
- if (!n.suggestions || !g.value || n.template) return [];
268
- const h = g.value.toLowerCase();
269
- return n.suggestions.filter((m) => m.toLowerCase().includes(h));
270
- }), t = $(() => S.value[i.value] || null), E = (h) => {
271
- const m = h || (S.value.length > 0 ? S.value[0] : null);
272
- m && g.value && m.toLowerCase().startsWith(g.value.toLowerCase()) ? f.value = m.substring(g.value.length) : f.value = "";
326
+ function mt(e, b, f, o) {
327
+ const S = O(!1), r = O(-1), p = O(""), u = O(!1), l = O(null), v = O(!1), E = P(() => {
328
+ if (!e.suggestions || !f.value || e.template) return [];
329
+ const g = f.value.toLowerCase();
330
+ return e.suggestions.filter((h) => h.toLowerCase().includes(g));
331
+ }), a = P(() => E.value[r.value] || null), _ = (g) => {
332
+ const h = g || (E.value.length > 0 ? E.value[0] : null);
333
+ h && f.value && h.toLowerCase().startsWith(f.value.toLowerCase()) ? p.value = h.substring(f.value.length) : p.value = "";
273
334
  }, F = () => {
274
- C.value = !1, i.value = -1, f.value = "", r.value = !1;
275
- }, v = () => {
276
- C.value = !0, i.value = 0, E(), r.value = !0;
277
- }, k = () => {
278
- a.value || p.value || V(() => {
279
- g.value && n.suggestions && n.suggestions.length > 0 && !n.template && S.value.length > 0 ? v() : F();
335
+ S.value = !1, r.value = -1, p.value = "", u.value = !1;
336
+ }, y = () => {
337
+ S.value = !0, r.value = 0, _(), u.value = !0;
338
+ }, C = () => {
339
+ o.value || v.value || W(() => {
340
+ f.value && e.suggestions && e.suggestions.length > 0 && !e.template && E.value.length > 0 ? y() : F();
280
341
  });
281
342
  };
282
- J(g, k), J(() => n.suggestions, k);
283
- const x = (h) => {
284
- p.value = !0, g.value = h, b("update:modelValue", h), b("suggestion-select", h), K(), V(() => {
285
- p.value = !1;
343
+ Y(f, C), Y(() => e.suggestions, C);
344
+ const w = (g) => {
345
+ v.value = !0, f.value = g, b("update:modelValue", g), b("suggestion-select", g), L(), W(() => {
346
+ v.value = !1;
286
347
  });
287
- }, y = () => {
288
- t.value && x(t.value);
289
- }, K = () => {
348
+ }, m = () => {
349
+ a.value && w(a.value);
350
+ }, L = () => {
290
351
  F();
291
352
  };
292
353
  return {
293
- showSuggestionsPopup: C,
294
- highlightedIndex: i,
295
- completionPlaceholder: f,
296
- showTabHint: r,
297
- suggestionsListRef: s,
298
- filteredSuggestions: S,
299
- activeSuggestion: t,
300
- updateCompletionPlaceholder: E,
301
- updateSuggestionsState: k,
302
- selectSuggestion: x,
303
- acceptCurrentSuggestion: y,
304
- closeSuggestionsPopup: K,
305
- navigateSuggestions: (h) => {
306
- if (!C.value || S.value.length === 0) return;
307
- h === "down" ? i.value = (i.value + 1) % S.value.length : i.value = (i.value - 1 + S.value.length) % S.value.length, t.value && E(t.value);
308
- const m = s.value;
309
- if (m) {
310
- const _ = m.children[i.value];
311
- _ && _.scrollIntoView({ block: "nearest" });
354
+ showSuggestionsPopup: S,
355
+ highlightedIndex: r,
356
+ completionPlaceholder: p,
357
+ showTabHint: u,
358
+ suggestionsListRef: l,
359
+ filteredSuggestions: E,
360
+ activeSuggestion: a,
361
+ updateCompletionPlaceholder: _,
362
+ updateSuggestionsState: C,
363
+ selectSuggestion: w,
364
+ acceptCurrentSuggestion: m,
365
+ closeSuggestionsPopup: L,
366
+ navigateSuggestions: (g) => {
367
+ if (!S.value || E.value.length === 0) return;
368
+ g === "down" ? r.value = (r.value + 1) % E.value.length : r.value = (r.value - 1 + E.value.length) % E.value.length, a.value && _(a.value);
369
+ const h = l.value;
370
+ if (h) {
371
+ const x = h.children[r.value];
372
+ x && x.scrollIntoView({ block: "nearest" });
312
373
  }
313
374
  },
314
- handleSuggestionItemHover: (h) => {
315
- i.value = h, E(S.value[h]);
375
+ handleSuggestionItemHover: (g) => {
376
+ r.value = g, _(E.value[g]);
316
377
  },
317
378
  handleClickOutside: () => {
318
- K();
379
+ L();
319
380
  },
320
- highlightSuggestionText: it
381
+ highlightSuggestionText: gt
321
382
  };
322
383
  }
323
- const ut = { class: "action-buttons" }, ct = {
384
+ const ht = { class: "action-buttons" }, vt = {
324
385
  key: 0,
325
386
  class: "action-buttons__utility"
326
- }, dt = { class: "action-buttons__submit-content" }, ft = { class: "action-buttons__cancel" }, ke = /* @__PURE__ */ he({
387
+ }, yt = { class: "action-buttons__submit-content" }, bt = { class: "action-buttons__cancel" }, Fe = /* @__PURE__ */ ve({
327
388
  __name: "ActionButtons",
328
389
  props: {
329
390
  loading: { type: Boolean, default: !1 },
@@ -341,34 +402,34 @@ const ut = { class: "action-buttons" }, ct = {
341
402
  isOverLimit: { type: Boolean, default: !1 }
342
403
  },
343
404
  emits: ["clear", "toggle-speech", "submit", "cancel"],
344
- setup(n, { emit: b }) {
345
- const g = Je(), a = n, C = b, i = $(() => a.allowSpeech), f = $(() => a.speechStatus.isRecording), r = $(() => a.disabled), s = $(() => r.value || a.isOverLimit), p = $(() => a.allowFiles || a.allowSpeech || a.showClear), S = () => {
346
- r.value || C("clear");
347
- }, t = () => {
348
- if (!r.value) {
349
- const v = !a.speechStatus.isRecording;
350
- C("toggle-speech", v);
405
+ setup(e, { emit: b }) {
406
+ const f = tt(), o = e, S = b, r = P(() => o.allowSpeech), p = P(() => o.speechStatus.isRecording), u = P(() => o.disabled), l = P(() => u.value || o.isOverLimit), v = P(() => o.allowFiles || o.allowSpeech || o.showClear), E = () => {
407
+ u.value || S("clear");
408
+ }, a = () => {
409
+ if (!u.value) {
410
+ const y = !o.speechStatus.isRecording;
411
+ S("toggle-speech", y);
351
412
  }
352
- }, E = () => {
353
- s.value || C("submit");
413
+ }, _ = () => {
414
+ l.value || S("submit");
354
415
  }, F = () => {
355
- r.value || C("cancel");
416
+ u.value || S("cancel");
356
417
  };
357
- return (v, k) => (R(), O("div", ut, [
358
- p.value ? (R(), O("div", ct, [
359
- v.allowFiles && !v.loading ? (R(), X(w(pe), {
418
+ return (y, C) => (k(), M("div", ht, [
419
+ v.value ? (k(), M("div", vt, [
420
+ y.allowFiles && !y.loading ? (k(), Z(T(me), {
360
421
  key: 0,
361
422
  content: "上传文件",
362
423
  placement: "top"
363
424
  }, {
364
425
  default: G(() => [
365
- U(w(ie), {
426
+ U(T(ue), {
366
427
  class: "action-buttons__button action-buttons__file-button",
367
428
  type: "text",
368
- disabled: r.value
429
+ disabled: u.value
369
430
  }, {
370
431
  default: G(() => [
371
- U(w(Qe), {
432
+ U(T(nt), {
372
433
  class: "action-buttons__icon",
373
434
  alt: "上传文件"
374
435
  })
@@ -377,73 +438,73 @@ const ut = { class: "action-buttons" }, ct = {
377
438
  }, 8, ["disabled"])
378
439
  ]),
379
440
  _: 1
380
- })) : B("", !0),
381
- i.value && !v.loading ? (R(), X(w(ie), {
441
+ })) : $("", !0),
442
+ r.value && !y.loading ? (k(), Z(T(ue), {
382
443
  key: 1,
383
- class: ne(["action-buttons__button action-buttons__speech-button", { "is-recording": f.value }]),
444
+ class: le(["action-buttons__button action-buttons__speech-button", { "is-recording": p.value }]),
384
445
  type: "text",
385
- disabled: r.value,
386
- onClick: t
446
+ disabled: u.value,
447
+ onClick: a
387
448
  }, {
388
449
  default: G(() => [
389
- f.value ? (R(), X(w(Ze), {
450
+ p.value ? (k(), Z(T(lt), {
390
451
  key: 1,
391
452
  class: "action-buttons__icon action-buttons__icon--recording",
392
453
  alt: "语音中"
393
- })) : (R(), X(w(Ye), {
454
+ })) : (k(), Z(T(st), {
394
455
  key: 0,
395
456
  class: "action-buttons__icon",
396
457
  alt: "录音"
397
458
  }))
398
459
  ]),
399
460
  _: 1
400
- }, 8, ["disabled", "class"])) : B("", !0),
401
- v.showClear ? (R(), X(w(pe), {
461
+ }, 8, ["disabled", "class"])) : $("", !0),
462
+ y.showClear ? (k(), Z(T(me), {
402
463
  key: 2,
403
464
  content: "清空内容",
404
465
  placement: "top"
405
466
  }, {
406
467
  default: G(() => [
407
- U(w(ie), {
468
+ U(T(ue), {
408
469
  class: "action-buttons__button action-buttons__clear-button",
409
470
  type: "text",
410
- disabled: r.value || !v.hasContent,
411
- onClick: S
471
+ disabled: u.value || !y.hasContent,
472
+ onClick: E
412
473
  }, {
413
474
  default: G(() => [
414
- (R(), X(He(w(g)), { class: "action-buttons__icon action-buttons__icon--close" }))
475
+ (k(), Z(Ue(T(f)), { class: "action-buttons__icon action-buttons__icon--close" }))
415
476
  ]),
416
477
  _: 1
417
478
  }, 8, ["disabled"])
418
479
  ]),
419
480
  _: 1
420
- })) : B("", !0)
421
- ])) : B("", !0),
422
- v.hasContent || v.loading ? (R(), X(w(ie), {
481
+ })) : $("", !0)
482
+ ])) : $("", !0),
483
+ y.hasContent || y.loading ? (k(), Z(T(ue), {
423
484
  key: 1,
424
485
  type: "text",
425
486
  class: "action-buttons__button action-buttons__submit",
426
- disabled: v.loading ? r.value : s.value,
427
- onClick: k[0] || (k[0] = (x) => v.loading ? F() : E())
487
+ disabled: y.loading ? u.value : l.value,
488
+ onClick: C[0] || (C[0] = (w) => y.loading ? F() : _())
428
489
  }, {
429
490
  default: G(() => [
430
- W("div", dt, [
431
- v.loading ? (R(), X(w(pe), {
491
+ K("div", yt, [
492
+ y.loading ? (k(), Z(T(me), {
432
493
  key: 1,
433
494
  content: "停止生成",
434
495
  placement: "top"
435
496
  }, {
436
497
  default: G(() => [
437
- W("div", ft, [
438
- U(w(tt), {
498
+ K("div", bt, [
499
+ U(T(at), {
439
500
  class: "action-buttons__icon action-buttons__icon--stop",
440
501
  alt: "加载中"
441
502
  }),
442
- k[1] || (k[1] = W("span", { class: "action-buttons__cancel-text" }, "停止回答", -1))
503
+ C[1] || (C[1] = K("span", { class: "action-buttons__cancel-text" }, "停止回答", -1))
443
504
  ])
444
505
  ]),
445
506
  _: 1
446
- })) : (R(), X(w(et), {
507
+ })) : (k(), Z(T(ot), {
447
508
  key: 0,
448
509
  class: "action-buttons__icon action-buttons__icon--send",
449
510
  alt: "发送"
@@ -451,483 +512,511 @@ const ut = { class: "action-buttons" }, ct = {
451
512
  ])
452
513
  ]),
453
514
  _: 1
454
- }, 8, ["disabled"])) : B("", !0)
515
+ }, 8, ["disabled"])) : $("", !0)
455
516
  ]));
456
517
  }
457
518
  });
458
- function pt(n, b) {
459
- const g = I(!1), a = xe({ ...b }), C = (e) => {
460
- Object.assign(a, e);
461
- }, i = (e) => {
462
- const o = [];
463
- let l = 0;
464
- const u = /\[(.*?)\]/g;
519
+ function Ct(e, b) {
520
+ const f = O(!1), o = Le({ ...b }), S = (t) => {
521
+ Object.assign(o, t);
522
+ }, r = (t) => {
523
+ const i = [];
524
+ let n = 0;
525
+ const s = /\[(.*?)\]/g;
465
526
  let d;
466
- for (; (d = u.exec(e)) !== null; )
467
- d.index > l && o.push({ type: "text", content: e.substring(l, d.index) }), o.push({ type: "field", content: d[1] }), l = d.index + d[0].length;
468
- return l < e.length && o.push({ type: "text", content: e.substring(l) }), o;
469
- }, f = () => {
470
- if (!n.value) return "";
471
- let e = "";
472
- const o = (l) => {
473
- let u = "";
474
- if (l.nodeType === Node.TEXT_NODE)
475
- u += l.textContent || "";
476
- else if (l.nodeType === Node.ELEMENT_NODE) {
477
- const d = l;
478
- if (d.classList.contains("template-field"))
479
- u += d.textContent || "";
480
- else if (d.tagName.toLowerCase() === "span")
481
- u += d.textContent || "";
482
- else if (d.tagName.toLowerCase() === "br")
483
- u += `
527
+ for (; (d = s.exec(t)) !== null; )
528
+ d.index > n && i.push({ type: "text", content: t.substring(n, d.index) }), i.push({ type: "field", content: d[1] }), n = d.index + d[0].length;
529
+ return n < t.length && i.push({ type: "text", content: t.substring(n) }), i;
530
+ }, p = () => {
531
+ if (!e.value) return "";
532
+ let t = "";
533
+ const i = (n) => {
534
+ let s = "";
535
+ if (n.nodeType === Node.TEXT_NODE) {
536
+ const d = n.textContent || "";
537
+ s += J(d);
538
+ } else if (n.nodeType === Node.ELEMENT_NODE) {
539
+ const d = n;
540
+ if (d.classList.contains("template-field")) {
541
+ const N = d.textContent || "";
542
+ s += J(N);
543
+ } else if (d.tagName.toLowerCase() === "span") {
544
+ const N = d.textContent || "";
545
+ s += J(N);
546
+ } else if (d.tagName.toLowerCase() === "br")
547
+ s += `
484
548
  `;
485
549
  else
486
- for (const T of Array.from(d.childNodes))
487
- u += o(T);
550
+ for (const N of Array.from(d.childNodes))
551
+ s += i(N);
488
552
  }
489
- return u;
553
+ return s;
490
554
  };
491
- return n.value.childNodes.forEach((l) => {
492
- e += o(l);
493
- }), e;
494
- }, r = (e) => a.initialValues && typeof a.initialValues[e] == "string" ? a.initialValues[e] : "", s = (e, o) => {
495
- const l = document.createElement("span");
496
- return l.className = "template-field", l.setAttribute("data-placeholder", e), o && (l.textContent = o), V(() => {
497
- p(l, o || "");
498
- }), l;
499
- }, p = (e, o) => {
500
- if (!o || o.trim() === "") {
501
- const l = e.getAttribute("data-placeholder") || "";
502
- l ? S(e, l, !0) : (e.style.minWidth = "", e.style.width = "");
503
- return;
504
- }
505
- S(e, o, !1);
506
- }, S = (e, o, l) => {
507
- const u = document.createElement("span");
508
- u.className = "template-field", u.style.visibility = "hidden", u.style.position = "absolute", u.style.top = "-9999px", u.style.left = "-9999px", u.style.whiteSpace = "nowrap", u.style.padding = "3px 8px", u.style.margin = "0 2px", u.style.boxSizing = "border-box", u.textContent = o, document.body.appendChild(u);
509
- const d = getComputedStyle(u), T = u.offsetWidth, D = parseFloat(d.fontSize);
510
- document.body.removeChild(u);
511
- const M = l ? 1.5 : 2, j = T / D, A = Math.max(M, Math.ceil(j));
512
- e.style.setProperty("min-width", `${A}em`, "important");
513
- const q = 20;
514
- A > q ? (e.style.setProperty("max-width", `${q}em`, "important"), e.style.setProperty("white-space", "normal", "important"), e.style.setProperty("word-break", "break-word", "important")) : e.style.removeProperty("max-width");
515
- }, t = (e) => {
516
- const l = (e === void 0 ? f() : e).trim().length > 0;
517
- g.value !== l && (g.value = l, a.onContentStatusChange(l));
518
- }, E = (e, o = "inside", l = !1) => {
519
- V(() => {
520
- const u = window.getSelection();
521
- if (!u) return;
555
+ return e.value.childNodes.forEach((n) => {
556
+ t += i(n);
557
+ }), t;
558
+ }, u = (t) => o.initialValues && typeof o.initialValues[t] == "string" ? o.initialValues[t] : "", l = (t, i) => {
559
+ const n = document.createElement("span");
560
+ return n.className = "template-field", n.setAttribute("data-placeholder", t), i && (n.textContent = i), W(() => {
561
+ v(n, i || "");
562
+ }), n;
563
+ }, v = (t, i) => {
564
+ const n = J(i);
565
+ if (!n || n.trim() === "") {
566
+ const s = t.getAttribute("data-placeholder") || "";
567
+ s ? E(t, s, !0) : (t.style.minWidth = "", t.style.width = "");
568
+ } else
569
+ E(t, n, !1);
570
+ De(t);
571
+ }, E = (t, i, n) => {
572
+ const s = document.createElement("span");
573
+ s.className = "template-field", s.style.visibility = "hidden", s.style.position = "absolute", s.style.top = "-9999px", s.style.left = "-9999px", s.style.whiteSpace = "nowrap", s.style.padding = "3px 8px", s.style.margin = "0 2px", s.style.boxSizing = "border-box", s.textContent = i, document.body.appendChild(s);
574
+ const d = getComputedStyle(s), N = s.offsetWidth, I = parseFloat(d.fontSize);
575
+ document.body.removeChild(s);
576
+ const V = n ? 1.5 : 2, q = N / I, B = Math.max(V, Math.ceil(q));
577
+ t.style.setProperty("min-width", `${B}em`, "important");
578
+ const X = 20;
579
+ B > X ? (t.style.setProperty("max-width", `${X}em`, "important"), t.style.setProperty("white-space", "normal", "important"), t.style.setProperty("word-break", "break-word", "important")) : t.style.removeProperty("max-width");
580
+ }, a = (t) => {
581
+ const n = (t === void 0 ? p() : t).trim().length > 0;
582
+ f.value !== n && (f.value = n, o.onContentStatusChange(n));
583
+ }, _ = (t, i = "inside", n = !1) => {
584
+ W(() => {
585
+ const s = window.getSelection();
586
+ if (!s) return;
522
587
  const d = document.createRange();
523
- switch (o) {
588
+ switch (i) {
524
589
  case "before":
525
- d.setStartBefore(e);
590
+ d.setStartBefore(t);
526
591
  break;
527
592
  case "after":
528
- d.setStartAfter(e);
593
+ d.setStartAfter(t);
529
594
  break;
530
595
  case "inside":
531
596
  default:
532
- d.selectNodeContents(e), d.collapse(l);
597
+ d.selectNodeContents(t), d.collapse(n);
533
598
  break;
534
599
  }
535
- u.removeAllRanges(), u.addRange(d), e.focus && e.focus();
600
+ s.removeAllRanges(), s.addRange(d), t.focus && t.focus();
536
601
  });
537
602
  }, F = () => {
538
- V(() => {
539
- const e = n.value;
540
- if (e) {
541
- const o = document.createRange(), l = window.getSelection();
542
- o.selectNodeContents(e), o.collapse(!1), l && (l.removeAllRanges(), l.addRange(o)), e.focus();
603
+ W(() => {
604
+ const t = e.value;
605
+ if (t) {
606
+ const i = document.createRange(), n = window.getSelection();
607
+ i.selectNodeContents(t), i.collapse(!1), n && (n.removeAllRanges(), n.addRange(i)), t.focus();
543
608
  }
544
609
  });
545
- }, v = (e, o) => {
546
- const l = n.value;
547
- if (!l) return null;
548
- l.innerHTML = "";
549
- let u = null;
550
- if (!o || o === a.template)
551
- e.forEach((d) => {
610
+ }, y = (t, i) => {
611
+ const n = e.value;
612
+ if (!n) return null;
613
+ n.innerHTML = "";
614
+ let s = null;
615
+ if (!i || i === o.template)
616
+ t.forEach((d) => {
552
617
  if (d.type === "field") {
553
- const T = r(d.content), D = s(d.content, T);
554
- l.appendChild(D), u || (u = D);
618
+ const N = u(d.content), I = l(d.content, N);
619
+ n.appendChild(I);
620
+ const V = he();
621
+ n.appendChild(V), s || (s = I);
555
622
  } else
556
- l.appendChild(document.createTextNode(d.content));
557
- }), a.initialValues && Object.keys(a.initialValues).length > 0 && V(() => {
558
- const d = f();
559
- d !== a.value && (a.onValueChange(d), a.onInput(d));
623
+ n.appendChild(document.createTextNode(d.content));
624
+ }), o.initialValues && Object.keys(o.initialValues).length > 0 && W(() => {
625
+ const d = p();
626
+ d !== o.value && (o.onValueChange(d), o.onInput(d));
560
627
  });
561
628
  else {
562
- const d = k(e, o);
563
- d.success ? d.elements.forEach((T) => {
564
- l.appendChild(T.node), T.isField && !u && (u = T.node);
565
- }) : (l.appendChild(document.createTextNode(o)), u = null);
629
+ const d = C(t, i);
630
+ d.success ? d.elements.forEach((N) => {
631
+ if (n.appendChild(N.node), N.isField) {
632
+ const I = he();
633
+ n.appendChild(I);
634
+ }
635
+ N.isField && !s && (s = N.node);
636
+ }) : (n.appendChild(document.createTextNode(i)), s = null);
566
637
  }
567
- return u;
568
- }, k = (e, o) => {
569
- const l = [];
570
- let u = 0, d = 0, T = !0;
571
- for (; d < e.length && u <= o.length && T; ) {
572
- const D = e[d];
573
- if (D.type === "text")
574
- o.substring(u).startsWith(D.content) ? (l.push({
575
- node: document.createTextNode(D.content),
638
+ return s;
639
+ }, C = (t, i) => {
640
+ const n = [];
641
+ let s = 0, d = 0, N = !0;
642
+ for (; d < t.length && s <= i.length && N; ) {
643
+ const I = t[d];
644
+ if (I.type === "text")
645
+ i.substring(s).startsWith(I.content) ? (n.push({
646
+ node: document.createTextNode(I.content),
576
647
  isField: !1
577
- }), u += D.content.length, d++) : T = !1;
648
+ }), s += I.content.length, d++) : N = !1;
578
649
  else {
579
- let M = "";
580
- const j = e.find((A, q) => q > d && A.type === "text");
581
- if (j) {
582
- const A = o.substring(u), q = A.indexOf(j.content);
583
- q !== -1 ? (M = A.substring(0, q), u += M.length) : T = !1;
650
+ let V = "";
651
+ const q = t.find((B, X) => X > d && B.type === "text");
652
+ if (q) {
653
+ const B = i.substring(s), X = B.indexOf(q.content);
654
+ X !== -1 ? (V = B.substring(0, X), s += V.length) : N = !1;
584
655
  } else
585
- M = o.substring(u), u = o.length;
586
- if (T) {
587
- const A = s(D.content, M);
588
- l.push({ node: A, isField: !0 }), d++;
656
+ V = i.substring(s), s = i.length;
657
+ if (N) {
658
+ const B = l(I.content, V);
659
+ n.push({ node: B, isField: !0 }), d++;
589
660
  }
590
661
  }
591
662
  }
592
- if (T && d < e.length)
593
- for (let D = d; D < e.length; D++) {
594
- const M = e[D];
595
- if (M.type === "field") {
596
- const j = !a.value || a.value === "" ? r(M.content) : "", A = s(M.content, j);
597
- l.push({ node: A, isField: !0 });
663
+ if (N && d < t.length)
664
+ for (let I = d; I < t.length; I++) {
665
+ const V = t[I];
666
+ if (V.type === "field") {
667
+ const q = !o.value || o.value === "" ? u(V.content) : "", B = l(V.content, q);
668
+ n.push({ node: B, isField: !0 });
598
669
  } else
599
- l.push({
600
- node: document.createTextNode(M.content),
670
+ n.push({
671
+ node: document.createTextNode(V.content),
601
672
  isField: !1
602
673
  });
603
674
  }
604
- return { success: T, elements: l };
605
- }, x = () => {
606
- if (!n.value) return;
607
- a.isInternalUpdate = !0;
608
- const e = i(a.template), o = v(e, a.value);
609
- t(), V(() => {
610
- h(), o && o.textContent ? E(o, "inside", !1) : o ? E(o, "inside", !0) : F(), a.isInternalUpdate = !1;
675
+ return { success: N, elements: n };
676
+ }, w = () => {
677
+ if (!e.value) return;
678
+ o.isInternalUpdate = !0;
679
+ const t = r(o.template), i = y(t, o.value);
680
+ a(), W(() => {
681
+ if (h(), i) {
682
+ const n = i.textContent || "", s = J(n);
683
+ s && s.trim() !== "" ? _(i, "inside", !1) : _(i, "inside", !0);
684
+ } else
685
+ F();
686
+ o.isInternalUpdate = !1;
611
687
  });
612
- }, y = () => {
613
- if (a.isComposing) return;
614
- K(), z(), h();
615
- const e = f();
616
- e !== a.value && (a.onValueChange(e), a.onInput(e)), t(e), e === "" && n.value && Array.from(n.value.childNodes).every((l) => l.nodeType === Node.ELEMENT_NODE && l.classList.contains("template-field") ? !l.textContent || l.textContent.trim() === "" : !1) && K();
617
- }, K = () => {
618
- if (!n.value) return;
619
- const e = [];
620
- n.value.childNodes.forEach((o) => {
621
- o.nodeType === Node.TEXT_NODE ? (o.textContent || "").trim() === "" && e.push(o) : o.nodeType === Node.ELEMENT_NODE && o.tagName.toLowerCase() === "br" && e.push(o);
622
- }), e.forEach((o) => {
623
- o.parentNode && o.parentNode.removeChild(o);
688
+ }, m = () => {
689
+ if (o.isComposing) return;
690
+ A(), g(), L(), h();
691
+ const t = p();
692
+ t !== o.value && (o.onValueChange(t), o.onInput(t)), a(t), t === "" && e.value && Array.from(e.value.childNodes).every((n) => n.nodeType === Node.ELEMENT_NODE && n.classList.contains("template-field") ? ut(n) : !!(n.nodeType === Node.TEXT_NODE && Q(n.textContent || ""))) && A();
693
+ }, L = () => {
694
+ if (!e.value) return;
695
+ ct(e.value), e.value.querySelectorAll(".template-field").forEach((i) => {
696
+ De(i);
624
697
  });
625
- }, P = (e) => {
626
- if (!a.template || !a.initialValues)
698
+ }, A = () => {
699
+ if (!e.value) return;
700
+ const t = [];
701
+ e.value.childNodes.forEach((i) => {
702
+ if (i.nodeType === Node.TEXT_NODE) {
703
+ const n = i.textContent || "";
704
+ if (Q(n)) {
705
+ const s = i.previousSibling;
706
+ if (s && s.nodeType === Node.ELEMENT_NODE && s.classList.contains("template-field"))
707
+ return;
708
+ }
709
+ (n.trim() === "" || Q(n)) && t.push(i);
710
+ } else i.nodeType === Node.ELEMENT_NODE && i.tagName.toLowerCase() === "br" && t.push(i);
711
+ }), t.forEach((i) => {
712
+ i.parentNode && i.parentNode.removeChild(i);
713
+ });
714
+ }, z = (t) => {
715
+ if (!o.template || !o.initialValues)
627
716
  return "字段";
628
- for (const [o, l] of Object.entries(a.initialValues))
629
- if (l === e)
630
- return o;
631
- return e.length <= 2 || /^[[\]{}()]+$/.test(e) || e.includes("[") && e.includes("]") ? e : "字段";
632
- }, H = (e) => {
633
- const o = e.getAttribute("data-placeholder");
634
- if (o)
635
- return o;
636
- const l = e.getAttribute("title") || e.getAttribute("data-field") || e.getAttribute("data-key") || e.getAttribute("placeholder") || "";
637
- if (l)
638
- return l;
639
- const u = e.textContent || "";
640
- return P(u);
641
- }, z = () => {
642
- if (!n.value) return;
643
- n.value.querySelectorAll("span").forEach((o) => {
644
- const l = o, u = l.style, d = l.classList.contains("template-field"), T = l.hasAttribute("data-placeholder");
645
- if (d && T)
717
+ for (const [i, n] of Object.entries(o.initialValues))
718
+ if (n === t)
719
+ return i;
720
+ return t.length <= 2 || /^[[\]{}()]+$/.test(t) || t.includes("[") && t.includes("]") ? t : "字段";
721
+ }, j = (t) => {
722
+ const i = t.getAttribute("data-placeholder");
723
+ if (i)
724
+ return i;
725
+ const n = t.getAttribute("title") || t.getAttribute("data-field") || t.getAttribute("data-key") || t.getAttribute("placeholder") || "";
726
+ if (n)
727
+ return n;
728
+ const s = t.textContent || "";
729
+ return z(s);
730
+ }, g = () => {
731
+ if (!e.value) return;
732
+ e.value.querySelectorAll("span").forEach((i) => {
733
+ const n = i, s = n.style, d = n.classList.contains("template-field"), N = n.hasAttribute("data-placeholder");
734
+ if (d && N)
646
735
  return;
647
- const D = u.backgroundColor && // 标准格式
648
- (u.backgroundColor === "rgba(0, 0, 0, 0.05)" || u.backgroundColor === "rgba(0, 0, 0, 0.08)" || // 可能的变体格式
649
- u.backgroundColor.includes("rgba(0, 0, 0, 0.05)") || u.backgroundColor.includes("rgba(0, 0, 0, 0.08)") || // 十六进制或其他可能的格式
650
- u.backgroundColor.toLowerCase().includes("0.05") || u.backgroundColor.toLowerCase().includes("0.08")), M = u.borderRadius === "4px" || u.padding === "3px 8px" || u.margin === "0px 2px" || u.whiteSpace === "nowrap" && u.padding && u.margin;
651
- if (D || M || T) {
652
- if (l.className = "template-field", !l.getAttribute("data-placeholder")) {
653
- const A = H(l);
654
- A && l.setAttribute("data-placeholder", A);
736
+ const I = s.backgroundColor && // 标准格式
737
+ (s.backgroundColor === "rgba(0, 0, 0, 0.05)" || s.backgroundColor === "rgba(0, 0, 0, 0.08)" || // 可能的变体格式
738
+ s.backgroundColor.includes("rgba(0, 0, 0, 0.05)") || s.backgroundColor.includes("rgba(0, 0, 0, 0.08)") || // 十六进制或其他可能的格式
739
+ s.backgroundColor.toLowerCase().includes("0.05") || s.backgroundColor.toLowerCase().includes("0.08")), V = s.borderRadius === "4px" || s.padding === "3px 8px" || s.margin === "0px 2px" || s.whiteSpace === "nowrap" && s.padding && s.margin;
740
+ if (I || V || N) {
741
+ if (n.className = "template-field", !n.getAttribute("data-placeholder")) {
742
+ const B = j(n);
743
+ B && n.setAttribute("data-placeholder", B);
655
744
  }
656
- l.removeAttribute("style");
657
- const j = l.textContent || "";
658
- p(l, j);
745
+ n.removeAttribute("style");
746
+ const q = n.textContent || "";
747
+ v(n, q);
659
748
  }
660
749
  });
661
750
  }, h = () => {
662
- if (!n.value) return;
663
- n.value.querySelectorAll(".template-field").forEach((o) => {
664
- const l = o.textContent || "";
665
- p(o, l);
751
+ if (!e.value) return;
752
+ e.value.querySelectorAll(".template-field").forEach((i) => {
753
+ const n = i.textContent || "";
754
+ v(i, n);
666
755
  });
667
756
  };
668
757
  return {
669
758
  // 状态
670
- hasContent: g,
759
+ hasContent: f,
671
760
  // 解析和DOM操作
672
- parseTemplateToParts: i,
673
- getValueFromDOM: f,
674
- getInitialContentForField: r,
675
- createFieldElement: s,
761
+ parseTemplateToParts: r,
762
+ getValueFromDOM: p,
763
+ getInitialContentForField: u,
764
+ createFieldElement: l,
676
765
  // 光标操作
677
- setCursorTo: E,
766
+ setCursorTo: _,
678
767
  setCursorToEnd: F,
679
768
  // DOM更新
680
- updateEditorDOM: x,
681
- renderTemplateToDOM: v,
769
+ updateEditorDOM: w,
770
+ renderTemplateToDOM: y,
682
771
  // 事件处理
683
- handleInput: y,
684
- checkHasContent: t,
685
- cleanupEmptyTextNodes: K,
772
+ handleInput: m,
773
+ checkHasContent: a,
774
+ cleanupEmptyTextNodes: A,
686
775
  // 推断 placeholder
687
- inferPlaceholderForContent: P,
688
- extractPlaceholderFromElement: H,
776
+ inferPlaceholderForContent: z,
777
+ extractPlaceholderFromElement: j,
689
778
  // 方法
690
779
  resetFields: () => {
691
- if (!n.value) return;
692
- a.isInternalUpdate = !0;
693
- const e = n.value;
694
- e.innerHTML = "";
695
- const o = i(a.template);
696
- let l = "";
697
- o.forEach((u) => {
698
- if (u.type === "field") {
699
- const d = r(u.content), T = s(u.content, d);
700
- d && (l += d), e.appendChild(T);
780
+ if (!e.value) return;
781
+ o.isInternalUpdate = !0;
782
+ const t = e.value;
783
+ t.innerHTML = "";
784
+ const i = r(o.template);
785
+ let n = "";
786
+ i.forEach((s) => {
787
+ if (s.type === "field") {
788
+ const d = u(s.content), N = l(s.content, d);
789
+ d && (n += d), t.appendChild(N);
701
790
  } else
702
- e.appendChild(document.createTextNode(u.content)), l += u.content;
703
- }), a.onValueChange(l), F(), t(l), V(() => {
704
- a.isInternalUpdate = !1;
791
+ t.appendChild(document.createTextNode(s.content)), n += s.content;
792
+ }), o.onValueChange(n), F(), a(n), W(() => {
793
+ o.isInternalUpdate = !1;
705
794
  });
706
795
  },
707
796
  activateFirstField: () => {
708
- var o;
709
- const e = (o = n.value) == null ? void 0 : o.querySelector(".template-field");
710
- e ? E(e, "inside", !1) : F();
797
+ var i;
798
+ const t = (i = e.value) == null ? void 0 : i.querySelector(".template-field");
799
+ t ? _(t, "inside", !1) : F();
711
800
  },
712
801
  // 选项更新
713
- updateOptions: C
802
+ updateOptions: S
714
803
  };
715
804
  }
716
- const ht = /* @__PURE__ */ he({
805
+ const wt = /* @__PURE__ */ ve({
717
806
  __name: "TemplateEditor",
718
- props: /* @__PURE__ */ Se({
807
+ props: /* @__PURE__ */ Ne({
719
808
  value: {},
720
809
  autofocus: { type: Boolean }
721
810
  }, {
722
811
  value: { default: "" },
723
812
  valueModifiers: {}
724
813
  }),
725
- emits: /* @__PURE__ */ Se(["input", "content-status", "submit", "focus", "blur", "empty-content"], ["update:value"]),
726
- setup(n, { expose: b, emit: g }) {
727
- const a = je(n, "value"), C = n, i = g, f = I(null), r = I(""), s = I({}), p = I(!1), S = I(!1), t = pt(f, {
728
- template: r.value,
729
- value: a.value,
730
- initialValues: s.value,
731
- isInternalUpdate: p,
732
- isComposing: S,
733
- onValueChange: (h) => {
734
- if (a.value !== h) {
735
- const m = p.value;
736
- p.value = !0, a.value = h, V(() => {
737
- p.value = m;
814
+ emits: /* @__PURE__ */ Ne(["input", "content-status", "submit", "focus", "blur", "empty-content"], ["update:value"]),
815
+ setup(e, { expose: b, emit: f }) {
816
+ const o = Ze(e, "value"), S = e, r = f, p = O(null), u = O(""), l = O({}), v = O(!1), E = O(!1), a = Ct(p, {
817
+ template: u.value,
818
+ value: o.value,
819
+ initialValues: l.value,
820
+ isInternalUpdate: v,
821
+ isComposing: E,
822
+ onValueChange: (g) => {
823
+ if (o.value !== g) {
824
+ const h = v.value;
825
+ v.value = !0, o.value = g, W(() => {
826
+ v.value = h;
738
827
  });
739
828
  }
740
829
  },
741
- onInput: (h) => {
742
- i("input", h);
830
+ onInput: (g) => {
831
+ r("input", g);
743
832
  },
744
- onContentStatusChange: (h) => i("content-status", h),
745
- onSubmit: (h) => i("submit", h)
746
- }), E = at({
747
- editor: f,
748
- isComposing: S,
749
- getValueFromDOM: t.getValueFromDOM,
750
- handleInput: t.handleInput,
751
- onSubmit: (h) => i("submit", h)
752
- }), F = (h, m) => {
753
- let _ = h;
754
- return Object.entries(m).forEach(([e, o]) => {
755
- const l = `[${e}]`;
756
- _ = _.replace(new RegExp(l.replace(/[[\]]/g, "\\$&"), "g"), o);
757
- }), _;
758
- }, v = (h) => {
759
- p.value = !0, r.value = h.template, s.value = h.initialValues || {};
760
- const m = F(r.value, s.value);
761
- t.updateOptions({
762
- template: r.value,
763
- value: m,
833
+ onContentStatusChange: (g) => r("content-status", g),
834
+ onSubmit: (g) => r("submit", g)
835
+ }), _ = ft({
836
+ editor: p,
837
+ isComposing: E,
838
+ getValueFromDOM: a.getValueFromDOM,
839
+ handleInput: a.handleInput,
840
+ onSubmit: (g) => r("submit", g)
841
+ }), F = (g, h) => {
842
+ let x = g;
843
+ return Object.entries(h).forEach(([H, t]) => {
844
+ const i = `[${H}]`;
845
+ x = x.replace(new RegExp(i.replace(/[[\]]/g, "\\$&"), "g"), t);
846
+ }), x;
847
+ }, y = (g) => {
848
+ v.value = !0, u.value = g.template, l.value = g.initialValues || {};
849
+ const h = F(u.value, l.value);
850
+ a.updateOptions({
851
+ template: u.value,
852
+ value: h,
764
853
  // 使用新生成的内容而不是旧的inputValue
765
- initialValues: s.value
766
- }), t.updateEditorDOM(), a.value = m, V(() => {
767
- p.value = !1;
854
+ initialValues: l.value
855
+ }), a.updateEditorDOM(), o.value = h, W(() => {
856
+ v.value = !1;
768
857
  });
769
- }, k = () => {
770
- S.value = !0;
771
- }, x = () => {
772
- S.value = !1, t.handleInput();
773
- }, y = (h) => {
774
- var e;
775
- if (!f.value) return;
776
- const m = h.target;
777
- let _ = null;
778
- if (m.classList.contains("template-field") ? _ = m : (e = m.parentElement) != null && e.classList.contains("template-field") && (_ = m.parentElement), _ && (!_.textContent || _.textContent.trim() === "")) {
779
- const o = window.getSelection(), l = document.createRange();
780
- o && (l.selectNodeContents(_), l.collapse(!0), o.removeAllRanges(), o.addRange(l), _.focus(), h.preventDefault(), h.stopPropagation());
858
+ }, C = () => {
859
+ E.value = !0;
860
+ }, w = () => {
861
+ E.value = !1, a.handleInput();
862
+ }, m = (g) => {
863
+ var H;
864
+ if (!p.value) return;
865
+ const h = g.target;
866
+ let x = null;
867
+ if (h.classList.contains("template-field") ? x = h : (H = h.parentElement) != null && H.classList.contains("template-field") && (x = h.parentElement), x && (!x.textContent || x.textContent.trim() === "")) {
868
+ const t = window.getSelection(), i = document.createRange();
869
+ t && (i.selectNodeContents(x), i.collapse(!0), t.removeAllRanges(), t.addRange(i), x.focus(), g.preventDefault(), g.stopPropagation());
781
870
  }
782
- }, K = (h) => {
783
- h.preventDefault();
784
- const m = h.clipboardData;
785
- if (!m) return;
786
- const _ = m.getData("text/html"), e = m.getData("text/plain");
787
- if (_) {
788
- const o = document.createElement("div");
789
- o.innerHTML = _;
790
- const l = o.querySelectorAll("span");
791
- let u = !1;
792
- if (l.forEach((d) => {
793
- const T = d, D = T.style, M = T.classList.contains("template-field"), j = T.hasAttribute("data-placeholder"), A = D.backgroundColor && // 标准格式
794
- (D.backgroundColor === "rgba(0, 0, 0, 0.05)" || D.backgroundColor === "rgba(0, 0, 0, 0.08)" || // 可能的变体格式
795
- D.backgroundColor.includes("rgba(0, 0, 0, 0.05)") || D.backgroundColor.includes("rgba(0, 0, 0, 0.08)") || // 十六进制或其他可能的格式
796
- D.backgroundColor.toLowerCase().includes("0.05") || D.backgroundColor.toLowerCase().includes("0.08")), q = D.borderRadius === "4px" || D.padding === "3px 8px" || D.margin === "0px 2px" || D.whiteSpace === "nowrap";
797
- if (M || j || A || q) {
798
- if (u = !0, T.className = "template-field", !T.getAttribute("data-placeholder")) {
799
- const ee = t.extractPlaceholderFromElement(T);
800
- ee && T.setAttribute("data-placeholder", ee);
871
+ }, L = (g) => {
872
+ g.preventDefault();
873
+ const h = g.clipboardData;
874
+ if (!h) return;
875
+ const x = h.getData("text/html"), H = h.getData("text/plain");
876
+ if (x) {
877
+ const t = document.createElement("div");
878
+ t.innerHTML = x;
879
+ const i = t.querySelectorAll("span");
880
+ let n = !1;
881
+ if (i.forEach((s) => {
882
+ const d = s, N = d.style, I = d.classList.contains("template-field"), V = d.hasAttribute("data-placeholder"), q = N.backgroundColor && // 标准格式
883
+ (N.backgroundColor === "rgba(0, 0, 0, 0.05)" || N.backgroundColor === "rgba(0, 0, 0, 0.08)" || // 可能的变体格式
884
+ N.backgroundColor.includes("rgba(0, 0, 0, 0.05)") || N.backgroundColor.includes("rgba(0, 0, 0, 0.08)") || // 十六进制或其他可能的格式
885
+ N.backgroundColor.toLowerCase().includes("0.05") || N.backgroundColor.toLowerCase().includes("0.08")), B = N.borderRadius === "4px" || N.padding === "3px 8px" || N.margin === "0px 2px" || N.whiteSpace === "nowrap";
886
+ if (I || V || q || B) {
887
+ if (n = !0, d.className = "template-field", !d.getAttribute("data-placeholder")) {
888
+ const X = a.extractPlaceholderFromElement(d);
889
+ X && d.setAttribute("data-placeholder", X);
801
890
  }
802
- T.removeAttribute("style");
891
+ d.removeAttribute("style");
803
892
  }
804
- }), u) {
805
- P(o);
893
+ }), n) {
894
+ A(t);
806
895
  return;
807
896
  }
808
897
  }
809
- e && H(e);
810
- }, P = (h) => {
811
- const m = window.getSelection();
812
- if (m && m.rangeCount > 0) {
813
- const _ = m.getRangeAt(0);
814
- _.deleteContents();
815
- const e = document.createDocumentFragment();
816
- for (; h.firstChild; )
817
- e.appendChild(h.firstChild);
818
- _.insertNode(e), _.collapse(!1), m.removeAllRanges(), m.addRange(_), z();
898
+ H && z(H);
899
+ }, A = (g) => {
900
+ const h = window.getSelection();
901
+ if (h && h.rangeCount > 0) {
902
+ const x = h.getRangeAt(0);
903
+ x.deleteContents();
904
+ const H = document.createDocumentFragment();
905
+ for (; g.firstChild; )
906
+ H.appendChild(g.firstChild);
907
+ x.insertNode(H), x.collapse(!1), h.removeAllRanges(), h.addRange(x), j();
819
908
  }
820
- }, H = (h) => {
821
- const m = window.getSelection();
822
- if (m && m.rangeCount > 0) {
823
- const _ = m.getRangeAt(0);
824
- _.deleteContents(), _.insertNode(document.createTextNode(h)), _.collapse(!1), m.removeAllRanges(), m.addRange(_), z();
909
+ }, z = (g) => {
910
+ const h = window.getSelection();
911
+ if (h && h.rangeCount > 0) {
912
+ const x = h.getRangeAt(0);
913
+ x.deleteContents(), x.insertNode(document.createTextNode(g)), x.collapse(!1), h.removeAllRanges(), h.addRange(x), j();
825
914
  }
826
- }, z = () => {
827
- S.value = !1, V(() => {
828
- t.handleInput();
829
- const h = t.getValueFromDOM();
830
- if (h !== a.value) {
831
- const m = p.value;
832
- p.value = !0, a.value = h, i("input", h), V(() => {
833
- p.value = m;
915
+ }, j = () => {
916
+ E.value = !1, W(() => {
917
+ a.handleInput();
918
+ const g = a.getValueFromDOM();
919
+ if (g !== o.value) {
920
+ const h = v.value;
921
+ v.value = !0, o.value = g, r("input", g), W(() => {
922
+ v.value = h;
834
923
  });
835
924
  }
836
925
  setTimeout(() => {
837
- const m = t.getValueFromDOM();
838
- m !== a.value && (p.value = !0, a.value = m, i("input", m), V(() => {
839
- p.value = !1;
926
+ const h = a.getValueFromDOM();
927
+ h !== o.value && (v.value = !0, o.value = h, r("input", h), W(() => {
928
+ v.value = !1;
840
929
  }));
841
930
  }, 50);
842
931
  });
843
932
  };
844
- return qe(() => {
845
- r.value && t.updateEditorDOM(), C.autofocus && f.value && t.setCursorToEnd();
846
- }), J(
847
- () => r.value,
933
+ return Ge(() => {
934
+ u.value && a.updateEditorDOM(), S.autofocus && p.value && a.setCursorToEnd();
935
+ }), Y(
936
+ () => u.value,
848
937
  () => {
849
- p.value || (t.updateOptions({
850
- template: r.value,
851
- value: a.value,
852
- initialValues: s.value
853
- }), t.updateEditorDOM());
938
+ v.value || (a.updateOptions({
939
+ template: u.value,
940
+ value: o.value,
941
+ initialValues: l.value
942
+ }), a.updateEditorDOM());
854
943
  }
855
- ), J(
856
- () => s.value,
944
+ ), Y(
945
+ () => l.value,
857
946
  () => {
858
- p.value || (t.updateOptions({
859
- template: r.value,
860
- value: a.value,
861
- initialValues: s.value
862
- }), t.updateEditorDOM());
947
+ v.value || (a.updateOptions({
948
+ template: u.value,
949
+ value: o.value,
950
+ initialValues: l.value
951
+ }), a.updateEditorDOM());
863
952
  },
864
953
  { deep: !0 }
865
- ), J(
866
- () => a.value,
867
- (h) => {
868
- p.value || (t.updateOptions({
869
- template: r.value,
870
- value: h,
871
- initialValues: s.value
872
- }), t.updateEditorDOM()), (!h || h.trim() === "") && i("empty-content");
954
+ ), Y(
955
+ () => o.value,
956
+ (g) => {
957
+ v.value || (a.updateOptions({
958
+ template: u.value,
959
+ value: g,
960
+ initialValues: l.value
961
+ }), a.updateEditorDOM()), (!g || g.trim() === "") && r("empty-content");
873
962
  }
874
963
  ), b({
875
964
  focus: () => {
876
- var h;
877
- (h = f.value) == null || h.focus(), t.setCursorToEnd();
965
+ var g;
966
+ (g = p.value) == null || g.focus(), a.setCursorToEnd();
878
967
  },
879
- resetFields: t.resetFields,
880
- activateFirstField: t.activateFirstField,
881
- getValueFromDOM: t.getValueFromDOM,
882
- setTemplate: v
883
- }), (h, m) => (R(), O("div", {
968
+ resetFields: a.resetFields,
969
+ activateFirstField: a.activateFirstField,
970
+ getValueFromDOM: a.getValueFromDOM,
971
+ setTemplate: y
972
+ }), (g, h) => (k(), M("div", {
884
973
  class: "template-editor",
885
974
  ref_key: "contentEditableRef",
886
- ref: f,
975
+ ref: p,
887
976
  contenteditable: "true",
888
- onInput: m[0] || (m[0] = //@ts-ignore
889
- (..._) => w(t).handleInput && w(t).handleInput(..._)),
890
- onKeydown: m[1] || (m[1] = //@ts-ignore
891
- (..._) => w(E).handleTemplateKeyDown && w(E).handleTemplateKeyDown(..._)),
892
- onClick: y,
893
- onCompositionstart: k,
894
- onCompositionend: x,
895
- onFocus: m[2] || (m[2] = (_) => h.$emit("focus", _)),
896
- onBlur: m[3] || (m[3] = (_) => h.$emit("blur", _)),
897
- onPaste: K
977
+ onInput: h[0] || (h[0] = //@ts-ignore
978
+ (...x) => T(a).handleInput && T(a).handleInput(...x)),
979
+ onKeydown: h[1] || (h[1] = //@ts-ignore
980
+ (...x) => T(_).handleTemplateKeyDown && T(_).handleTemplateKeyDown(...x)),
981
+ onClick: m,
982
+ onCompositionstart: C,
983
+ onCompositionend: w,
984
+ onFocus: h[2] || (h[2] = (x) => g.$emit("focus", x)),
985
+ onBlur: h[3] || (h[3] = (x) => g.$emit("blur", x)),
986
+ onPaste: L
898
987
  }, null, 544));
899
988
  }
900
- }), mt = ["data-theme"], gt = { class: "tiny-sender__container" }, vt = {
989
+ }), St = ["data-theme"], Et = { class: "tiny-sender__container" }, _t = {
901
990
  key: 0,
902
991
  class: "tiny-sender__header-slot"
903
- }, yt = {
992
+ }, Nt = {
904
993
  key: 0,
905
994
  class: "tiny-sender__prefix-slot"
906
- }, bt = { class: "tiny-sender__content-area" }, Ct = {
995
+ }, Tt = { class: "tiny-sender__content-area" }, xt = {
907
996
  key: 0,
908
997
  class: "tiny-sender__decorative-content"
909
- }, wt = {
998
+ }, Rt = {
910
999
  key: 2,
911
1000
  class: "tiny-sender__input-field-wrapper"
912
- }, St = {
1001
+ }, kt = {
913
1002
  key: 0,
914
1003
  class: "tiny-sender__completion-placeholder"
915
- }, _t = { class: "user-input-mirror" }, Et = {
1004
+ }, Dt = { class: "user-input-mirror" }, Ft = {
916
1005
  key: 0,
917
1006
  class: "tiny-sender__tab-hint"
918
- }, Tt = {
1007
+ }, Lt = {
919
1008
  key: 1,
920
1009
  class: "tiny-sender__actions-slot"
921
- }, Nt = { class: "tiny-sender__footer-left" }, kt = { class: "tiny-sender__footer-right" }, xt = { class: "real-word-length" }, Rt = {
1010
+ }, Ot = { class: "tiny-sender__footer-left" }, At = { class: "tiny-sender__footer-right" }, It = { class: "real-word-length" }, Mt = {
922
1011
  key: 1,
923
1012
  class: "tiny-sender__toolbar"
924
- }, Dt = { class: "tiny-sender__buttons-container" }, Ft = {
1013
+ }, Vt = { class: "tiny-sender__buttons-container" }, Bt = {
925
1014
  key: 1,
926
1015
  class: "tiny-sender__footer-slot"
927
- }, Lt = ["onMouseenter", "onMousedown"], It = { class: "suggestion-item__icon" }, Ot = { class: "suggestion-item__text" }, At = {
1016
+ }, Wt = ["onMouseenter", "onMousedown"], $t = { class: "suggestion-item__icon" }, Pt = { class: "suggestion-item__text" }, Kt = {
928
1017
  key: 0,
929
1018
  class: "tiny-sender__error"
930
- }, re = /* @__PURE__ */ he({
1019
+ }, ce = /* @__PURE__ */ ve({
931
1020
  __name: "index",
932
1021
  props: {
933
1022
  autofocus: { type: Boolean, default: !1 },
@@ -952,337 +1041,337 @@ const ht = /* @__PURE__ */ he({
952
1041
  templateInitialValues: { default: () => ({}) }
953
1042
  },
954
1043
  emits: ["update:modelValue", "submit", "clear", "speech-start", "speech-end", "speech-interim", "speech-error", "suggestion-select", "focus", "blur", "escape-press", "cancel", "reset-template"],
955
- setup(n, { expose: b, emit: g }) {
956
- const a = n, C = g, i = I(null), f = I(null), r = I(null), s = I(null), p = I(null), S = I(!1), { inputValue: t, isComposing: E, clearInput: F } = st(a, C), {
957
- showSuggestionsPopup: v,
958
- highlightedIndex: k,
959
- completionPlaceholder: x,
960
- showTabHint: y,
961
- suggestionsListRef: K,
962
- filteredSuggestions: P,
963
- activeSuggestion: H,
964
- updateCompletionPlaceholder: z,
965
- updateSuggestionsState: h,
966
- selectSuggestion: m,
967
- acceptCurrentSuggestion: _,
968
- closeSuggestionsPopup: e,
969
- navigateSuggestions: o,
970
- handleSuggestionItemHover: l,
971
- highlightSuggestionText: u
972
- } = rt(a, C, t, E), d = I(a.mode), T = I(!1), D = () => {
973
- d.value === "single" && (d.value = "multiple", V(() => {
1044
+ setup(e, { expose: b, emit: f }) {
1045
+ const o = e, S = f, r = O(null), p = O(null), u = O(null), l = O(null), v = O(null), E = O(!1), { inputValue: a, isComposing: _, clearInput: F } = rt(o, S), {
1046
+ showSuggestionsPopup: y,
1047
+ highlightedIndex: C,
1048
+ completionPlaceholder: w,
1049
+ showTabHint: m,
1050
+ suggestionsListRef: L,
1051
+ filteredSuggestions: A,
1052
+ activeSuggestion: z,
1053
+ updateCompletionPlaceholder: j,
1054
+ updateSuggestionsState: g,
1055
+ selectSuggestion: h,
1056
+ acceptCurrentSuggestion: x,
1057
+ closeSuggestionsPopup: H,
1058
+ navigateSuggestions: t,
1059
+ handleSuggestionItemHover: i,
1060
+ highlightSuggestionText: n
1061
+ } = mt(o, S, a, _), s = O(o.mode), d = O(!1), N = () => {
1062
+ s.value === "single" && (s.value = "multiple", W(() => {
974
1063
  setTimeout(() => {
975
1064
  const c = document.querySelector(".tiny-textarea__inner");
976
1065
  if (c) {
977
1066
  c.style.whiteSpace = "pre-wrap";
978
- const N = t.value.length;
979
- c.focus(), c.setSelectionRange(N, N);
1067
+ const R = a.value.length;
1068
+ c.focus(), c.setSelectionRange(R, R);
980
1069
  }
981
1070
  }, 50);
982
1071
  }));
983
- }, M = (c, N) => {
984
- const L = document.createElement("span");
985
- L.style.visibility = "hidden", L.style.position = "absolute", L.style.whiteSpace = "nowrap", L.style.font = N, L.textContent = c, document.body.appendChild(L);
986
- const Q = L.offsetWidth;
987
- return document.body.removeChild(L), Q;
988
- }, j = () => {
989
- if (a.mode !== "single" || !i.value || T.value) return;
990
- const N = document.querySelector(".tiny-sender__content-area").querySelector(".tiny-input__inner"), L = p.value || document.querySelector(".tiny-sender__buttons-container");
991
- if (!N) return;
992
- const Q = window.getComputedStyle(N).font, Y = M(t.value, Q), Ke = N.offsetWidth - ((L == null ? void 0 : L.offsetWidth) || 0) - 20;
993
- Y > Ke && d.value === "single" && (T.value = !0, d.value = "multiple", V(() => {
994
- i.value ? setTimeout(() => {
995
- const oe = document.querySelector(".tiny-textarea__inner");
996
- if (oe) {
997
- oe.style.whiteSpace = "pre-wrap";
998
- const we = t.value.length;
999
- oe.focus(), oe.setSelectionRange(we, we);
1072
+ }, I = (c, R) => {
1073
+ const D = document.createElement("span");
1074
+ D.style.visibility = "hidden", D.style.position = "absolute", D.style.whiteSpace = "nowrap", D.style.font = R, D.textContent = c, document.body.appendChild(D);
1075
+ const ee = D.offsetWidth;
1076
+ return document.body.removeChild(D), ee;
1077
+ }, V = () => {
1078
+ if (o.mode !== "single" || !r.value || d.value) return;
1079
+ const R = document.querySelector(".tiny-sender__content-area").querySelector(".tiny-input__inner"), D = v.value || document.querySelector(".tiny-sender__buttons-container");
1080
+ if (!R) return;
1081
+ const ee = window.getComputedStyle(R).font, te = I(a.value, ee), je = R.offsetWidth - ((D == null ? void 0 : D.offsetWidth) || 0) - 20;
1082
+ te > je && s.value === "single" && (d.value = !0, s.value = "multiple", W(() => {
1083
+ r.value ? setTimeout(() => {
1084
+ const re = document.querySelector(".tiny-textarea__inner");
1085
+ if (re) {
1086
+ re.style.whiteSpace = "pre-wrap";
1087
+ const _e = a.value.length;
1088
+ re.focus(), re.setSelectionRange(_e, _e);
1000
1089
  }
1001
- T.value = !1;
1002
- }, 300) : T.value = !1;
1090
+ d.value = !1;
1091
+ }, 300) : d.value = !1;
1003
1092
  }));
1004
- }, A = () => {
1005
- if (S.value && r.value)
1006
- me();
1007
- else if (i.value)
1008
- i.value.focus();
1093
+ }, q = () => {
1094
+ if (E.value && u.value)
1095
+ ye();
1096
+ else if (r.value)
1097
+ r.value.focus();
1009
1098
  else {
1010
1099
  const c = document.querySelector(".tiny-input__inner");
1011
1100
  c == null || c.focus();
1012
1101
  }
1013
- }, q = () => {
1014
- S.value = !1, C("reset-template"), V(() => {
1015
- t.value === "" && (d.value = a.mode || "single"), setTimeout(() => {
1016
- A();
1102
+ }, B = () => {
1103
+ E.value = !1, S("reset-template"), W(() => {
1104
+ a.value === "" && (s.value = o.mode || "single"), setTimeout(() => {
1105
+ q();
1017
1106
  }, 50);
1018
1107
  });
1019
- }, ee = () => {
1108
+ }, X = () => {
1020
1109
  var c;
1021
- F(), S.value ? q() : (c = f.value) == null || c.focus(), V(() => {
1022
- t.value === "" && (d.value = a.mode || "single");
1023
- }), e();
1024
- }, Re = (c) => {
1025
- C("update:modelValue", c);
1026
- }, me = () => {
1027
- r.value && r.value.activateFirstField();
1028
- }, De = (c, N) => {
1029
- S.value = !0, V(() => {
1030
- r.value && r.value.setTemplate({ template: c, initialValues: N });
1110
+ F(), E.value ? B() : (c = p.value) == null || c.focus(), W(() => {
1111
+ a.value === "" && (s.value = o.mode || "single");
1112
+ }), H();
1113
+ }, Ae = (c) => {
1114
+ S("update:modelValue", c);
1115
+ }, ye = () => {
1116
+ u.value && u.value.activateFirstField();
1117
+ }, Ie = (c, R) => {
1118
+ E.value = !0, W(() => {
1119
+ u.value && u.value.setTemplate({ template: c, initialValues: R });
1031
1120
  });
1032
- }, Fe = $(() => {
1033
- const c = typeof a.speech == "object" ? a.speech : {};
1121
+ }, Me = P(() => {
1122
+ const c = typeof o.speech == "object" ? o.speech : {};
1034
1123
  return {
1035
1124
  ...c,
1036
- onStart: () => C("speech-start"),
1037
- onEnd: (N) => C("speech-end", N),
1038
- onInterim: (N) => C("speech-interim", N),
1039
- onFinal: (N) => {
1125
+ onStart: () => S("speech-start"),
1126
+ onEnd: (R) => S("speech-end", R),
1127
+ onInterim: (R) => S("speech-interim", R),
1128
+ onFinal: (R) => {
1040
1129
  if (c.autoReplace)
1041
- t.value = N;
1130
+ a.value = R;
1042
1131
  else {
1043
- const L = t.value;
1044
- L && N && !L.endsWith(" ") && !N.startsWith(" ") && L.length > 0 ? t.value = L + " " + N : t.value = L + N;
1132
+ const D = a.value;
1133
+ D && R && !D.endsWith(" ") && !R.startsWith(" ") && D.length > 0 ? a.value = D + " " + R : a.value = D + R;
1045
1134
  }
1046
- C("speech-end", N);
1135
+ S("speech-end", R);
1047
1136
  },
1048
- onError: (N) => {
1049
- Pe(N.message), C("speech-error", N);
1137
+ onError: (R) => {
1138
+ qe(R.message), S("speech-error", R);
1050
1139
  }
1051
1140
  };
1052
- }), { speechState: le, start: ge, stop: ve } = ot(Fe.value), ue = () => {
1053
- le.isRecording ? ve() : ge();
1054
- }, { handleKeyPress: Le, triggerSubmit: ce } = lt(
1141
+ }), { speechState: ae, start: be, stop: Ce } = pt(Me.value), de = () => {
1142
+ ae.isRecording ? Ce() : be();
1143
+ }, { handleKeyPress: Ve, triggerSubmit: fe } = dt(
1144
+ o,
1145
+ S,
1055
1146
  a,
1056
- C,
1057
- t,
1058
- E,
1059
- le,
1060
- v,
1061
- H,
1062
1147
  _,
1063
- e,
1064
- o,
1065
- ue,
1066
- d,
1067
- D
1068
- ), Ie = (c) => {
1069
- C("focus", c), t.value && P.value.length > 0 && !a.template && (v.value = !0, y.value = !0, k.value === -1 && (k.value = 0), z(H.value || P.value[0]));
1070
- }, Oe = (c) => {
1071
- C("blur", c);
1072
- }, Ae = $(() => d.value === "multiple" ? "textarea" : "text"), Ve = $(
1148
+ ae,
1149
+ y,
1150
+ z,
1151
+ x,
1152
+ H,
1153
+ t,
1154
+ de,
1155
+ s,
1156
+ N
1157
+ ), Be = (c) => {
1158
+ S("focus", c), a.value && A.value.length > 0 && !o.template && (y.value = !0, m.value = !0, C.value === -1 && (C.value = 0), j(z.value || A.value[0]));
1159
+ }, We = (c) => {
1160
+ S("blur", c);
1161
+ }, $e = P(() => s.value === "multiple" ? "textarea" : "text"), Pe = P(
1073
1162
  () => ({
1074
1163
  display: "flex",
1075
- justifyContent: a.showWordLimit && a.maxLength !== 1 / 0 ? "space-between" : "flex-end",
1164
+ justifyContent: o.showWordLimit && o.maxLength !== 1 / 0 ? "space-between" : "flex-end",
1076
1165
  alignItems: "center"
1077
1166
  })
1078
- ), Me = Ue(), Be = $(() => !!Me.decorativeContent), ae = $(() => a.disabled || Be.value), ye = $(() => a.loading), be = $(() => a.hasContent !== void 0 ? a.hasContent : !!t.value), $e = $(() => ({
1079
- "is-disabled": ae.value,
1080
- "is-loading": ye.value,
1081
- "has-error": !!se.value,
1082
- "is-auto-switching": T.value
1083
- })), se = I(""), Pe = (c) => {
1084
- se.value = c, setTimeout(() => se.value = "", 5e3);
1085
- }, We = () => {
1086
- E.value = !1, setTimeout(() => {
1087
- E.value = !1, h();
1167
+ ), Ke = Je(), He = P(() => !!Ke.decorativeContent), ie = P(() => o.disabled || He.value), we = P(() => o.loading), Se = P(() => o.hasContent !== void 0 ? o.hasContent : !!a.value), Xe = P(() => ({
1168
+ "is-disabled": ie.value,
1169
+ "is-loading": we.value,
1170
+ "has-error": !!oe.value,
1171
+ "is-auto-switching": d.value
1172
+ })), oe = O(""), qe = (c) => {
1173
+ oe.value = c, setTimeout(() => oe.value = "", 5e3);
1174
+ }, ze = () => {
1175
+ _.value = !1, setTimeout(() => {
1176
+ _.value = !1, g();
1088
1177
  }, 50);
1089
- }, de = $(() => a.maxLength !== 1 / 0 && t.value.length > a.maxLength);
1090
- return J(t, () => {
1091
- V(j), t.value === "" && a.mode === "single" && (d.value = "single");
1092
- }), J(
1093
- () => S.value,
1178
+ }, pe = P(() => o.maxLength !== 1 / 0 && a.value.length > o.maxLength);
1179
+ return Y(a, () => {
1180
+ W(V), a.value === "" && o.mode === "single" && (s.value = "single");
1181
+ }), Y(
1182
+ () => E.value,
1094
1183
  (c) => {
1095
- c && (d.value = "multiple");
1184
+ c && (s.value = "multiple");
1096
1185
  }
1097
1186
  ), b({
1098
- focus: A,
1187
+ focus: q,
1099
1188
  blur: () => {
1100
- if (i.value)
1101
- i.value.blur();
1189
+ if (r.value)
1190
+ r.value.blur();
1102
1191
  else {
1103
1192
  const c = document.querySelector(".tiny-input__inner");
1104
1193
  c == null || c.blur();
1105
1194
  }
1106
1195
  },
1107
- clear: ee,
1108
- submit: ce,
1109
- startSpeech: ge,
1110
- stopSpeech: ve,
1111
- activateTemplateFirstField: me,
1112
- setTemplate: De
1113
- }), (c, N) => (R(), O("div", {
1196
+ clear: X,
1197
+ submit: fe,
1198
+ startSpeech: be,
1199
+ stopSpeech: Ce,
1200
+ activateTemplateFirstField: ye,
1201
+ setTemplate: Ie
1202
+ }), (c, R) => (k(), M("div", {
1114
1203
  ref_key: "senderRef",
1115
- ref: f,
1116
- class: ne(["tiny-sender", [$e.value, `theme-${c.theme}`, `mode-${d.value}`]]),
1204
+ ref: p,
1205
+ class: le(["tiny-sender", [Xe.value, `theme-${c.theme}`, `mode-${s.value}`]]),
1117
1206
  "data-theme": c.theme
1118
1207
  }, [
1119
- W("div", gt, [
1120
- W("div", {
1208
+ K("div", Et, [
1209
+ K("div", {
1121
1210
  class: "tiny-sender__input-wrapper",
1122
1211
  ref_key: "inputWrapperRef",
1123
- ref: s
1212
+ ref: l
1124
1213
  }, [
1125
- U(fe, { name: "tiny-sender-slide-down" }, {
1214
+ U(ge, { name: "tiny-sender-slide-down" }, {
1126
1215
  default: G(() => [
1127
- c.$slots.header ? (R(), O("div", vt, [
1128
- Z(c.$slots, "header")
1129
- ])) : B("", !0)
1216
+ c.$slots.header ? (k(), M("div", _t, [
1217
+ ne(c.$slots, "header")
1218
+ ])) : $("", !0)
1130
1219
  ]),
1131
1220
  _: 3
1132
1221
  }),
1133
- W("div", {
1134
- class: ne(["tiny-sender__input-row", { "has-prefix": c.$slots.prefix, "has-header": c.$slots.header }])
1222
+ K("div", {
1223
+ class: le(["tiny-sender__input-row", { "has-prefix": c.$slots.prefix, "has-header": c.$slots.header }])
1135
1224
  }, [
1136
- c.$slots.prefix ? (R(), O("div", yt, [
1137
- Z(c.$slots, "prefix")
1138
- ])) : B("", !0),
1139
- W("div", bt, [
1140
- c.$slots.decorativeContent ? (R(), O("div", Ct, [
1141
- Z(c.$slots, "decorativeContent")
1142
- ])) : B("", !0),
1143
- S.value ? (R(), X(ht, {
1225
+ c.$slots.prefix ? (k(), M("div", Nt, [
1226
+ ne(c.$slots, "prefix")
1227
+ ])) : $("", !0),
1228
+ K("div", Tt, [
1229
+ c.$slots.decorativeContent ? (k(), M("div", xt, [
1230
+ ne(c.$slots, "decorativeContent")
1231
+ ])) : $("", !0),
1232
+ E.value ? (k(), Z(wt, {
1144
1233
  key: 1,
1145
1234
  ref_key: "templateEditorRef",
1146
- ref: r,
1147
- value: w(t),
1148
- "onUpdate:value": N[0] || (N[0] = (L) => _e(t) ? t.value = L : null),
1149
- onInput: Re,
1150
- onEmptyContent: q
1151
- }, null, 8, ["value"])) : (R(), O("div", wt, [
1152
- U(w(Ge), {
1235
+ ref: u,
1236
+ value: T(a),
1237
+ "onUpdate:value": R[0] || (R[0] = (D) => Te(a) ? a.value = D : null),
1238
+ onInput: Ae,
1239
+ onEmptyContent: B
1240
+ }, null, 8, ["value"])) : (k(), M("div", Rt, [
1241
+ U(T(et), {
1153
1242
  ref_key: "inputRef",
1154
- ref: i,
1243
+ ref: r,
1155
1244
  autosize: c.autoSize,
1156
- type: Ae.value,
1157
- readonly: ye.value,
1245
+ type: $e.value,
1246
+ readonly: we.value,
1158
1247
  resize: "none",
1159
- modelValue: w(t),
1160
- "onUpdate:modelValue": N[1] || (N[1] = (L) => _e(t) ? t.value = L : null),
1161
- disabled: ae.value,
1248
+ modelValue: T(a),
1249
+ "onUpdate:modelValue": R[1] || (R[1] = (D) => Te(a) ? a.value = D : null),
1250
+ disabled: ie.value,
1162
1251
  placeholder: c.placeholder,
1163
1252
  autofocus: c.autofocus,
1164
- onKeydown: w(Le),
1165
- onCompositionstart: N[2] || (N[2] = (L) => E.value = !0),
1166
- onCompositionend: We,
1167
- onFocus: Ie,
1168
- onBlur: Oe
1253
+ onKeydown: T(Ve),
1254
+ onCompositionstart: R[2] || (R[2] = (D) => _.value = !0),
1255
+ onCompositionend: ze,
1256
+ onFocus: Be,
1257
+ onBlur: We
1169
1258
  }, null, 8, ["autosize", "type", "readonly", "modelValue", "disabled", "placeholder", "autofocus", "onKeydown"]),
1170
- w(x) && !w(E) ? (R(), O("div", St, [
1171
- W("span", _t, te(w(t)), 1),
1172
- Ee(te(w(x)) + " ", 1),
1173
- w(y) ? (R(), O("div", Et, "TAB")) : B("", !0)
1174
- ])) : B("", !0)
1259
+ T(w) && !T(_) ? (k(), M("div", kt, [
1260
+ K("span", Dt, se(T(a)), 1),
1261
+ xe(se(T(w)) + " ", 1),
1262
+ T(m) ? (k(), M("div", Ft, "TAB")) : $("", !0)
1263
+ ])) : $("", !0)
1175
1264
  ]))
1176
1265
  ]),
1177
- d.value === "single" ? (R(), O("div", Tt, [
1178
- W("div", {
1266
+ s.value === "single" ? (k(), M("div", Lt, [
1267
+ K("div", {
1179
1268
  class: "tiny-sender__buttons-container",
1180
1269
  ref_key: "buttonsContainerRef",
1181
- ref: p
1270
+ ref: v
1182
1271
  }, [
1183
- Z(c.$slots, "actions"),
1184
- U(ke, {
1272
+ ne(c.$slots, "actions"),
1273
+ U(Fe, {
1185
1274
  "allow-speech": c.allowSpeech,
1186
1275
  "allow-files": c.allowFiles,
1187
1276
  loading: c.loading,
1188
- disabled: ae.value,
1277
+ disabled: ie.value,
1189
1278
  "show-clear": c.clearable,
1190
- "has-content": be.value,
1191
- "speech-status": w(le),
1279
+ "has-content": Se.value,
1280
+ "speech-status": T(ae),
1192
1281
  "submit-type": c.submitType,
1193
- "is-over-limit": de.value,
1194
- onClear: ee,
1195
- onToggleSpeech: ue,
1196
- onSubmit: w(ce),
1197
- onCancel: N[3] || (N[3] = (L) => c.$emit("cancel"))
1282
+ "is-over-limit": pe.value,
1283
+ onClear: X,
1284
+ onToggleSpeech: de,
1285
+ onSubmit: T(fe),
1286
+ onCancel: R[3] || (R[3] = (D) => c.$emit("cancel"))
1198
1287
  }, null, 8, ["allow-speech", "allow-files", "loading", "disabled", "show-clear", "has-content", "speech-status", "submit-type", "is-over-limit", "onSubmit"])
1199
1288
  ], 512)
1200
- ])) : B("", !0)
1289
+ ])) : $("", !0)
1201
1290
  ], 2),
1202
- U(fe, { name: "tiny-sender-slide-up" }, {
1291
+ U(ge, { name: "tiny-sender-slide-up" }, {
1203
1292
  default: G(() => [
1204
- d.value === "multiple" ? (R(), O("div", {
1293
+ s.value === "multiple" ? (k(), M("div", {
1205
1294
  key: 0,
1206
- style: ze(Ve.value),
1295
+ style: Qe(Pe.value),
1207
1296
  class: "tiny-sender__footer-slot tiny-sender__bottom-row"
1208
1297
  }, [
1209
- W("div", Nt, [
1210
- Z(c.$slots, "footer-left")
1298
+ K("div", Ot, [
1299
+ ne(c.$slots, "footer-left")
1211
1300
  ]),
1212
- W("div", kt, [
1213
- Z(c.$slots, "footer-right"),
1214
- c.showWordLimit && c.maxLength !== 1 / 0 ? (R(), O("div", {
1301
+ K("div", At, [
1302
+ ne(c.$slots, "footer-right"),
1303
+ c.showWordLimit && c.maxLength !== 1 / 0 ? (k(), M("div", {
1215
1304
  key: 0,
1216
- class: ne(["tiny-sender__word-limit", { "is-over-limit": de.value }])
1305
+ class: le(["tiny-sender__word-limit", { "is-over-limit": pe.value }])
1217
1306
  }, [
1218
- W("span", xt, te(w(t).length), 1),
1219
- Ee("/" + te(c.maxLength), 1)
1220
- ], 2)) : B("", !0),
1221
- d.value === "multiple" ? (R(), O("div", Rt, [
1222
- W("div", Dt, [
1223
- U(ke, {
1307
+ K("span", It, se(T(a).length), 1),
1308
+ xe("/" + se(c.maxLength), 1)
1309
+ ], 2)) : $("", !0),
1310
+ s.value === "multiple" ? (k(), M("div", Mt, [
1311
+ K("div", Vt, [
1312
+ U(Fe, {
1224
1313
  "allow-speech": c.allowSpeech,
1225
1314
  "allow-files": c.allowFiles,
1226
1315
  loading: c.loading,
1227
- disabled: ae.value,
1316
+ disabled: ie.value,
1228
1317
  "show-clear": c.clearable,
1229
- "has-content": be.value,
1230
- "speech-status": w(le),
1318
+ "has-content": Se.value,
1319
+ "speech-status": T(ae),
1231
1320
  "submit-type": c.submitType,
1232
- "is-over-limit": de.value,
1233
- onClear: ee,
1234
- onToggleSpeech: ue,
1235
- onSubmit: w(ce),
1236
- onCancel: N[4] || (N[4] = (L) => c.$emit("cancel"))
1321
+ "is-over-limit": pe.value,
1322
+ onClear: X,
1323
+ onToggleSpeech: de,
1324
+ onSubmit: T(fe),
1325
+ onCancel: R[4] || (R[4] = (D) => c.$emit("cancel"))
1237
1326
  }, null, 8, ["allow-speech", "allow-files", "loading", "disabled", "show-clear", "has-content", "speech-status", "submit-type", "is-over-limit", "onSubmit"])
1238
1327
  ])
1239
- ])) : B("", !0)
1328
+ ])) : $("", !0)
1240
1329
  ])
1241
- ], 4)) : c.$slots.footer ? (R(), O("div", Ft, [
1242
- Z(c.$slots, "footer")
1243
- ])) : B("", !0)
1330
+ ], 4)) : c.$slots.footer ? (k(), M("div", Bt, [
1331
+ ne(c.$slots, "footer")
1332
+ ])) : $("", !0)
1244
1333
  ]),
1245
1334
  _: 3
1246
1335
  })
1247
1336
  ], 512)
1248
1337
  ]),
1249
- U(fe, { name: "tiny-sender-slide-up" }, {
1338
+ U(ge, { name: "tiny-sender-slide-up" }, {
1250
1339
  default: G(() => [
1251
- w(v) && w(P).length ? (R(), O("div", {
1340
+ T(y) && T(A).length ? (k(), M("div", {
1252
1341
  key: 0,
1253
1342
  ref_key: "suggestionsListRef",
1254
- ref: K,
1343
+ ref: L,
1255
1344
  class: "tiny-sender__suggestions"
1256
1345
  }, [
1257
- (R(!0), O(Te, null, Ne(w(P), (L, Q) => (R(), O("div", {
1258
- key: Q,
1259
- class: ne(["suggestion-item", { highlighted: Q === w(k) }]),
1260
- onMouseenter: (Y) => w(l)(Q),
1261
- onMousedown: Xe((Y) => w(m)(L), ["prevent"])
1346
+ (k(!0), M(Re, null, ke(T(A), (D, ee) => (k(), M("div", {
1347
+ key: ee,
1348
+ class: le(["suggestion-item", { highlighted: ee === T(C) }]),
1349
+ onMouseenter: (te) => T(i)(ee),
1350
+ onMousedown: Ye((te) => T(h)(D), ["prevent"])
1262
1351
  }, [
1263
- W("span", It, [
1264
- U(w(nt))
1352
+ K("span", $t, [
1353
+ U(T(it))
1265
1354
  ]),
1266
- W("span", Ot, [
1267
- (R(!0), O(Te, null, Ne(w(u)(L, w(t)), (Y, Ce) => (R(), O("span", {
1268
- key: Ce,
1269
- class: ne({ "suggestion-item__text--match": Y.isMatch, "suggestion-item__text--normal": !Y.isMatch })
1270
- }, te(Y.text), 3))), 128))
1355
+ K("span", Pt, [
1356
+ (k(!0), M(Re, null, ke(T(n)(D, T(a)), (te, Ee) => (k(), M("span", {
1357
+ key: Ee,
1358
+ class: le({ "suggestion-item__text--match": te.isMatch, "suggestion-item__text--normal": !te.isMatch })
1359
+ }, se(te.text), 3))), 128))
1271
1360
  ])
1272
- ], 42, Lt))), 128))
1273
- ], 512)) : B("", !0)
1361
+ ], 42, Wt))), 128))
1362
+ ], 512)) : $("", !0)
1274
1363
  ]),
1275
1364
  _: 1
1276
1365
  }),
1277
- se.value ? (R(), O("div", At, te(se.value), 1)) : B("", !0)
1278
- ], 10, mt));
1366
+ oe.value ? (k(), M("div", Kt, se(oe.value), 1)) : $("", !0)
1367
+ ], 10, St));
1279
1368
  }
1280
1369
  });
1281
- re.name = "TrSender";
1282
- const Vt = function(n) {
1283
- n.component(re.name, re);
1370
+ ce.name = "TrSender";
1371
+ const Ht = function(e) {
1372
+ e.component(ce.name, ce);
1284
1373
  };
1285
- re.install = Vt;
1374
+ ce.install = Ht;
1286
1375
  export {
1287
- re as default
1376
+ ce as default
1288
1377
  };