@opentiny/tiny-robot 0.2.4 → 0.2.5

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