@opentiny/tiny-robot 0.2.0 → 0.3.0-alpha.0

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