@nethesis/chat-island 0.1.9 → 0.1.11

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
@@ -43,7 +43,7 @@ function w(e) {
43
43
  //#endregion
44
44
  //#region src/drag.ts
45
45
  var T = 8;
46
- function ee(e, t) {
46
+ function E(e, t) {
47
47
  let [n, a] = c(() => {
48
48
  try {
49
49
  let e = localStorage.getItem(t);
@@ -103,7 +103,7 @@ function ee(e, t) {
103
103
  }
104
104
  //#endregion
105
105
  //#region node_modules/ltx/lib/escape.js
106
- var E = /* @__PURE__ */ y(((e) => {
106
+ var D = /* @__PURE__ */ y(((e) => {
107
107
  var t = {
108
108
  "&": "&",
109
109
  "<": "&lt;",
@@ -145,8 +145,8 @@ var E = /* @__PURE__ */ y(((e) => {
145
145
  return e.replace(/&(amp|#38|lt|#60|gt|#62);/g, i);
146
146
  }
147
147
  e.escapeXML = a, e.escapeXMLText = s, e.unescapeXML = o, e.unescapeXMLText = c;
148
- })), D = /* @__PURE__ */ y(((e, t) => {
149
- var n = E(), r = class e {
148
+ })), O = /* @__PURE__ */ y(((e, t) => {
149
+ var n = D(), r = class e {
150
150
  constructor(e, t) {
151
151
  this.name = e, this.parent = null, this.children = [], this.attrs = {}, this.setAttrs(t);
152
152
  }
@@ -277,8 +277,8 @@ var E = /* @__PURE__ */ y(((e) => {
277
277
  }
278
278
  };
279
279
  r.prototype.tree = r.prototype.root, t.exports = r;
280
- })), O = /* @__PURE__ */ y(((e, t) => {
281
- var n = D();
280
+ })), k = /* @__PURE__ */ y(((e, t) => {
281
+ var n = O();
282
282
  function r(e, t) {
283
283
  if (Array.isArray(t)) {
284
284
  for (let n of t) r(e, n);
@@ -296,7 +296,7 @@ var E = /* @__PURE__ */ y(((e) => {
296
296
  return a;
297
297
  }
298
298
  t.exports = i;
299
- })), k = /* @__PURE__ */ y(((e, t) => {
299
+ })), A = /* @__PURE__ */ y(((e, t) => {
300
300
  var n = typeof Reflect == "object" ? Reflect : null, r = n && typeof n.apply == "function" ? n.apply : function(e, t, n) {
301
301
  return Function.prototype.apply.call(e, t, n);
302
302
  }, i = n && typeof n.ownKeys == "function" ? n.ownKeys : Object.getOwnPropertySymbols ? function(e) {
@@ -471,8 +471,8 @@ var E = /* @__PURE__ */ y(((e) => {
471
471
  });
472
472
  else throw TypeError("The \"emitter\" argument must be of type EventEmitter. Received type " + typeof e);
473
473
  }
474
- })), te = /* @__PURE__ */ y(((e, t) => {
475
- var n = k(), r = E(), i = 0, a = 1, o = 2, s = 3, c = 4, l = 5, u = 6, d = 7, f = 8, p = 9, m = 10;
474
+ })), ee = /* @__PURE__ */ y(((e, t) => {
475
+ var n = A(), r = D(), i = 0, a = 1, o = 2, s = 3, c = 4, l = 5, u = 6, d = 7, f = 8, p = 9, m = 10;
476
476
  t.exports = class extends n.EventEmitter {
477
477
  constructor() {
478
478
  super();
@@ -565,14 +565,14 @@ var E = /* @__PURE__ */ y(((e) => {
565
565
  e && this.write(e), this.write = function() {};
566
566
  }
567
567
  };
568
- })), A = E(), j = /* @__PURE__ */ x(D(), 1), M = /* @__PURE__ */ x(O(), 1), N = k(), ne = /* @__PURE__ */ x(te(), 1), re = class extends Error {
568
+ })), j = D(), M = /* @__PURE__ */ x(O(), 1), N = /* @__PURE__ */ x(k(), 1), P = A(), te = /* @__PURE__ */ x(ee(), 1), ne = class extends Error {
569
569
  constructor(e) {
570
570
  super(e), this.name = "TimeoutError";
571
571
  }
572
572
  };
573
573
  //#endregion
574
574
  //#region node_modules/@xmpp/events/lib/delay.js
575
- function ie(e) {
575
+ function re(e) {
576
576
  let t, n = new Promise((n) => {
577
577
  t = setTimeout(n, e);
578
578
  });
@@ -580,32 +580,32 @@ function ie(e) {
580
580
  }
581
581
  //#endregion
582
582
  //#region node_modules/@xmpp/events/lib/timeout.js
583
- function ae(e, t) {
584
- let n = ie(t);
583
+ function ie(e, t) {
584
+ let n = re(t);
585
585
  function r() {
586
586
  clearTimeout(n.timeout);
587
587
  }
588
- let i = new re();
588
+ let i = new ne();
589
589
  return Promise.race([e.finally(r), n.then(() => {
590
590
  throw i;
591
591
  })]);
592
592
  }
593
593
  //#endregion
594
594
  //#region node_modules/@xmpp/events/lib/onoff.js
595
- var oe = /* @__PURE__ */ new WeakMap();
596
- function se(e) {
597
- let t = oe.get(e);
595
+ var ae = /* @__PURE__ */ new WeakMap();
596
+ function oe(e) {
597
+ let t = ae.get(e);
598
598
  return t || (t = {
599
599
  on: (e.addEventListener ?? e.addListener).bind(e),
600
600
  off: (e.removeEventListener ?? e.removeListener).bind(e),
601
601
  once: (e.once ?? ((t, n) => e.addEventListener(t, n, { once: !0 }))).bind(e)
602
- }, oe.set(e, t)), t;
602
+ }, ae.set(e, t)), t;
603
603
  }
604
604
  //#endregion
605
605
  //#region node_modules/@xmpp/events/lib/promise.js
606
- function P(e, t, n = "error", r) {
606
+ function F(e, t, n = "error", r) {
607
607
  return new Promise((i, a) => {
608
- let o, { off: s, once: c } = se(e), l = () => {
608
+ let o, { off: s, once: c } = oe(e), l = () => {
609
609
  clearTimeout(o), s(t, d), s(n, u);
610
610
  };
611
611
  function u(e) {
@@ -615,7 +615,7 @@ function P(e, t, n = "error", r) {
615
615
  i(e), l();
616
616
  }
617
617
  if (c(t, d), n && c(n, u), r) {
618
- let e = new re();
618
+ let e = new ne();
619
619
  o = setTimeout(() => {
620
620
  l(), a(e);
621
621
  }, r);
@@ -624,14 +624,14 @@ function P(e, t, n = "error", r) {
624
624
  }
625
625
  //#endregion
626
626
  //#region node_modules/@xmpp/events/lib/Deferred.js
627
- function ce() {
627
+ function se() {
628
628
  this.promise = new Promise((e, t) => {
629
629
  this.resolve = e, this.reject = t;
630
630
  });
631
631
  }
632
632
  //#endregion
633
633
  //#region node_modules/@xmpp/events/lib/procedure.js
634
- function le(e, t = null, n) {
634
+ function ce(e, t = null, n) {
635
635
  return new Promise((r, i) => {
636
636
  function a(t) {
637
637
  e.removeListener("nonza", s), i(t);
@@ -651,38 +651,38 @@ function le(e, t = null, n) {
651
651
  }
652
652
  //#endregion
653
653
  //#region node_modules/@xmpp/events/lib/listeners.js
654
- function ue(e) {
654
+ function le(e) {
655
655
  return {
656
656
  subscribe(t) {
657
- let { on: n } = se(t);
657
+ let { on: n } = oe(t);
658
658
  for (let [t, r] of Object.entries(e)) n(t, r);
659
659
  },
660
660
  unsubscribe(t) {
661
- let { off: n } = se(t);
661
+ let { off: n } = oe(t);
662
662
  for (let [t, r] of Object.entries(e)) n(t, r);
663
663
  }
664
664
  };
665
665
  }
666
666
  //#endregion
667
667
  //#region node_modules/@xmpp/xml/lib/XMLError.js
668
- var F = class extends Error {
668
+ var ue = class extends Error {
669
669
  constructor(...e) {
670
670
  super(...e), this.name = "XMLError";
671
671
  }
672
- }, de = class extends N.EventEmitter {
672
+ }, de = class extends P.EventEmitter {
673
673
  constructor() {
674
674
  super();
675
- let e = new ne.default();
675
+ let e = new te.default();
676
676
  this.root = null, this.cursor = null, e.on("startElement", this.onStartElement.bind(this)), e.on("endElement", this.onEndElement.bind(this)), e.on("text", this.onText.bind(this)), this.parser = e;
677
677
  }
678
678
  onStartElement(e, t) {
679
- let n = new j.default(e, t), { root: r, cursor: i } = this;
679
+ let n = new M.default(e, t), { root: r, cursor: i } = this;
680
680
  r ? i !== r && i.append(n) : (this.root = n, this.emit("start", n)), this.cursor = n;
681
681
  }
682
682
  onEndElement(e) {
683
683
  let { root: t, cursor: n } = this;
684
684
  if (e !== n.name) {
685
- this.emit("error", new F(`${n.name} must be closed.`));
685
+ this.emit("error", new ue(`${n.name} must be closed.`));
686
686
  return;
687
687
  }
688
688
  if (n === t) {
@@ -698,7 +698,7 @@ var F = class extends Error {
698
698
  onText(e) {
699
699
  let { cursor: t } = this;
700
700
  if (!t) {
701
- this.emit("error", new F(`${e} must be a child.`));
701
+ this.emit("error", new ue(`${e} must be a child.`));
702
702
  return;
703
703
  }
704
704
  t.t(e);
@@ -710,21 +710,21 @@ var F = class extends Error {
710
710
  e && this.parser.write(e);
711
711
  }
712
712
  };
713
- de.XMLError = F;
713
+ de.XMLError = ue;
714
714
  //#endregion
715
715
  //#region node_modules/@xmpp/xml/index.js
716
716
  function I(...e) {
717
- return (0, M.default)(...e);
717
+ return (0, N.default)(...e);
718
718
  }
719
719
  Object.assign(I, {
720
- Element: j.default,
721
- createElement: M.default,
720
+ Element: M.default,
721
+ createElement: N.default,
722
722
  Parser: de,
723
- escapeXML: A.escapeXML,
724
- unescapeXML: A.unescapeXML,
725
- escapeXMLText: A.escapeXMLText,
726
- unescapeXMLText: A.unescapeXMLText,
727
- XMLError: F,
723
+ escapeXML: j.escapeXML,
724
+ unescapeXML: j.unescapeXML,
725
+ escapeXMLText: j.escapeXMLText,
726
+ unescapeXMLText: j.unescapeXMLText,
727
+ XMLError: ue,
728
728
  xml: I
729
729
  });
730
730
  //#endregion
@@ -845,7 +845,7 @@ function Se(e) {
845
845
  }
846
846
  //#endregion
847
847
  //#region node_modules/@xmpp/connection/index.js
848
- var Ce = "urn:ietf:params:xml:ns:xmpp-streams", we = "http://etherx.jabber.org/streams", Te = class extends N.EventEmitter {
848
+ var Ce = "urn:ietf:params:xml:ns:xmpp-streams", we = "http://etherx.jabber.org/streams", Te = class extends P.EventEmitter {
849
849
  #e = null;
850
850
  #t = null;
851
851
  constructor(e = {}) {
@@ -880,7 +880,7 @@ var Ce = "urn:ietf:params:xml:ns:xmpp-streams", we = "http://etherx.jabber.org/s
880
880
  });
881
881
  }
882
882
  _attachSocket(e) {
883
- this.socket = e, this.#e ??= ue({
883
+ this.socket = e, this.#e ??= le({
884
884
  data: this._onData.bind(this),
885
885
  close: this.#r.bind(this),
886
886
  connect: () => this._status("connect"),
@@ -903,7 +903,7 @@ var Ce = "urn:ietf:params:xml:ns:xmpp-streams", we = "http://etherx.jabber.org/s
903
903
  let { protocol: t } = Se(this.options.service), n = e.element.getChildText("see-other-host"), { port: r } = xe(n), i;
904
904
  i = r ? `${t || "xmpp:"}//${n}` : (t ? `${t}//` : "") + n;
905
905
  try {
906
- await P(this, "disconnect");
906
+ await F(this, "disconnect");
907
907
  let { domain: e, lang: t } = this.options;
908
908
  await this.connect(i), await this.open({
909
909
  domain: e,
@@ -914,7 +914,7 @@ var Ce = "urn:ietf:params:xml:ns:xmpp-streams", we = "http://etherx.jabber.org/s
914
914
  }
915
915
  }
916
916
  _attachParser(e) {
917
- this.parser = e, this.#t ??= ue({
917
+ this.parser = e, this.#t ??= le({
918
918
  element: this._onElement.bind(this),
919
919
  error: this.#n.bind(this),
920
920
  end: this.#i.bind(this),
@@ -951,7 +951,7 @@ var Ce = "urn:ietf:params:xml:ns:xmpp-streams", we = "http://etherx.jabber.org/s
951
951
  if (this.status !== "offline") throw Error("Connection is not offline");
952
952
  let { service: e, domain: t, lang: n } = this.options;
953
953
  await this.connect(e);
954
- let r = P(this, "online");
954
+ let r = F(this, "online");
955
955
  return await this.open({
956
956
  domain: t,
957
957
  lang: n
@@ -960,15 +960,15 @@ var Ce = "urn:ietf:params:xml:ns:xmpp-streams", we = "http://etherx.jabber.org/s
960
960
  async connect(e) {
961
961
  this._status("connecting", e);
962
962
  let t = new this.Socket();
963
- return this._attachSocket(t), t.connect(this.socketParameters(e)), P(t, "connect");
963
+ return this._attachSocket(t), t.connect(this.socketParameters(e)), F(t, "connect");
964
964
  }
965
965
  async _closeSocket(e = this.timeout) {
966
- this._status("disconnecting"), this.socket.end(), await P(this.socket, "close", "error", e);
966
+ this._status("disconnecting"), this.socket.end(), await F(this.socket, "close", "error", e);
967
967
  }
968
968
  async open(e) {
969
969
  this._status("opening");
970
970
  let { domain: t, lang: n } = e, r = this.headerElement();
971
- return r.attrs.to = t, r.attrs["xml:lang"] = n, this.root = r, this._attachParser(new this.Parser()), await this.write(this.header(r)), P(this, "open", "error", this.timeout);
971
+ return r.attrs.to = t, r.attrs["xml:lang"] = n, this.root = r, this._attachParser(new this.Parser()), await this.write(this.header(r)), F(this, "open", "error", this.timeout);
972
972
  }
973
973
  async stop() {
974
974
  let e = await this.disconnect();
@@ -977,7 +977,7 @@ var Ce = "urn:ietf:params:xml:ns:xmpp-streams", we = "http://etherx.jabber.org/s
977
977
  async _closeStream(e = this.timeout) {
978
978
  await this.#c("close");
979
979
  let t = this.footer(this.footerElement());
980
- return await this.write(t), this._status("closing"), P(this.parser, "end", "error", e);
980
+ return await this.write(t), this._status("closing"), F(this.parser, "end", "error", e);
981
981
  }
982
982
  async restart() {
983
983
  this._detachParser();
@@ -991,7 +991,7 @@ var Ce = "urn:ietf:params:xml:ns:xmpp-streams", we = "http://etherx.jabber.org/s
991
991
  e.parent = this.root, await this.write(e.toString()), this.emit("send", e);
992
992
  }
993
993
  sendReceive(e, t = this.timeout) {
994
- return Promise.all([this.send(e), P(this, "element", "error", t)]).then(([, e]) => e);
994
+ return Promise.all([this.send(e), F(this, "element", "error", t)]).then(([, e]) => e);
995
995
  }
996
996
  async write(e) {
997
997
  if (this.status === "closing") throw Error("Connection is closing");
@@ -1092,7 +1092,7 @@ var Ee = class extends Te {
1092
1092
  Ee.prototype.NS = "jabber:client";
1093
1093
  //#endregion
1094
1094
  //#region node_modules/@xmpp/reconnect/index.js
1095
- var De = class extends N.EventEmitter {
1095
+ var De = class extends P.EventEmitter {
1096
1096
  constructor(e) {
1097
1097
  super(), this.delay = 1e3, this.entity = e, this._timeout = null;
1098
1098
  }
@@ -1140,7 +1140,7 @@ function Ae(e) {
1140
1140
  "::1"
1141
1141
  ].includes(t.hostname));
1142
1142
  }
1143
- var je = class extends N.EventEmitter {
1143
+ var je = class extends P.EventEmitter {
1144
1144
  #e = null;
1145
1145
  socket = null;
1146
1146
  url = null;
@@ -1149,7 +1149,7 @@ var je = class extends N.EventEmitter {
1149
1149
  this.url = e, this.secure = Ae(e), this._attachSocket(new WebSocket(e, ["xmpp"]));
1150
1150
  }
1151
1151
  _attachSocket(e) {
1152
- this.socket = e, this.#e ??= ue({
1152
+ this.socket = e, this.#e ??= le({
1153
1153
  open: () => this.emit("connect"),
1154
1154
  message: ({ data: e }) => this.emit("data", e),
1155
1155
  error: (e) => {
@@ -1181,13 +1181,13 @@ var je = class extends N.EventEmitter {
1181
1181
  }
1182
1182
  }, Me = class extends de {
1183
1183
  onStartElement(e, t) {
1184
- let n = new j.default(e, t), { cursor: r } = this;
1184
+ let n = new M.default(e, t), { cursor: r } = this;
1185
1185
  r && r.append(n), this.cursor = n;
1186
1186
  }
1187
1187
  onEndElement(e) {
1188
1188
  let { cursor: t } = this;
1189
1189
  if (e !== t.name) {
1190
- this.emit("error", new F(`${t.name} must be closed.`));
1190
+ this.emit("error", new ue(`${t.name} must be closed.`));
1191
1191
  return;
1192
1192
  }
1193
1193
  if (t.parent) {
@@ -1342,10 +1342,10 @@ var Ye = class {
1342
1342
  }
1343
1343
  async request(e, t = 3e4) {
1344
1344
  e.attrs.id || (e.attrs.id = Ke());
1345
- let n = new ce();
1345
+ let n = new se();
1346
1346
  this.handlers.set(e.attrs.id, n);
1347
1347
  try {
1348
- await this.entity.send(e), await ae(n.promise, t);
1348
+ await this.entity.send(e), await ie(n.promise, t);
1349
1349
  } catch (t) {
1350
1350
  throw this.handlers.delete(e.attrs.id), t;
1351
1351
  }
@@ -1594,7 +1594,7 @@ async function bt(e, t) {
1594
1594
  e._status("connecting", n);
1595
1595
  let i = r.prototype.socketParameters(n), a = new r.prototype.Socket();
1596
1596
  try {
1597
- a.connect(i), await P(a, "connect");
1597
+ a.connect(i), await F(a, "connect");
1598
1598
  } catch {
1599
1599
  return bt(e, t);
1600
1600
  }
@@ -1645,7 +1645,7 @@ async function Dt({ saslFactory: e, entity: t, mechanism: n, credentials: r }) {
1645
1645
  serviceName: a,
1646
1646
  ...r
1647
1647
  };
1648
- await le(t, i.clientFirst && I("auth", {
1648
+ await ce(t, i.clientFirst && I("auth", {
1649
1649
  xmlns: Tt,
1650
1650
  mechanism: i.name
1651
1651
  }, St(await i.response(o))), async (e, n) => {
@@ -1695,7 +1695,7 @@ async function At({ saslFactory: e, entity: t, mechanism: n, credentials: r, use
1695
1695
  serviceName: c,
1696
1696
  ...r
1697
1697
  };
1698
- await le(t, I("authenticate", {
1698
+ await ce(t, I("authenticate", {
1699
1699
  xmlns: kt,
1700
1700
  mechanism: s.name
1701
1701
  }, [
@@ -1832,13 +1832,13 @@ function Vt({ streamFeatures: e, sm: t, entity: n, resumed: r, failed: i, enable
1832
1832
  });
1833
1833
  }
1834
1834
  function Ht(e, t) {
1835
- return le(e, Wt({ sm: t }), (e, t) => {
1835
+ return ce(e, Wt({ sm: t }), (e, t) => {
1836
1836
  if (e.is("enabled", "urn:xmpp:sm:3")) return t(e);
1837
1837
  if (e.is("failed", "urn:xmpp:sm:3")) throw ve.fromElement(e);
1838
1838
  });
1839
1839
  }
1840
1840
  async function Ut(e, t) {
1841
- return le(e, Gt({ sm: t }), (e, t) => {
1841
+ return ce(e, Gt({ sm: t }), (e, t) => {
1842
1842
  if (e.is("resumed", "urn:xmpp:sm:3")) return t(e);
1843
1843
  if (e.is("failed", "urn:xmpp:sm:3")) throw ve.fromElement(e);
1844
1844
  });
@@ -1861,7 +1861,7 @@ function Gt({ sm: e }) {
1861
1861
  });
1862
1862
  }
1863
1863
  function Kt({ streamFeatures: e, entity: t, middleware: n, bind2: r, sasl2: i }) {
1864
- let a = null, o = null, s = null, c = new N.EventEmitter();
1864
+ let a = null, o = null, s = null, c = new P.EventEmitter();
1865
1865
  Object.assign(c, {
1866
1866
  preferredMaximum: null,
1867
1867
  enabled: !1,
@@ -2034,7 +2034,7 @@ var Zt = /* @__PURE__ */ y(((e, t) => {
2034
2034
  });
2035
2035
  })))(), 1), V = "urn:xmpp:fast:0";
2036
2036
  function $t({ sasl2: e, entity: t }) {
2037
- let n = new Qt.default(), r, i = new N.EventEmitter();
2037
+ let n = new Qt.default(), r, i = new P.EventEmitter();
2038
2038
  Object.assign(i, {
2039
2039
  mechanism: null,
2040
2040
  mechanisms: [],
@@ -2256,13 +2256,13 @@ function mn(e = {}) {
2256
2256
  }, dn(n ?? {
2257
2257
  username: r,
2258
2258
  password: i
2259
- }, a)), ee = Kt({
2259
+ }, a)), E = Kt({
2260
2260
  streamFeatures: h,
2261
2261
  entity: l,
2262
2262
  middleware: m,
2263
2263
  bind2: w,
2264
2264
  sasl2: S
2265
- }), E = Lt({
2265
+ }), D = Lt({
2266
2266
  iqCaller: g,
2267
2267
  streamFeatures: h
2268
2268
  }, t);
@@ -2281,8 +2281,8 @@ function mn(e = {}) {
2281
2281
  saslFactory: y,
2282
2282
  sasl2: S,
2283
2283
  sasl: T,
2284
- resourceBinding: E,
2285
- streamManagement: ee,
2284
+ resourceBinding: D,
2285
+ streamManagement: E,
2286
2286
  mechanisms: b,
2287
2287
  bind2: w,
2288
2288
  fast: C
@@ -2559,14 +2559,14 @@ var U = {
2559
2559
  xmlns: U.data,
2560
2560
  type: "submit"
2561
2561
  }, o("FORM_TYPE", "http://jabber.org/protocol/muc#roomconfig"), o("muc#roomconfig_roomname", e), o("muc#roomconfig_persistentroom", "1"), o("muc#roomconfig_membersonly", "1"), o("muc#roomconfig_publicroom", "0"), o("muc#roomconfig_whois", "anyone"), o("allow_subscription", "1"), o("mam", "1")))), 15e3), n && await this.setGroupAvatar(r, n).catch(() => {});
2562
- let s = t.filter((e) => e && e !== this.cfg.username);
2562
+ let s = t.filter((e) => e && e !== this.cfg.username), c = Date.now();
2563
2563
  await this.xmpp.iqCaller.request(I("iq", {
2564
2564
  type: "set",
2565
2565
  to: r
2566
- }, I("query", { xmlns: U.mucAdmin }, ...s.map((e) => I("item", {
2566
+ }, I("query", { xmlns: U.mucAdmin }, ...s.map((e, t) => I("item", {
2567
2567
  affiliation: "member",
2568
2568
  jid: `${e}@${this.domain}`
2569
- })))), 15e3);
2569
+ }, I("reason", {}, String(c + t)))))), 15e3);
2570
2570
  for (let e of s) await this.xmpp.iqCaller.request(I("iq", {
2571
2571
  type: "set",
2572
2572
  to: r
@@ -2964,6 +2964,7 @@ var An = (e) => {
2964
2964
  contacts: {},
2965
2965
  online: {},
2966
2966
  mobile: {},
2967
+ inactive: {},
2967
2968
  conversations: {},
2968
2969
  order: [],
2969
2970
  open: null,
@@ -2982,6 +2983,7 @@ var An = (e) => {
2982
2983
  contacts: {},
2983
2984
  online: {},
2984
2985
  mobile: {},
2986
+ inactive: {},
2985
2987
  conversations: {},
2986
2988
  order: [],
2987
2989
  open: null,
@@ -2992,6 +2994,7 @@ var An = (e) => {
2992
2994
  name: e.name || e.username
2993
2995
  }])) }),
2994
2996
  setMobile: (t) => e({ mobile: Object.fromEntries(t.map((e) => [e, !0])) }),
2997
+ setInactive: (t) => e({ inactive: t }),
2995
2998
  setOnline: (t, n) => e((e) => e.online[t] === n ? {} : { online: {
2996
2999
  ...e.online,
2997
3000
  [t]: n
@@ -3154,7 +3157,13 @@ async function Ln(e, t) {
3154
3157
  if (!n.ok) throw Error(`push/mobile: HTTP ${n.status}`);
3155
3158
  return (await n.json()).users;
3156
3159
  }
3157
- async function Rn(e, t, n) {
3160
+ async function Rn(e, t) {
3161
+ let n = await fetch(`https://${e}/chat-gw/users/inactive`, { headers: { Authorization: `Bearer ${t}` } });
3162
+ if (!n.ok) throw Error(`users/inactive: HTTP ${n.status}`);
3163
+ let { users: r } = await n.json();
3164
+ return Object.fromEntries(r.map((e) => [e.username, e.name || e.username]));
3165
+ }
3166
+ async function zn(e, t, n) {
3158
3167
  let r = await fetch(`https://${e}/chat-gw/conversations/${encodeURIComponent(n)}`, {
3159
3168
  method: "DELETE",
3160
3169
  headers: { Authorization: `Bearer ${t}` }
@@ -3163,16 +3172,16 @@ async function Rn(e, t, n) {
3163
3172
  }
3164
3173
  //#endregion
3165
3174
  //#region src/push.ts
3166
- var zn = (e) => {
3175
+ var Bn = (e) => {
3167
3176
  let t = atob((e + "=".repeat((4 - e.length % 4) % 4)).replace(/-/g, "+").replace(/_/g, "/"));
3168
3177
  return Uint8Array.from(t, (e) => e.charCodeAt(0));
3169
- }, Bn = !1;
3170
- function Vn() {
3171
- Bn || (Bn = !0, navigator.serviceWorker.addEventListener("message", (e) => {
3178
+ }, Vn = !1;
3179
+ function Hn() {
3180
+ Vn || (Vn = !0, navigator.serviceWorker.addEventListener("message", (e) => {
3172
3181
  e.data?.type === "chat-island-open" && typeof e.data.username == "string" && window.dispatchEvent(new CustomEvent("chat-island-open", { detail: { username: e.data.username } }));
3173
3182
  }));
3174
3183
  }
3175
- async function Hn(e, t) {
3184
+ async function Un(e, t) {
3176
3185
  if (!("serviceWorker" in navigator) || !("PushManager" in window)) throw Error("push not supported by this browser");
3177
3186
  if (Notification.permission === "denied" || Notification.permission !== "granted" && await Notification.requestPermission() !== "granted") return null;
3178
3187
  let n = `https://${e.host}/chat-gw`, r = await fetch(`${n}/push/vapid`);
@@ -3181,7 +3190,7 @@ async function Hn(e, t) {
3181
3190
  await navigator.serviceWorker.ready;
3182
3191
  let o = await a.pushManager.getSubscription() ?? await a.pushManager.subscribe({
3183
3192
  userVisibleOnly: !0,
3184
- applicationServerKey: zn(i.publicKey)
3193
+ applicationServerKey: Bn(i.publicKey)
3185
3194
  }), s = await fetch(`${n}/push/web`, {
3186
3195
  method: "POST",
3187
3196
  headers: {
@@ -3192,7 +3201,7 @@ async function Hn(e, t) {
3192
3201
  });
3193
3202
  if (!s.ok) throw Error(`push/web: HTTP ${s.status} ${(await s.text()).slice(0, 120)}`);
3194
3203
  let c = await s.json();
3195
- return Vn(), {
3204
+ return Hn(), {
3196
3205
  node: c.node,
3197
3206
  service: c.service
3198
3207
  };
@@ -3208,8 +3217,8 @@ function X(e, t) {
3208
3217
  }
3209
3218
  //#endregion
3210
3219
  //#region src/components/Avatar.tsx
3211
- var Un = (e) => e.split(/\s+/).slice(0, 2).map((e) => e[0]?.toUpperCase() ?? "").join("");
3212
- function Wn({ contact: e, username: t, size: n = 40 }) {
3220
+ var Wn = (e) => e.split(/\s+/).slice(0, 2).map((e) => e[0]?.toUpperCase() ?? "").join("");
3221
+ function Gn({ contact: e, username: t, size: n = 40 }) {
3213
3222
  let r = e?.name || t, i = {
3214
3223
  width: n,
3215
3224
  height: n,
@@ -3224,13 +3233,13 @@ function Wn({ contact: e, username: t, size: n = 40 }) {
3224
3233
  }) : /* @__PURE__ */ d("div", {
3225
3234
  style: i,
3226
3235
  className: "ci-rounded-full ci-shrink-0 ci-flex ci-items-center ci-justify-center ci-font-medium ci-bg-gray-700 ci-text-gray-50 dark:ci-bg-gray-300 dark:ci-text-gray-900",
3227
- children: Un(r)
3236
+ children: Wn(r)
3228
3237
  });
3229
3238
  }
3230
- function Gn({ online: e, presence: t, mobile: n }) {
3239
+ function Kn({ online: e, presence: t, mobile: n }) {
3231
3240
  return /* @__PURE__ */ d("span", { className: `ci-absolute ci-bottom-0 ci-right-0 ci-w-3 ci-h-3 ci-rounded-full ci-ring-2 ci-ring-gray-50 dark:ci-ring-gray-950 ${t === "dnd" || t === "busy" ? "ci-bg-phoneIslandClose dark:ci-bg-phoneIslandCloseDark" : e || n ? "ci-bg-phoneIslandCall dark:ci-bg-phoneIslandCallDark" : "ci-bg-gray-400 dark:ci-bg-gray-600"}` });
3232
3241
  }
3233
- function Kn({ name: e, size: t = 40, avatar: n }) {
3242
+ function qn({ name: e, size: t = 40, avatar: n }) {
3234
3243
  let r = {
3235
3244
  width: t,
3236
3245
  height: t,
@@ -3245,12 +3254,12 @@ function Kn({ name: e, size: t = 40, avatar: n }) {
3245
3254
  }) : /* @__PURE__ */ d("div", {
3246
3255
  style: r,
3247
3256
  className: "ci-rounded-full ci-shrink-0 ci-flex ci-items-center ci-justify-center ci-font-medium ci-bg-iconSecondary dark:ci-bg-iconSecondaryDark ci-text-white",
3248
- children: Un(e || "G")
3257
+ children: Wn(e || "G")
3249
3258
  });
3250
3259
  }
3251
3260
  //#endregion
3252
3261
  //#region src/components/Button.tsx
3253
- var qn = "ci-flex ci-content-center ci-items-center ci-justify-center ci-tracking-wide ci-duration-200 ci-transform ci-outline-none focus:ci-ring-2 focus:ci-z-20 focus:ci-ring-offset-2 disabled:ci-opacity-40 disabled:ci-cursor-not-allowed ci-border ci-border-transparent focus:ci-ring-offset-white dark:focus:ci-ring-offset-black ci-text-sm ci-leading-4 ci-transition-colors ci-shrink-0 ci-font-light", Jn = {
3262
+ var Jn = "ci-flex ci-content-center ci-items-center ci-justify-center ci-tracking-wide ci-duration-200 ci-transform ci-outline-none focus:ci-ring-2 focus:ci-z-20 focus:ci-ring-offset-2 disabled:ci-opacity-40 disabled:ci-cursor-not-allowed ci-border ci-border-transparent focus:ci-ring-offset-white dark:focus:ci-ring-offset-black ci-text-sm ci-leading-4 ci-transition-colors ci-shrink-0 ci-font-light", Yn = {
3254
3263
  default: "ci-bg-phoneIslandActive dark:ci-bg-phoneIslandActiveDark hover:ci-bg-gray-500 dark:hover:ci-bg-gray-50 focus:ci-ring-emerald-500 dark:focus:ci-ring-emerald-300 ci-text-primaryInvert dark:ci-text-primaryInvertDark ci-h-12 ci-w-12 ci-rounded-full",
3255
3264
  green: "ci-bg-phoneIslandCall dark:ci-bg-phoneIslandCallDark hover:ci-bg-phoneIslandCallHover dark:hover:ci-bg-phoneIslandCallHoverDark focus:ci-ring-green-500 ci-text-white dark:ci-text-gray-950 ci-h-12 ci-w-12 ci-rounded-full",
3256
3265
  red: "ci-bg-phoneIslandClose dark:ci-bg-phoneIslandCloseDark hover:ci-bg-phoneIslandCloseHover dark:hover:ci-bg-phoneIslandCloseHoverDark focus:ci-ring-emerald-500 ci-text-white dark:ci-text-gray-950 ci-h-12 ci-w-12 ci-rounded-full",
@@ -3263,7 +3272,7 @@ function Z({ variant: e, className: t = "", children: n, ...r }) {
3263
3272
  return /* @__PURE__ */ d("button", {
3264
3273
  type: "button",
3265
3274
  "aria-label": r["aria-label"] ?? r.title,
3266
- className: `${qn} ${Jn[e]} ${t}`,
3275
+ className: `${Jn} ${Yn[e]} ${t}`,
3267
3276
  ...r,
3268
3277
  children: n
3269
3278
  });
@@ -3431,12 +3440,13 @@ var Q = {
3431
3440
  };
3432
3441
  //#endregion
3433
3442
  //#region src/components/Dock.tsx
3434
- function Yn({ onDragStart: e, pushButton: t = !0 }) {
3435
- let { order: n, open: r, conversations: i, contacts: a, online: o, mobile: s, openChat: c, removeHead: l, picker: p, setPicker: m, status: h, push: g, enablePush: _, newChatButton: v } = J(w((e) => ({
3443
+ function Xn({ onDragStart: e, pushButton: t = !0 }) {
3444
+ 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 } = J(w((e) => ({
3436
3445
  order: e.order,
3437
3446
  open: e.open,
3438
3447
  conversations: e.conversations,
3439
3448
  contacts: e.contacts,
3449
+ inactive: e.inactive,
3440
3450
  online: e.online,
3441
3451
  mobile: e.mobile,
3442
3452
  openChat: e.openChat,
@@ -3458,45 +3468,45 @@ function Yn({ onDragStart: e, pushButton: t = !0 }) {
3458
3468
  className: "ci-relative ci-group",
3459
3469
  children: [/* @__PURE__ */ f("button", {
3460
3470
  type: "button",
3461
- title: t?.kind === "group" ? t.name ?? e : a[e]?.name ?? e,
3462
- onClick: () => n ? J.getState().closeChat() : c(e),
3471
+ title: t?.kind === "group" ? t.name ?? e : a[e]?.name ?? o[e] ?? e,
3472
+ onClick: () => n ? J.getState().closeChat() : l(e),
3463
3473
  className: `ci-relative ci-rounded-full ci-shadow-lg ci-transition-transform hover:ci-scale-105 ci-ring-2 ci-border-0 ci-p-0 ci-bg-transparent ${n ? "ci-ring-iconSecondary dark:ci-ring-iconSecondaryDark" : "ci-ring-gray-50 dark:ci-ring-gray-950"}`,
3464
- children: [t?.kind === "group" ? /* @__PURE__ */ d(Kn, {
3474
+ children: [t?.kind === "group" ? /* @__PURE__ */ d(qn, {
3465
3475
  name: t.name ?? e,
3466
3476
  size: 48,
3467
3477
  avatar: t.avatar
3468
- }) : /* @__PURE__ */ f(u, { children: [/* @__PURE__ */ d(Wn, {
3478
+ }) : /* @__PURE__ */ f(u, { children: [/* @__PURE__ */ d(Gn, {
3469
3479
  contact: a[e],
3470
3480
  username: e,
3471
3481
  size: 48
3472
- }), /* @__PURE__ */ d(Gn, {
3473
- online: o[e],
3482
+ }), /* @__PURE__ */ d(Kn, {
3483
+ online: s[e],
3474
3484
  presence: a[e]?.presence,
3475
- mobile: s[e]
3485
+ mobile: c[e]
3476
3486
  })] }), t?.unread > 0 && /* @__PURE__ */ d("span", {
3477
3487
  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",
3478
3488
  children: t.unread > 99 ? "99+" : t.unread
3479
3489
  })]
3480
3490
  }), /* @__PURE__ */ d("button", {
3481
3491
  type: "button",
3482
- "aria-label": `Remove ${t?.kind === "group" ? t.name ?? e : a[e]?.name ?? e} from the dock`,
3483
- onClick: () => l(e),
3492
+ "aria-label": `Remove ${t?.kind === "group" ? t.name ?? e : a[e]?.name ?? o[e] ?? e} from the dock`,
3493
+ onClick: () => p(e),
3484
3494
  className: "ci-absolute ci--top-1 ci--left-1 ci-hidden group-hover:ci-flex group-focus-within:ci-flex ci-w-5 ci-h-5 ci-rounded-full ci-border-0 ci-p-0 ci-bg-gray-700 dark:ci-bg-gray-300 ci-text-gray-50 dark:ci-text-gray-900 ci-items-center ci-justify-center",
3485
3495
  children: Q.close
3486
3496
  })]
3487
3497
  }, e);
3488
3498
  }),
3489
- v && /* @__PURE__ */ f(Z, {
3499
+ y && /* @__PURE__ */ f(Z, {
3490
3500
  variant: "default",
3491
- title: h === "online" ? "New chat" : `Chat ${h}`,
3492
- onClick: () => m(!p),
3501
+ title: g === "online" ? "New chat" : `Chat ${g}`,
3502
+ onClick: () => h(!m),
3493
3503
  className: "ci-relative ci-shadow-lg",
3494
- children: [Q.chat, h !== "online" && /* @__PURE__ */ d("span", { className: "ci-absolute ci-bottom-0 ci-right-0 ci-w-3 ci-h-3 ci-rounded-full ci-bg-phoneIslandClose dark:ci-bg-phoneIslandCloseDark ci-ring-2 ci-ring-gray-50 dark:ci-ring-gray-950" })]
3504
+ children: [Q.chat, g !== "online" && /* @__PURE__ */ d("span", { className: "ci-absolute ci-bottom-0 ci-right-0 ci-w-3 ci-h-3 ci-rounded-full ci-bg-phoneIslandClose dark:ci-bg-phoneIslandCloseDark ci-ring-2 ci-ring-gray-50 dark:ci-ring-gray-950" })]
3495
3505
  }),
3496
- t && g === "ask" && h === "online" && /* @__PURE__ */ d(Z, {
3506
+ t && _ === "ask" && g === "online" && /* @__PURE__ */ d(Z, {
3497
3507
  variant: "neutral",
3498
3508
  title: "Enable notifications when the tab is closed",
3499
- onClick: _,
3509
+ onClick: v,
3500
3510
  className: "ci-shadow-lg ci-bg-gray-50 dark:ci-bg-gray-950",
3501
3511
  children: Q.bell
3502
3512
  })
@@ -3505,7 +3515,7 @@ function Yn({ onDragStart: e, pushButton: t = !0 }) {
3505
3515
  }
3506
3516
  //#endregion
3507
3517
  //#region src/shortcodes.ts
3508
- var Xn = {
3518
+ var Zn = {
3509
3519
  "+1": "👍",
3510
3520
  thumbsup: "👍",
3511
3521
  "-1": "👎",
@@ -3699,13 +3709,13 @@ var Xn = {
3699
3709
  zzz: "💤",
3700
3710
  sweat_drops: "💦",
3701
3711
  dash: "💨"
3702
- }, Zn = /(```[\s\S]*?(?:```|$)|`[^`\n]*`?)/g, Qn = /:([a-z0-9_+-]+):/g, $n = (e) => e.replace(Qn, (e, t) => Xn[t] ?? e);
3712
+ }, Qn = /(```[\s\S]*?(?:```|$)|`[^`\n]*`?)/g, $n = /:([a-z0-9_+-]+):/g, er = (e) => e.replace($n, (e, t) => Zn[t] ?? e);
3703
3713
  function $(e) {
3704
- return e.includes(":") ? e.split(Zn).map((e, t) => t % 2 ? e : $n(e)).join("") : e;
3714
+ return e.includes(":") ? e.split(Qn).map((e, t) => t % 2 ? e : er(e)).join("") : e;
3705
3715
  }
3706
3716
  //#endregion
3707
3717
  //#region src/components/EmojiPicker.tsx
3708
- var er = [
3718
+ var tr = [
3709
3719
  {
3710
3720
  label: "Smileys",
3711
3721
  icon: "😀",
@@ -3736,7 +3746,7 @@ var er = [
3736
3746
  icon: "☕",
3737
3747
  emojis: "☕ 🍵 🥤 🍕 🍔 🍟 🌭 🥪 🌮 🍝 🍣 🍩 🍪 🍫 🍎 🍌 🍓 🥐 🚗 🚕 🚌 🚆 ✈️ 🚀 🏠 🏢 🏖️ 🌍 ☀️ 🌤️ 🌧️ ⛈️ ❄️ ⚡ 🌈 🌙"
3738
3748
  }
3739
- ], tr = [
3749
+ ], nr = [
3740
3750
  "👍",
3741
3751
  "❤️",
3742
3752
  "😂",
@@ -3744,7 +3754,7 @@ var er = [
3744
3754
  "😢",
3745
3755
  "🙏"
3746
3756
  ];
3747
- function nr({ onPick: e, onClose: t, className: n = "" }) {
3757
+ function rr({ onPick: e, onClose: t, className: n = "" }) {
3748
3758
  let [r, a] = c(0), o = s(null);
3749
3759
  return i(() => {
3750
3760
  let e = (e) => o.current && !o.current.contains(e.target) && t(), n = (e) => {
@@ -3760,7 +3770,7 @@ function nr({ onPick: e, onClose: t, className: n = "" }) {
3760
3770
  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}`,
3761
3771
  children: [/* @__PURE__ */ d("div", {
3762
3772
  className: "ci-flex ci-gap-1 ci-px-2 ci-pt-2 ci-border-b ci-border-gray-300 dark:ci-border-gray-700",
3763
- children: er.map((e, t) => /* @__PURE__ */ d("button", {
3773
+ children: tr.map((e, t) => /* @__PURE__ */ d("button", {
3764
3774
  type: "button",
3765
3775
  title: e.label,
3766
3776
  "aria-label": e.label,
@@ -3774,7 +3784,7 @@ function nr({ onPick: e, onClose: t, className: n = "" }) {
3774
3784
  }, e.label))
3775
3785
  }), /* @__PURE__ */ d("div", {
3776
3786
  className: "ci-grid ci-grid-cols-7 ci-gap-1 ci-p-2 ci-h-64 ci-overflow-y-auto",
3777
- children: er[r].emojis.split(" ").map((t) => /* @__PURE__ */ d("button", {
3787
+ children: tr[r].emojis.split(" ").map((t) => /* @__PURE__ */ d("button", {
3778
3788
  type: "button",
3779
3789
  onClick: () => e(t),
3780
3790
  style: {
@@ -3789,27 +3799,27 @@ function nr({ onPick: e, onClose: t, className: n = "" }) {
3789
3799
  }
3790
3800
  //#endregion
3791
3801
  //#region src/components/MessageList.tsx
3792
- var rr = (e) => /\.(png|jpe?g|gif|webp|avif|svg)(\?|$)/i.test(e), ir = (e) => /\.(webm|ogg|oga|opus|mp3|m4a|wav)(\?|$)/i.test(e), ar = (e) => {
3802
+ var ir = (e) => /\.(png|jpe?g|gif|webp|avif|svg)(\?|$)/i.test(e), ar = (e) => /\.(webm|ogg|oga|opus|mp3|m4a|wav)(\?|$)/i.test(e), or = (e) => {
3793
3803
  let t = e.split("/").pop() || "file";
3794
3804
  try {
3795
3805
  return decodeURIComponent(t);
3796
3806
  } catch {
3797
3807
  return t;
3798
3808
  }
3799
- }, or = (e) => {
3809
+ }, sr = (e) => {
3800
3810
  try {
3801
3811
  return new URL(e).protocol === "https:";
3802
3812
  } catch {
3803
3813
  return !1;
3804
3814
  }
3805
- }, sr = (e) => new Date(e).toLocaleTimeString([], {
3815
+ }, cr = (e) => new Date(e).toLocaleTimeString([], {
3806
3816
  hour: "2-digit",
3807
3817
  minute: "2-digit"
3808
- }), cr = (e) => new Date(e).toLocaleDateString([], {
3818
+ }), lr = (e) => new Date(e).toLocaleDateString([], {
3809
3819
  weekday: "short",
3810
3820
  day: "numeric",
3811
3821
  month: "short"
3812
- }), lr = (e, t) => new Date(e).toDateString() === new Date(t).toDateString(), ur = (e) => {
3822
+ }), ur = (e, t) => new Date(e).toDateString() === new Date(t).toDateString(), dr = (e) => {
3813
3823
  if (!e.startsWith("{\"")) return null;
3814
3824
  try {
3815
3825
  let t = JSON.parse(e);
@@ -3820,17 +3830,17 @@ var rr = (e) => /\.(png|jpe?g|gif|webp|avif|svg)(\?|$)/i.test(e), ir = (e) => /\
3820
3830
  } catch {
3821
3831
  return null;
3822
3832
  }
3823
- }, dr = n(function({ url: e }) {
3824
- return or(e) ? rr(e) ? /* @__PURE__ */ d("a", {
3833
+ }, fr = n(function({ url: e }) {
3834
+ return sr(e) ? ir(e) ? /* @__PURE__ */ d("a", {
3825
3835
  href: e,
3826
3836
  target: "_blank",
3827
3837
  rel: "noreferrer",
3828
3838
  children: /* @__PURE__ */ d("img", {
3829
3839
  src: e,
3830
- alt: ar(e),
3840
+ alt: or(e),
3831
3841
  className: "ci-max-w-full ci-max-h-60 ci-rounded-2xl ci-block"
3832
3842
  })
3833
- }) : ir(e) ? /* @__PURE__ */ d("audio", {
3843
+ }) : ar(e) ? /* @__PURE__ */ d("audio", {
3834
3844
  controls: !0,
3835
3845
  src: e,
3836
3846
  className: "ci-max-w-full"
@@ -3847,15 +3857,15 @@ var rr = (e) => /\.(png|jpe?g|gif|webp|avif|svg)(\?|$)/i.test(e), ir = (e) => /\
3847
3857
  stroke: "currentColor",
3848
3858
  strokeWidth: "2",
3849
3859
  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" })
3850
- }), ar(e)]
3860
+ }), or(e)]
3851
3861
  }) : /* @__PURE__ */ d("span", {
3852
3862
  className: "ci-break-all",
3853
3863
  children: e
3854
3864
  });
3855
- }), fr = /(`[^`\n]+`)|(\*\*[^*\n]+\*\*|__[^_\n]+__)|(~~[^~\n]+~~)|(\*[^*\s][^*\n]*\*|_[^_\s][^_\n]*_)|\[([^\]\n]+)\]\((https?:\/\/[^\s)]+)\)|(https?:\/\/[^\s<]+)/g;
3856
- function pr({ text: e }) {
3865
+ }), pr = /(`[^`\n]+`)|(\*\*[^*\n]+\*\*|__[^_\n]+__)|(~~[^~\n]+~~)|(\*[^*\s][^*\n]*\*|_[^_\s][^_\n]*_)|\[([^\]\n]+)\]\((https?:\/\/[^\s)]+)\)|(https?:\/\/[^\s<]+)/g;
3866
+ function mr({ text: e }) {
3857
3867
  let t = [], n = 0;
3858
- for (let r of e.matchAll(fr)) {
3868
+ for (let r of e.matchAll(pr)) {
3859
3869
  let i = r[0], a = r.index ?? 0;
3860
3870
  a > n && t.push($(e.slice(n, a))), r[1] ? t.push(/* @__PURE__ */ d("code", {
3861
3871
  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]",
@@ -3876,17 +3886,17 @@ function pr({ text: e }) {
3876
3886
  }
3877
3887
  return n < e.length && t.push($(e.slice(n))), /* @__PURE__ */ d(u, { children: t });
3878
3888
  }
3879
- var mr = n(function({ text: e }) {
3889
+ var hr = n(function({ text: e }) {
3880
3890
  let t = e.split(/```[^\n]*\n?([\s\S]*?)```/g);
3881
3891
  return /* @__PURE__ */ d("span", {
3882
3892
  className: "ci-whitespace-pre-wrap ci-break-words",
3883
3893
  children: t.map((e, t) => t % 2 ? /* @__PURE__ */ d("pre", {
3884
3894
  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",
3885
3895
  children: e.replace(/\n$/, "")
3886
- }, t) : /* @__PURE__ */ d(pr, { text: e.replace(/^(\s*)[-*] (?=\S)/gm, "$1• ") }, t))
3896
+ }, t) : /* @__PURE__ */ d(mr, { text: e.replace(/^(\s*)[-*] (?=\S)/gm, "$1• ") }, t))
3887
3897
  });
3888
3898
  });
3889
- function hr({ text: e, count: t }) {
3899
+ function gr({ text: e, count: t }) {
3890
3900
  return /* @__PURE__ */ f("span", {
3891
3901
  className: "ci-italic ci-opacity-80",
3892
3902
  children: [
@@ -3899,7 +3909,7 @@ function hr({ text: e, count: t }) {
3899
3909
  ]
3900
3910
  });
3901
3911
  }
3902
- function gr({ forMsg: e, me: t, onReact: n, nameOf: r, mine: i }) {
3912
+ function _r({ forMsg: e, me: t, onReact: n, nameOf: r, mine: i }) {
3903
3913
  if (!e) return null;
3904
3914
  let a = /* @__PURE__ */ new Map();
3905
3915
  for (let [t, n] of Object.entries(e)) for (let e of n) a.set(e, [...a.get(e) ?? [], t]);
@@ -3924,7 +3934,7 @@ function gr({ forMsg: e, me: t, onReact: n, nameOf: r, mine: i }) {
3924
3934
  })
3925
3935
  }) : null;
3926
3936
  }
3927
- function _r({ reply: e, messages: t, mine: n, name: r }) {
3937
+ function vr({ reply: e, messages: t, mine: n, name: r }) {
3928
3938
  let i = t.find((t) => t.oid === e.id), a = i ? i.oob ? "Attachment" : i.body : e.quote?.replace(/^[^:]*: /, "") ?? "", o = (t) => {
3929
3939
  t.stopPropagation();
3930
3940
  let n = document.querySelector(`.chat-island-root [data-oid="${CSS.escape(e.id)}"]`);
@@ -3948,7 +3958,7 @@ function _r({ reply: e, messages: t, mine: n, name: r }) {
3948
3958
  })]
3949
3959
  });
3950
3960
  }
3951
- function vr({ messages: e, typing: t, onLoadOlder: n, hasOlder: r, group: a, reactions: o, me: l = "", onReact: u, onReply: p }) {
3961
+ function yr({ messages: e, typing: t, onLoadOlder: n, hasOlder: r, group: a, reactions: o, me: l = "", onReact: u, onReply: p }) {
3952
3962
  let m = J((e) => e.contacts), h = s(null), g = s(!0), [_, v] = c(null), [y, b] = c(null), x = (e) => m[e]?.name ?? e;
3953
3963
  i(() => {
3954
3964
  let e = h.current;
@@ -3982,7 +3992,7 @@ function vr({ messages: e, typing: t, onLoadOlder: n, hasOlder: r, group: a, rea
3982
3992
  children: "Scroll up for older messages"
3983
3993
  }),
3984
3994
  e.map((t, n) => {
3985
- let r = e[n - 1], i = !r || !lr(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", {
3995
+ let r = e[n - 1], i = !r || !ur(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", {
3986
3996
  type: "button",
3987
3997
  title: "React",
3988
3998
  "aria-label": "React to this message",
@@ -4005,14 +4015,14 @@ function vr({ messages: e, typing: t, onLoadOlder: n, hasOlder: r, group: a, rea
4005
4015
  "data-oid": t.oid,
4006
4016
  children: [i && /* @__PURE__ */ d("div", {
4007
4017
  className: "ci-text-center ci-text-xs ci-text-gray-500 dark:ci-text-gray-400 ci-py-2",
4008
- children: cr(t.ts)
4018
+ children: lr(t.ts)
4009
4019
  }), /* @__PURE__ */ f("div", {
4010
4020
  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"}`,
4011
4021
  children: [
4012
4022
  c && /* @__PURE__ */ d("span", {
4013
4023
  className: "ci-w-7 ci-shrink-0",
4014
4024
  title: c,
4015
- children: !s && /* @__PURE__ */ d(Wn, {
4025
+ children: !s && /* @__PURE__ */ d(Gn, {
4016
4026
  contact: m[t.nick],
4017
4027
  username: t.nick,
4018
4028
  size: 28
@@ -4027,7 +4037,7 @@ function vr({ messages: e, typing: t, onLoadOlder: n, hasOlder: r, group: a, rea
4027
4037
  role: "menu",
4028
4038
  onClick: (e) => e.stopPropagation(),
4029
4039
  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"}`,
4030
- children: [tr.map((e) => /* @__PURE__ */ d("button", {
4040
+ children: [nr.map((e) => /* @__PURE__ */ d("button", {
4031
4041
  type: "button",
4032
4042
  role: "menuitem",
4033
4043
  "aria-label": e,
@@ -4051,28 +4061,28 @@ function vr({ messages: e, typing: t, onLoadOlder: n, hasOlder: r, group: a, rea
4051
4061
  })]
4052
4062
  }),
4053
4063
  /* @__PURE__ */ f("div", {
4054
- title: sr(t.ts),
4055
- onDoubleClick: () => g && C(h, tr[0]),
4064
+ title: cr(t.ts),
4065
+ onDoubleClick: () => g && C(h, nr[0]),
4056
4066
  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" : ""}`,
4057
4067
  children: [
4058
- t.reply && /* @__PURE__ */ d(_r, {
4068
+ t.reply && /* @__PURE__ */ d(vr, {
4059
4069
  reply: t.reply,
4060
4070
  messages: e,
4061
4071
  mine: t.mine,
4062
4072
  name: (e) => e === l ? "You" : x(e)
4063
4073
  }),
4064
- t.oob ? /* @__PURE__ */ d(dr, { url: t.oob }) : ur(t.body) ? /* @__PURE__ */ d(hr, { ...ur(t.body) }) : /* @__PURE__ */ d(mr, { text: t.body }),
4065
- t.oob && t.body && t.body !== t.oob && t.body !== ar(t.oob) && /* @__PURE__ */ d("div", {
4074
+ t.oob ? /* @__PURE__ */ d(fr, { url: t.oob }) : dr(t.body) ? /* @__PURE__ */ d(gr, { ...dr(t.body) }) : /* @__PURE__ */ d(hr, { text: t.body }),
4075
+ t.oob && t.body && t.body !== t.oob && t.body !== or(t.oob) && /* @__PURE__ */ d("div", {
4066
4076
  className: "ci-text-xs ci-opacity-80 ci-mt-1",
4067
4077
  children: t.body
4068
4078
  }),
4069
4079
  /* @__PURE__ */ d("span", {
4070
4080
  className: "ci-block ci-text-right ci-text-[10px] ci-leading-none ci-opacity-60 ci-mt-1",
4071
- children: sr(t.ts)
4081
+ children: cr(t.ts)
4072
4082
  })
4073
4083
  ]
4074
4084
  }),
4075
- h && /* @__PURE__ */ d(gr, {
4085
+ h && /* @__PURE__ */ d(_r, {
4076
4086
  forMsg: o?.[h],
4077
4087
  me: l,
4078
4088
  mine: t.mine,
@@ -4095,7 +4105,7 @@ function vr({ messages: e, typing: t, onLoadOlder: n, hasOlder: r, group: a, rea
4095
4105
  })
4096
4106
  })
4097
4107
  ]
4098
- }), y && /* @__PURE__ */ d(nr, {
4108
+ }), y && /* @__PURE__ */ d(rr, {
4099
4109
  className: "ci-absolute ci-bottom-2 ci-left-1/2 ci--translate-x-1/2",
4100
4110
  onPick: (e) => C(y, e),
4101
4111
  onClose: () => b(null)
@@ -4104,7 +4114,7 @@ function vr({ messages: e, typing: t, onLoadOlder: n, hasOlder: r, group: a, rea
4104
4114
  }
4105
4115
  //#endregion
4106
4116
  //#region src/ogg.ts
4107
- function yr(e, t, n) {
4117
+ function br(e, t, n) {
4108
4118
  let r = e[t];
4109
4119
  if (r === void 0) return null;
4110
4120
  let i = 1;
@@ -4118,7 +4128,7 @@ function yr(e, t, n) {
4118
4128
  unknown: !n && o
4119
4129
  };
4120
4130
  }
4121
- var br = /* @__PURE__ */ new Set([
4131
+ var xr = /* @__PURE__ */ new Set([
4122
4132
  408125543,
4123
4133
  524531317,
4124
4134
  374648427,
@@ -4126,18 +4136,18 @@ var br = /* @__PURE__ */ new Set([
4126
4136
  225,
4127
4137
  160
4128
4138
  ]);
4129
- function xr(e) {
4139
+ function Sr(e) {
4130
4140
  let t = {
4131
4141
  channels: 1,
4132
4142
  packets: []
4133
4143
  }, n = 0;
4134
4144
  for (; n < e.length;) {
4135
- let r = yr(e, n, !0);
4145
+ let r = br(e, n, !0);
4136
4146
  if (!r) break;
4137
- let i = yr(e, n + r.len, !1);
4147
+ let i = br(e, n + r.len, !1);
4138
4148
  if (!i) break;
4139
4149
  let a = n + r.len + i.len;
4140
- if (br.has(r.value)) {
4150
+ if (xr.has(r.value)) {
4141
4151
  n = a;
4142
4152
  continue;
4143
4153
  }
@@ -4146,14 +4156,14 @@ function xr(e) {
4146
4156
  if (r.value === 25506) t.head = e.slice(a, o);
4147
4157
  else if (r.value === 159) t.channels = e[a] || 1;
4148
4158
  else if (r.value === 163 || r.value === 161) {
4149
- let n = yr(e, a, !1);
4159
+ let n = br(e, a, !1);
4150
4160
  n && (e[a + n.len + 2] >> 1 & 3 || t.packets.push(e.slice(a + n.len + 3, o)));
4151
4161
  }
4152
4162
  n = o;
4153
4163
  }
4154
4164
  return t;
4155
4165
  }
4156
- function Sr(e) {
4166
+ function Cr(e) {
4157
4167
  if (!e.length) return 0;
4158
4168
  let t = e[0], n = t >> 3, r;
4159
4169
  r = n < 12 ? [
@@ -4170,7 +4180,7 @@ function Sr(e) {
4170
4180
  let i = t & 3, a = i === 0 ? 1 : i === 3 ? (e[1] ?? 0) & 63 : 2;
4171
4181
  return Math.round(a * r * 48);
4172
4182
  }
4173
- var Cr = (() => {
4183
+ var wr = (() => {
4174
4184
  let e = /* @__PURE__ */ new Uint32Array(256);
4175
4185
  for (let t = 0; t < 256; t++) {
4176
4186
  let n = t << 24;
@@ -4179,12 +4189,12 @@ var Cr = (() => {
4179
4189
  }
4180
4190
  return e;
4181
4191
  })();
4182
- function wr(e) {
4192
+ function Tr(e) {
4183
4193
  let t = 0;
4184
- for (let n = 0; n < e.length; n++) t = (t << 8 ^ Cr[(t >>> 24 ^ e[n]) & 255]) >>> 0;
4194
+ for (let n = 0; n < e.length; n++) t = (t << 8 ^ wr[(t >>> 24 ^ e[n]) & 255]) >>> 0;
4185
4195
  return t;
4186
4196
  }
4187
- function Tr(e, t, n, r, i) {
4197
+ function Er(e, t, n, r, i) {
4188
4198
  let a = [];
4189
4199
  for (let t of e) {
4190
4200
  let e = t.length;
@@ -4200,29 +4210,29 @@ function Tr(e, t, n, r, i) {
4200
4210
  ], 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);
4201
4211
  let l = 27 + a.length;
4202
4212
  for (let t of e) s.set(t, l), l += t.length;
4203
- return c.setUint32(22, wr(s), !0), s;
4213
+ return c.setUint32(22, Tr(s), !0), s;
4204
4214
  }
4205
- function Er(e) {
4215
+ function Dr(e) {
4206
4216
  let t = /* @__PURE__ */ new Uint8Array(19), n = new DataView(t.buffer);
4207
4217
  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;
4208
4218
  }
4209
- function Dr() {
4219
+ function Or() {
4210
4220
  let e = new TextEncoder().encode("chat-island"), t = new Uint8Array(12 + e.length + 4);
4211
4221
  return t.set(new TextEncoder().encode("OpusTags"), 0), new DataView(t.buffer).setUint32(8, e.length, !0), t.set(e, 12), t;
4212
4222
  }
4213
- function Or(e) {
4214
- let { head: t, channels: n, packets: r } = xr(e);
4223
+ function kr(e) {
4224
+ let { head: t, channels: n, packets: r } = Sr(e);
4215
4225
  if (!r.length) return null;
4216
- let i = t && t.length >= 19 && new TextDecoder().decode(t.slice(0, 8)) === "OpusHead", a = Math.random() * 4294967295 >>> 0, o = [Tr([i ? t : Er(n)], 0, a, 0, 2), Tr([Dr()], 0, a, 1, 0)], s = 0, c = 2;
4226
+ let i = t && t.length >= 19 && new TextDecoder().decode(t.slice(0, 8)) === "OpusHead", a = Math.random() * 4294967295 >>> 0, o = [Er([i ? t : Dr(n)], 0, a, 0, 2), Er([Or()], 0, a, 1, 0)], s = 0, c = 2;
4217
4227
  for (let e = 0; e < r.length;) {
4218
4228
  let t = [], n = 0;
4219
4229
  for (; e < r.length && t.length < 50;) {
4220
4230
  let i = Math.floor(r[e].length / 255) + 1;
4221
4231
  if (n + i > 255) break;
4222
- t.push(r[e]), n += i, s += Sr(r[e]), e++;
4232
+ t.push(r[e]), n += i, s += Cr(r[e]), e++;
4223
4233
  }
4224
4234
  if (!t.length) return null;
4225
- o.push(Tr(t, s, a, c++, e >= r.length ? 4 : 0));
4235
+ o.push(Er(t, s, a, c++, e >= r.length ? 4 : 0));
4226
4236
  }
4227
4237
  let l = o.reduce((e, t) => e + t.length, 0), u = new Uint8Array(l), d = 0;
4228
4238
  for (let e of o) u.set(e, d), d += e.length;
@@ -4230,100 +4240,100 @@ function Or(e) {
4230
4240
  }
4231
4241
  //#endregion
4232
4242
  //#region src/components/Composer.tsx
4233
- var kr = [
4243
+ var Ar = [
4234
4244
  "audio/ogg;codecs=opus",
4235
4245
  "audio/webm;codecs=opus",
4236
4246
  "audio/mp4",
4237
4247
  "audio/webm"
4238
4248
  ];
4239
- async function Ar(e, t) {
4249
+ async function jr(e, t) {
4240
4250
  let n = Date.now();
4241
4251
  if (/webm/.test(t) && /opus/.test(t)) try {
4242
- let t = Or(new Uint8Array(await new Blob(e).arrayBuffer()));
4252
+ let t = kr(new Uint8Array(await new Blob(e).arrayBuffer()));
4243
4253
  if (t) return new File([t], `voice-${n}.ogg`, { type: "audio/ogg" });
4244
4254
  } catch {}
4245
- return new File(e, `voice-${n}.${jr(t)}`, { type: t.split(";")[0] });
4246
- }
4247
- var jr = (e) => /mp4/.test(e) ? "m4a" : /ogg/.test(e) ? "ogg" : "webm", Mr = (e) => `${Math.floor(e / 6e4)}:${String(Math.floor(e % 6e4 / 1e3)).padStart(2, "0")}`;
4248
- function Nr({ onSend: e, onTyping: t, onFile: n, disabled: r, focusKey: o }) {
4249
- let [l, u] = c(""), [p, m] = c(!1), h = s(null), g = s(null), _ = s(null), v = s(), y = s(!1), [b, x] = c(null), [S, C] = c(0), w = s(!1), T = s(!1), ee = s(!1), E = s({});
4250
- i(() => _.current?.focus(), []), i(() => () => {
4251
- ee.current = !0, w.current = !0, window.clearTimeout(v.current);
4252
- let { r: e, stream: t } = E.current;
4253
- e && e.state !== "inactive" && e.stop(), t?.getTracks().forEach((e) => e.stop()), E.current = {};
4255
+ return new File(e, `voice-${n}.${Mr(t)}`, { type: t.split(";")[0] });
4256
+ }
4257
+ var Mr = (e) => /mp4/.test(e) ? "m4a" : /ogg/.test(e) ? "ogg" : "webm", Nr = (e) => `${Math.floor(e / 6e4)}:${String(Math.floor(e % 6e4 / 1e3)).padStart(2, "0")}`;
4258
+ function Pr({ onSend: e, onTyping: t, onFile: n, disabled: r, disabledText: o, focusKey: l }) {
4259
+ 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({});
4260
+ i(() => v.current?.focus(), []), i(() => () => {
4261
+ D.current = !0, T.current = !0, window.clearTimeout(y.current);
4262
+ let { r: e, stream: t } = O.current;
4263
+ e && e.state !== "inactive" && e.stop(), t?.getTracks().forEach((e) => e.stop()), O.current = {};
4254
4264
  }, []), i(() => {
4255
- if (!b) return;
4256
- let e = window.setInterval(() => C(Date.now() - b.since), 250);
4265
+ if (!x) return;
4266
+ let e = window.setInterval(() => w(Date.now() - x.since), 250);
4257
4267
  return () => window.clearInterval(e);
4258
- }, [b]), i(() => {
4259
- o && _.current?.focus();
4260
- }, [o]);
4261
- let D = (e) => {
4262
- y.current !== e && (y.current = e, t(e));
4263
- }, O = (e) => {
4268
+ }, [x]), i(() => {
4269
+ l && v.current?.focus();
4270
+ }, [l]);
4271
+ let k = (e) => {
4272
+ b.current !== e && (b.current = e, t(e));
4273
+ }, A = (e) => {
4264
4274
  let t = e.includes(":") ? $(e) : e;
4265
- t !== e && (h.current = Math.max(0, (_.current?.selectionStart ?? e.length) - (e.length - t.length))), u(t), t ? (D(!0), window.clearTimeout(v.current), v.current = window.setTimeout(() => D(!1), 4e3)) : D(!1);
4275
+ 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);
4266
4276
  };
4267
4277
  a(() => {
4268
- h.current !== null && (_.current?.setSelectionRange(h.current, h.current), h.current = null);
4269
- }, [l]);
4270
- let k = (e) => {
4271
- let t = _.current, n = t?.selectionStart ?? l.length, r = t?.selectionEnd ?? n;
4272
- O(l.slice(0, n) + e + l.slice(r)), requestAnimationFrame(() => {
4278
+ g.current !== null && (v.current?.setSelectionRange(g.current, g.current), g.current = null);
4279
+ }, [u]);
4280
+ let ee = (e) => {
4281
+ let t = v.current, n = t?.selectionStart ?? u.length, r = t?.selectionEnd ?? n;
4282
+ A(u.slice(0, n) + e + u.slice(r)), requestAnimationFrame(() => {
4273
4283
  t?.focus(), t?.setSelectionRange(n + e.length, n + e.length);
4274
4284
  });
4275
- }, te = () => {
4276
- let t = l.trim();
4277
- t && (u(""), Promise.resolve(e(t)).catch(() => u((e) => e || t)), window.clearTimeout(v.current), y.current = !1);
4278
- }, A = async () => {
4279
- if (T.current || b) return;
4280
- T.current = !0;
4285
+ }, j = () => {
4286
+ let t = u.trim();
4287
+ t && (p(""), Promise.resolve(e(t)).catch(() => p((e) => e || t)), window.clearTimeout(y.current), b.current = !1);
4288
+ }, M = async () => {
4289
+ if (E.current || x) return;
4290
+ E.current = !0;
4281
4291
  let e;
4282
4292
  try {
4283
4293
  e = await navigator.mediaDevices.getUserMedia({ audio: !0 });
4284
4294
  let t = e;
4285
- if (ee.current) {
4295
+ if (D.current) {
4286
4296
  t.getTracks().forEach((e) => e.stop());
4287
4297
  return;
4288
4298
  }
4289
- let r = kr.find((e) => MediaRecorder.isTypeSupported(e)), i = new MediaRecorder(e, r ? { mimeType: r } : void 0), a = [];
4299
+ let r = Ar.find((e) => MediaRecorder.isTypeSupported(e)), i = new MediaRecorder(e, r ? { mimeType: r } : void 0), a = [];
4290
4300
  i.ondataavailable = (e) => e.data.size && a.push(e.data), i.onstop = () => {
4291
- t.getTracks().forEach((e) => e.stop()), E.current = {}, x(null), !w.current && a.length && Ar(a, i.mimeType || r || "").then(n);
4292
- }, w.current = !1, i.start(), E.current = {
4301
+ t.getTracks().forEach((e) => e.stop()), O.current = {}, S(null), !T.current && a.length && jr(a, i.mimeType || r || "").then(n);
4302
+ }, T.current = !1, i.start(), O.current = {
4293
4303
  r: i,
4294
4304
  stream: t
4295
- }, C(0), x({
4305
+ }, w(0), S({
4296
4306
  r: i,
4297
4307
  since: Date.now()
4298
4308
  });
4299
4309
  } catch {
4300
4310
  e?.getTracks().forEach((e) => e.stop());
4301
4311
  } finally {
4302
- T.current = !1;
4312
+ E.current = !1;
4303
4313
  }
4304
- }, j = (e) => {
4305
- w.current = e, b?.r.stop();
4314
+ }, N = (e) => {
4315
+ T.current = e, x?.r.stop();
4306
4316
  };
4307
- return b ? /* @__PURE__ */ f("div", {
4317
+ return x ? /* @__PURE__ */ f("div", {
4308
4318
  className: "ci-flex ci-items-center ci-gap-2 ci-px-3 ci-py-3",
4309
4319
  children: [
4310
4320
  /* @__PURE__ */ d(Z, {
4311
4321
  variant: "transparent",
4312
4322
  title: "Discard",
4313
4323
  "aria-label": "Discard",
4314
- onClick: () => j(!0),
4324
+ onClick: () => N(!0),
4315
4325
  className: "ci-h-10 ci-w-10",
4316
4326
  children: Q.close
4317
4327
  }),
4318
4328
  /* @__PURE__ */ f("div", {
4319
4329
  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",
4320
- 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 ", Mr(S)] })]
4330
+ 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 ", Nr(C)] })]
4321
4331
  }),
4322
4332
  /* @__PURE__ */ d(Z, {
4323
4333
  variant: "green",
4324
4334
  title: "Send voice note",
4325
4335
  "aria-label": "Send voice note",
4326
- onClick: () => j(!1),
4336
+ onClick: () => N(!1),
4327
4337
  className: "ci-h-10 ci-w-10",
4328
4338
  children: Q.send
4329
4339
  })
@@ -4331,13 +4341,13 @@ function Nr({ onSend: e, onTyping: t, onFile: n, disabled: r, focusKey: o }) {
4331
4341
  }) : /* @__PURE__ */ f("div", {
4332
4342
  className: "ci-relative ci-flex ci-items-center ci-gap-2 ci-px-3 ci-py-3",
4333
4343
  children: [
4334
- p && /* @__PURE__ */ d(nr, {
4344
+ m && /* @__PURE__ */ d(rr, {
4335
4345
  className: "ci-absolute ci-bottom-full ci-left-3 ci-mb-1",
4336
- onPick: k,
4337
- onClose: () => m(!1)
4346
+ onPick: ee,
4347
+ onClose: () => h(!1)
4338
4348
  }),
4339
4349
  /* @__PURE__ */ d("input", {
4340
- ref: g,
4350
+ ref: _,
4341
4351
  type: "file",
4342
4352
  hidden: !0,
4343
4353
  onChange: (e) => e.target.files?.[0] && (n(e.target.files[0]), e.target.value = "")
@@ -4346,7 +4356,7 @@ function Nr({ onSend: e, onTyping: t, onFile: n, disabled: r, focusKey: o }) {
4346
4356
  variant: "transparent",
4347
4357
  disabled: r,
4348
4358
  title: "Attach a file",
4349
- onClick: () => g.current?.click(),
4359
+ onClick: () => _.current?.click(),
4350
4360
  className: "ci-h-10 ci-w-10",
4351
4361
  children: Q.clip
4352
4362
  }),
@@ -4357,36 +4367,36 @@ function Nr({ onSend: e, onTyping: t, onFile: n, disabled: r, focusKey: o }) {
4357
4367
  disabled: r,
4358
4368
  title: "Emoji",
4359
4369
  "aria-label": "Emoji",
4360
- "aria-expanded": p,
4361
- onClick: () => m((e) => !e),
4370
+ "aria-expanded": m,
4371
+ onClick: () => h((e) => !e),
4362
4372
  className: "ci-absolute ci-left-2 ci-bottom-1 ci-z-10 ci-h-8 ci-w-8 ci-flex ci-items-center ci-justify-center ci-rounded-full ci-border-0 ci-bg-transparent ci-text-secondaryNeutral dark:ci-text-secondaryNeutralDark hover:ci-bg-gray-300/70 dark:hover:ci-bg-gray-700/30 disabled:ci-opacity-40",
4363
4373
  children: Q.smile
4364
4374
  }), /* @__PURE__ */ d("textarea", {
4365
- ref: _,
4366
- value: l,
4375
+ ref: v,
4376
+ value: u,
4367
4377
  disabled: r,
4368
4378
  rows: 1,
4369
- placeholder: r ? "Connecting…" : "Write a message",
4370
- onChange: (e) => O(e.target.value),
4379
+ placeholder: r ? o ?? "Connecting…" : "Write a message",
4380
+ onChange: (e) => A(e.target.value),
4371
4381
  onKeyDown: (e) => {
4372
- let t = (l.match(/```/g) ?? []).length % 2 == 1;
4373
- e.key === "Enter" && !e.shiftKey && !t && (e.preventDefault(), te());
4382
+ let t = (u.match(/```/g) ?? []).length % 2 == 1;
4383
+ e.key === "Enter" && !e.shiftKey && !t && (e.preventDefault(), j());
4374
4384
  },
4375
4385
  className: "ci-block ci-w-full ci-resize-none ci-max-h-32 ci-pl-11 ci-pr-4 ci-py-2.5 ci-rounded-3xl ci-border-0 ci-bg-elevationL2 dark:ci-bg-elevationL2Dark ci-text-gray-900 dark:ci-text-white placeholder:ci-text-gray-500 dark:placeholder:ci-text-gray-400 ci-outline-none focus:ci-ring-2 focus:ci-ring-gray-400 dark:focus:ci-ring-gray-500 ci-text-sm",
4376
- style: { height: Math.min(128, 40 + 20 * (l.split("\n").length - 1)) }
4386
+ style: { height: Math.min(128, 40 + 20 * (u.split("\n").length - 1)) }
4377
4387
  })]
4378
4388
  }),
4379
- l.trim() ? /* @__PURE__ */ d(Z, {
4389
+ u.trim() ? /* @__PURE__ */ d(Z, {
4380
4390
  variant: "default",
4381
4391
  disabled: r,
4382
- onClick: te,
4392
+ onClick: j,
4383
4393
  title: "Send",
4384
4394
  className: "ci-h-10 ci-w-10",
4385
4395
  children: Q.send
4386
4396
  }) : /* @__PURE__ */ d(Z, {
4387
4397
  variant: "default",
4388
4398
  disabled: r || typeof MediaRecorder > "u",
4389
- onClick: A,
4399
+ onClick: M,
4390
4400
  title: "Record a voice note",
4391
4401
  "aria-label": "Record a voice note",
4392
4402
  className: "ci-h-10 ci-w-10",
@@ -4397,72 +4407,75 @@ function Nr({ onSend: e, onTyping: t, onFile: n, disabled: r, focusKey: o }) {
4397
4407
  }
4398
4408
  //#endregion
4399
4409
  //#region src/components/ChatWindow.tsx
4400
- var Pr = (e) => !!e && ![
4410
+ var Fr = (e) => !!e && ![
4401
4411
  "offline",
4402
4412
  "dnd",
4403
4413
  "busy",
4404
4414
  "ringing",
4405
4415
  "onhold"
4406
4416
  ].includes(e);
4407
- function Fr({ peer: e, actions: t, onDragStart: n }) {
4408
- let { c: r, contacts: a, online: o, mobile: s, status: l, closeChat: p, openChat: m, markRead: h, order: g, me: _ } = J(w((t) => ({
4417
+ function Ir({ peer: e, actions: t, onDragStart: n }) {
4418
+ let { c: r, contacts: a, online: o, mobile: s, inactive: l, status: p, closeChat: m, openChat: h, markRead: g, order: _, me: v } = J(w((t) => ({
4409
4419
  c: t.conversations[e],
4410
4420
  contacts: t.contacts,
4411
4421
  online: t.online,
4412
4422
  mobile: t.mobile,
4423
+ inactive: t.inactive,
4413
4424
  status: t.status,
4414
4425
  closeChat: t.closeChat,
4415
4426
  openChat: t.openChat,
4416
4427
  markRead: t.markRead,
4417
4428
  order: t.order,
4418
4429
  me: t.me
4419
- }))), v = Math.max(0, g.indexOf(e)), y = a[e], [b, x] = c(!1), [S, C] = c(null), [T, ee] = c(0), E = (e) => e === _ ? "You" : a[e]?.name ?? e, D = [...r?.members ?? []].sort((e, t) => Number(e === _) - Number(t === _));
4430
+ }))), y = Math.max(0, _.indexOf(e)), b = a[e], [x, S] = c(!1), [C, T] = c(null), [E, D] = c(0), O = (e) => e === v ? "You" : a[e]?.name ?? e, k = [...r?.members ?? []].sort((e, t) => Number(e === v) - Number(t === v));
4420
4431
  i(() => {
4421
4432
  r && !r.loaded && t.loadOlder(e);
4422
4433
  }, [e, r?.loaded]), i(() => {
4423
- h(e);
4434
+ g(e);
4424
4435
  }, [e, r?.messages.length]), i(() => {
4425
- x(!1), C(null);
4436
+ S(!1), T(null);
4426
4437
  }, [e]);
4427
- let O = (t) => {
4438
+ let A = (t) => {
4428
4439
  if (!t.oid) return;
4429
- let n = r?.kind === "group" ? t.nick ?? "" : t.mine ? _ : e, i = t.oob ? "Attachment" : t.body.replace(/```/g, "").replace(/\s+/g, " ").trim().slice(0, 100), o = n === _ ? J.getState().myName || _ : a[n]?.name ?? n;
4430
- C({
4440
+ let n = r?.kind === "group" ? t.nick ?? "" : t.mine ? v : e, i = t.oob ? "Attachment" : t.body.replace(/```/g, "").replace(/\s+/g, " ").trim().slice(0, 100), o = n === v ? J.getState().myName || v : a[n]?.name ?? n;
4441
+ T({
4431
4442
  id: t.oid,
4432
4443
  author: n,
4433
4444
  quote: `${o}: ${i}`
4434
- }), ee((e) => e + 1);
4445
+ }), D((e) => e + 1);
4446
+ }, ee = (e) => {
4447
+ e.key === "Escape" && (e.stopPropagation(), C ? T(null) : x ? S(!1) : m());
4435
4448
  };
4436
- return r ? /* @__PURE__ */ f("div", {
4449
+ if (!r) return null;
4450
+ let j = r.kind !== "group" && !!l[e];
4451
+ return /* @__PURE__ */ f("div", {
4437
4452
  role: "dialog",
4438
- "aria-label": r.kind === "group" ? r.name ?? e : y?.name ?? e,
4439
- onKeyDown: (e) => {
4440
- e.key === "Escape" && (e.stopPropagation(), S ? C(null) : b ? x(!1) : p());
4441
- },
4453
+ "aria-label": r.kind === "group" ? r.name ?? e : b?.name ?? l[e] ?? e,
4454
+ onKeyDown: ee,
4442
4455
  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",
4443
4456
  children: [
4444
4457
  /* @__PURE__ */ d("span", {
4445
4458
  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",
4446
- style: { bottom: `calc(1.875rem + ${v} * 3.75rem)` },
4459
+ style: { bottom: `calc(1.875rem + ${y} * 3.75rem)` },
4447
4460
  "aria-hidden": "true"
4448
4461
  }),
4449
4462
  /* @__PURE__ */ f("div", {
4450
4463
  className: `ci-flex ci-items-center ci-gap-3 ci-px-4 ci-py-3 ci-rounded-t-3xl ${n ? "ci-cursor-grab active:ci-cursor-grabbing ci-touch-none" : ""}`,
4451
4464
  onPointerDown: n,
4452
4465
  children: [
4453
- r.kind === "group" ? /* @__PURE__ */ d(Kn, {
4466
+ r.kind === "group" ? /* @__PURE__ */ d(qn, {
4454
4467
  name: r.name ?? e,
4455
4468
  size: 36,
4456
4469
  avatar: r.avatar
4457
4470
  }) : /* @__PURE__ */ f("span", {
4458
4471
  className: "ci-relative",
4459
- children: [/* @__PURE__ */ d(Wn, {
4460
- contact: y,
4472
+ children: [/* @__PURE__ */ d(Gn, {
4473
+ contact: b,
4461
4474
  username: e,
4462
4475
  size: 36
4463
- }), /* @__PURE__ */ d(Gn, {
4476
+ }), /* @__PURE__ */ d(Kn, {
4464
4477
  online: o[e],
4465
- presence: y?.presence,
4478
+ presence: b?.presence,
4466
4479
  mobile: s[e]
4467
4480
  })]
4468
4481
  }),
@@ -4471,31 +4484,31 @@ function Fr({ peer: e, actions: t, onDragStart: n }) {
4471
4484
  ...r.kind === "group" ? {
4472
4485
  role: "button",
4473
4486
  tabIndex: 0,
4474
- "aria-expanded": b,
4475
- onKeyDown: (e) => (e.key === "Enter" || e.key === " ") && (e.preventDefault(), x((e) => !e))
4487
+ "aria-expanded": x,
4488
+ onKeyDown: (e) => (e.key === "Enter" || e.key === " ") && (e.preventDefault(), S((e) => !e))
4476
4489
  } : {},
4477
- onClick: () => r.kind === "group" && x((e) => !e),
4490
+ onClick: () => r.kind === "group" && S((e) => !e),
4478
4491
  children: [/* @__PURE__ */ d("div", {
4479
4492
  className: "ci-font-medium ci-truncate ci-text-sm",
4480
- children: r.kind === "group" ? r.name ?? e : y?.name ?? e
4493
+ children: r.kind === "group" ? r.name ?? e : b?.name ?? l[e] ?? e
4481
4494
  }), /* @__PURE__ */ d("div", {
4482
4495
  className: "ci-text-xs ci-text-gray-500 dark:ci-text-gray-400 ci-truncate",
4483
- children: l === "online" ? r.kind === "group" ? D.map(E).join(", ") : r.typing ? "typing…" : o[e] ? "online" : s[e] ? "Mobile" : "offline" : l
4496
+ children: j ? "No longer active" : p === "online" ? r.kind === "group" ? k.map(O).join(", ") : r.typing ? "typing…" : o[e] ? "online" : s[e] ? "Mobile" : "offline" : p
4484
4497
  })]
4485
4498
  }),
4486
- r.kind !== "group" && y?.number && Pr(y.presence) && /* @__PURE__ */ d(Z, {
4499
+ !j && r.kind !== "group" && b?.number && Fr(b.presence) && /* @__PURE__ */ d(Z, {
4487
4500
  variant: "call",
4488
- title: `Call ${y.number}`,
4501
+ title: `Call ${b.number}`,
4489
4502
  "aria-label": "Call",
4490
4503
  onClick: () => Y("chat-island-call", {
4491
4504
  username: e,
4492
- number: y.number
4505
+ number: b.number
4493
4506
  }),
4494
4507
  children: Q.phone
4495
4508
  }),
4496
4509
  /* @__PURE__ */ d(Z, {
4497
4510
  variant: "small",
4498
- onClick: () => p(),
4511
+ onClick: () => m(),
4499
4512
  "aria-label": "Minimize",
4500
4513
  title: "Minimize",
4501
4514
  children: Q.minus
@@ -4503,18 +4516,18 @@ function Fr({ peer: e, actions: t, onDragStart: n }) {
4503
4516
  ]
4504
4517
  }),
4505
4518
  /* @__PURE__ */ d("div", { className: "ci-border-t ci-border-gray-300 dark:ci-border-gray-700" }),
4506
- b && r.kind === "group" && /* @__PURE__ */ d("div", {
4519
+ x && r.kind === "group" && /* @__PURE__ */ d("div", {
4507
4520
  className: "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",
4508
- children: D.map((e) => /* @__PURE__ */ f("div", {
4521
+ children: k.map((e) => /* @__PURE__ */ f("div", {
4509
4522
  className: "ci-flex ci-items-center ci-gap-3 ci-px-2 ci-py-1.5 ci-text-sm",
4510
4523
  children: [
4511
4524
  /* @__PURE__ */ f("span", {
4512
4525
  className: "ci-relative",
4513
- children: [/* @__PURE__ */ d(Wn, {
4526
+ children: [/* @__PURE__ */ d(Gn, {
4514
4527
  contact: a[e],
4515
4528
  username: e,
4516
4529
  size: 28
4517
- }), e !== _ && /* @__PURE__ */ d(Gn, {
4530
+ }), e !== v && /* @__PURE__ */ d(Kn, {
4518
4531
  online: o[e],
4519
4532
  presence: a[e]?.presence,
4520
4533
  mobile: s[e]
@@ -4522,15 +4535,15 @@ function Fr({ peer: e, actions: t, onDragStart: n }) {
4522
4535
  }),
4523
4536
  /* @__PURE__ */ d("span", {
4524
4537
  className: "ci-truncate ci-flex-1",
4525
- children: E(e)
4538
+ children: O(e)
4526
4539
  }),
4527
- e !== _ && /* @__PURE__ */ f(u, { children: [/* @__PURE__ */ d(Z, {
4540
+ e !== v && /* @__PURE__ */ f(u, { children: [/* @__PURE__ */ d(Z, {
4528
4541
  variant: "small",
4529
4542
  title: "Chat",
4530
4543
  "aria-label": "Chat",
4531
- onClick: () => m(e),
4544
+ onClick: () => h(e),
4532
4545
  children: Q.chat
4533
- }), a[e]?.number && Pr(a[e]?.presence) && /* @__PURE__ */ d(Z, {
4546
+ }), a[e]?.number && Fr(a[e]?.presence) && /* @__PURE__ */ d(Z, {
4534
4547
  variant: "call",
4535
4548
  title: `Call ${a[e]?.number}`,
4536
4549
  "aria-label": "Call",
@@ -4546,55 +4559,56 @@ function Fr({ peer: e, actions: t, onDragStart: n }) {
4546
4559
  /* @__PURE__ */ f("div", {
4547
4560
  className: "ci-flex-1 ci-min-h-0 ci-flex ci-flex-col ci-overflow-hidden ci-rounded-b-3xl",
4548
4561
  children: [
4549
- /* @__PURE__ */ d(vr, {
4562
+ /* @__PURE__ */ d(yr, {
4550
4563
  messages: r.messages,
4551
4564
  typing: r.typing,
4552
4565
  group: r.kind === "group",
4553
4566
  hasOlder: r.loaded && !r.complete,
4554
4567
  onLoadOlder: () => t.loadOlder(e),
4555
4568
  reactions: r.reactions,
4556
- me: _,
4569
+ me: v,
4557
4570
  onReact: (n, r) => t.react(e, n, r),
4558
- onReply: O
4571
+ onReply: A
4559
4572
  }),
4560
- S && /* @__PURE__ */ f("div", {
4573
+ C && /* @__PURE__ */ f("div", {
4561
4574
  className: "ci-mx-3 ci-mt-1 ci-flex ci-items-center ci-gap-2 ci-pl-3 ci-pr-1 ci-py-1.5 ci-rounded-2xl ci-bg-elevationL2 dark:ci-bg-elevationL2Dark ci-border-0 ci-border-l-4 ci-border-solid ci-border-iconSecondary dark:ci-border-iconSecondaryDark",
4562
4575
  children: [/* @__PURE__ */ f("div", {
4563
4576
  className: "ci-flex-1 ci-min-w-0 ci-text-xs",
4564
4577
  children: [/* @__PURE__ */ d("div", {
4565
4578
  className: "ci-font-medium ci-text-gray-900 dark:ci-text-white",
4566
- children: S.author === _ ? "You" : a[S.author]?.name ?? S.author
4579
+ children: C.author === v ? "You" : a[C.author]?.name ?? C.author
4567
4580
  }), /* @__PURE__ */ d("div", {
4568
4581
  className: "ci-truncate ci-text-gray-500 dark:ci-text-gray-400",
4569
- children: S.quote?.replace(/^[^:]*: /, "")
4582
+ children: C.quote?.replace(/^[^:]*: /, "")
4570
4583
  })]
4571
4584
  }), /* @__PURE__ */ d(Z, {
4572
4585
  variant: "small",
4573
- onClick: () => C(null),
4586
+ onClick: () => T(null),
4574
4587
  "aria-label": "Cancel reply",
4575
4588
  title: "Cancel reply",
4576
4589
  children: Q.close
4577
4590
  })]
4578
4591
  }),
4579
- /* @__PURE__ */ d(Nr, {
4580
- focusKey: T,
4581
- disabled: l !== "online",
4582
- onSend: (n) => t.send(e, n, S ?? void 0).then(() => C(null)),
4592
+ /* @__PURE__ */ d(Pr, {
4593
+ focusKey: E,
4594
+ disabled: p !== "online" || j,
4595
+ disabledText: j ? "This operator is no longer active" : void 0,
4596
+ onSend: (n) => t.send(e, n, C ?? void 0).then(() => T(null)),
4583
4597
  onTyping: (n) => t.typing(e, n),
4584
4598
  onFile: (n) => t.upload(e, n)
4585
4599
  }, e)
4586
4600
  ]
4587
4601
  })
4588
4602
  ]
4589
- }) : null;
4603
+ });
4590
4604
  }
4591
4605
  //#endregion
4592
4606
  //#region src/components/NewChat.tsx
4593
- async function Ir(e) {
4607
+ async function Lr(e) {
4594
4608
  let t = await createImageBitmap(e), n = Math.min(t.width, t.height), r = document.createElement("canvas");
4595
4609
  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);
4596
4610
  }
4597
- function Lr({ onOpen: e, onCreateGroup: t }) {
4611
+ function Rr({ onOpen: e, onCreateGroup: t }) {
4598
4612
  let { contacts: n, online: r, mobile: i, setPicker: a } = J(), [l, p] = c(""), [m, h] = c([]), [g, _] = c(""), [v, y] = c(!1), [b, x] = c(), S = s(null), C = o(() => {
4599
4613
  let e = Object.values(n), t = l.trim().toLowerCase();
4600
4614
  return t ? e.filter((e) => (e.name ?? "").toLowerCase().includes(t) || e.username.includes(t)) : e;
@@ -4617,7 +4631,7 @@ function Lr({ onOpen: e, onCreateGroup: t }) {
4617
4631
  autoFocus: !0,
4618
4632
  value: l,
4619
4633
  onChange: (e) => p(e.target.value),
4620
- placeholder: "Search colleagues",
4634
+ placeholder: "Search operators",
4621
4635
  className: "ci-flex-1 ci-bg-transparent ci-border-0 ci-outline-none ci-text-sm ci-text-gray-900 dark:ci-text-white placeholder:ci-text-gray-500 dark:placeholder:ci-text-gray-400"
4622
4636
  })]
4623
4637
  }), /* @__PURE__ */ d(Z, {
@@ -4641,7 +4655,7 @@ function Lr({ onOpen: e, onCreateGroup: t }) {
4641
4655
  className: "ci-overflow-y-auto ci-py-1 ci-m-0 ci-p-0 ci-list-none ci-flex-1",
4642
4656
  children: [C.length === 0 && /* @__PURE__ */ d("li", {
4643
4657
  className: "ci-px-4 ci-py-6 ci-text-center ci-text-sm ci-text-gray-500 dark:ci-text-gray-400",
4644
- children: "No colleagues found"
4658
+ children: "No operators found"
4645
4659
  }), C.map((e) => {
4646
4660
  let t = m.includes(e.username);
4647
4661
  return /* @__PURE__ */ d("li", { children: /* @__PURE__ */ f("button", {
@@ -4651,11 +4665,11 @@ function Lr({ onOpen: e, onCreateGroup: t }) {
4651
4665
  children: [
4652
4666
  /* @__PURE__ */ f("span", {
4653
4667
  className: "ci-relative",
4654
- children: [/* @__PURE__ */ d(Wn, {
4668
+ children: [/* @__PURE__ */ d(Gn, {
4655
4669
  contact: e,
4656
4670
  username: e.username,
4657
4671
  size: 36
4658
- }), /* @__PURE__ */ d(Gn, {
4672
+ }), /* @__PURE__ */ d(Kn, {
4659
4673
  online: r[e.username],
4660
4674
  presence: e.presence,
4661
4675
  mobile: i[e.username]
@@ -4702,7 +4716,7 @@ function Lr({ onOpen: e, onCreateGroup: t }) {
4702
4716
  type: "file",
4703
4717
  accept: "image/*",
4704
4718
  hidden: !0,
4705
- onChange: (e) => e.target.files?.[0] && Ir(e.target.files[0]).then(x).catch(() => {})
4719
+ onChange: (e) => e.target.files?.[0] && Lr(e.target.files[0]).then(x).catch(() => {})
4706
4720
  }),
4707
4721
  /* @__PURE__ */ d("button", {
4708
4722
  type: "button",
@@ -4737,22 +4751,22 @@ function Lr({ onOpen: e, onCreateGroup: t }) {
4737
4751
  }
4738
4752
  //#endregion
4739
4753
  //#region src/theme.ts
4740
- var Rr = "chat-island-theme", zr = () => {
4754
+ var zr = "chat-island-theme", Br = () => {
4741
4755
  try {
4742
- let e = localStorage.getItem(Rr);
4756
+ let e = localStorage.getItem(zr);
4743
4757
  return e === "light" || e === "dark" || e === "system" ? e : void 0;
4744
4758
  } catch {
4745
4759
  return;
4746
4760
  }
4747
4761
  };
4748
- function Br(e) {
4749
- let [t, n] = c(() => e ?? zr()), [r, a] = c(!1);
4750
- return i(() => n(e ?? zr()), [e]), i(() => {
4762
+ function Vr(e) {
4763
+ let [t, n] = c(() => e ?? Br()), [r, a] = c(!1);
4764
+ return i(() => n(e ?? Br()), [e]), i(() => {
4751
4765
  let e = (e) => {
4752
4766
  let t = e.detail?.theme;
4753
4767
  if (t === "light" || t === "dark" || t === "system") {
4754
4768
  try {
4755
- localStorage.setItem(Rr, t);
4769
+ localStorage.setItem(zr, t);
4756
4770
  } catch {}
4757
4771
  n(t);
4758
4772
  }
@@ -4778,14 +4792,15 @@ function Br(e) {
4778
4792
  }
4779
4793
  //#endregion
4780
4794
  //#region src/ChatIsland.tsx
4781
- function Vr() {
4795
+ function Hr() {
4782
4796
  let e = J.getState();
4783
4797
  return Object.values(e.conversations).map((t) => {
4784
4798
  let n = t.messages[t.messages.length - 1], r = e.contacts[t.peer];
4785
4799
  return {
4786
4800
  peer: t.peer,
4787
4801
  kind: t.kind,
4788
- name: t.kind === "group" ? t.name ?? t.peer.split("@")[0] : r?.name ?? t.peer,
4802
+ name: t.kind === "group" ? t.name ?? t.peer.split("@")[0] : r?.name ?? e.inactive[t.peer] ?? t.peer,
4803
+ inactive: t.kind === "group" ? void 0 : !!e.inactive[t.peer],
4789
4804
  avatar: t.kind === "group" ? t.avatar : r?.avatar,
4790
4805
  online: t.kind !== "group" && !!e.online[t.peer],
4791
4806
  mobile: t.kind !== "group" && !!e.mobile[t.peer],
@@ -4793,7 +4808,7 @@ function Vr() {
4793
4808
  unread: t.unread,
4794
4809
  members: t.members,
4795
4810
  last: n ? {
4796
- body: Wr(n.body),
4811
+ body: Gr(n.body),
4797
4812
  ts: n.ts,
4798
4813
  mine: n.mine,
4799
4814
  oob: n.oob,
@@ -4802,7 +4817,7 @@ function Vr() {
4802
4817
  };
4803
4818
  }).filter((e) => e.last || e.kind === "group").sort((e, t) => (t.last?.ts ?? 0) - (e.last?.ts ?? 0));
4804
4819
  }
4805
- var Hr = class extends t {
4820
+ var Ur = class extends t {
4806
4821
  state = { failed: !1 };
4807
4822
  failures = [];
4808
4823
  static getDerivedStateFromError() {
@@ -4820,7 +4835,7 @@ var Hr = class extends t {
4820
4835
  return this.state.failed ? null : this.props.children;
4821
4836
  }
4822
4837
  };
4823
- function Ur(e) {
4838
+ function Wr(e) {
4824
4839
  try {
4825
4840
  let [t, n, r] = atob(e).split(":");
4826
4841
  return t && n && r ? {
@@ -4832,9 +4847,9 @@ function Ur(e) {
4832
4847
  return null;
4833
4848
  }
4834
4849
  }
4835
- var Wr = (e) => (ur(e) ? "Attachment" : $(e)).replace(/```[^\n]*\n?/g, "").replace(/(\*\*|__|~~|`)/g, "").replace(/(^|\s)[*_](\S[^*_]*)[*_]/g, "$1$2").replace(/\s+/g, " ").trim();
4836
- function Gr({ 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 }) {
4837
- let g = o(() => Ur(e), [e]), _ = Br(n), v = s(g), y = s(p), b = s(u);
4850
+ var Gr = (e) => (dr(e) ? "Attachment" : $(e)).replace(/```[^\n]*\n?/g, "").replace(/(\*\*|__|~~|`)/g, "").replace(/(^|\s)[*_](\S[^*_]*)[*_]/g, "$1$2").replace(/\s+/g, " ").trim();
4851
+ function Kr({ 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 }) {
4852
+ let g = o(() => Wr(e), [e]), _ = Vr(n), v = s(g), y = s(p), b = s(u);
4838
4853
  i(() => {
4839
4854
  v.current = g, y.current = p, b.current = u;
4840
4855
  }, [
@@ -4850,11 +4865,11 @@ function Gr({ dataConfig: e, position: t = "bottom-right", theme: n, serviceWork
4850
4865
  let e = (e) => e.persisted && S((e) => e + 1);
4851
4866
  return window.addEventListener("pageshow", e), () => window.removeEventListener("pageshow", e);
4852
4867
  }, []);
4853
- let C = s(null), T = s(/* @__PURE__ */ new Set()), E = s(!1), D = s(null), O = s(null), k = ee(O, `chat-island-pos:${g?.host ?? ""}:${g?.username ?? ""}`), { open: te, picker: A, status: j } = J(w((e) => ({
4868
+ let C = s(null), T = s(/* @__PURE__ */ new Set()), D = s(!1), O = s(null), k = s(null), A = E(k, `chat-island-pos:${g?.host ?? ""}:${g?.username ?? ""}`), { open: ee, picker: j, status: M } = J(w((e) => ({
4854
4869
  open: e.open,
4855
4870
  picker: e.picker,
4856
4871
  status: e.status
4857
- }))), M = o(() => ({
4872
+ }))), N = o(() => ({
4858
4873
  send: async (e, t, n) => {
4859
4874
  let r = C.current;
4860
4875
  if (!r) throw Error("not connected");
@@ -4897,7 +4912,7 @@ function Gr({ dataConfig: e, position: t = "bottom-right", theme: n, serviceWork
4897
4912
  if (!t || !n) return;
4898
4913
  let r = J.getState().conversations[e];
4899
4914
  try {
4900
- r?.kind === "group" && await t.leaveGroup(e, !!r.owner).catch(() => {}), await Rn(n.host, n.token, e), J.getState().removeConversation(e);
4915
+ r?.kind === "group" && await t.leaveGroup(e, !!r.owner).catch(() => {}), await zn(n.host, n.token, e), J.getState().removeConversation(e);
4901
4916
  } catch (e) {
4902
4917
  Y("chat-island-error", {
4903
4918
  scope: "delete",
@@ -4955,7 +4970,7 @@ function Gr({ dataConfig: e, position: t = "bottom-right", theme: n, serviceWork
4955
4970
  if (e.setStatus(n, a), Y("chat-island-status", {
4956
4971
  status: n,
4957
4972
  error: a
4958
- }), n === "online" && r && !E.current && typeof Notification < "u") {
4973
+ }), n === "online" && r && !D.current && typeof Notification < "u") {
4959
4974
  let e = Notification.permission;
4960
4975
  (e === "granted" || b.current === "auto" && e === "default") && i();
4961
4976
  }
@@ -4984,7 +4999,7 @@ function Gr({ dataConfig: e, position: t = "bottom-right", theme: n, serviceWork
4984
4999
  }), n = (e, t) => {
4985
5000
  let n = J.getState(), r = document.visibilityState === "visible";
4986
5001
  if (r && n.open === e) return;
4987
- let i = n.conversations[e], a = i?.kind === "group" ? i.name ?? e : n.contacts[e]?.name ?? e, o = t.oob ? "Attachment" : $(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;
5002
+ let i = n.conversations[e], a = i?.kind === "group" ? i.name ?? e : n.contacts[e]?.name ?? n.inactive[e] ?? e, o = t.oob ? "Attachment" : $(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;
4988
5003
  y.current && Cn();
4989
5004
  let u = s ? i?.avatar : n.contacts[e]?.avatar;
4990
5005
  if (Y("chat-island-notify", {
@@ -5009,16 +5024,16 @@ function Gr({ dataConfig: e, position: t = "bottom-right", theme: n, serviceWork
5009
5024
  };
5010
5025
  C.current = t;
5011
5026
  let i = () => {
5012
- r && !E.current && (E.current = !0, Hn(g, r).then((e) => {
5027
+ r && !D.current && (D.current = !0, Un(g, r).then((e) => {
5013
5028
  if (!e) {
5014
- E.current = !1, J.setState({ push: Notification.permission === "denied" ? "denied" : "ask" });
5029
+ D.current = !1, J.setState({ push: Notification.permission === "denied" ? "denied" : "ask" });
5015
5030
  return;
5016
5031
  }
5017
5032
  return t.enablePush(e.service, e.node).then(() => {
5018
- D.current = e, J.setState({ push: "enabled" }), Y("chat-island-push", { enabled: !0 });
5033
+ O.current = e, J.setState({ push: "enabled" }), Y("chat-island-push", { enabled: !0 });
5019
5034
  });
5020
5035
  }).catch((e) => {
5021
- E.current = !1, Y("chat-island-error", {
5036
+ D.current = !1, Y("chat-island-error", {
5022
5037
  scope: "push",
5023
5038
  message: e.message
5024
5039
  });
@@ -5030,56 +5045,58 @@ function Gr({ dataConfig: e, position: t = "bottom-right", theme: n, serviceWork
5030
5045
  });
5031
5046
  let s = () => t.stop();
5032
5047
  window.addEventListener("pagehide", s), t.start();
5033
- let c = () => Ln(g.host, g.token).then(e.setMobile).catch(() => {});
5048
+ let c = () => {
5049
+ Ln(g.host, g.token).then(e.setMobile).catch(() => {}), Rn(g.host, g.token).then(e.setInactive).catch(() => {});
5050
+ };
5034
5051
  c();
5035
5052
  let u = window.setInterval(c, 12e4);
5036
5053
  In(g.host, g.token, g.username, (e) => J.setState({ myName: e })).then(e.setContacts).catch((e) => Y("chat-island-error", {
5037
5054
  scope: "contacts",
5038
5055
  message: e.message
5039
5056
  }));
5040
- let d = X("chat-island-open", ({ username: t }) => t && e.openChat(t)), f = X("chat-island-close", () => e.closeChat()), p = X("chat-island-new", () => e.setPicker(!0)), m = X("chat-island-delete", ({ username: e }) => e && M.remove(e)), h = X("chat-island-contacts", ({ contacts: t }) => t && e.setContacts(t)), _ = X("chat-island-conversations-request", () => Y("chat-island-conversations", { conversations: Vr() }));
5057
+ let d = X("chat-island-open", ({ username: t }) => t && e.openChat(t)), f = X("chat-island-close", () => e.closeChat()), p = X("chat-island-new", () => e.setPicker(!0)), m = X("chat-island-delete", ({ username: e }) => e && N.remove(e)), h = X("chat-island-contacts", ({ contacts: t }) => t && e.setContacts(t)), _ = X("chat-island-conversations-request", () => Y("chat-island-conversations", { conversations: Hr() }));
5041
5058
  return () => {
5042
- window.removeEventListener("pagehide", s), window.clearInterval(u), _(), p(), m(), d(), f(), h(), D.current && t.disablePush(D.current.service, D.current.node).catch(() => {}), D.current = null, t.stop(), C.current = null, E.current = !1;
5059
+ window.removeEventListener("pagehide", s), window.clearInterval(u), _(), p(), m(), d(), f(), h(), O.current && t.disablePush(O.current.service, O.current.node).catch(() => {}), O.current = null, t.stop(), C.current = null, D.current = !1;
5043
5060
  };
5044
5061
  }, [
5045
5062
  g,
5046
5063
  r,
5047
5064
  x
5048
5065
  ]);
5049
- let N = J((e) => Object.keys(e.contacts).join(","));
5066
+ let P = J((e) => Object.keys(e.contacts).join(","));
5050
5067
  i(() => {
5051
- j === "online" && N && C.current?.announce(N.split(","));
5052
- }, [j, N]);
5053
- let ne = J((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);
5054
- i(() => Y("chat-island-conversations", { conversations: Vr() }), [ne]);
5055
- let re = J((e) => Object.values(e.conversations).reduce((e, t) => e + t.unread, 0));
5056
- if (i(() => Y("chat-island-unread", { total: re }), [re]), !g) return null;
5057
- let ie = m && !h && k.anchor ? {
5058
- right: k.anchor.right,
5059
- bottom: k.anchor.bottom
5060
- } : void 0, ae = ie ? "" : t === "bottom-left" ? "ci-left-4 ci-bottom-5" : "ci-right-4 ci-bottom-5";
5068
+ M === "online" && P && C.current?.announce(P.split(","));
5069
+ }, [M, P]);
5070
+ let te = J((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);
5071
+ i(() => Y("chat-island-conversations", { conversations: Hr() }), [te]);
5072
+ let ne = J((e) => Object.values(e.conversations).reduce((e, t) => e + t.unread, 0));
5073
+ if (i(() => Y("chat-island-unread", { total: ne }), [ne]), !g) return null;
5074
+ let re = m && !h && A.anchor ? {
5075
+ right: A.anchor.right,
5076
+ bottom: A.anchor.bottom
5077
+ } : void 0, ie = re ? "" : t === "bottom-left" ? "ci-left-4 ci-bottom-5" : "ci-right-4 ci-bottom-5";
5061
5078
  return /* @__PURE__ */ d("div", {
5062
- ref: O,
5063
- style: ie,
5064
- onClickCapture: k.onClickCapture,
5065
- className: `chat-island-root ${_ ? "ci-dark" : ""} ci-fixed ${ae} ci-z-[9999] ci-flex ci-items-end ci-gap-3 ci-font-sans ci-select-none`,
5066
- "data-status": j,
5067
- children: /* @__PURE__ */ f(Hr, { children: [
5068
- te && /* @__PURE__ */ d(Fr, {
5069
- peer: te,
5070
- actions: M,
5071
- onDragStart: h ?? (m ? k.start : void 0)
5079
+ ref: k,
5080
+ style: re,
5081
+ onClickCapture: A.onClickCapture,
5082
+ className: `chat-island-root ${_ ? "ci-dark" : ""} ci-fixed ${ie} ci-z-[9999] ci-flex ci-items-end ci-gap-3 ci-font-sans ci-select-none`,
5083
+ "data-status": M,
5084
+ children: /* @__PURE__ */ f(Ur, { children: [
5085
+ ee && /* @__PURE__ */ d(Ir, {
5086
+ peer: ee,
5087
+ actions: N,
5088
+ onDragStart: h ?? (m ? A.start : void 0)
5072
5089
  }),
5073
- A && /* @__PURE__ */ d(Lr, {
5090
+ j && /* @__PURE__ */ d(Rr, {
5074
5091
  onOpen: (e) => J.getState().openChat(e),
5075
- onCreateGroup: M.createGroup
5092
+ onCreateGroup: N.createGroup
5076
5093
  }),
5077
- /* @__PURE__ */ d(Yn, {
5078
- onDragStart: h ?? (m ? k.start : void 0),
5094
+ /* @__PURE__ */ d(Xn, {
5095
+ onDragStart: h ?? (m ? A.start : void 0),
5079
5096
  pushButton: u !== "auto"
5080
5097
  })
5081
5098
  ] })
5082
5099
  });
5083
5100
  }
5084
5101
  //#endregion
5085
- export { Gr as ChatIsland, Pn as contactsFromOperators };
5102
+ export { Kr as ChatIsland, Pn as contactsFromOperators };