@mobilon-dev/chotto 0.3.101 → 0.3.104

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.
Files changed (32) hide show
  1. package/dist/chotto.css +1 -1
  2. package/dist/components/2_chatinput_elements/FilePreview/FilePreview.vue.js +4 -3
  3. package/dist/components/2_chatinput_elements/FilePreview/FilePreview.vue2.js +72 -119
  4. package/dist/components/2_chatinput_elements/FileUploader/FileUploader.vue.js +2 -2
  5. package/dist/components/2_chatinput_elements/FileUploader/FileUploader.vue2.js +109 -88
  6. package/dist/components/3_compounds/ChatInput/ChatInput.vue.js +2 -2
  7. package/dist/components/3_compounds/ChatInput/ChatInput.vue2.js +355 -218
  8. package/dist/components/3_compounds/ChatInput/icons/ArrowIcon.vue.js +40 -0
  9. package/dist/hooks/messages/canStartEditLastSent.js +16 -0
  10. package/dist/hooks/uploadFile/generatePreview.js +19 -18
  11. package/dist/hooks/useMessageDraft.js +85 -65
  12. package/dist/index.js +192 -186
  13. package/dist/locale/en.js +4 -0
  14. package/dist/locale/ru.js +4 -0
  15. package/dist/themes/dark.css +1 -1
  16. package/dist/themes/default.css +1 -1
  17. package/dist/themes/glass.css +1 -1
  18. package/dist/themes/green.css +1 -1
  19. package/dist/themes/mobilon1.css +1 -1
  20. package/dist/types/components/2_chatinput_elements/FilePreview/stories/FilePreview.stories.d.ts +3 -3
  21. package/dist/types/components/2_chatinput_elements/FilePreview/styles/types.d.ts +135 -127
  22. package/dist/types/components/2_chatinput_elements/FileUploader/FileUploader.vue.d.ts +9 -0
  23. package/dist/types/components/3_compounds/ChatInput/ChatInput.vue.d.ts +27 -3
  24. package/dist/types/components/3_compounds/ChatInput/icons/ArrowIcon.vue.d.ts +2 -0
  25. package/dist/types/components/3_compounds/ChatInput/icons/index.d.ts +1 -0
  26. package/dist/types/components/3_compounds/ChatInput/styles/types.d.ts +74 -0
  27. package/dist/types/hooks/messages/canStartEditLastSent.d.ts +22 -0
  28. package/dist/types/hooks/messages/index.d.ts +1 -0
  29. package/dist/types/hooks/useMessageDraft.d.ts +10 -3
  30. package/dist/types/locale/en.d.ts +4 -0
  31. package/dist/types/locale/ru.d.ts +4 -0
  32. package/package.json +1 -1
@@ -1,28 +1,31 @@
1
- import { defineComponent as we, inject as Ce, watch as d, ref as E, computed as _, nextTick as S, unref as u, onMounted as Ae, onUnmounted as Ee, createElementBlock as k, openBlock as F, createElementVNode as h, createVNode as O, normalizeClass as j, createBlock as Fe, createCommentVNode as U, renderSlot as Y, toDisplayString as Me, withDirectives as Re, withKeys as He, vModelText as ke } from "vue";
2
- import { useImmediateDebouncedRef as Le } from "../../../hooks/useImmediateDebouncedRef.js";
3
- import { useMessageDraft as De, commitChatDraftToList as Pe } from "../../../hooks/useMessageDraft.js";
1
+ import { defineComponent as Ne, inject as je, watch as p, ref as S, computed as _, provide as $e, nextTick as b, unref as r, onMounted as Ge, onUnmounted as Oe, createElementBlock as C, openBlock as x, createElementVNode as f, createVNode as q, normalizeClass as O, toDisplayString as U, createCommentVNode as V, Fragment as Ue, renderList as Ve, createBlock as Ye, renderSlot as le, withDirectives as Xe, withKeys as Je, vModelText as Qe } from "vue";
2
+ import { useImmediateDebouncedRef as Ze } from "../../../hooks/useImmediateDebouncedRef.js";
3
+ import { MAX_ATTACHED_FILES as ie, useMessageDraft as et, getDraftFiles as tt, commitChatDraftToList as nt } from "../../../hooks/useMessageDraft.js";
4
4
  import "../../../hooks/useSearchModel.js";
5
5
  import "../../../hooks/useTheme.js";
6
- import { useEmojiNative as We } from "../../../hooks/useEmojiNative.js";
6
+ import { useEmojiNative as lt } from "../../../hooks/useEmojiNative.js";
7
7
  /* empty css */
8
8
  /* empty css */
9
- import { t as I } from "../../../locale/useLocale.js";
9
+ import { t as h } from "../../../locale/useLocale.js";
10
10
  /* empty css */
11
11
  import "../../../node_modules/linkifyjs/dist/linkify.js";
12
12
  import "../../../node_modules/linkify-string/dist/linkify-string.js";
13
13
  import "../../../functions/parseMarkdown.js";
14
- import { textToAppleEmojiHtml as qe, textContainsEmoji as Be, previousGraphemeIndex as V, nextGraphemeIndex as $, snapIndexToGrapheme as J } from "../../../functions/renderAppleEmojis.js";
15
- import { hideEditPreview as je } from "../../../hooks/messages/useStartEdit.js";
16
- import ze from "./icons/SendIcon.vue.js";
17
- import Ke from "../../2_chatinput_elements/TextFormatToolbar/TextFormatToolbar.vue.js";
18
- import Ne from "../../2_chatinput_elements/FilePreview/FilePreview.vue.js";
19
- const Ge = { class: "chat-input__container" }, Oe = ["id"], Ue = ["id"], Ye = { class: "chat-input__inline-buttons" }, Ve = {
14
+ import { textToAppleEmojiHtml as it, textContainsEmoji as ot, previousGraphemeIndex as oe, nextGraphemeIndex as se, snapIndexToGrapheme as ae } from "../../../functions/renderAppleEmojis.js";
15
+ import { useStartEdit as st, hideEditPreview as at } from "../../../hooks/messages/useStartEdit.js";
16
+ import { canStartEditLastSent as rt, isEditableLastSentCandidate as ut } from "../../../hooks/messages/canStartEditLastSent.js";
17
+ import { buildEditPayload as ct } from "../../../hooks/messages/buildEditPayload.js";
18
+ import dt from "./icons/SendIcon.vue.js";
19
+ import re from "./icons/ArrowIcon.vue.js";
20
+ import ft from "../../2_chatinput_elements/TextFormatToolbar/TextFormatToolbar.vue.js";
21
+ import pt from "../../2_chatinput_elements/FilePreview/FilePreview.vue.js";
22
+ const ht = { class: "chat-input__container" }, mt = ["id"], vt = ["id"], gt = { class: "chat-input__file-counter" }, yt = { class: "chat-input__file-chips-wrap" }, St = ["aria-label"], _t = ["aria-label"], xt = { class: "chat-input__inline-buttons" }, It = {
20
23
  key: 0,
21
24
  class: "chat-input__input chat-input__disabled-placeholder"
22
- }, $e = {
25
+ }, bt = {
23
26
  key: 1,
24
27
  class: "chat-input__input-wrap"
25
- }, Je = ["innerHTML"], Qe = ["disabled", "placeholder"], Xe = ["disabled"], Ze = { class: "" }, et = { class: "chat-input__third-line" }, z = 40, _t = /* @__PURE__ */ we({
28
+ }, Ct = ["innerHTML"], Ft = ["disabled", "placeholder"], Tt = ["disabled"], Et = { class: "" }, At = { class: "chat-input__third-line" }, Y = 40, Jt = /* @__PURE__ */ Ne({
26
29
  __name: "ChatInput",
27
30
  props: {
28
31
  state: {
@@ -48,95 +51,168 @@ const Ge = { class: "chat-input__container" }, Oe = ["id"], Ue = ["id"], Ye = {
48
51
  type: String,
49
52
  required: !1,
50
53
  default: null
54
+ },
55
+ maxAttachedFiles: {
56
+ type: Number,
57
+ required: !1,
58
+ default: ie
59
+ },
60
+ resolveEditLastSentMessage: {
61
+ type: Function,
62
+ required: !1,
63
+ default: null
51
64
  }
52
65
  },
53
66
  emits: ["send", "typing"],
54
- setup(T, { emit: Q }) {
55
- const L = Q, b = Ce("chatAppId"), { resetMessage: X, getMessage: l, setMessageText: M, setForceSendMessage: Z, resetEdit: ee, resetMessageFile: te } = De(b), { isNative: ne, emojiSrc: ie } = We(b);
56
- let K = l().id;
57
- d(
58
- () => l().id,
67
+ setup(M, { emit: ue }) {
68
+ const H = ue, F = je("chatAppId"), { resetMessage: ce, getMessage: o, setMessageText: D, setForceSendMessage: de, resetEdit: fe, removeMessageFile: pe } = et(F), { startEdit: he } = st(F), { isNative: me, emojiSrc: ve } = lt(F);
69
+ let X = o().id;
70
+ p(
71
+ () => o().id,
59
72
  (e) => {
60
- K = e;
73
+ X = e;
61
74
  }
62
75
  );
63
- const n = E(), m = E(), v = E(null), w = E(!1), oe = Le("", 2e3), D = _(() => {
64
- var e;
65
- return (e = l().file) == null ? void 0 : e.preview;
66
- }), le = _(
67
- () => qe(l().text || "", v.value, ie.value)
68
- ), g = _(
69
- () => !ne.value && Be(l().text || "")
70
- ), c = () => {
71
- if (!m.value || !n.value) return;
72
- const e = n.value, t = m.value, o = Math.max(0, e.offsetWidth - e.clientWidth);
73
- t.style.right = o > 0 ? `${o}px` : "", t.scrollTop = e.scrollTop;
76
+ const l = S(), T = S(), L = S(), E = S(null), R = S(!1), ge = Ze("", 2e3), z = S(!1), B = S(!1);
77
+ let m = null;
78
+ const v = _(() => tt(o()));
79
+ function K() {
80
+ const e = L.value;
81
+ if (!e) {
82
+ z.value = !1, B.value = !1;
83
+ return;
84
+ }
85
+ const t = e.scrollWidth - e.clientWidth;
86
+ z.value = e.scrollLeft > 1, B.value = t - e.scrollLeft > 1;
87
+ }
88
+ function ye(e) {
89
+ const t = e.firstElementChild;
90
+ if (!t) return e.clientWidth;
91
+ const n = parseFloat(getComputedStyle(e).gap) || 8;
92
+ return t.offsetWidth + n;
93
+ }
94
+ function J(e) {
95
+ const t = L.value;
96
+ if (!t) return;
97
+ const n = ye(t);
98
+ t.scrollBy({ left: e === "right" ? n : -n, behavior: "smooth" });
99
+ }
100
+ function Q() {
101
+ m == null || m.disconnect();
102
+ const e = L.value;
103
+ e && (m = new ResizeObserver(() => K()), m.observe(e));
104
+ }
105
+ function Se(e) {
106
+ return e.preview ?? {
107
+ isImage: !1,
108
+ isVideo: !1,
109
+ isAudio: !1,
110
+ fileName: e.name,
111
+ fileSize: ""
112
+ };
113
+ }
114
+ const _e = _(
115
+ () => it(o().text || "", E.value, ve.value)
116
+ ), A = _(
117
+ () => !me.value && ot(o().text || "")
118
+ ), g = () => {
119
+ if (!T.value || !l.value) return;
120
+ const e = l.value, t = T.value, n = Math.max(0, e.offsetWidth - e.clientWidth);
121
+ t.style.right = n > 0 ? `${n}px` : "", t.scrollTop = e.scrollTop;
74
122
  };
75
- let y = 0;
76
- function P() {
77
- v.value = null;
123
+ let w = 0;
124
+ function N() {
125
+ E.value = null;
78
126
  }
79
- function se(e = "nearest") {
80
- const t = n.value;
81
- if (!t || !g.value) return;
82
- const o = t.value, i = J(o, t.selectionStart, e), r = J(o, t.selectionEnd, e);
83
- (i !== t.selectionStart || r !== t.selectionEnd) && t.setSelectionRange(i, r);
127
+ function xe(e = "nearest") {
128
+ const t = l.value;
129
+ if (!t || !A.value) return;
130
+ const n = t.value, i = ae(n, t.selectionStart, e), s = ae(n, t.selectionEnd, e);
131
+ (i !== t.selectionStart || s !== t.selectionEnd) && t.setSelectionRange(i, s);
84
132
  }
85
- function W() {
86
- se("nearest"), f();
133
+ function j() {
134
+ xe("nearest"), I();
87
135
  }
88
- function ae(e) {
89
- if (!g.value || e.key !== "ArrowLeft" && e.key !== "ArrowRight" || e.altKey || e.metaKey || e.ctrlKey) return;
90
- const t = n.value;
136
+ function Ie(e) {
137
+ var s, u, c;
138
+ const t = o(), n = l.value;
139
+ if (!rt({
140
+ key: e.key,
141
+ altKey: e.altKey,
142
+ metaKey: e.metaKey,
143
+ ctrlKey: e.ctrlKey,
144
+ shiftKey: e.shiftKey,
145
+ hasResolver: typeof a.resolveEditLastSentMessage == "function",
146
+ disabled: a.state === "disabled",
147
+ isRecording: t.isRecording,
148
+ draftText: t.text ?? "",
149
+ replyMessageId: (s = t.reply) == null ? void 0 : s.messageId,
150
+ editMessageId: (u = t.edit) == null ? void 0 : u.messageId,
151
+ textareaText: (n == null ? void 0 : n.value) ?? t.text ?? "",
152
+ selectionStart: (n == null ? void 0 : n.selectionStart) ?? 0
153
+ })) return !1;
154
+ const i = (c = a.resolveEditLastSentMessage) == null ? void 0 : c.call(a);
155
+ return ut(i) ? (e.preventDefault(), he(ct(i)), !0) : !1;
156
+ }
157
+ function be(e) {
158
+ if (Ie(e) || !A.value || e.key !== "ArrowLeft" && e.key !== "ArrowRight" || e.altKey || e.metaKey || e.ctrlKey) return;
159
+ const t = l.value;
91
160
  if (!t) return;
92
- const o = t.value, i = t.selectionStart !== t.selectionEnd;
161
+ const n = t.value, i = t.selectionStart !== t.selectionEnd;
93
162
  if (e.shiftKey) {
94
- requestAnimationFrame(() => W());
163
+ requestAnimationFrame(() => j());
95
164
  return;
96
165
  }
97
166
  if (i) {
98
167
  e.preventDefault();
99
- const x = e.key === "ArrowLeft" ? t.selectionStart : t.selectionEnd, A = e.key === "ArrowLeft" ? V(o, x) : $(o, x);
100
- t.setSelectionRange(A, A), f();
168
+ const c = e.key === "ArrowLeft" ? t.selectionStart : t.selectionEnd, y = e.key === "ArrowLeft" ? oe(n, c) : se(n, c);
169
+ t.setSelectionRange(y, y), I();
101
170
  return;
102
171
  }
103
172
  e.preventDefault();
104
- const r = t.selectionStart, p = e.key === "ArrowLeft" ? V(o, r) : $(o, r);
105
- t.setSelectionRange(p, p), f();
173
+ const s = t.selectionStart, u = e.key === "ArrowLeft" ? oe(n, s) : se(n, s);
174
+ t.setSelectionRange(u, u), I();
106
175
  }
107
- function f() {
108
- if (!g.value) {
109
- P();
176
+ function I() {
177
+ if (!A.value) {
178
+ N();
110
179
  return;
111
180
  }
112
- y && cancelAnimationFrame(y), y = requestAnimationFrame(() => {
113
- var p;
114
- y = 0;
115
- const e = n.value;
181
+ w && cancelAnimationFrame(w), w = requestAnimationFrame(() => {
182
+ var u;
183
+ w = 0;
184
+ const e = l.value;
116
185
  if (!e) {
117
- P();
186
+ N();
118
187
  return;
119
188
  }
120
- const t = e.selectionStart, o = e.selectionEnd;
121
- if (t === o) {
122
- v.value !== null && (v.value = null, S(c));
189
+ const t = e.selectionStart, n = e.selectionEnd;
190
+ if (t === n) {
191
+ E.value !== null && (E.value = null, b(g));
123
192
  return;
124
193
  }
125
- const i = v.value;
126
- if (i && i.start === t && i.end === o) return;
127
- const r = ((p = m.value) == null ? void 0 : p.scrollTop) ?? 0;
128
- v.value = { start: t, end: o }, S(() => {
129
- m.value && (m.value.scrollTop = r), c();
194
+ const i = E.value;
195
+ if (i && i.start === t && i.end === n) return;
196
+ const s = ((u = T.value) == null ? void 0 : u.scrollTop) ?? 0;
197
+ E.value = { start: t, end: n }, b(() => {
198
+ T.value && (T.value.scrollTop = s), g();
130
199
  });
131
200
  });
132
201
  }
133
- function re(e) {
134
- e.buttons && f();
202
+ function Ce(e) {
203
+ e.buttons && I();
135
204
  }
136
- function N() {
137
- document.activeElement === n.value && f();
205
+ function Z() {
206
+ document.activeElement === l.value && I();
138
207
  }
139
- const a = T, ue = _(() => !!(a.state == "disabled" || l().text == "" && !l().file || l().isRecording)), ce = _(() => {
208
+ const a = M, ee = _(() => {
209
+ const e = Number(a.maxAttachedFiles);
210
+ return Number.isFinite(e) && e > 0 ? Math.floor(e) : ie;
211
+ });
212
+ $e("maxAttachedFiles", ee);
213
+ const Fe = _(
214
+ () => h("component.ChatInput.FilesSelectedCount").replace("{count}", String(v.value.length)).replace("{max}", String(ee.value))
215
+ ), Te = _(() => !!(a.state == "disabled" || o().text == "" && !v.value.length || o().isRecording)), Ee = _(() => {
140
216
  var t;
141
217
  if (a.inputButtonColor)
142
218
  return a.inputButtonColor;
@@ -144,237 +220,298 @@ const Ge = { class: "chat-input__container" }, Oe = ["id"], Ue = ["id"], Ye = {
144
220
  return "#25D366";
145
221
  const e = a.selectedChannel.channelId.toLowerCase();
146
222
  return e.includes("whatsapp") || e.includes("waba") ? "#25D366" : e.includes("telegram") ? "#37AFE2" : e.includes("sms") ? "#6C757D" : e.includes("max") ? "#4B0082" : "#25D366";
147
- }), de = _(() => {
223
+ }), Ae = _(() => {
148
224
  var t;
149
225
  if (!((t = a.selectedChannel) != null && t.channelId))
150
- return I("component.ChatInput.InputPlaceholder");
226
+ return h("component.ChatInput.InputPlaceholder");
151
227
  const e = a.selectedChannel.channelId.toLowerCase();
152
- return e.includes("whatsapp") || e.includes("waba") ? I("component.ChatInput.WhatsappInputPlaceholder") : e.includes("telegram") ? I("component.ChatInput.TelegramInputPlaceholder") : e.includes("sms") ? I("component.ChatInput.SmsInputPlaceholder") : e.includes("max") ? I("component.ChatInput.MaxInputPlaceholder") : I("component.ChatInput.InputPlaceholder");
228
+ return e.includes("whatsapp") || e.includes("waba") ? h("component.ChatInput.WhatsappInputPlaceholder") : e.includes("telegram") ? h("component.ChatInput.TelegramInputPlaceholder") : e.includes("sms") ? h("component.ChatInput.SmsInputPlaceholder") : e.includes("max") ? h("component.ChatInput.MaxInputPlaceholder") : h("component.ChatInput.InputPlaceholder");
153
229
  });
154
- d(
155
- () => oe.value,
230
+ p(
231
+ () => ge.value,
156
232
  () => {
157
- L("typing");
233
+ H("typing");
158
234
  }
159
- ), d(
160
- () => {
161
- var e;
162
- return (e = l().edit) == null ? void 0 : e.messageId;
163
- },
164
- (e, t) => {
165
- e != null && e !== t && (w.value = !0, S(() => {
166
- if (!w.value) return;
167
- const o = n.value;
168
- o && (C(o), w.value = !1, H(o), requestAnimationFrame(() => H(o)));
169
- }));
235
+ );
236
+ function te(e = !1) {
237
+ b(() => {
238
+ if (e && !R.value) return;
239
+ const t = l.value;
240
+ t && (k(t), e && (R.value = !1), P(t), requestAnimationFrame(() => P(t)));
241
+ });
242
+ }
243
+ p(
244
+ () => o().edit,
245
+ (e) => {
246
+ (e == null ? void 0 : e.messageId) != null && (R.value = !0, te(!0));
247
+ }
248
+ ), p(
249
+ () => o().reply,
250
+ (e) => {
251
+ (e == null ? void 0 : e.messageId) != null && te();
170
252
  }
171
- ), d(
253
+ ), p(
172
254
  () => a.focusOnInputArea,
173
255
  () => {
174
- a.focusOnInputArea && S(() => {
175
- const e = u(n);
256
+ a.focusOnInputArea && b(() => {
257
+ const e = r(l);
176
258
  e == null || e.focus();
177
259
  });
178
260
  },
179
261
  { immediate: !0 }
180
- ), d(
181
- () => l().text,
262
+ ), p(
263
+ () => o().text,
182
264
  () => {
183
- const e = n.value;
184
- e && (C(e), w.value && (w.value = !1, H(e), requestAnimationFrame(() => H(e))));
265
+ const e = l.value;
266
+ e && (k(e), R.value && (R.value = !1, P(e), requestAnimationFrame(() => P(e))));
185
267
  },
186
268
  { immediate: !0, flush: "post" }
187
- ), d(
188
- () => l().id,
269
+ ), p(
270
+ () => o().id,
189
271
  () => {
190
- const e = n.value;
191
- e && (R(e), requestAnimationFrame(() => {
192
- const t = n.value;
193
- t && C(t);
272
+ const e = l.value;
273
+ e && (W(e), requestAnimationFrame(() => {
274
+ const t = l.value;
275
+ t && k(t);
194
276
  }));
195
277
  }
196
- ), d(g, (e) => {
197
- e && S(() => {
198
- const t = n.value;
278
+ ), p(A, (e) => {
279
+ e && b(() => {
280
+ const t = l.value;
199
281
  if (!t) return;
200
- const o = t.scrollTop;
201
- C(t), t.scrollTop = o, c(), requestAnimationFrame(c);
282
+ const n = t.scrollTop;
283
+ k(t), t.scrollTop = n, g(), requestAnimationFrame(g);
202
284
  });
203
285
  });
204
- function R(e) {
205
- const t = l().inputHeight;
206
- e.style.height = (t || z) + "px", (!t || t <= z) && (e.style.overflowY = "hidden");
286
+ function W(e) {
287
+ const t = o().inputHeight;
288
+ e.style.height = (t || Y) + "px", (!t || t <= Y) && (e.style.overflowY = "hidden");
207
289
  }
208
- function fe(e) {
290
+ function we(e) {
209
291
  const t = parseFloat(e.style.height);
210
- Number.isFinite(t) && (l().inputHeight = t);
292
+ Number.isFinite(t) && (o().inputHeight = t);
211
293
  }
212
- function C(e) {
213
- const t = l().text || "";
294
+ function k(e) {
295
+ const t = o().text || "";
214
296
  if (e.value !== t || e.clientWidth === 0) {
215
- R(e);
297
+ W(e);
216
298
  return;
217
299
  }
218
- const o = e.scrollTop;
300
+ const n = e.scrollTop;
219
301
  e.style.height = "auto";
220
- const i = getComputedStyle(e), r = parseFloat(i.fontSize) || 16, p = parseFloat(i.lineHeight) || r * 1.4, x = z, A = p * 11, B = e.scrollHeight, xe = t.split(`
221
- `).length > 1, s = document.createElement("div");
222
- s.style.position = "absolute", s.style.visibility = "hidden", s.style.whiteSpace = "nowrap", s.style.font = i.font, s.style.fontSize = i.fontSize, s.style.fontFamily = i.fontFamily, s.style.fontWeight = i.fontWeight, s.style.letterSpacing = i.letterSpacing, s.textContent = t, document.body.appendChild(s);
223
- const _e = s.offsetWidth;
224
- document.body.removeChild(s);
225
- const Se = parseFloat(i.paddingLeft) || 0, Ie = parseFloat(i.paddingRight) || 0, Te = e.clientWidth - Se - Ie, be = _e > Te, G = xe || be;
226
- if (G && B <= x + 1) {
227
- R(e);
302
+ const i = getComputedStyle(e), s = parseFloat(i.fontSize) || 16, u = parseFloat(i.lineHeight) || s * 1.4, c = Y, y = u * 11, G = e.scrollHeight, Ke = t.split(`
303
+ `).length > 1, d = document.createElement("div");
304
+ d.style.position = "absolute", d.style.visibility = "hidden", d.style.whiteSpace = "nowrap", d.style.font = i.font, d.style.fontSize = i.fontSize, d.style.fontFamily = i.fontFamily, d.style.fontWeight = i.fontWeight, d.style.letterSpacing = i.letterSpacing, d.textContent = t, document.body.appendChild(d);
305
+ const We = d.offsetWidth;
306
+ document.body.removeChild(d);
307
+ const Pe = parseFloat(i.paddingLeft) || 0, qe = parseFloat(i.paddingRight) || 0, ze = e.clientWidth - Pe - qe, Be = We > ze, ne = Ke || Be;
308
+ if (ne && G <= c + 1) {
309
+ W(e);
228
310
  return;
229
311
  }
230
- t.trim() && G ? B <= A ? (e.style.height = B + "px", e.style.overflowY = "hidden") : (e.style.height = A + "px", e.style.overflowY = "auto", e.scrollTop = o) : (e.style.height = x + "px", e.style.overflowY = "hidden"), fe(e), c(), requestAnimationFrame(c);
312
+ t.trim() && ne ? G <= y ? (e.style.height = G + "px", e.style.overflowY = "hidden") : (e.style.height = y + "px", e.style.overflowY = "auto", e.scrollTop = n) : (e.style.height = c + "px", e.style.overflowY = "hidden"), we(e), g(), requestAnimationFrame(g);
231
313
  }
232
- function H(e) {
233
- if (a.state === "disabled" || l().isRecording) return;
314
+ function P(e) {
315
+ if (a.state === "disabled" || o().isRecording) return;
234
316
  const t = e.value.length;
235
- e.focus(), e.setSelectionRange(t, t), e.scrollTop = e.scrollHeight, c();
317
+ e.focus(), e.setSelectionRange(t, t), e.scrollTop = e.scrollHeight, g();
236
318
  }
237
- d(
238
- () => l().forceSend,
319
+ p(
320
+ () => o().forceSend,
239
321
  () => {
240
- l().forceSend && (q(), Z(!1));
322
+ o().forceSend && ($(), de(!1));
241
323
  }
242
324
  );
243
- const pe = (e) => {
325
+ const Me = (e) => {
244
326
  const t = e.target;
245
- L("typing", t.value), f();
327
+ H("typing", t.value), I();
246
328
  };
247
- Ae(() => {
248
- const e = n.value;
249
- e && (R(e), C(e)), document.addEventListener("selectionchange", N);
250
- }), Ee(() => {
251
- Pe(K), document.removeEventListener("selectionchange", N), y && cancelAnimationFrame(y);
329
+ p(
330
+ v,
331
+ (e, t) => {
332
+ b(() => {
333
+ Q(), K();
334
+ const n = L.value;
335
+ n && e.length > ((t == null ? void 0 : t.length) ?? 0) && n.scrollTo({ left: n.scrollWidth, behavior: "smooth" });
336
+ });
337
+ },
338
+ { flush: "post" }
339
+ ), Ge(() => {
340
+ const e = l.value;
341
+ e && (W(e), k(e)), Q(), K(), document.addEventListener("selectionchange", Z);
342
+ }), Oe(() => {
343
+ nt(X), document.removeEventListener("selectionchange", Z), m == null || m.disconnect(), w && cancelAnimationFrame(w);
252
344
  });
253
- const he = (e) => {
345
+ const Le = (e) => {
254
346
  if (e.shiftKey) {
255
- if (n.value instanceof HTMLTextAreaElement) {
256
- let t = n.value.selectionStart;
257
- t && (n.value.setRangeText(`
258
- `, t, t, "end"), M(n.value.value));
347
+ if (l.value instanceof HTMLTextAreaElement) {
348
+ let t = l.value.selectionStart;
349
+ t && (l.value.setRangeText(`
350
+ `, t, t, "end"), D(l.value.value));
259
351
  }
260
352
  e.preventDefault();
261
353
  } else if (e.ctrlKey) {
262
- if (n.value instanceof HTMLTextAreaElement) {
263
- let t = n.value.selectionStart;
264
- t && (n.value.setRangeText(`
265
- `, t, t, "end"), M(n.value.value));
354
+ if (l.value instanceof HTMLTextAreaElement) {
355
+ let t = l.value.selectionStart;
356
+ t && (l.value.setRangeText(`
357
+ `, t, t, "end"), D(l.value.value));
266
358
  }
267
359
  e.preventDefault();
268
360
  } else
269
- e.preventDefault(), q();
270
- }, me = (e) => {
271
- if (n.value) {
272
- const t = n.value.value;
273
- n.value.value = e.newText;
274
- const o = e.newText.length - (t.length - (e.end - e.start)), i = e.start + o;
275
- M(e.newText), S(() => {
276
- n.value && (n.value.setSelectionRange(i, i), n.value.focus());
361
+ e.preventDefault(), $();
362
+ }, Re = (e) => {
363
+ if (l.value) {
364
+ const t = l.value.value;
365
+ l.value.value = e.newText;
366
+ const n = e.newText.length - (t.length - (e.end - e.start)), i = e.start + n;
367
+ D(e.newText), b(() => {
368
+ l.value && (l.value.setSelectionRange(i, i), l.value.focus());
277
369
  });
278
370
  }
279
371
  };
280
- function ve() {
281
- te();
372
+ function ke(e) {
373
+ pe(e);
282
374
  }
283
- function ge() {
284
- ee(), M(""), je(b), n.value && n.value.focus();
375
+ function He() {
376
+ fe(), D(""), at(F), l.value && l.value.focus();
285
377
  }
286
- function ye() {
287
- const e = l();
378
+ function De() {
379
+ const e = o();
288
380
  return e.edit ? (e.text ?? "").trim() === (e.edit.text ?? "").trim() : !1;
289
381
  }
290
- const q = () => {
291
- var t, o;
292
- const e = E(l());
293
- if (e.value.edit && ye()) {
294
- ge();
382
+ const $ = () => {
383
+ const e = S(o());
384
+ if (e.value.edit && De() && !v.value.length) {
385
+ He();
295
386
  return;
296
387
  }
297
- if (e.value.text != "" || e.value.file) {
298
- const i = {
388
+ if (e.value.text != "" || v.value.length) {
389
+ const t = {
299
390
  type: "",
300
391
  text: "",
301
392
  url: "",
302
393
  filename: "",
303
394
  size: "",
304
395
  reply: void 0
305
- };
306
- e.value.file ? (i.type = "message." + e.value.file.type, i.url = e.value.file.url, i.filename = e.value.file.name, i.size = (t = e.value.file.size) == null ? void 0 : t.toString(), i.text = (o = e == null ? void 0 : e.value) == null ? void 0 : o.text.trim()) : (i.type = "message.text", i.text = e.value.text.trim()), e.value.reply && (i.reply = e.value.reply), e.value.edit && (i.edit = e.value.edit), L("send", i), X(), n.value && n.value.focus();
396
+ }, n = v.value;
397
+ if (n.length) {
398
+ const i = e.value.text.trim();
399
+ n.forEach((s, u) => {
400
+ var y;
401
+ const c = {
402
+ type: "message." + s.type,
403
+ url: s.url,
404
+ filename: s.name,
405
+ size: (y = s.size) == null ? void 0 : y.toString(),
406
+ text: u === 0 ? i : ""
407
+ };
408
+ u === 0 && (e.value.reply && (c.reply = e.value.reply), e.value.edit && (c.edit = e.value.edit)), H("send", c);
409
+ });
410
+ } else
411
+ t.type = "message.text", t.text = e.value.text.trim(), e.value.reply && (t.reply = e.value.reply), e.value.edit && (t.edit = e.value.edit), H("send", t);
412
+ ce(), l.value && l.value.focus();
307
413
  }
308
414
  };
309
- return (e, t) => (F(), k("div", Ge, [
310
- h("div", {
311
- id: "chat-input-reply-line-" + u(b),
415
+ return (e, t) => (x(), C("div", ht, [
416
+ f("div", {
417
+ id: "chat-input-reply-line-" + r(F),
312
418
  class: "chat-input__reply-line"
313
- }, null, 8, Oe),
314
- h("div", {
315
- id: "chat-input-file-line-" + u(b),
316
- class: j(["chat-input__file-line", { "chat-input__file-line--visible": !!D.value }])
419
+ }, null, 8, mt),
420
+ f("div", {
421
+ id: "chat-input-file-line-" + r(F),
422
+ class: O(["chat-input__file-line", { "chat-input__file-line--visible": v.value.length > 0 }])
317
423
  }, [
318
- D.value ? (F(), Fe(Ne, {
319
- key: 0,
320
- "file-info": D.value,
321
- onReset: ve
322
- }, null, 8, ["file-info"])) : U("", !0)
323
- ], 10, Ue),
324
- h("div", Ye, [
325
- Y(e.$slots, "inline-buttons", {}, void 0, !0)
424
+ f("span", gt, [
425
+ f("span", null, U(r(h)("component.ChatInput.FilesSelected")), 1),
426
+ f("span", null, U(Fe.value), 1)
427
+ ]),
428
+ f("div", yt, [
429
+ z.value ? (x(), C("button", {
430
+ key: 0,
431
+ type: "button",
432
+ class: "chat-input__file-scroll chat-input__file-scroll--left",
433
+ "aria-label": r(h)("component.ChatInput.FilesScrollLeft"),
434
+ onClick: t[0] || (t[0] = (n) => J("left"))
435
+ }, [
436
+ q(r(re))
437
+ ], 8, St)) : V("", !0),
438
+ f("div", {
439
+ ref_key: "refFileChips",
440
+ ref: L,
441
+ class: "chat-input__file-chips",
442
+ onScroll: K
443
+ }, [
444
+ (x(!0), C(Ue, null, Ve(v.value, (n, i) => (x(), Ye(pt, {
445
+ key: (n.url || n.name || "") + "-" + i,
446
+ "file-info": Se(n),
447
+ onReset: (s) => ke(i)
448
+ }, null, 8, ["file-info", "onReset"]))), 128))
449
+ ], 544),
450
+ B.value ? (x(), C("button", {
451
+ key: 1,
452
+ type: "button",
453
+ class: "chat-input__file-scroll chat-input__file-scroll--right",
454
+ "aria-label": r(h)("component.ChatInput.FilesScrollRight"),
455
+ onClick: t[1] || (t[1] = (n) => J("right"))
456
+ }, [
457
+ q(r(re))
458
+ ], 8, _t)) : V("", !0)
459
+ ])
460
+ ], 10, vt),
461
+ f("div", xt, [
462
+ le(e.$slots, "inline-buttons", {}, void 0, !0)
326
463
  ]),
327
- T.disabledPlaceholder && (T.state == "disabled" || u(l)().isRecording) ? (F(), k("div", Ve, Me(T.disabledPlaceholder), 1)) : (F(), k("div", $e, [
328
- g.value ? (F(), k("div", {
464
+ M.disabledPlaceholder && (M.state == "disabled" || r(o)().isRecording) ? (x(), C("div", It, U(M.disabledPlaceholder), 1)) : (x(), C("div", bt, [
465
+ A.value ? (x(), C("div", {
329
466
  key: 0,
330
467
  ref_key: "refMirror",
331
- ref: m,
468
+ ref: T,
332
469
  class: "chat-input__input-mirror",
333
470
  "aria-hidden": "true",
334
- innerHTML: le.value
335
- }, null, 8, Je)) : U("", !0),
336
- Re(h("textarea", {
471
+ innerHTML: _e.value
472
+ }, null, 8, Ct)) : V("", !0),
473
+ Xe(f("textarea", {
337
474
  ref_key: "refInput",
338
- ref: n,
339
- "onUpdate:modelValue": t[0] || (t[0] = (o) => u(l)().text = o),
475
+ ref: l,
476
+ "onUpdate:modelValue": t[2] || (t[2] = (n) => r(o)().text = n),
340
477
  rows: "1",
341
- disabled: T.state == "disabled" || u(l)().isRecording,
342
- class: j(["chat-input__input", { "chat-input__input--emoji-images": g.value }]),
343
- placeholder: de.value,
478
+ disabled: M.state == "disabled" || r(o)().isRecording,
479
+ class: O(["chat-input__input", { "chat-input__input--emoji-images": A.value }]),
480
+ placeholder: Ae.value,
344
481
  onKeydown: [
345
- ae,
346
- He(he, ["enter"])
482
+ be,
483
+ Je(Le, ["enter"])
347
484
  ],
348
- onInput: pe,
349
- onScroll: c,
350
- onSelect: f,
351
- onMouseup: W,
352
- onKeyup: W,
353
- onMousemove: re,
354
- onBlur: P
355
- }, null, 42, Qe), [
356
- [ke, u(l)().text]
485
+ onInput: Me,
486
+ onScroll: g,
487
+ onSelect: I,
488
+ onMouseup: j,
489
+ onKeyup: j,
490
+ onMousemove: Ce,
491
+ onBlur: N
492
+ }, null, 42, Ft), [
493
+ [Qe, r(o)().text]
357
494
  ])
358
495
  ])),
359
- O(Ke, {
360
- textarea: n.value,
361
- onFormatApplied: me
496
+ q(ft, {
497
+ textarea: l.value,
498
+ onFormatApplied: Re
362
499
  }, null, 8, ["textarea"]),
363
- h("button", {
364
- class: j(["chat-input__button", { "chat-input__button-disabled": ue.value }]),
365
- disabled: u(l)().isRecording,
366
- onClick: q
500
+ f("button", {
501
+ class: O(["chat-input__button", { "chat-input__button-disabled": Te.value }]),
502
+ disabled: r(o)().isRecording,
503
+ onClick: $
367
504
  }, [
368
- h("span", Ze, [
369
- O(u(ze), { color: ce.value }, null, 8, ["color"])
505
+ f("span", Et, [
506
+ q(r(dt), { color: Ee.value }, null, 8, ["color"])
370
507
  ])
371
- ], 10, Xe),
372
- h("div", et, [
373
- Y(e.$slots, "buttons", {}, void 0, !0)
508
+ ], 10, Tt),
509
+ f("div", At, [
510
+ le(e.$slots, "buttons", {}, void 0, !0)
374
511
  ])
375
512
  ]));
376
513
  }
377
514
  });
378
515
  export {
379
- _t as default
516
+ Jt as default
380
517
  };