@nethesis/chat-island 0.1.0 → 0.1.2

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
@@ -277,7 +277,7 @@ var D = /* @__PURE__ */ y(((e) => {
277
277
  }
278
278
  };
279
279
  r.prototype.tree = r.prototype.root, t.exports = r;
280
- })), ee = /* @__PURE__ */ y(((e, t) => {
280
+ })), k = /* @__PURE__ */ y(((e, t) => {
281
281
  var n = O();
282
282
  function r(e, t) {
283
283
  if (Array.isArray(t)) {
@@ -296,7 +296,7 @@ var D = /* @__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 D = /* @__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 = D(), 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 D = /* @__PURE__ */ y(((e) => {
565
565
  e && this.write(e), this.write = function() {};
566
566
  }
567
567
  };
568
- })), A = D(), ne = /* @__PURE__ */ x(O(), 1), re = /* @__PURE__ */ x(ee(), 1), j = k(), ie = /* @__PURE__ */ x(te(), 1), ae = 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 oe(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 oe(e) {
580
580
  }
581
581
  //#endregion
582
582
  //#region node_modules/@xmpp/events/lib/timeout.js
583
- function se(e, t) {
584
- let n = oe(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 ae();
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 ce = /* @__PURE__ */ new WeakMap();
596
- function le(e) {
597
- let t = ce.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
- }, ce.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 M(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 } = le(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 M(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 ae();
618
+ let e = new ne();
619
619
  o = setTimeout(() => {
620
620
  l(), a(e);
621
621
  }, r);
@@ -624,14 +624,14 @@ function M(e, t, n = "error", r) {
624
624
  }
625
625
  //#endregion
626
626
  //#region node_modules/@xmpp/events/lib/Deferred.js
627
- function ue() {
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 de(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 de(e, t = null, n) {
651
651
  }
652
652
  //#endregion
653
653
  //#region node_modules/@xmpp/events/lib/listeners.js
654
- function fe(e) {
654
+ function le(e) {
655
655
  return {
656
656
  subscribe(t) {
657
- let { on: n } = le(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 } = le(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 pe = class extends Error {
668
+ var ue = class extends Error {
669
669
  constructor(...e) {
670
670
  super(...e), this.name = "XMLError";
671
671
  }
672
- }, me = class extends j.EventEmitter {
672
+ }, de = class extends P.EventEmitter {
673
673
  constructor() {
674
674
  super();
675
- let e = new ie.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 ne.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 pe(`${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 pe = class extends Error {
698
698
  onText(e) {
699
699
  let { cursor: t } = this;
700
700
  if (!t) {
701
- this.emit("error", new pe(`${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,37 +710,37 @@ var pe = class extends Error {
710
710
  e && this.parser.write(e);
711
711
  }
712
712
  };
713
- me.XMLError = pe;
713
+ de.XMLError = ue;
714
714
  //#endregion
715
715
  //#region node_modules/@xmpp/xml/index.js
716
- function N(...e) {
717
- return (0, re.default)(...e);
716
+ function I(...e) {
717
+ return (0, N.default)(...e);
718
718
  }
719
- Object.assign(N, {
720
- Element: ne.default,
721
- createElement: re.default,
722
- Parser: me,
723
- escapeXML: A.escapeXML,
724
- unescapeXML: A.unescapeXML,
725
- escapeXMLText: A.escapeXMLText,
726
- unescapeXMLText: A.unescapeXMLText,
727
- XMLError: pe,
728
- xml: N
719
+ Object.assign(I, {
720
+ Element: M.default,
721
+ createElement: N.default,
722
+ Parser: de,
723
+ escapeXML: j.escapeXML,
724
+ unescapeXML: j.unescapeXML,
725
+ escapeXMLText: j.escapeXMLText,
726
+ unescapeXMLText: j.unescapeXMLText,
727
+ XMLError: ue,
728
+ xml: I
729
729
  });
730
730
  //#endregion
731
731
  //#region node_modules/@xmpp/jid/lib/escaping.js
732
- function he(e) {
732
+ function fe(e) {
733
733
  return !(!e || e.replaceAll(String.raw`\20`, "").replaceAll(String.raw`\22`, "").replaceAll(String.raw`\26`, "").replaceAll(String.raw`\27`, "").replaceAll(String.raw`\2f`, "").replaceAll(String.raw`\3a`, "").replaceAll(String.raw`\3c`, "").replaceAll(String.raw`\3e`, "").replaceAll(String.raw`\40`, "").replaceAll(String.raw`\5c`, "").search(/[ "&'/:<>@\\]/g) === -1);
734
734
  }
735
- function ge(e) {
735
+ function pe(e) {
736
736
  return e === null ? null : e.replaceAll(/^\s+|\s+$/g, "").replaceAll("\\", String.raw`\5c`).replaceAll(" ", String.raw`\20`).replaceAll("\"", String.raw`\22`).replaceAll("&", String.raw`\26`).replaceAll("'", String.raw`\27`).replaceAll("/", String.raw`\2f`).replaceAll(":", String.raw`\3a`).replaceAll("<", String.raw`\3c`).replaceAll(">", String.raw`\3e`).replaceAll("@", String.raw`\40`);
737
737
  }
738
- function _e(e) {
738
+ function me(e) {
739
739
  return e === null ? null : e.replaceAll(String.raw`\20`, " ").replaceAll(String.raw`\22`, "\"").replaceAll(String.raw`\26`, "&").replaceAll(String.raw`\27`, "'").replaceAll(String.raw`\2f`, "/").replaceAll(String.raw`\3a`, ":").replaceAll(String.raw`\3c`, "<").replaceAll(String.raw`\3e`, ">").replaceAll(String.raw`\40`, "@").replaceAll(String.raw`\5c`, "\\");
740
740
  }
741
741
  //#endregion
742
742
  //#region node_modules/@xmpp/jid/lib/JID.js
743
- var P = class e {
743
+ var L = class e {
744
744
  constructor(e, t, n) {
745
745
  if (typeof t != "string" || !t) throw TypeError("Invalid domain.");
746
746
  this.setDomain(t), this.setLocal(typeof e == "string" ? e : ""), this.setResource(typeof n == "string" ? n : "");
@@ -759,11 +759,11 @@ var P = class e {
759
759
  return this._local === e._local && this._domain === e._domain && this._resource === e._resource;
760
760
  }
761
761
  setLocal(e, t) {
762
- return t ||= he(e), t && (e = ge(e)), this._local = e && e.toLowerCase(), this;
762
+ return t ||= fe(e), t && (e = pe(e)), this._local = e && e.toLowerCase(), this;
763
763
  }
764
764
  getLocal(e = !1) {
765
765
  let t = null;
766
- return t = e ? _e(this._local) : this._local, t;
766
+ return t = e ? me(this._local) : this._local, t;
767
767
  }
768
768
  setDomain(e) {
769
769
  return this._domain = e.toLowerCase(), this;
@@ -778,37 +778,37 @@ var P = class e {
778
778
  return this._resource;
779
779
  }
780
780
  };
781
- Object.defineProperty(P.prototype, "local", {
782
- get: P.prototype.getLocal,
783
- set: P.prototype.setLocal
784
- }), Object.defineProperty(P.prototype, "domain", {
785
- get: P.prototype.getDomain,
786
- set: P.prototype.setDomain
787
- }), Object.defineProperty(P.prototype, "resource", {
788
- get: P.prototype.getResource,
789
- set: P.prototype.setResource
781
+ Object.defineProperty(L.prototype, "local", {
782
+ get: L.prototype.getLocal,
783
+ set: L.prototype.setLocal
784
+ }), Object.defineProperty(L.prototype, "domain", {
785
+ get: L.prototype.getDomain,
786
+ set: L.prototype.setDomain
787
+ }), Object.defineProperty(L.prototype, "resource", {
788
+ get: L.prototype.getResource,
789
+ set: L.prototype.setResource
790
790
  });
791
791
  //#endregion
792
792
  //#region node_modules/@xmpp/jid/lib/parse.js
793
- function ve(e) {
793
+ function he(e) {
794
794
  let t, n, r = e.indexOf("/");
795
795
  r !== -1 && (n = e.slice(r + 1), e = e.slice(0, r));
796
796
  let i = e.indexOf("@");
797
- return i !== -1 && (t = e.slice(0, i), e = e.slice(i + 1)), new P(t, e, n);
797
+ return i !== -1 && (t = e.slice(0, i), e = e.slice(i + 1)), new L(t, e, n);
798
798
  }
799
799
  //#endregion
800
800
  //#region node_modules/@xmpp/jid/index.js
801
- function ye(e, t) {
801
+ function ge(e, t) {
802
802
  return e.equals(t);
803
803
  }
804
- function be(...e) {
805
- return !e[1] && !e[2] ? ve(...e) : new P(...e);
804
+ function _e(...e) {
805
+ return !e[1] && !e[2] ? he(...e) : new L(...e);
806
806
  }
807
- var F = be.bind();
808
- F.jid = be, F.JID = P, F.parse = ve, F.equal = ye, F.detectEscape = he, F.escapeLocal = ge, F.unescapeLocal = _e;
807
+ var R = _e.bind();
808
+ R.jid = _e, R.JID = L, R.parse = he, R.equal = ge, R.detectEscape = fe, R.escapeLocal = pe, R.unescapeLocal = me;
809
809
  //#endregion
810
810
  //#region node_modules/@xmpp/error/index.js
811
- var xe = class extends Error {
811
+ var ve = class extends Error {
812
812
  constructor(e, t, n) {
813
813
  super(e + (t ? ` - ${t}` : "")), this.name = "XMPPError", this.condition = e, this.text = t, this.application = n;
814
814
  }
@@ -818,14 +818,14 @@ var xe = class extends Error {
818
818
  let o = new this(t.name, i ? i.text() : "", a);
819
819
  return o.element = e, o;
820
820
  }
821
- }, Se = class extends xe {
821
+ }, ye = class extends ve {
822
822
  constructor(...e) {
823
823
  super(...e), this.name = "StreamError";
824
824
  }
825
825
  };
826
826
  //#endregion
827
827
  //#region node_modules/@xmpp/connection/lib/util.js
828
- function Ce(e) {
828
+ function be(e) {
829
829
  let { port: t, hostname: n, protocol: r } = new URL(e);
830
830
  return n === "[::1]" && (n = "::1"), {
831
831
  port: t,
@@ -833,19 +833,19 @@ function Ce(e) {
833
833
  protocol: r
834
834
  };
835
835
  }
836
- function we(e) {
837
- let { port: t, hostname: n } = Ce(`http://${e}`);
836
+ function xe(e) {
837
+ let { port: t, hostname: n } = be(`http://${e}`);
838
838
  return {
839
839
  port: t,
840
840
  hostname: n
841
841
  };
842
842
  }
843
- function Te(e) {
844
- return e.includes("://") ? Ce(e) : we(e);
843
+ function Se(e) {
844
+ return e.includes("://") ? be(e) : xe(e);
845
845
  }
846
846
  //#endregion
847
847
  //#region node_modules/@xmpp/connection/index.js
848
- var Ee = "urn:ietf:params:xml:ns:xmpp-streams", De = "http://etherx.jabber.org/streams", Oe = class extends j.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 = {}) {
@@ -856,7 +856,7 @@ var Ee = "urn:ietf:params:xml:ns:xmpp-streams", De = "http://etherx.jabber.org/s
856
856
  }
857
857
  async _streamError(e, t) {
858
858
  try {
859
- await this.send(N("stream:error", {}, [N(e, { xmlns: Ee }, t)]));
859
+ await this.send(I("stream:error", {}, [I(e, { xmlns: Ce }, t)]));
860
860
  } catch {}
861
861
  return this.disconnect();
862
862
  }
@@ -880,7 +880,7 @@ var Ee = "urn:ietf:params:xml:ns:xmpp-streams", De = "http://etherx.jabber.org/s
880
880
  });
881
881
  }
882
882
  _attachSocket(e) {
883
- this.socket = e, this.#e ??= fe({
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"),
@@ -891,19 +891,19 @@ var Ee = "urn:ietf:params:xml:ns:xmpp-streams", De = "http://etherx.jabber.org/s
891
891
  this.socket && this.#e?.unsubscribe(this.socket), this.socket = null;
892
892
  }
893
893
  _onElement(e) {
894
- let t = e.is("error", De);
894
+ let t = e.is("error", we);
895
895
  t && this._onStreamError(e), this.emit("element", e), this.emit(this.isStanza(e) ? "stanza" : "nonza", e), t && this.disconnect();
896
896
  }
897
897
  _onStreamError(e) {
898
- let t = Se.fromElement(e);
898
+ let t = ye.fromElement(e);
899
899
  if (t.condition === "see-other-host") return this._onSeeOtherHost(t);
900
900
  this.emit("error", t);
901
901
  }
902
902
  async _onSeeOtherHost(e) {
903
- let { protocol: t } = Te(this.options.service), n = e.element.getChildText("see-other-host"), { port: r } = we(n), i;
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 M(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 Ee = "urn:ietf:params:xml:ns:xmpp-streams", De = "http://etherx.jabber.org/s
914
914
  }
915
915
  }
916
916
  _attachParser(e) {
917
- this.parser = e, this.#t ??= fe({
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),
@@ -925,7 +925,7 @@ var Ee = "urn:ietf:params:xml:ns:xmpp-streams", De = "http://etherx.jabber.org/s
925
925
  this.parser && this.#t?.unsubscribe(this.parser), this.parser = null, this.root = null;
926
926
  }
927
927
  _jid(e) {
928
- return this.jid = F(e), this.jid;
928
+ return this.jid = R(e), this.jid;
929
929
  }
930
930
  _status(e, ...t) {
931
931
  this.status !== e && (this.status = e, this.emit("status", e, ...t), this.emit(e, ...t));
@@ -951,7 +951,7 @@ var Ee = "urn:ietf:params:xml:ns:xmpp-streams", De = "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 = M(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 Ee = "urn:ietf:params:xml:ns:xmpp-streams", De = "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)), M(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 M(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)), M(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 Ee = "urn:ietf:params:xml:ns:xmpp-streams", De = "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"), M(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 Ee = "urn:ietf:params:xml:ns:xmpp-streams", De = "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), M(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");
@@ -1010,7 +1010,7 @@ var Ee = "urn:ietf:params:xml:ns:xmpp-streams", De = "http://etherx.jabber.org/s
1010
1010
  return e.toString();
1011
1011
  }
1012
1012
  headerElement() {
1013
- return new N.Element("", {
1013
+ return new I.Element("", {
1014
1014
  version: "1.0",
1015
1015
  xmlns: this.NS
1016
1016
  });
@@ -1045,10 +1045,10 @@ var Ee = "urn:ietf:params:xml:ns:xmpp-streams", De = "http://etherx.jabber.org/s
1045
1045
  }));
1046
1046
  }
1047
1047
  };
1048
- Oe.prototype.NS = "", Oe.prototype.Socket = null, Oe.prototype.Parser = null;
1048
+ Te.prototype.NS = "", Te.prototype.Socket = null, Te.prototype.Parser = null;
1049
1049
  //#endregion
1050
1050
  //#region node_modules/@xmpp/client-core/lib/Client.js
1051
- var ke = class extends Oe {
1051
+ var Ee = class extends Te {
1052
1052
  constructor(e) {
1053
1053
  super(e), this.transports = [];
1054
1054
  }
@@ -1089,10 +1089,10 @@ var ke = class extends Oe {
1089
1089
  return this.Transport.prototype.footerElement(...e);
1090
1090
  }
1091
1091
  };
1092
- ke.prototype.NS = "jabber:client";
1092
+ Ee.prototype.NS = "jabber:client";
1093
1093
  //#endregion
1094
1094
  //#region node_modules/@xmpp/reconnect/index.js
1095
- var Ae = class extends j.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
  }
@@ -1125,36 +1125,36 @@ var Ae = class extends j.EventEmitter {
1125
1125
  e.removeListener("disconnect", this.#e), clearTimeout(t);
1126
1126
  }
1127
1127
  };
1128
- function je({ entity: e }) {
1129
- let t = new Ae(e);
1128
+ function Oe({ entity: e }) {
1129
+ let t = new De(e);
1130
1130
  return t.start(), t;
1131
1131
  }
1132
1132
  //#endregion
1133
1133
  //#region node_modules/@xmpp/websocket/lib/Socket.js
1134
- var Me = "ECONNERROR";
1135
- function Ne(e) {
1136
- let t = Ce(e);
1134
+ var ke = "ECONNERROR";
1135
+ function Ae(e) {
1136
+ let t = be(e);
1137
1137
  return !!(t.protocol === "wss:" || [
1138
1138
  "localhost",
1139
1139
  "127.0.0.1",
1140
1140
  "::1"
1141
1141
  ].includes(t.hostname));
1142
1142
  }
1143
- var Pe = class extends j.EventEmitter {
1143
+ var je = class extends P.EventEmitter {
1144
1144
  #e = null;
1145
1145
  socket = null;
1146
1146
  url = null;
1147
1147
  secure = !1;
1148
1148
  connect(e) {
1149
- this.url = e, this.secure = Ne(e), this._attachSocket(new WebSocket(e, ["xmpp"]));
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 ??= fe({
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) => {
1156
1156
  let { url: t } = this, { error: n } = e;
1157
- n || (n = Error(e.message || `WebSocket ${Me} ${t}`), n.errno = Me, n.code = Me), n.event = e, n.url = t, this.emit("error", n);
1157
+ n || (n = Error(e.message || `WebSocket ${ke} ${t}`), n.errno = ke, n.code = ke), n.event = e, n.url = t, this.emit("error", n);
1158
1158
  },
1159
1159
  close: (e) => {
1160
1160
  this._detachSocket(), this.emit("close", !e.wasClean, e);
@@ -1179,15 +1179,15 @@ var Pe = class extends j.EventEmitter {
1179
1179
  }
1180
1180
  n();
1181
1181
  }
1182
- }, Fe = class extends me {
1182
+ }, Me = class extends de {
1183
1183
  onStartElement(e, t) {
1184
- let n = new ne.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 pe(`${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) {
@@ -1196,7 +1196,7 @@ var Pe = class extends j.EventEmitter {
1196
1196
  }
1197
1197
  t.is("open", "urn:ietf:params:xml:ns:xmpp-framing") ? this.emit("start", t) : t.is("close", "urn:ietf:params:xml:ns:xmpp-framing") ? this.emit("end", t) : this.emit("element", t), this.cursor = null;
1198
1198
  }
1199
- }, Ie = "urn:ietf:params:xml:ns:xmpp-framing", Le = class extends Oe {
1199
+ }, Ne = "urn:ietf:params:xml:ns:xmpp-framing", Pe = class extends Te {
1200
1200
  send(e, ...t) {
1201
1201
  return e.attrs.xmlns ??= this.NS, super.send(e, ...t);
1202
1202
  }
@@ -1204,27 +1204,27 @@ var Pe = class extends j.EventEmitter {
1204
1204
  for (let t of e) t.attrs.xmlns ??= this.NS, t.parent = this.root, this.socket.write(t.toString()), this.emit("send", t);
1205
1205
  }
1206
1206
  footerElement() {
1207
- return new N.Element("close", { xmlns: Ie });
1207
+ return new I.Element("close", { xmlns: Ne });
1208
1208
  }
1209
1209
  headerElement() {
1210
1210
  let e = super.headerElement();
1211
- return e.name = "open", e.attrs.xmlns = Ie, e;
1211
+ return e.name = "open", e.attrs.xmlns = Ne, e;
1212
1212
  }
1213
1213
  socketParameters(e) {
1214
1214
  return /^wss?:\/\//.test(e) ? e : void 0;
1215
1215
  }
1216
1216
  };
1217
- Le.prototype.Socket = Pe, Le.prototype.NS = "jabber:client", Le.prototype.Parser = Fe;
1217
+ Pe.prototype.Socket = je, Pe.prototype.NS = "jabber:client", Pe.prototype.Parser = Me;
1218
1218
  //#endregion
1219
1219
  //#region node_modules/@xmpp/websocket/index.js
1220
- function Re({ entity: e }) {
1221
- e.transports.push(Le);
1220
+ function Fe({ entity: e }) {
1221
+ e.transports.push(Pe);
1222
1222
  }
1223
1223
  //#endregion
1224
1224
  //#region __vite-browser-external
1225
- var ze = /* @__PURE__ */ y(((e, t) => {
1225
+ var Ie = /* @__PURE__ */ y(((e, t) => {
1226
1226
  t.exports = {};
1227
- })), Be = /* @__PURE__ */ y(((e, t) => {
1227
+ })), Le = /* @__PURE__ */ y(((e, t) => {
1228
1228
  t.exports = n;
1229
1229
  function n(e) {
1230
1230
  if (!Array.isArray(e)) throw TypeError("Middleware stack must be an array!");
@@ -1245,40 +1245,40 @@ var ze = /* @__PURE__ */ y(((e, t) => {
1245
1245
  }
1246
1246
  };
1247
1247
  }
1248
- })), I = /* @__PURE__ */ x(ze(), 1), Ve = /* @__PURE__ */ x(Be(), 1), He = class {
1248
+ })), z = /* @__PURE__ */ x(Ie(), 1), Re = /* @__PURE__ */ x(Le(), 1), ze = class {
1249
1249
  constructor(e, t) {
1250
1250
  this.stanza = t, this.entity = e;
1251
1251
  let { name: n, attrs: r } = t, { type: i, id: a } = r;
1252
1252
  this.name = n, this.id = a || "", this.type = n === "message" ? i || "normal" : n === "presence" ? i || "available" : i || "", this.from = null, this.to = null, this.local = "", this.domain = "", this.resource = "";
1253
1253
  }
1254
- }, Ue = class extends He {
1254
+ }, Be = class extends ze {
1255
1255
  constructor(e, t) {
1256
1256
  super(e, t);
1257
1257
  let { jid: n } = e, { domain: r } = e.options ?? {}, i = t.attrs.to || n?.toString(), a = t.attrs.from || r;
1258
- i && (this.to = new F(i)), a && (this.from = new F(a), this.local = this.from.local, this.domain = this.from.domain, this.resource = this.from.resource);
1258
+ i && (this.to = new R(i)), a && (this.from = new R(a), this.local = this.from.local, this.domain = this.from.domain, this.resource = this.from.resource);
1259
1259
  }
1260
- }, We = class extends He {
1260
+ }, Ve = class extends ze {
1261
1261
  constructor(e, t) {
1262
1262
  super(e, t);
1263
1263
  let { jid: n } = e, { domain: r } = e.options ?? {}, i = t.attrs.from || n?.toString(), a = t.attrs.to || r;
1264
- i && (this.from = new F(i)), a && (this.to = new F(a), this.local = this.to.local, this.domain = this.to.domain, this.resource = this.to.resource);
1264
+ i && (this.from = new R(i)), a && (this.to = new R(a), this.local = this.to.local, this.domain = this.to.domain, this.resource = this.to.resource);
1265
1265
  }
1266
1266
  };
1267
1267
  //#endregion
1268
1268
  //#region node_modules/@xmpp/middleware/index.js
1269
- function Ge(e, t, n) {
1269
+ function He(e, t, n) {
1270
1270
  return (r) => {
1271
1271
  let i = new n(e, r);
1272
- return (0, Ve.default)(t)(i);
1272
+ return (0, Re.default)(t)(i);
1273
1273
  };
1274
1274
  }
1275
- function Ke(e) {
1275
+ function Ue(e) {
1276
1276
  return (t, n) => {
1277
1277
  n().then((t) => t && e.send(t)).catch((t) => e.emit("error", t));
1278
1278
  };
1279
1279
  }
1280
- function qe({ entity: e }) {
1281
- let t = [Ke(e)], n = [], r = Ge(e, t, Ue), i = Ge(e, n, We);
1280
+ function We({ entity: e }) {
1281
+ let t = [Ue(e)], n = [], r = He(e, t, Be), i = He(e, n, Ve);
1282
1282
  return e.on("element", r), e.on("send", i), {
1283
1283
  use(e) {
1284
1284
  return t.push(e), e;
@@ -1290,7 +1290,7 @@ function qe({ entity: e }) {
1290
1290
  }
1291
1291
  //#endregion
1292
1292
  //#region node_modules/@xmpp/stream-features/index.js
1293
- function Je({ middleware: e }) {
1293
+ function Ge({ middleware: e }) {
1294
1294
  function t(t, n, r) {
1295
1295
  return e.use((e, i) => {
1296
1296
  let { stanza: a } = e;
@@ -1303,14 +1303,14 @@ function Je({ middleware: e }) {
1303
1303
  }
1304
1304
  //#endregion
1305
1305
  //#region node_modules/@xmpp/id/index.js
1306
- function Ye() {
1306
+ function Ke() {
1307
1307
  let e;
1308
1308
  for (; !e;) e = Math.random().toString(36).slice(2, 12);
1309
1309
  return e;
1310
1310
  }
1311
1311
  //#endregion
1312
1312
  //#region node_modules/@xmpp/middleware/lib/StanzaError.js
1313
- var Xe = class extends xe {
1313
+ var qe = class extends ve {
1314
1314
  constructor(e, t, n, r) {
1315
1315
  super(e, t, n), this.type = r, this.name = "StanzaError";
1316
1316
  }
@@ -1321,10 +1321,10 @@ var Xe = class extends xe {
1321
1321
  };
1322
1322
  //#endregion
1323
1323
  //#region node_modules/@xmpp/iq/caller.js
1324
- function Ze({ name: e, type: t }) {
1324
+ function Je({ name: e, type: t }) {
1325
1325
  return !(e !== "iq" || t !== "error" && t !== "result");
1326
1326
  }
1327
- var Qe = class {
1327
+ var Ye = class {
1328
1328
  constructor({ entity: e, middleware: t }) {
1329
1329
  this.handlers = /* @__PURE__ */ new Map(), this.entity = e, this.middleware = t;
1330
1330
  }
@@ -1332,20 +1332,20 @@ var Qe = class {
1332
1332
  this.middleware.use(this._route.bind(this));
1333
1333
  }
1334
1334
  _route({ type: e, name: t, id: n, stanza: r }, i) {
1335
- if (!Ze({
1335
+ if (!Je({
1336
1336
  name: t,
1337
1337
  type: e
1338
1338
  })) return i();
1339
1339
  let a = this.handlers.get(n);
1340
1340
  if (!a) return i();
1341
- e === "error" ? a.reject(Xe.fromElement(r.getChild("error"))) : a.resolve(r), this.handlers.delete(n);
1341
+ e === "error" ? a.reject(qe.fromElement(r.getChild("error"))) : a.resolve(r), this.handlers.delete(n);
1342
1342
  }
1343
1343
  async request(e, t = 3e4) {
1344
- e.attrs.id || (e.attrs.id = Ye());
1345
- let n = new ue();
1344
+ e.attrs.id || (e.attrs.id = Ke());
1345
+ let n = new se();
1346
1346
  this.handlers.set(e.attrs.id, n);
1347
1347
  try {
1348
- await this.entity.send(e), await se(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
  }
@@ -1353,7 +1353,7 @@ var Qe = class {
1353
1353
  }
1354
1354
  _childRequest(e, t, n, ...r) {
1355
1355
  let { name: i, attrs: { xmlns: a } } = t;
1356
- return this.request(N("iq", {
1356
+ return this.request(I("iq", {
1357
1357
  type: e,
1358
1358
  to: n
1359
1359
  }, t), ...r).then((e) => e.getChild(i, a));
@@ -1365,71 +1365,71 @@ var Qe = class {
1365
1365
  return this._childRequest("set", ...e);
1366
1366
  }
1367
1367
  };
1368
- function $e(...e) {
1369
- let t = new Qe(...e);
1368
+ function Xe(...e) {
1369
+ let t = new Ye(...e);
1370
1370
  return t.start(), t;
1371
1371
  }
1372
1372
  //#endregion
1373
1373
  //#region node_modules/@xmpp/iq/callee.js
1374
- var et = "urn:ietf:params:xml:ns:xmpp-stanzas";
1375
- function tt({ name: e, type: t }) {
1374
+ var Ze = "urn:ietf:params:xml:ns:xmpp-stanzas";
1375
+ function Qe({ name: e, type: t }) {
1376
1376
  return e === "iq" && t !== "error" && t !== "result";
1377
1377
  }
1378
- function nt({ type: e }, t, n) {
1378
+ function $e({ type: e }, t, n) {
1379
1379
  return !(e !== "get" && e !== "set" || t.length !== 1 || !n);
1380
1380
  }
1381
- function rt({ stanza: e }) {
1382
- return N("iq", {
1381
+ function et({ stanza: e }) {
1382
+ return I("iq", {
1383
1383
  to: e.attrs.from,
1384
1384
  from: e.attrs.to,
1385
1385
  id: e.attrs.id
1386
1386
  });
1387
1387
  }
1388
- function it(e, t) {
1389
- let n = rt(e);
1388
+ function tt(e, t) {
1389
+ let n = et(e);
1390
1390
  return n.attrs.type = "result", t && n.append(t), n;
1391
1391
  }
1392
- function at(e, t, n) {
1393
- let r = rt(e);
1392
+ function nt(e, t, n) {
1393
+ let r = et(e);
1394
1394
  return r.attrs.type = "error", n && r.append(n), r.append(t), r;
1395
1395
  }
1396
- function ot(e, t) {
1397
- return N("error", { type: e }, N(t, et));
1396
+ function rt(e, t) {
1397
+ return I("error", { type: e }, I(t, Ze));
1398
1398
  }
1399
- function st(e) {
1399
+ function it(e) {
1400
1400
  return async function(t, n) {
1401
- if (!tt(t)) return n();
1401
+ if (!Qe(t)) return n();
1402
1402
  let { stanza: r } = t, i = r.getChildElements(), [a] = i;
1403
- if (!nt(t, i, a)) return at(t, ot("modify", "bad-request"), a);
1403
+ if (!$e(t, i, a)) return nt(t, rt("modify", "bad-request"), a);
1404
1404
  t.element = a;
1405
1405
  let o;
1406
1406
  try {
1407
1407
  o = await n();
1408
1408
  } catch (t) {
1409
- e.emit("error", t), o = ot("cancel", "internal-server-error");
1409
+ e.emit("error", t), o = rt("cancel", "internal-server-error");
1410
1410
  }
1411
- return o ||= ot("cancel", "service-unavailable"), o instanceof N.Element && o.is("error") ? at(t, o, a) : it(t, o instanceof N.Element ? o : void 0);
1411
+ return o ||= rt("cancel", "service-unavailable"), o instanceof I.Element && o.is("error") ? nt(t, o, a) : tt(t, o instanceof I.Element ? o : void 0);
1412
1412
  };
1413
1413
  }
1414
- function ct(e, t, n, r) {
1414
+ function at(e, t, n, r) {
1415
1415
  return (i, a) => i.type !== e | !i.element || !i.element.is(n, t) ? a() : r(i, a);
1416
1416
  }
1417
- function lt({ middleware: e, entity: t }) {
1418
- return e.use(st(t)), {
1417
+ function ot({ middleware: e, entity: t }) {
1418
+ return e.use(it(t)), {
1419
1419
  get(t, n, r) {
1420
- e.use(ct("get", t, n, r));
1420
+ e.use(at("get", t, n, r));
1421
1421
  },
1422
1422
  set(t, n, r) {
1423
- e.use(ct("set", t, n, r));
1423
+ e.use(at("set", t, n, r));
1424
1424
  }
1425
1425
  };
1426
1426
  }
1427
1427
  //#endregion
1428
1428
  //#region node_modules/@xmpp/resolve/lib/dns.js
1429
- var ut = ["ENOTFOUND", "ENODATA"];
1430
- function dt(e, t = {}) {
1429
+ var st = ["ENOTFOUND", "ENODATA"];
1430
+ function ct(e, t = {}) {
1431
1431
  return t.all = !0, new Promise((n, r) => {
1432
- I.default.lookup(e, t, (e, t) => {
1432
+ z.default.lookup(e, t, (e, t) => {
1433
1433
  if (e) return r(e);
1434
1434
  let i = [];
1435
1435
  for (let { family: e, address: n } of t) {
@@ -1448,17 +1448,17 @@ function dt(e, t = {}) {
1448
1448
  });
1449
1449
  });
1450
1450
  }
1451
- function ft(e, { service: t, protocol: n }) {
1451
+ function lt(e, { service: t, protocol: n }) {
1452
1452
  return new Promise((r, i) => {
1453
- I.default.resolveSrv(`_${t}._${n}.${e}`, (e, a) => {
1454
- e && ut.includes(e.code) ? r([]) : e ? i(e) : r(a.map((e) => Object.assign(e, {
1453
+ z.default.resolveSrv(`_${t}._${n}.${e}`, (e, a) => {
1454
+ e && st.includes(e.code) ? r([]) : e ? i(e) : r(a.map((e) => Object.assign(e, {
1455
1455
  service: t,
1456
1456
  protocol: n
1457
1457
  })));
1458
1458
  });
1459
1459
  });
1460
1460
  }
1461
- function pt(e) {
1461
+ function ut(e) {
1462
1462
  return e.toSorted((e, t) => {
1463
1463
  let n = e.priority - t.priority;
1464
1464
  if (n !== 0) return n;
@@ -1466,10 +1466,10 @@ function pt(e) {
1466
1466
  return r === 0 ? 0 : r;
1467
1467
  });
1468
1468
  }
1469
- function mt(e, t) {
1469
+ function dt(e, t) {
1470
1470
  let n = [];
1471
1471
  return Promise.all(e.map(async (e) => {
1472
- let r = await dt(e.name, t);
1472
+ let r = await ct(e.name, t);
1473
1473
  for (let t of r) {
1474
1474
  let { port: r, service: i } = e, a = t.address;
1475
1475
  n.push({
@@ -1480,7 +1480,7 @@ function mt(e, t) {
1480
1480
  }
1481
1481
  })).then(() => n);
1482
1482
  }
1483
- function ht(e, t = {}) {
1483
+ function ft(e, t = {}) {
1484
1484
  t.srv ||= [
1485
1485
  {
1486
1486
  service: "xmpps-client",
@@ -1524,15 +1524,15 @@ function ht(e, t = {}) {
1524
1524
  }
1525
1525
  ];
1526
1526
  let n = { options: t };
1527
- return dt(e, t).then((r) => Promise.all(t.srv.map((r) => ft(e, {
1527
+ return ct(e, t).then((r) => Promise.all(t.srv.map((r) => lt(e, {
1528
1528
  ...r,
1529
1529
  family: n
1530
- }).then((e) => mt(e, t)))).then((e) => [...pt(e.flat()), ...r]));
1530
+ }).then((e) => dt(e, t)))).then((e) => [...ut(e.flat()), ...r]));
1531
1531
  }
1532
1532
  //#endregion
1533
1533
  //#region node_modules/@xmpp/xml/lib/parse.js
1534
- function gt(e) {
1535
- let t = new me(), n = null, r = null;
1534
+ function pt(e) {
1535
+ let t = new de(), n = null, r = null;
1536
1536
  if (t.on("start", (e) => {
1537
1537
  n = e;
1538
1538
  }), t.on("element", (e) => {
@@ -1544,19 +1544,19 @@ function gt(e) {
1544
1544
  }
1545
1545
  //#endregion
1546
1546
  //#region node_modules/@xmpp/resolve/lib/alt-connections.js
1547
- function _t(e) {
1547
+ function mt(e) {
1548
1548
  return e.startsWith("https") || e.startsWith("wss");
1549
1549
  }
1550
- function vt(e, t) {
1550
+ function ht(e, t) {
1551
1551
  let n;
1552
- if (n = _t(e.uri) && !_t(t.uri) ? -1 : !_t(e.uri) && _t(t.uri) ? 1 : 0, n !== 0) return n;
1552
+ if (n = mt(e.uri) && !mt(t.uri) ? -1 : !mt(e.uri) && mt(t.uri) ? 1 : 0, n !== 0) return n;
1553
1553
  let r;
1554
1554
  return r = e.method === t.method ? 0 : e.method === "websocket" ? -1 : t.method === "websocket" ? 1 : e.method === "xbosh" ? -1 : t.method === "xbosh" ? 1 : e.method === "httppoll" ? -1 : +(t.method === "httppoll"), r === 0 ? 0 : r;
1555
1555
  }
1556
1556
  //#endregion
1557
1557
  //#region node_modules/@xmpp/resolve/lib/http.js
1558
- function yt(e) {
1559
- return fetch(`https://${e}/.well-known/host-meta`).then((e) => e.text()).then((e) => gt(e).getChildren("Link").filter((e) => [
1558
+ function gt(e) {
1559
+ return fetch(`https://${e}/.well-known/host-meta`).then((e) => e.text()).then((e) => pt(e).getChildren("Link").filter((e) => [
1560
1560
  "urn:xmpp:alt-connections:websocket",
1561
1561
  "urn:xmpp:alt-connections:httppoll",
1562
1562
  "urn:xmpp:alt-connections:xbosh"
@@ -1565,17 +1565,17 @@ function yt(e) {
1565
1565
  href: e.href,
1566
1566
  method: e.rel.split(":").pop(),
1567
1567
  uri: e.href
1568
- })).toSorted(vt)).catch(() => []);
1568
+ })).toSorted(ht)).catch(() => []);
1569
1569
  }
1570
1570
  //#endregion
1571
1571
  //#region node_modules/@xmpp/resolve/resolve.js
1572
- function bt(...e) {
1573
- return Promise.all([ht ? ht(...e) : Promise.resolve([]), yt(...e)]).then(([e, t]) => [...e, ...t]);
1572
+ function _t(...e) {
1573
+ return Promise.all([ft ? ft(...e) : Promise.resolve([]), gt(...e)]).then(([e, t]) => [...e, ...t]);
1574
1574
  }
1575
1575
  //#endregion
1576
1576
  //#region node_modules/@xmpp/resolve/index.js
1577
- async function xt(e) {
1578
- let t = await bt(e, { srv: [{
1577
+ async function vt(e) {
1578
+ let t = await _t(e, { srv: [{
1579
1579
  service: "xmpps-client",
1580
1580
  protocol: "tcp"
1581
1581
  }, {
@@ -1584,30 +1584,30 @@ async function xt(e) {
1584
1584
  }] });
1585
1585
  return [...new Set(t.map((e) => e.uri))];
1586
1586
  }
1587
- function St(e, t) {
1587
+ function yt(e, t) {
1588
1588
  return t.filter((t) => e._findTransport(t));
1589
1589
  }
1590
- async function Ct(e, t) {
1590
+ async function bt(e, t) {
1591
1591
  if (t.length === 0) throw Error("Couldn't connect");
1592
1592
  let n = t.shift(), r = e._findTransport(n);
1593
- if (!r) return Ct(e, t);
1593
+ if (!r) return 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 M(a, "connect");
1597
+ a.connect(i), await F(a, "connect");
1598
1598
  } catch {
1599
- return Ct(e, t);
1599
+ return bt(e, t);
1600
1600
  }
1601
1601
  e._attachSocket(a), a.emit("connect"), e.Transport = r, e.Socket = r.prototype.Socket, e.Parser = r.prototype.Parser;
1602
1602
  }
1603
- function wt({ entity: e }) {
1603
+ function xt({ entity: e }) {
1604
1604
  let t = e.connect;
1605
1605
  e.connect = async function(n) {
1606
1606
  if (!n || /:\/\//.test(n)) return t.call(this, n);
1607
- let r = St(e, await xt(n));
1607
+ let r = yt(e, await vt(n));
1608
1608
  if (r.length === 0) throw Error("No compatible transport found.");
1609
1609
  try {
1610
- await Ct(e, r);
1610
+ await bt(e, r);
1611
1611
  } catch (t) {
1612
1612
  throw await e.disconnect(), e._status("disconnect"), t;
1613
1613
  }
@@ -1615,24 +1615,24 @@ function wt({ entity: e }) {
1615
1615
  }
1616
1616
  //#endregion
1617
1617
  //#region node_modules/@xmpp/base64/index.js
1618
- function Tt(e) {
1618
+ function St(e) {
1619
1619
  return globalThis.btoa(e);
1620
1620
  }
1621
- function Et(e) {
1621
+ function Ct(e) {
1622
1622
  return globalThis.atob(e);
1623
1623
  }
1624
1624
  //#endregion
1625
1625
  //#region node_modules/@xmpp/sasl/lib/SASLError.js
1626
- var L = class extends xe {
1626
+ var wt = class extends ve {
1627
1627
  constructor(...e) {
1628
1628
  super(...e), this.name = "SASLError";
1629
1629
  }
1630
- }, R = "urn:ietf:params:xml:ns:xmpp-sasl";
1631
- function Dt(e, t, n) {
1630
+ }, Tt = "urn:ietf:params:xml:ns:xmpp-sasl";
1631
+ function Et(e, t, n) {
1632
1632
  let r = new Set(e.getChildren("mechanism", t).map((e) => e.text()));
1633
1633
  return n._mechs.map(({ name: e }) => e).filter((e) => r.has(e));
1634
1634
  }
1635
- async function Ot({ saslFactory: e, entity: t, mechanism: n, credentials: r }) {
1635
+ async function Dt({ saslFactory: e, entity: t, mechanism: n, credentials: r }) {
1636
1636
  let i = e.create([n]);
1637
1637
  if (!i) throw Error(`SASL: Mechanism ${n} not found.`);
1638
1638
  let { domain: a } = t.options, o = {
@@ -1645,31 +1645,31 @@ async function Ot({ saslFactory: e, entity: t, mechanism: n, credentials: r }) {
1645
1645
  serviceName: a,
1646
1646
  ...r
1647
1647
  };
1648
- await de(t, i.clientFirst && N("auth", {
1649
- xmlns: R,
1648
+ await ce(t, i.clientFirst && I("auth", {
1649
+ xmlns: Tt,
1650
1650
  mechanism: i.name
1651
- }, Tt(await i.response(o))), async (e, n) => {
1652
- if (e.getNS() === R) {
1651
+ }, St(await i.response(o))), async (e, n) => {
1652
+ if (e.getNS() === Tt) {
1653
1653
  if (e.name === "challenge") {
1654
- await i.challenge(Et(e.text()));
1654
+ await i.challenge(Ct(e.text()));
1655
1655
  let n = await i.response(o);
1656
- await t.send(N("response", {
1657
- xmlns: R,
1656
+ await t.send(I("response", {
1657
+ xmlns: Tt,
1658
1658
  mechanism: i.name
1659
- }, typeof n == "string" ? Tt(n) : ""));
1659
+ }, typeof n == "string" ? St(n) : ""));
1660
1660
  return;
1661
1661
  }
1662
- if (e.name === "failure") throw L.fromElement(e);
1662
+ if (e.name === "failure") throw wt.fromElement(e);
1663
1663
  if (e.name === "success") return n();
1664
1664
  }
1665
1665
  });
1666
1666
  }
1667
- function kt({ streamFeatures: e, saslFactory: t }, n) {
1668
- e.use("mechanisms", R, async ({ entity: e }, r, i) => {
1669
- let a = Dt(i, R, t);
1670
- if (a.length === 0) throw new L("SASL: No compatible mechanism available.");
1667
+ function Ot({ streamFeatures: e, saslFactory: t }, n) {
1668
+ e.use("mechanisms", Tt, async ({ entity: e }, r, i) => {
1669
+ let a = Et(i, Tt, t);
1670
+ if (a.length === 0) throw new wt("SASL: No compatible mechanism available.");
1671
1671
  async function o(n, r) {
1672
- await Ot({
1672
+ await Dt({
1673
1673
  saslFactory: t,
1674
1674
  entity: e,
1675
1675
  mechanism: r,
@@ -1681,8 +1681,8 @@ function kt({ streamFeatures: e, saslFactory: t }, n) {
1681
1681
  }
1682
1682
  //#endregion
1683
1683
  //#region node_modules/@xmpp/sasl2/index.js
1684
- var At = "urn:xmpp:sasl:2";
1685
- async function jt({ saslFactory: e, entity: t, mechanism: n, credentials: r, userAgent: i, streamFeatures: a, features: o }) {
1684
+ var kt = "urn:xmpp:sasl:2";
1685
+ async function At({ saslFactory: e, entity: t, mechanism: n, credentials: r, userAgent: i, streamFeatures: a, features: o }) {
1686
1686
  let s = e.create([n]);
1687
1687
  if (!s) throw Error(`SASL: Mechanism ${n} not found.`);
1688
1688
  let { domain: c } = t.options, l = {
@@ -1695,29 +1695,29 @@ async function jt({ saslFactory: e, entity: t, mechanism: n, credentials: r, use
1695
1695
  serviceName: c,
1696
1696
  ...r
1697
1697
  };
1698
- await de(t, N("authenticate", {
1699
- xmlns: At,
1698
+ await ce(t, I("authenticate", {
1699
+ xmlns: kt,
1700
1700
  mechanism: s.name
1701
1701
  }, [
1702
- s.clientFirst && N("initial-response", {}, Tt(await s.response(l))),
1702
+ s.clientFirst && I("initial-response", {}, St(await s.response(l))),
1703
1703
  i,
1704
1704
  ...a
1705
1705
  ]), async (e, n) => {
1706
- if (e.getNS() === At) {
1706
+ if (e.getNS() === kt) {
1707
1707
  if (e.name === "challenge") {
1708
- await s.challenge(Et(e.text()));
1708
+ await s.challenge(Ct(e.text()));
1709
1709
  let n = await s.response(l);
1710
- await t.send(N("response", {
1711
- xmlns: At,
1710
+ await t.send(I("response", {
1711
+ xmlns: kt,
1712
1712
  mechanism: s.name
1713
- }, typeof n == "string" ? Tt(n) : ""));
1713
+ }, typeof n == "string" ? St(n) : ""));
1714
1714
  return;
1715
1715
  }
1716
- if (e.name === "failure") throw L.fromElement(e);
1716
+ if (e.name === "failure") throw wt.fromElement(e);
1717
1717
  if (e.name === "continue") throw Error("SASL continue is not supported yet");
1718
1718
  if (e.name === "success") {
1719
1719
  let r = e.getChild("additional-data")?.text();
1720
- r && s.final && await s.final(Et(r));
1720
+ r && s.final && await s.final(Ct(r));
1721
1721
  let i = e.getChildText("authorization-identifier");
1722
1722
  i && t._jid(i);
1723
1723
  for (let t of e.getChildElements()) o.get(t.getNS())?.[1]?.(t);
@@ -1726,24 +1726,24 @@ async function jt({ saslFactory: e, entity: t, mechanism: n, credentials: r, use
1726
1726
  }
1727
1727
  });
1728
1728
  }
1729
- function Mt({ streamFeatures: e, saslFactory: t }, n) {
1729
+ function jt({ streamFeatures: e, saslFactory: t }, n) {
1730
1730
  let r = /* @__PURE__ */ new Map(), i;
1731
- return e.use("authentication", At, async ({ entity: e }, a, o) => {
1732
- let s = Dt(o, At, t), c = await Nt({
1731
+ return e.use("authentication", kt, async ({ entity: e }, a, o) => {
1732
+ let s = Et(o, kt, t), c = await Mt({
1733
1733
  element: o,
1734
1734
  features: r
1735
1735
  }), l = !!i?.mechanism;
1736
- if (s.length === 0 && !l) throw new L("SASL: No compatible mechanism available.");
1736
+ if (s.length === 0 && !l) throw new wt("SASL: No compatible mechanism available.");
1737
1737
  await n(u, s, l ? i : null, e);
1738
1738
  async function u(n, a, o) {
1739
1739
  await i.auth({
1740
- authenticate: jt,
1740
+ authenticate: At,
1741
1741
  entity: e,
1742
1742
  userAgent: o,
1743
1743
  streamFeatures: c,
1744
1744
  features: r,
1745
1745
  credentials: n
1746
- }) || await jt({
1746
+ }) || await At({
1747
1747
  entity: e,
1748
1748
  userAgent: o,
1749
1749
  streamFeatures: c,
@@ -1762,7 +1762,7 @@ function Mt({ streamFeatures: e, saslFactory: t }, n) {
1762
1762
  }
1763
1763
  };
1764
1764
  }
1765
- async function Nt({ element: e, features: t }) {
1765
+ async function Mt({ element: e, features: t }) {
1766
1766
  let n = [], r = e.getChild("inline");
1767
1767
  if (!r) return n;
1768
1768
  for (let e of r.getChildElements()) {
@@ -1773,55 +1773,55 @@ async function Nt({ element: e, features: t }) {
1773
1773
  }
1774
1774
  //#endregion
1775
1775
  //#region node_modules/@xmpp/resource-binding/index.js
1776
- var Pt = "urn:ietf:params:xml:ns:xmpp-bind";
1777
- function Ft(e) {
1778
- return N("bind", { xmlns: Pt }, e && N("resource", {}, e));
1776
+ var Nt = "urn:ietf:params:xml:ns:xmpp-bind";
1777
+ function Pt(e) {
1778
+ return I("bind", { xmlns: Nt }, e && I("resource", {}, e));
1779
1779
  }
1780
- async function It(e, t, n) {
1781
- let r = (await t.set(Ft(n))).getChildText("jid");
1780
+ async function Ft(e, t, n) {
1781
+ let r = (await t.set(Pt(n))).getChildText("jid");
1782
1782
  return e._jid(r), e._ready(!1), r;
1783
1783
  }
1784
- function Lt({ iqCaller: e }, t) {
1784
+ function It({ iqCaller: e }, t) {
1785
1785
  return async ({ entity: n }, r) => {
1786
- t = typeof t == "function" ? await t() : t, await It(n, e, t), r();
1786
+ t = typeof t == "function" ? await t() : t, await Ft(n, e, t), r();
1787
1787
  };
1788
1788
  }
1789
- function Rt({ streamFeatures: e, iqCaller: t }, n) {
1790
- e.use("bind", Pt, Lt({ iqCaller: t }, n));
1789
+ function Lt({ streamFeatures: e, iqCaller: t }, n) {
1790
+ e.use("bind", Nt, It({ iqCaller: t }, n));
1791
1791
  }
1792
1792
  //#endregion
1793
1793
  //#region node_modules/@xmpp/time/index.js
1794
- function zt(e = /* @__PURE__ */ new Date()) {
1794
+ function Rt(e = /* @__PURE__ */ new Date()) {
1795
1795
  return typeof e == "string" && (e = new Date(e)), new Date(e).toISOString().split(".")[0] + "Z";
1796
1796
  }
1797
1797
  //#endregion
1798
1798
  //#region node_modules/@xmpp/stream-management/bind2.js
1799
- function Bt({ bind2: e, sm: t, failed: n, enabled: r }) {
1800
- e.use(z, (e) => Gt({ sm: t }), async (e) => {
1799
+ function zt({ bind2: e, sm: t, failed: n, enabled: r }) {
1800
+ e.use(B, (e) => Wt({ sm: t }), async (e) => {
1801
1801
  e.is("enabled") ? r(e.attrs) : e.is("failed") && n();
1802
1802
  });
1803
1803
  }
1804
1804
  //#endregion
1805
1805
  //#region node_modules/@xmpp/stream-management/sasl2.js
1806
- function Vt({ sasl2: e, sm: t, failed: n, resumed: r }) {
1807
- e.use(z, (e) => {
1808
- if (e.is("sm") && t.id) return Kt({ sm: t });
1806
+ function Bt({ sasl2: e, sm: t, failed: n, resumed: r }) {
1807
+ e.use(B, (e) => {
1808
+ if (e.is("sm") && t.id) return Gt({ sm: t });
1809
1809
  }, (e) => {
1810
1810
  e.is("resumed") ? r(e) : e.is("failed") && n();
1811
1811
  });
1812
1812
  }
1813
1813
  //#endregion
1814
1814
  //#region node_modules/@xmpp/stream-management/stream-feature.js
1815
- function Ht({ streamFeatures: e, sm: t, entity: n, resumed: r, failed: i, enabled: a }) {
1816
- e.use("sm", z, async (e, o) => {
1815
+ function Vt({ streamFeatures: e, sm: t, entity: n, resumed: r, failed: i, enabled: a }) {
1816
+ e.use("sm", B, async (e, o) => {
1817
1817
  if (t.id) try {
1818
- await r(await Wt(n, t));
1818
+ await r(await Ut(n, t));
1819
1819
  return;
1820
1820
  } catch {
1821
1821
  i();
1822
1822
  }
1823
1823
  await o();
1824
- let s = Ut(n, t);
1824
+ let s = Ht(n, t);
1825
1825
  if (t.outbound_q.length > 0) throw Error("Stream Management assertion failure, queue should be empty after enable");
1826
1826
  t.outbound = 0;
1827
1827
  try {
@@ -1831,37 +1831,37 @@ function Ht({ streamFeatures: e, sm: t, entity: n, resumed: r, failed: i, enable
1831
1831
  }
1832
1832
  });
1833
1833
  }
1834
- function Ut(e, t) {
1835
- return de(e, Gt({ sm: t }), (e, t) => {
1834
+ function Ht(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
- if (e.is("failed", "urn:xmpp:sm:3")) throw xe.fromElement(e);
1837
+ if (e.is("failed", "urn:xmpp:sm:3")) throw ve.fromElement(e);
1838
1838
  });
1839
1839
  }
1840
- async function Wt(e, t) {
1841
- return de(e, Kt({ sm: t }), (e, t) => {
1840
+ async function Ut(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
- if (e.is("failed", "urn:xmpp:sm:3")) throw xe.fromElement(e);
1843
+ if (e.is("failed", "urn:xmpp:sm:3")) throw ve.fromElement(e);
1844
1844
  });
1845
1845
  }
1846
1846
  //#endregion
1847
1847
  //#region node_modules/@xmpp/stream-management/index.js
1848
- var z = "urn:xmpp:sm:3";
1849
- function Gt({ sm: e }) {
1850
- return N("enable", {
1851
- xmlns: z,
1848
+ var B = "urn:xmpp:sm:3";
1849
+ function Wt({ sm: e }) {
1850
+ return I("enable", {
1851
+ xmlns: B,
1852
1852
  max: e.preferredMaximum,
1853
1853
  resume: "true"
1854
1854
  });
1855
1855
  }
1856
- function Kt({ sm: e }) {
1857
- return N("resume", {
1858
- xmlns: z,
1856
+ function Gt({ sm: e }) {
1857
+ return I("resume", {
1858
+ xmlns: B,
1859
1859
  h: e.inbound,
1860
1860
  previd: e.id
1861
1861
  });
1862
1862
  }
1863
- function qt({ streamFeatures: e, entity: t, middleware: n, bind2: r, sasl2: i }) {
1864
- let a = null, o = null, s = null, c = new j.EventEmitter();
1863
+ function Kt({ streamFeatures: e, entity: t, middleware: n, bind2: r, sasl2: i }) {
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,
@@ -1877,8 +1877,8 @@ function qt({ streamFeatures: e, entity: t, middleware: n, bind2: r, sasl2: i })
1877
1877
  });
1878
1878
  async function l() {
1879
1879
  try {
1880
- await t.send(N("a", {
1881
- xmlns: z,
1880
+ await t.send(I("a", {
1881
+ xmlns: B,
1882
1882
  h: c.inbound
1883
1883
  }));
1884
1884
  } catch {}
@@ -1891,7 +1891,7 @@ function qt({ streamFeatures: e, entity: t, middleware: n, bind2: r, sasl2: i })
1891
1891
  async function u(e) {
1892
1892
  c.enabled = !0, f(+e.attrs.h);
1893
1893
  let n = c.outbound_q;
1894
- c.outbound_q = [], await t.sendMany(n.map((e) => Jt({
1894
+ c.outbound_q = [], await t.sendMany(n.map((e) => qt({
1895
1895
  entity: t,
1896
1896
  item: e
1897
1897
  }))), c.emit("resumed"), t._ready(!0), h();
@@ -1923,12 +1923,12 @@ function qt({ streamFeatures: e, entity: t, middleware: n, bind2: r, sasl2: i })
1923
1923
  "message",
1924
1924
  "iq"
1925
1925
  ].includes(n.name) ? c.inbound += 1 : n.is("r", "urn:xmpp:sm:3") ? await l() : n.is("a", "urn:xmpp:sm:3") && f(+n.attrs.h), h(), t();
1926
- }), r && Bt({
1926
+ }), r && zt({
1927
1927
  bind2: r,
1928
1928
  sm: c,
1929
1929
  failed: d,
1930
1930
  enabled: m
1931
- }), i && Vt({
1931
+ }), i && Bt({
1932
1932
  sasl2: i,
1933
1933
  sm: c,
1934
1934
  failed: d,
@@ -1940,7 +1940,7 @@ function qt({ streamFeatures: e, entity: t, middleware: n, bind2: r, sasl2: i })
1940
1940
  function g() {
1941
1941
  clearTimeout(o), clearTimeout(s), c.enabled && (c.timeout && !a && (a = setTimeout(() => {
1942
1942
  clearTimeout(o), t.disconnect().catch(() => {});
1943
- }, c.timeout)), t.send(N("r", { xmlns: z })).catch(() => {}), h());
1943
+ }, c.timeout)), t.send(I("r", { xmlns: B })).catch(() => {}), h());
1944
1944
  }
1945
1945
  return n.filter((e, t) => {
1946
1946
  let { stanza: n } = e;
@@ -1950,9 +1950,9 @@ function qt({ streamFeatures: e, entity: t, middleware: n, bind2: r, sasl2: i })
1950
1950
  "iq"
1951
1951
  ].includes(n.name) ? t() : (c.outbound_q.push({
1952
1952
  stanza: n,
1953
- stamp: zt()
1953
+ stamp: Rt()
1954
1954
  }), clearTimeout(o), clearTimeout(s), s = setTimeout(g, c.requestAckDebounce), t());
1955
- }), e && Ht({
1955
+ }), e && Vt({
1956
1956
  streamFeatures: e,
1957
1957
  sm: c,
1958
1958
  entity: t,
@@ -1961,9 +1961,9 @@ function qt({ streamFeatures: e, entity: t, middleware: n, bind2: r, sasl2: i })
1961
1961
  enabled: m
1962
1962
  }), c;
1963
1963
  }
1964
- function Jt({ entity: e, item: t }) {
1964
+ function qt({ entity: e, item: t }) {
1965
1965
  let { stanza: n, stamp: r } = t;
1966
- return n.name === "message" && !n.getChild("delay", "urn:xmpp:delay") && n.append(N("delay", {
1966
+ return n.name === "message" && !n.getChild("delay", "urn:xmpp:delay") && n.append(I("delay", {
1967
1967
  xmlns: "urn:xmpp:delay",
1968
1968
  from: e.jid.toString(),
1969
1969
  stamp: r
@@ -1971,17 +1971,17 @@ function Jt({ entity: e, item: t }) {
1971
1971
  }
1972
1972
  //#endregion
1973
1973
  //#region node_modules/@xmpp/client-core/src/bind2/bind2.js
1974
- var Yt = "urn:xmpp:bind:0";
1975
- function Xt({ sasl2: e, entity: t }, n) {
1974
+ var Jt = "urn:xmpp:bind:0";
1975
+ function Yt({ sasl2: e, entity: t }, n) {
1976
1976
  let r = /* @__PURE__ */ new Map();
1977
- return e.use(Yt, async (e) => {
1978
- if (!e.is("bind", Yt)) return;
1977
+ return e.use(Jt, async (e) => {
1978
+ if (!e.is("bind", Jt)) return;
1979
1979
  n = typeof n == "function" ? await n() : n;
1980
- let t = await Zt({
1980
+ let t = await Xt({
1981
1981
  element: e,
1982
1982
  features: r
1983
1983
  });
1984
- return N("bind", { xmlns: "urn:xmpp:bind:0" }, n && N("tag", null, n), ...t);
1984
+ return I("bind", { xmlns: "urn:xmpp:bind:0" }, n && I("tag", null, n), ...t);
1985
1985
  }, (e) => {
1986
1986
  if (e.is("bound")) {
1987
1987
  t._ready(!1);
@@ -1991,7 +1991,7 @@ function Xt({ sasl2: e, entity: t }, n) {
1991
1991
  r.set(e, [t, n]);
1992
1992
  } };
1993
1993
  }
1994
- function Zt({ element: e, features: t }) {
1994
+ function Xt({ element: e, features: t }) {
1995
1995
  let n = [], r = e.getChild("inline");
1996
1996
  if (!r) return n;
1997
1997
  for (let e of r.getChildElements()) {
@@ -2002,7 +2002,7 @@ function Zt({ element: e, features: t }) {
2002
2002
  }
2003
2003
  //#endregion
2004
2004
  //#region node_modules/saslmechanisms/lib/factory.js
2005
- var Qt = /* @__PURE__ */ y(((e, t) => {
2005
+ var Zt = /* @__PURE__ */ y(((e, t) => {
2006
2006
  (function(n, r) {
2007
2007
  typeof e == "object" ? r(e, t) : typeof define == "function" && define.amd && define(["exports", "module"], r);
2008
2008
  })(e, function(e, t) {
@@ -2022,9 +2022,9 @@ var Qt = /* @__PURE__ */ y(((e, t) => {
2022
2022
  return null;
2023
2023
  }, e = t.exports = n;
2024
2024
  });
2025
- })), $t = /* @__PURE__ */ x((/* @__PURE__ */ y(((e, t) => {
2025
+ })), Qt = /* @__PURE__ */ x((/* @__PURE__ */ y(((e, t) => {
2026
2026
  (function(n, r) {
2027
- typeof e == "object" ? r(e, t, Qt()) : typeof define == "function" && define.amd && define([
2027
+ typeof e == "object" ? r(e, t, Zt()) : typeof define == "function" && define.amd && define([
2028
2028
  "exports",
2029
2029
  "module",
2030
2030
  "./lib/factory"
@@ -2032,9 +2032,9 @@ var Qt = /* @__PURE__ */ y(((e, t) => {
2032
2032
  })(e, function(e, t, n) {
2033
2033
  e = t.exports = n, e.Factory = n;
2034
2034
  });
2035
- })))(), 1), B = "urn:xmpp:fast:0";
2036
- function en({ sasl2: e, entity: t }) {
2037
- let n = new $t.default(), r, i = new j.EventEmitter();
2035
+ })))(), 1), V = "urn:xmpp:fast:0";
2036
+ function $t({ sasl2: e, entity: t }) {
2037
+ let n = new Qt.default(), r, i = new P.EventEmitter();
2038
2038
  Object.assign(i, {
2039
2039
  mechanism: null,
2040
2040
  mechanisms: [],
@@ -2072,7 +2072,7 @@ function en({ sasl2: e, entity: t }) {
2072
2072
  async auth({ authenticate: e, entity: t, userAgent: n, credentials: r, streamFeatures: o, features: s }) {
2073
2073
  if (!i.mechanism) return !1;
2074
2074
  let { token: c } = r;
2075
- if (!tn(c, i.mechanisms)) return l();
2075
+ if (!en(c, i.mechanisms)) return l();
2076
2076
  try {
2077
2077
  return await e({
2078
2078
  saslFactory: i.saslFactory,
@@ -2081,13 +2081,13 @@ function en({ sasl2: e, entity: t }) {
2081
2081
  ...r,
2082
2082
  password: c.token
2083
2083
  },
2084
- streamFeatures: [...o, N("fast", { xmlns: B })],
2084
+ streamFeatures: [...o, I("fast", { xmlns: V })],
2085
2085
  entity: t,
2086
2086
  userAgent: n,
2087
2087
  features: s
2088
2088
  }), !0;
2089
2089
  } catch (e) {
2090
- return e instanceof L && ["not-authorized", "credentials-expired"].includes(e.condition) ? l() : (t.emit("error", e), !1);
2090
+ return e instanceof wt && ["not-authorized", "credentials-expired"].includes(e.condition) ? l() : (t.emit("error", e), !1);
2091
2091
  }
2092
2092
  async function l() {
2093
2093
  return await i.delete(), a(o), !1;
@@ -2095,34 +2095,34 @@ function en({ sasl2: e, entity: t }) {
2095
2095
  }
2096
2096
  });
2097
2097
  function a(e) {
2098
- e.push(N("request-token", {
2099
- xmlns: B,
2098
+ e.push(I("request-token", {
2099
+ xmlns: V,
2100
2100
  mechanism: i.mechanism
2101
2101
  }));
2102
2102
  }
2103
2103
  function o() {
2104
2104
  i.mechanism = null, i.mechanisms = [];
2105
2105
  }
2106
- return o(), e.use(B, async (e) => {
2107
- if (!e.is("fast", B)) return o();
2106
+ return o(), e.use(V, async (e) => {
2107
+ if (!e.is("fast", V)) return o();
2108
2108
  i.available = !0;
2109
- let t = Dt(e, B, n), r = t[0];
2109
+ let t = Et(e, V, n), r = t[0];
2110
2110
  if (!r) return o();
2111
2111
  i.mechanisms = t, i.mechanism = r;
2112
2112
  }, async (e) => {
2113
- e.is("token", B) && await i.save({
2113
+ e.is("token", V) && await i.save({
2114
2114
  mechanism: i.mechanism,
2115
2115
  token: e.attrs.token,
2116
2116
  expiry: e.attrs.expiry
2117
2117
  });
2118
2118
  }), i;
2119
2119
  }
2120
- function tn(e, t) {
2120
+ function en(e, t) {
2121
2121
  return !(!e || !t.includes(e.mechanism) || new Date(e.expiry) <= /* @__PURE__ */ new Date());
2122
2122
  }
2123
2123
  //#endregion
2124
2124
  //#region node_modules/sasl-plain/lib/mechanism.js
2125
- var nn = /* @__PURE__ */ y(((e, t) => {
2125
+ var tn = /* @__PURE__ */ y(((e, t) => {
2126
2126
  (function(n, r) {
2127
2127
  typeof e == "object" ? r(e, t) : typeof define == "function" && define.amd && define(["exports", "module"], r);
2128
2128
  })(e, function(e, t) {
@@ -2134,9 +2134,9 @@ var nn = /* @__PURE__ */ y(((e, t) => {
2134
2134
  return this;
2135
2135
  }, e = t.exports = n;
2136
2136
  });
2137
- })), rn = /* @__PURE__ */ x((/* @__PURE__ */ y(((e, t) => {
2137
+ })), nn = /* @__PURE__ */ x((/* @__PURE__ */ y(((e, t) => {
2138
2138
  (function(n, r) {
2139
- typeof e == "object" ? r(e, t, nn()) : typeof define == "function" && define.amd && define([
2139
+ typeof e == "object" ? r(e, t, tn()) : typeof define == "function" && define.amd && define([
2140
2140
  "exports",
2141
2141
  "module",
2142
2142
  "./lib/mechanism"
@@ -2145,12 +2145,12 @@ var nn = /* @__PURE__ */ y(((e, t) => {
2145
2145
  e = t.exports = n, e.Mechanism = n;
2146
2146
  });
2147
2147
  })))(), 1);
2148
- function an(e) {
2149
- e.use(rn.default);
2148
+ function rn(e) {
2149
+ e.use(nn.default);
2150
2150
  }
2151
2151
  //#endregion
2152
2152
  //#region node_modules/sasl-anonymous/lib/mechanism.js
2153
- var on = /* @__PURE__ */ y(((e, t) => {
2153
+ var an = /* @__PURE__ */ y(((e, t) => {
2154
2154
  (function(n, r) {
2155
2155
  typeof e == "object" ? r(e, t) : typeof define == "function" && define.amd && define(["exports", "module"], r);
2156
2156
  })(e, function(e, t) {
@@ -2159,9 +2159,9 @@ var on = /* @__PURE__ */ y(((e, t) => {
2159
2159
  return e.trace || "";
2160
2160
  }, n.prototype.challenge = function(e) {}, e = t.exports = n;
2161
2161
  });
2162
- })), sn = /* @__PURE__ */ x((/* @__PURE__ */ y(((e, t) => {
2162
+ })), on = /* @__PURE__ */ x((/* @__PURE__ */ y(((e, t) => {
2163
2163
  (function(n, r) {
2164
- typeof e == "object" ? r(e, t, on()) : typeof define == "function" && define.amd && define([
2164
+ typeof e == "object" ? r(e, t, an()) : typeof define == "function" && define.amd && define([
2165
2165
  "exports",
2166
2166
  "module",
2167
2167
  "./lib/mechanism"
@@ -2170,99 +2170,99 @@ var on = /* @__PURE__ */ y(((e, t) => {
2170
2170
  e = t.exports = n, e.Mechanism = n;
2171
2171
  });
2172
2172
  })))(), 1);
2173
- function cn(e) {
2174
- e.use(sn.default);
2173
+ function sn(e) {
2174
+ e.use(on.default);
2175
2175
  }
2176
2176
  //#endregion
2177
2177
  //#region node_modules/@xmpp/sasl-ht-sha-256-none/index.js
2178
- function V() {}
2179
- V.prototype.Mechanism = V, V.prototype.name = "HT-SHA-256-NONE", V.prototype.clientFirst = !0, V.prototype.response = async function({ username: e, password: t }) {
2178
+ function H() {}
2179
+ H.prototype.Mechanism = H, H.prototype.name = "HT-SHA-256-NONE", H.prototype.clientFirst = !0, H.prototype.response = async function({ username: e, password: t }) {
2180
2180
  this.key = await crypto.subtle.importKey("raw", new TextEncoder().encode(t), {
2181
2181
  name: "HMAC",
2182
2182
  hash: "SHA-256"
2183
2183
  }, !1, ["sign", "verify"]);
2184
2184
  let n = await crypto.subtle.sign("HMAC", this.key, new TextEncoder().encode("Initiator"));
2185
2185
  return `${e}\0${String.fromCodePoint(...new Uint8Array(n))}`;
2186
- }, V.prototype.final = async function(e) {
2186
+ }, H.prototype.final = async function(e) {
2187
2187
  let t = Uint8Array.from(e, (e) => e.codePointAt(0));
2188
2188
  if (await crypto.subtle.verify("HMAC", this.key, t, new TextEncoder().encode("Responder")) !== !0) throw Error("Responder message from server was wrong");
2189
2189
  };
2190
- function ln(e) {
2191
- e.use(V);
2190
+ function cn(e) {
2191
+ e.use(H);
2192
2192
  }
2193
2193
  //#endregion
2194
2194
  //#region node_modules/@xmpp/client/lib/createOnAuthenticate.js
2195
- var un = "ANONYMOUS", dn = "PLAIN";
2196
- function fn(e, t) {
2195
+ var ln = "ANONYMOUS", un = "PLAIN";
2196
+ function dn(e, t) {
2197
2197
  return async function(...n) {
2198
2198
  if (typeof e == "function") {
2199
2199
  await e(...n);
2200
2200
  return;
2201
2201
  }
2202
2202
  let [r, i, a, o] = n;
2203
- e.token ??= await a?.fetch(), await r(e, pn({
2203
+ e.token ??= await a?.fetch(), await r(e, fn({
2204
2204
  mechanisms: i,
2205
2205
  entity: o,
2206
2206
  credentials: e
2207
2207
  }), t);
2208
2208
  };
2209
2209
  }
2210
- function pn({ mechanisms: e, entity: t, credentials: n }) {
2211
- return !n?.username && !n?.password && !n?.token && e.includes(un) ? un : t.isSecure() ? e[0] : e.find((e) => e !== dn);
2210
+ function fn({ mechanisms: e, entity: t, credentials: n }) {
2211
+ return !n?.username && !n?.password && !n?.token && e.includes(ln) ? ln : t.isSecure() ? e[0] : e.find((e) => e !== un);
2212
2212
  }
2213
2213
  //#endregion
2214
2214
  //#region node_modules/@xmpp/client/lib/getDomain.js
2215
- function mn(e) {
2215
+ function pn(e) {
2216
2216
  return (e.split("://")[1] || e).split(":")[0].split("/")[0];
2217
2217
  }
2218
2218
  //#endregion
2219
2219
  //#region node_modules/@xmpp/client/index.js
2220
- function hn(e = {}) {
2220
+ function mn(e = {}) {
2221
2221
  let { resource: t, credentials: n, username: r, password: i, userAgent: a, ...o } = e, { domain: s, service: c } = o;
2222
- !s && c && (o.domain = mn(c));
2223
- let l = new ke(o);
2224
- r && o.domain && (l.jid = F(r, o.domain));
2225
- let u = je({ entity: l }), d = Re({ entity: l }), f = gn(I.default, { entity: l }), p = gn(I.default, { entity: l }), m = qe({ entity: l }), h = Je({ middleware: m }), g = $e({
2222
+ !s && c && (o.domain = pn(c));
2223
+ let l = new Ee(o);
2224
+ r && o.domain && (l.jid = R(r, o.domain));
2225
+ let u = Oe({ entity: l }), d = Fe({ entity: l }), f = hn(z.default, { entity: l }), p = hn(z.default, { entity: l }), m = We({ entity: l }), h = Ge({ middleware: m }), g = Xe({
2226
2226
  middleware: m,
2227
2227
  entity: l
2228
- }), _ = lt({
2228
+ }), _ = ot({
2229
2229
  middleware: m,
2230
2230
  entity: l
2231
- }), v = wt({ entity: l }), y = new $t.default(), b = Object.entries({
2232
- ...typeof I.default == "function" && { scramsha1: I.default },
2233
- plain: an,
2234
- anonymous: cn
2231
+ }), v = xt({ entity: l }), y = new Qt.default(), b = Object.entries({
2232
+ ...typeof z.default == "function" && { scramsha1: z.default },
2233
+ plain: rn,
2234
+ anonymous: sn
2235
2235
  }).map(([e, t]) => ({ [e]: t(y) }));
2236
- a ??= N("user-agent", { id: globalThis.crypto.randomUUID() });
2237
- let x = gn(I.default, { streamFeatures: h }), S = Mt({
2236
+ a ??= I("user-agent", { id: globalThis.crypto.randomUUID() });
2237
+ let x = hn(z.default, { streamFeatures: h }), S = jt({
2238
2238
  streamFeatures: h,
2239
2239
  saslFactory: y
2240
- }, fn(n ?? {
2240
+ }, dn(n ?? {
2241
2241
  username: r,
2242
2242
  password: i
2243
- }, a)), C = en({
2243
+ }, a)), C = $t({
2244
2244
  sasl2: S,
2245
2245
  entity: l
2246
2246
  });
2247
2247
  S.setup({ fast: C });
2248
- let w = Xt({
2248
+ let w = Yt({
2249
2249
  sasl2: S,
2250
2250
  entity: l
2251
2251
  }, t);
2252
- ln(C.saslFactory);
2253
- let T = kt({
2252
+ cn(C.saslFactory);
2253
+ let T = Ot({
2254
2254
  streamFeatures: h,
2255
2255
  saslFactory: y
2256
- }, fn(n ?? {
2256
+ }, dn(n ?? {
2257
2257
  username: r,
2258
2258
  password: i
2259
- }, a)), E = qt({
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
- }), D = Rt({
2265
+ }), D = Lt({
2266
2266
  iqCaller: g,
2267
2267
  streamFeatures: h
2268
2268
  }, t);
@@ -2288,12 +2288,12 @@ function hn(e = {}) {
2288
2288
  fast: C
2289
2289
  });
2290
2290
  }
2291
- function gn(e, ...t) {
2291
+ function hn(e, ...t) {
2292
2292
  if (typeof e == "function") return e(...t);
2293
2293
  }
2294
2294
  //#endregion
2295
2295
  //#region src/xmpp.ts
2296
- var H = {
2296
+ var U = {
2297
2297
  carbons: "urn:xmpp:carbons:2",
2298
2298
  forward: "urn:xmpp:forward:0",
2299
2299
  mam: "urn:xmpp:mam:2",
@@ -2319,7 +2319,7 @@ var H = {
2319
2319
  vcard: "vcard-temp",
2320
2320
  ping: "urn:xmpp:ping",
2321
2321
  reactions: "urn:xmpp:reactions:0"
2322
- }, _n = 3e4, vn = class {
2322
+ }, gn = 3e4, _n = class {
2323
2323
  xmpp;
2324
2324
  me;
2325
2325
  domain;
@@ -2337,7 +2337,7 @@ var H = {
2337
2337
  cfg;
2338
2338
  h;
2339
2339
  constructor(e, t) {
2340
- this.cfg = e, this.h = t, this.domain = e.host, this.mucHost = `conference.${e.host}`, this.me = `${e.username}@${e.host}`, this.xmpp = hn({
2340
+ this.cfg = e, this.h = t, this.domain = e.host, this.mucHost = `conference.${e.host}`, this.me = `${e.username}@${e.host}`, this.xmpp = mn({
2341
2341
  service: `wss://${e.host}/xmpp-websocket`,
2342
2342
  domain: e.host,
2343
2343
  username: e.username,
@@ -2347,7 +2347,7 @@ var H = {
2347
2347
  this.stopped || this.unauthorized || ((e === "connecting" || e === "opening" || e === "connect") && this.h.status("connecting"), (e === "disconnect" || e === "close") && (this.connected = !1, window.clearInterval(this.pingTimer), this.forgetPresence(), this.h.status("offline")), e === "disconnect" && this.scheduleRetry());
2348
2348
  }), this.xmpp.on("error", (e) => {
2349
2349
  if (!this.stopped) {
2350
- if (yn(e)) {
2350
+ if (vn(e)) {
2351
2351
  this.unauthorized = !0, window.clearTimeout(this.retryTimer), this.h.status("unauthorized", e.message);
2352
2352
  return;
2353
2353
  }
@@ -2360,14 +2360,14 @@ var H = {
2360
2360
  }
2361
2361
  this.attempt = 0, this.connected = !0;
2362
2362
  try {
2363
- await this.xmpp.send(N("iq", {
2363
+ await this.xmpp.send(I("iq", {
2364
2364
  type: "set",
2365
2365
  id: "carbons"
2366
- }, N("enable", { xmlns: H.carbons }))), await this.xmpp.send(N("presence"));
2366
+ }, I("enable", { xmlns: U.carbons }))), await this.xmpp.send(I("presence"));
2367
2367
  } catch {
2368
2368
  return;
2369
2369
  }
2370
- window.clearInterval(this.pingTimer), this.pingTimer = window.setInterval(() => this.ping(), _n), this.h.status("online");
2370
+ window.clearInterval(this.pingTimer), this.pingTimer = window.setInterval(() => this.ping(), gn), this.h.status("online");
2371
2371
  }), this.xmpp.on("stanza", (e) => this.onStanza(e));
2372
2372
  }
2373
2373
  start() {
@@ -2389,10 +2389,10 @@ var H = {
2389
2389
  document.visibilityState === "visible" && this.wake();
2390
2390
  };
2391
2391
  ping() {
2392
- this.connected && this.xmpp.iqCaller.request(N("iq", {
2392
+ this.connected && this.xmpp.iqCaller.request(I("iq", {
2393
2393
  type: "get",
2394
2394
  to: this.domain
2395
- }, N("ping", { xmlns: H.ping })), 1e4).catch((e) => {
2395
+ }, I("ping", { xmlns: U.ping })), 1e4).catch((e) => {
2396
2396
  !this.stopped && this.connected && e.name !== "StanzaError" && this.xmpp.disconnect().catch(() => {});
2397
2397
  });
2398
2398
  }
@@ -2406,7 +2406,7 @@ var H = {
2406
2406
  let e = this.xmpp;
2407
2407
  (e.status === "offline" ? this.xmpp.start() : e.connect(e.options.service).then(() => e.open({ domain: e.options.domain }))).catch((e) => {
2408
2408
  if (!this.stopped) {
2409
- if (yn(e)) {
2409
+ if (vn(e)) {
2410
2410
  this.unauthorized = !0, this.h.status("unauthorized", e.message);
2411
2411
  return;
2412
2412
  }
@@ -2424,14 +2424,14 @@ var H = {
2424
2424
  }
2425
2425
  async send(e, t, n) {
2426
2426
  let r = crypto.randomUUID(), i = [
2427
- N("body", {}, t),
2428
- N("origin-id", {
2429
- xmlns: H.sid,
2427
+ I("body", {}, t),
2428
+ I("origin-id", {
2429
+ xmlns: U.sid,
2430
2430
  id: r
2431
2431
  }),
2432
- N("store", { xmlns: H.hints })
2432
+ I("store", { xmlns: U.hints })
2433
2433
  ];
2434
- return n && i.push(N("x", { xmlns: H.oob }, N("url", {}, n))), this.isGroup(e) ? (await this.xmpp.send(N("message", {
2434
+ return n && i.push(I("x", { xmlns: U.oob }, I("url", {}, n))), this.isGroup(e) ? (await this.xmpp.send(I("message", {
2435
2435
  to: e,
2436
2436
  type: "groupchat",
2437
2437
  id: r
@@ -2446,7 +2446,7 @@ var H = {
2446
2446
  oob: n,
2447
2447
  room: e,
2448
2448
  nick: this.cfg.username
2449
- }) : (i.push(N("active", { xmlns: H.chatstates })), await this.xmpp.send(N("message", {
2449
+ }) : (i.push(I("active", { xmlns: U.chatstates })), await this.xmpp.send(I("message", {
2450
2450
  to: `${e}@${this.domain}`,
2451
2451
  type: "chat",
2452
2452
  id: r
@@ -2462,35 +2462,35 @@ var H = {
2462
2462
  });
2463
2463
  }
2464
2464
  async react(e, t, n) {
2465
- let r = this.isGroup(e), i = N("reactions", {
2466
- xmlns: H.reactions,
2465
+ let r = this.isGroup(e), i = I("reactions", {
2466
+ xmlns: U.reactions,
2467
2467
  id: t
2468
- }, ...n.map((e) => N("reaction", {}, e)));
2469
- await this.xmpp.send(N("message", {
2468
+ }, ...n.map((e) => I("reaction", {}, e)));
2469
+ await this.xmpp.send(I("message", {
2470
2470
  to: r ? e : `${e}@${this.domain}`,
2471
2471
  type: r ? "groupchat" : "chat",
2472
2472
  id: crypto.randomUUID()
2473
- }, i, N("store", { xmlns: H.hints })));
2473
+ }, i, I("store", { xmlns: U.hints })));
2474
2474
  }
2475
2475
  async announce(e) {
2476
- for (let t of e) await this.xmpp.send(N("presence", { to: `${t}@${this.domain}` }, N("x", { xmlns: H.hello }))).catch(() => {});
2476
+ for (let t of e) await this.xmpp.send(I("presence", { to: `${t}@${this.domain}` }, I("x", { xmlns: U.hello }))).catch(() => {});
2477
2477
  }
2478
2478
  typing(e, t) {
2479
- return this.isGroup(e) ? Promise.resolve() : this.xmpp.send(N("message", {
2479
+ return this.isGroup(e) ? Promise.resolve() : this.xmpp.send(I("message", {
2480
2480
  to: `${e}@${this.domain}`,
2481
2481
  type: "chat"
2482
- }, N(t ? "composing" : "paused", { xmlns: H.chatstates })));
2482
+ }, I(t ? "composing" : "paused", { xmlns: U.chatstates })));
2483
2483
  }
2484
2484
  enablePush(e, t) {
2485
- return this.xmpp.iqCaller.request(N("iq", { type: "set" }, N("enable", {
2486
- xmlns: H.push,
2485
+ return this.xmpp.iqCaller.request(I("iq", { type: "set" }, I("enable", {
2486
+ xmlns: U.push,
2487
2487
  jid: e,
2488
2488
  node: t
2489
2489
  })), 15e3);
2490
2490
  }
2491
2491
  disablePush(e, t) {
2492
- return this.xmpp.iqCaller.request(N("iq", { type: "set" }, N("disable", {
2493
- xmlns: H.push,
2492
+ return this.xmpp.iqCaller.request(I("iq", { type: "set" }, I("disable", {
2493
+ xmlns: U.push,
2494
2494
  jid: e,
2495
2495
  node: t
2496
2496
  })), 5e3);
@@ -2504,27 +2504,27 @@ var H = {
2504
2504
  async mam(e, t, n) {
2505
2505
  let r = crypto.randomUUID();
2506
2506
  this.mamQueries.set(r, []), this.mamReactions.set(r, []);
2507
- let i = N("set", { xmlns: H.rsm }, N("max", {}, String(n)), N("before", {}, t ?? "")), a = [N("field", {
2507
+ let i = I("set", { xmlns: U.rsm }, I("max", {}, String(n)), I("before", {}, t ?? "")), a = [I("field", {
2508
2508
  var: "FORM_TYPE",
2509
2509
  type: "hidden"
2510
- }, N("value", {}, H.mam))];
2511
- e && a.push(N("field", { var: "with" }, N("value", {}, this.isGroup(e) ? e : `${e}@${this.domain}`)));
2512
- let o = N("x", {
2513
- xmlns: H.data,
2510
+ }, I("value", {}, U.mam))];
2511
+ e && a.push(I("field", { var: "with" }, I("value", {}, this.isGroup(e) ? e : `${e}@${this.domain}`)));
2512
+ let o = I("x", {
2513
+ xmlns: U.data,
2514
2514
  type: "submit"
2515
2515
  }, ...a), s, c, l;
2516
2516
  try {
2517
- s = await this.xmpp.iqCaller.request(N("iq", {
2517
+ s = await this.xmpp.iqCaller.request(I("iq", {
2518
2518
  type: "set",
2519
2519
  id: r
2520
- }, N("query", {
2521
- xmlns: H.mam,
2520
+ }, I("query", {
2521
+ xmlns: U.mam,
2522
2522
  queryid: r
2523
2523
  }, o, i)), 3e4);
2524
2524
  } finally {
2525
2525
  c = this.mamQueries.get(r) ?? [], l = this.mamReactions.get(r) ?? [], this.mamQueries.delete(r), this.mamReactions.delete(r);
2526
2526
  }
2527
- let u = s.getChild("fin", H.mam), d = u?.getChild("set", H.rsm)?.getChildText("first") ?? void 0;
2527
+ let u = s.getChild("fin", U.mam), d = u?.getChild("set", U.rsm)?.getChildText("first") ?? void 0;
2528
2528
  return {
2529
2529
  messages: c,
2530
2530
  reactions: l,
@@ -2533,103 +2533,103 @@ var H = {
2533
2533
  };
2534
2534
  }
2535
2535
  async createGroup(e, t, n) {
2536
- let r = `g-${Math.random().toString(36).slice(2, 10)}@${this.mucHost}`, i = this.cfg.username, a = this.waitFor((e) => e.is("presence") && U(e.attrs.from) === r, 1e4);
2537
- await this.xmpp.send(N("presence", { to: `${r}/${i}` }, N("x", { xmlns: H.muc }))), await a;
2538
- let o = (e, t) => N("field", { var: e }, N("value", {}, t));
2539
- await this.xmpp.iqCaller.request(N("iq", {
2536
+ let r = `g-${Math.random().toString(36).slice(2, 10)}@${this.mucHost}`, i = this.cfg.username, a = this.waitFor((e) => e.is("presence") && W(e.attrs.from) === r, 1e4);
2537
+ await this.xmpp.send(I("presence", { to: `${r}/${i}` }, I("x", { xmlns: U.muc }))), await a;
2538
+ let o = (e, t) => I("field", { var: e }, I("value", {}, t));
2539
+ await this.xmpp.iqCaller.request(I("iq", {
2540
2540
  type: "set",
2541
2541
  to: r
2542
- }, N("query", { xmlns: H.mucOwner }, N("x", {
2543
- xmlns: H.data,
2542
+ }, I("query", { xmlns: U.mucOwner }, I("x", {
2543
+ xmlns: U.data,
2544
2544
  type: "submit"
2545
2545
  }, 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(() => {});
2546
2546
  let s = t.filter((e) => e && e !== this.cfg.username);
2547
- await this.xmpp.iqCaller.request(N("iq", {
2547
+ await this.xmpp.iqCaller.request(I("iq", {
2548
2548
  type: "set",
2549
2549
  to: r
2550
- }, N("query", { xmlns: H.mucAdmin }, ...s.map((e) => N("item", {
2550
+ }, I("query", { xmlns: U.mucAdmin }, ...s.map((e) => I("item", {
2551
2551
  affiliation: "member",
2552
2552
  jid: `${e}@${this.domain}`
2553
2553
  })))), 15e3);
2554
- for (let e of s) await this.xmpp.iqCaller.request(N("iq", {
2554
+ for (let e of s) await this.xmpp.iqCaller.request(I("iq", {
2555
2555
  type: "set",
2556
2556
  to: r
2557
- }, N("subscribe", {
2558
- xmlns: H.mucsub,
2557
+ }, I("subscribe", {
2558
+ xmlns: U.mucsub,
2559
2559
  jid: `${e}@${this.domain}`,
2560
2560
  nick: e
2561
- }, N("event", { node: H.mucsubMessages }))), 15e3).catch(() => {});
2562
- await this.xmpp.iqCaller.request(N("iq", {
2561
+ }, I("event", { node: U.mucsubMessages }))), 15e3).catch(() => {});
2562
+ await this.xmpp.iqCaller.request(I("iq", {
2563
2563
  type: "set",
2564
2564
  to: r
2565
- }, N("subscribe", {
2566
- xmlns: H.mucsub,
2565
+ }, I("subscribe", {
2566
+ xmlns: U.mucsub,
2567
2567
  nick: i
2568
- }, N("event", { node: H.mucsubMessages }))), 15e3), await this.xmpp.send(N("presence", {
2568
+ }, I("event", { node: U.mucsubMessages }))), 15e3), await this.xmpp.send(I("presence", {
2569
2569
  to: `${r}/${i}`,
2570
2570
  type: "unavailable"
2571
2571
  }));
2572
- for (let t of s) await this.xmpp.send(N("message", { to: `${t}@${this.domain}` }, N("x", {
2573
- xmlns: H.conference,
2572
+ for (let t of s) await this.xmpp.send(I("message", { to: `${t}@${this.domain}` }, I("x", {
2573
+ xmlns: U.conference,
2574
2574
  jid: r,
2575
2575
  reason: e
2576
2576
  }))).catch(() => {});
2577
2577
  return r;
2578
2578
  }
2579
2579
  async leaveGroup(e, t) {
2580
- t ? await this.xmpp.iqCaller.request(N("iq", {
2580
+ t ? await this.xmpp.iqCaller.request(I("iq", {
2581
2581
  type: "set",
2582
2582
  to: e
2583
- }, N("query", { xmlns: H.mucOwner }, N("destroy", {}))), 1e4) : await this.xmpp.iqCaller.request(N("iq", {
2583
+ }, I("query", { xmlns: U.mucOwner }, I("destroy", {}))), 1e4) : await this.xmpp.iqCaller.request(I("iq", {
2584
2584
  type: "set",
2585
2585
  to: e
2586
- }, N("unsubscribe", { xmlns: H.mucsub })), 1e4);
2586
+ }, I("unsubscribe", { xmlns: U.mucsub })), 1e4);
2587
2587
  }
2588
2588
  async setGroupAvatar(e, t) {
2589
2589
  let n = /^data:(image\/[a-z+]+);base64,(.+)$/i.exec(t);
2590
- n && await this.xmpp.iqCaller.request(N("iq", {
2590
+ n && await this.xmpp.iqCaller.request(I("iq", {
2591
2591
  type: "set",
2592
2592
  to: e
2593
- }, N("vCard", { xmlns: H.vcard }, N("PHOTO", {}, N("TYPE", {}, n[1]), N("BINVAL", {}, n[2])))), 15e3);
2593
+ }, I("vCard", { xmlns: U.vcard }, I("PHOTO", {}, I("TYPE", {}, n[1]), I("BINVAL", {}, n[2])))), 15e3);
2594
2594
  }
2595
2595
  async groupAvatar(e) {
2596
- let t = (await this.xmpp.iqCaller.request(N("iq", {
2596
+ let t = (await this.xmpp.iqCaller.request(I("iq", {
2597
2597
  type: "get",
2598
2598
  to: e
2599
- }, N("vCard", { xmlns: H.vcard })), 1e4)).getChild("vCard", H.vcard)?.getChild("PHOTO"), n = t?.getChildText("BINVAL");
2599
+ }, I("vCard", { xmlns: U.vcard })), 1e4)).getChild("vCard", U.vcard)?.getChild("PHOTO"), n = t?.getChildText("BINVAL");
2600
2600
  return n ? `data:${t?.getChildText("TYPE") || "image/jpeg"};base64,${n.replace(/\s+/g, "")}` : void 0;
2601
2601
  }
2602
2602
  async listGroups() {
2603
- let e = ((await this.xmpp.iqCaller.request(N("iq", {
2603
+ let e = ((await this.xmpp.iqCaller.request(I("iq", {
2604
2604
  type: "get",
2605
2605
  to: this.mucHost
2606
- }, N("subscriptions", { xmlns: H.mucsub })), 15e3)).getChild("subscriptions", H.mucsub)?.getChildren("subscription") ?? []).map((e) => e.attrs.jid);
2606
+ }, I("subscriptions", { xmlns: U.mucsub })), 15e3)).getChild("subscriptions", U.mucsub)?.getChildren("subscription") ?? []).map((e) => e.attrs.jid);
2607
2607
  return Promise.all(e.map((e) => this.groupInfo(e)));
2608
2608
  }
2609
2609
  async subscribed(e) {
2610
- return ((await this.xmpp.iqCaller.request(N("iq", {
2610
+ return ((await this.xmpp.iqCaller.request(I("iq", {
2611
2611
  type: "get",
2612
2612
  to: this.mucHost
2613
- }, N("subscriptions", { xmlns: H.mucsub })), 15e3)).getChild("subscriptions", H.mucsub)?.getChildren("subscription") ?? []).some((t) => U(t.attrs.jid) === e);
2613
+ }, I("subscriptions", { xmlns: U.mucsub })), 15e3)).getChild("subscriptions", U.mucsub)?.getChildren("subscription") ?? []).some((t) => W(t.attrs.jid) === e);
2614
2614
  }
2615
2615
  async groupInfo(e) {
2616
2616
  let t = e.split("@")[0], n = [], r = !1;
2617
2617
  try {
2618
- t = (await this.xmpp.iqCaller.request(N("iq", {
2618
+ t = (await this.xmpp.iqCaller.request(I("iq", {
2619
2619
  type: "get",
2620
2620
  to: e
2621
- }, N("query", { xmlns: H.discoInfo })), 1e4)).getChild("query", H.discoInfo)?.getChild("identity")?.attrs.name || t;
2621
+ }, I("query", { xmlns: U.discoInfo })), 1e4)).getChild("query", U.discoInfo)?.getChild("identity")?.attrs.name || t;
2622
2622
  } catch {}
2623
2623
  try {
2624
- n = ((await this.xmpp.iqCaller.request(N("iq", {
2624
+ n = ((await this.xmpp.iqCaller.request(I("iq", {
2625
2625
  type: "get",
2626
2626
  to: e
2627
- }, N("query", { xmlns: H.mucAdmin }, N("item", { affiliation: "member" }))), 1e4)).getChild("query", H.mucAdmin)?.getChildren("item") ?? []).map((e) => W(e.attrs.jid));
2628
- let t = await this.xmpp.iqCaller.request(N("iq", {
2627
+ }, I("query", { xmlns: U.mucAdmin }, I("item", { affiliation: "member" }))), 1e4)).getChild("query", U.mucAdmin)?.getChildren("item") ?? []).map((e) => G(e.attrs.jid));
2628
+ let t = await this.xmpp.iqCaller.request(I("iq", {
2629
2629
  type: "get",
2630
2630
  to: e
2631
- }, N("query", { xmlns: H.mucAdmin }, N("item", { affiliation: "owner" }))), 1e4);
2632
- for (let e of t.getChild("query", H.mucAdmin)?.getChildren("item") ?? []) n.push(W(e.attrs.jid)), W(e.attrs.jid) === this.cfg.username && (r = !0);
2631
+ }, I("query", { xmlns: U.mucAdmin }, I("item", { affiliation: "owner" }))), 1e4);
2632
+ for (let e of t.getChild("query", U.mucAdmin)?.getChildren("item") ?? []) n.push(G(e.attrs.jid)), G(e.attrs.jid) === this.cfg.username && (r = !0);
2633
2633
  } catch {}
2634
2634
  let i = await this.groupAvatar(e).catch(() => void 0);
2635
2635
  return {
@@ -2641,15 +2641,15 @@ var H = {
2641
2641
  };
2642
2642
  }
2643
2643
  async upload(e) {
2644
- let t = await this.findUploadService(), n = (await this.xmpp.iqCaller.request(N("iq", {
2644
+ let t = await this.findUploadService(), n = (await this.xmpp.iqCaller.request(I("iq", {
2645
2645
  type: "get",
2646
2646
  to: t
2647
- }, N("request", {
2648
- xmlns: H.upload,
2647
+ }, I("request", {
2648
+ xmlns: U.upload,
2649
2649
  filename: e.name,
2650
2650
  size: String(e.size),
2651
2651
  "content-type": e.type || "application/octet-stream"
2652
- })), 3e4)).getChild("slot", H.upload), r = n?.getChild("put"), i = n?.getChild("get")?.attrs.url;
2652
+ })), 3e4)).getChild("slot", U.upload), r = n?.getChild("put"), i = n?.getChild("get")?.attrs.url;
2653
2653
  if (!r || !i) throw Error("upload: no slot");
2654
2654
  let a = { "Content-Type": e.type || "application/octet-stream" };
2655
2655
  for (let e of r.getChildren("header")) a[e.attrs.name] = e.text();
@@ -2665,20 +2665,20 @@ var H = {
2665
2665
  if (this.uploadService) return this.uploadService;
2666
2666
  let e = async (e) => {
2667
2667
  try {
2668
- return (await this.xmpp.iqCaller.request(N("iq", {
2668
+ return (await this.xmpp.iqCaller.request(I("iq", {
2669
2669
  type: "get",
2670
2670
  to: e
2671
- }, N("query", { xmlns: H.discoInfo })), 1e4)).getChild("query", H.discoInfo)?.getChildren("feature").some((e) => e.attrs.var === H.upload) ?? !1;
2671
+ }, I("query", { xmlns: U.discoInfo })), 1e4)).getChild("query", U.discoInfo)?.getChildren("feature").some((e) => e.attrs.var === U.upload) ?? !1;
2672
2672
  } catch {
2673
2673
  return !1;
2674
2674
  }
2675
2675
  }, t = [`upload.${this.domain}`];
2676
2676
  try {
2677
- let e = await this.xmpp.iqCaller.request(N("iq", {
2677
+ let e = await this.xmpp.iqCaller.request(I("iq", {
2678
2678
  type: "get",
2679
2679
  to: this.domain
2680
- }, N("query", { xmlns: H.disco })), 1e4);
2681
- for (let n of e.getChild("query", H.disco)?.getChildren("item") ?? []) t.includes(n.attrs.jid) || t.push(n.attrs.jid);
2680
+ }, I("query", { xmlns: U.disco })), 1e4);
2681
+ for (let n of e.getChild("query", U.disco)?.getChildren("item") ?? []) t.includes(n.attrs.jid) || t.push(n.attrs.jid);
2682
2682
  } catch {}
2683
2683
  for (let n of t) if (await e(n)) return this.uploadService = n, n;
2684
2684
  throw Error("upload: service not found");
@@ -2699,40 +2699,40 @@ var H = {
2699
2699
  onStanza(e) {
2700
2700
  for (let t of [...this.waiters]) t.test(e) && (this.waiters.splice(this.waiters.indexOf(t), 1), t.resolve());
2701
2701
  if (e.is("presence")) {
2702
- let t = e.attrs.from ?? "", n = U(t);
2702
+ let t = e.attrs.from ?? "", n = W(t);
2703
2703
  if (!n || n === this.me || n.endsWith("@" + this.mucHost) || e.attrs.type === "error" || e.attrs.type?.startsWith("subscribe")) return;
2704
- let r = W(n), i = this.online.get(r) ?? /* @__PURE__ */ new Set();
2704
+ let r = G(n), i = this.online.get(r) ?? /* @__PURE__ */ new Set();
2705
2705
  e.attrs.type === "unavailable" ? i.delete(t) : i.add(t), this.online.set(r, i), this.h.presence(r, i.size > 0);
2706
- let a = e.getChild("x", H.hello);
2707
- a && !a.attrs.reply && e.attrs.type !== "unavailable" && this.xmpp.send(N("presence", { to: n }, N("x", {
2708
- xmlns: H.hello,
2706
+ let a = e.getChild("x", U.hello);
2707
+ a && !a.attrs.reply && e.attrs.type !== "unavailable" && this.xmpp.send(I("presence", { to: n }, I("x", {
2708
+ xmlns: U.hello,
2709
2709
  reply: "1"
2710
2710
  }))).catch(() => {});
2711
2711
  return;
2712
2712
  }
2713
2713
  if (!e.is("message")) return;
2714
- let t = !e.attrs.from || U(e.attrs.from) === this.me, n = e.getChild("result", H.mam);
2714
+ let t = !e.attrs.from || W(e.attrs.from) === this.me, n = e.getChild("result", U.mam);
2715
2715
  if (n) {
2716
2716
  if (!t) return;
2717
- let e = n.getChild("forwarded", H.forward)?.getChild("message"), r = this.mamQueries.get(n.attrs.queryid);
2717
+ let e = n.getChild("forwarded", U.forward)?.getChild("message"), r = this.mamQueries.get(n.attrs.queryid);
2718
2718
  if (e && r) {
2719
2719
  let t = this.reactionOf(e);
2720
2720
  t && this.mamReactions.get(n.attrs.queryid)?.push(t);
2721
- let i = t ? void 0 : this.toMessage(e, n.attrs.id, bn(n.getChild("forwarded", H.forward)));
2721
+ let i = t ? void 0 : this.toMessage(e, n.attrs.id, yn(n.getChild("forwarded", U.forward)));
2722
2722
  i && r.push(i);
2723
2723
  }
2724
2724
  return;
2725
2725
  }
2726
- let r = e.getChild("received", H.carbons) ?? e.getChild("sent", H.carbons);
2726
+ let r = e.getChild("received", U.carbons) ?? e.getChild("sent", U.carbons);
2727
2727
  if (r) {
2728
2728
  if (!t) return;
2729
- let e = r.getChild("forwarded", H.forward)?.getChild("message");
2729
+ let e = r.getChild("forwarded", U.forward)?.getChild("message");
2730
2730
  e && this.deliver(e);
2731
2731
  return;
2732
2732
  }
2733
- let i = e.getChild("x", H.conference);
2733
+ let i = e.getChild("x", U.conference);
2734
2734
  if (i) {
2735
- let e = U(i.attrs.jid);
2735
+ let e = W(i.attrs.jid);
2736
2736
  this.isGroup(e) && this.h.groupInvite(e);
2737
2737
  return;
2738
2738
  }
@@ -2744,24 +2744,24 @@ var H = {
2744
2744
  this.h.reaction(t);
2745
2745
  return;
2746
2746
  }
2747
- let n = this.toMessage(e, e.getChild("stanza-id", H.sid)?.attrs.id, bn(e));
2747
+ let n = this.toMessage(e, e.getChild("stanza-id", U.sid)?.attrs.id, yn(e));
2748
2748
  if (n) {
2749
2749
  this.h.message(n);
2750
2750
  return;
2751
2751
  }
2752
2752
  if (e.attrs.type !== "chat") return;
2753
- let r = U(e.attrs.from), i = r === this.me ? U(e.attrs.to) : r, a = e.getChildByAttr("xmlns", H.chatstates);
2754
- !e.getChild("body") && a && this.h.typing(W(i), a.name === "composing");
2753
+ let r = W(e.attrs.from), i = r === this.me ? W(e.attrs.to) : r, a = e.getChildByAttr("xmlns", U.chatstates);
2754
+ !e.getChild("body") && a && this.h.typing(G(i), a.name === "composing");
2755
2755
  }
2756
2756
  reactionOf(e) {
2757
- let t = e.getChild("event", H.pubsubEvent), n = e, r;
2758
- if (t && t.getChild("items")?.attrs.node === H.mucsubMessages) {
2759
- r = U(e.attrs.from);
2760
- let i = xn(t);
2761
- if (!this.isGroup(r) || !i || U(i.attrs.from) !== r) return;
2757
+ let t = e.getChild("event", U.pubsubEvent), n = e, r;
2758
+ if (t && t.getChild("items")?.attrs.node === U.mucsubMessages) {
2759
+ r = W(e.attrs.from);
2760
+ let i = bn(t);
2761
+ if (!this.isGroup(r) || !i || W(i.attrs.from) !== r) return;
2762
2762
  n = i;
2763
- } else if (e.attrs.type === "groupchat" && (r = U(e.attrs.from), !this.isGroup(r))) return;
2764
- let i = n.getChild("reactions", H.reactions), a = i?.attrs.id;
2763
+ } else if (e.attrs.type === "groupchat" && (r = W(e.attrs.from), !this.isGroup(r))) return;
2764
+ let i = n.getChild("reactions", U.reactions), a = i?.attrs.id;
2765
2765
  if (!i || !a) return;
2766
2766
  let o = [...new Set(i.getChildren("reaction").map((e) => e.text().trim()).filter((e) => e && e.length <= 16))].slice(0, 5);
2767
2767
  if (r) {
@@ -2774,50 +2774,50 @@ var H = {
2774
2774
  } : void 0;
2775
2775
  }
2776
2776
  if (n.attrs.type !== "chat") return;
2777
- let s = U(n.attrs.from), c = s === this.me || !n.attrs.from, l = W(c ? U(n.attrs.to) : s);
2777
+ let s = W(n.attrs.from), c = s === this.me || !n.attrs.from, l = G(c ? W(n.attrs.to) : s);
2778
2778
  return l ? {
2779
2779
  peer: l,
2780
2780
  target: a,
2781
- user: c ? this.cfg.username : W(s),
2781
+ user: c ? this.cfg.username : G(s),
2782
2782
  emojis: o
2783
2783
  } : void 0;
2784
2784
  }
2785
2785
  toMessage(e, t, n) {
2786
- let r = e.getChild("event", H.pubsubEvent);
2787
- if (r && r.getChild("items")?.attrs.node === H.mucsubMessages) {
2788
- let i = U(e.attrs.from);
2786
+ let r = e.getChild("event", U.pubsubEvent);
2787
+ if (r && r.getChild("items")?.attrs.node === U.mucsubMessages) {
2788
+ let i = W(e.attrs.from);
2789
2789
  if (!this.isGroup(i)) return;
2790
- let a = xn(r);
2791
- if (!a || U(a.attrs.from) !== i) return;
2790
+ let a = bn(r);
2791
+ if (!a || W(a.attrs.from) !== i) return;
2792
2792
  let o = (a.attrs.from ?? "").split("/")[1] ?? "", s = a.getChildText("body");
2793
2793
  return s == null ? void 0 : {
2794
- id: a.getChild("origin-id", H.sid)?.attrs.id ?? t ?? a.getChild("stanza-id", H.sid)?.attrs.id ?? a.attrs.id ?? crypto.randomUUID(),
2795
- oid: a.getChild("origin-id", H.sid)?.attrs.id ?? a.attrs.id,
2794
+ id: a.getChild("origin-id", U.sid)?.attrs.id ?? t ?? a.getChild("stanza-id", U.sid)?.attrs.id ?? a.attrs.id ?? crypto.randomUUID(),
2795
+ oid: a.getChild("origin-id", U.sid)?.attrs.id ?? a.attrs.id,
2796
2796
  from: i,
2797
2797
  to: this.cfg.username,
2798
2798
  body: s,
2799
- ts: bn(a) !== n && a.getChild("delay", H.delay) ? bn(a) : n,
2799
+ ts: yn(a) !== n && a.getChild("delay", U.delay) ? yn(a) : n,
2800
2800
  mine: o === this.cfg.username,
2801
- oob: a.getChild("x", H.oob)?.getChildText("url") ?? void 0,
2801
+ oob: a.getChild("x", U.oob)?.getChildText("url") ?? void 0,
2802
2802
  room: i,
2803
2803
  nick: o
2804
2804
  };
2805
2805
  }
2806
2806
  let i = e.getChildText("body");
2807
2807
  if (i == null) return;
2808
- let a = U(e.attrs.from);
2808
+ let a = W(e.attrs.from);
2809
2809
  if (e.attrs.type === "groupchat") {
2810
2810
  if (!this.isGroup(a)) return;
2811
2811
  let r = (e.attrs.from ?? "").split("/")[1] ?? "";
2812
2812
  return {
2813
- id: t ?? e.getChild("origin-id", H.sid)?.attrs.id ?? e.attrs.id ?? crypto.randomUUID(),
2814
- oid: e.getChild("origin-id", H.sid)?.attrs.id ?? e.attrs.id,
2813
+ id: t ?? e.getChild("origin-id", U.sid)?.attrs.id ?? e.attrs.id ?? crypto.randomUUID(),
2814
+ oid: e.getChild("origin-id", U.sid)?.attrs.id ?? e.attrs.id,
2815
2815
  from: a,
2816
2816
  to: this.cfg.username,
2817
2817
  body: i,
2818
2818
  ts: n,
2819
2819
  mine: r === this.cfg.username,
2820
- oob: e.getChild("x", H.oob)?.getChildText("url") ?? void 0,
2820
+ oob: e.getChild("x", U.oob)?.getChildText("url") ?? void 0,
2821
2821
  room: a,
2822
2822
  nick: r
2823
2823
  };
@@ -2825,35 +2825,35 @@ var H = {
2825
2825
  if (e.attrs.type !== "chat") return;
2826
2826
  let o = a === this.me;
2827
2827
  return {
2828
- id: t ?? e.getChild("origin-id", H.sid)?.attrs.id ?? e.attrs.id ?? crypto.randomUUID(),
2829
- oid: e.getChild("origin-id", H.sid)?.attrs.id ?? e.attrs.id,
2830
- from: W(a),
2831
- to: W(U(e.attrs.to)),
2828
+ id: t ?? e.getChild("origin-id", U.sid)?.attrs.id ?? e.attrs.id ?? crypto.randomUUID(),
2829
+ oid: e.getChild("origin-id", U.sid)?.attrs.id ?? e.attrs.id,
2830
+ from: G(a),
2831
+ to: G(W(e.attrs.to)),
2832
2832
  body: i,
2833
2833
  ts: n,
2834
2834
  mine: o,
2835
- oob: e.getChild("x", H.oob)?.getChildText("url") ?? void 0
2835
+ oob: e.getChild("x", U.oob)?.getChildText("url") ?? void 0
2836
2836
  };
2837
2837
  }
2838
- }, U = (e = "") => e.split("/")[0], yn = (e) => e.name === "SASLError" || e.condition === "not-authorized", W = (e = "") => e.split("@")[0], bn = (e) => {
2839
- let t = e?.getChild("delay", H.delay)?.attrs.stamp;
2838
+ }, W = (e = "") => e.split("/")[0], vn = (e) => e.name === "SASLError" || e.condition === "not-authorized", G = (e = "") => e.split("@")[0], yn = (e) => {
2839
+ let t = e?.getChild("delay", U.delay)?.attrs.stamp;
2840
2840
  return t ? Date.parse(t) : Date.now();
2841
2841
  };
2842
- function xn(e) {
2842
+ function bn(e) {
2843
2843
  for (let t of e.children) {
2844
2844
  if (typeof t == "string") continue;
2845
2845
  if (t.name === "message") return t;
2846
- let e = xn(t);
2846
+ let e = bn(t);
2847
2847
  if (e) return e;
2848
2848
  }
2849
2849
  }
2850
2850
  //#endregion
2851
2851
  //#region src/sound.ts
2852
- var G;
2853
- function Sn() {
2852
+ var K;
2853
+ function xn() {
2854
2854
  try {
2855
- G ??= new AudioContext(), G.state === "suspended" && G.resume();
2856
- let e = G.currentTime;
2855
+ K ??= new AudioContext(), K.state === "suspended" && K.resume();
2856
+ let e = K.currentTime;
2857
2857
  for (let [t, n, r] of [[
2858
2858
  880,
2859
2859
  0,
@@ -2863,14 +2863,14 @@ function Sn() {
2863
2863
  .1,
2864
2864
  .16
2865
2865
  ]]) {
2866
- let i = G.createOscillator(), a = G.createGain();
2867
- i.type = "sine", i.frequency.value = t, a.gain.setValueAtTime(1e-4, e + n), a.gain.exponentialRampToValueAtTime(.12, e + n + .01), a.gain.exponentialRampToValueAtTime(1e-4, e + n + r), i.connect(a).connect(G.destination), i.start(e + n), i.stop(e + n + r + .02);
2866
+ let i = K.createOscillator(), a = K.createGain();
2867
+ i.type = "sine", i.frequency.value = t, a.gain.setValueAtTime(1e-4, e + n), a.gain.exponentialRampToValueAtTime(.12, e + n + .01), a.gain.exponentialRampToValueAtTime(1e-4, e + n + r), i.connect(a).connect(K.destination), i.start(e + n), i.stop(e + n + r + .02);
2868
2868
  }
2869
2869
  } catch {}
2870
2870
  }
2871
2871
  //#endregion
2872
2872
  //#region node_modules/zustand/esm/vanilla.mjs
2873
- var Cn = (e) => {
2873
+ var Sn = (e) => {
2874
2874
  let t, n = /* @__PURE__ */ new Set(), r = (e, r) => {
2875
2875
  let i = typeof e == "function" ? e(t) : e;
2876
2876
  if (!Object.is(i, t)) {
@@ -2887,15 +2887,15 @@ var Cn = (e) => {
2887
2887
  }
2888
2888
  }, o = t = e(r, i, a);
2889
2889
  return a;
2890
- }, wn = (e) => e ? Cn(e) : Cn, { useDebugValue: Tn } = e, { useSyncExternalStoreWithSelector: En } = l, Dn = (e) => e;
2891
- function On(e, t = Dn, n) {
2892
- let r = En(e.subscribe, e.getState, e.getServerState || e.getInitialState, t, n);
2893
- return Tn(r), r;
2890
+ }, Cn = (e) => e ? Sn(e) : Sn, { useDebugValue: wn } = e, { useSyncExternalStoreWithSelector: Tn } = l, En = (e) => e;
2891
+ function Dn(e, t = En, n) {
2892
+ let r = Tn(e.subscribe, e.getState, e.getServerState || e.getInitialState, t, n);
2893
+ return wn(r), r;
2894
2894
  }
2895
- var kn = (e) => {
2896
- let t = typeof e == "function" ? wn(e) : e, n = (e, n) => On(t, e, n);
2895
+ var On = (e) => {
2896
+ let t = typeof e == "function" ? Cn(e) : e, n = (e, n) => Dn(t, e, n);
2897
2897
  return Object.assign(n, t), n;
2898
- }, An = (e) => e ? kn(e) : kn, jn = (e) => e.room ?? (e.mine ? e.to : e.from), K = (e, t) => ({
2898
+ }, kn = (e) => e ? On(e) : On, An = (e) => e.room ?? (e.mine ? e.to : e.from), q = (e, t) => ({
2899
2899
  peer: e,
2900
2900
  kind: t && e.endsWith("@" + t) ? "group" : "chat",
2901
2901
  messages: [],
@@ -2903,13 +2903,13 @@ var kn = (e) => {
2903
2903
  typing: !1,
2904
2904
  loaded: !1,
2905
2905
  complete: !1
2906
- }), Mn = (e, t, n, r) => {
2906
+ }), jn = (e, t, n, r) => {
2907
2907
  if (e.includes(t)) return e;
2908
2908
  let i = [t, ...e];
2909
2909
  if (i.length <= n) return i;
2910
2910
  let a = [...i].reverse().find((e) => e !== r);
2911
2911
  return i.filter((e) => e !== a);
2912
- }, q = An((e, t) => ({
2912
+ }, J = kn((e, t) => ({
2913
2913
  me: "",
2914
2914
  mucHost: "",
2915
2915
  status: "connecting",
@@ -2951,14 +2951,14 @@ var kn = (e) => {
2951
2951
  ensure: (n) => {
2952
2952
  let r = t().conversations[n];
2953
2953
  if (r) return r;
2954
- let i = K(n, t().mucHost);
2954
+ let i = q(n, t().mucHost);
2955
2955
  return e((e) => ({ conversations: {
2956
2956
  ...e.conversations,
2957
2957
  [n]: i
2958
2958
  } })), i;
2959
2959
  },
2960
2960
  setGroup: (t, n, r, i, a) => e((e) => {
2961
- let o = e.conversations[t] ?? K(t, e.mucHost);
2961
+ let o = e.conversations[t] ?? q(t, e.mucHost);
2962
2962
  return { conversations: {
2963
2963
  ...e.conversations,
2964
2964
  [t]: {
@@ -2974,9 +2974,9 @@ var kn = (e) => {
2974
2974
  seed: (t, n) => e((e) => {
2975
2975
  let r = { ...e.conversations };
2976
2976
  for (let i of t) {
2977
- let t = jn(i);
2977
+ let t = An(i);
2978
2978
  if (!t || t === n) continue;
2979
- let a = r[t] ?? K(t, e.mucHost);
2979
+ let a = r[t] ?? q(t, e.mucHost);
2980
2980
  if (a.messages.some((e) => e.id === i.id)) continue;
2981
2981
  if (a.loaded) {
2982
2982
  r[t] = {
@@ -2994,10 +2994,10 @@ var kn = (e) => {
2994
2994
  return { conversations: r };
2995
2995
  }),
2996
2996
  addMessage: (t, n, r) => e((e) => {
2997
- let i = e.conversations[t] ?? K(t, e.mucHost), a = i.messages.filter((e) => e.id !== n.id && !(e.pending && n.mine && e.body === n.body && e.oob === n.oob)), o = a.length;
2997
+ let i = e.conversations[t] ?? q(t, e.mucHost), a = i.messages.filter((e) => e.id !== n.id && !(e.pending && n.mine && e.body === n.body && e.oob === n.oob)), o = a.length;
2998
2998
  for (; o > 0 && a[o - 1].ts > n.ts;) o--;
2999
2999
  a.splice(o, 0, n);
3000
- let s = e.open === t, c = r?.live && !n.mine && !s ? i.unread + 1 : i.unread, l = Mn(e.order, t, e.maxHeads, e.open);
3000
+ let s = e.open === t, c = r?.live && !n.mine && !s ? i.unread + 1 : i.unread, l = jn(e.order, t, e.maxHeads, e.open);
3001
3001
  return {
3002
3002
  conversations: {
3003
3003
  ...e.conversations,
@@ -3012,7 +3012,7 @@ var kn = (e) => {
3012
3012
  };
3013
3013
  }),
3014
3014
  prependHistory: (t, n, r, i) => e((e) => {
3015
- let a = e.conversations[t] ?? K(t, e.mucHost), o = new Set(a.messages.map((e) => e.id)), s = [...n.filter((e) => !o.has(e.id)), ...a.messages].sort((e, t) => e.ts - t.ts);
3015
+ let a = e.conversations[t] ?? q(t, e.mucHost), o = new Set(a.messages.map((e) => e.id)), s = [...n.filter((e) => !o.has(e.id)), ...a.messages].sort((e, t) => e.ts - t.ts);
3016
3016
  return { conversations: {
3017
3017
  ...e.conversations,
3018
3018
  [t]: {
@@ -3028,7 +3028,7 @@ var kn = (e) => {
3028
3028
  if (!t.length) return {};
3029
3029
  let n = { ...e.conversations };
3030
3030
  for (let r of t) {
3031
- let t = n[r.peer] ?? K(r.peer, e.mucHost), i = { ...t.reactions ?? {} }, a = { ...i[r.target] ?? {} };
3031
+ let t = n[r.peer] ?? q(r.peer, e.mucHost), i = { ...t.reactions ?? {} }, a = { ...i[r.target] ?? {} };
3032
3032
  r.emojis.length ? a[r.user] = r.emojis : delete a[r.user], i[r.target] = a, n[r.peer] = {
3033
3033
  ...t,
3034
3034
  reactions: i
@@ -3046,9 +3046,9 @@ var kn = (e) => {
3046
3046
  openChat: (t) => e((e) => ({
3047
3047
  conversations: e.conversations[t] ? e.conversations : {
3048
3048
  ...e.conversations,
3049
- [t]: K(t, e.mucHost)
3049
+ [t]: q(t, e.mucHost)
3050
3050
  },
3051
- order: Mn(e.order, t, e.maxHeads, e.open),
3051
+ order: jn(e.order, t, e.maxHeads, e.open),
3052
3052
  open: t,
3053
3053
  picker: !1
3054
3054
  })),
@@ -3077,15 +3077,15 @@ var kn = (e) => {
3077
3077
  }));
3078
3078
  //#endregion
3079
3079
  //#region src/api.ts
3080
- async function Nn(e, t, n) {
3080
+ async function Mn(e, t, n) {
3081
3081
  let r = await fetch(`https://${e}/api${n}`, { headers: { Authorization: `Bearer ${t}` } });
3082
3082
  if (!r.ok) throw Error(`${n}: HTTP ${r.status}`);
3083
3083
  return await r.json();
3084
3084
  }
3085
- async function Pn(e, t, n) {
3086
- let r = await Nn(e, t, "/user/endpoints/all"), i = {};
3085
+ async function Nn(e, t, n) {
3086
+ let r = await Mn(e, t, "/user/endpoints/all"), i = {};
3087
3087
  try {
3088
- i = await Nn(e, t, "/user/all_avatars");
3088
+ i = await Mn(e, t, "/user/all_avatars");
3089
3089
  } catch {}
3090
3090
  return Object.values(r).filter((e) => e.username && e.username !== n).map((e) => ({
3091
3091
  username: e.username,
@@ -3094,12 +3094,12 @@ async function Pn(e, t, n) {
3094
3094
  presence: e.mainPresence
3095
3095
  })).sort((e, t) => e.name.localeCompare(t.name));
3096
3096
  }
3097
- async function Fn(e, t) {
3097
+ async function Pn(e, t) {
3098
3098
  let n = await fetch(`https://${e}/chat-gw/push/mobile`, { headers: { Authorization: `Bearer ${t}` } });
3099
3099
  if (!n.ok) throw Error(`push/mobile: HTTP ${n.status}`);
3100
3100
  return (await n.json()).users;
3101
3101
  }
3102
- async function In(e, t, n) {
3102
+ async function Fn(e, t, n) {
3103
3103
  let r = await fetch(`https://${e}/chat-gw/conversations/${encodeURIComponent(n)}`, {
3104
3104
  method: "DELETE",
3105
3105
  headers: { Authorization: `Bearer ${t}` }
@@ -3108,16 +3108,16 @@ async function In(e, t, n) {
3108
3108
  }
3109
3109
  //#endregion
3110
3110
  //#region src/push.ts
3111
- var Ln = (e) => {
3111
+ var In = (e) => {
3112
3112
  let t = atob((e + "=".repeat((4 - e.length % 4) % 4)).replace(/-/g, "+").replace(/_/g, "/"));
3113
3113
  return Uint8Array.from(t, (e) => e.charCodeAt(0));
3114
- }, Rn = !1;
3115
- function zn() {
3116
- Rn || (Rn = !0, navigator.serviceWorker.addEventListener("message", (e) => {
3114
+ }, Ln = !1;
3115
+ function Rn() {
3116
+ Ln || (Ln = !0, navigator.serviceWorker.addEventListener("message", (e) => {
3117
3117
  e.data?.type === "chat-island-open" && typeof e.data.username == "string" && window.dispatchEvent(new CustomEvent("chat-island-open", { detail: { username: e.data.username } }));
3118
3118
  }));
3119
3119
  }
3120
- async function Bn(e, t) {
3120
+ async function zn(e, t) {
3121
3121
  if (!("serviceWorker" in navigator) || !("PushManager" in window)) throw Error("push not supported by this browser");
3122
3122
  if (Notification.permission === "denied" || Notification.permission !== "granted" && await Notification.requestPermission() !== "granted") return null;
3123
3123
  let n = `https://${e.host}/chat-gw`, r = await fetch(`${n}/push/vapid`);
@@ -3126,7 +3126,7 @@ async function Bn(e, t) {
3126
3126
  await navigator.serviceWorker.ready;
3127
3127
  let o = await a.pushManager.getSubscription() ?? await a.pushManager.subscribe({
3128
3128
  userVisibleOnly: !0,
3129
- applicationServerKey: Ln(i.publicKey)
3129
+ applicationServerKey: In(i.publicKey)
3130
3130
  }), s = await fetch(`${n}/push/web`, {
3131
3131
  method: "POST",
3132
3132
  headers: {
@@ -3137,24 +3137,24 @@ async function Bn(e, t) {
3137
3137
  });
3138
3138
  if (!s.ok) throw Error(`push/web: HTTP ${s.status} ${(await s.text()).slice(0, 120)}`);
3139
3139
  let c = await s.json();
3140
- return zn(), {
3140
+ return Rn(), {
3141
3141
  node: c.node,
3142
3142
  service: c.service
3143
3143
  };
3144
3144
  }
3145
3145
  //#endregion
3146
3146
  //#region src/events.ts
3147
- function J(e, t) {
3147
+ function Y(e, t) {
3148
3148
  window.dispatchEvent(new CustomEvent(e, { detail: t }));
3149
3149
  }
3150
- function Y(e, t) {
3150
+ function X(e, t) {
3151
3151
  let n = (e) => t(e.detail);
3152
3152
  return window.addEventListener(e, n), () => window.removeEventListener(e, n);
3153
3153
  }
3154
3154
  //#endregion
3155
3155
  //#region src/components/Avatar.tsx
3156
- var Vn = (e) => e.split(/\s+/).slice(0, 2).map((e) => e[0]?.toUpperCase() ?? "").join("");
3157
- function X({ contact: e, username: t, size: n = 40 }) {
3156
+ var Bn = (e) => e.split(/\s+/).slice(0, 2).map((e) => e[0]?.toUpperCase() ?? "").join("");
3157
+ function Vn({ contact: e, username: t, size: n = 40 }) {
3158
3158
  let r = e?.name || t, i = {
3159
3159
  width: n,
3160
3160
  height: n,
@@ -3168,7 +3168,7 @@ function X({ contact: e, username: t, size: n = 40 }) {
3168
3168
  }) : /* @__PURE__ */ d("div", {
3169
3169
  style: i,
3170
3170
  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",
3171
- children: Vn(r)
3171
+ children: Bn(r)
3172
3172
  });
3173
3173
  }
3174
3174
  function Hn({ online: e, presence: t, mobile: n }) {
@@ -3188,7 +3188,7 @@ function Un({ name: e, size: t = 40, avatar: n }) {
3188
3188
  }) : /* @__PURE__ */ d("div", {
3189
3189
  style: r,
3190
3190
  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",
3191
- children: Vn(e || "G")
3191
+ children: Bn(e || "G")
3192
3192
  });
3193
3193
  }
3194
3194
  //#endregion
@@ -3368,7 +3368,7 @@ var Q = {
3368
3368
  //#endregion
3369
3369
  //#region src/components/Dock.tsx
3370
3370
  function Kn({ onDragStart: e, pushButton: t = !0 }) {
3371
- 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 } = q(w((e) => ({
3371
+ 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) => ({
3372
3372
  order: e.order,
3373
3373
  open: e.open,
3374
3374
  conversations: e.conversations,
@@ -3385,7 +3385,7 @@ function Kn({ onDragStart: e, pushButton: t = !0 }) {
3385
3385
  newChatButton: e.newChatButton
3386
3386
  })));
3387
3387
  return /* @__PURE__ */ f("div", {
3388
- className: "ci-flex ci-flex-col-reverse ci-items-center ci-gap-3 ci-mb-3 ci-cursor-grab active:ci-cursor-grabbing ci-touch-none",
3388
+ 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" : ""}`,
3389
3389
  onPointerDown: e,
3390
3390
  children: [
3391
3391
  n.map((e) => {
@@ -3395,13 +3395,13 @@ function Kn({ onDragStart: e, pushButton: t = !0 }) {
3395
3395
  children: [/* @__PURE__ */ f("button", {
3396
3396
  type: "button",
3397
3397
  title: t?.kind === "group" ? t.name ?? e : a[e]?.name ?? e,
3398
- onClick: () => n ? q.getState().closeChat() : c(e),
3398
+ onClick: () => n ? J.getState().closeChat() : c(e),
3399
3399
  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"}`,
3400
3400
  children: [t?.kind === "group" ? /* @__PURE__ */ d(Un, {
3401
3401
  name: t.name ?? e,
3402
3402
  size: 48,
3403
3403
  avatar: t.avatar
3404
- }) : /* @__PURE__ */ f(u, { children: [/* @__PURE__ */ d(X, {
3404
+ }) : /* @__PURE__ */ f(u, { children: [/* @__PURE__ */ d(Vn, {
3405
3405
  contact: a[e],
3406
3406
  username: e,
3407
3407
  size: 48
@@ -3861,7 +3861,7 @@ function pr({ forMsg: e, me: t, onReact: n, nameOf: r, mine: i }) {
3861
3861
  }) : null;
3862
3862
  }
3863
3863
  function mr({ messages: e, typing: t, onLoadOlder: n, hasOlder: r, group: a, reactions: o, me: l = "", onReact: u }) {
3864
- let p = q((e) => e.contacts), m = s(null), h = s(!0), [g, _] = c(null), [v, y] = c(null), b = (e) => p[e]?.name ?? e;
3864
+ let p = J((e) => e.contacts), m = s(null), h = s(!0), [g, _] = c(null), [v, y] = c(null), b = (e) => p[e]?.name ?? e;
3865
3865
  i(() => {
3866
3866
  let e = m.current;
3867
3867
  e && h.current && (e.scrollTop = e.scrollHeight);
@@ -3913,7 +3913,7 @@ function mr({ messages: e, typing: t, onLoadOlder: n, hasOlder: r, group: a, rea
3913
3913
  c && /* @__PURE__ */ d("span", {
3914
3914
  className: "ci-w-7 ci-shrink-0",
3915
3915
  title: c,
3916
- children: !s && /* @__PURE__ */ d(X, {
3916
+ children: !s && /* @__PURE__ */ d(Vn, {
3917
3917
  contact: p[t.nick],
3918
3918
  username: t.nick,
3919
3919
  size: 28
@@ -4157,15 +4157,15 @@ function kr({ onSend: e, onTyping: t, onFile: n, disabled: r }) {
4157
4157
  a(() => {
4158
4158
  m.current !== null && (g.current?.setSelectionRange(m.current, m.current), m.current = null);
4159
4159
  }, [o]);
4160
- let ee = (e) => {
4160
+ let k = (e) => {
4161
4161
  let t = g.current, n = t?.selectionStart ?? o.length, r = t?.selectionEnd ?? n;
4162
4162
  O(o.slice(0, n) + e + o.slice(r)), requestAnimationFrame(() => {
4163
4163
  t?.focus(), t?.setSelectionRange(n + e.length, n + e.length);
4164
4164
  });
4165
- }, k = () => {
4165
+ }, A = () => {
4166
4166
  let t = o.trim();
4167
4167
  t && (l(""), Promise.resolve(e(t)).catch(() => l((e) => e || t)), window.clearTimeout(_.current), v.current = !1);
4168
- }, te = async () => {
4168
+ }, ee = async () => {
4169
4169
  if (w.current || y) return;
4170
4170
  w.current = !0;
4171
4171
  let e;
@@ -4191,7 +4191,7 @@ function kr({ onSend: e, onTyping: t, onFile: n, disabled: r }) {
4191
4191
  } finally {
4192
4192
  w.current = !1;
4193
4193
  }
4194
- }, A = (e) => {
4194
+ }, j = (e) => {
4195
4195
  C.current = e, y?.r.stop();
4196
4196
  };
4197
4197
  return y ? /* @__PURE__ */ f("div", {
@@ -4201,7 +4201,7 @@ function kr({ onSend: e, onTyping: t, onFile: n, disabled: r }) {
4201
4201
  variant: "transparent",
4202
4202
  title: "Discard",
4203
4203
  "aria-label": "Discard",
4204
- onClick: () => A(!0),
4204
+ onClick: () => j(!0),
4205
4205
  className: "ci-h-10 ci-w-10",
4206
4206
  children: Q.close
4207
4207
  }),
@@ -4213,7 +4213,7 @@ function kr({ onSend: e, onTyping: t, onFile: n, disabled: r }) {
4213
4213
  variant: "green",
4214
4214
  title: "Send voice note",
4215
4215
  "aria-label": "Send voice note",
4216
- onClick: () => A(!1),
4216
+ onClick: () => j(!1),
4217
4217
  className: "ci-h-10 ci-w-10",
4218
4218
  children: Q.send
4219
4219
  })
@@ -4223,7 +4223,7 @@ function kr({ onSend: e, onTyping: t, onFile: n, disabled: r }) {
4223
4223
  children: [
4224
4224
  u && /* @__PURE__ */ d($n, {
4225
4225
  className: "ci-absolute ci-bottom-full ci-left-3 ci-mb-1",
4226
- onPick: ee,
4226
+ onPick: k,
4227
4227
  onClose: () => p(!1)
4228
4228
  }),
4229
4229
  /* @__PURE__ */ d("input", {
@@ -4260,7 +4260,7 @@ function kr({ onSend: e, onTyping: t, onFile: n, disabled: r }) {
4260
4260
  onChange: (e) => O(e.target.value),
4261
4261
  onKeyDown: (e) => {
4262
4262
  let t = (o.match(/```/g) ?? []).length % 2 == 1;
4263
- e.key === "Enter" && !e.shiftKey && !t && (e.preventDefault(), k());
4263
+ e.key === "Enter" && !e.shiftKey && !t && (e.preventDefault(), A());
4264
4264
  },
4265
4265
  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",
4266
4266
  style: { height: Math.min(128, 40 + 20 * (o.split("\n").length - 1)) }
@@ -4269,14 +4269,14 @@ function kr({ onSend: e, onTyping: t, onFile: n, disabled: r }) {
4269
4269
  o.trim() ? /* @__PURE__ */ d(Z, {
4270
4270
  variant: "default",
4271
4271
  disabled: r,
4272
- onClick: k,
4272
+ onClick: A,
4273
4273
  title: "Send",
4274
4274
  className: "ci-h-10 ci-w-10",
4275
4275
  children: Q.send
4276
4276
  }) : /* @__PURE__ */ d(Z, {
4277
4277
  variant: "default",
4278
4278
  disabled: r || typeof MediaRecorder > "u",
4279
- onClick: te,
4279
+ onClick: ee,
4280
4280
  title: "Record a voice note",
4281
4281
  "aria-label": "Record a voice note",
4282
4282
  className: "ci-h-10 ci-w-10",
@@ -4295,7 +4295,7 @@ var Ar = (e) => !!e && ![
4295
4295
  "onhold"
4296
4296
  ].includes(e);
4297
4297
  function jr({ peer: e, actions: t, onDragStart: n }) {
4298
- let { c: r, contacts: a, online: o, mobile: s, status: l, closeChat: p, openChat: m, markRead: h, order: g, me: _ } = q(w((t) => ({
4298
+ let { c: r, contacts: a, online: o, mobile: s, status: l, closeChat: p, openChat: m, markRead: h, order: g, me: _ } = J(w((t) => ({
4299
4299
  c: t.conversations[e],
4300
4300
  contacts: t.contacts,
4301
4301
  online: t.online,
@@ -4325,7 +4325,7 @@ function jr({ peer: e, actions: t, onDragStart: n }) {
4325
4325
  "aria-hidden": "true"
4326
4326
  }),
4327
4327
  /* @__PURE__ */ f("div", {
4328
- className: "ci-flex ci-items-center ci-gap-3 ci-px-4 ci-py-3 ci-cursor-grab active:ci-cursor-grabbing ci-touch-none ci-rounded-t-3xl",
4328
+ 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" : ""}`,
4329
4329
  onPointerDown: n,
4330
4330
  children: [
4331
4331
  r.kind === "group" ? /* @__PURE__ */ d(Un, {
@@ -4334,7 +4334,7 @@ function jr({ peer: e, actions: t, onDragStart: n }) {
4334
4334
  avatar: r.avatar
4335
4335
  }) : /* @__PURE__ */ f("span", {
4336
4336
  className: "ci-relative",
4337
- children: [/* @__PURE__ */ d(X, {
4337
+ children: [/* @__PURE__ */ d(Vn, {
4338
4338
  contact: y,
4339
4339
  username: e,
4340
4340
  size: 36
@@ -4365,7 +4365,7 @@ function jr({ peer: e, actions: t, onDragStart: n }) {
4365
4365
  variant: "call",
4366
4366
  title: `Call ${y.number}`,
4367
4367
  "aria-label": "Call",
4368
- onClick: () => J("chat-island-call", {
4368
+ onClick: () => Y("chat-island-call", {
4369
4369
  username: e,
4370
4370
  number: y.number
4371
4371
  }),
@@ -4387,7 +4387,7 @@ function jr({ peer: e, actions: t, onDragStart: n }) {
4387
4387
  children: [
4388
4388
  /* @__PURE__ */ f("span", {
4389
4389
  className: "ci-relative",
4390
- children: [/* @__PURE__ */ d(X, {
4390
+ children: [/* @__PURE__ */ d(Vn, {
4391
4391
  contact: a[e],
4392
4392
  username: e,
4393
4393
  size: 28
@@ -4411,7 +4411,7 @@ function jr({ peer: e, actions: t, onDragStart: n }) {
4411
4411
  variant: "call",
4412
4412
  title: `Call ${a[e]?.number}`,
4413
4413
  "aria-label": "Call",
4414
- onClick: () => J("chat-island-call", {
4414
+ onClick: () => Y("chat-island-call", {
4415
4415
  username: e,
4416
4416
  number: a[e].number
4417
4417
  }),
@@ -4448,7 +4448,7 @@ async function Mr(e) {
4448
4448
  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);
4449
4449
  }
4450
4450
  function Nr({ onOpen: e, onCreateGroup: t }) {
4451
- let { contacts: n, online: r, mobile: i, setPicker: a } = q(), [l, p] = c(""), [m, h] = c([]), [g, _] = c(""), [v, y] = c(!1), [b, x] = c(), S = s(null), C = o(() => {
4451
+ 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(() => {
4452
4452
  let e = Object.values(n), t = l.trim().toLowerCase();
4453
4453
  return t ? e.filter((e) => (e.name ?? "").toLowerCase().includes(t) || e.username.includes(t)) : e;
4454
4454
  }, [n, l]), w = (e) => h((t) => t.includes(e) ? t.filter((t) => t !== e) : [...t, e]), T = async () => {
@@ -4504,7 +4504,7 @@ function Nr({ onOpen: e, onCreateGroup: t }) {
4504
4504
  children: [
4505
4505
  /* @__PURE__ */ f("span", {
4506
4506
  className: "ci-relative",
4507
- children: [/* @__PURE__ */ d(X, {
4507
+ children: [/* @__PURE__ */ d(Vn, {
4508
4508
  contact: e,
4509
4509
  username: e.username,
4510
4510
  size: 36
@@ -4588,9 +4588,50 @@ function Nr({ onOpen: e, onCreateGroup: t }) {
4588
4588
  });
4589
4589
  }
4590
4590
  //#endregion
4591
+ //#region src/theme.ts
4592
+ var Pr = "chat-island-theme", Fr = () => {
4593
+ try {
4594
+ let e = localStorage.getItem(Pr);
4595
+ return e === "light" || e === "dark" || e === "system" ? e : void 0;
4596
+ } catch {
4597
+ return;
4598
+ }
4599
+ };
4600
+ function Ir(e) {
4601
+ let [t, n] = c(() => e ?? Fr()), [r, a] = c(!1);
4602
+ return i(() => n(e ?? Fr()), [e]), i(() => {
4603
+ let e = (e) => {
4604
+ let t = e.detail?.theme;
4605
+ if (t === "light" || t === "dark" || t === "system") {
4606
+ try {
4607
+ localStorage.setItem(Pr, t);
4608
+ } catch {}
4609
+ n(t);
4610
+ }
4611
+ };
4612
+ return window.addEventListener("chat-island-theme-change", e), () => window.removeEventListener("chat-island-theme-change", e);
4613
+ }, []), i(() => {
4614
+ if (t === "light" || t === "dark") {
4615
+ a(t === "dark");
4616
+ return;
4617
+ }
4618
+ if (t === "system") {
4619
+ let e = window.matchMedia("(prefers-color-scheme: dark)"), t = () => a(e.matches);
4620
+ return t(), e.addEventListener("change", t), () => e.removeEventListener("change", t);
4621
+ }
4622
+ let e = document.documentElement, n = () => a(e.classList.contains("dark"));
4623
+ n();
4624
+ let r = new MutationObserver(n);
4625
+ return r.observe(e, {
4626
+ attributes: !0,
4627
+ attributeFilter: ["class"]
4628
+ }), () => r.disconnect();
4629
+ }, [t]), r;
4630
+ }
4631
+ //#endregion
4591
4632
  //#region src/ChatIsland.tsx
4592
- function Pr() {
4593
- let e = q.getState();
4633
+ function Lr() {
4634
+ let e = J.getState();
4594
4635
  return Object.values(e.conversations).map((t) => {
4595
4636
  let n = t.messages[t.messages.length - 1], r = e.contacts[t.peer];
4596
4637
  return {
@@ -4604,7 +4645,7 @@ function Pr() {
4604
4645
  unread: t.unread,
4605
4646
  members: t.members,
4606
4647
  last: n ? {
4607
- body: Lr(n.body),
4648
+ body: Br(n.body),
4608
4649
  ts: n.ts,
4609
4650
  mine: n.mine,
4610
4651
  oob: n.oob,
@@ -4613,25 +4654,25 @@ function Pr() {
4613
4654
  };
4614
4655
  }).filter((e) => e.last || e.kind === "group").sort((e, t) => (t.last?.ts ?? 0) - (e.last?.ts ?? 0));
4615
4656
  }
4616
- var Fr = class extends t {
4657
+ var Rr = class extends t {
4617
4658
  state = { failed: !1 };
4618
4659
  failures = [];
4619
4660
  static getDerivedStateFromError() {
4620
4661
  return { failed: !0 };
4621
4662
  }
4622
4663
  componentDidCatch(e) {
4623
- J("chat-island-error", {
4664
+ Y("chat-island-error", {
4624
4665
  scope: "render",
4625
4666
  message: e.message
4626
4667
  });
4627
4668
  let t = Date.now();
4628
- this.failures = [...this.failures.filter((e) => t - e < 1e4), t], !(this.failures.length >= 3) && (q.getState().closeChat(), window.setTimeout(() => this.setState({ failed: !1 }), 0));
4669
+ this.failures = [...this.failures.filter((e) => t - e < 1e4), t], !(this.failures.length >= 3) && (J.getState().closeChat(), window.setTimeout(() => this.setState({ failed: !1 }), 0));
4629
4670
  }
4630
4671
  render() {
4631
4672
  return this.state.failed ? null : this.props.children;
4632
4673
  }
4633
4674
  };
4634
- function Ir(e) {
4675
+ function zr(e) {
4635
4676
  try {
4636
4677
  let [t, n, r] = atob(e).split(":");
4637
4678
  return t && n && r ? {
@@ -4643,135 +4684,135 @@ function Ir(e) {
4643
4684
  return null;
4644
4685
  }
4645
4686
  }
4646
- var Lr = (e) => (sr(e) ? "Attachment" : $(e)).replace(/```[^\n]*\n?/g, "").replace(/(\*\*|__|~~|`)/g, "").replace(/(^|\s)[*_](\S[^*_]*)[*_]/g, "$1$2").replace(/\s+/g, " ").trim();
4647
- function Rr({ dataConfig: e, position: t = "bottom-right", dark: n, serviceWorker: r, maxHeads: a = 5, newChatButton: l = !0, notifications: u = "click", sound: p = !0 }) {
4648
- let m = o(() => Ir(e), [e]), h = s(m), g = s(p), _ = s(u);
4687
+ var Br = (e) => (sr(e) ? "Attachment" : $(e)).replace(/```[^\n]*\n?/g, "").replace(/(\*\*|__|~~|`)/g, "").replace(/(^|\s)[*_](\S[^*_]*)[*_]/g, "$1$2").replace(/\s+/g, " ").trim();
4688
+ function Vr({ 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 }) {
4689
+ let h = o(() => zr(e), [e]), g = Ir(n), _ = s(h), v = s(p), y = s(u);
4649
4690
  i(() => {
4650
- h.current = m, g.current = p, _.current = u;
4691
+ _.current = h, v.current = p, y.current = u;
4651
4692
  }, [
4652
- m,
4693
+ h,
4653
4694
  p,
4654
4695
  u
4655
- ]), i(() => q.setState({
4696
+ ]), i(() => J.setState({
4656
4697
  maxHeads: a,
4657
4698
  newChatButton: l
4658
4699
  }), [a, l]);
4659
- let [v, y] = c(0);
4700
+ let [b, x] = c(0);
4660
4701
  i(() => {
4661
- let e = (e) => e.persisted && y((e) => e + 1);
4702
+ let e = (e) => e.persisted && x((e) => e + 1);
4662
4703
  return window.addEventListener("pageshow", e), () => window.removeEventListener("pageshow", e);
4663
4704
  }, []);
4664
- let b = s(null), x = s(/* @__PURE__ */ new Set()), S = s(!1), C = s(null), T = s(null), D = E(T, `chat-island-pos:${m?.host ?? ""}:${m?.username ?? ""}`), { open: O, picker: ee, status: k } = q(w((e) => ({
4705
+ let S = s(null), C = s(/* @__PURE__ */ new Set()), T = s(!1), D = s(null), O = s(null), k = E(O, `chat-island-pos:${h?.host ?? ""}:${h?.username ?? ""}`), { open: A, picker: ee, status: j } = J(w((e) => ({
4665
4706
  open: e.open,
4666
4707
  picker: e.picker,
4667
4708
  status: e.status
4668
- }))), te = o(() => ({
4709
+ }))), M = o(() => ({
4669
4710
  send: async (e, t) => {
4670
- let n = b.current;
4711
+ let n = S.current;
4671
4712
  if (!n) throw Error("not connected");
4672
4713
  try {
4673
- q.getState().addMessage(e, await n.send(e, $(t)));
4714
+ J.getState().addMessage(e, await n.send(e, $(t)));
4674
4715
  } catch (e) {
4675
- throw J("chat-island-error", {
4716
+ throw Y("chat-island-error", {
4676
4717
  scope: "send",
4677
4718
  message: e.message
4678
4719
  }), e;
4679
4720
  }
4680
4721
  },
4681
- typing: (e, t) => q.getState().online[e] && b.current?.typing(e, t).catch(() => {}),
4722
+ typing: (e, t) => J.getState().online[e] && S.current?.typing(e, t).catch(() => {}),
4682
4723
  upload: async (e, t) => {
4683
- let n = b.current;
4724
+ let n = S.current;
4684
4725
  if (n) try {
4685
4726
  let r = await n.upload(t);
4686
- q.getState().addMessage(e, await n.send(e, t.name, r));
4727
+ J.getState().addMessage(e, await n.send(e, t.name, r));
4687
4728
  } catch (e) {
4688
- J("chat-island-error", {
4729
+ Y("chat-island-error", {
4689
4730
  scope: "upload",
4690
4731
  message: e.message
4691
4732
  });
4692
4733
  }
4693
4734
  },
4694
4735
  createGroup: async (e, t, n) => {
4695
- let r = b.current, i = h.current;
4736
+ let r = S.current, i = _.current;
4696
4737
  if (r && i) try {
4697
- let a = await r.createGroup(e, t, n), o = q.getState();
4738
+ let a = await r.createGroup(e, t, n), o = J.getState();
4698
4739
  o.setGroup(a, e, [...t, i.username], n), o.openChat(a);
4699
4740
  } catch (e) {
4700
- J("chat-island-error", {
4741
+ Y("chat-island-error", {
4701
4742
  scope: "group",
4702
4743
  message: e.message
4703
4744
  });
4704
4745
  }
4705
4746
  },
4706
4747
  remove: async (e) => {
4707
- let t = b.current, n = h.current;
4748
+ let t = S.current, n = _.current;
4708
4749
  if (!t || !n) return;
4709
- let r = q.getState().conversations[e];
4750
+ let r = J.getState().conversations[e];
4710
4751
  try {
4711
- r?.kind === "group" && await t.leaveGroup(e, !!r.owner).catch(() => {}), await In(n.host, n.token, e), q.getState().removeConversation(e);
4752
+ r?.kind === "group" && await t.leaveGroup(e, !!r.owner).catch(() => {}), await Fn(n.host, n.token, e), J.getState().removeConversation(e);
4712
4753
  } catch (e) {
4713
- J("chat-island-error", {
4754
+ Y("chat-island-error", {
4714
4755
  scope: "delete",
4715
4756
  message: e.message
4716
4757
  });
4717
4758
  }
4718
4759
  },
4719
4760
  react: async (e, t, n) => {
4720
- let r = b.current, i = h.current?.username;
4761
+ let r = S.current, i = _.current?.username;
4721
4762
  if (!r || !i) return;
4722
- let a = (q.getState().conversations[e]?.reactions?.[t]?.[i] ?? []).includes(n) ? [] : [n];
4763
+ let a = (J.getState().conversations[e]?.reactions?.[t]?.[i] ?? []).includes(n) ? [] : [n];
4723
4764
  try {
4724
- await r.react(e, t, a), q.getState().applyReactions([{
4765
+ await r.react(e, t, a), J.getState().applyReactions([{
4725
4766
  peer: e,
4726
4767
  target: t,
4727
4768
  user: i,
4728
4769
  emojis: a
4729
4770
  }]);
4730
4771
  } catch (e) {
4731
- J("chat-island-error", {
4772
+ Y("chat-island-error", {
4732
4773
  scope: "reaction",
4733
4774
  message: e.message
4734
4775
  });
4735
4776
  }
4736
4777
  },
4737
4778
  loadOlder: async (e) => {
4738
- let t = b.current, n = q.getState().ensure(e);
4739
- if (!(!t || n.complete || x.current.has(e))) {
4740
- x.current.add(e);
4779
+ let t = S.current, n = J.getState().ensure(e);
4780
+ if (!(!t || n.complete || C.current.has(e))) {
4781
+ C.current.add(e);
4741
4782
  try {
4742
4783
  let r = await t.history(e, n.oldest);
4743
- q.getState().prependHistory(e, r.messages, r.complete, r.first), q.getState().applyReactions(r.reactions);
4784
+ J.getState().prependHistory(e, r.messages, r.complete, r.first), J.getState().applyReactions(r.reactions);
4744
4785
  } catch (e) {
4745
- J("chat-island-error", {
4786
+ Y("chat-island-error", {
4746
4787
  scope: "history",
4747
4788
  message: e.message
4748
4789
  });
4749
4790
  } finally {
4750
- x.current.delete(e);
4791
+ C.current.delete(e);
4751
4792
  }
4752
4793
  }
4753
4794
  }
4754
4795
  }), []);
4755
4796
  i(() => {
4756
- if (!m) return;
4757
- let e = q.getState();
4758
- e.reset(), q.setState({
4759
- me: m.username,
4760
- mucHost: `conference.${m.host}`,
4797
+ if (!h) return;
4798
+ let e = J.getState();
4799
+ e.reset(), J.setState({
4800
+ me: h.username,
4801
+ mucHost: `conference.${h.host}`,
4761
4802
  maxHeads: a,
4762
4803
  newChatButton: l
4763
4804
  });
4764
- let t = new vn(m, {
4805
+ let t = new _n(h, {
4765
4806
  status: (n, a) => {
4766
- if (e.setStatus(n, a), J("chat-island-status", {
4807
+ if (e.setStatus(n, a), Y("chat-island-status", {
4767
4808
  status: n,
4768
4809
  error: a
4769
- }), n === "online" && r && !S.current && typeof Notification < "u") {
4810
+ }), n === "online" && r && !T.current && typeof Notification < "u") {
4770
4811
  let e = Notification.permission;
4771
- (e === "granted" || _.current === "auto" && e === "default") && i();
4812
+ (e === "granted" || y.current === "auto" && e === "default") && i();
4772
4813
  }
4773
4814
  n === "online" && t.listGroups().then((t) => t.forEach((t) => e.setGroup(t.peer, t.name, t.members, t.avatar, t.owner))).catch(() => {}).then(() => t.recent()).then((e) => {
4774
- e && (q.getState().seed(e.messages, m.username), q.getState().applyReactions(e.reactions));
4815
+ e && (J.getState().seed(e.messages, h.username), J.getState().applyReactions(e.reactions));
4775
4816
  }).catch(() => {});
4776
4817
  },
4777
4818
  typing: (t, n) => e.setTyping(t, n),
@@ -4785,17 +4826,17 @@ function Rr({ dataConfig: e, position: t = "bottom-right", dark: n, serviceWorke
4785
4826
  }).catch(() => {});
4786
4827
  },
4787
4828
  message: (r) => {
4788
- let i = jn(r);
4789
- r.room && !q.getState().conversations[r.room]?.name && t.groupInfo(r.room).then((t) => e.setGroup(t.peer, t.name, t.members, t.avatar, t.owner)).catch(() => {}), e.addMessage(i, r, { live: !0 }), J("chat-island-message", {
4829
+ let i = An(r);
4830
+ r.room && !J.getState().conversations[r.room]?.name && t.groupInfo(r.room).then((t) => e.setGroup(t.peer, t.name, t.members, t.avatar, t.owner)).catch(() => {}), e.addMessage(i, r, { live: !0 }), Y("chat-island-message", {
4790
4831
  ...r,
4791
4832
  peer: i
4792
- }), J("chat-island-unread", { total: q.getState().totalUnread() }), r.mine || n(i, r);
4833
+ }), Y("chat-island-unread", { total: J.getState().totalUnread() }), r.mine || n(i, r);
4793
4834
  }
4794
4835
  }), n = (e, t) => {
4795
- let n = q.getState(), r = document.visibilityState === "visible";
4836
+ let n = J.getState(), r = document.visibilityState === "visible";
4796
4837
  if (r && n.open === e) return;
4797
4838
  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" && t.nick ? `${n.contacts[t.nick]?.name ?? t.nick}: ${o}` : o;
4798
- if (g.current && Sn(), J("chat-island-notify", {
4839
+ if (v.current && xn(), Y("chat-island-notify", {
4799
4840
  peer: e,
4800
4841
  name: a,
4801
4842
  body: s
@@ -4805,83 +4846,83 @@ function Rr({ dataConfig: e, position: t = "bottom-right", dark: n, serviceWorke
4805
4846
  tag: `chat-${e}`
4806
4847
  });
4807
4848
  t.onclick = () => {
4808
- window.focus(), q.getState().openChat(e), t.close();
4849
+ window.focus(), J.getState().openChat(e), t.close();
4809
4850
  };
4810
4851
  } catch {}
4811
4852
  };
4812
- b.current = t;
4853
+ S.current = t;
4813
4854
  let i = () => {
4814
- r && !S.current && (S.current = !0, Bn(m, r).then((e) => {
4855
+ r && !T.current && (T.current = !0, zn(h, r).then((e) => {
4815
4856
  if (!e) {
4816
- S.current = !1, q.setState({ push: Notification.permission === "denied" ? "denied" : "ask" });
4857
+ T.current = !1, J.setState({ push: Notification.permission === "denied" ? "denied" : "ask" });
4817
4858
  return;
4818
4859
  }
4819
4860
  return t.enablePush(e.service, e.node).then(() => {
4820
- C.current = e, q.setState({ push: "enabled" }), J("chat-island-push", { enabled: !0 });
4861
+ D.current = e, J.setState({ push: "enabled" }), Y("chat-island-push", { enabled: !0 });
4821
4862
  });
4822
4863
  }).catch((e) => {
4823
- S.current = !1, J("chat-island-error", {
4864
+ T.current = !1, Y("chat-island-error", {
4824
4865
  scope: "push",
4825
4866
  message: e.message
4826
4867
  });
4827
4868
  }));
4828
4869
  }, o = !!r && "serviceWorker" in navigator && "PushManager" in window && typeof Notification < "u";
4829
- q.setState({
4870
+ J.setState({
4830
4871
  push: o ? Notification.permission === "denied" ? "denied" : "ask" : "unavailable",
4831
4872
  enablePush: i
4832
4873
  });
4833
4874
  let s = () => t.stop();
4834
4875
  window.addEventListener("pagehide", s), t.start();
4835
- let c = () => Fn(m.host, m.token).then(e.setMobile).catch(() => {});
4876
+ let c = () => Pn(h.host, h.token).then(e.setMobile).catch(() => {});
4836
4877
  c();
4837
4878
  let u = window.setInterval(c, 12e4);
4838
- Pn(m.host, m.token, m.username).then(e.setContacts).catch((e) => J("chat-island-error", {
4879
+ Nn(h.host, h.token, h.username).then(e.setContacts).catch((e) => Y("chat-island-error", {
4839
4880
  scope: "contacts",
4840
4881
  message: e.message
4841
4882
  }));
4842
- let d = Y("chat-island-open", ({ username: t }) => t && e.openChat(t)), f = Y("chat-island-close", () => e.closeChat()), p = Y("chat-island-new", () => e.setPicker(!0)), h = Y("chat-island-delete", ({ username: e }) => e && te.remove(e)), v = Y("chat-island-contacts", ({ contacts: t }) => t && e.setContacts(t)), y = Y("chat-island-conversations-request", () => J("chat-island-conversations", { conversations: Pr() }));
4883
+ 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)), g = X("chat-island-contacts", ({ contacts: t }) => t && e.setContacts(t)), _ = X("chat-island-conversations-request", () => Y("chat-island-conversations", { conversations: Lr() }));
4843
4884
  return () => {
4844
- window.removeEventListener("pagehide", s), window.clearInterval(u), y(), p(), h(), d(), f(), v(), C.current && t.disablePush(C.current.service, C.current.node).catch(() => {}), C.current = null, t.stop(), b.current = null, S.current = !1;
4885
+ window.removeEventListener("pagehide", s), window.clearInterval(u), _(), p(), m(), d(), f(), g(), D.current && t.disablePush(D.current.service, D.current.node).catch(() => {}), D.current = null, t.stop(), S.current = null, T.current = !1;
4845
4886
  };
4846
4887
  }, [
4847
- m,
4888
+ h,
4848
4889
  r,
4849
- v
4890
+ b
4850
4891
  ]);
4851
- let A = q((e) => Object.keys(e.contacts).join(","));
4892
+ let N = J((e) => Object.keys(e.contacts).join(","));
4852
4893
  i(() => {
4853
- k === "online" && A && b.current?.announce(A.split(","));
4854
- }, [k, A]);
4855
- let ne = q((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);
4856
- i(() => J("chat-island-conversations", { conversations: Pr() }), [ne]);
4857
- let re = q((e) => Object.values(e.conversations).reduce((e, t) => e + t.unread, 0));
4858
- if (i(() => J("chat-island-unread", { total: re }), [re]), !m) return null;
4859
- let j = D.anchor ? {
4860
- right: D.anchor.right,
4861
- bottom: D.anchor.bottom
4862
- } : void 0, ie = j ? "" : t === "bottom-left" ? "ci-left-4 ci-bottom-5" : "ci-right-4 ci-bottom-5";
4894
+ j === "online" && N && S.current?.announce(N.split(","));
4895
+ }, [j, N]);
4896
+ let P = 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);
4897
+ i(() => Y("chat-island-conversations", { conversations: Lr() }), [P]);
4898
+ let te = J((e) => Object.values(e.conversations).reduce((e, t) => e + t.unread, 0));
4899
+ if (i(() => Y("chat-island-unread", { total: te }), [te]), !h) return null;
4900
+ let ne = m && k.anchor ? {
4901
+ right: k.anchor.right,
4902
+ bottom: k.anchor.bottom
4903
+ } : void 0, re = ne ? "" : t === "bottom-left" ? "ci-left-4 ci-bottom-5" : "ci-right-4 ci-bottom-5";
4863
4904
  return /* @__PURE__ */ d("div", {
4864
- ref: T,
4865
- style: j,
4866
- onClickCapture: D.onClickCapture,
4867
- className: `chat-island-root ${n ? "dark" : ""} ci-fixed ${ie} ci-z-[9999] ci-flex ci-items-end ci-gap-3 ci-font-sans ci-select-none`,
4868
- "data-status": k,
4869
- children: /* @__PURE__ */ f(Fr, { children: [
4870
- O && /* @__PURE__ */ d(jr, {
4871
- peer: O,
4872
- actions: te,
4873
- onDragStart: D.start
4905
+ ref: O,
4906
+ style: ne,
4907
+ onClickCapture: k.onClickCapture,
4908
+ className: `chat-island-root ${g ? "ci-dark" : ""} ci-fixed ${re} ci-z-[9999] ci-flex ci-items-end ci-gap-3 ci-font-sans ci-select-none`,
4909
+ "data-status": j,
4910
+ children: /* @__PURE__ */ f(Rr, { children: [
4911
+ A && /* @__PURE__ */ d(jr, {
4912
+ peer: A,
4913
+ actions: M,
4914
+ onDragStart: m ? k.start : void 0
4874
4915
  }),
4875
4916
  ee && /* @__PURE__ */ d(Nr, {
4876
- onOpen: (e) => q.getState().openChat(e),
4877
- onCreateGroup: te.createGroup
4917
+ onOpen: (e) => J.getState().openChat(e),
4918
+ onCreateGroup: M.createGroup
4878
4919
  }),
4879
4920
  /* @__PURE__ */ d(Kn, {
4880
- onDragStart: D.start,
4921
+ onDragStart: m ? k.start : void 0,
4881
4922
  pushButton: u !== "auto"
4882
4923
  })
4883
4924
  ] })
4884
4925
  });
4885
4926
  }
4886
4927
  //#endregion
4887
- export { Rr as ChatIsland };
4928
+ export { Vr as ChatIsland };