@mobilon-dev/chotto 0.3.99 → 0.3.100

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 (25) hide show
  1. package/dist/chotto.css +1 -1
  2. package/dist/components/1_atoms/EmojiGlyph/EmojiGlyph.vue.js +15 -15
  3. package/dist/components/2_chatinput_elements/ButtonEmojiPicker/ButtonEmojiPicker.vue.js +1 -1
  4. package/dist/components/2_chatinput_elements/ButtonEmojiPicker/ButtonEmojiPicker.vue2.js +79 -65
  5. package/dist/components/2_chatlist_elements/ChatItem/ChatItem.vue.js +1 -1
  6. package/dist/components/2_chatlist_elements/ChatItem/ChatItem.vue2.js +150 -150
  7. package/dist/components/2_feed_elements/MessageReactions/MessageReactions.vue.js +2 -2
  8. package/dist/components/2_feed_elements/MessageReactions/MessageReactions.vue2.js +79 -78
  9. package/dist/components/2_feed_elements/ReplyStickerMessage/ReplyStickerMessage.vue.js +2 -2
  10. package/dist/components/2_feed_elements/ReplyStickerMessage/ReplyStickerMessage.vue2.js +42 -42
  11. package/dist/components/3_compounds/ChatInput/ChatInput.vue.js +2 -2
  12. package/dist/components/3_compounds/ChatInput/ChatInput.vue2.js +68 -68
  13. package/dist/functions/renderAppleEmojis.js +120 -91
  14. package/dist/hooks/messages/useMessageLinks.js +15 -15
  15. package/dist/hooks/useEmojiNative.js +24 -12
  16. package/dist/node_modules/vue3-emoji-picker-ru/dist/emoji-picker.es.js +581 -555
  17. package/dist/themes/dark.css +1 -1
  18. package/dist/themes/default.css +1 -1
  19. package/dist/themes/glass.css +1 -1
  20. package/dist/themes/green.css +1 -1
  21. package/dist/themes/mobilon1.css +1 -1
  22. package/dist/types/components/2_chatinput_elements/ButtonEmojiPicker/ButtonEmojiPicker.vue.d.ts +21 -2
  23. package/dist/types/functions/renderAppleEmojis.d.ts +13 -10
  24. package/dist/types/hooks/useEmojiNative.d.ts +5 -2
  25. package/package.json +2 -2
@@ -1,9 +1,9 @@
1
- import { defineComponent as be, inject as we, watch as d, ref as E, computed as _, nextTick as S, unref as u, onMounted as Ce, onUnmounted as Ae, createElementBlock as k, openBlock as F, createElementVNode as h, createVNode as O, normalizeClass as z, createBlock as Ee, createCommentVNode as U, renderSlot as Y, toDisplayString as Fe, withDirectives as Me, withKeys as Re, vModelText as He } from "vue";
2
- import { useImmediateDebouncedRef as ke } from "../../../hooks/useImmediateDebouncedRef.js";
3
- import { useMessageDraft as Le, commitChatDraftToList as De } from "../../../hooks/useMessageDraft.js";
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";
4
4
  import "../../../hooks/useSearchModel.js";
5
5
  import "../../../hooks/useTheme.js";
6
- import { useEmojiNative as Pe } from "../../../hooks/useEmojiNative.js";
6
+ import { useEmojiNative as We } from "../../../hooks/useEmojiNative.js";
7
7
  /* empty css */
8
8
  /* empty css */
9
9
  import { t as I } from "../../../locale/useLocale.js";
@@ -11,18 +11,18 @@ import { t as I } from "../../../locale/useLocale.js";
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 We, textContainsEmoji as qe, previousGraphemeIndex as V, nextGraphemeIndex as $, snapIndexToGrapheme as J } from "../../../functions/renderAppleEmojis.js";
15
- import { hideEditPreview as Be } from "../../../hooks/messages/useStartEdit.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
16
  import ze from "./icons/SendIcon.vue.js";
17
17
  import Ke from "../../2_chatinput_elements/TextFormatToolbar/TextFormatToolbar.vue.js";
18
- import je from "../../2_chatinput_elements/FilePreview/FilePreview.vue.js";
19
- const Ne = { class: "chat-input__container" }, Ge = ["id"], Oe = ["id"], Ue = { class: "chat-input__inline-buttons" }, Ye = {
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 = {
20
20
  key: 0,
21
21
  class: "chat-input__input chat-input__disabled-placeholder"
22
- }, Ve = {
22
+ }, $e = {
23
23
  key: 1,
24
24
  class: "chat-input__input-wrap"
25
- }, $e = ["innerHTML"], Je = ["disabled", "placeholder"], Qe = ["disabled"], Xe = { class: "" }, Ze = { class: "chat-input__third-line" }, K = 40, xt = /* @__PURE__ */ be({
25
+ }, Je = ["innerHTML"], Qe = ["disabled", "placeholder"], Xe = ["disabled"], Ze = { class: "" }, et = { class: "chat-input__third-line" }, z = 40, _t = /* @__PURE__ */ we({
26
26
  __name: "ChatInput",
27
27
  props: {
28
28
  state: {
@@ -52,21 +52,21 @@ const Ne = { class: "chat-input__container" }, Ge = ["id"], Oe = ["id"], Ue = {
52
52
  },
53
53
  emits: ["send", "typing"],
54
54
  setup(T, { emit: Q }) {
55
- const L = Q, b = we("chatAppId"), { resetMessage: X, getMessage: l, setMessageText: M, setForceSendMessage: Z, resetEdit: ee, resetMessageFile: te } = Le(b), { isNative: ne } = Pe(b);
56
- let j = l().id;
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
57
  d(
58
58
  () => l().id,
59
59
  (e) => {
60
- j = e;
60
+ K = e;
61
61
  }
62
62
  );
63
- const n = E(), m = E(), v = E(null), w = E(!1), ie = ke("", 2e3), D = _(() => {
63
+ const n = E(), m = E(), v = E(null), w = E(!1), oe = Le("", 2e3), D = _(() => {
64
64
  var e;
65
65
  return (e = l().file) == null ? void 0 : e.preview;
66
- }), oe = _(
67
- () => We(l().text || "", v.value)
66
+ }), le = _(
67
+ () => qe(l().text || "", v.value, ie.value)
68
68
  ), g = _(
69
- () => !ne.value && qe(l().text || "")
69
+ () => !ne.value && Be(l().text || "")
70
70
  ), c = () => {
71
71
  if (!m.value || !n.value) return;
72
72
  const e = n.value, t = m.value, o = Math.max(0, e.offsetWidth - e.clientWidth);
@@ -76,16 +76,16 @@ const Ne = { class: "chat-input__container" }, Ge = ["id"], Oe = ["id"], Ue = {
76
76
  function P() {
77
77
  v.value = null;
78
78
  }
79
- function le(e = "nearest") {
79
+ function se(e = "nearest") {
80
80
  const t = n.value;
81
81
  if (!t || !g.value) return;
82
82
  const o = t.value, i = J(o, t.selectionStart, e), r = J(o, t.selectionEnd, e);
83
83
  (i !== t.selectionStart || r !== t.selectionEnd) && t.setSelectionRange(i, r);
84
84
  }
85
85
  function W() {
86
- le("nearest"), f();
86
+ se("nearest"), f();
87
87
  }
88
- function se(e) {
88
+ function ae(e) {
89
89
  if (!g.value || e.key !== "ArrowLeft" && e.key !== "ArrowRight" || e.altKey || e.metaKey || e.ctrlKey) return;
90
90
  const t = n.value;
91
91
  if (!t) return;
@@ -130,13 +130,13 @@ const Ne = { class: "chat-input__container" }, Ge = ["id"], Oe = ["id"], Ue = {
130
130
  });
131
131
  });
132
132
  }
133
- function ae(e) {
133
+ function re(e) {
134
134
  e.buttons && f();
135
135
  }
136
136
  function N() {
137
137
  document.activeElement === n.value && f();
138
138
  }
139
- const a = T, re = _(() => !!(a.state == "disabled" || l().text == "" && !l().file || l().isRecording)), ue = _(() => {
139
+ const a = T, ue = _(() => !!(a.state == "disabled" || l().text == "" && !l().file || l().isRecording)), ce = _(() => {
140
140
  var t;
141
141
  if (a.inputButtonColor)
142
142
  return a.inputButtonColor;
@@ -144,7 +144,7 @@ const Ne = { class: "chat-input__container" }, Ge = ["id"], Oe = ["id"], Ue = {
144
144
  return "#25D366";
145
145
  const e = a.selectedChannel.channelId.toLowerCase();
146
146
  return e.includes("whatsapp") || e.includes("waba") ? "#25D366" : e.includes("telegram") ? "#37AFE2" : e.includes("sms") ? "#6C757D" : e.includes("max") ? "#4B0082" : "#25D366";
147
- }), ce = _(() => {
147
+ }), de = _(() => {
148
148
  var t;
149
149
  if (!((t = a.selectedChannel) != null && t.channelId))
150
150
  return I("component.ChatInput.InputPlaceholder");
@@ -152,7 +152,7 @@ const Ne = { class: "chat-input__container" }, Ge = ["id"], Oe = ["id"], Ue = {
152
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");
153
153
  });
154
154
  d(
155
- () => ie.value,
155
+ () => oe.value,
156
156
  () => {
157
157
  L("typing");
158
158
  }
@@ -203,9 +203,9 @@ const Ne = { class: "chat-input__container" }, Ge = ["id"], Oe = ["id"], Ue = {
203
203
  });
204
204
  function R(e) {
205
205
  const t = l().inputHeight;
206
- e.style.height = (t || K) + "px", (!t || t <= K) && (e.style.overflowY = "hidden");
206
+ e.style.height = (t || z) + "px", (!t || t <= z) && (e.style.overflowY = "hidden");
207
207
  }
208
- function de(e) {
208
+ function fe(e) {
209
209
  const t = parseFloat(e.style.height);
210
210
  Number.isFinite(t) && (l().inputHeight = t);
211
211
  }
@@ -217,17 +217,17 @@ const Ne = { class: "chat-input__container" }, Ge = ["id"], Oe = ["id"], Ue = {
217
217
  }
218
218
  const o = e.scrollTop;
219
219
  e.style.height = "auto";
220
- const i = getComputedStyle(e), r = parseFloat(i.fontSize) || 16, p = parseFloat(i.lineHeight) || r * 1.4, x = K, A = p * 11, B = e.scrollHeight, ye = t.split(`
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
221
  `).length > 1, s = document.createElement("div");
222
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 xe = s.offsetWidth;
223
+ const _e = s.offsetWidth;
224
224
  document.body.removeChild(s);
225
- const _e = parseFloat(i.paddingLeft) || 0, Se = parseFloat(i.paddingRight) || 0, Ie = e.clientWidth - _e - Se, Te = xe > Ie, G = ye || Te;
225
+ const Se = parseFloat(i.paddingLeft) || 0, Ie = parseFloat(i.paddingRight) || 0, Te = e.clientWidth - Se - Ie, be = _e > Te, G = xe || be;
226
226
  if (G && B <= x + 1) {
227
227
  R(e);
228
228
  return;
229
229
  }
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"), de(e), c(), requestAnimationFrame(c);
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);
231
231
  }
232
232
  function H(e) {
233
233
  if (a.state === "disabled" || l().isRecording) return;
@@ -240,17 +240,17 @@ const Ne = { class: "chat-input__container" }, Ge = ["id"], Oe = ["id"], Ue = {
240
240
  l().forceSend && (q(), Z(!1));
241
241
  }
242
242
  );
243
- const fe = (e) => {
243
+ const pe = (e) => {
244
244
  const t = e.target;
245
245
  L("typing", t.value), f();
246
246
  };
247
- Ce(() => {
247
+ Ae(() => {
248
248
  const e = n.value;
249
249
  e && (R(e), C(e)), document.addEventListener("selectionchange", N);
250
- }), Ae(() => {
251
- De(j), document.removeEventListener("selectionchange", N), y && cancelAnimationFrame(y);
250
+ }), Ee(() => {
251
+ Pe(K), document.removeEventListener("selectionchange", N), y && cancelAnimationFrame(y);
252
252
  });
253
- const pe = (e) => {
253
+ const he = (e) => {
254
254
  if (e.shiftKey) {
255
255
  if (n.value instanceof HTMLTextAreaElement) {
256
256
  let t = n.value.selectionStart;
@@ -267,7 +267,7 @@ const Ne = { class: "chat-input__container" }, Ge = ["id"], Oe = ["id"], Ue = {
267
267
  e.preventDefault();
268
268
  } else
269
269
  e.preventDefault(), q();
270
- }, he = (e) => {
270
+ }, me = (e) => {
271
271
  if (n.value) {
272
272
  const t = n.value.value;
273
273
  n.value.value = e.newText;
@@ -277,21 +277,21 @@ const Ne = { class: "chat-input__container" }, Ge = ["id"], Oe = ["id"], Ue = {
277
277
  });
278
278
  }
279
279
  };
280
- function me() {
281
- te();
282
- }
283
280
  function ve() {
284
- ee(), M(""), Be(b), n.value && n.value.focus();
281
+ te();
285
282
  }
286
283
  function ge() {
284
+ ee(), M(""), je(b), n.value && n.value.focus();
285
+ }
286
+ function ye() {
287
287
  const e = l();
288
288
  return e.edit ? (e.text ?? "").trim() === (e.edit.text ?? "").trim() : !1;
289
289
  }
290
290
  const q = () => {
291
291
  var t, o;
292
292
  const e = E(l());
293
- if (e.value.edit && ge()) {
294
- ve();
293
+ if (e.value.edit && ye()) {
294
+ ge();
295
295
  return;
296
296
  }
297
297
  if (e.value.text != "" || e.value.file) {
@@ -306,75 +306,75 @@ const Ne = { class: "chat-input__container" }, Ge = ["id"], Oe = ["id"], Ue = {
306
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();
307
307
  }
308
308
  };
309
- return (e, t) => (F(), k("div", Ne, [
309
+ return (e, t) => (F(), k("div", Ge, [
310
310
  h("div", {
311
311
  id: "chat-input-reply-line-" + u(b),
312
312
  class: "chat-input__reply-line"
313
- }, null, 8, Ge),
313
+ }, null, 8, Oe),
314
314
  h("div", {
315
315
  id: "chat-input-file-line-" + u(b),
316
- class: z(["chat-input__file-line", { "chat-input__file-line--visible": !!D.value }])
316
+ class: j(["chat-input__file-line", { "chat-input__file-line--visible": !!D.value }])
317
317
  }, [
318
- D.value ? (F(), Ee(je, {
318
+ D.value ? (F(), Fe(Ne, {
319
319
  key: 0,
320
320
  "file-info": D.value,
321
- onReset: me
321
+ onReset: ve
322
322
  }, null, 8, ["file-info"])) : U("", !0)
323
- ], 10, Oe),
324
- h("div", Ue, [
323
+ ], 10, Ue),
324
+ h("div", Ye, [
325
325
  Y(e.$slots, "inline-buttons", {}, void 0, !0)
326
326
  ]),
327
- T.disabledPlaceholder && (T.state == "disabled" || u(l)().isRecording) ? (F(), k("div", Ye, Fe(T.disabledPlaceholder), 1)) : (F(), k("div", Ve, [
327
+ T.disabledPlaceholder && (T.state == "disabled" || u(l)().isRecording) ? (F(), k("div", Ve, Me(T.disabledPlaceholder), 1)) : (F(), k("div", $e, [
328
328
  g.value ? (F(), k("div", {
329
329
  key: 0,
330
330
  ref_key: "refMirror",
331
331
  ref: m,
332
332
  class: "chat-input__input-mirror",
333
333
  "aria-hidden": "true",
334
- innerHTML: oe.value
335
- }, null, 8, $e)) : U("", !0),
336
- Me(h("textarea", {
334
+ innerHTML: le.value
335
+ }, null, 8, Je)) : U("", !0),
336
+ Re(h("textarea", {
337
337
  ref_key: "refInput",
338
338
  ref: n,
339
339
  "onUpdate:modelValue": t[0] || (t[0] = (o) => u(l)().text = o),
340
340
  rows: "1",
341
341
  disabled: T.state == "disabled" || u(l)().isRecording,
342
- class: z(["chat-input__input", { "chat-input__input--emoji-images": g.value }]),
343
- placeholder: ce.value,
342
+ class: j(["chat-input__input", { "chat-input__input--emoji-images": g.value }]),
343
+ placeholder: de.value,
344
344
  onKeydown: [
345
- se,
346
- Re(pe, ["enter"])
345
+ ae,
346
+ He(he, ["enter"])
347
347
  ],
348
- onInput: fe,
348
+ onInput: pe,
349
349
  onScroll: c,
350
350
  onSelect: f,
351
351
  onMouseup: W,
352
352
  onKeyup: W,
353
- onMousemove: ae,
353
+ onMousemove: re,
354
354
  onBlur: P
355
- }, null, 42, Je), [
356
- [He, u(l)().text]
355
+ }, null, 42, Qe), [
356
+ [ke, u(l)().text]
357
357
  ])
358
358
  ])),
359
359
  O(Ke, {
360
360
  textarea: n.value,
361
- onFormatApplied: he
361
+ onFormatApplied: me
362
362
  }, null, 8, ["textarea"]),
363
363
  h("button", {
364
- class: z(["chat-input__button", { "chat-input__button-disabled": re.value }]),
364
+ class: j(["chat-input__button", { "chat-input__button-disabled": ue.value }]),
365
365
  disabled: u(l)().isRecording,
366
366
  onClick: q
367
367
  }, [
368
- h("span", Xe, [
369
- O(u(ze), { color: ue.value }, null, 8, ["color"])
368
+ h("span", Ze, [
369
+ O(u(ze), { color: ce.value }, null, 8, ["color"])
370
370
  ])
371
- ], 10, Qe),
372
- h("div", Ze, [
371
+ ], 10, Xe),
372
+ h("div", et, [
373
373
  Y(e.$slots, "buttons", {}, void 0, !0)
374
374
  ])
375
375
  ]));
376
376
  }
377
377
  });
378
378
  export {
379
- xt as default
379
+ _t as default
380
380
  };
@@ -1,36 +1,50 @@
1
- const g = "https://cdn.jsdelivr.net/npm/emoji-datasource-apple@6.0.1/img/apple/64", l = new RegExp("(?:\\p{Regional_Indicator}{2})|(?:[#*0-9]\\uFE0F?\\u20E3)|(?:\\p{Extended_Pictographic}(?:\\uFE0F|\\uFE0E)?(?:\\p{Emoji_Modifier})?(?:\\u200D(?:\\p{Extended_Pictographic}|\\p{Emoji_Modifier_Base})(?:\\uFE0F|\\uFE0E)?(?:\\p{Emoji_Modifier})?)*)", "gu"), I = "position:relative;display:inline-block;vertical-align:baseline;", T = "visibility:hidden;", _ = "position:absolute;left:0;top:0;width:100%;height:100%;object-fit:contain;pointer-events:none;display:block;margin:0;", b = Intl.Segmenter, p = typeof Intl < "u" && b ? new b(void 0, { granularity: "grapheme" }) : null;
2
- function v(t, e, r = "nearest") {
1
+ const i = "https://cdn.jsdelivr.net/npm/emoji-datasource-apple@6.0.1/img/apple/64";
2
+ function f(t) {
3
+ return (t || i).trim().replace(/\/+$/, "") || i;
4
+ }
5
+ function b(t) {
6
+ return /emoji-datasource-apple/i.test(t);
7
+ }
8
+ const I = /* @__PURE__ */ new Set([
9
+ "2640",
10
+ "2640-fe0f",
11
+ "2642",
12
+ "2642-fe0f",
13
+ "2695",
14
+ "2695-fe0f"
15
+ ]), u = new RegExp("(?:\\p{Regional_Indicator}{2})|(?:[#*0-9]\\uFE0F?\\u20E3)|(?:\\p{Extended_Pictographic}(?:\\uFE0F|\\uFE0E)?(?:\\p{Emoji_Modifier})?(?:\\u200D(?:\\p{Extended_Pictographic}|\\p{Emoji_Modifier_Base})(?:\\uFE0F|\\uFE0E)?(?:\\p{Emoji_Modifier})?)*)", "gu"), v = "position:relative;display:inline-block;vertical-align:baseline;", M = "visibility:hidden;", $ = "position:absolute;left:0;top:0;width:100%;height:100%;object-fit:contain;pointer-events:none;display:block;margin:0;", C = Intl.Segmenter, m = typeof Intl < "u" && C ? new C(void 0, { granularity: "grapheme" }) : null;
16
+ function O(t, e, r = "nearest") {
3
17
  const n = t.length;
4
18
  if (e <= 0) return 0;
5
19
  if (e >= n) return n;
6
- if (p) {
7
- let s = 0;
8
- for (const { index: a } of p.segment(t)) {
9
- if (a === e) return e;
10
- if (a > e)
11
- return r === "before" ? s : r === "after" ? a : e - s <= a - e ? s : a;
12
- s = a;
20
+ if (m) {
21
+ let a = 0;
22
+ for (const { index: c } of m.segment(t)) {
23
+ if (c === e) return e;
24
+ if (c > e)
25
+ return r === "before" ? a : r === "after" ? c : e - a <= c - e ? a : c;
26
+ a = c;
13
27
  }
14
28
  return n;
15
29
  }
16
30
  const o = t.charCodeAt(e);
17
31
  return o >= 56320 && o <= 57343 ? r === "after" ? Math.min(n, e + 1) : e - 1 : e;
18
32
  }
19
- function C(t, e) {
33
+ function w(t, e) {
20
34
  if (e >= t.length) return t.length;
21
- if (p) {
22
- for (const { index: n } of p.segment(t))
35
+ if (m) {
36
+ for (const { index: n } of m.segment(t))
23
37
  if (n > e) return n;
24
38
  return t.length;
25
39
  }
26
40
  const r = t.codePointAt(e);
27
41
  return e + (r !== void 0 && r > 65535 ? 2 : 1);
28
42
  }
29
- function j(t, e) {
43
+ function P(t, e) {
30
44
  if (e <= 0) return 0;
31
- if (p) {
45
+ if (m) {
32
46
  let n = 0;
33
- for (const { index: o } of p.segment(t)) {
47
+ for (const { index: o } of m.segment(t)) {
34
48
  if (o >= e) return n;
35
49
  n = o;
36
50
  }
@@ -39,7 +53,7 @@ function j(t, e) {
39
53
  const r = t.charCodeAt(e - 1);
40
54
  return r >= 56320 && r <= 57343 ? e - 2 : e - 1;
41
55
  }
42
- function d(t, e) {
56
+ function p(t, e) {
43
57
  const r = [];
44
58
  for (const n of t) {
45
59
  const o = n.codePointAt(0);
@@ -47,107 +61,122 @@ function d(t, e) {
47
61
  }
48
62
  return r.join("-");
49
63
  }
50
- function $(t) {
51
- return `${g}/${d(t)}.png`;
64
+ function A(t, e = i) {
65
+ const r = f(e), n = p(t);
66
+ if (!n || b(r) && I.has(n)) return !1;
67
+ const o = p(t, { stripVariationSelectors: !0 });
68
+ return !(b(r) && I.has(o));
69
+ }
70
+ function S(t, e = i) {
71
+ return `${f(e)}/${p(t)}.png`;
52
72
  }
53
- function A(t) {
54
- const e = d(t), r = d(t, { stripVariationSelectors: !0 });
55
- if (e !== r)
56
- return `${g}/${r}.png`;
73
+ function k(t, e = i) {
74
+ const r = f(e);
75
+ if (!A(t, r)) return null;
76
+ const n = p(t), o = p(t, { stripVariationSelectors: !0 });
77
+ if (n !== o)
78
+ return b(r) && I.has(o) ? null : `${r}/${o}.png`;
57
79
  if (!/[\uFE0E\uFE0F]/.test(t)) {
58
- const n = d(`${t}️`);
59
- if (n !== e)
60
- return `${g}/${n}.png`;
80
+ const a = p(`${t}️`);
81
+ if (a !== n)
82
+ return b(r) && I.has(a) ? null : `${r}/${a}.png`;
61
83
  }
62
84
  return null;
63
85
  }
64
- function k(t, e) {
65
- const r = A(e);
66
- r && t.addEventListener(
86
+ function y(t, e, r) {
87
+ const n = k(e, r);
88
+ n && t.addEventListener(
67
89
  "error",
68
90
  () => {
69
- t.src !== r && (t.src = r);
91
+ t.src !== n && (t.src = n);
70
92
  },
71
93
  { once: !0 }
72
94
  );
73
95
  }
74
- function M(t) {
75
- const e = d(t);
76
- if (!e) return E(t);
77
- const r = `${g}/${e}.png`, n = A(t), o = n ? ` data-fallback="${h(n)}" onerror="if(this.dataset.fallback&&this.src!==this.dataset.fallback){this.onerror=null;this.src=this.dataset.fallback}"` : "";
78
- return `<span class="chotto-emoji-slot" style="${I}"><span class="chotto-emoji-metric" style="${T}">${E(t)}</span><img class="chotto-emoji" src="${h(r)}" alt="${h(t)}" draggable="false" style="${_}"${o} /></span>`;
79
- }
80
- function N(t) {
81
- const e = document.createElement("span");
82
- e.className = "chotto-emoji-slot", e.setAttribute("style", I);
83
- const r = document.createElement("span");
84
- r.className = "chotto-emoji-metric", r.setAttribute("style", T), r.textContent = t;
85
- const n = document.createElement("img");
86
- return n.className = "chotto-emoji", n.src = $(t), n.alt = t, n.draggable = !1, n.setAttribute("style", _), k(n, t), e.append(r, n), e;
87
- }
88
- function h(t) {
96
+ function j(t, e = i) {
97
+ const r = f(e), n = p(t);
98
+ if (!n || !A(t, r)) return _(t);
99
+ const o = `${r}/${n}.png`, a = k(t, r), c = a ? ` data-fallback="${T(a)}" onerror="if(this.dataset.fallback&&this.src!==this.dataset.fallback){this.onerror=null;this.src=this.dataset.fallback}"` : "";
100
+ return `<span class="chotto-emoji-slot" style="${v}"><span class="chotto-emoji-metric" style="${M}">${_(t)}</span><img class="chotto-emoji" src="${T(o)}" alt="${T(t)}" draggable="false" style="${$}"${c} /></span>`;
101
+ }
102
+ function L(t, e = i) {
103
+ const r = f(e);
104
+ if (!A(t, r)) {
105
+ const c = document.createElement("span");
106
+ return c.textContent = t, c;
107
+ }
108
+ const n = document.createElement("span");
109
+ n.className = "chotto-emoji-slot", n.setAttribute("style", v);
110
+ const o = document.createElement("span");
111
+ o.className = "chotto-emoji-metric", o.setAttribute("style", M), o.textContent = t;
112
+ const a = document.createElement("img");
113
+ return a.className = "chotto-emoji", a.src = S(t, r), a.alt = t, a.draggable = !1, a.setAttribute("style", $), y(a, t, r), n.append(o, a), n;
114
+ }
115
+ function T(t) {
89
116
  return t.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
90
117
  }
91
- function E(t) {
118
+ function _(t) {
92
119
  return t.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
93
120
  }
94
- function m(t) {
95
- return t ? E(t).replace(l, (e) => M(e)) : "";
121
+ function g(t, e) {
122
+ return t ? _(t).replace(u, (r) => j(r, e)) : "";
96
123
  }
97
- function y(t, e) {
124
+ function H(t, e, r = i) {
98
125
  if (!t) return "";
99
- const r = e ? Math.max(0, Math.min(e.start, e.end)) : -1, n = e ? Math.min(t.length, Math.max(e.start, e.end)) : -1;
100
- return r < 0 || r === n ? m(t) : m(t.slice(0, r)) + `<span class="chat-input__emoji-selection" style="background-color: var(--chotto-chatinput-selection-bg, rgba(51, 133, 255, 0.35)); border-radius: 2px; box-decoration-break: clone; -webkit-box-decoration-break: clone;">${m(t.slice(r, n))}</span>` + m(t.slice(n));
126
+ const n = f(r), o = e ? Math.max(0, Math.min(e.start, e.end)) : -1, a = e ? Math.min(t.length, Math.max(e.start, e.end)) : -1;
127
+ return o < 0 || o === a ? g(t, n) : g(t.slice(0, o), n) + `<span class="chat-input__emoji-selection" style="background-color: var(--chotto-chatinput-selection-bg, rgba(51, 133, 255, 0.35)); border-radius: 2px; box-decoration-break: clone; -webkit-box-decoration-break: clone;">${g(t.slice(o, a), n)}</span>` + g(t.slice(a), n);
101
128
  }
102
- function S(t) {
103
- return t ? (l.lastIndex = 0, l.test(t)) : !1;
129
+ function R(t) {
130
+ return t ? (u.lastIndex = 0, u.test(t)) : !1;
104
131
  }
105
- function L(t) {
106
- var s;
132
+ function J(t, e = i) {
133
+ var F;
107
134
  if (!t || typeof document > "u") return t;
108
- const e = document.createElement("div");
109
- e.innerHTML = t;
110
- const r = document.createTreeWalker(e, NodeFilter.SHOW_TEXT, {
111
- acceptNode: (a) => {
112
- let c = a.parentNode;
113
- for (; c && c !== e; ) {
114
- const i = c.nodeName;
115
- if (i === "SCRIPT" || i === "STYLE" || i === "TEXTAREA")
135
+ const r = f(e), n = document.createElement("div");
136
+ n.innerHTML = t;
137
+ const o = document.createTreeWalker(n, NodeFilter.SHOW_TEXT, {
138
+ acceptNode: (E) => {
139
+ let s = E.parentNode;
140
+ for (; s && s !== n; ) {
141
+ const l = s.nodeName;
142
+ if (l === "SCRIPT" || l === "STYLE" || l === "TEXTAREA")
116
143
  return NodeFilter.FILTER_REJECT;
117
- c = c.parentNode;
144
+ s = s.parentNode;
118
145
  }
119
146
  return NodeFilter.FILTER_ACCEPT;
120
147
  }
121
- }), n = [];
122
- let o;
123
- for (; o = r.nextNode(); )
124
- n.push(o);
125
- for (const a of n.reverse()) {
126
- const c = a.textContent || "";
127
- if (l.lastIndex = 0, !l.test(c)) continue;
128
- l.lastIndex = 0;
129
- const i = document.createDocumentFragment();
130
- let f = 0, u;
131
- for (; u = l.exec(c); ) {
132
- u.index > f && i.appendChild(document.createTextNode(c.slice(f, u.index)));
133
- const F = N(u[0]);
134
- i.appendChild(F), f = u.index + u[0].length;
148
+ }), a = [];
149
+ let c;
150
+ for (; c = o.nextNode(); )
151
+ a.push(c);
152
+ for (const E of a.reverse()) {
153
+ const s = E.textContent || "";
154
+ if (u.lastIndex = 0, !u.test(s)) continue;
155
+ u.lastIndex = 0;
156
+ const l = document.createDocumentFragment();
157
+ let h = 0, d;
158
+ for (; d = u.exec(s); ) {
159
+ d.index > h && l.appendChild(document.createTextNode(s.slice(h, d.index)));
160
+ const N = L(d[0], r);
161
+ l.appendChild(N), h = d.index + d[0].length;
135
162
  }
136
- f < c.length && i.appendChild(document.createTextNode(c.slice(f))), (s = a.parentNode) == null || s.replaceChild(i, a);
163
+ h < s.length && l.appendChild(document.createTextNode(s.slice(h))), (F = E.parentNode) == null || F.replaceChild(l, E);
137
164
  }
138
- return e.innerHTML;
165
+ return n.innerHTML;
139
166
  }
140
167
  export {
141
- g as APPLE_EMOJI_CDN,
142
- M as createAppleEmojiImgHtml,
143
- N as createAppleEmojiSlotElement,
144
- d as emojiToAppleCode,
145
- A as getAppleEmojiFallbackUrl,
146
- $ as getAppleEmojiUrl,
147
- C as nextGraphemeIndex,
148
- j as previousGraphemeIndex,
149
- L as replaceEmojisInHtml,
150
- v as snapIndexToGrapheme,
151
- S as textContainsEmoji,
152
- y as textToAppleEmojiHtml
168
+ i as APPLE_EMOJI_CDN,
169
+ j as createAppleEmojiImgHtml,
170
+ L as createAppleEmojiSlotElement,
171
+ p as emojiToAppleCode,
172
+ k as getAppleEmojiFallbackUrl,
173
+ S as getAppleEmojiUrl,
174
+ A as hasAppleEmojiImage,
175
+ w as nextGraphemeIndex,
176
+ f as normalizeEmojiCdn,
177
+ P as previousGraphemeIndex,
178
+ J as replaceEmojisInHtml,
179
+ O as snapIndexToGrapheme,
180
+ R as textContainsEmoji,
181
+ H as textToAppleEmojiHtml
153
182
  };