@mobilon-dev/chotto 0.3.87 → 0.3.89

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,7 +1,7 @@
1
1
  import o from "./MessageReactions.vue2.js";
2
2
  /* empty css */
3
3
  import t from "../../../_virtual/_plugin-vue_export-helper.js";
4
- const a = /* @__PURE__ */ t(o, [["__scopeId", "data-v-44eccc7b"]]);
4
+ const r = /* @__PURE__ */ t(o, [["__scopeId", "data-v-64bc224b"]]);
5
5
  export {
6
- a as default
6
+ r as default
7
7
  };
@@ -1,4 +1,4 @@
1
- import { defineComponent as Ce, inject as E, ref as M, computed as c, unref as i, onMounted as _e, onUnmounted as Ne, watch as Se, createElementBlock as d, openBlock as l, normalizeClass as K, createBlock as Q, Fragment as A, renderList as F, withCtx as C, createElementVNode as g, createCommentVNode as _, createVNode as u, toDisplayString as Ue, Teleport as je, Transition as D, withDirectives as V, normalizeStyle as $, withModifiers as y, vShow as z } from "vue";
1
+ import { defineComponent as Ce, inject as E, ref as M, computed as c, unref as i, onMounted as _e, onUnmounted as Ne, watch as Se, createElementBlock as d, openBlock as l, normalizeClass as K, createBlock as Q, Fragment as A, renderList as F, withCtx as C, createElementVNode as p, createCommentVNode as _, createVNode as u, toDisplayString as Ue, Teleport as je, Transition as D, withDirectives as V, normalizeStyle as $, withModifiers as y, vShow as z } from "vue";
2
2
  import Pe from "../../../node_modules/vue3-emoji-picker-ru/dist/emoji-picker.es.js";
3
3
  /* empty css */
4
4
  import "../../../hooks/useMessageDraft.js";
@@ -82,7 +82,7 @@ const Ve = ["onClick"], $e = { class: "message-reactions__emoji" }, ze = {
82
82
  },
83
83
  emits: ["toggle-reaction", "add-reaction", "remove-reaction", "menu"],
84
84
  setup(s, { emit: J }) {
85
- const n = s, a = J, v = E("chatAppId"), G = E("currentUserId", void 0), W = E("reactionUserNames", void 0), { startReply: X } = Be(v || ""), m = M(null), f = M(null), N = M("light"), { isNative: Y } = Le(v || ""), S = c(() => Qe), Z = c(() => n.mode), k = c(() => n.currentUserId ?? i(G)), U = c(() => n.reactionUserNames ?? i(W)), ee = c(() => {
85
+ const n = s, a = J, g = E("chatAppId"), G = E("currentUserId", void 0), W = E("reactionUserNames", void 0), { startReply: X } = Be(g || ""), m = M(null), f = M(null), N = M("light"), { isNative: Y } = Le(g || ""), S = c(() => Qe), Z = c(() => n.mode), k = c(() => n.currentUserId ?? i(G)), U = c(() => n.reactionUserNames ?? i(W)), ee = c(() => {
86
86
  var t, r;
87
87
  const e = (t = n.currentUserName) == null ? void 0 : t.trim();
88
88
  if (e) return e;
@@ -105,7 +105,7 @@ const Ve = ["onClick"], $e = { class: "message-reactions__emoji" }, ze = {
105
105
  quickReactionsRef: ue,
106
106
  quickPanelStyle: de,
107
107
  pickerStyle: me,
108
- closeQuickPanel: p,
108
+ closeQuickPanel: v,
109
109
  handleMessageMouseEnter: fe,
110
110
  handleMessageMouseLeave: pe,
111
111
  openFullPicker: ge,
@@ -117,8 +117,8 @@ const Ve = ["onClick"], $e = { class: "message-reactions__emoji" }, ze = {
117
117
  handleClickOutside: O
118
118
  } = re, ve = c(() => m.value ? Te(m.value) : !1), ye = () => {
119
119
  var o;
120
- if (!v) return "light";
121
- const e = document.getElementById(v);
120
+ if (!g) return "light";
121
+ const e = document.getElementById(g);
122
122
  return (o = e == null ? void 0 : e.getAttribute("data-theme")) != null && o.includes("dark") ? "dark" : "light";
123
123
  };
124
124
  function I() {
@@ -156,11 +156,11 @@ const Ve = ["onClick"], $e = { class: "message-reactions__emoji" }, ze = {
156
156
  const o = h(e);
157
157
  o && a("remove-reaction", { messageId: n.messageId, key: o }), a("add-reaction", { messageId: n.messageId, key: e });
158
158
  }
159
- p();
159
+ v();
160
160
  }
161
161
  }
162
162
  function be() {
163
- n.readonly || !n.enabled || !n.reply || (X(n.reply), p());
163
+ n.readonly || !n.enabled || !n.reply || (X(n.reply), v());
164
164
  }
165
165
  function Re(e) {
166
166
  if (n.readonly || !n.enabled || !n.menuEnabled) return;
@@ -168,13 +168,13 @@ const Ve = ["onClick"], $e = { class: "message-reactions__emoji" }, ze = {
168
168
  const r = o.getBoundingClientRect();
169
169
  return { top: r.top, right: r.right, bottom: r.bottom, left: r.left, width: r.width, height: r.height };
170
170
  })() : void 0;
171
- p(), a("menu", { messageId: n.messageId, triggerRect: t, event: e });
171
+ a("menu", { messageId: n.messageId, triggerRect: t, event: e });
172
172
  }
173
173
  async function Ee() {
174
174
  n.readonly || !n.enabled || (N.value = ye(), await ge());
175
175
  }
176
176
  function Me(e) {
177
- if (T(), p(), !I()) return;
177
+ if (T(), v(), !I()) return;
178
178
  const o = e.i;
179
179
  if (L(o))
180
180
  return;
@@ -190,7 +190,7 @@ const Ve = ["onClick"], $e = { class: "message-reactions__emoji" }, ze = {
190
190
  }), Se(
191
191
  () => [n.enabled, n.readonly],
192
192
  ([e, o]) => {
193
- (!e || o) && (p(), T());
193
+ (!e || o) && (v(), T());
194
194
  }
195
195
  ), (e, o) => (l(), d("div", {
196
196
  ref_key: "reactionsContainerRef",
@@ -207,11 +207,11 @@ const Ve = ["onClick"], $e = { class: "message-reactions__emoji" }, ze = {
207
207
  delay: 400
208
208
  }, {
209
209
  default: C(() => [
210
- g("button", {
210
+ p("button", {
211
211
  class: K(["message-reactions__chip", { "is-active": t.reactedByMe && t.count === 1 }]),
212
212
  onClick: (r) => ke(t.key)
213
213
  }, [
214
- g("span", $e, [
214
+ p("span", $e, [
215
215
  u(H, {
216
216
  emoji: t.key
217
217
  }, null, 8, ["emoji"])
@@ -224,7 +224,7 @@ const Ve = ["onClick"], $e = { class: "message-reactions__emoji" }, ze = {
224
224
  (l(), Q(je, { to: "body" }, [
225
225
  u(D, { name: "message-reactions-popover" }, {
226
226
  default: C(() => [
227
- V(g("div", {
227
+ V(p("div", {
228
228
  ref_key: "quickReactionsRef",
229
229
  ref: ue,
230
230
  class: "message-reactions__quick-panel",
@@ -242,7 +242,7 @@ const Ve = ["onClick"], $e = { class: "message-reactions__emoji" }, ze = {
242
242
  }, [
243
243
  u(H, { emoji: t }, null, 8, ["emoji"])
244
244
  ], 8, He))), 128)),
245
- g("button", {
245
+ p("button", {
246
246
  class: "message-reactions__expand",
247
247
  title: "Развернуть",
248
248
  onClick: y(Ee, ["stop"])
@@ -273,7 +273,7 @@ const Ve = ["onClick"], $e = { class: "message-reactions__emoji" }, ze = {
273
273
  }),
274
274
  u(D, { name: "message-reactions-popover" }, {
275
275
  default: C(() => [
276
- V(g("div", {
276
+ V(p("div", {
277
277
  ref_key: "pickerRef",
278
278
  ref: ce,
279
279
  class: "message-reactions__picker",
@@ -1,7 +1,7 @@
1
- import o from "./ReplyTextMessage.vue2.js";
1
+ import e from "./ReplyTextMessage.vue2.js";
2
2
  /* empty css */
3
- import t from "../../../_virtual/_plugin-vue_export-helper.js";
4
- const s = /* @__PURE__ */ t(o, [["__scopeId", "data-v-646d5d7c"]]);
3
+ import o from "../../../_virtual/_plugin-vue_export-helper.js";
4
+ const r = /* @__PURE__ */ o(e, [["__scopeId", "data-v-31ae85ec"]]);
5
5
  export {
6
- s as default
6
+ r as default
7
7
  };
@@ -1,15 +1,16 @@
1
- import { defineComponent as a, createElementBlock as r, openBlock as s, createCommentVNode as c, createElementVNode as l, toDisplayString as d, unref as t } from "vue";
1
+ import { defineComponent as x, computed as f, createElementBlock as r, openBlock as o, createBlock as h, withCtx as g, createElementVNode as s, createCommentVNode as p, toDisplayString as d, unref as u } from "vue";
2
+ import k from "../../1_atoms/Tooltip/Tooltip.vue.js";
2
3
  import "../../../locale/useLocale.js";
3
4
  /* empty css */
4
5
  import "../../../hooks/useTheme.js";
5
- import { useMessageLinks as u } from "../../../hooks/messages/useMessageLinks.js";
6
+ import { useMessageLinks as _ } from "../../../hooks/messages/useMessageLinks.js";
6
7
  import "../../../functions/parseMarkdown.js";
7
8
  import "../../../hooks/useMessageDraft.js";
8
9
  import "../../../hooks/useSearchModel.js";
9
10
  import "../../../hooks/useEmojiNative.js";
10
11
  /* empty css */
11
12
  /* empty css */
12
- const g = { class: "container" }, x = ["textContent"], f = ["innerHTML"], E = /* @__PURE__ */ a({
13
+ const C = { class: "reply-text-message__wrapper" }, y = ["textContent"], T = ["innerHTML"], M = ["textContent"], H = ["innerHTML"], A = /* @__PURE__ */ x({
13
14
  __name: "ReplyTextMessage",
14
15
  props: {
15
16
  message: {
@@ -17,22 +18,57 @@ const g = { class: "container" }, x = ["textContent"], f = ["innerHTML"], E = /*
17
18
  required: !0
18
19
  }
19
20
  },
20
- setup(e) {
21
- const i = e, { linkedHtml: m, inNewWindow: o } = u(() => i.message.text);
22
- return (k, n) => (s(), r("div", g, [
23
- e.message.header ? (s(), r("p", {
21
+ setup(t) {
22
+ const i = t, { linkedHtml: a } = _(() => i.message.text), c = f(() => {
23
+ var e;
24
+ return ((e = i.message.text) == null ? void 0 : e.trim()) || "";
25
+ }), l = (e) => {
26
+ var m;
27
+ const n = (m = e.target) == null ? void 0 : m.closest("a");
28
+ n instanceof HTMLAnchorElement && n.href && (e.preventDefault(), e.stopPropagation(), window.open(n.href, "_blank", "noopener,noreferrer"));
29
+ };
30
+ return (e, n) => (o(), r("div", C, [
31
+ c.value ? (o(), h(k, {
24
32
  key: 0,
25
- textContent: d(`В ответ ${e.message.header}`)
26
- }, null, 8, x)) : c("", !0),
27
- l("p", {
28
- class: "text",
29
- onClick: n[0] || (n[0] = //@ts-ignore
30
- (...p) => t(o) && t(o)(...p)),
31
- innerHTML: t(m)
32
- }, null, 8, f)
33
+ position: "top",
34
+ offset: 8,
35
+ delay: 1e3,
36
+ "max-width": "25rem",
37
+ text: c.value
38
+ }, {
39
+ default: g(() => [
40
+ s("div", {
41
+ class: "container",
42
+ onClick: l
43
+ }, [
44
+ t.message.header ? (o(), r("p", {
45
+ key: 0,
46
+ textContent: d(`В ответ ${t.message.header}`)
47
+ }, null, 8, y)) : p("", !0),
48
+ s("p", {
49
+ class: "text",
50
+ innerHTML: u(a)
51
+ }, null, 8, T)
52
+ ])
53
+ ]),
54
+ _: 1
55
+ }, 8, ["text"])) : (o(), r("div", {
56
+ key: 1,
57
+ class: "container",
58
+ onClick: l
59
+ }, [
60
+ t.message.header ? (o(), r("p", {
61
+ key: 0,
62
+ textContent: d(`В ответ ${t.message.header}`)
63
+ }, null, 8, M)) : p("", !0),
64
+ s("p", {
65
+ class: "text",
66
+ innerHTML: u(a)
67
+ }, null, 8, H)
68
+ ]))
33
69
  ]));
34
70
  }
35
71
  });
36
72
  export {
37
- E as default
73
+ A as default
38
74
  };
@@ -1,7 +1,7 @@
1
1
  import t from "./ChatInput.vue2.js";
2
2
  /* empty css */
3
3
  import o from "../../../_virtual/_plugin-vue_export-helper.js";
4
- const m = /* @__PURE__ */ o(t, [["__scopeId", "data-v-ab7a7750"]]);
4
+ const a = /* @__PURE__ */ o(t, [["__scopeId", "data-v-edf490bf"]]);
5
5
  export {
6
- m as default
6
+ a as default
7
7
  };
@@ -1,26 +1,27 @@
1
- import { defineComponent as X, inject as Z, ref as f, computed as h, watch as m, nextTick as v, unref as a, onMounted as ee, createElementBlock as g, openBlock as y, createElementVNode as u, createVNode as H, renderSlot as A, toDisplayString as te, createCommentVNode as ne, withDirectives as le, withKeys as ie, normalizeClass as E, vModelText as oe } from "vue";
2
- import { useImmediateDebouncedRef as se } from "../../../hooks/useImmediateDebouncedRef.js";
3
- import { useMessageDraft as ae } from "../../../hooks/useMessageDraft.js";
1
+ import { defineComponent as re, inject as ue, ref as f, computed as _, watch as h, nextTick as d, unref as r, onMounted as ce, createElementBlock as C, openBlock as I, createElementVNode as p, createVNode as P, renderSlot as W, toDisplayString as de, createCommentVNode as pe, withDirectives as fe, normalizeClass as H, withKeys as he, vModelText as me } from "vue";
2
+ import { useImmediateDebouncedRef as ve } from "../../../hooks/useImmediateDebouncedRef.js";
3
+ import { useMessageDraft as ge } from "../../../hooks/useMessageDraft.js";
4
4
  import "../../../hooks/useSearchModel.js";
5
5
  import "../../../hooks/useTheme.js";
6
- import { useEmojiNative as re } from "../../../hooks/useEmojiNative.js";
6
+ import { useEmojiNative as ye } from "../../../hooks/useEmojiNative.js";
7
7
  /* empty css */
8
8
  /* empty css */
9
- import { t as c } from "../../../locale/useLocale.js";
9
+ import { t as m } 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 ue } from "../../../functions/renderAppleEmojis.js";
15
- import ce from "./icons/SendIcon.vue.js";
16
- import de from "../../2_chatinput_elements/TextFormatToolbar/TextFormatToolbar.vue.js";
17
- const pe = { class: "chat-input__container" }, fe = ["id"], he = ["id"], me = { class: "chat-input__inline-buttons" }, ve = {
14
+ import { textToAppleEmojiHtml as xe, textContainsEmoji as _e } from "../../../functions/renderAppleEmojis.js";
15
+ import { hideEditPreview as Te } from "../../../hooks/messages/useStartEdit.js";
16
+ import be from "./icons/SendIcon.vue.js";
17
+ import Se from "../../2_chatinput_elements/TextFormatToolbar/TextFormatToolbar.vue.js";
18
+ const Ce = { class: "chat-input__container" }, Ie = ["id"], we = ["id"], Ae = { class: "chat-input__inline-buttons" }, Ee = {
18
19
  key: 0,
19
20
  class: "chat-input__input chat-input__disabled-placeholder"
20
- }, ge = {
21
+ }, Me = {
21
22
  key: 1,
22
23
  class: "chat-input__input-wrap"
23
- }, ye = ["innerHTML"], _e = ["disabled", "placeholder"], xe = ["disabled"], be = { class: "" }, Ie = { class: "chat-input__third-line" }, je = /* @__PURE__ */ X({
24
+ }, Fe = ["innerHTML"], He = ["disabled", "placeholder"], Re = ["disabled"], ke = { class: "" }, ze = { class: "chat-input__third-line" }, Ze = /* @__PURE__ */ re({
24
25
  __name: "ChatInput",
25
26
  props: {
26
27
  state: {
@@ -49,103 +50,164 @@ const pe = { class: "chat-input__container" }, fe = ["id"], he = ["id"], me = {
49
50
  }
50
51
  },
51
52
  emits: ["send", "typing"],
52
- setup(d, { emit: k }) {
53
- const _ = k, p = Z("chatAppId"), { resetMessage: D, getMessage: l, setMessageText: x, setForceSendMessage: F } = ae(p), { isNative: C } = re(p), n = f(), b = f(), L = se("", 2e3), P = f(), R = h(() => ue(l().text || "")), T = () => {
54
- b.value && n.value && (b.value.scrollTop = n.value.scrollTop);
55
- }, r = d, z = h(() => !!(r.state == "disabled" || l().text == "" && !l().file || l().isRecording)), B = h(() => {
53
+ setup(v, { emit: B }) {
54
+ const w = B, g = ue("chatAppId"), { resetMessage: L, getMessage: l, setMessageText: T, setForceSendMessage: j, resetEdit: q } = ge(g), { isNative: K } = ye(g), n = f(), A = f(), u = f(!1), y = f(!1), N = ve("", 2e3), R = f(), O = _(() => xe(l().text || "")), x = _(
55
+ () => !K.value && _e(l().text || "")
56
+ ), c = () => {
57
+ if (!A.value || !n.value) return;
58
+ const e = n.value, t = A.value, i = Math.max(0, e.offsetWidth - e.clientWidth);
59
+ t.style.right = i > 0 ? `${i}px` : "", t.scrollTop = e.scrollTop;
60
+ };
61
+ let b = 0;
62
+ function E() {
63
+ if (!x.value) {
64
+ u.value = !1;
65
+ return;
66
+ }
67
+ b && cancelAnimationFrame(b), b = requestAnimationFrame(() => {
68
+ b = 0;
69
+ const e = n.value;
70
+ if (!e) {
71
+ u.value = !1;
72
+ return;
73
+ }
74
+ const t = e.selectionStart !== e.selectionEnd;
75
+ u.value !== t && (u.value = t, t || d(c));
76
+ });
77
+ }
78
+ const a = v, Y = _(() => !!(a.state == "disabled" || l().text == "" && !l().file || l().isRecording)), $ = _(() => {
56
79
  var t;
57
- if (r.inputButtonColor)
58
- return r.inputButtonColor;
59
- if (!((t = r.selectedChannel) != null && t.channelId))
80
+ if (a.inputButtonColor)
81
+ return a.inputButtonColor;
82
+ if (!((t = a.selectedChannel) != null && t.channelId))
60
83
  return "#25D366";
61
- const e = r.selectedChannel.channelId.toLowerCase();
84
+ const e = a.selectedChannel.channelId.toLowerCase();
62
85
  return e.includes("whatsapp") || e.includes("waba") ? "#25D366" : e.includes("telegram") ? "#37AFE2" : e.includes("sms") ? "#6C757D" : e.includes("max") ? "#4B0082" : "#25D366";
63
- }), W = h(() => {
86
+ }), V = _(() => {
64
87
  var t;
65
- if (!((t = r.selectedChannel) != null && t.channelId))
66
- return c("component.ChatInput.InputPlaceholder");
67
- const e = r.selectedChannel.channelId.toLowerCase();
68
- return e.includes("whatsapp") || e.includes("waba") ? c("component.ChatInput.WhatsappInputPlaceholder") : e.includes("telegram") ? c("component.ChatInput.TelegramInputPlaceholder") : e.includes("sms") ? c("component.ChatInput.SmsInputPlaceholder") : e.includes("max") ? c("component.ChatInput.MaxInputPlaceholder") : c("component.ChatInput.InputPlaceholder");
88
+ if (!((t = a.selectedChannel) != null && t.channelId))
89
+ return m("component.ChatInput.InputPlaceholder");
90
+ const e = a.selectedChannel.channelId.toLowerCase();
91
+ return e.includes("whatsapp") || e.includes("waba") ? m("component.ChatInput.WhatsappInputPlaceholder") : e.includes("telegram") ? m("component.ChatInput.TelegramInputPlaceholder") : e.includes("sms") ? m("component.ChatInput.SmsInputPlaceholder") : e.includes("max") ? m("component.ChatInput.MaxInputPlaceholder") : m("component.ChatInput.InputPlaceholder");
69
92
  });
70
- m(
71
- () => L.value,
93
+ h(
94
+ () => N.value,
72
95
  () => {
73
- _("typing");
96
+ w("typing");
74
97
  }
75
- ), m(
76
- () => r.focusOnInputArea,
98
+ ), h(
77
99
  () => {
78
- r.focusOnInputArea && v(() => {
79
- const e = a(n);
100
+ var e;
101
+ return (e = l().edit) == null ? void 0 : e.messageId;
102
+ },
103
+ (e, t) => {
104
+ e != null && e !== t && (y.value = !0, d(() => {
105
+ if (!y.value) return;
106
+ const i = n.value;
107
+ i && (M(i), y.value = !1, S(i), requestAnimationFrame(() => S(i)));
108
+ }));
109
+ }
110
+ ), h(
111
+ () => a.focusOnInputArea,
112
+ () => {
113
+ a.focusOnInputArea && d(() => {
114
+ const e = r(n);
80
115
  e == null || e.focus();
81
116
  });
82
117
  },
83
118
  { immediate: !0 }
84
- ), m(
119
+ ), h(
85
120
  () => l().text,
86
121
  () => {
87
- v(() => {
122
+ d(() => {
88
123
  const e = n.value;
89
- if (!e) return;
90
- const t = e.scrollTop;
91
- e.style.height = "auto";
92
- const i = getComputedStyle(e), o = parseFloat(i.fontSize) || 16, q = parseFloat(i.lineHeight) || o * 1.4, S = 40, w = q * 11, M = e.scrollHeight, K = l().text.split(`
93
- `).length > 1, s = document.createElement("div");
94
- 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 = l().text, document.body.appendChild(s);
95
- const V = s.offsetWidth;
96
- document.body.removeChild(s);
97
- const $ = parseFloat(i.paddingLeft) || 0, G = parseFloat(i.paddingRight) || 0, U = e.clientWidth - $ - G, J = V > U, Q = K || J;
98
- l().text.trim() && Q ? M <= w ? (e.style.height = M + "px", e.style.overflowY = "hidden") : (e.style.height = w + "px", e.style.overflowY = "auto", e.scrollTop = t) : (e.style.height = S + "px", e.style.overflowY = "hidden"), T();
124
+ e && (M(e), y.value && (y.value = !1, S(e), requestAnimationFrame(() => S(e))));
99
125
  });
100
126
  },
101
127
  { immediate: !0 }
102
- ), m(
128
+ ), h(x, (e) => {
129
+ e && d(() => {
130
+ const t = n.value;
131
+ if (!t) return;
132
+ const i = t.scrollTop;
133
+ M(t), t.scrollTop = i, c(), requestAnimationFrame(c);
134
+ });
135
+ });
136
+ function M(e) {
137
+ const t = e.scrollTop;
138
+ e.style.height = "auto";
139
+ const i = getComputedStyle(e), o = parseFloat(i.fontSize) || 16, ee = parseFloat(i.lineHeight) || o * 1.4, k = 40, z = ee * 11, D = e.scrollHeight, te = l().text.split(`
140
+ `).length > 1, s = document.createElement("div");
141
+ 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 = l().text, document.body.appendChild(s);
142
+ const ne = s.offsetWidth;
143
+ document.body.removeChild(s);
144
+ const ie = parseFloat(i.paddingLeft) || 0, le = parseFloat(i.paddingRight) || 0, oe = e.clientWidth - ie - le, se = ne > oe, ae = te || se;
145
+ l().text.trim() && ae ? D <= z ? (e.style.height = D + "px", e.style.overflowY = "hidden") : (e.style.height = z + "px", e.style.overflowY = "auto", e.scrollTop = t) : (e.style.height = k + "px", e.style.overflowY = "hidden"), c(), requestAnimationFrame(c);
146
+ }
147
+ function S(e) {
148
+ if (a.state === "disabled" || l().isRecording) return;
149
+ const t = e.value.length;
150
+ e.focus(), e.setSelectionRange(t, t), e.scrollTop = e.scrollHeight, c();
151
+ }
152
+ h(
103
153
  () => l().forceSend,
104
154
  () => {
105
- l().forceSend && (I(), F(!1));
155
+ l().forceSend && (F(), j(!1));
106
156
  }
107
157
  );
108
- const j = (e) => {
158
+ const U = (e) => {
109
159
  const t = e.target;
110
- _("typing", t.value);
111
- }, N = () => {
112
- v(() => {
160
+ w("typing", t.value);
161
+ }, G = () => {
162
+ d(() => {
113
163
  const e = n.value;
114
164
  e && (e.style.height = "40px", e.style.overflowY = "hidden");
115
165
  });
116
166
  };
117
- ee(() => {
118
- N();
167
+ ce(() => {
168
+ G();
119
169
  });
120
- const O = (e) => {
170
+ const J = (e) => {
121
171
  if (e.shiftKey) {
122
172
  if (n.value instanceof HTMLTextAreaElement) {
123
173
  let t = n.value.selectionStart;
124
174
  t && (n.value.setRangeText(`
125
- `, t, t, "end"), x(n.value.value));
175
+ `, t, t, "end"), T(n.value.value));
126
176
  }
127
177
  e.preventDefault();
128
178
  } else if (e.ctrlKey) {
129
179
  if (n.value instanceof HTMLTextAreaElement) {
130
180
  let t = n.value.selectionStart;
131
181
  t && (n.value.setRangeText(`
132
- `, t, t, "end"), x(n.value.value));
182
+ `, t, t, "end"), T(n.value.value));
133
183
  }
134
184
  e.preventDefault();
135
185
  } else
136
- e.preventDefault(), I();
137
- }, Y = (e) => {
186
+ e.preventDefault(), F();
187
+ }, Q = (e) => {
138
188
  if (n.value) {
139
189
  const t = n.value.value;
140
190
  n.value.value = e.newText;
141
191
  const i = e.newText.length - (t.length - (e.end - e.start)), o = e.start + i;
142
- x(e.newText), v(() => {
192
+ T(e.newText), d(() => {
143
193
  n.value && (n.value.setSelectionRange(o, o), n.value.focus());
144
194
  });
145
195
  }
146
- }, I = () => {
196
+ };
197
+ function X() {
198
+ q(), T(""), Te(g), R.value = void 0, n.value && n.value.focus();
199
+ }
200
+ function Z() {
201
+ const e = l();
202
+ return e.edit ? (e.text ?? "").trim() === (e.edit.text ?? "").trim() : !1;
203
+ }
204
+ const F = () => {
147
205
  var t, i;
148
206
  const e = f(l());
207
+ if (e.value.edit && Z()) {
208
+ X();
209
+ return;
210
+ }
149
211
  if (e.value.text != "" || e.value.file) {
150
212
  const o = {
151
213
  type: "",
@@ -155,63 +217,70 @@ const pe = { class: "chat-input__container" }, fe = ["id"], he = ["id"], me = {
155
217
  size: "",
156
218
  reply: void 0
157
219
  };
158
- e.value.file ? (o.type = "message." + e.value.file.type, o.url = e.value.file.url, o.filename = e.value.file.name, o.size = (t = e.value.file.size) == null ? void 0 : t.toString(), o.text = (i = e == null ? void 0 : e.value) == null ? void 0 : i.text.trim()) : (o.type = "message.text", o.text = e.value.text.trim()), e.value.reply && (o.reply = e.value.reply), e.value.edit && (o.edit = e.value.edit), _("send", o), D(), P.value = void 0, n.value && n.value.focus();
220
+ e.value.file ? (o.type = "message." + e.value.file.type, o.url = e.value.file.url, o.filename = e.value.file.name, o.size = (t = e.value.file.size) == null ? void 0 : t.toString(), o.text = (i = e == null ? void 0 : e.value) == null ? void 0 : i.text.trim()) : (o.type = "message.text", o.text = e.value.text.trim()), e.value.reply && (o.reply = e.value.reply), e.value.edit && (o.edit = e.value.edit), w("send", o), L(), R.value = void 0, n.value && n.value.focus();
159
221
  }
160
222
  };
161
- return (e, t) => (y(), g("div", pe, [
162
- u("div", {
163
- id: "chat-input-reply-line-" + a(p),
223
+ return (e, t) => (I(), C("div", Ce, [
224
+ p("div", {
225
+ id: "chat-input-reply-line-" + r(g),
164
226
  class: "chat-input__reply-line"
165
- }, null, 8, fe),
166
- u("div", {
167
- id: "chat-input-file-line-" + a(p),
227
+ }, null, 8, Ie),
228
+ p("div", {
229
+ id: "chat-input-file-line-" + r(g),
168
230
  class: "chat-input__file-line"
169
- }, null, 8, he),
170
- u("div", me, [
171
- A(e.$slots, "inline-buttons", {}, void 0, !0)
231
+ }, null, 8, we),
232
+ p("div", Ae, [
233
+ W(e.$slots, "inline-buttons", {}, void 0, !0)
172
234
  ]),
173
- d.disabledPlaceholder && (d.state == "disabled" || a(l)().isRecording) ? (y(), g("div", ve, te(d.disabledPlaceholder), 1)) : (y(), g("div", ge, [
174
- !a(C) && a(l)().text ? (y(), g("div", {
235
+ v.disabledPlaceholder && (v.state == "disabled" || r(l)().isRecording) ? (I(), C("div", Ee, de(v.disabledPlaceholder), 1)) : (I(), C("div", Me, [
236
+ x.value ? (I(), C("div", {
175
237
  key: 0,
176
238
  ref_key: "refMirror",
177
- ref: b,
178
- class: "chat-input__input-mirror",
239
+ ref: A,
240
+ class: H(["chat-input__input-mirror", { "chat-input__input-mirror--hidden": u.value }]),
179
241
  "aria-hidden": "true",
180
- innerHTML: R.value
181
- }, null, 8, ye)) : ne("", !0),
182
- le(u("textarea", {
242
+ innerHTML: O.value
243
+ }, null, 10, Fe)) : pe("", !0),
244
+ fe(p("textarea", {
183
245
  ref_key: "refInput",
184
246
  ref: n,
185
- "onUpdate:modelValue": t[0] || (t[0] = (i) => a(l)().text = i),
186
- disabled: d.state == "disabled" || a(l)().isRecording,
187
- class: E(["chat-input__input", { "chat-input__input--emoji-images": !a(C) }]),
188
- placeholder: W.value,
189
- onKeydown: ie(O, ["enter"]),
190
- onInput: j,
191
- onScroll: T
192
- }, null, 42, _e), [
193
- [oe, a(l)().text]
247
+ "onUpdate:modelValue": t[0] || (t[0] = (i) => r(l)().text = i),
248
+ disabled: v.state == "disabled" || r(l)().isRecording,
249
+ class: H(["chat-input__input", {
250
+ "chat-input__input--emoji-images": x.value && !u.value,
251
+ "chat-input__input--selecting": x.value && u.value
252
+ }]),
253
+ placeholder: V.value,
254
+ onKeydown: he(J, ["enter"]),
255
+ onInput: U,
256
+ onScroll: c,
257
+ onSelect: E,
258
+ onMouseup: E,
259
+ onKeyup: E,
260
+ onBlur: t[1] || (t[1] = (i) => u.value = !1)
261
+ }, null, 42, He), [
262
+ [me, r(l)().text]
194
263
  ])
195
264
  ])),
196
- H(de, {
265
+ P(Se, {
197
266
  textarea: n.value,
198
- onFormatApplied: Y
267
+ onFormatApplied: Q
199
268
  }, null, 8, ["textarea"]),
200
- u("button", {
201
- class: E(["chat-input__button", { "chat-input__button-disabled": z.value }]),
202
- disabled: a(l)().isRecording,
203
- onClick: I
269
+ p("button", {
270
+ class: H(["chat-input__button", { "chat-input__button-disabled": Y.value }]),
271
+ disabled: r(l)().isRecording,
272
+ onClick: F
204
273
  }, [
205
- u("span", be, [
206
- H(a(ce), { color: B.value }, null, 8, ["color"])
274
+ p("span", ke, [
275
+ P(r(be), { color: $.value }, null, 8, ["color"])
207
276
  ])
208
- ], 10, xe),
209
- u("div", Ie, [
210
- A(e.$slots, "buttons", {}, void 0, !0)
277
+ ], 10, Re),
278
+ p("div", ze, [
279
+ W(e.$slots, "buttons", {}, void 0, !0)
211
280
  ])
212
281
  ]));
213
282
  }
214
283
  });
215
284
  export {
216
- je as default
285
+ Ze as default
217
286
  };
@@ -1,11 +1,28 @@
1
- import { computed as n } from "vue";
1
+ import { computed as p } from "vue";
2
+ const n = /* @__PURE__ */ new Set([
3
+ "message.system",
4
+ "message.typing",
5
+ "message.delimiter",
6
+ "system.date"
7
+ ]);
8
+ function d(r, i) {
9
+ for (let e = i - 1; e >= 0; e--)
10
+ if (!n.has(r[e].type))
11
+ return r[e];
12
+ return null;
13
+ }
2
14
  function a({ objects: r }) {
3
15
  return {
4
- groupedObjects: n(() => !r.value || r.value.length === 0 ? [] : r.value.map((s, e, t) => {
5
- const o = e > 0 && t[e - 1].position === s.position && t[e - 1].header === s.header, u = e > 0 && !["message.system", "message.typing"].includes(t[e - 1].type);
16
+ groupedObjects: p(() => !r.value || r.value.length === 0 ? [] : r.value.map((e, u, s) => {
17
+ if (n.has(e.type))
18
+ return {
19
+ ...e,
20
+ isFirstInSeries: !0
21
+ };
22
+ const t = d(s, u), o = t != null && t.position === e.position && t.header === e.header;
6
23
  return {
7
- ...s,
8
- isFirstInSeries: !o || !u
24
+ ...e,
25
+ isFirstInSeries: !o
9
26
  };
10
27
  }))
11
28
  };