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

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