@nethesis/chat-island 0.1.15 → 0.1.16

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.
package/dist/index.js CHANGED
@@ -2959,11 +2959,16 @@ var An = (e) => {
2959
2959
  loaded: !1,
2960
2960
  complete: !1
2961
2961
  }), Nn = (e, t, n, r) => {
2962
- if (e.includes(t)) return e;
2963
- let i = [t, ...e];
2964
- if (i.length <= n) return i;
2965
- let a = [...i].reverse().find((e) => e !== r);
2966
- return i.filter((e) => e !== a);
2962
+ let i = e.indexOf(t);
2963
+ if (i >= 0 && i < n) return e;
2964
+ let a = [t, ...e.filter((e) => e !== t)].slice(0, 100);
2965
+ if (!r || a.indexOf(r) < n) return a;
2966
+ let o = a.filter((e) => e !== r);
2967
+ return [
2968
+ ...o.slice(0, n - 1),
2969
+ r,
2970
+ ...o.slice(n - 1)
2971
+ ];
2967
2972
  }, Pn = (e, t) => e.id === t.id || !!e.oid && e.oid === t.oid, Y = jn((e, t) => ({
2968
2973
  me: "",
2969
2974
  myName: "",
@@ -3525,7 +3530,7 @@ var $ = {
3525
3530
  //#endregion
3526
3531
  //#region src/components/Dock.tsx
3527
3532
  function Zn({ onDragStart: e, pushButton: t = !0 }) {
3528
- let { order: n, open: r, conversations: i, contacts: a, inactive: o, online: s, mobile: c, openChat: l, removeHead: p, picker: m, setPicker: h, status: g, push: _, enablePush: v, newChatButton: y } = Y(w((e) => ({
3533
+ let { order: n, open: r, conversations: i, contacts: a, inactive: o, online: s, mobile: c, openChat: l, removeHead: p, picker: m, setPicker: h, status: g, push: _, enablePush: v, newChatButton: y, maxHeads: b } = Y(w((e) => ({
3529
3534
  order: e.order,
3530
3535
  open: e.open,
3531
3536
  conversations: e.conversations,
@@ -3540,13 +3545,14 @@ function Zn({ onDragStart: e, pushButton: t = !0 }) {
3540
3545
  status: e.status,
3541
3546
  push: e.push,
3542
3547
  enablePush: e.enablePush,
3543
- newChatButton: e.newChatButton
3548
+ newChatButton: e.newChatButton,
3549
+ maxHeads: e.maxHeads
3544
3550
  })));
3545
3551
  return /* @__PURE__ */ f("div", {
3546
3552
  className: `ci-flex ci-flex-col-reverse ci-items-center ci-gap-3 ci-mb-3 ${e ? "ci-cursor-grab active:ci-cursor-grabbing ci-touch-none" : ""}`,
3547
3553
  onPointerDown: e,
3548
3554
  children: [
3549
- n.map((e) => {
3555
+ n.slice(0, b).map((e) => {
3550
3556
  let t = i[e], n = r === e;
3551
3557
  return /* @__PURE__ */ f("div", {
3552
3558
  className: "ci-relative ci-group",
@@ -3580,6 +3586,7 @@ function Zn({ onDragStart: e, pushButton: t = !0 }) {
3580
3586
  })]
3581
3587
  }, e);
3582
3588
  }),
3589
+ n.length > b && /* @__PURE__ */ d(Qn, { peers: n.slice(b) }),
3583
3590
  y && /* @__PURE__ */ f(Q, {
3584
3591
  variant: "default",
3585
3592
  title: g === "online" ? "New chat" : `Chat ${g}`,
@@ -3597,9 +3604,96 @@ function Zn({ onDragStart: e, pushButton: t = !0 }) {
3597
3604
  ]
3598
3605
  });
3599
3606
  }
3607
+ function Qn({ peers: e }) {
3608
+ let { conversations: t, contacts: n, inactive: r, online: a, mobile: o, openChat: l, removeHead: p } = Y(w((e) => ({
3609
+ conversations: e.conversations,
3610
+ contacts: e.contacts,
3611
+ inactive: e.inactive,
3612
+ online: e.online,
3613
+ mobile: e.mobile,
3614
+ openChat: e.openChat,
3615
+ removeHead: e.removeHead
3616
+ }))), [m, h] = c(!1), g = s(null), _ = e.reduce((e, n) => e + (t[n]?.unread ?? 0), 0), v = (e) => t[e]?.kind === "group" ? t[e]?.name ?? e : n[e]?.name ?? r[e] ?? e;
3617
+ return i(() => {
3618
+ if (!m) return;
3619
+ let e = (e) => g.current && !g.current.contains(e.target) && h(!1), t = (e) => e.key === "Escape" && h(!1);
3620
+ return document.addEventListener("pointerdown", e, !0), document.addEventListener("keydown", t, !0), () => {
3621
+ document.removeEventListener("pointerdown", e, !0), document.removeEventListener("keydown", t, !0);
3622
+ };
3623
+ }, [m]), /* @__PURE__ */ f("div", {
3624
+ ref: g,
3625
+ className: "ci-relative",
3626
+ children: [/* @__PURE__ */ f(Q, {
3627
+ variant: "default",
3628
+ title: `${e.length} more chats`,
3629
+ "aria-expanded": m,
3630
+ onClick: () => h((e) => !e),
3631
+ className: "ci-relative ci-shadow-lg ci-font-medium ci-ring-2 ci-ring-gray-50 dark:ci-ring-gray-950",
3632
+ children: [
3633
+ "+",
3634
+ e.length,
3635
+ _ > 0 && /* @__PURE__ */ d("span", {
3636
+ className: "ci-absolute ci--top-1 ci--right-1 ci-min-w-5 ci-h-5 ci-px-1 ci-rounded-full ci-bg-phoneIslandClose dark:ci-bg-phoneIslandCloseDark ci-text-white dark:ci-text-gray-950 ci-text-xs ci-font-medium ci-flex ci-items-center ci-justify-center",
3637
+ children: _ > 99 ? "99+" : _
3638
+ })
3639
+ ]
3640
+ }), m && /* @__PURE__ */ d("div", {
3641
+ role: "menu",
3642
+ onPointerDown: (e) => e.stopPropagation(),
3643
+ className: "ci-anim-drop ci-absolute ci-right-full ci-mr-3 ci-top-0 ci-z-30 ci-w-64 ci-max-h-80 ci-overflow-y-auto ci-py-2 ci-rounded-2xl ci-bg-gray-50 dark:ci-bg-gray-950 ci-shadow-2xl ci-border ci-border-solid ci-border-gray-300 dark:ci-border-gray-600 ci-text-gray-900 dark:ci-text-white ci-text-sm ci-cursor-default",
3644
+ children: e.map((e) => {
3645
+ let r = t[e];
3646
+ return /* @__PURE__ */ f("div", {
3647
+ className: "ci-group ci-flex ci-items-center ci-pr-2 hover:ci-bg-gray-200 dark:hover:ci-bg-gray-700",
3648
+ children: [/* @__PURE__ */ f("button", {
3649
+ type: "button",
3650
+ role: "menuitem",
3651
+ onClick: () => {
3652
+ h(!1), l(e);
3653
+ },
3654
+ className: "ci-flex-1 ci-min-w-0 ci-flex ci-items-center ci-gap-3 ci-px-3 ci-py-2 ci-border-0 ci-bg-transparent ci-text-left ci-text-inherit",
3655
+ children: [
3656
+ /* @__PURE__ */ d("span", {
3657
+ className: "ci-relative",
3658
+ children: r?.kind === "group" ? /* @__PURE__ */ d(Jn, {
3659
+ name: v(e),
3660
+ size: 32,
3661
+ avatar: r.avatar
3662
+ }) : /* @__PURE__ */ f(u, { children: [/* @__PURE__ */ d(Kn, {
3663
+ contact: n[e],
3664
+ username: e,
3665
+ size: 32
3666
+ }), /* @__PURE__ */ d(qn, {
3667
+ online: a[e],
3668
+ presence: n[e]?.presence,
3669
+ mobile: o[e]
3670
+ })] })
3671
+ }),
3672
+ /* @__PURE__ */ d("span", {
3673
+ className: "ci-flex-1 ci-truncate",
3674
+ children: v(e)
3675
+ }),
3676
+ (r?.unread ?? 0) > 0 && /* @__PURE__ */ d("span", {
3677
+ className: "ci-min-w-5 ci-h-5 ci-px-1 ci-rounded-full ci-bg-phoneIslandClose dark:ci-bg-phoneIslandCloseDark ci-text-white dark:ci-text-gray-950 ci-text-xs ci-font-medium ci-flex ci-items-center ci-justify-center",
3678
+ children: r.unread > 99 ? "99+" : r.unread
3679
+ })
3680
+ ]
3681
+ }), /* @__PURE__ */ d(Q, {
3682
+ variant: "small",
3683
+ "aria-label": `Remove ${v(e)} from the dock`,
3684
+ title: "Remove from the dock",
3685
+ onClick: () => p(e),
3686
+ className: "ci-opacity-0 group-hover:ci-opacity-100 focus:ci-opacity-100",
3687
+ children: $.close
3688
+ })]
3689
+ }, e);
3690
+ })
3691
+ })]
3692
+ });
3693
+ }
3600
3694
  //#endregion
3601
3695
  //#region src/shortcodes.ts
3602
- var Qn = {
3696
+ var $n = {
3603
3697
  "+1": "👍",
3604
3698
  thumbsup: "👍",
3605
3699
  "-1": "👎",
@@ -3793,13 +3887,13 @@ var Qn = {
3793
3887
  zzz: "💤",
3794
3888
  sweat_drops: "💦",
3795
3889
  dash: "💨"
3796
- }, $n = /(```[\s\S]*?(?:```|$)|`[^`\n]*`?)/g, er = /:([a-z0-9_+-]+):/g, tr = (e) => e.replace(er, (e, t) => Qn[t] ?? e);
3797
- function nr(e) {
3798
- return e.includes(":") ? e.split($n).map((e, t) => t % 2 ? e : tr(e)).join("") : e;
3890
+ }, er = /(```[\s\S]*?(?:```|$)|`[^`\n]*`?)/g, tr = /:([a-z0-9_+-]+):/g, nr = (e) => e.replace(tr, (e, t) => $n[t] ?? e);
3891
+ function rr(e) {
3892
+ return e.includes(":") ? e.split(er).map((e, t) => t % 2 ? e : nr(e)).join("") : e;
3799
3893
  }
3800
3894
  //#endregion
3801
3895
  //#region src/components/EmojiPicker.tsx
3802
- var rr = [
3896
+ var ir = [
3803
3897
  {
3804
3898
  label: "Smileys",
3805
3899
  icon: "😀",
@@ -3830,7 +3924,7 @@ var rr = [
3830
3924
  icon: "☕",
3831
3925
  emojis: "☕ 🍵 🥤 🍕 🍔 🍟 🌭 🥪 🌮 🍝 🍣 🍩 🍪 🍫 🍎 🍌 🍓 🥐 🚗 🚕 🚌 🚆 ✈️ 🚀 🏠 🏢 🏖️ 🌍 ☀️ 🌤️ 🌧️ ⛈️ ❄️ ⚡ 🌈 🌙"
3832
3926
  }
3833
- ], ir = [
3927
+ ], ar = [
3834
3928
  "👍",
3835
3929
  "❤️",
3836
3930
  "😂",
@@ -3838,7 +3932,7 @@ var rr = [
3838
3932
  "😢",
3839
3933
  "🙏"
3840
3934
  ];
3841
- function ar({ onPick: e, onClose: t, className: n = "" }) {
3935
+ function or({ onPick: e, onClose: t, className: n = "" }) {
3842
3936
  let [r, a] = c(0), o = s(null);
3843
3937
  return i(() => {
3844
3938
  let e = (e) => o.current && !o.current.contains(e.target) && t(), n = (e) => {
@@ -3851,10 +3945,10 @@ function ar({ onPick: e, onClose: t, className: n = "" }) {
3851
3945
  ref: o,
3852
3946
  role: "dialog",
3853
3947
  "aria-label": "Emoji",
3854
- className: `ci-z-30 ci-w-[21rem] ci-max-w-full ci-rounded-2xl ci-bg-gray-50 dark:ci-bg-gray-950 ci-shadow-2xl ci-ring-1 ci-ring-gray-300 dark:ci-ring-gray-700 ci-select-none ${n}`,
3948
+ className: `ci-z-30 ci-w-[21rem] ci-max-w-full ci-rounded-2xl ci-bg-gray-50 dark:ci-bg-gray-950 ci-shadow-2xl ci-border ci-border-solid ci-border-gray-300 dark:ci-border-gray-600 ci-select-none ${n}`,
3855
3949
  children: [/* @__PURE__ */ d("div", {
3856
3950
  className: "ci-flex ci-gap-1 ci-px-2 ci-pt-2 ci-border-b ci-border-gray-300 dark:ci-border-gray-700",
3857
- children: rr.map((e, t) => /* @__PURE__ */ d("button", {
3951
+ children: ir.map((e, t) => /* @__PURE__ */ d("button", {
3858
3952
  type: "button",
3859
3953
  title: e.label,
3860
3954
  "aria-label": e.label,
@@ -3868,7 +3962,7 @@ function ar({ onPick: e, onClose: t, className: n = "" }) {
3868
3962
  }, e.label))
3869
3963
  }), /* @__PURE__ */ d("div", {
3870
3964
  className: "ci-grid ci-grid-cols-7 ci-gap-1 ci-p-2 ci-h-64 ci-overflow-y-auto",
3871
- children: rr[r].emojis.split(" ").map((t) => /* @__PURE__ */ d("button", {
3965
+ children: ir[r].emojis.split(" ").map((t) => /* @__PURE__ */ d("button", {
3872
3966
  type: "button",
3873
3967
  onClick: () => e(t),
3874
3968
  style: {
@@ -3883,27 +3977,27 @@ function ar({ onPick: e, onClose: t, className: n = "" }) {
3883
3977
  }
3884
3978
  //#endregion
3885
3979
  //#region src/components/MessageList.tsx
3886
- var or = (e) => /\.(png|jpe?g|gif|webp|avif|svg)(\?|$)/i.test(e), sr = (e) => /\.(webm|ogg|oga|opus|mp3|m4a|wav)(\?|$)/i.test(e), cr = (e) => {
3980
+ var sr = (e) => /\.(png|jpe?g|gif|webp|avif|svg)(\?|$)/i.test(e), cr = (e) => /\.(webm|ogg|oga|opus|mp3|m4a|wav)(\?|$)/i.test(e), lr = (e) => {
3887
3981
  let t = e.split("/").pop() || "file";
3888
3982
  try {
3889
3983
  return decodeURIComponent(t);
3890
3984
  } catch {
3891
3985
  return t;
3892
3986
  }
3893
- }, lr = (e) => {
3987
+ }, ur = (e) => {
3894
3988
  try {
3895
3989
  return new URL(e).protocol === "https:";
3896
3990
  } catch {
3897
3991
  return !1;
3898
3992
  }
3899
- }, ur = (e) => new Date(e).toLocaleTimeString([], {
3993
+ }, dr = (e) => new Date(e).toLocaleTimeString([], {
3900
3994
  hour: "2-digit",
3901
3995
  minute: "2-digit"
3902
- }), dr = (e) => new Date(e).toLocaleDateString([], {
3996
+ }), fr = (e) => new Date(e).toLocaleDateString([], {
3903
3997
  weekday: "short",
3904
3998
  day: "numeric",
3905
3999
  month: "short"
3906
- }), fr = (e, t) => new Date(e).toDateString() === new Date(t).toDateString(), pr = (e) => {
4000
+ }), pr = (e, t) => new Date(e).toDateString() === new Date(t).toDateString(), mr = (e) => {
3907
4001
  if (!e.startsWith("{\"")) return null;
3908
4002
  try {
3909
4003
  let t = JSON.parse(e);
@@ -3914,17 +4008,17 @@ var or = (e) => /\.(png|jpe?g|gif|webp|avif|svg)(\?|$)/i.test(e), sr = (e) => /\
3914
4008
  } catch {
3915
4009
  return null;
3916
4010
  }
3917
- }, mr = n(function({ url: e }) {
3918
- return lr(e) ? or(e) ? /* @__PURE__ */ d("a", {
4011
+ }, hr = n(function({ url: e }) {
4012
+ return ur(e) ? sr(e) ? /* @__PURE__ */ d("a", {
3919
4013
  href: e,
3920
4014
  target: "_blank",
3921
4015
  rel: "noreferrer",
3922
4016
  children: /* @__PURE__ */ d("img", {
3923
4017
  src: e,
3924
- alt: cr(e),
4018
+ alt: lr(e),
3925
4019
  className: "ci-max-w-full ci-max-h-60 ci-rounded-2xl ci-block"
3926
4020
  })
3927
- }) : sr(e) ? /* @__PURE__ */ d("audio", {
4021
+ }) : cr(e) ? /* @__PURE__ */ d("audio", {
3928
4022
  controls: !0,
3929
4023
  src: e,
3930
4024
  className: "ci-max-w-full"
@@ -3941,17 +4035,17 @@ var or = (e) => /\.(png|jpe?g|gif|webp|avif|svg)(\?|$)/i.test(e), sr = (e) => /\
3941
4035
  stroke: "currentColor",
3942
4036
  strokeWidth: "2",
3943
4037
  children: /* @__PURE__ */ d("path", { d: "M21.44 11.05l-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48" })
3944
- }), cr(e)]
4038
+ }), lr(e)]
3945
4039
  }) : /* @__PURE__ */ d("span", {
3946
4040
  className: "ci-break-all",
3947
4041
  children: e
3948
4042
  });
3949
- }), hr = /(`[^`\n]+`)|(\*\*[^*\n]+\*\*|__[^_\n]+__)|(~~[^~\n]+~~)|(\*[^*\s][^*\n]*\*|_[^_\s][^_\n]*_)|\[([^\]\n]+)\]\((https?:\/\/[^\s)]+)\)|(https?:\/\/[^\s<]+)/g;
3950
- function gr({ text: e }) {
4043
+ }), gr = /(`[^`\n]+`)|(\*\*[^*\n]+\*\*|__[^_\n]+__)|(~~[^~\n]+~~)|(\*[^*\s][^*\n]*\*|_[^_\s][^_\n]*_)|\[([^\]\n]+)\]\((https?:\/\/[^\s)]+)\)|(https?:\/\/[^\s<]+)/g;
4044
+ function _r({ text: e }) {
3951
4045
  let t = [], n = 0;
3952
- for (let r of e.matchAll(hr)) {
4046
+ for (let r of e.matchAll(gr)) {
3953
4047
  let i = r[0], a = r.index ?? 0;
3954
- a > n && t.push(nr(e.slice(n, a))), r[1] ? t.push(/* @__PURE__ */ d("code", {
4048
+ a > n && t.push(rr(e.slice(n, a))), r[1] ? t.push(/* @__PURE__ */ d("code", {
3955
4049
  className: "ci-px-1 ci-py-0.5 ci-rounded ci-bg-black/10 dark:ci-bg-white/10 ci-font-mono ci-text-[0.85em]",
3956
4050
  children: i.slice(1, -1)
3957
4051
  }, a)) : r[2] ? t.push(/* @__PURE__ */ d("strong", { children: i.slice(2, -2) }, a)) : r[3] ? t.push(/* @__PURE__ */ d("s", { children: i.slice(2, -2) }, a)) : r[4] ? t.push(/* @__PURE__ */ d("em", { children: i.slice(1, -1) }, a)) : r[5] ? t.push(/* @__PURE__ */ d("a", {
@@ -3968,19 +4062,19 @@ function gr({ text: e }) {
3968
4062
  children: i
3969
4063
  }, a)), n = a + i.length;
3970
4064
  }
3971
- return n < e.length && t.push(nr(e.slice(n))), /* @__PURE__ */ d(u, { children: t });
4065
+ return n < e.length && t.push(rr(e.slice(n))), /* @__PURE__ */ d(u, { children: t });
3972
4066
  }
3973
- var _r = n(function({ text: e }) {
4067
+ var vr = n(function({ text: e }) {
3974
4068
  let t = e.split(/```[^\n]*\n?([\s\S]*?)```/g);
3975
4069
  return /* @__PURE__ */ d("span", {
3976
4070
  className: "ci-whitespace-pre-wrap ci-break-words",
3977
4071
  children: t.map((e, t) => t % 2 ? /* @__PURE__ */ d("pre", {
3978
4072
  className: "ci-my-1 ci-p-2 ci-rounded-xl ci-bg-black/10 dark:ci-bg-white/10 ci-font-mono ci-text-xs ci-overflow-x-auto ci-whitespace-pre",
3979
4073
  children: e.replace(/\n$/, "")
3980
- }, t) : /* @__PURE__ */ d(gr, { text: e.replace(/^(\s*)[-*] (?=\S)/gm, "$1• ") }, t))
4074
+ }, t) : /* @__PURE__ */ d(_r, { text: e.replace(/^(\s*)[-*] (?=\S)/gm, "$1• ") }, t))
3981
4075
  });
3982
4076
  });
3983
- function vr({ text: e, count: t }) {
4077
+ function yr({ text: e, count: t }) {
3984
4078
  return /* @__PURE__ */ f("span", {
3985
4079
  className: "ci-italic ci-opacity-80",
3986
4080
  children: [
@@ -3993,7 +4087,7 @@ function vr({ text: e, count: t }) {
3993
4087
  ]
3994
4088
  });
3995
4089
  }
3996
- function yr({ forMsg: e, me: t, onReact: n, nameOf: r, mine: i }) {
4090
+ function br({ forMsg: e, me: t, onReact: n, nameOf: r, mine: i }) {
3997
4091
  if (!e) return null;
3998
4092
  let a = /* @__PURE__ */ new Map();
3999
4093
  for (let [t, n] of Object.entries(e)) for (let e of n) a.set(e, [...a.get(e) ?? [], t]);
@@ -4018,7 +4112,7 @@ function yr({ forMsg: e, me: t, onReact: n, nameOf: r, mine: i }) {
4018
4112
  })
4019
4113
  }) : null;
4020
4114
  }
4021
- function br({ reply: e, messages: t, mine: n, name: r }) {
4115
+ function xr({ reply: e, messages: t, mine: n, name: r }) {
4022
4116
  let i = t.find((t) => t.oid === e.id), a = i ? i.oob ? "Attachment" : i.body : e.quote?.replace(/^[^:]*: /, "") ?? "", o = (t) => {
4023
4117
  t.stopPropagation();
4024
4118
  let n = document.querySelector(`.chat-island-root [data-oid="${CSS.escape(e.id)}"]`);
@@ -4042,7 +4136,7 @@ function br({ reply: e, messages: t, mine: n, name: r }) {
4042
4136
  })]
4043
4137
  });
4044
4138
  }
4045
- function xr({ messages: e, typing: t, onLoadOlder: n, hasOlder: r, group: a, reactions: o, me: l = "", onReact: u, onReply: p }) {
4139
+ function Sr({ messages: e, typing: t, onLoadOlder: n, hasOlder: r, group: a, reactions: o, me: l = "", onReact: u, onReply: p }) {
4046
4140
  let m = Y((e) => e.contacts), h = s(null), g = s(!0), [_, v] = c(null), [y, b] = c(null), x = (e) => m[e]?.name ?? e;
4047
4141
  i(() => {
4048
4142
  let e = h.current;
@@ -4076,7 +4170,7 @@ function xr({ messages: e, typing: t, onLoadOlder: n, hasOlder: r, group: a, rea
4076
4170
  children: "Scroll up for older messages"
4077
4171
  }),
4078
4172
  e.map((t, n) => {
4079
- let r = e[n - 1], i = !r || !fr(r.ts, t.ts), s = r && !i && r.mine === t.mine && r.nick === t.nick && t.ts - r.ts < 12e4, c = a && !t.mine && t.nick ? x(t.nick) : null, h = t.oid, g = !!u && !!h && !t.pending, y = g && /* @__PURE__ */ d("button", {
4173
+ let r = e[n - 1], i = !r || !pr(r.ts, t.ts), s = r && !i && r.mine === t.mine && r.nick === t.nick && t.ts - r.ts < 12e4, c = a && !t.mine && t.nick ? x(t.nick) : null, h = t.oid, g = !!u && !!h && !t.pending, y = g && /* @__PURE__ */ d("button", {
4080
4174
  type: "button",
4081
4175
  title: "React",
4082
4176
  "aria-label": "React to this message",
@@ -4099,7 +4193,7 @@ function xr({ messages: e, typing: t, onLoadOlder: n, hasOlder: r, group: a, rea
4099
4193
  "data-oid": t.oid,
4100
4194
  children: [i && /* @__PURE__ */ d("div", {
4101
4195
  className: "ci-text-center ci-text-xs ci-text-gray-500 dark:ci-text-gray-400 ci-py-2",
4102
- children: dr(t.ts)
4196
+ children: fr(t.ts)
4103
4197
  }), /* @__PURE__ */ f("div", {
4104
4198
  className: `ci-group ci-flex ci-items-start ci-gap-1.5 ${t.mine ? "ci-justify-end" : "ci-justify-start"} ${s ? "ci-mt-0.5" : "ci-mt-2"}`,
4105
4199
  children: [
@@ -4120,8 +4214,8 @@ function xr({ messages: e, typing: t, onLoadOlder: n, hasOlder: r, group: a, rea
4120
4214
  _ === h && h && /* @__PURE__ */ f("div", {
4121
4215
  role: "menu",
4122
4216
  onClick: (e) => e.stopPropagation(),
4123
- className: `ci-absolute ci-bottom-full ci-mb-1 ci-z-20 ci-flex ci-items-center ci-gap-0.5 ci-p-1 ci-rounded-full ci-bg-gray-50 dark:ci-bg-gray-950 ci-shadow-xl ci-ring-1 ci-ring-gray-300 dark:ci-ring-gray-700 ${t.mine ? "ci-right-0" : "ci-left-0"}`,
4124
- children: [ir.map((e) => /* @__PURE__ */ d("button", {
4217
+ className: `ci-absolute ci-bottom-full ci-mb-1 ci-z-20 ci-flex ci-items-center ci-gap-0.5 ci-p-1 ci-rounded-full ci-bg-gray-50 dark:ci-bg-gray-950 ci-shadow-xl ci-border ci-border-solid ci-border-gray-300 dark:ci-border-gray-600 ${t.mine ? "ci-right-0" : "ci-left-0"}`,
4218
+ children: [ar.map((e) => /* @__PURE__ */ d("button", {
4125
4219
  type: "button",
4126
4220
  role: "menuitem",
4127
4221
  "aria-label": e,
@@ -4145,28 +4239,28 @@ function xr({ messages: e, typing: t, onLoadOlder: n, hasOlder: r, group: a, rea
4145
4239
  })]
4146
4240
  }),
4147
4241
  /* @__PURE__ */ f("div", {
4148
- title: ur(t.ts),
4149
- onDoubleClick: () => g && C(h, ir[0]),
4242
+ title: dr(t.ts),
4243
+ onDoubleClick: () => g && C(h, ar[0]),
4150
4244
  className: `ci-px-3.5 ci-py-2 ci-rounded-3xl ci-text-sm ci-select-text ci-cursor-text ${t.mine ? "ci-bg-gray-700 ci-text-gray-50 dark:ci-bg-gray-300 dark:ci-text-gray-900 ci-rounded-br-lg" : "ci-bg-elevationL2 ci-text-gray-900 dark:ci-bg-elevationL2Dark dark:ci-text-white ci-rounded-bl-lg"} ${t.pending ? "ci-opacity-60" : ""}`,
4151
4245
  children: [
4152
- t.reply && /* @__PURE__ */ d(br, {
4246
+ t.reply && /* @__PURE__ */ d(xr, {
4153
4247
  reply: t.reply,
4154
4248
  messages: e,
4155
4249
  mine: t.mine,
4156
4250
  name: (e) => e === l ? "You" : x(e)
4157
4251
  }),
4158
- t.oob ? /* @__PURE__ */ d(mr, { url: t.oob }) : pr(t.body) ? /* @__PURE__ */ d(vr, { ...pr(t.body) }) : /* @__PURE__ */ d(_r, { text: t.body }),
4159
- t.oob && t.body && t.body !== t.oob && t.body !== cr(t.oob) && /* @__PURE__ */ d("div", {
4252
+ t.oob ? /* @__PURE__ */ d(hr, { url: t.oob }) : mr(t.body) ? /* @__PURE__ */ d(yr, { ...mr(t.body) }) : /* @__PURE__ */ d(vr, { text: t.body }),
4253
+ t.oob && t.body && t.body !== t.oob && t.body !== lr(t.oob) && /* @__PURE__ */ d("div", {
4160
4254
  className: "ci-text-xs ci-opacity-80 ci-mt-1",
4161
4255
  children: t.body
4162
4256
  }),
4163
4257
  /* @__PURE__ */ d("span", {
4164
4258
  className: "ci-block ci-text-right ci-text-[10px] ci-leading-none ci-opacity-60 ci-mt-1",
4165
- children: ur(t.ts)
4259
+ children: dr(t.ts)
4166
4260
  })
4167
4261
  ]
4168
4262
  }),
4169
- h && /* @__PURE__ */ d(yr, {
4263
+ h && /* @__PURE__ */ d(br, {
4170
4264
  forMsg: o?.[h],
4171
4265
  me: l,
4172
4266
  mine: t.mine,
@@ -4189,7 +4283,7 @@ function xr({ messages: e, typing: t, onLoadOlder: n, hasOlder: r, group: a, rea
4189
4283
  })
4190
4284
  })
4191
4285
  ]
4192
- }), y && /* @__PURE__ */ d(ar, {
4286
+ }), y && /* @__PURE__ */ d(or, {
4193
4287
  className: "ci-absolute ci-bottom-2 ci-left-1/2 ci--translate-x-1/2",
4194
4288
  onPick: (e) => C(y, e),
4195
4289
  onClose: () => b(null)
@@ -4198,7 +4292,7 @@ function xr({ messages: e, typing: t, onLoadOlder: n, hasOlder: r, group: a, rea
4198
4292
  }
4199
4293
  //#endregion
4200
4294
  //#region src/ogg.ts
4201
- function Sr(e, t, n) {
4295
+ function Cr(e, t, n) {
4202
4296
  let r = e[t];
4203
4297
  if (r === void 0) return null;
4204
4298
  let i = 1;
@@ -4212,7 +4306,7 @@ function Sr(e, t, n) {
4212
4306
  unknown: !n && o
4213
4307
  };
4214
4308
  }
4215
- var Cr = /* @__PURE__ */ new Set([
4309
+ var wr = /* @__PURE__ */ new Set([
4216
4310
  408125543,
4217
4311
  524531317,
4218
4312
  374648427,
@@ -4220,18 +4314,18 @@ var Cr = /* @__PURE__ */ new Set([
4220
4314
  225,
4221
4315
  160
4222
4316
  ]);
4223
- function wr(e) {
4317
+ function Tr(e) {
4224
4318
  let t = {
4225
4319
  channels: 1,
4226
4320
  packets: []
4227
4321
  }, n = 0;
4228
4322
  for (; n < e.length;) {
4229
- let r = Sr(e, n, !0);
4323
+ let r = Cr(e, n, !0);
4230
4324
  if (!r) break;
4231
- let i = Sr(e, n + r.len, !1);
4325
+ let i = Cr(e, n + r.len, !1);
4232
4326
  if (!i) break;
4233
4327
  let a = n + r.len + i.len;
4234
- if (Cr.has(r.value)) {
4328
+ if (wr.has(r.value)) {
4235
4329
  n = a;
4236
4330
  continue;
4237
4331
  }
@@ -4240,14 +4334,14 @@ function wr(e) {
4240
4334
  if (r.value === 25506) t.head = e.slice(a, o);
4241
4335
  else if (r.value === 159) t.channels = e[a] || 1;
4242
4336
  else if (r.value === 163 || r.value === 161) {
4243
- let n = Sr(e, a, !1);
4337
+ let n = Cr(e, a, !1);
4244
4338
  n && (e[a + n.len + 2] >> 1 & 3 || t.packets.push(e.slice(a + n.len + 3, o)));
4245
4339
  }
4246
4340
  n = o;
4247
4341
  }
4248
4342
  return t;
4249
4343
  }
4250
- function Tr(e) {
4344
+ function Er(e) {
4251
4345
  if (!e.length) return 0;
4252
4346
  let t = e[0], n = t >> 3, r;
4253
4347
  r = n < 12 ? [
@@ -4264,7 +4358,7 @@ function Tr(e) {
4264
4358
  let i = t & 3, a = i === 0 ? 1 : i === 3 ? (e[1] ?? 0) & 63 : 2;
4265
4359
  return Math.round(a * r * 48);
4266
4360
  }
4267
- var Er = (() => {
4361
+ var Dr = (() => {
4268
4362
  let e = /* @__PURE__ */ new Uint32Array(256);
4269
4363
  for (let t = 0; t < 256; t++) {
4270
4364
  let n = t << 24;
@@ -4273,12 +4367,12 @@ var Er = (() => {
4273
4367
  }
4274
4368
  return e;
4275
4369
  })();
4276
- function Dr(e) {
4370
+ function Or(e) {
4277
4371
  let t = 0;
4278
- for (let n = 0; n < e.length; n++) t = (t << 8 ^ Er[(t >>> 24 ^ e[n]) & 255]) >>> 0;
4372
+ for (let n = 0; n < e.length; n++) t = (t << 8 ^ Dr[(t >>> 24 ^ e[n]) & 255]) >>> 0;
4279
4373
  return t;
4280
4374
  }
4281
- function Or(e, t, n, r, i) {
4375
+ function kr(e, t, n, r, i) {
4282
4376
  let a = [];
4283
4377
  for (let t of e) {
4284
4378
  let e = t.length;
@@ -4294,29 +4388,29 @@ function Or(e, t, n, r, i) {
4294
4388
  ], 0), s[5] = i, c.setUint32(6, t % 4294967296, !0), c.setUint32(10, Math.floor(t / 4294967296), !0), c.setUint32(14, n, !0), c.setUint32(18, r, !0), s[26] = a.length, s.set(a, 27);
4295
4389
  let l = 27 + a.length;
4296
4390
  for (let t of e) s.set(t, l), l += t.length;
4297
- return c.setUint32(22, Dr(s), !0), s;
4391
+ return c.setUint32(22, Or(s), !0), s;
4298
4392
  }
4299
- function kr(e) {
4393
+ function Ar(e) {
4300
4394
  let t = /* @__PURE__ */ new Uint8Array(19), n = new DataView(t.buffer);
4301
4395
  return t.set(new TextEncoder().encode("OpusHead"), 0), t[8] = 1, t[9] = e, n.setUint16(10, 312, !0), n.setUint32(12, 48e3, !0), t;
4302
4396
  }
4303
- function Ar() {
4397
+ function jr() {
4304
4398
  let e = new TextEncoder().encode("chat-island"), t = new Uint8Array(12 + e.length + 4);
4305
4399
  return t.set(new TextEncoder().encode("OpusTags"), 0), new DataView(t.buffer).setUint32(8, e.length, !0), t.set(e, 12), t;
4306
4400
  }
4307
- function jr(e) {
4308
- let { head: t, channels: n, packets: r } = wr(e);
4401
+ function Mr(e) {
4402
+ let { head: t, channels: n, packets: r } = Tr(e);
4309
4403
  if (!r.length) return null;
4310
- let i = t && t.length >= 19 && new TextDecoder().decode(t.slice(0, 8)) === "OpusHead", a = Math.random() * 4294967295 >>> 0, o = [Or([i ? t : kr(n)], 0, a, 0, 2), Or([Ar()], 0, a, 1, 0)], s = 0, c = 2;
4404
+ let i = t && t.length >= 19 && new TextDecoder().decode(t.slice(0, 8)) === "OpusHead", a = Math.random() * 4294967295 >>> 0, o = [kr([i ? t : Ar(n)], 0, a, 0, 2), kr([jr()], 0, a, 1, 0)], s = 0, c = 2;
4311
4405
  for (let e = 0; e < r.length;) {
4312
4406
  let t = [], n = 0;
4313
4407
  for (; e < r.length && t.length < 50;) {
4314
4408
  let i = Math.floor(r[e].length / 255) + 1;
4315
4409
  if (n + i > 255) break;
4316
- t.push(r[e]), n += i, s += Tr(r[e]), e++;
4410
+ t.push(r[e]), n += i, s += Er(r[e]), e++;
4317
4411
  }
4318
4412
  if (!t.length) return null;
4319
- o.push(Or(t, s, a, c++, e >= r.length ? 4 : 0));
4413
+ o.push(kr(t, s, a, c++, e >= r.length ? 4 : 0));
4320
4414
  }
4321
4415
  let l = o.reduce((e, t) => e + t.length, 0), u = new Uint8Array(l), d = 0;
4322
4416
  for (let e of o) u.set(e, d), d += e.length;
@@ -4324,22 +4418,22 @@ function jr(e) {
4324
4418
  }
4325
4419
  //#endregion
4326
4420
  //#region src/components/Composer.tsx
4327
- var Mr = [
4421
+ var Nr = [
4328
4422
  "audio/ogg;codecs=opus",
4329
4423
  "audio/webm;codecs=opus",
4330
4424
  "audio/mp4",
4331
4425
  "audio/webm"
4332
4426
  ];
4333
- async function Nr(e, t) {
4427
+ async function Pr(e, t) {
4334
4428
  let n = Date.now();
4335
4429
  if (/webm/.test(t) && /opus/.test(t)) try {
4336
- let t = jr(new Uint8Array(await new Blob(e).arrayBuffer()));
4430
+ let t = Mr(new Uint8Array(await new Blob(e).arrayBuffer()));
4337
4431
  if (t) return new File([t], `voice-${n}.ogg`, { type: "audio/ogg" });
4338
4432
  } catch {}
4339
- return new File(e, `voice-${n}.${Pr(t)}`, { type: t.split(";")[0] });
4433
+ return new File(e, `voice-${n}.${Fr(t)}`, { type: t.split(";")[0] });
4340
4434
  }
4341
- var Pr = (e) => /mp4/.test(e) ? "m4a" : /ogg/.test(e) ? "ogg" : "webm", Fr = (e) => `${Math.floor(e / 6e4)}:${String(Math.floor(e % 6e4 / 1e3)).padStart(2, "0")}`;
4342
- function Ir({ onSend: e, onTyping: t, onFile: n, disabled: r, disabledText: o, focusKey: l }) {
4435
+ var Fr = (e) => /mp4/.test(e) ? "m4a" : /ogg/.test(e) ? "ogg" : "webm", Ir = (e) => `${Math.floor(e / 6e4)}:${String(Math.floor(e % 6e4 / 1e3)).padStart(2, "0")}`;
4436
+ function Lr({ onSend: e, onTyping: t, onFile: n, disabled: r, disabledText: o, focusKey: l }) {
4343
4437
  let [u, p] = c(""), [m, h] = c(!1), g = s(null), _ = s(null), v = s(null), y = s(), b = s(!1), [x, S] = c(null), [C, w] = c(0), T = s(!1), E = s(!1), D = s(!1), O = s({});
4344
4438
  i(() => v.current?.focus(), []), i(() => () => {
4345
4439
  D.current = !0, T.current = !0, window.clearTimeout(y.current);
@@ -4355,7 +4449,7 @@ function Ir({ onSend: e, onTyping: t, onFile: n, disabled: r, disabledText: o, f
4355
4449
  let k = (e) => {
4356
4450
  b.current !== e && (b.current = e, t(e));
4357
4451
  }, A = (e) => {
4358
- let t = e.includes(":") ? nr(e) : e;
4452
+ let t = e.includes(":") ? rr(e) : e;
4359
4453
  t !== e && (g.current = Math.max(0, (v.current?.selectionStart ?? e.length) - (e.length - t.length))), p(t), t ? (k(!0), window.clearTimeout(y.current), y.current = window.setTimeout(() => k(!1), 4e3)) : k(!1);
4360
4454
  };
4361
4455
  a(() => {
@@ -4380,9 +4474,9 @@ function Ir({ onSend: e, onTyping: t, onFile: n, disabled: r, disabledText: o, f
4380
4474
  t.getTracks().forEach((e) => e.stop());
4381
4475
  return;
4382
4476
  }
4383
- let r = Mr.find((e) => MediaRecorder.isTypeSupported(e)), i = new MediaRecorder(e, r ? { mimeType: r } : void 0), a = [];
4477
+ let r = Nr.find((e) => MediaRecorder.isTypeSupported(e)), i = new MediaRecorder(e, r ? { mimeType: r } : void 0), a = [];
4384
4478
  i.ondataavailable = (e) => e.data.size && a.push(e.data), i.onstop = () => {
4385
- t.getTracks().forEach((e) => e.stop()), O.current = {}, S(null), !T.current && a.length && Nr(a, i.mimeType || r || "").then(n);
4479
+ t.getTracks().forEach((e) => e.stop()), O.current = {}, S(null), !T.current && a.length && Pr(a, i.mimeType || r || "").then(n);
4386
4480
  }, T.current = !1, i.start(), O.current = {
4387
4481
  r: i,
4388
4482
  stream: t
@@ -4411,7 +4505,7 @@ function Ir({ onSend: e, onTyping: t, onFile: n, disabled: r, disabledText: o, f
4411
4505
  }),
4412
4506
  /* @__PURE__ */ f("div", {
4413
4507
  className: "ci-flex-1 ci-flex ci-items-center ci-gap-2 ci-px-4 ci-py-2.5 ci-rounded-3xl ci-bg-elevationL2 dark:ci-bg-elevationL2Dark ci-text-sm",
4414
- children: [/* @__PURE__ */ d("span", { className: "ci-w-2.5 ci-h-2.5 ci-rounded-full ci-bg-phoneIslandClose dark:ci-bg-phoneIslandCloseDark ci-animate-pulse" }), /* @__PURE__ */ f("span", { children: ["Recording ", Fr(C)] })]
4508
+ children: [/* @__PURE__ */ d("span", { className: "ci-w-2.5 ci-h-2.5 ci-rounded-full ci-bg-phoneIslandClose dark:ci-bg-phoneIslandCloseDark ci-animate-pulse" }), /* @__PURE__ */ f("span", { children: ["Recording ", Ir(C)] })]
4415
4509
  }),
4416
4510
  /* @__PURE__ */ d(Q, {
4417
4511
  variant: "green",
@@ -4425,7 +4519,7 @@ function Ir({ onSend: e, onTyping: t, onFile: n, disabled: r, disabledText: o, f
4425
4519
  }) : /* @__PURE__ */ f("div", {
4426
4520
  className: "ci-relative ci-flex ci-items-center ci-gap-2 ci-px-3 ci-py-3",
4427
4521
  children: [
4428
- m && /* @__PURE__ */ d(ar, {
4522
+ m && /* @__PURE__ */ d(or, {
4429
4523
  className: "ci-absolute ci-bottom-full ci-left-3 ci-mb-1",
4430
4524
  onPick: j,
4431
4525
  onClose: () => h(!1)
@@ -4491,14 +4585,14 @@ function Ir({ onSend: e, onTyping: t, onFile: n, disabled: r, disabledText: o, f
4491
4585
  }
4492
4586
  //#endregion
4493
4587
  //#region src/components/ChatWindow.tsx
4494
- var Lr = (e) => !!e && ![
4588
+ var Rr = (e) => !!e && ![
4495
4589
  "offline",
4496
4590
  "dnd",
4497
4591
  "busy",
4498
4592
  "ringing",
4499
4593
  "onhold"
4500
4594
  ].includes(e);
4501
- function Rr({ peer: e, actions: t, theme: n, onDragStart: r }) {
4595
+ function zr({ peer: e, actions: t, theme: n, onDragStart: r }) {
4502
4596
  let { c: a, contacts: o, online: s, mobile: l, inactive: p, status: m, closeChat: h, openChat: g, markRead: _, order: v, me: y } = Y(w((t) => ({
4503
4597
  c: t.conversations[e],
4504
4598
  contacts: t.contacts,
@@ -4536,10 +4630,10 @@ function Rr({ peer: e, actions: t, theme: n, onDragStart: r }) {
4536
4630
  role: "dialog",
4537
4631
  "aria-label": a.kind === "group" ? a.name ?? e : x?.name ?? p[e] ?? e,
4538
4632
  onKeyDown: P,
4539
- className: "ci-relative ci-w-[22rem] ci-h-[30rem] ci-flex ci-flex-col ci-rounded-3xl ci-shadow-2xl ci-bg-gray-50 dark:ci-bg-gray-950 ci-text-gray-900 dark:ci-text-white",
4633
+ className: "ci-relative ci-w-[22rem] ci-h-[30rem] ci-flex ci-flex-col ci-rounded-3xl ci-shadow-2xl ci-bg-gray-50 dark:ci-bg-gray-950 dark:ci-border dark:ci-border-solid dark:ci-border-gray-700 ci-text-gray-900 dark:ci-text-white",
4540
4634
  children: [
4541
4635
  /* @__PURE__ */ d("span", {
4542
- className: "ci-absolute ci--right-1.5 ci-w-3 ci-h-3 ci-rotate-45 ci-bg-gray-50 dark:ci-bg-gray-950 ci-shadow-2xl ci-transition-all ci-duration-200",
4636
+ className: "ci-absolute ci--right-1.5 ci-w-3 ci-h-3 ci-rotate-45 ci-bg-gray-50 dark:ci-bg-gray-950 dark:ci-border-0 dark:ci-border-t dark:ci-border-r dark:ci-border-solid dark:ci-border-gray-700 ci-shadow-2xl ci-transition-all ci-duration-200",
4543
4637
  style: { bottom: `calc(1.875rem + ${b} * 3.75rem)` },
4544
4638
  "aria-hidden": "true"
4545
4639
  }),
@@ -4580,7 +4674,7 @@ function Rr({ peer: e, actions: t, theme: n, onDragStart: r }) {
4580
4674
  children: F ? "No longer active" : m === "online" ? a.kind === "group" ? M.map(j).join(", ") : a.typing ? "typing…" : s[e] ? "online" : l[e] ? "Mobile" : "offline" : m
4581
4675
  })]
4582
4676
  }),
4583
- !F && a.kind !== "group" && x?.number && Lr(x.presence) && /* @__PURE__ */ d(Q, {
4677
+ !F && a.kind !== "group" && x?.number && Rr(x.presence) && /* @__PURE__ */ d(Q, {
4584
4678
  variant: "call",
4585
4679
  title: `Call ${x.number}`,
4586
4680
  "aria-label": "Call",
@@ -4608,12 +4702,12 @@ function Rr({ peer: e, actions: t, theme: n, onDragStart: r }) {
4608
4702
  ]
4609
4703
  }),
4610
4704
  /* @__PURE__ */ d("div", { className: "ci-border-t ci-border-gray-300 dark:ci-border-gray-700" }),
4611
- T && /* @__PURE__ */ d(Br, {
4705
+ T && /* @__PURE__ */ d(Vr, {
4612
4706
  theme: n,
4613
4707
  onClose: () => E(!1)
4614
4708
  }),
4615
4709
  S && a.kind === "group" && /* @__PURE__ */ d("div", {
4616
- className: "ci-anim-drop ci-absolute ci-left-3 ci-right-3 ci-top-16 ci-z-10 ci-max-h-64 ci-overflow-y-auto ci-rounded-2xl ci-bg-gray-50 dark:ci-bg-gray-950 ci-shadow-2xl ci-ring-1 ci-ring-gray-300 dark:ci-ring-gray-700 ci-p-2",
4710
+ className: "ci-anim-drop ci-absolute ci-left-3 ci-right-3 ci-top-16 ci-z-10 ci-max-h-64 ci-overflow-y-auto ci-rounded-2xl ci-bg-gray-50 dark:ci-bg-gray-950 ci-shadow-2xl ci-border ci-border-solid ci-border-gray-300 dark:ci-border-gray-600 ci-p-2",
4617
4711
  children: M.map((e) => /* @__PURE__ */ f("div", {
4618
4712
  className: "ci-flex ci-items-center ci-gap-3 ci-px-2 ci-py-1.5 ci-text-sm",
4619
4713
  children: [
@@ -4639,7 +4733,7 @@ function Rr({ peer: e, actions: t, theme: n, onDragStart: r }) {
4639
4733
  "aria-label": "Chat",
4640
4734
  onClick: () => g(e),
4641
4735
  children: $.chat
4642
- }), o[e]?.number && Lr(o[e]?.presence) && /* @__PURE__ */ d(Q, {
4736
+ }), o[e]?.number && Rr(o[e]?.presence) && /* @__PURE__ */ d(Q, {
4643
4737
  variant: "call",
4644
4738
  title: `Call ${o[e]?.number}`,
4645
4739
  "aria-label": "Call",
@@ -4655,7 +4749,7 @@ function Rr({ peer: e, actions: t, theme: n, onDragStart: r }) {
4655
4749
  /* @__PURE__ */ f("div", {
4656
4750
  className: "ci-flex-1 ci-min-h-0 ci-flex ci-flex-col ci-overflow-hidden ci-rounded-b-3xl",
4657
4751
  children: [
4658
- /* @__PURE__ */ d(xr, {
4752
+ /* @__PURE__ */ d(Sr, {
4659
4753
  messages: a.messages,
4660
4754
  typing: a.typing,
4661
4755
  group: a.kind === "group",
@@ -4685,7 +4779,7 @@ function Rr({ peer: e, actions: t, theme: n, onDragStart: r }) {
4685
4779
  children: $.close
4686
4780
  })]
4687
4781
  }),
4688
- /* @__PURE__ */ d(Ir, {
4782
+ /* @__PURE__ */ d(Lr, {
4689
4783
  focusKey: k,
4690
4784
  disabled: m !== "online" || F,
4691
4785
  disabledText: F ? "No longer active" : void 0,
@@ -4698,7 +4792,7 @@ function Rr({ peer: e, actions: t, theme: n, onDragStart: r }) {
4698
4792
  ]
4699
4793
  });
4700
4794
  }
4701
- var zr = [
4795
+ var Br = [
4702
4796
  {
4703
4797
  value: "light",
4704
4798
  label: "Light",
@@ -4715,7 +4809,7 @@ var zr = [
4715
4809
  icon: $.monitor
4716
4810
  }
4717
4811
  ];
4718
- function Br({ theme: e, onClose: t }) {
4812
+ function Vr({ theme: e, onClose: t }) {
4719
4813
  let n = s(null);
4720
4814
  return i(() => {
4721
4815
  let e = (e) => n.current && !n.current.contains(e.target) && !e.target.closest("[aria-label=\"Menu\"]") && t();
@@ -4723,11 +4817,11 @@ function Br({ theme: e, onClose: t }) {
4723
4817
  }, [t]), /* @__PURE__ */ f("div", {
4724
4818
  ref: n,
4725
4819
  role: "menu",
4726
- className: "ci-anim-drop ci-absolute ci-right-3 ci-top-14 ci-z-20 ci-w-44 ci-py-2 ci-rounded-2xl ci-bg-gray-50 dark:ci-bg-gray-950 ci-shadow-2xl ci-ring-1 ci-ring-gray-300 dark:ci-ring-gray-700 ci-text-sm",
4820
+ className: "ci-anim-drop ci-absolute ci-right-3 ci-top-14 ci-z-20 ci-w-44 ci-py-2 ci-rounded-2xl ci-bg-gray-50 dark:ci-bg-gray-950 ci-shadow-2xl ci-border ci-border-solid ci-border-gray-300 dark:ci-border-gray-600 ci-text-sm",
4727
4821
  children: [/* @__PURE__ */ d("div", {
4728
4822
  className: "ci-px-4 ci-py-1 ci-font-semibold ci-text-gray-600 dark:ci-text-gray-50",
4729
4823
  children: "Theme"
4730
- }), zr.map((n) => /* @__PURE__ */ f("button", {
4824
+ }), Br.map((n) => /* @__PURE__ */ f("button", {
4731
4825
  type: "button",
4732
4826
  role: "menuitemradio",
4733
4827
  "aria-checked": e === n.value,
@@ -4751,11 +4845,11 @@ function Br({ theme: e, onClose: t }) {
4751
4845
  }
4752
4846
  //#endregion
4753
4847
  //#region src/components/NewChat.tsx
4754
- async function Vr(e) {
4848
+ async function Hr(e) {
4755
4849
  let t = await createImageBitmap(e), n = Math.min(t.width, t.height), r = document.createElement("canvas");
4756
4850
  return r.width = r.height = 128, r.getContext("2d")?.drawImage(t, (t.width - n) / 2, (t.height - n) / 2, n, n, 0, 0, 128, 128), r.toDataURL("image/jpeg", .8);
4757
4851
  }
4758
- function Hr({ onOpen: e, onCreateGroup: t, onDragStart: n }) {
4852
+ function Ur({ onOpen: e, onCreateGroup: t, onDragStart: n }) {
4759
4853
  let { contacts: r, online: i, mobile: a, setPicker: l } = Y(), [p, m] = c(""), [h, g] = c([]), [_, v] = c(""), [y, b] = c(!1), [x, S] = c(), C = s(null), w = o(() => {
4760
4854
  let e = Object.values(r), t = p.trim().toLowerCase();
4761
4855
  return t ? e.filter((e) => (e.name ?? "").toLowerCase().includes(t) || e.username.includes(t)) : e;
@@ -4768,7 +4862,7 @@ function Hr({ onOpen: e, onCreateGroup: t, onDragStart: n }) {
4768
4862
  }
4769
4863
  };
4770
4864
  return /* @__PURE__ */ f("div", {
4771
- className: "ci-w-[22rem] ci-max-h-[30rem] ci-flex ci-flex-col ci-rounded-3xl ci-shadow-2xl ci-overflow-hidden ci-bg-gray-50 dark:ci-bg-gray-950 ci-text-gray-900 dark:ci-text-white",
4865
+ className: "ci-w-[22rem] ci-max-h-[30rem] ci-flex ci-flex-col ci-rounded-3xl ci-shadow-2xl dark:ci-border dark:ci-border-solid dark:ci-border-gray-700 ci-overflow-hidden ci-bg-gray-50 dark:ci-bg-gray-950 ci-text-gray-900 dark:ci-text-white",
4772
4866
  children: [
4773
4867
  /* @__PURE__ */ f("div", {
4774
4868
  className: `ci-px-4 ci-py-3 ci-flex ci-items-center ci-gap-2 ${n ? "ci-cursor-grab active:ci-cursor-grabbing ci-touch-none" : ""}`,
@@ -4864,7 +4958,7 @@ function Hr({ onOpen: e, onCreateGroup: t, onDragStart: n }) {
4864
4958
  type: "file",
4865
4959
  accept: "image/*",
4866
4960
  hidden: !0,
4867
- onChange: (e) => e.target.files?.[0] && Vr(e.target.files[0]).then(S).catch(() => {})
4961
+ onChange: (e) => e.target.files?.[0] && Hr(e.target.files[0]).then(S).catch(() => {})
4868
4962
  }),
4869
4963
  /* @__PURE__ */ d("button", {
4870
4964
  type: "button",
@@ -4899,22 +4993,22 @@ function Hr({ onOpen: e, onCreateGroup: t, onDragStart: n }) {
4899
4993
  }
4900
4994
  //#endregion
4901
4995
  //#region src/theme.ts
4902
- var Ur = "chat-island-theme", Wr = () => {
4996
+ var Wr = "chat-island-theme", Gr = () => {
4903
4997
  try {
4904
- let e = localStorage.getItem(Ur);
4998
+ let e = localStorage.getItem(Wr);
4905
4999
  return e === "light" || e === "dark" || e === "system" ? e : void 0;
4906
5000
  } catch {
4907
5001
  return;
4908
5002
  }
4909
5003
  };
4910
- function Gr(e) {
4911
- let [t, n] = c(() => e ?? Wr()), [r, a] = c(!1);
4912
- return i(() => n(e ?? Wr()), [e]), i(() => {
5004
+ function Kr(e) {
5005
+ let [t, n] = c(() => e ?? Gr()), [r, a] = c(!1);
5006
+ return i(() => n(e ?? Gr()), [e]), i(() => {
4913
5007
  let e = (e) => {
4914
5008
  let t = e.detail?.theme;
4915
5009
  if (t === "light" || t === "dark" || t === "system") {
4916
5010
  try {
4917
- localStorage.setItem(Ur, t);
5011
+ localStorage.setItem(Wr, t);
4918
5012
  } catch {}
4919
5013
  n(t);
4920
5014
  }
@@ -4940,7 +5034,7 @@ function Gr(e) {
4940
5034
  }
4941
5035
  //#endregion
4942
5036
  //#region src/ChatIsland.tsx
4943
- function Kr() {
5037
+ function qr() {
4944
5038
  let e = Y.getState();
4945
5039
  return Object.values(e.conversations).map((t) => {
4946
5040
  let n = t.messages[t.messages.length - 1], r = e.contacts[t.peer];
@@ -4956,7 +5050,7 @@ function Kr() {
4956
5050
  unread: t.unread,
4957
5051
  members: t.members,
4958
5052
  last: n ? {
4959
- body: Yr(n.body),
5053
+ body: Xr(n.body),
4960
5054
  ts: n.ts,
4961
5055
  mine: n.mine,
4962
5056
  oob: n.oob,
@@ -4965,7 +5059,7 @@ function Kr() {
4965
5059
  };
4966
5060
  }).filter((e) => e.last || e.kind === "group").sort((e, t) => (t.last?.ts ?? 0) - (e.last?.ts ?? 0));
4967
5061
  }
4968
- var qr = class extends t {
5062
+ var Jr = class extends t {
4969
5063
  state = { failed: !1 };
4970
5064
  failures = [];
4971
5065
  static getDerivedStateFromError() {
@@ -4983,7 +5077,7 @@ var qr = class extends t {
4983
5077
  return this.state.failed ? null : this.props.children;
4984
5078
  }
4985
5079
  };
4986
- function Jr(e) {
5080
+ function Yr(e) {
4987
5081
  try {
4988
5082
  let [t, n, r] = atob(e).split(":");
4989
5083
  return t && n && r ? {
@@ -4995,8 +5089,8 @@ function Jr(e) {
4995
5089
  return null;
4996
5090
  }
4997
5091
  }
4998
- var Yr = (e) => (pr(e) ? "Attachment" : nr(e)).replace(/```[^\n]*\n?/g, "").replace(/(\*\*|__|~~|`)/g, "").replace(/(^|\s)[*_](\S[^*_]*)[*_]/g, "$1$2").replace(/\s+/g, " ").trim();
4999
- function Xr(e, t = !1) {
5092
+ var Xr = (e) => (mr(e) ? "Attachment" : rr(e)).replace(/```[^\n]*\n?/g, "").replace(/(\*\*|__|~~|`)/g, "").replace(/(^|\s)[*_](\S[^*_]*)[*_]/g, "$1$2").replace(/\s+/g, " ").trim();
5093
+ function Zr(e, t = !1) {
5000
5094
  let [n, r] = c(e);
5001
5095
  return i(() => {
5002
5096
  if (e || t) return r(e);
@@ -5008,8 +5102,8 @@ function Xr(e, t = !1) {
5008
5102
  (t) => !e && t.target === t.currentTarget && r(e)
5009
5103
  ];
5010
5104
  }
5011
- function Zr({ dataConfig: e, position: t = "bottom-right", theme: n, serviceWorker: r, maxHeads: a = 5, newChatButton: l = !0, notifications: u = "click", sound: p = !0, drag: m = !0, onDragStart: h }) {
5012
- let g = o(() => Jr(e), [e]), [_, v] = Gr(n), y = s(g), b = s(p), x = s(u);
5105
+ function Qr({ dataConfig: e, position: t = "bottom-right", theme: n, serviceWorker: r, maxHeads: a = 5, newChatButton: l = !0, notifications: u = "click", sound: p = !0, drag: m = !0, onDragStart: h }) {
5106
+ let g = o(() => Yr(e), [e]), [_, v] = Kr(n), y = s(g), b = s(p), x = s(u);
5013
5107
  i(() => {
5014
5108
  y.current = g, b.current = p, x.current = u;
5015
5109
  }, [
@@ -5034,7 +5128,7 @@ function Zr({ dataConfig: e, position: t = "bottom-right", theme: n, serviceWork
5034
5128
  let r = T.current;
5035
5129
  if (!r) throw Error("not connected");
5036
5130
  try {
5037
- Y.getState().addMessage(e, await r.send(e, nr(t), void 0, n));
5131
+ Y.getState().addMessage(e, await r.send(e, rr(t), void 0, n));
5038
5132
  } catch (e) {
5039
5133
  throw X("chat-island-error", {
5040
5134
  scope: "send",
@@ -5159,7 +5253,7 @@ function Zr({ dataConfig: e, position: t = "bottom-right", theme: n, serviceWork
5159
5253
  }), n = (e, t) => {
5160
5254
  let n = Y.getState(), r = document.visibilityState === "visible";
5161
5255
  if (r && n.open === e) return;
5162
- let i = n.conversations[e], a = i?.kind === "group" ? i.name ?? e : n.contacts[e]?.name ?? n.inactive[e] ?? e, o = t.oob ? "Attachment" : nr(t.body), s = i?.kind === "group", c = s && t.nick ? n.contacts[t.nick]?.name ?? t.nick : a, l = s && t.nick ? `${c}: ${o}` : o;
5256
+ let i = n.conversations[e], a = i?.kind === "group" ? i.name ?? e : n.contacts[e]?.name ?? n.inactive[e] ?? e, o = t.oob ? "Attachment" : rr(t.body), s = i?.kind === "group", c = s && t.nick ? n.contacts[t.nick]?.name ?? t.nick : a, l = s && t.nick ? `${c}: ${o}` : o;
5163
5257
  b.current && Cn();
5164
5258
  let u = s ? i?.avatar : n.contacts[e]?.avatar;
5165
5259
  if (X("chat-island-notify", {
@@ -5214,7 +5308,7 @@ function Zr({ dataConfig: e, position: t = "bottom-right", theme: n, serviceWork
5214
5308
  scope: "contacts",
5215
5309
  message: e.message
5216
5310
  }));
5217
- let d = Z("chat-island-open", ({ username: t }) => t && e.openChat(t)), f = Z("chat-island-close", () => e.closeChat()), p = Z("chat-island-new", () => e.setPicker(!0)), m = Z("chat-island-delete", ({ username: e }) => e && F.remove(e)), h = Z("chat-island-send", ({ username: e, text: t }) => e && t && F.send(e, t).catch(() => {})), _ = Z("chat-island-group-create", ({ name: e, members: t }) => e && t?.length && F.createGroup(e, t)), v = Z("chat-island-contacts", ({ contacts: t }) => t && e.setContacts(t)), y = Z("chat-island-conversations-request", () => X("chat-island-conversations", { conversations: Kr() }));
5311
+ let d = Z("chat-island-open", ({ username: t }) => t && e.openChat(t)), f = Z("chat-island-close", () => e.closeChat()), p = Z("chat-island-new", () => e.setPicker(!0)), m = Z("chat-island-delete", ({ username: e }) => e && F.remove(e)), h = Z("chat-island-send", ({ username: e, text: t }) => e && t && F.send(e, t).catch(() => {})), _ = Z("chat-island-group-create", ({ name: e, members: t }) => e && t?.length && F.createGroup(e, t)), v = Z("chat-island-contacts", ({ contacts: t }) => t && e.setContacts(t)), y = Z("chat-island-conversations-request", () => X("chat-island-conversations", { conversations: qr() }));
5218
5312
  return () => {
5219
5313
  window.removeEventListener("pagehide", s), window.clearInterval(u), y(), p(), m(), h(), _(), d(), f(), v(), k.current && t.disablePush(k.current.service, k.current.node).catch(() => {}), k.current = null, t.stop(), T.current = null, O.current = !1;
5220
5314
  };
@@ -5228,14 +5322,14 @@ function Zr({ dataConfig: e, position: t = "bottom-right", theme: n, serviceWork
5228
5322
  P === "online" && ee && T.current?.announce(ee.split(","));
5229
5323
  }, [P, ee]);
5230
5324
  let te = Y((e) => Object.values(e.conversations).map((e) => `${e.peer}:${e.kind}:${e.name ?? ""}:${(e.members ?? []).length}:${e.unread}:${e.messages[e.messages.length - 1]?.id ?? ""}`).join("|") + "#" + Object.keys(e.contacts).length + "#" + Object.values(e.online).filter(Boolean).length + "#" + Object.keys(e.inactive).length);
5231
- i(() => X("chat-island-conversations", { conversations: Kr() }), [te]);
5325
+ i(() => X("chat-island-conversations", { conversations: qr() }), [te]);
5232
5326
  let ne = Y((e) => Object.values(e.conversations).reduce((e, t) => e + t.unread, 0));
5233
5327
  i(() => X("chat-island-unread", { total: ne }), [ne]);
5234
5328
  let re = s(null), ie = s(M), I = s(null), L = !N && !!M && M !== ie.current && !!re.current;
5235
5329
  L && (I.current = re.current.offsetHeight), i(() => {
5236
5330
  ie.current = M, M || (I.current = null);
5237
5331
  }, [M]);
5238
- let [ae, oe, se] = Xr(M), [ce, le, R] = Xr(N, L);
5332
+ let [ae, oe, se] = Zr(M), [ce, le, R] = Zr(N, L);
5239
5333
  if (!g) return null;
5240
5334
  let ue = m && !h && j.anchor ? {
5241
5335
  right: j.anchor.right,
@@ -5247,12 +5341,12 @@ function Zr({ dataConfig: e, position: t = "bottom-right", theme: n, serviceWork
5247
5341
  onClickCapture: j.onClickCapture,
5248
5342
  className: `chat-island-root ${_ ? "ci-dark" : ""} ci-fixed ${de} ci-z-[9999] ci-flex ci-items-end ci-gap-3 ci-font-sans ci-select-none`,
5249
5343
  "data-status": P,
5250
- children: /* @__PURE__ */ f(qr, { children: [
5344
+ children: /* @__PURE__ */ f(Jr, { children: [
5251
5345
  ae && /* @__PURE__ */ d("div", {
5252
5346
  className: oe ? "ci-anim-close" : I.current ? "ci-anim-morph" : "ci-anim-open",
5253
5347
  style: I.current ? { "--ci-from": `${I.current}px` } : void 0,
5254
5348
  onAnimationEnd: se,
5255
- children: /* @__PURE__ */ d(Rr, {
5349
+ children: /* @__PURE__ */ d(zr, {
5256
5350
  peer: ae,
5257
5351
  actions: F,
5258
5352
  theme: v,
@@ -5263,7 +5357,7 @@ function Zr({ dataConfig: e, position: t = "bottom-right", theme: n, serviceWork
5263
5357
  ref: re,
5264
5358
  className: le ? "ci-anim-close" : "ci-anim-open",
5265
5359
  onAnimationEnd: R,
5266
- children: /* @__PURE__ */ d(Hr, {
5360
+ children: /* @__PURE__ */ d(Ur, {
5267
5361
  onOpen: (e) => Y.getState().openChat(e),
5268
5362
  onCreateGroup: F.createGroup,
5269
5363
  onDragStart: h ?? (m ? j.start : void 0)
@@ -5277,4 +5371,4 @@ function Zr({ dataConfig: e, position: t = "bottom-right", theme: n, serviceWork
5277
5371
  });
5278
5372
  }
5279
5373
  //#endregion
5280
- export { Zr as ChatIsland, Fn as contactsFromOperators };
5374
+ export { Qr as ChatIsland, Fn as contactsFromOperators };