@opentiny/tiny-robot 0.2.4 → 0.2.6

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 $e, computed as P, nextTick as W, defineComponent as be, createElementBlock as A, openBlock as D, createCommentVNode as K, createBlock as Q, unref as E, withCtx as Y, createVNode as G, normalizeClass as ae, resolveDynamicComponent as it, createElementVNode as U, mergeModels as Fe, useModel as rt, onMounted as ut, useSlots as ct, Transition as ve, renderSlot as se, isRef as Le, createTextVNode as Ie, toDisplayString as le, normalizeStyle as Oe, Fragment as Ae, renderList as Me, withModifiers as dt } from "vue";
2
+ import { I as ft } from "../index5.js";
3
+ import { g as z, i as pt, t as mt } from "../utils.js";
4
+ import { B as fe } from "../index3.js";
5
+ import { T as Ve } from "../index4.js";
6
+ import { i as ht } from "../close.js";
7
+ import { I as gt, L as vt, v as yt, w as bt, P as Ct, _ as St } from "../tiny-robot-svgs.js";
8
+ function wt(t, y) {
9
+ const h = 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 !== h.value && (h.value = f);
14
14
  }
15
- ), Y(
16
- () => d.value,
17
- (v) => {
18
- b("update:modelValue", v);
15
+ ), te(
16
+ () => h.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
+ h.value = f, y("update:modelValue", f);
23
+ }, u = (f) => {
24
+ f == null || f.preventDefault();
25
+ const p = h.value;
26
+ !t.disabled && !t.loading && p.trim() && y("submit", p);
27
+ }, i = () => {
28
+ h.value = "", y("update:modelValue", ""), y("clear");
29
+ }, r = I(!1);
30
30
  return {
31
- inputValue: d,
31
+ inputValue: h,
32
32
  inputWrapper: o,
33
- isComposing: u,
34
- handleChange: S,
35
- handleSubmit: i,
36
- handleClear: f,
33
+ isComposing: r,
34
+ handleChange: x,
35
+ handleSubmit: u,
36
+ handleClear: i,
37
37
  clearInput: () => {
38
- f();
38
+ i();
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 Pe = "​", ee = (t) => t.split("").every((y) => y === Pe), J = (t) => t.replace(/\u200B/g, ""), ye = () => document.createTextNode(Pe), Et = (t) => {
43
+ const y = t.textContent || "", h = J(y);
44
+ return !h || h.trim() === "";
45
+ }, Be = (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 h = ye();
50
+ t.parentNode && t.parentNode.insertBefore(h, t.nextSibling);
51
+ }, _t = (t) => {
52
+ Array.from(t.childNodes).forEach((h) => {
53
+ if (h.nodeType === Node.TEXT_NODE && ee(h.textContent || "")) {
54
+ const o = h.previousSibling;
55
+ o && o.nodeType === Node.ELEMENT_NODE && o.classList.contains("template-field") || h.parentNode && h.parentNode.removeChild(h);
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 Tt(t, y, h, o, x, u, i, r, c, f, p, a, b, L) {
60
+ const _ = (m) => !(t.disabled || t.loading || m.trim().length === 0 || a.value), v = () => {
61
+ _(h.value) && y("submit", h.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 V = m.target, H = V.selectionStart, C = h.value;
81
+ h.value = C.substring(0, H) + `
82
+ ` + C.substring(H), setTimeout(() => {
83
+ V.selectionStart = V.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" && u.value && i.value) {
88
+ m.preventDefault(), r();
89
89
  return;
90
90
  }
91
- if (i.value) {
91
+ if (u.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" && i.value) {
101
+ m.preventDefault(), r();
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
+ u.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) && _(h.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 Nt(t) {
115
+ const y = (u, i, r) => {
116
+ var L, _;
117
+ const { startOffset: c, collapsed: f } = i;
118
+ let p = i.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 && u.key === "ArrowLeft", b = p.nodeType === Node.TEXT_NODE && c === (((_ = p.textContent) == null ? void 0 : _.length) || 0) && u.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 w = p.previousSibling;
128
+ !w && p.parentNode && p.parentNode !== r && (w = p.parentNode.previousSibling), w && w.nodeType === Node.ELEMENT_NODE && w.classList.contains("template-field") && (v = w, 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 w = p.nextSibling;
135
+ !w && p.parentNode && p.parentNode !== r && (w = p.parentNode.nextSibling), w && w.nodeType === Node.ELEMENT_NODE && w.classList.contains("template-field") && (v = w, 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
+ u.preventDefault();
139
+ const w = document.createRange(), m = z(r);
140
+ return m && (R === "before" ? w.setStartBefore(v) : R === "after" ? w.setStartAfter(v) : (w.selectNodeContents(v), w.collapse(u.key === "ArrowLeft")), m.removeAllRanges(), m.addRange(w)), !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 || "", w = J(R);
145
+ if (!w || w.trim() === "") {
146
+ u.preventDefault();
147
+ const m = document.createRange(), $ = z(r);
148
+ if (!$) return !0;
149
+ if (u.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 V = p.nextSibling;
153
+ V && V.nodeType === Node.TEXT_NODE && ee(V.textContent || "") ? (m.setStart(V, 0), m.setEnd(V, 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
+ u.preventDefault();
161
+ const w = document.createRange(), m = z(r);
162
+ return m && (u.key === "ArrowLeft" ? v && v.nodeType === Node.ELEMENT_NODE && v.classList.contains("template-field") ? (w.selectNodeContents(v), w.collapse(!1)) : w.setStartBefore(p) : R ? R.nodeType === Node.ELEMENT_NODE && R.classList.contains("template-field") ? (w.selectNodeContents(R), w.collapse(!0)) : pt(r) ? (w.setStart(R, 1), w.collapse(!0)) : w.setStartAfter(p) : w.setStartAfter(p), m.removeAllRanges(), m.addRange(w)), !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
+ }, h = (u, i, r) => {
166
+ if (!i.collapsed) return !1;
167
+ const { startContainer: c, startOffset: f } = i;
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 || "", _ = J(L);
172
+ if (!_ || _.trim() === "") {
173
+ u.preventDefault();
174
+ const v = b.previousSibling, R = c.nextSibling;
175
+ b.parentNode && b.parentNode.removeChild(b), c.parentNode && c.parentNode.removeChild(c);
176
+ const w = z(r);
177
+ if (w) {
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(r, 0), m.collapse(!0), w.removeAllRanges(), w.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
+ u.preventDefault();
184
+ const v = z(r);
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 (J(a).length === 1 && f === a.length) {
196
+ u.preventDefault(), c.textContent = "";
197
+ const L = c.parentNode, _ = z(r);
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
+ u.preventDefault();
209
+ const b = z(r);
210
+ return b && (i.setStartBefore(a), i.collapse(!0), b.removeAllRanges(), b.addRange(i)), !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 = (u, i, r) => {
215
+ if (!i.collapsed) return !1;
216
+ const { startContainer: c, startOffset: f } = i;
217
+ if (c.nodeType === Node.TEXT_NODE && c.parentNode && c.parentNode.classList.contains("template-field") && c.textContent) {
218
+ const a = c.textContent, b = J(a);
219
+ if (f === a.length && b.length === 1) {
220
+ u.preventDefault(), c.textContent = "";
221
+ const L = c.parentNode, _ = z(r);
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: (u) => {
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 i = t.editor.value;
235
+ if (!i) return;
236
+ const r = z(i);
237
+ if (!r || r.rangeCount === 0) return;
238
+ const c = r.getRangeAt(0);
239
+ if (u.key === "Enter") {
240
+ u.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
+ (u.key === "ArrowLeft" || u.key === "ArrowRight") && !u.shiftKey && y(u, c, i) || u.key === "Backspace" && h(u, c, i) || u.key === "Delete" && o(u, c, i);
243
244
  }
244
245
  };
245
246
  }
246
- function gt(t) {
247
- const b = Oe({
247
+ function xt(t) {
248
+ const y = $e({
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) => {
263
- var u;
264
- b.error = new Error(f.error), b.isRecording = !1, (u = t.onError) == null || u.call(t, b.error);
252
+ }), h = y.isSupported ? new (window.webkitSpeechRecognition || window.SpeechRecognition)() : void 0;
253
+ h !== void 0 && (h.continuous = t.continuous ?? !1, h.interimResults = t.interimResults ?? !0, h.lang = t.lang ?? navigator.language, h.onstart = () => {
254
+ var i;
255
+ y.isRecording = !0, y.error = void 0, (i = t.onStart) == null || i.call(t);
256
+ }, h.onend = () => {
257
+ var i;
258
+ y.isRecording = !1, (i = t.onEnd) == null || i.call(t);
259
+ }, h.onresult = (i) => {
260
+ var c, f;
261
+ const r = Array.from(i.results).map((p) => p[0].transcript).join("");
262
+ i.results[0].isFinal ? (c = t.onFinal) == null || c.call(t, r) : (f = t.onInterim) == null || f.call(t, r);
263
+ }, h.onerror = (i) => {
264
+ var r;
265
+ y.error = new Error(i.error), y.isRecording = !1, (r = t.onError) == null || r.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 i;
269
+ if (!h) {
270
+ const r = new Error("浏览器不支持语音识别");
271
+ y.error = r, (i = t.onError) == null || i.call(t, r);
271
272
  return;
272
273
  }
273
- if (b.isRecording) {
274
+ if (y.isRecording) {
274
275
  try {
275
- d.stop(), setTimeout(() => {
276
+ h.stop(), setTimeout(() => {
276
277
  try {
277
- d.start();
278
- } catch (u) {
279
- i(u);
278
+ h.start();
279
+ } catch (r) {
280
+ u(r);
280
281
  }
281
282
  }, 100);
282
- } catch (u) {
283
- i(u);
283
+ } catch (r) {
284
+ u(r);
284
285
  }
285
286
  return;
286
287
  }
287
288
  try {
288
- d.start();
289
- } catch (u) {
290
- i(u);
289
+ h.start();
290
+ } catch (r) {
291
+ u(r);
291
292
  }
292
- }, S = () => {
293
- if (d && b.isRecording)
293
+ }, x = () => {
294
+ if (h && y.isRecording)
294
295
  try {
295
- d.stop();
296
- } catch (f) {
297
- i(f);
296
+ h.stop();
297
+ } catch (i) {
298
+ u(i);
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
+ }, u = (i) => {
301
+ var r;
302
+ y.error = i instanceof Error ? i : new Error("语音识别操作失败"), y.isRecording = !1, (r = t.onError) == null || r.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 kt = (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 h = t.toLowerCase(), o = y.toLowerCase(), x = [];
314
+ let u = 0;
315
+ for (; u < h.length; ) {
316
+ const f = h.indexOf(o, u);
317
+ if (f === -1) break;
318
+ x.push({
319
+ start: f,
320
+ end: f + y.length
321
+ }), u = f + 1;
322
+ }
323
+ if (x.length === 0)
314
324
  return [{ text: t, isMatch: !1 }];
315
325
  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),
326
+ for (const f of x)
327
+ if (i.length === 0)
328
+ i.push(f);
329
+ else {
330
+ const p = i[i.length - 1];
331
+ f.start <= p.end ? p.end = Math.max(p.end, f.end) : i.push(f);
332
+ }
333
+ const r = [];
334
+ let c = 0;
335
+ for (const f of i)
336
+ c < f.start && r.push({
337
+ text: t.substring(c, f.start),
338
+ isMatch: !1
339
+ }), r.push({
340
+ text: t.substring(f.start, f.end),
341
+ isMatch: !0
342
+ }), c = f.end;
343
+ return c < t.length && r.push({
344
+ text: t.substring(c),
324
345
  isMatch: !1
325
- }), i;
346
+ }), r;
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 Rt(t, y, h, o) {
349
+ const x = I(!1), u = I(-1), i = I(-1), r = I(""), c = I(!1), f = I(null), p = I(!1), a = I(null), b = P(() => {
350
+ if (!t.suggestions || !h.value || t.template) return [];
351
+ const e = h.value.toLowerCase();
352
+ return t.suggestions.filter((l) => l.toLowerCase().includes(e));
353
+ }), L = P(() => {
354
+ let e = -1;
355
+ return a.value === "mouse" && i.value !== -1 ? e = i.value : a.value === "keyboard" && u.value !== -1 && (e = u.value), b.value[e] || null;
356
+ }), _ = (e) => e === u.value || e === i.value, v = (e) => {
357
+ if (a.value === null) {
358
+ r.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;
361
+ const l = e || L.value;
362
+ l && h.value && l.toLowerCase().startsWith(h.value.toLowerCase()) ? (r.value = l.substring(h.value.length), c.value = !0) : (r.value = "", c.value = !1);
363
+ }, R = () => {
364
+ x.value = !1, u.value = -1, i.value = -1, a.value = null, r.value = "", c.value = !1;
343
365
  }, w = () => {
344
- o.value || v.value || W(() => {
345
- d.value && t.suggestions && t.suggestions.length > 0 && !t.template && _.value.length > 0 ? y() : F();
366
+ x.value = !0, u.value = -1, i.value = -1, a.value = null, v();
367
+ }, m = () => {
368
+ o.value || p.value || W(() => {
369
+ h.value && t.suggestions && t.suggestions.length > 0 && !t.template && b.value.length > 0 ? w() : 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(h, m), te(() => t.suggestions, m);
373
+ const $ = (e) => {
374
+ p.value = !0, h.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
+ }, V = () => {
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: r,
385
+ showTabHint: c,
386
+ suggestionsListRef: f,
387
+ filteredSuggestions: b,
388
+ activeSuggestion: L,
389
+ isItemHighlighted: _,
390
+ updateCompletionPlaceholder: v,
391
+ updateSuggestionsState: m,
392
+ selectSuggestion: $,
393
+ acceptCurrentSuggestion: V,
394
+ closeSuggestionsPopup: H,
395
+ navigateSuggestions: (e) => {
396
+ if (!x.value || b.value.length === 0) return;
397
+ a.value = "keyboard", u.value === -1 ? u.value = e === "down" ? 0 : b.value.length - 1 : e === "down" ? u.value = (u.value + 1) % b.value.length : u.value = (u.value - 1 + b.value.length) % b.value.length;
398
+ const l = b.value[u.value];
399
+ l && v(l);
400
+ const n = f.value;
401
+ if (n) {
402
+ const s = n.children[u.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", i.value = e, v(b.value[e]);
408
+ },
409
+ handleSuggestionItemLeave: () => {
410
+ if (i.value = -1, u.value !== -1) {
411
+ a.value = "keyboard";
412
+ const e = b.value[u.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: kt
387
421
  };
388
422
  }
389
- const vt = { class: "action-buttons" }, yt = {
423
+ const Dt = { class: "action-buttons" }, Ft = {
390
424
  key: 0,
391
425
  class: "action-buttons__utility"
392
- }, bt = { class: "action-buttons__submit-content" }, Ct = {
426
+ }, Lt = { class: "action-buttons__submit-content" }, It = {
393
427
  key: 1,
394
428
  class: "action-buttons__cancel"
395
- }, Le = /* @__PURE__ */ he({
429
+ }, We = /* @__PURE__ */ be({
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 h = ht(), o = t, x = y, u = P(() => o.allowSpeech), i = P(() => o.speechStatus.isRecording), r = P(() => o.disabled), c = P(() => r.value || o.isOverLimit), f = P(() => o.allowFiles || o.allowSpeech || o.showClear), p = () => {
449
+ r.value || x("clear");
450
+ }, a = () => {
451
+ if (!r.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
+ r.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", Dt, [
461
+ f.value ? (D(), A("div", Ft, [
462
+ _.allowFiles && !_.loading ? (D(), Q(E(Ve), {
429
463
  key: 0,
430
464
  content: "上传文件",
431
465
  placement: "top"
432
466
  }, {
433
- default: J(() => [
434
- U(x(ue), {
467
+ default: Y(() => [
468
+ G(E(fe), {
435
469
  class: "action-buttons__button action-buttons__file-button",
436
470
  type: "text",
437
- disabled: u.value
471
+ disabled: r.value
438
472
  }, {
439
- default: J(() => [
440
- U(x(nt), {
473
+ default: Y(() => [
474
+ G(E(gt), {
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
+ u.value && !_.loading ? (D(), Q(E(fe), {
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": i.value }]),
453
487
  type: "text",
454
- disabled: u.value,
455
- onClick: l
488
+ disabled: r.value,
489
+ onClick: a
456
490
  }, {
457
- default: J(() => [
458
- f.value ? (k(), G(x(ot), {
491
+ default: Y(() => [
492
+ i.value ? (D(), Q(E(yt), {
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(E(vt), {
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(E(Ve), {
471
505
  key: 2,
472
506
  content: "清空内容",
473
507
  placement: "top"
474
508
  }, {
475
- default: J(() => [
476
- U(x(ue), {
509
+ default: Y(() => [
510
+ G(E(fe), {
477
511
  class: "action-buttons__button action-buttons__clear-button",
478
512
  type: "text",
479
- disabled: u.value || !y.hasContent,
480
- onClick: _
513
+ disabled: r.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(it(E(h)), { 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(E(fe), {
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 ? r.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", Lt, [
534
+ _.loading ? (D(), A("div", It, [
535
+ G(E(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(E(bt), {
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;
552
+ function Ot(t, y) {
553
+ const h = I(!1), o = $e({ ...y }), x = (e) => {
554
+ Object.assign(o, e);
555
+ }, u = (e) => {
556
+ const l = [];
557
+ let n = 0;
558
+ const s = /\[(.*?)\]/g;
525
559
  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 = () => {
560
+ for (; (g = s.exec(e)) !== null; )
561
+ g.index > n && l.push({ type: "text", content: e.substring(n, g.index) }), l.push({ type: "field", content: g[1] }), n = g.index + g[0].length;
562
+ return n < e.length && l.push({ type: "text", content: e.substring(n) }), l;
563
+ }, i = () => {
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;
565
+ let e = "";
566
+ const l = (n) => {
567
+ let s = "";
568
+ if (n.nodeType === Node.TEXT_NODE) {
569
+ const g = n.textContent || "";
570
+ s += J(g);
571
+ } else if (n.nodeType === Node.ELEMENT_NODE) {
572
+ const g = n;
539
573
  if (g.classList.contains("template-field")) {
540
574
  const T = g.textContent || "";
541
- a += Z(T);
575
+ s += J(T);
542
576
  } else if (g.tagName.toLowerCase() === "span") {
543
577
  const T = g.textContent || "";
544
- a += Z(T);
578
+ s += J(T);
545
579
  } else if (g.tagName.toLowerCase() === "br")
546
- a += `
580
+ s += `
547
581
  `;
548
582
  else
549
583
  for (const T of Array.from(g.childNodes))
550
- a += r(T);
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
+ }, r = (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 = J(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");
577
- 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) => {
602
+ p(e, n, !1);
603
+ Be(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 g = getComputedStyle(s), T = s.offsetWidth, O = parseFloat(g.fontSize);
608
+ document.body.removeChild(s);
609
+ const M = n ? 1.5 : 2, j = T / O, B = Math.max(M, Math.ceil(j));
610
+ e.style.setProperty("min-width", `${B}em`, "important");
611
+ const X = 20;
612
+ B > X ? (e.style.setProperty("max-width", `${X}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 ? i() : e).trim().length > 0;
615
+ h.value !== n && (h.value = n, o.onContentStatusChange(n));
616
+ }, b = (e, l = "inside", n = !1) => {
583
617
  W(() => {
584
- const a = window.getSelection();
585
- if (!a) return;
618
+ const s = z(t.value);
619
+ if (!s) return;
586
620
  const g = document.createRange();
587
- switch (r) {
621
+ switch (l) {
588
622
  case "before":
589
- g.setStartBefore(n);
623
+ g.setStartBefore(e);
590
624
  break;
591
625
  case "after":
592
- g.setStartAfter(n);
626
+ g.setStartAfter(e);
593
627
  break;
594
628
  case "inside":
595
629
  default:
596
- g.selectNodeContents(n), g.collapse(e);
630
+ g.selectNodeContents(e), g.collapse(n);
597
631
  break;
598
632
  }
599
- a.removeAllRanges(), a.addRange(g), n.focus && n.focus();
633
+ s.removeAllRanges(), s.addRange(g), 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) => {
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((g) => {
616
650
  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);
651
+ const T = r(g.content), O = c(g.content, T);
652
+ n.appendChild(O);
653
+ const M = ye();
654
+ n.appendChild(M), s || (s = O);
621
655
  } else
622
- e.appendChild(document.createTextNode(g.content));
656
+ n.appendChild(document.createTextNode(g.content));
623
657
  }), o.initialValues && Object.keys(o.initialValues).length > 0 && W(() => {
624
- const g = f();
658
+ const g = i();
625
659
  g !== o.value && (o.onValueChange(g), o.onInput(g));
626
660
  });
627
661
  else {
628
- const g = w(n, r);
662
+ const g = v(e, l);
629
663
  g.success ? g.elements.forEach((T) => {
630
- if (e.appendChild(T.node), T.isField) {
631
- const A = me();
632
- e.appendChild(A);
664
+ if (n.appendChild(T.node), T.isField) {
665
+ const O = ye();
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, g = 0, T = !0;
675
+ for (; g < e.length && s <= l.length && T; ) {
676
+ const O = e[g];
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, g++) : T = !1;
648
682
  else {
649
- 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;
683
+ let M = "";
684
+ const j = e.find((B, X) => X > g && B.type === "text");
685
+ if (j) {
686
+ const B = l.substring(s), X = B.indexOf(j.content);
687
+ X !== -1 ? (M = B.substring(0, X), s += M.length) : T = !1;
654
688
  } else
655
- V = r.substring(a), a = r.length;
689
+ M = 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, M);
692
+ n.push({ node: B, isField: !0 }), g++;
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];
665
- 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 });
696
+ if (T && g < e.length)
697
+ for (let O = g; O < e.length; O++) {
698
+ const M = e[O];
699
+ if (M.type === "field") {
700
+ const j = !o.value || o.value === "" ? r(M.content) : "", B = c(M.content, j);
701
+ n.push({ node: B, isField: !0 });
668
702
  } else
669
- e.push({
670
- node: document.createTextNode(V.content),
703
+ n.push({
704
+ node: document.createTextNode(M.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 = u(o.template), l = _(e, o.value);
713
+ a(), W(() => {
714
+ if (S(), l) {
715
+ const n = l.textContent || "", s = J(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
+ }, w = () => {
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 = i();
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") ? Et(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
+ _t(t.value), t.value.querySelectorAll(".template-field").forEach((l) => {
729
+ Be(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
+ }, V = (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 V(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");
765
+ t.value.querySelectorAll("span").forEach((l) => {
766
+ const n = l, s = n.style, g = n.classList.contains("template-field"), T = n.hasAttribute("data-placeholder");
733
767
  if (g && 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")), M = s.borderRadius === "4px" || s.padding === "3px 8px" || s.margin === "0px 2px" || s.whiteSpace === "nowrap" && s.padding && s.margin;
773
+ if (O || M || 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: h,
759
793
  // 解析和DOM操作
760
- parseTemplateToParts: i,
761
- getValueFromDOM: f,
762
- getInitialContentForField: u,
763
- createFieldElement: s,
794
+ parseTemplateToParts: u,
795
+ getValueFromDOM: i,
796
+ getInitialContentForField: r,
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: w,
806
+ checkHasContent: a,
807
+ cleanupEmptyTextNodes: $,
774
808
  // 推断 placeholder
775
- inferPlaceholderForContent: z,
776
- extractPlaceholderFromElement: j,
809
+ inferPlaceholderForContent: V,
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 = u(o.template);
818
+ let n = "";
819
+ l.forEach((s) => {
820
+ if (s.type === "field") {
821
+ const g = r(s.content), T = c(s.content, g);
822
+ g && (n += g), 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 At = /* @__PURE__ */ be({
805
839
  __name: "TemplateEditor",
806
- props: /* @__PURE__ */ _e({
840
+ props: /* @__PURE__ */ Fe({
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__ */ Fe(["input", "content-status", "submit", "focus", "blur", "empty-content"], ["update:value"]),
848
+ setup(t, { expose: y, emit: h }) {
849
+ const o = rt(t, "value"), x = t, u = h, i = I(null), r = I(""), c = I({}), f = I(!1), p = I(!1), a = Ot(i, {
850
+ template: r.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
+ u("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) => u("content-status", C),
867
+ onSubmit: (C) => u("submit", C)
868
+ }), b = Nt({
869
+ editor: i,
870
+ isComposing: p,
871
+ getValueFromDOM: a.getValueFromDOM,
872
+ handleInput: a.handleInput,
873
+ onSubmit: (C) => u("submit", C)
874
+ }), L = (C, S) => {
875
+ let N = C;
876
+ return Object.entries(S).forEach(([q, e]) => {
877
+ const l = `[${q}]`;
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, r.value = C.template, c.value = C.initialValues || {};
882
+ const S = L(r.value, c.value);
883
+ a.updateOptions({
884
+ template: r.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
+ }, w = (C) => {
896
+ var q;
897
+ if (!i.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 : (q = S.parentElement) != null && q.classList.contains("template-field") && (N = S.parentElement), N && (!N.textContent || N.textContent.trim() === "")) {
901
+ const e = z(i.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"), q = 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 g = s, T = g.style, O = g.classList.contains("template-field"), M = g.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 || M || j || B) {
922
+ if (n = !0, g.className = "template-field", !g.getAttribute("data-placeholder")) {
923
+ const X = a.extractPlaceholderFromElement(g);
924
+ X && g.setAttribute("data-placeholder", X);
889
925
  }
890
926
  g.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
+ q && V(q);
934
+ }, $ = (C) => {
935
+ const S = z(i.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 q = document.createDocumentFragment();
940
+ for (; C.firstChild; )
941
+ q.appendChild(C.firstChild);
942
+ N.insertNode(q), 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
+ }, V = (C) => {
945
+ const S = z(i.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, u("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, u("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 ut(() => {
969
+ r.value && a.updateEditorDOM(), x.autofocus && i.value && a.setCursorToEnd();
970
+ }), te(
971
+ () => r.value,
936
972
  () => {
937
- v.value || (l.updateOptions({
938
- template: u.value,
973
+ f.value || (a.updateOptions({
974
+ template: r.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: r.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: r.value,
994
+ value: C,
995
+ initialValues: c.value
996
+ }), a.updateEditorDOM()), (!C || C.trim() === "") && u("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 = i.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: i,
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) => E(a).handleInput && E(a).handleInput(...N)),
1014
+ onKeydown: S[1] || (S[1] = //@ts-ignore
1015
+ (...N) => E(b).handleTemplateKeyDown && E(b).handleTemplateKeyDown(...N)),
1016
+ onClick: w,
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
+ }), Mt = ["data-theme"], Vt = { class: "tiny-sender__container" }, Bt = {
989
1025
  key: 0,
990
1026
  class: "tiny-sender__header-slot"
991
- }, Tt = {
1027
+ }, Wt = {
992
1028
  key: 0,
993
1029
  class: "tiny-sender__prefix-slot"
994
- }, xt = { class: "tiny-sender__content-area" }, Rt = {
1030
+ }, $t = { class: "tiny-sender__content-area" }, Pt = {
995
1031
  key: 0,
996
1032
  class: "tiny-sender__decorative-content"
997
- }, kt = {
1033
+ }, Kt = {
998
1034
  key: 2,
999
1035
  class: "tiny-sender__input-field-wrapper"
1000
- }, Dt = {
1036
+ }, Ht = {
1001
1037
  key: 0,
1002
1038
  class: "tiny-sender__completion-placeholder"
1003
- }, Ft = { class: "user-input-mirror" }, Lt = {
1039
+ }, qt = { class: "user-input-mirror" }, Xt = {
1004
1040
  key: 0,
1005
1041
  class: "tiny-sender__tab-hint"
1006
- }, Ot = {
1042
+ }, zt = {
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
+ }, jt = { class: "tiny-sender__footer-left" }, Ut = { class: "tiny-sender__footer-right" }, Zt = { class: "real-word-length" }, Gt = {
1010
1046
  key: 1,
1011
1047
  class: "tiny-sender__toolbar"
1012
- }, Bt = { class: "tiny-sender__buttons-container" }, Wt = {
1048
+ }, Jt = { class: "tiny-sender__buttons-container" }, Qt = {
1013
1049
  key: 1,
1014
1050
  class: "tiny-sender__footer-slot"
1015
- }, $t = ["onMouseenter", "onMousedown"], Pt = { class: "suggestion-item__text" }, Kt = {
1051
+ }, Yt = ["onMouseenter", "onMousedown"], en = { class: "suggestion-item__text" }, tn = {
1016
1052
  key: 0,
1017
1053
  class: "tiny-sender__error"
1018
- }, ce = /* @__PURE__ */ he({
1054
+ }, pe = /* @__PURE__ */ be({
1019
1055
  __name: "index",
1020
1056
  props: {
1021
1057
  autofocus: { type: Boolean, default: !1 },
@@ -1041,339 +1077,355 @@ 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: h }) {
1081
+ const o = t, x = h, u = I(null), i = I(null), r = I(null), c = I(null), f = I(null), p = I(!1), { inputValue: a, isComposing: b, clearInput: L } = wt(o, x), {
1082
+ showSuggestionsPopup: _,
1083
+ completionPlaceholder: v,
1084
+ showTabHint: R,
1085
+ suggestionsListRef: w,
1086
+ filteredSuggestions: m,
1087
+ activeSuggestion: $,
1088
+ isItemHighlighted: V,
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: q,
1094
+ handleSuggestionItemHover: e,
1095
+ handleSuggestionItemLeave: l,
1096
+ highlightSuggestionText: n
1097
+ } = Rt(o, x, a, b), s = I(o.mode), g = 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
+ }, M = () => {
1114
+ var ce, xe, ke;
1115
+ if (o.mode !== "single" || !u.value || g.value || !i.value || !c.value) return;
1116
+ const d = i.value.querySelector(".tiny-sender__content-area");
1117
+ if (!d) return;
1118
+ const k = ((xe = (ce = u.value) == null ? void 0 : ce.querySelector) == null ? void 0 : xe.call(ce, ".tiny-input__inner")) || d.querySelector(".tiny-input__inner"), F = f.value || i.value.querySelector(".tiny-sender__buttons-container");
1119
+ if (!k) {
1120
+ console.warn("Cannot find input element for overflow check");
1121
+ return;
1122
+ }
1123
+ const ne = k.getBoundingClientRect(), Z = F == null ? void 0 : F.getBoundingClientRect();
1124
+ if (ne.width === 0) {
1125
+ setTimeout(() => M(), 50);
1126
+ return;
1127
+ }
1128
+ const ge = window.getComputedStyle(k).font, nt = O(a.value, ge), Te = (ke = i.value) == null ? void 0 : ke.classList.contains("tr-sender-compact"), st = Te ? 12 : 20, lt = ne.width, at = (Z == null ? void 0 : Z.width) || 0, Ne = lt - at - st, ot = Te ? 50 : 80;
1129
+ nt > Ne && Ne > ot && s.value === "single" && (g.value = !0, s.value = "multiple", W(() => {
1130
+ u.value ? setTimeout(() => {
1131
+ var Re;
1132
+ const de = (Re = i.value) == null ? void 0 : Re.querySelector(".tiny-textarea__inner");
1133
+ if (de) {
1134
+ de.style.whiteSpace = "pre-wrap";
1135
+ const De = a.value.length;
1136
+ de.focus(), de.setSelectionRange(De, De);
1088
1137
  }
1089
- a.value = !1;
1090
- }, 300) : a.value = !1;
1138
+ g.value = !1;
1139
+ }, 300) : g.value = !1;
1091
1140
  }));
1092
- }, V = () => {
1093
- if (_.value && u.value)
1094
- ve();
1095
- else if (i.value)
1096
- i.value.focus();
1141
+ }, j = () => {
1142
+ if (p.value && r.value)
1143
+ Ce();
1144
+ else if (u.value)
1145
+ u.value.focus();
1097
1146
  else {
1098
- const c = document.querySelector(".tiny-input__inner");
1099
- c == null || c.focus();
1147
+ const d = document.querySelector(".tiny-input__inner");
1148
+ d == null || d.focus();
1100
1149
  }
1101
- }, H = () => {
1102
- _.value = !1, S("reset-template"), W(() => {
1103
- l.value === "" && (e.value = o.mode || "single"), setTimeout(() => {
1104
- V();
1150
+ }, B = () => {
1151
+ p.value = !1, x("reset-template"), W(() => {
1152
+ a.value === "" && (s.value = o.mode || "single"), setTimeout(() => {
1153
+ j();
1105
1154
  }, 50);
1106
1155
  });
1107
- }, B = () => {
1108
- var c;
1109
- F(), _.value ? H() : (c = f.value) == null || c.focus(), W(() => {
1110
- l.value === "" && (e.value = o.mode || "single");
1156
+ }, X = () => {
1157
+ var d;
1158
+ L(), p.value ? B() : (d = i.value) == null || d.focus(), W(() => {
1159
+ a.value === "" && (s.value = o.mode || "single");
1111
1160
  }), 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 });
1161
+ }, Ke = (d) => {
1162
+ x("update:modelValue", d);
1163
+ }, Ce = () => {
1164
+ r.value && r.value.activateFirstField();
1165
+ }, He = (d, k) => {
1166
+ p.value = !0, W(() => {
1167
+ r.value && r.value.setTemplate({ template: d, initialValues: k });
1119
1168
  });
1120
- }, Me = $(() => {
1121
- const c = typeof o.speech == "object" ? o.speech : {};
1169
+ }, qe = P(() => {
1170
+ const d = typeof o.speech == "object" ? o.speech : {};
1122
1171
  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;
1172
+ ...d,
1173
+ onStart: () => x("speech-start"),
1174
+ onEnd: (k) => x("speech-end", k),
1175
+ onInterim: (k) => x("speech-interim", k),
1176
+ onFinal: (k) => {
1177
+ if (d.autoReplace)
1178
+ a.value = k;
1130
1179
  else {
1131
- const D = l.value;
1132
- D && R && !D.endsWith(" ") && !R.startsWith(" ") && D.length > 0 ? l.value = D + " " + R : l.value = D + R;
1180
+ const F = a.value;
1181
+ F && k && !F.endsWith(" ") && !k.startsWith(" ") && F.length > 0 ? a.value = F + " " + k : a.value = F + k;
1133
1182
  }
1134
- S("speech-end", R);
1183
+ x("speech-end", k);
1135
1184
  },
1136
- onError: (R) => {
1137
- ze(R.message), S("speech-error", R);
1185
+ onError: (k) => {
1186
+ et(k.message), x("speech-error", k);
1138
1187
  }
1139
1188
  };
1140
- }), { speechState: ae, start: ye, stop: be } = gt(Me.value), de = () => {
1141
- ae.isRecording ? be() : ye();
1142
- }, { handleKeyPress: Ve, triggerSubmit: fe } = ft(
1189
+ }), { speechState: ie, start: Se, stop: we } = xt(qe.value), me = () => {
1190
+ ie.isRecording ? we() : Se();
1191
+ }, re = P(() => o.maxLength !== 1 / 0 && a.value.length > o.maxLength), { handleKeyPress: Xe, triggerSubmit: he } = Tt(
1143
1192
  o,
1193
+ x,
1194
+ a,
1195
+ b,
1196
+ ie,
1197
+ _,
1198
+ $,
1144
1199
  S,
1145
- l,
1146
- E,
1147
- ae,
1148
- y,
1149
- z,
1150
- h,
1151
1200
  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 = $(
1201
+ q,
1202
+ me,
1203
+ re,
1204
+ s,
1205
+ T
1206
+ ), ze = (d) => {
1207
+ x("focus", d), a.value && m.value.length > 0 && !o.template && (_.value = !0, R.value = !0);
1208
+ }, je = (d) => {
1209
+ x("blur", d), N();
1210
+ }, Ue = P(() => s.value === "multiple" ? "textarea" : "text"), Ze = P(
1161
1211
  () => ({
1162
1212
  display: "flex",
1163
1213
  justifyContent: o.showWordLimit && o.maxLength !== 1 / 0 ? "space-between" : "flex-end",
1164
1214
  alignItems: "center"
1165
1215
  })
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),
1216
+ ), Ge = ct(), Je = P(() => !!Ge.decorativeContent), ue = P(() => o.disabled || Je.value), Ee = P(() => o.loading), _e = P(() => o.hasContent !== void 0 ? o.hasContent : !!a.value), Qe = P(() => ({
1217
+ "is-disabled": ue.value,
1218
+ "is-loading": Ee.value,
1219
+ "has-error": !!oe.value,
1220
+ "is-auto-switching": g.value
1221
+ })), Ye = P(() => ({
1222
+ width: mt(o.suggestionPopupWidth),
1173
1223
  maxWidth: "100%"
1174
1224
  // 确保不超出父容器宽度
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();
1225
+ })), oe = I(""), et = (d) => {
1226
+ oe.value = d, setTimeout(() => oe.value = "", 5e3);
1227
+ }, tt = () => {
1228
+ b.value = !1, setTimeout(() => {
1229
+ b.value = !1, H();
1180
1230
  }, 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");
1231
+ };
1232
+ return te(a, () => {
1233
+ W(M), a.value === "" && o.mode === "single" && (s.value = "single");
1234
+ }), te(
1235
+ () => p.value,
1236
+ (d) => {
1237
+ d && (s.value = "multiple");
1188
1238
  }
1189
- ), b({
1190
- focus: V,
1239
+ ), y({
1240
+ focus: j,
1191
1241
  blur: () => {
1192
- if (i.value)
1193
- i.value.blur();
1242
+ if (u.value)
1243
+ u.value.blur();
1194
1244
  else {
1195
- const c = document.querySelector(".tiny-input__inner");
1196
- c == null || c.blur();
1245
+ const d = document.querySelector(".tiny-input__inner");
1246
+ d == null || d.blur();
1197
1247
  }
1198
1248
  },
1199
- clear: B,
1200
- submit: fe,
1201
- startSpeech: ye,
1202
- stopSpeech: be,
1203
- activateTemplateFirstField: ve,
1204
- setTemplate: Ie
1205
- }), (c, R) => (k(), I("div", {
1249
+ clear: X,
1250
+ submit: he,
1251
+ startSpeech: Se,
1252
+ stopSpeech: we,
1253
+ activateTemplateFirstField: Ce,
1254
+ setTemplate: He
1255
+ }), (d, k) => (D(), A("div", {
1206
1256
  ref_key: "senderRef",
1207
- ref: f,
1208
- class: oe(["tiny-sender", [Xe.value, `theme-${c.theme}`, `mode-${e.value}`]]),
1209
- "data-theme": c.theme
1257
+ ref: i,
1258
+ class: ae(["tiny-sender", [Qe.value, `theme-${d.theme}`, `mode-${s.value}`]]),
1259
+ "data-theme": d.theme
1210
1260
  }, [
1211
- X("div", _t, [
1212
- X("div", {
1261
+ U("div", Vt, [
1262
+ U("div", {
1213
1263
  class: "tiny-sender__input-wrapper",
1214
1264
  ref_key: "inputWrapperRef",
1215
- ref: s
1265
+ ref: c
1216
1266
  }, [
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)
1267
+ G(ve, { name: "tiny-sender-slide-down" }, {
1268
+ default: Y(() => [
1269
+ d.$slots.header ? (D(), A("div", Bt, [
1270
+ se(d.$slots, "header")
1271
+ ])) : K("", !0)
1222
1272
  ]),
1223
1273
  _: 3
1224
1274
  }),
1225
- X("div", {
1226
- class: oe(["tiny-sender__input-row", { "has-prefix": c.$slots.prefix, "has-header": c.$slots.header }])
1275
+ U("div", {
1276
+ class: ae(["tiny-sender__input-row", { "has-prefix": d.$slots.prefix, "has-header": d.$slots.header }])
1227
1277
  }, [
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, {
1278
+ d.$slots.prefix ? (D(), A("div", Wt, [
1279
+ se(d.$slots, "prefix")
1280
+ ])) : K("", !0),
1281
+ U("div", $t, [
1282
+ d.$slots.decorativeContent ? (D(), A("div", Pt, [
1283
+ se(d.$slots, "decorativeContent")
1284
+ ])) : K("", !0),
1285
+ p.value ? (D(), Q(At, {
1236
1286
  key: 1,
1237
1287
  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), {
1288
+ ref: r,
1289
+ value: E(a),
1290
+ "onUpdate:value": k[0] || (k[0] = (F) => Le(a) ? a.value = F : null),
1291
+ onInput: Ke,
1292
+ onEmptyContent: B
1293
+ }, null, 8, ["value"])) : (D(), A("div", Kt, [
1294
+ G(E(ft), {
1245
1295
  ref_key: "inputRef",
1246
- ref: i,
1247
- autosize: c.autoSize,
1248
- type: $e.value,
1249
- readonly: Ce.value,
1296
+ ref: u,
1297
+ autosize: d.autoSize,
1298
+ type: Ue.value,
1299
+ readonly: Ee.value,
1250
1300
  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
1301
+ modelValue: E(a),
1302
+ "onUpdate:modelValue": k[1] || (k[1] = (F) => Le(a) ? a.value = F : null),
1303
+ disabled: ue.value,
1304
+ placeholder: d.placeholder,
1305
+ autofocus: d.autofocus,
1306
+ onKeydown: E(Xe),
1307
+ onCompositionstart: k[2] || (k[2] = (F) => b.value = !0),
1308
+ onCompositionend: tt,
1309
+ onFocus: ze,
1310
+ onBlur: je
1261
1311
  }, 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)
1312
+ E(v) && !E(b) ? (D(), A("div", Ht, [
1313
+ U("span", qt, le(E(a)), 1),
1314
+ Ie(le(E(v)) + " ", 1),
1315
+ E(R) ? (D(), A("div", Xt, "TAB")) : K("", !0)
1316
+ ])) : K("", !0)
1267
1317
  ]))
1268
1318
  ]),
1269
- e.value === "single" ? (k(), I("div", Ot, [
1270
- X("div", {
1319
+ s.value === "single" ? (D(), A("div", zt, [
1320
+ U("div", {
1271
1321
  class: "tiny-sender__buttons-container",
1272
1322
  ref_key: "buttonsContainerRef",
1273
- ref: v
1323
+ ref: f
1274
1324
  }, [
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"))
1325
+ se(d.$slots, "actions"),
1326
+ G(We, {
1327
+ "allow-speech": d.allowSpeech,
1328
+ "allow-files": d.allowFiles,
1329
+ loading: d.loading,
1330
+ disabled: ue.value,
1331
+ "show-clear": d.clearable,
1332
+ "has-content": _e.value,
1333
+ "speech-status": E(ie),
1334
+ "submit-type": d.submitType,
1335
+ "is-over-limit": re.value,
1336
+ onClear: X,
1337
+ onToggleSpeech: me,
1338
+ onSubmit: E(he),
1339
+ onCancel: k[3] || (k[3] = (F) => d.$emit("cancel"))
1290
1340
  }, null, 8, ["allow-speech", "allow-files", "loading", "disabled", "show-clear", "has-content", "speech-status", "submit-type", "is-over-limit", "onSubmit"])
1291
1341
  ], 512)
1292
- ])) : P("", !0)
1342
+ ])) : K("", !0)
1293
1343
  ], 2),
1294
- U(ge, { name: "tiny-sender-slide-up" }, {
1295
- default: J(() => [
1296
- e.value === "multiple" ? (k(), I("div", {
1344
+ G(ve, { name: "tiny-sender-slide-up" }, {
1345
+ default: Y(() => [
1346
+ s.value === "multiple" ? (D(), A("div", {
1297
1347
  key: 0,
1298
- style: xe(Pe.value),
1348
+ style: Oe(Ze.value),
1299
1349
  class: "tiny-sender__footer-slot tiny-sender__bottom-row"
1300
1350
  }, [
1301
- X("div", At, [
1302
- ne(c.$slots, "footer-left")
1351
+ U("div", jt, [
1352
+ se(d.$slots, "footer-left")
1303
1353
  ]),
1304
- X("div", It, [
1305
- ne(c.$slots, "footer-right"),
1306
- c.showWordLimit && c.maxLength !== 1 / 0 ? (k(), I("div", {
1354
+ U("div", Ut, [
1355
+ se(d.$slots, "footer-right"),
1356
+ d.showWordLimit && d.maxLength !== 1 / 0 ? (D(), A("div", {
1307
1357
  key: 0,
1308
- class: oe(["tiny-sender__word-limit", { "is-over-limit": pe.value }])
1358
+ class: ae(["tiny-sender__word-limit", { "is-over-limit": re.value }])
1309
1359
  }, [
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"))
1360
+ U("span", Zt, le(E(a).length), 1),
1361
+ Ie("/" + le(d.maxLength), 1)
1362
+ ], 2)) : K("", !0),
1363
+ s.value === "multiple" ? (D(), A("div", Gt, [
1364
+ U("div", Jt, [
1365
+ G(We, {
1366
+ "allow-speech": d.allowSpeech,
1367
+ "allow-files": d.allowFiles,
1368
+ loading: d.loading,
1369
+ disabled: ue.value,
1370
+ "show-clear": d.clearable,
1371
+ "has-content": _e.value,
1372
+ "speech-status": E(ie),
1373
+ "submit-type": d.submitType,
1374
+ "is-over-limit": re.value,
1375
+ onClear: X,
1376
+ onToggleSpeech: me,
1377
+ onSubmit: E(he),
1378
+ onCancel: k[4] || (k[4] = (F) => d.$emit("cancel"))
1329
1379
  }, null, 8, ["allow-speech", "allow-files", "loading", "disabled", "show-clear", "has-content", "speech-status", "submit-type", "is-over-limit", "onSubmit"])
1330
1380
  ])
1331
- ])) : P("", !0)
1381
+ ])) : K("", !0)
1332
1382
  ])
1333
- ], 4)) : c.$slots.footer ? (k(), I("div", Wt, [
1334
- ne(c.$slots, "footer")
1335
- ])) : P("", !0)
1383
+ ], 4)) : d.$slots.footer ? (D(), A("div", Qt, [
1384
+ se(d.$slots, "footer")
1385
+ ])) : K("", !0)
1336
1386
  ]),
1337
1387
  _: 3
1338
1388
  })
1339
1389
  ], 512)
1340
1390
  ]),
1341
- U(ge, { name: "tiny-sender-slide-up" }, {
1342
- default: J(() => [
1343
- x(y) && x(M).length ? (k(), I("div", {
1391
+ G(ve, { name: "tiny-sender-slide-up" }, {
1392
+ default: Y(() => [
1393
+ E(_) && E(m).length ? (D(), A("div", {
1344
1394
  key: 0,
1345
1395
  ref_key: "suggestionsListRef",
1346
- ref: L,
1396
+ ref: w,
1347
1397
  class: "tiny-sender__suggestions",
1348
- style: xe(qe.value)
1398
+ style: Oe(Ye.value)
1349
1399
  }, [
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"])
1400
+ (D(!0), A(Ae, null, Me(E(m), (F, ne) => (D(), A("div", {
1401
+ key: ne,
1402
+ class: ae(["suggestion-item", { highlighted: E(V)(ne) }]),
1403
+ onMouseenter: (Z) => E(e)(ne),
1404
+ onMouseleave: k[5] || (k[5] = //@ts-ignore
1405
+ (...Z) => E(l) && E(l)(...Z)),
1406
+ onMousedown: dt((Z) => E(C)(F), ["prevent"])
1355
1407
  }, [
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))
1408
+ G(E(St), { class: "suggestion-item__icon" }),
1409
+ U("span", en, [
1410
+ (D(!0), A(Ae, null, Me(E(n)(F, E(a)), (Z, ge) => (D(), A("span", {
1411
+ key: ge,
1412
+ class: ae({ "suggestion-item__text--match": Z.isMatch, "suggestion-item__text--normal": !Z.isMatch })
1413
+ }, le(Z.text), 3))), 128))
1362
1414
  ])
1363
- ], 42, $t))), 128))
1364
- ], 4)) : P("", !0)
1415
+ ], 42, Yt))), 128))
1416
+ ], 4)) : K("", !0)
1365
1417
  ]),
1366
1418
  _: 1
1367
1419
  }),
1368
- le.value ? (k(), I("div", Kt, se(le.value), 1)) : P("", !0)
1369
- ], 10, Et));
1420
+ oe.value ? (D(), A("div", tn, le(oe.value), 1)) : K("", !0)
1421
+ ], 10, Mt));
1370
1422
  }
1371
1423
  });
1372
- ce.name = "TrSender";
1373
- const Ht = function(t) {
1374
- t.component(ce.name, ce);
1424
+ pe.name = "TrSender";
1425
+ const nn = function(t) {
1426
+ t.component(pe.name, pe);
1375
1427
  };
1376
- ce.install = Ht;
1428
+ pe.install = nn;
1377
1429
  export {
1378
- ce as default
1430
+ pe as default
1379
1431
  };