@opentiny/tiny-robot 0.3.0-alpha.12 → 0.3.0-alpha.14

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,10 +1,10 @@
1
- import { ref as H, watch as ee, reactive as at, computed as L, nextTick as J, defineComponent as me, createElementBlock as R, openBlock as S, createCommentVNode as M, normalizeStyle as Pe, createBlock as Q, unref as C, withCtx as re, createElementVNode as U, createVNode as X, normalizeClass as te, toDisplayString as ae, useAttrs as lt, resolveComponent as rt, mergeProps as ve, Fragment as ie, renderList as ye, mergeModels as it, useModel as ut, Transition as He, withModifiers as ct, useSlots as dt, renderSlot as oe, isRef as ft, createTextVNode as Ge } from "vue";
1
+ import { ref as H, watch as ee, reactive as at, computed as L, nextTick as J, defineComponent as me, createElementBlock as R, openBlock as S, createCommentVNode as M, normalizeStyle as Pe, createBlock as Y, unref as C, withCtx as re, createElementVNode as z, createVNode as X, normalizeClass as te, toDisplayString as ae, useAttrs as lt, resolveComponent as rt, mergeProps as ve, Fragment as ie, renderList as ye, mergeModels as it, useModel as ut, Transition as He, withModifiers as ct, useSlots as dt, renderSlot as oe, isRef as ft, createTextVNode as Ge } from "vue";
2
2
  import { I as pt } from "../index6.js";
3
3
  import { d as ht } from "../index3.js";
4
4
  import { T as Ee } from "../index2.js";
5
- import { B as gt, Z as vt, a as yt, U as mt, O as St, b as wt, S as bt } from "../tiny-robot-svgs.js";
5
+ import { p as gt, u as vt, I as yt, x as mt, i as St, l as wt, z as _t } from "../tiny-robot-svgs.js";
6
6
  import { _ as Oe } from "../_plugin-vue_export-helper.js";
7
- import { t as _t } from "../utils.js";
7
+ import { t as bt } from "../utils.js";
8
8
  function Ct(i, c) {
9
9
  const a = H(i.modelValue || i.defaultValue || ""), u = H(null);
10
10
  ee(
@@ -39,7 +39,7 @@ function Ct(i, c) {
39
39
  }
40
40
  };
41
41
  }
42
- function kt(i, c, a, u, v, w, o, p, _, h, k, g, I, m, P, B) {
42
+ function kt(i, c, a, u, v, w, o, p, b, h, k, g, I, m, P, B) {
43
43
  const A = () => {
44
44
  g.value && (P != null && P.value && (B == null || B()), c("submit", a.value.trim()));
45
45
  }, f = (y, W) => {
@@ -60,9 +60,9 @@ function kt(i, c, a, u, v, w, o, p, _, h, k, g, I, m, P, B) {
60
60
  if (u.value) return;
61
61
  if (y.key === "Enter" && y.shiftKey && (I == null ? void 0 : I.value) === "single" && m) {
62
62
  y.preventDefault(), m();
63
- const K = y.target, q = K.selectionStart, Z = a.value;
64
- a.value = Z.substring(0, q) + `
65
- ` + Z.substring(q), setTimeout(() => {
63
+ const K = y.target, q = K.selectionStart, Q = a.value;
64
+ a.value = Q.substring(0, q) + `
65
+ ` + Q.substring(q), setTimeout(() => {
66
66
  K.selectionStart = K.selectionEnd = q + 1;
67
67
  }, 0);
68
68
  return;
@@ -86,7 +86,7 @@ function kt(i, c, a, u, v, w, o, p, _, h, k, g, I, m, P, B) {
86
86
  }
87
87
  }
88
88
  if (y.key === "Escape") {
89
- w.value ? (_(), y.preventDefault()) : v.isRecording && (k(), y.preventDefault()), c("escape-press");
89
+ w.value ? (b(), y.preventDefault()) : v.isRecording && (k(), y.preventDefault()), c("escape-press");
90
90
  return;
91
91
  }
92
92
  f(y, i.submitType) && (y.preventDefault(), g.value && A());
@@ -107,9 +107,9 @@ function xt(i) {
107
107
  var o;
108
108
  c.isRecording = !1, (o = i.onEnd) == null || o.call(i);
109
109
  }, a.onresult = (o) => {
110
- var _, h;
110
+ var b, h;
111
111
  const p = Array.from(o.results).map((k) => k[0].transcript).join("");
112
- o.results[0].isFinal ? (_ = i.onFinal) == null || _.call(i, p) : (h = i.onInterim) == null || h.call(i, p);
112
+ o.results[0].isFinal ? (b = i.onFinal) == null || b.call(i, p) : (h = i.onInterim) == null || h.call(i, p);
113
113
  }, a.onerror = (o) => {
114
114
  var p;
115
115
  c.error = new Error(o.error), c.isRecording = !1, (p = i.onError) == null || p.call(i, c.error);
@@ -181,22 +181,22 @@ const It = (i, c) => {
181
181
  h.start <= k.end ? k.end = Math.max(k.end, h.end) : o.push(h);
182
182
  }
183
183
  const p = [];
184
- let _ = 0;
184
+ let b = 0;
185
185
  for (const h of o)
186
- _ < h.start && p.push({
187
- text: i.substring(_, h.start),
186
+ b < h.start && p.push({
187
+ text: i.substring(b, h.start),
188
188
  isMatch: !1
189
189
  }), p.push({
190
190
  text: i.substring(h.start, h.end),
191
191
  isMatch: !0
192
- }), _ = h.end;
193
- return _ < i.length && p.push({
194
- text: i.substring(_),
192
+ }), b = h.end;
193
+ return b < i.length && p.push({
194
+ text: i.substring(b),
195
195
  isMatch: !1
196
196
  }), p;
197
197
  };
198
198
  function Rt(i, c, a, u, v) {
199
- const w = H(!1), o = H(-1), p = H(-1), _ = H(""), h = H(!1), k = H(null), g = H(!1), I = H(null), m = L(() => {
199
+ const w = H(!1), o = H(-1), p = H(-1), b = H(""), h = H(!1), k = H(null), g = H(!1), I = H(null), m = L(() => {
200
200
  if (!i.suggestions || !a.value || v.value) return [];
201
201
  const O = a.value.toLowerCase();
202
202
  return i.suggestions.filter((V) => V.toLowerCase().includes(O));
@@ -205,13 +205,13 @@ function Rt(i, c, a, u, v) {
205
205
  return I.value === "mouse" && p.value !== -1 ? O = p.value : I.value === "keyboard" && o.value !== -1 && (O = o.value), m.value[O] || null;
206
206
  }), B = (O) => O === o.value || O === p.value, A = (O) => {
207
207
  if (I.value === null) {
208
- _.value = "", h.value = !1;
208
+ b.value = "", h.value = !1;
209
209
  return;
210
210
  }
211
211
  const V = O || P.value;
212
- V && a.value && V.toLowerCase().startsWith(a.value.toLowerCase()) ? (_.value = V.substring(a.value.length), h.value = !0) : (_.value = "", h.value = !1);
212
+ V && a.value && V.toLowerCase().startsWith(a.value.toLowerCase()) ? (b.value = V.substring(a.value.length), h.value = !0) : (b.value = "", h.value = !1);
213
213
  }, f = () => {
214
- w.value = !1, o.value = -1, p.value = -1, I.value = null, _.value = "", h.value = !1;
214
+ w.value = !1, o.value = -1, p.value = -1, I.value = null, b.value = "", h.value = !1;
215
215
  }, E = () => {
216
216
  w.value = !0, o.value = -1, p.value = -1, I.value = null, A();
217
217
  }, y = () => {
@@ -231,7 +231,7 @@ function Rt(i, c, a, u, v) {
231
231
  };
232
232
  return {
233
233
  showSuggestionsPopup: w,
234
- completionPlaceholder: _,
234
+ completionPlaceholder: b,
235
235
  showTabHint: h,
236
236
  suggestionsListRef: k,
237
237
  filteredSuggestions: m,
@@ -308,23 +308,23 @@ const Ot = { class: "action-buttons" }, Tt = { class: "action-buttons__submit-co
308
308
  return () => f;
309
309
  if (typeof f == "function")
310
310
  return f;
311
- }), o = L(() => a.allowSpeech), p = L(() => a.speechStatus.isRecording), _ = L(() => a.disabled), h = L(() => {
311
+ }), o = L(() => a.allowSpeech), p = L(() => a.speechStatus.isRecording), b = L(() => a.disabled), h = L(() => {
312
312
  var f, E;
313
- return _.value || a.isOverLimit || ((E = (f = a.buttonGroup) == null ? void 0 : f.submit) == null ? void 0 : E.disabled);
313
+ return b.value || a.isOverLimit || ((E = (f = a.buttonGroup) == null ? void 0 : f.submit) == null ? void 0 : E.disabled);
314
314
  }), k = L(() => a.allowFiles || a.allowSpeech || a.showClear), g = () => {
315
- _.value || u("clear");
315
+ b.value || u("clear");
316
316
  }, I = () => {
317
- if (!_.value) {
317
+ if (!b.value) {
318
318
  const f = !a.speechStatus.isRecording;
319
319
  u("toggle-speech", f);
320
320
  }
321
321
  }, m = () => {
322
322
  h.value || u("submit");
323
323
  }, P = () => {
324
- _.value || u("cancel");
324
+ b.value || u("cancel");
325
325
  }, B = L(() => {
326
326
  var f, E;
327
- return _.value || ((E = (f = a.buttonGroup) == null ? void 0 : f.file) == null ? void 0 : E.disabled);
327
+ return b.value || ((E = (f = a.buttonGroup) == null ? void 0 : f.file) == null ? void 0 : E.disabled);
328
328
  }), A = () => {
329
329
  B.value || u("trigger-select");
330
330
  };
@@ -334,7 +334,7 @@ const Ot = { class: "action-buttons" }, Tt = { class: "action-buttons__submit-co
334
334
  class: "action-buttons__utility",
335
335
  style: Pe({ "padding-right": f.hasContent || f.loading ? "0" : "6px" })
336
336
  }, [
337
- f.allowFiles && !f.loading ? (S(), Q(C(Ee), {
337
+ f.allowFiles && !f.loading ? (S(), Y(C(Ee), {
338
338
  key: 0,
339
339
  effect: "light",
340
340
  placement: "top",
@@ -342,7 +342,7 @@ const Ot = { class: "action-buttons" }, Tt = { class: "action-buttons__submit-co
342
342
  "visible-arrow": !1
343
343
  }, {
344
344
  default: re(() => [
345
- U("div", {
345
+ z("div", {
346
346
  class: "action-buttons__button",
347
347
  onClick: A
348
348
  }, [
@@ -359,23 +359,23 @@ const Ot = { class: "action-buttons" }, Tt = { class: "action-buttons__submit-co
359
359
  class: te(["action-buttons__button", { "is-recording": p.value }]),
360
360
  onClick: I
361
361
  }, [
362
- p.value ? (S(), Q(C(yt), {
362
+ p.value ? (S(), Y(C(yt), {
363
363
  key: 1,
364
364
  class: "action-buttons__icon action-buttons__icon--recording",
365
365
  alt: "语音中"
366
- })) : (S(), Q(C(vt), {
366
+ })) : (S(), Y(C(vt), {
367
367
  key: 0,
368
368
  class: "action-buttons__icon",
369
369
  alt: "录音"
370
370
  }))
371
371
  ], 2)) : M("", !0),
372
- f.showClear ? (S(), Q(C(Ee), {
372
+ f.showClear ? (S(), Y(C(Ee), {
373
373
  key: 2,
374
374
  content: "清空内容",
375
375
  placement: "top"
376
376
  }, {
377
377
  default: re(() => [
378
- U("div", {
378
+ z("div", {
379
379
  class: "action-buttons__button",
380
380
  onClick: g
381
381
  }, [
@@ -390,7 +390,7 @@ const Ot = { class: "action-buttons" }, Tt = { class: "action-buttons__submit-co
390
390
  class: "action-buttons__button action-buttons__submit",
391
391
  onClick: E[0] || (E[0] = (y) => f.loading ? P() : m())
392
392
  }, [
393
- U("div", Tt, [
393
+ z("div", Tt, [
394
394
  f.loading ? (S(), R("div", {
395
395
  key: 1,
396
396
  class: te(["action-buttons__cancel", { "action-buttons__cancel--icon-only": !f.stopText }])
@@ -400,7 +400,7 @@ const Ot = { class: "action-buttons" }, Tt = { class: "action-buttons__submit-co
400
400
  alt: "停止"
401
401
  }),
402
402
  f.stopText ? (S(), R("span", $t, ae(f.stopText), 1)) : M("", !0)
403
- ], 2)) : (S(), Q(C(Ee), {
403
+ ], 2)) : (S(), Y(C(Ee), {
404
404
  key: 0,
405
405
  effect: "light",
406
406
  placement: "top",
@@ -438,14 +438,14 @@ const Ot = { class: "action-buttons" }, Tt = { class: "action-buttons__submit-co
438
438
  "data-id": c.id,
439
439
  "data-type": c.type
440
440
  }, C(a)), ae(c.content), 17, Lt)) : (S(), R(ie, { key: 1 }, [
441
- c.asChild ? (S(!0), R(ie, { key: 0 }, ye(c.content, (o) => (S(), Q(w, ve({
441
+ c.asChild ? (S(!0), R(ie, { key: 0 }, ye(c.content, (o) => (S(), Y(w, ve({
442
442
  key: `${o.id}-${o.type}`
443
443
  }, { ref_for: !0 }, o), null, 16))), 128)) : (S(), R("span", ve({
444
444
  key: 1,
445
445
  "data-id": c.id,
446
446
  "data-type": c.type
447
447
  }, C(a)), [
448
- (S(!0), R(ie, null, ye(c.content, (o) => (S(), Q(w, ve({
448
+ (S(!0), R(ie, null, ye(c.content, (o) => (S(), Y(w, ve({
449
449
  key: `${o.id}-${o.type}`
450
450
  }, { ref_for: !0 }, o), null, 16))), 128))
451
451
  ], 16, Et))
@@ -476,10 +476,10 @@ const Pt = { class: "editor-container" }, De = "​", Fe = "​", Wt = /* @__PUR
476
476
  const e = navigator.userAgent;
477
477
  return e.includes("Safari") && !e.includes("Chrome") && !e.includes("Chromium") && !e.includes("CriOS");
478
478
  }
479
- const o = w(), p = () => Math.random().toString(36).substring(2, 15), _ = ut(i, "modelValue"), h = a, k = H(0), g = (e) => e.map((t, s) => ({
479
+ const o = w(), p = () => Math.random().toString(36).substring(2, 15), b = ut(i, "modelValue"), h = a, k = H(0), g = (e) => e.map((t, s) => ({
480
480
  id: `id-${s}`,
481
481
  ...t.type === "template" ? { ...t, prefix: De, suffix: Fe } : t
482
- })), I = (e) => e.map((t) => ({ type: t.type, content: t.content })), m = H(g(_.value || [])), P = (e) => {
482
+ })), I = (e) => e.map((t) => ({ type: t.type, content: t.content })), m = H(g(b.value || [])), P = (e) => {
483
483
  const t = { type: "text", content: "​", id: p() };
484
484
  if (e.length > 0)
485
485
  if (o && e[e.length - 1].type === "template")
@@ -543,13 +543,13 @@ const Pt = { class: "editor-container" }, De = "​", Fe = "​", Wt = /* @__PUR
543
543
  }
544
544
  });
545
545
  ee(
546
- () => _.value,
546
+ () => b.value,
547
547
  (e) => {
548
548
  P(g(e || [])), K.commit(E(m.value));
549
549
  },
550
550
  { deep: !0 }
551
551
  );
552
- const q = (e, t = document.body) => t.contains(e) ? e instanceof HTMLElement && e.dataset.id ? e : e.parentElement ? q(e.parentElement, t) : null : null, Z = (e) => e === f.value, ue = (e) => {
552
+ const q = (e, t = document.body) => t.contains(e) ? e instanceof HTMLElement && e.dataset.id ? e : e.parentElement ? q(e.parentElement, t) : null : null, Q = (e) => e === f.value, ue = (e) => {
553
553
  const t = window.getSelection();
554
554
  if (!t)
555
555
  return null;
@@ -575,13 +575,13 @@ const Pt = { class: "editor-container" }, De = "​", Fe = "​", Wt = /* @__PUR
575
575
  const l = window.getSelection();
576
576
  if (!l)
577
577
  return;
578
- const { node: d, offset: b } = ce(e, t);
578
+ const { node: d, offset: _ } = ce(e, t);
579
579
  if (!s) {
580
- l.setBaseAndExtent(d, b, d, b);
580
+ l.setBaseAndExtent(d, _, d, _);
581
581
  return;
582
582
  }
583
583
  const { node: D, offset: T } = ce(s, r ?? 0);
584
- l.setBaseAndExtent(d, b, D, T);
584
+ l.setBaseAndExtent(d, _, D, T);
585
585
  }, O = (e, t) => {
586
586
  const s = p(), r = { id: s, type: "text", content: e };
587
587
  if (t) {
@@ -595,7 +595,7 @@ const Pt = { class: "editor-container" }, De = "​", Fe = "​", Wt = /* @__PUR
595
595
  var d;
596
596
  const l = (d = f.value) == null ? void 0 : d.querySelector(`[data-id="${s}"][data-type="text"]`);
597
597
  l && G(l, e.length);
598
- }), _.value = I(m.value);
598
+ }), b.value = I(m.value);
599
599
  }, V = H({
600
600
  hasStarted: !1,
601
601
  range: null
@@ -619,14 +619,14 @@ const Pt = { class: "editor-container" }, De = "​", Fe = "​", Wt = /* @__PUR
619
619
  "deleteSoftLineBackward",
620
620
  "deleteSoftLineForward",
621
621
  "deleteByCut"
622
- ], b = ue(f.value);
622
+ ], _ = ue(f.value);
623
623
  if (d.includes(s)) {
624
- if (r && Z(l.startContainer) && Z(l.endContainer)) {
625
- O(r), b && W.set(K.get(), j(b));
624
+ if (r && Q(l.startContainer) && Q(l.endContainer)) {
625
+ O(r), _ && W.set(K.get(), j(_));
626
626
  return;
627
627
  }
628
628
  const T = j(l);
629
- T.startId && T.endId ? (Se(T, s, r), b && W.set(K.get(), j(b))) : console.warn("range is not valid, range:", T);
629
+ T.startId && T.endId ? (Se(T, s, r), _ && W.set(K.get(), j(_))) : console.warn("range is not valid, range:", T);
630
630
  } else s === "insertCompositionText" && V.value.hasStarted && (V.value = { hasStarted: !1, range: j(l) });
631
631
  }, j = (e) => {
632
632
  const t = q(e.startContainer, f.value), s = q(e.endContainer, f.value);
@@ -650,11 +650,11 @@ const Pt = { class: "editor-container" }, De = "​", Fe = "​", Wt = /* @__PUR
650
650
  const d = B.value.findIndex((D) => D.id === r.id);
651
651
  if (d < 0 || d >= B.value.length - 1)
652
652
  return [{ ...r, startOffset: 0, endOffset: 0 }];
653
- const b = B.value[d + 1];
653
+ const _ = B.value[d + 1];
654
654
  return [
655
655
  {
656
- id: b.id,
657
- type: b.type,
656
+ id: _.id,
657
+ type: _.type,
658
658
  startOffset: 0,
659
659
  endOffset: 0
660
660
  }
@@ -663,16 +663,16 @@ const Pt = { class: "editor-container" }, De = "​", Fe = "​", Wt = /* @__PUR
663
663
  const r = we(e);
664
664
  if (!Array.isArray(r) || r.length === 0)
665
665
  return;
666
- const l = ne(r, e, t), d = be(l, e, t, s);
666
+ const l = ne(r, e, t), d = _e(l, e, t, s);
667
667
  if (d.some((T) => T.tag === "new")) {
668
668
  const { afterId: T, content: $ } = d[0];
669
669
  O($, T);
670
670
  return;
671
671
  }
672
- const b = d, D = [];
673
- for (const [T, $] of b.entries()) {
674
- const z = m.value.find((Be) => Be.id === $.id), ge = T === 0 ? s : "";
675
- z ? z.type === "text" ? z.content = N(z.content, ge, $.startOffset, $.endOffset) : z.type === "template" ? $.type === "prefix" || $.type === "suffix" ? $.startOffset === 0 && $.endOffset === 1 && ge.length === 0 ? z[$.type] = "" : console.warn(`${$.type} can not be inserted text. it only can be deleted`, $) : $.startOffset < 0 || $.endOffset > z.content.length ? D.push(z.id) : z.content = N(z.content, ge, $.startOffset, $.endOffset) : console.warn("dataItem.type is not text or template", z) : console.warn("can not find dataItem", $);
672
+ const _ = d, D = [];
673
+ for (const [T, $] of _.entries()) {
674
+ const U = m.value.find((Be) => Be.id === $.id), ge = T === 0 ? s : "";
675
+ U ? U.type === "text" ? U.content = N(U.content, ge, $.startOffset, $.endOffset) : U.type === "template" ? $.type === "prefix" || $.type === "suffix" ? $.startOffset === 0 && $.endOffset === 1 && ge.length === 0 ? U[$.type] = "" : console.warn(`${$.type} can not be inserted text. it only can be deleted`, $) : $.startOffset < 0 || $.endOffset > U.content.length ? D.push(U.id) : U.content = N(U.content, ge, $.startOffset, $.endOffset) : console.warn("dataItem.type is not text or template", U) : console.warn("can not find dataItem", $);
676
676
  }
677
677
  P(m.value.filter((T) => !D.includes(T.id))), P(
678
678
  m.value.filter((T) => {
@@ -684,12 +684,12 @@ const Pt = { class: "editor-container" }, De = "​", Fe = "​", Wt = /* @__PUR
684
684
  );
685
685
  for (const T of m.value.filter(($) => $.type === "template"))
686
686
  T.prefix.length === 0 && (T.prefix = De), T.suffix.length === 0 && (T.suffix = Fe);
687
- b.length > 0 && Te(b, s), _.value = I(m.value);
687
+ _.length > 0 && Te(_, s), b.value = I(m.value);
688
688
  }, Te = (e, t) => {
689
689
  const s = e[0], r = `[data-id="${s.id}"][data-type="${s.type}"]`, l = e.slice(1).map((d) => `[data-id="${d.id}"][data-type="${d.type}"]`);
690
690
  J(() => {
691
- var b, D;
692
- const d = (b = f.value) == null ? void 0 : b.querySelector(r);
691
+ var _, D;
692
+ const d = (_ = f.value) == null ? void 0 : _.querySelector(r);
693
693
  if (d)
694
694
  G(d, s.startOffset + t.length);
695
695
  else if (t.length === 0)
@@ -704,7 +704,7 @@ const Pt = { class: "editor-container" }, De = "​", Fe = "​", Wt = /* @__PUR
704
704
  console.warn(`can not find el with selector: ${r}`);
705
705
  });
706
706
  }, we = (e) => {
707
- const t = B.value.findIndex((b) => b.id === e.startId && b.type === e.startType), s = B.value.findIndex((b) => b.id === e.endId && b.type === e.endType);
707
+ const t = B.value.findIndex((_) => _.id === e.startId && _.type === e.startType), s = B.value.findIndex((_) => _.id === e.endId && _.type === e.endType);
708
708
  if (t === -1 || s === -1 || t > s)
709
709
  return console.warn("startIndex or endIndex is -1, or startIndex > endIndex. ", { range: e }), null;
710
710
  const r = B.value[t], l = B.value[s];
@@ -725,8 +725,8 @@ const Pt = { class: "editor-container" }, De = "​", Fe = "​", Wt = /* @__PUR
725
725
  endOffset: r.content.length
726
726
  }
727
727
  ];
728
- for (let b = t + 1; b < s; b++) {
729
- const D = B.value[b];
728
+ for (let _ = t + 1; _ < s; _++) {
729
+ const D = B.value[_];
730
730
  d.push({
731
731
  id: D.id,
732
732
  type: D.type,
@@ -740,7 +740,7 @@ const Pt = { class: "editor-container" }, De = "​", Fe = "​", Wt = /* @__PUR
740
740
  startOffset: 0,
741
741
  endOffset: e.endOffset
742
742
  }), d;
743
- }, be = (e, t, s, r) => {
743
+ }, _e = (e, t, s, r) => {
744
744
  const l = e[0];
745
745
  if (l.type !== "prefix" && l.type !== "suffix")
746
746
  return e;
@@ -775,11 +775,11 @@ const Pt = { class: "editor-container" }, De = "​", Fe = "​", Wt = /* @__PUR
775
775
  }, de = (e, t, s = 0) => {
776
776
  const r = B.value.findIndex((l) => l.id === e.id && l.type === e.type);
777
777
  if (r > 0) {
778
- const l = B.value[r - 1], { id: d, type: b, content: D } = l;
779
- if (b === "text" || b === "template")
778
+ const l = B.value[r - 1], { id: d, type: _, content: D } = l;
779
+ if (_ === "text" || _ === "template")
780
780
  return {
781
781
  id: d,
782
- type: b,
782
+ type: _,
783
783
  startOffset: D.length - s,
784
784
  endOffset: D.length
785
785
  };
@@ -792,11 +792,11 @@ const Pt = { class: "editor-container" }, De = "​", Fe = "​", Wt = /* @__PUR
792
792
  }, se = (e, t, s = 0) => {
793
793
  const r = B.value.findIndex((l) => l.id === e.id && l.type === e.type);
794
794
  if (r < B.value.length - 1) {
795
- const l = B.value[r + 1], { id: d, type: b } = l;
796
- if (b === "text" || b === "template")
795
+ const l = B.value[r + 1], { id: d, type: _ } = l;
796
+ if (_ === "text" || _ === "template")
797
797
  return {
798
798
  id: d,
799
- type: b,
799
+ type: _,
800
800
  startOffset: 0,
801
801
  endOffset: 0 + s
802
802
  };
@@ -810,14 +810,14 @@ const Pt = { class: "editor-container" }, De = "​", Fe = "​", Wt = /* @__PUR
810
810
  V.value = { hasStarted: !0, range: null };
811
811
  }, $e = (e) => {
812
812
  const t = V.value.range;
813
- t ? (e.data && Z(t.startContainer) && Z(t.endContainer) ? (O(e.data), W.set(K.get(), j(t))) : t.startId && t.endId ? (Se(t, "insertCompositionText", e.data), W.set(K.get(), j(t))) : console.warn("range is not valid, range:", t), k.value++) : console.warn("range is null, compositionEnd:", e), V.value = { hasStarted: !1, range: null };
814
- }, Y = (() => {
813
+ t ? (e.data && Q(t.startContainer) && Q(t.endContainer) ? (O(e.data), W.set(K.get(), j(t))) : t.startId && t.endId ? (Se(t, "insertCompositionText", e.data), W.set(K.get(), j(t))) : console.warn("range is not valid, range:", t), k.value++) : console.warn("range is null, compositionEnd:", e), V.value = { hasStarted: !1, range: null };
814
+ }, Z = (() => {
815
815
  const e = navigator.userAgent.toLowerCase();
816
816
  return /macintosh|mac os x|iphone|ipad|ipod/.test(e);
817
- })(), _e = (e) => {
818
- const t = Y && e.metaKey && !e.shiftKey && e.key.toLowerCase() === "z" || // Cmd+Z
819
- !Y && e.ctrlKey && !e.shiftKey && e.key.toLowerCase() === "z", s = Y && e.metaKey && e.shiftKey && e.key.toLowerCase() === "z" || // Cmd+Shift+z
820
- !Y && e.ctrlKey && (e.key.toLowerCase() === "y" || e.shiftKey && e.key.toLowerCase() === "z"), r = e.key.toLowerCase() === "enter";
817
+ })(), be = (e) => {
818
+ const t = Z && e.metaKey && !e.shiftKey && e.key.toLowerCase() === "z" || // Cmd+Z
819
+ !Z && e.ctrlKey && !e.shiftKey && e.key.toLowerCase() === "z", s = Z && e.metaKey && e.shiftKey && e.key.toLowerCase() === "z" || // Cmd+Shift+z
820
+ !Z && e.ctrlKey && (e.key.toLowerCase() === "y" || e.shiftKey && e.key.toLowerCase() === "z"), r = e.key.toLowerCase() === "enter";
821
821
  if (t) {
822
822
  e.preventDefault();
823
823
  const l = ue(f.value);
@@ -868,9 +868,9 @@ const Pt = { class: "editor-container" }, De = "​", Fe = "​", Wt = /* @__PUR
868
868
  onBeforeinput: le,
869
869
  onCompositionstart: fe,
870
870
  onCompositionend: $e,
871
- onKeydown: _e
871
+ onKeydown: be
872
872
  }, [
873
- (S(!0), R(ie, null, ye(A.value, (s) => (S(), Q(Ft, ve({
873
+ (S(!0), R(ie, null, ye(A.value, (s) => (S(), Y(Ft, ve({
874
874
  key: `${s.id}-${s.type}`
875
875
  }, { ref_for: !0 }, s), null, 16))), 128))
876
876
  ], 32))
@@ -888,14 +888,14 @@ const Pt = { class: "editor-container" }, De = "​", Fe = "​", Wt = /* @__PUR
888
888
  },
889
889
  emits: ["item-hover", "item-leave", "select"],
890
890
  setup(i, { emit: c }) {
891
- const a = i, u = c, v = H(null), w = (_) => {
892
- u("item-hover", _);
891
+ const a = i, u = c, v = H(null), w = (b) => {
892
+ u("item-hover", b);
893
893
  }, o = () => {
894
894
  u("item-leave");
895
- }, p = (_) => {
896
- u("select", _);
895
+ }, p = (b) => {
896
+ u("select", b);
897
897
  };
898
- return (_, h) => (S(), Q(He, { name: "tiny-sender-slide-up" }, {
898
+ return (b, h) => (S(), Y(He, { name: "tiny-sender-slide-up" }, {
899
899
  default: re(() => [
900
900
  a.show && a.suggestions.length ? (S(), R("div", {
901
901
  key: 0,
@@ -911,8 +911,8 @@ const Pt = { class: "editor-container" }, De = "​", Fe = "​", Wt = /* @__PUR
911
911
  onMouseleave: o,
912
912
  onMousedown: ct((I) => p(k), ["prevent"])
913
913
  }, [
914
- X(C(bt), { class: "suggestion-list__icon" }),
915
- U("span", Nt, [
914
+ X(C(_t), { class: "suggestion-list__icon" }),
915
+ z("span", Nt, [
916
916
  (S(!0), R(ie, null, ye(a.highlightSuggestionText(k, a.inputValue), (I, m) => (S(), R("span", {
917
917
  key: m,
918
918
  class: te({
@@ -927,7 +927,7 @@ const Pt = { class: "editor-container" }, De = "​", Fe = "​", Wt = /* @__PUR
927
927
  _: 1
928
928
  }));
929
929
  }
930
- }), Mt = /* @__PURE__ */ Oe(Vt, [["__scopeId", "data-v-238fcdfd"]]), Ut = ["data-theme"], qt = { class: "tiny-sender__container" }, zt = {
930
+ }), Mt = /* @__PURE__ */ Oe(Vt, [["__scopeId", "data-v-238fcdfd"]]), zt = ["data-theme"], qt = { class: "tiny-sender__container" }, Ut = {
931
931
  key: 0,
932
932
  class: "tiny-sender__header-slot"
933
933
  }, jt = {
@@ -939,10 +939,10 @@ const Pt = { class: "editor-container" }, De = "​", Fe = "​", Wt = /* @__PUR
939
939
  }, Jt = {
940
940
  key: 2,
941
941
  class: "tiny-sender__input-field-wrapper"
942
- }, Zt = {
942
+ }, Qt = {
943
943
  key: 0,
944
944
  class: "tiny-sender__completion-placeholder"
945
- }, Qt = { class: "user-input-mirror" }, Yt = {
945
+ }, Yt = { class: "user-input-mirror" }, Zt = {
946
946
  key: 0,
947
947
  class: "tiny-sender__tab-hint"
948
948
  }, en = {
@@ -982,7 +982,7 @@ const Pt = { class: "editor-container" }, De = "​", Fe = "​", Wt = /* @__PUR
982
982
  emits: ["update:modelValue", "update:templateData", "submit", "clear", "speech-start", "speech-end", "speech-interim", "speech-error", "suggestion-select", "focus", "blur", "escape-press", "cancel", "reset-template", "files-selected"],
983
983
  setup(i, { expose: c, emit: a }) {
984
984
  var Ne;
985
- const u = i, v = a, w = H(null), o = H(null), p = H(null), _ = H(null), h = H(null), k = L(() => u.templateData && u.templateData.length > 0), { inputValue: g, isComposing: I, clearInput: m } = Ct(u, v), P = L(() => !!g.value.trim()), B = L(() => {
985
+ const u = i, v = a, w = H(null), o = H(null), p = H(null), b = H(null), h = H(null), k = L(() => u.templateData && u.templateData.length > 0), { inputValue: g, isComposing: I, clearInput: m } = Ct(u, v), P = L(() => !!g.value.trim()), B = L(() => {
986
986
  var n, x;
987
987
  return !(u.disabled || u.loading || !P.value || he.value || (x = (n = u.buttonGroup) == null ? void 0 : n.submit) != null && x.disabled);
988
988
  }), {
@@ -993,7 +993,7 @@ const Pt = { class: "editor-container" }, De = "​", Fe = "​", Wt = /* @__PUR
993
993
  filteredSuggestions: W,
994
994
  activeSuggestion: K,
995
995
  isItemHighlighted: q,
996
- updateSuggestionsState: Z,
996
+ updateSuggestionsState: Q,
997
997
  selectSuggestion: ue,
998
998
  acceptCurrentSuggestion: ce,
999
999
  closeSuggestionsPopup: G,
@@ -1018,11 +1018,11 @@ const Pt = { class: "editor-container" }, De = "​", Fe = "​", Wt = /* @__PUR
1018
1018
  const ke = F.offsetWidth;
1019
1019
  return document.body.removeChild(F), ke;
1020
1020
  }, we = () => {
1021
- var xe, Ue, qe;
1022
- if (u.mode !== "single" || !w.value || ne.value || !o.value || !_.value) return;
1021
+ var xe, ze, qe;
1022
+ if (u.mode !== "single" || !w.value || ne.value || !o.value || !b.value) return;
1023
1023
  const n = o.value.querySelector(".tiny-sender__content-area");
1024
1024
  if (!n) return;
1025
- const x = ((Ue = (xe = w.value) == null ? void 0 : xe.querySelector) == null ? void 0 : Ue.call(xe, ".tiny-input__inner")) || n.querySelector(".tiny-input__inner"), F = h.value || o.value.querySelector(".tiny-sender__buttons-container");
1025
+ const x = ((ze = (xe = w.value) == null ? void 0 : xe.querySelector) == null ? void 0 : ze.call(xe, ".tiny-input__inner")) || n.querySelector(".tiny-input__inner"), F = h.value || o.value.querySelector(".tiny-sender__buttons-container");
1026
1026
  if (!x) {
1027
1027
  console.warn("Cannot find input element for overflow check");
1028
1028
  return;
@@ -1032,11 +1032,11 @@ const Pt = { class: "editor-container" }, De = "​", Fe = "​", Wt = /* @__PUR
1032
1032
  setTimeout(() => we(), 50);
1033
1033
  return;
1034
1034
  }
1035
- const Ye = window.getComputedStyle(x).font, et = Te(g.value, Ye), Ve = (qe = o.value) == null ? void 0 : qe.classList.contains("tr-sender-compact"), tt = Ve ? 12 : 20, nt = ke.width, st = (Le == null ? void 0 : Le.width) || 0, Me = nt - st - tt, ot = Ve ? 50 : 80;
1035
+ const Ze = window.getComputedStyle(x).font, et = Te(g.value, Ze), Ve = (qe = o.value) == null ? void 0 : qe.classList.contains("tr-sender-compact"), tt = Ve ? 12 : 20, nt = ke.width, st = (Le == null ? void 0 : Le.width) || 0, Me = nt - st - tt, ot = Ve ? 50 : 80;
1036
1036
  et > Me && Me > ot && N.value === "single" && (ne.value = !0, N.value = "multiple", J(() => {
1037
1037
  w.value ? setTimeout(() => {
1038
- var ze;
1039
- const Ie = (ze = o.value) == null ? void 0 : ze.querySelector(".tiny-textarea__inner");
1038
+ var Ue;
1039
+ const Ie = (Ue = o.value) == null ? void 0 : Ue.querySelector(".tiny-textarea__inner");
1040
1040
  if (Ie) {
1041
1041
  Ie.style.whiteSpace = "pre-wrap";
1042
1042
  const je = g.value.length;
@@ -1045,7 +1045,7 @@ const Pt = { class: "editor-container" }, De = "​", Fe = "​", Wt = /* @__PUR
1045
1045
  ne.value = !1;
1046
1046
  }, 300) : ne.value = !1;
1047
1047
  }));
1048
- }, be = () => {
1048
+ }, _e = () => {
1049
1049
  if (k.value && p.value)
1050
1050
  Ke();
1051
1051
  else if (w.value)
@@ -1065,7 +1065,7 @@ const Pt = { class: "editor-container" }, De = "​", Fe = "​", Wt = /* @__PUR
1065
1065
  var n;
1066
1066
  v("update:templateData", []), (n = p.value) == null || n.clearHistory(), J(() => {
1067
1067
  g.value === "" && (N.value = u.mode || "single"), setTimeout(() => {
1068
- be();
1068
+ _e();
1069
1069
  }, 50);
1070
1070
  }), G();
1071
1071
  }, fe = () => {
@@ -1107,14 +1107,14 @@ const Pt = { class: "editor-container" }, De = "​", Fe = "​", Wt = /* @__PUR
1107
1107
  v("speech-error", x);
1108
1108
  }
1109
1109
  };
1110
- }), { speechState: Y, start: _e, stop: pe } = xt(We.value), Ce = () => {
1111
- Y.isRecording ? pe() : _e();
1110
+ }), { speechState: Z, start: be, stop: pe } = xt(We.value), Ce = () => {
1111
+ Z.isRecording ? pe() : be();
1112
1112
  }, he = L(() => u.maxLength !== 1 / 0 && g.value.length > u.maxLength), { handleKeyPress: e, triggerSubmit: t } = kt(
1113
1113
  u,
1114
1114
  v,
1115
1115
  g,
1116
1116
  I,
1117
- Y,
1117
+ Z,
1118
1118
  A,
1119
1119
  K,
1120
1120
  ce,
@@ -1136,17 +1136,17 @@ const Pt = { class: "editor-container" }, De = "​", Fe = "​", Wt = /* @__PUR
1136
1136
  justifyContent: u.showWordLimit && u.maxLength !== 1 / 0 ? "space-between" : "flex-end",
1137
1137
  alignItems: "center"
1138
1138
  })
1139
- ), b = dt(), D = L(() => !!b.decorativeContent), T = L(() => u.disabled || D.value), $ = L(() => u.loading), z = L(() => ({
1139
+ ), _ = dt(), D = L(() => !!_.decorativeContent), T = L(() => u.disabled || D.value), $ = L(() => u.loading), U = L(() => ({
1140
1140
  "is-disabled": T.value,
1141
1141
  "is-loading": $.value,
1142
1142
  "is-auto-switching": ne.value
1143
1143
  })), ge = L(() => ({
1144
- width: _t(u.suggestionPopupWidth),
1144
+ width: bt(u.suggestionPopupWidth),
1145
1145
  maxWidth: "100%"
1146
1146
  // 确保不超出父容器宽度
1147
1147
  })), Be = () => {
1148
1148
  I.value = !1, setTimeout(() => {
1149
- I.value = !1, Z();
1149
+ I.value = !1, Q();
1150
1150
  }, 50);
1151
1151
  };
1152
1152
  ee(g, () => {
@@ -1159,48 +1159,48 @@ const Pt = { class: "editor-container" }, De = "​", Fe = "​", Wt = /* @__PUR
1159
1159
  );
1160
1160
  const Ke = () => {
1161
1161
  p.value && p.value.activateFirstField();
1162
- }, { accept: Je = "*", multiple: Ze = !0 } = ((Ne = u.buttonGroup) == null ? void 0 : Ne.file) || {}, { open: Ae, files: Qe } = ht({ accept: Je, multiple: Ze });
1163
- return ee(Qe, (n) => {
1162
+ }, { accept: Je = "*", multiple: Qe = !0 } = ((Ne = u.buttonGroup) == null ? void 0 : Ne.file) || {}, { open: Ae, files: Ye } = ht({ accept: Je, multiple: Qe });
1163
+ return ee(Ye, (n) => {
1164
1164
  n && n.length > 0 && v("files-selected", Array.from(n));
1165
1165
  }), c({
1166
- focus: be,
1166
+ focus: _e,
1167
1167
  blur: de,
1168
1168
  clear: fe,
1169
1169
  submit: t,
1170
- startSpeech: _e,
1170
+ startSpeech: be,
1171
1171
  stopSpeech: pe,
1172
1172
  activateTemplateFirstField: Ke
1173
1173
  }), (n, x) => (S(), R("div", {
1174
1174
  ref_key: "senderRef",
1175
1175
  ref: o,
1176
- class: te(["tiny-sender", [z.value, `theme-${n.theme}`, `mode-${N.value}`]]),
1176
+ class: te(["tiny-sender", [U.value, `theme-${n.theme}`, `mode-${N.value}`]]),
1177
1177
  "data-theme": n.theme
1178
1178
  }, [
1179
- U("div", qt, [
1180
- U("div", {
1179
+ z("div", qt, [
1180
+ z("div", {
1181
1181
  class: "tiny-sender__input-wrapper",
1182
1182
  ref_key: "inputWrapperRef",
1183
- ref: _
1183
+ ref: b
1184
1184
  }, [
1185
1185
  X(He, { name: "tiny-sender-slide-down" }, {
1186
1186
  default: re(() => [
1187
- n.$slots.header ? (S(), R("div", zt, [
1187
+ n.$slots.header ? (S(), R("div", Ut, [
1188
1188
  oe(n.$slots, "header")
1189
1189
  ])) : M("", !0)
1190
1190
  ]),
1191
1191
  _: 3
1192
1192
  }),
1193
- U("div", {
1193
+ z("div", {
1194
1194
  class: te(["tiny-sender__input-row", { "has-prefix": n.$slots.prefix, "has-header": n.$slots.header }])
1195
1195
  }, [
1196
1196
  n.$slots.prefix ? (S(), R("div", jt, [
1197
1197
  oe(n.$slots, "prefix")
1198
1198
  ])) : M("", !0),
1199
- U("div", Gt, [
1199
+ z("div", Gt, [
1200
1200
  n.$slots.decorativeContent ? (S(), R("div", Xt, [
1201
1201
  oe(n.$slots, "decorativeContent")
1202
1202
  ])) : M("", !0),
1203
- k.value ? (S(), Q(Kt, {
1203
+ k.value ? (S(), Y(Kt, {
1204
1204
  key: 1,
1205
1205
  ref_key: "templateEditorRef",
1206
1206
  ref: p,
@@ -1225,15 +1225,15 @@ const Pt = { class: "editor-container" }, De = "​", Fe = "​", Wt = /* @__PUR
1225
1225
  onFocus: s,
1226
1226
  onBlur: r
1227
1227
  }, null, 8, ["autosize", "type", "modelValue", "disabled", "placeholder", "autofocus", "onKeydown"]),
1228
- C(f) && !C(I) ? (S(), R("div", Zt, [
1229
- U("span", Qt, ae(C(g)), 1),
1228
+ C(f) && !C(I) ? (S(), R("div", Qt, [
1229
+ z("span", Yt, ae(C(g)), 1),
1230
1230
  Ge(ae(C(f)) + " ", 1),
1231
- C(E) ? (S(), R("div", Yt, "TAB")) : M("", !0)
1231
+ C(E) ? (S(), R("div", Zt, "TAB")) : M("", !0)
1232
1232
  ])) : M("", !0)
1233
1233
  ]))
1234
1234
  ]),
1235
1235
  N.value === "single" ? (S(), R("div", en, [
1236
- U("div", {
1236
+ z("div", {
1237
1237
  class: "tiny-sender__buttons-container",
1238
1238
  ref_key: "buttonsContainerRef",
1239
1239
  ref: h
@@ -1246,7 +1246,7 @@ const Pt = { class: "editor-container" }, De = "​", Fe = "​", Wt = /* @__PUR
1246
1246
  disabled: T.value,
1247
1247
  "show-clear": n.clearable,
1248
1248
  "has-content": P.value,
1249
- "speech-status": C(Y),
1249
+ "speech-status": C(Z),
1250
1250
  "button-group": n.buttonGroup,
1251
1251
  "submit-type": n.submitType,
1252
1252
  "is-over-limit": he.value,
@@ -1267,20 +1267,20 @@ const Pt = { class: "editor-container" }, De = "​", Fe = "​", Wt = /* @__PUR
1267
1267
  style: Pe(d.value),
1268
1268
  class: "tiny-sender__footer-slot tiny-sender__bottom-row"
1269
1269
  }, [
1270
- U("div", tn, [
1270
+ z("div", tn, [
1271
1271
  oe(n.$slots, "footer-left")
1272
1272
  ]),
1273
- U("div", nn, [
1273
+ z("div", nn, [
1274
1274
  oe(n.$slots, "footer-right"),
1275
1275
  n.showWordLimit && n.maxLength !== 1 / 0 ? (S(), R("div", {
1276
1276
  key: 0,
1277
1277
  class: te(["tiny-sender__word-limit", { "is-over-limit": he.value }])
1278
1278
  }, [
1279
- U("span", sn, ae(C(g).length), 1),
1279
+ z("span", sn, ae(C(g).length), 1),
1280
1280
  Ge("/" + ae(n.maxLength), 1)
1281
1281
  ], 2)) : M("", !0),
1282
1282
  N.value === "multiple" ? (S(), R("div", on, [
1283
- U("div", an, [
1283
+ z("div", an, [
1284
1284
  X(Xe, {
1285
1285
  "allow-speech": n.allowSpeech,
1286
1286
  "allow-files": n.allowFiles,
@@ -1288,7 +1288,7 @@ const Pt = { class: "editor-container" }, De = "​", Fe = "​", Wt = /* @__PUR
1288
1288
  disabled: T.value,
1289
1289
  "show-clear": n.clearable,
1290
1290
  "has-content": P.value,
1291
- "speech-status": C(Y),
1291
+ "speech-status": C(Z),
1292
1292
  "button-group": n.buttonGroup,
1293
1293
  "submit-type": n.submitType,
1294
1294
  "is-over-limit": he.value,
@@ -1323,7 +1323,7 @@ const Pt = { class: "editor-container" }, De = "​", Fe = "​", Wt = /* @__PUR
1323
1323
  onItemLeave: C(le),
1324
1324
  onSelect: C(ue)
1325
1325
  }, null, 8, ["show", "suggestions", "popup-style", "is-item-highlighted", "highlight-suggestion-text", "input-value", "onItemHover", "onItemLeave", "onSelect"])
1326
- ], 10, Ut));
1326
+ ], 10, zt));
1327
1327
  }
1328
1328
  });
1329
1329
  Re.name = "TrSender";