@nethesis/chat-island 0.1.14 → 0.1.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/components/Button.d.ts +5 -0
- package/dist/components/ChatWindow.d.ts +3 -1
- package/dist/events.d.ts +3 -0
- package/dist/index.css +1 -1
- package/dist/index.js +1109 -847
- package/dist/theme.d.ts +1 -1
- package/dist-widget/index.widget.css +1 -1
- package/dist-widget/index.widget.js +6 -6
- package/package.json +7 -2
package/dist/index.js
CHANGED
|
@@ -471,7 +471,7 @@ 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
|
-
})),
|
|
474
|
+
})), j = /* @__PURE__ */ y(((e, t) => {
|
|
475
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() {
|
|
@@ -565,14 +565,14 @@ var D = /* @__PURE__ */ y(((e) => {
|
|
|
565
565
|
e && this.write(e), this.write = function() {};
|
|
566
566
|
}
|
|
567
567
|
};
|
|
568
|
-
})),
|
|
568
|
+
})), M = D(), N = /* @__PURE__ */ x(O(), 1), P = /* @__PURE__ */ x(k(), 1), F = A(), ee = /* @__PURE__ */ x(j(), 1), te = 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
|
|
575
|
+
function ne(e) {
|
|
576
576
|
let t, n = new Promise((n) => {
|
|
577
577
|
t = setTimeout(n, e);
|
|
578
578
|
});
|
|
@@ -580,32 +580,32 @@ function re(e) {
|
|
|
580
580
|
}
|
|
581
581
|
//#endregion
|
|
582
582
|
//#region node_modules/@xmpp/events/lib/timeout.js
|
|
583
|
-
function
|
|
584
|
-
let n =
|
|
583
|
+
function re(e, t) {
|
|
584
|
+
let n = ne(t);
|
|
585
585
|
function r() {
|
|
586
586
|
clearTimeout(n.timeout);
|
|
587
587
|
}
|
|
588
|
-
let i = new
|
|
588
|
+
let i = new te();
|
|
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
|
|
596
|
-
function
|
|
597
|
-
let t =
|
|
595
|
+
var ie = /* @__PURE__ */ new WeakMap();
|
|
596
|
+
function I(e) {
|
|
597
|
+
let t = ie.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
|
-
},
|
|
602
|
+
}, ie.set(e, t)), t;
|
|
603
603
|
}
|
|
604
604
|
//#endregion
|
|
605
605
|
//#region node_modules/@xmpp/events/lib/promise.js
|
|
606
|
-
function
|
|
606
|
+
function L(e, t, n = "error", r) {
|
|
607
607
|
return new Promise((i, a) => {
|
|
608
|
-
let o, { off: s, once: c } =
|
|
608
|
+
let o, { off: s, once: c } = I(e), l = () => {
|
|
609
609
|
clearTimeout(o), s(t, d), s(n, u);
|
|
610
610
|
};
|
|
611
611
|
function u(e) {
|
|
@@ -615,7 +615,7 @@ function F(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
|
|
618
|
+
let e = new te();
|
|
619
619
|
o = setTimeout(() => {
|
|
620
620
|
l(), a(e);
|
|
621
621
|
}, r);
|
|
@@ -624,14 +624,14 @@ function F(e, t, n = "error", r) {
|
|
|
624
624
|
}
|
|
625
625
|
//#endregion
|
|
626
626
|
//#region node_modules/@xmpp/events/lib/Deferred.js
|
|
627
|
-
function
|
|
627
|
+
function ae() {
|
|
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
|
|
634
|
+
function oe(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 ce(e, t = null, n) {
|
|
|
651
651
|
}
|
|
652
652
|
//#endregion
|
|
653
653
|
//#region node_modules/@xmpp/events/lib/listeners.js
|
|
654
|
-
function
|
|
654
|
+
function se(e) {
|
|
655
655
|
return {
|
|
656
656
|
subscribe(t) {
|
|
657
|
-
let { on: n } =
|
|
657
|
+
let { on: n } = I(t);
|
|
658
658
|
for (let [t, r] of Object.entries(e)) n(t, r);
|
|
659
659
|
},
|
|
660
660
|
unsubscribe(t) {
|
|
661
|
-
let { off: n } =
|
|
661
|
+
let { off: n } = I(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
|
|
668
|
+
var ce = class extends Error {
|
|
669
669
|
constructor(...e) {
|
|
670
670
|
super(...e), this.name = "XMLError";
|
|
671
671
|
}
|
|
672
|
-
},
|
|
672
|
+
}, le = class extends F.EventEmitter {
|
|
673
673
|
constructor() {
|
|
674
674
|
super();
|
|
675
|
-
let e = new
|
|
675
|
+
let e = new ee.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
|
|
679
|
+
let n = new N.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
|
|
685
|
+
this.emit("error", new ce(`${n.name} must be closed.`));
|
|
686
686
|
return;
|
|
687
687
|
}
|
|
688
688
|
if (n === t) {
|
|
@@ -698,7 +698,7 @@ var ue = class extends Error {
|
|
|
698
698
|
onText(e) {
|
|
699
699
|
let { cursor: t } = this;
|
|
700
700
|
if (!t) {
|
|
701
|
-
this.emit("error", new
|
|
701
|
+
this.emit("error", new ce(`${e} must be a child.`));
|
|
702
702
|
return;
|
|
703
703
|
}
|
|
704
704
|
t.t(e);
|
|
@@ -710,37 +710,37 @@ var ue = class extends Error {
|
|
|
710
710
|
e && this.parser.write(e);
|
|
711
711
|
}
|
|
712
712
|
};
|
|
713
|
-
|
|
713
|
+
le.XMLError = ce;
|
|
714
714
|
//#endregion
|
|
715
715
|
//#region node_modules/@xmpp/xml/index.js
|
|
716
|
-
function
|
|
717
|
-
return (0,
|
|
718
|
-
}
|
|
719
|
-
Object.assign(
|
|
720
|
-
Element:
|
|
721
|
-
createElement:
|
|
722
|
-
Parser:
|
|
723
|
-
escapeXML:
|
|
724
|
-
unescapeXML:
|
|
725
|
-
escapeXMLText:
|
|
726
|
-
unescapeXMLText:
|
|
727
|
-
XMLError:
|
|
728
|
-
xml:
|
|
716
|
+
function R(...e) {
|
|
717
|
+
return (0, P.default)(...e);
|
|
718
|
+
}
|
|
719
|
+
Object.assign(R, {
|
|
720
|
+
Element: N.default,
|
|
721
|
+
createElement: P.default,
|
|
722
|
+
Parser: le,
|
|
723
|
+
escapeXML: M.escapeXML,
|
|
724
|
+
unescapeXML: M.unescapeXML,
|
|
725
|
+
escapeXMLText: M.escapeXMLText,
|
|
726
|
+
unescapeXMLText: M.unescapeXMLText,
|
|
727
|
+
XMLError: ce,
|
|
728
|
+
xml: R
|
|
729
729
|
});
|
|
730
730
|
//#endregion
|
|
731
731
|
//#region node_modules/@xmpp/jid/lib/escaping.js
|
|
732
|
-
function
|
|
732
|
+
function ue(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
|
|
735
|
+
function de(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
|
|
738
|
+
function fe(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
|
|
743
|
+
var z = 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 L = 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 ||=
|
|
762
|
+
return t ||= ue(e), t && (e = de(e)), this._local = e && e.toLowerCase(), this;
|
|
763
763
|
}
|
|
764
764
|
getLocal(e = !1) {
|
|
765
765
|
let t = null;
|
|
766
|
-
return t = e ?
|
|
766
|
+
return t = e ? fe(this._local) : this._local, t;
|
|
767
767
|
}
|
|
768
768
|
setDomain(e) {
|
|
769
769
|
return this._domain = e.toLowerCase(), this;
|
|
@@ -778,37 +778,37 @@ var L = class e {
|
|
|
778
778
|
return this._resource;
|
|
779
779
|
}
|
|
780
780
|
};
|
|
781
|
-
Object.defineProperty(
|
|
782
|
-
get:
|
|
783
|
-
set:
|
|
784
|
-
}), Object.defineProperty(
|
|
785
|
-
get:
|
|
786
|
-
set:
|
|
787
|
-
}), Object.defineProperty(
|
|
788
|
-
get:
|
|
789
|
-
set:
|
|
781
|
+
Object.defineProperty(z.prototype, "local", {
|
|
782
|
+
get: z.prototype.getLocal,
|
|
783
|
+
set: z.prototype.setLocal
|
|
784
|
+
}), Object.defineProperty(z.prototype, "domain", {
|
|
785
|
+
get: z.prototype.getDomain,
|
|
786
|
+
set: z.prototype.setDomain
|
|
787
|
+
}), Object.defineProperty(z.prototype, "resource", {
|
|
788
|
+
get: z.prototype.getResource,
|
|
789
|
+
set: z.prototype.setResource
|
|
790
790
|
});
|
|
791
791
|
//#endregion
|
|
792
792
|
//#region node_modules/@xmpp/jid/lib/parse.js
|
|
793
|
-
function
|
|
793
|
+
function pe(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
|
|
797
|
+
return i !== -1 && (t = e.slice(0, i), e = e.slice(i + 1)), new z(t, e, n);
|
|
798
798
|
}
|
|
799
799
|
//#endregion
|
|
800
800
|
//#region node_modules/@xmpp/jid/index.js
|
|
801
|
-
function
|
|
801
|
+
function me(e, t) {
|
|
802
802
|
return e.equals(t);
|
|
803
803
|
}
|
|
804
|
-
function
|
|
805
|
-
return !e[1] && !e[2] ?
|
|
804
|
+
function he(...e) {
|
|
805
|
+
return !e[1] && !e[2] ? pe(...e) : new z(...e);
|
|
806
806
|
}
|
|
807
|
-
var
|
|
808
|
-
|
|
807
|
+
var B = he.bind();
|
|
808
|
+
B.jid = he, B.JID = z, B.parse = pe, B.equal = me, B.detectEscape = ue, B.escapeLocal = de, B.unescapeLocal = fe;
|
|
809
809
|
//#endregion
|
|
810
810
|
//#region node_modules/@xmpp/error/index.js
|
|
811
|
-
var
|
|
811
|
+
var ge = 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 ve = 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
|
-
},
|
|
821
|
+
}, _e = class extends ge {
|
|
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
|
|
828
|
+
function ve(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 be(e) {
|
|
|
833
833
|
protocol: r
|
|
834
834
|
};
|
|
835
835
|
}
|
|
836
|
-
function
|
|
837
|
-
let { port: t, hostname: n } =
|
|
836
|
+
function ye(e) {
|
|
837
|
+
let { port: t, hostname: n } = ve(`http://${e}`);
|
|
838
838
|
return {
|
|
839
839
|
port: t,
|
|
840
840
|
hostname: n
|
|
841
841
|
};
|
|
842
842
|
}
|
|
843
|
-
function
|
|
844
|
-
return e.includes("://") ?
|
|
843
|
+
function be(e) {
|
|
844
|
+
return e.includes("://") ? ve(e) : ye(e);
|
|
845
845
|
}
|
|
846
846
|
//#endregion
|
|
847
847
|
//#region node_modules/@xmpp/connection/index.js
|
|
848
|
-
var
|
|
848
|
+
var xe = "urn:ietf:params:xml:ns:xmpp-streams", Se = "http://etherx.jabber.org/streams", Ce = class extends F.EventEmitter {
|
|
849
849
|
#e = null;
|
|
850
850
|
#t = null;
|
|
851
851
|
constructor(e = {}) {
|
|
@@ -856,7 +856,7 @@ var Ce = "urn:ietf:params:xml:ns:xmpp-streams", we = "http://etherx.jabber.org/s
|
|
|
856
856
|
}
|
|
857
857
|
async _streamError(e, t) {
|
|
858
858
|
try {
|
|
859
|
-
await this.send(
|
|
859
|
+
await this.send(R("stream:error", {}, [R(e, { xmlns: xe }, t)]));
|
|
860
860
|
} catch {}
|
|
861
861
|
return this.disconnect();
|
|
862
862
|
}
|
|
@@ -880,7 +880,7 @@ var Ce = "urn:ietf:params:xml:ns:xmpp-streams", we = "http://etherx.jabber.org/s
|
|
|
880
880
|
});
|
|
881
881
|
}
|
|
882
882
|
_attachSocket(e) {
|
|
883
|
-
this.socket = e, this.#e ??=
|
|
883
|
+
this.socket = e, this.#e ??= se({
|
|
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 Ce = "urn:ietf:params:xml:ns:xmpp-streams", we = "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",
|
|
894
|
+
let t = e.is("error", Se);
|
|
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 =
|
|
898
|
+
let t = _e.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 } =
|
|
903
|
+
let { protocol: t } = be(this.options.service), n = e.element.getChildText("see-other-host"), { port: r } = ye(n), i;
|
|
904
904
|
i = r ? `${t || "xmpp:"}//${n}` : (t ? `${t}//` : "") + n;
|
|
905
905
|
try {
|
|
906
|
-
await
|
|
906
|
+
await L(this, "disconnect");
|
|
907
907
|
let { domain: e, lang: t } = this.options;
|
|
908
908
|
await this.connect(i), await this.open({
|
|
909
909
|
domain: e,
|
|
@@ -914,7 +914,7 @@ var Ce = "urn:ietf:params:xml:ns:xmpp-streams", we = "http://etherx.jabber.org/s
|
|
|
914
914
|
}
|
|
915
915
|
}
|
|
916
916
|
_attachParser(e) {
|
|
917
|
-
this.parser = e, this.#t ??=
|
|
917
|
+
this.parser = e, this.#t ??= se({
|
|
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 Ce = "urn:ietf:params:xml:ns:xmpp-streams", we = "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 =
|
|
928
|
+
return this.jid = B(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 Ce = "urn:ietf:params:xml:ns:xmpp-streams", we = "http://etherx.jabber.org/s
|
|
|
951
951
|
if (this.status !== "offline") throw Error("Connection is not offline");
|
|
952
952
|
let { service: e, domain: t, lang: n } = this.options;
|
|
953
953
|
await this.connect(e);
|
|
954
|
-
let r =
|
|
954
|
+
let r = L(this, "online");
|
|
955
955
|
return await this.open({
|
|
956
956
|
domain: t,
|
|
957
957
|
lang: n
|
|
@@ -960,15 +960,15 @@ var Ce = "urn:ietf:params:xml:ns:xmpp-streams", we = "http://etherx.jabber.org/s
|
|
|
960
960
|
async connect(e) {
|
|
961
961
|
this._status("connecting", e);
|
|
962
962
|
let t = new this.Socket();
|
|
963
|
-
return this._attachSocket(t), t.connect(this.socketParameters(e)),
|
|
963
|
+
return this._attachSocket(t), t.connect(this.socketParameters(e)), L(t, "connect");
|
|
964
964
|
}
|
|
965
965
|
async _closeSocket(e = this.timeout) {
|
|
966
|
-
this._status("disconnecting"), this.socket.end(), await
|
|
966
|
+
this._status("disconnecting"), this.socket.end(), await L(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)),
|
|
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)), L(this, "open", "error", this.timeout);
|
|
972
972
|
}
|
|
973
973
|
async stop() {
|
|
974
974
|
let e = await this.disconnect();
|
|
@@ -977,7 +977,7 @@ var Ce = "urn:ietf:params:xml:ns:xmpp-streams", we = "http://etherx.jabber.org/s
|
|
|
977
977
|
async _closeStream(e = this.timeout) {
|
|
978
978
|
await this.#c("close");
|
|
979
979
|
let t = this.footer(this.footerElement());
|
|
980
|
-
return await this.write(t), this._status("closing"),
|
|
980
|
+
return await this.write(t), this._status("closing"), L(this.parser, "end", "error", e);
|
|
981
981
|
}
|
|
982
982
|
async restart() {
|
|
983
983
|
this._detachParser();
|
|
@@ -991,7 +991,7 @@ var Ce = "urn:ietf:params:xml:ns:xmpp-streams", we = "http://etherx.jabber.org/s
|
|
|
991
991
|
e.parent = this.root, await this.write(e.toString()), this.emit("send", e);
|
|
992
992
|
}
|
|
993
993
|
sendReceive(e, t = this.timeout) {
|
|
994
|
-
return Promise.all([this.send(e),
|
|
994
|
+
return Promise.all([this.send(e), L(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 Ce = "urn:ietf:params:xml:ns:xmpp-streams", we = "http://etherx.jabber.org/s
|
|
|
1010
1010
|
return e.toString();
|
|
1011
1011
|
}
|
|
1012
1012
|
headerElement() {
|
|
1013
|
-
return new
|
|
1013
|
+
return new R.Element("", {
|
|
1014
1014
|
version: "1.0",
|
|
1015
1015
|
xmlns: this.NS
|
|
1016
1016
|
});
|
|
@@ -1045,10 +1045,10 @@ var Ce = "urn:ietf:params:xml:ns:xmpp-streams", we = "http://etherx.jabber.org/s
|
|
|
1045
1045
|
}));
|
|
1046
1046
|
}
|
|
1047
1047
|
};
|
|
1048
|
-
|
|
1048
|
+
Ce.prototype.NS = "", Ce.prototype.Socket = null, Ce.prototype.Parser = null;
|
|
1049
1049
|
//#endregion
|
|
1050
1050
|
//#region node_modules/@xmpp/client-core/lib/Client.js
|
|
1051
|
-
var
|
|
1051
|
+
var we = class extends Ce {
|
|
1052
1052
|
constructor(e) {
|
|
1053
1053
|
super(e), this.transports = [];
|
|
1054
1054
|
}
|
|
@@ -1089,10 +1089,10 @@ var Ee = class extends Te {
|
|
|
1089
1089
|
return this.Transport.prototype.footerElement(...e);
|
|
1090
1090
|
}
|
|
1091
1091
|
};
|
|
1092
|
-
|
|
1092
|
+
we.prototype.NS = "jabber:client";
|
|
1093
1093
|
//#endregion
|
|
1094
1094
|
//#region node_modules/@xmpp/reconnect/index.js
|
|
1095
|
-
var
|
|
1095
|
+
var Te = class extends F.EventEmitter {
|
|
1096
1096
|
constructor(e) {
|
|
1097
1097
|
super(), this.delay = 1e3, this.entity = e, this._timeout = null;
|
|
1098
1098
|
}
|
|
@@ -1125,36 +1125,36 @@ var De = class extends P.EventEmitter {
|
|
|
1125
1125
|
e.removeListener("disconnect", this.#e), clearTimeout(t);
|
|
1126
1126
|
}
|
|
1127
1127
|
};
|
|
1128
|
-
function
|
|
1129
|
-
let t = new
|
|
1128
|
+
function Ee({ entity: e }) {
|
|
1129
|
+
let t = new Te(e);
|
|
1130
1130
|
return t.start(), t;
|
|
1131
1131
|
}
|
|
1132
1132
|
//#endregion
|
|
1133
1133
|
//#region node_modules/@xmpp/websocket/lib/Socket.js
|
|
1134
|
-
var
|
|
1135
|
-
function
|
|
1136
|
-
let t =
|
|
1134
|
+
var De = "ECONNERROR";
|
|
1135
|
+
function Oe(e) {
|
|
1136
|
+
let t = ve(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
|
|
1143
|
+
var ke = class extends F.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 =
|
|
1149
|
+
this.url = e, this.secure = Oe(e), this._attachSocket(new WebSocket(e, ["xmpp"]));
|
|
1150
1150
|
}
|
|
1151
1151
|
_attachSocket(e) {
|
|
1152
|
-
this.socket = e, this.#e ??=
|
|
1152
|
+
this.socket = e, this.#e ??= se({
|
|
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 ${
|
|
1157
|
+
n || (n = Error(e.message || `WebSocket ${De} ${t}`), n.errno = De, n.code = De), 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 je = class extends P.EventEmitter {
|
|
|
1179
1179
|
}
|
|
1180
1180
|
n();
|
|
1181
1181
|
}
|
|
1182
|
-
},
|
|
1182
|
+
}, Ae = class extends le {
|
|
1183
1183
|
onStartElement(e, t) {
|
|
1184
|
-
let n = new
|
|
1184
|
+
let n = new N.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
|
|
1190
|
+
this.emit("error", new ce(`${t.name} must be closed.`));
|
|
1191
1191
|
return;
|
|
1192
1192
|
}
|
|
1193
1193
|
if (t.parent) {
|
|
@@ -1196,7 +1196,7 @@ var je = class extends P.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
|
-
},
|
|
1199
|
+
}, je = "urn:ietf:params:xml:ns:xmpp-framing", Me = class extends Ce {
|
|
1200
1200
|
send(e, ...t) {
|
|
1201
1201
|
return e.attrs.xmlns ??= this.NS, super.send(e, ...t);
|
|
1202
1202
|
}
|
|
@@ -1204,27 +1204,27 @@ var je = class extends P.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
|
|
1207
|
+
return new R.Element("close", { xmlns: je });
|
|
1208
1208
|
}
|
|
1209
1209
|
headerElement() {
|
|
1210
1210
|
let e = super.headerElement();
|
|
1211
|
-
return e.name = "open", e.attrs.xmlns =
|
|
1211
|
+
return e.name = "open", e.attrs.xmlns = je, e;
|
|
1212
1212
|
}
|
|
1213
1213
|
socketParameters(e) {
|
|
1214
1214
|
return /^wss?:\/\//.test(e) ? e : void 0;
|
|
1215
1215
|
}
|
|
1216
1216
|
};
|
|
1217
|
-
|
|
1217
|
+
Me.prototype.Socket = ke, Me.prototype.NS = "jabber:client", Me.prototype.Parser = Ae;
|
|
1218
1218
|
//#endregion
|
|
1219
1219
|
//#region node_modules/@xmpp/websocket/index.js
|
|
1220
|
-
function
|
|
1221
|
-
e.transports.push(
|
|
1220
|
+
function Ne({ entity: e }) {
|
|
1221
|
+
e.transports.push(Me);
|
|
1222
1222
|
}
|
|
1223
1223
|
//#endregion
|
|
1224
1224
|
//#region __vite-browser-external
|
|
1225
|
-
var
|
|
1225
|
+
var Pe = /* @__PURE__ */ y(((e, t) => {
|
|
1226
1226
|
t.exports = {};
|
|
1227
|
-
})),
|
|
1227
|
+
})), Fe = /* @__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 Ie = /* @__PURE__ */ y(((e, t) => {
|
|
|
1245
1245
|
}
|
|
1246
1246
|
};
|
|
1247
1247
|
}
|
|
1248
|
-
})),
|
|
1248
|
+
})), V = /* @__PURE__ */ x(Pe(), 1), Ie = /* @__PURE__ */ x(Fe(), 1), Le = 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
|
-
},
|
|
1254
|
+
}, Re = class extends Le {
|
|
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
|
|
1258
|
+
i && (this.to = new B(i)), a && (this.from = new B(a), this.local = this.from.local, this.domain = this.from.domain, this.resource = this.from.resource);
|
|
1259
1259
|
}
|
|
1260
|
-
},
|
|
1260
|
+
}, ze = class extends Le {
|
|
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
|
|
1264
|
+
i && (this.from = new B(i)), a && (this.to = new B(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
|
|
1269
|
+
function Be(e, t, n) {
|
|
1270
1270
|
return (r) => {
|
|
1271
1271
|
let i = new n(e, r);
|
|
1272
|
-
return (0,
|
|
1272
|
+
return (0, Ie.default)(t)(i);
|
|
1273
1273
|
};
|
|
1274
1274
|
}
|
|
1275
|
-
function
|
|
1275
|
+
function Ve(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
|
|
1281
|
-
let t = [
|
|
1280
|
+
function He({ entity: e }) {
|
|
1281
|
+
let t = [Ve(e)], n = [], r = Be(e, t, Re), i = Be(e, n, ze);
|
|
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 We({ entity: e }) {
|
|
|
1290
1290
|
}
|
|
1291
1291
|
//#endregion
|
|
1292
1292
|
//#region node_modules/@xmpp/stream-features/index.js
|
|
1293
|
-
function
|
|
1293
|
+
function Ue({ 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 Ge({ middleware: e }) {
|
|
|
1303
1303
|
}
|
|
1304
1304
|
//#endregion
|
|
1305
1305
|
//#region node_modules/@xmpp/id/index.js
|
|
1306
|
-
function
|
|
1306
|
+
function We() {
|
|
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
|
|
1313
|
+
var Ge = class extends ge {
|
|
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 qe = class extends ve {
|
|
|
1321
1321
|
};
|
|
1322
1322
|
//#endregion
|
|
1323
1323
|
//#region node_modules/@xmpp/iq/caller.js
|
|
1324
|
-
function
|
|
1324
|
+
function Ke({ name: e, type: t }) {
|
|
1325
1325
|
return !(e !== "iq" || t !== "error" && t !== "result");
|
|
1326
1326
|
}
|
|
1327
|
-
var
|
|
1327
|
+
var qe = 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 Ye = 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 (!
|
|
1335
|
+
if (!Ke({
|
|
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(
|
|
1341
|
+
e === "error" ? a.reject(Ge.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 =
|
|
1345
|
-
let n = new
|
|
1344
|
+
e.attrs.id || (e.attrs.id = We());
|
|
1345
|
+
let n = new ae();
|
|
1346
1346
|
this.handlers.set(e.attrs.id, n);
|
|
1347
1347
|
try {
|
|
1348
|
-
await this.entity.send(e), await
|
|
1348
|
+
await this.entity.send(e), await re(n.promise, t);
|
|
1349
1349
|
} catch (t) {
|
|
1350
1350
|
throw this.handlers.delete(e.attrs.id), t;
|
|
1351
1351
|
}
|
|
@@ -1353,7 +1353,7 @@ var Ye = class {
|
|
|
1353
1353
|
}
|
|
1354
1354
|
_childRequest(e, t, n, ...r) {
|
|
1355
1355
|
let { name: i, attrs: { xmlns: a } } = t;
|
|
1356
|
-
return this.request(
|
|
1356
|
+
return this.request(R("iq", {
|
|
1357
1357
|
type: e,
|
|
1358
1358
|
to: n
|
|
1359
1359
|
}, t), ...r).then((e) => e.getChild(i, a));
|
|
@@ -1365,71 +1365,71 @@ var Ye = class {
|
|
|
1365
1365
|
return this._childRequest("set", ...e);
|
|
1366
1366
|
}
|
|
1367
1367
|
};
|
|
1368
|
-
function
|
|
1369
|
-
let t = new
|
|
1368
|
+
function Je(...e) {
|
|
1369
|
+
let t = new qe(...e);
|
|
1370
1370
|
return t.start(), t;
|
|
1371
1371
|
}
|
|
1372
1372
|
//#endregion
|
|
1373
1373
|
//#region node_modules/@xmpp/iq/callee.js
|
|
1374
|
-
var
|
|
1375
|
-
function
|
|
1374
|
+
var Ye = "urn:ietf:params:xml:ns:xmpp-stanzas";
|
|
1375
|
+
function Xe({ name: e, type: t }) {
|
|
1376
1376
|
return e === "iq" && t !== "error" && t !== "result";
|
|
1377
1377
|
}
|
|
1378
|
-
function
|
|
1378
|
+
function Ze({ type: e }, t, n) {
|
|
1379
1379
|
return !(e !== "get" && e !== "set" || t.length !== 1 || !n);
|
|
1380
1380
|
}
|
|
1381
|
-
function
|
|
1382
|
-
return
|
|
1381
|
+
function Qe({ stanza: e }) {
|
|
1382
|
+
return R("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
|
|
1389
|
-
let n =
|
|
1388
|
+
function $e(e, t) {
|
|
1389
|
+
let n = Qe(e);
|
|
1390
1390
|
return n.attrs.type = "result", t && n.append(t), n;
|
|
1391
1391
|
}
|
|
1392
|
-
function
|
|
1393
|
-
let r =
|
|
1392
|
+
function et(e, t, n) {
|
|
1393
|
+
let r = Qe(e);
|
|
1394
1394
|
return r.attrs.type = "error", n && r.append(n), r.append(t), r;
|
|
1395
1395
|
}
|
|
1396
|
-
function
|
|
1397
|
-
return
|
|
1396
|
+
function tt(e, t) {
|
|
1397
|
+
return R("error", { type: e }, R(t, Ye));
|
|
1398
1398
|
}
|
|
1399
|
-
function
|
|
1399
|
+
function nt(e) {
|
|
1400
1400
|
return async function(t, n) {
|
|
1401
|
-
if (!
|
|
1401
|
+
if (!Xe(t)) return n();
|
|
1402
1402
|
let { stanza: r } = t, i = r.getChildElements(), [a] = i;
|
|
1403
|
-
if (
|
|
1403
|
+
if (!Ze(t, i, a)) return et(t, tt("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 =
|
|
1409
|
+
e.emit("error", t), o = tt("cancel", "internal-server-error");
|
|
1410
1410
|
}
|
|
1411
|
-
return o ||=
|
|
1411
|
+
return o ||= tt("cancel", "service-unavailable"), o instanceof R.Element && o.is("error") ? et(t, o, a) : $e(t, o instanceof R.Element ? o : void 0);
|
|
1412
1412
|
};
|
|
1413
1413
|
}
|
|
1414
|
-
function
|
|
1414
|
+
function rt(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
|
|
1418
|
-
return e.use(
|
|
1417
|
+
function it({ middleware: e, entity: t }) {
|
|
1418
|
+
return e.use(nt(t)), {
|
|
1419
1419
|
get(t, n, r) {
|
|
1420
|
-
e.use(
|
|
1420
|
+
e.use(rt("get", t, n, r));
|
|
1421
1421
|
},
|
|
1422
1422
|
set(t, n, r) {
|
|
1423
|
-
e.use(
|
|
1423
|
+
e.use(rt("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
|
|
1430
|
-
function
|
|
1429
|
+
var at = ["ENOTFOUND", "ENODATA"];
|
|
1430
|
+
function ot(e, t = {}) {
|
|
1431
1431
|
return t.all = !0, new Promise((n, r) => {
|
|
1432
|
-
|
|
1432
|
+
V.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 ct(e, t = {}) {
|
|
|
1448
1448
|
});
|
|
1449
1449
|
});
|
|
1450
1450
|
}
|
|
1451
|
-
function
|
|
1451
|
+
function st(e, { service: t, protocol: n }) {
|
|
1452
1452
|
return new Promise((r, i) => {
|
|
1453
|
-
|
|
1454
|
-
e &&
|
|
1453
|
+
V.default.resolveSrv(`_${t}._${n}.${e}`, (e, a) => {
|
|
1454
|
+
e && at.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
|
|
1461
|
+
function ct(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 ut(e) {
|
|
|
1466
1466
|
return r === 0 ? 0 : r;
|
|
1467
1467
|
});
|
|
1468
1468
|
}
|
|
1469
|
-
function
|
|
1469
|
+
function lt(e, t) {
|
|
1470
1470
|
let n = [];
|
|
1471
1471
|
return Promise.all(e.map(async (e) => {
|
|
1472
|
-
let r = await
|
|
1472
|
+
let r = await ot(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 dt(e, t) {
|
|
|
1480
1480
|
}
|
|
1481
1481
|
})).then(() => n);
|
|
1482
1482
|
}
|
|
1483
|
-
function
|
|
1483
|
+
function ut(e, t = {}) {
|
|
1484
1484
|
t.srv ||= [
|
|
1485
1485
|
{
|
|
1486
1486
|
service: "xmpps-client",
|
|
@@ -1524,15 +1524,15 @@ function ft(e, t = {}) {
|
|
|
1524
1524
|
}
|
|
1525
1525
|
];
|
|
1526
1526
|
let n = { options: t };
|
|
1527
|
-
return
|
|
1527
|
+
return ot(e, t).then((r) => Promise.all(t.srv.map((r) => st(e, {
|
|
1528
1528
|
...r,
|
|
1529
1529
|
family: n
|
|
1530
|
-
}).then((e) =>
|
|
1530
|
+
}).then((e) => lt(e, t)))).then((e) => [...ct(e.flat()), ...r]));
|
|
1531
1531
|
}
|
|
1532
1532
|
//#endregion
|
|
1533
1533
|
//#region node_modules/@xmpp/xml/lib/parse.js
|
|
1534
|
-
function
|
|
1535
|
-
let t = new
|
|
1534
|
+
function dt(e) {
|
|
1535
|
+
let t = new le(), 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 pt(e) {
|
|
|
1544
1544
|
}
|
|
1545
1545
|
//#endregion
|
|
1546
1546
|
//#region node_modules/@xmpp/resolve/lib/alt-connections.js
|
|
1547
|
-
function
|
|
1547
|
+
function ft(e) {
|
|
1548
1548
|
return e.startsWith("https") || e.startsWith("wss");
|
|
1549
1549
|
}
|
|
1550
|
-
function
|
|
1550
|
+
function pt(e, t) {
|
|
1551
1551
|
let n;
|
|
1552
|
-
if (n =
|
|
1552
|
+
if (n = ft(e.uri) && !ft(t.uri) ? -1 : !ft(e.uri) && ft(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
|
|
1559
|
-
return fetch(`https://${e}/.well-known/host-meta`).then((e) => e.text()).then((e) =>
|
|
1558
|
+
function mt(e) {
|
|
1559
|
+
return fetch(`https://${e}/.well-known/host-meta`).then((e) => e.text()).then((e) => dt(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 gt(e) {
|
|
|
1565
1565
|
href: e.href,
|
|
1566
1566
|
method: e.rel.split(":").pop(),
|
|
1567
1567
|
uri: e.href
|
|
1568
|
-
})).toSorted(
|
|
1568
|
+
})).toSorted(pt)).catch(() => []);
|
|
1569
1569
|
}
|
|
1570
1570
|
//#endregion
|
|
1571
1571
|
//#region node_modules/@xmpp/resolve/resolve.js
|
|
1572
|
-
function
|
|
1573
|
-
return Promise.all([
|
|
1572
|
+
function ht(...e) {
|
|
1573
|
+
return Promise.all([ut ? ut(...e) : Promise.resolve([]), mt(...e)]).then(([e, t]) => [...e, ...t]);
|
|
1574
1574
|
}
|
|
1575
1575
|
//#endregion
|
|
1576
1576
|
//#region node_modules/@xmpp/resolve/index.js
|
|
1577
|
-
async function
|
|
1578
|
-
let t = await
|
|
1577
|
+
async function gt(e) {
|
|
1578
|
+
let t = await ht(e, { srv: [{
|
|
1579
1579
|
service: "xmpps-client",
|
|
1580
1580
|
protocol: "tcp"
|
|
1581
1581
|
}, {
|
|
@@ -1584,30 +1584,30 @@ async function vt(e) {
|
|
|
1584
1584
|
}] });
|
|
1585
1585
|
return [...new Set(t.map((e) => e.uri))];
|
|
1586
1586
|
}
|
|
1587
|
-
function
|
|
1587
|
+
function _t(e, t) {
|
|
1588
1588
|
return t.filter((t) => e._findTransport(t));
|
|
1589
1589
|
}
|
|
1590
|
-
async function
|
|
1590
|
+
async function vt(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
|
|
1593
|
+
if (!r) return vt(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
|
|
1597
|
+
a.connect(i), await L(a, "connect");
|
|
1598
1598
|
} catch {
|
|
1599
|
-
return
|
|
1599
|
+
return vt(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
|
|
1603
|
+
function yt({ 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 =
|
|
1607
|
+
let r = _t(e, await gt(n));
|
|
1608
1608
|
if (r.length === 0) throw Error("No compatible transport found.");
|
|
1609
1609
|
try {
|
|
1610
|
-
await
|
|
1610
|
+
await vt(e, r);
|
|
1611
1611
|
} catch (t) {
|
|
1612
1612
|
throw await e.disconnect(), e._status("disconnect"), t;
|
|
1613
1613
|
}
|
|
@@ -1615,24 +1615,24 @@ function xt({ entity: e }) {
|
|
|
1615
1615
|
}
|
|
1616
1616
|
//#endregion
|
|
1617
1617
|
//#region node_modules/@xmpp/base64/index.js
|
|
1618
|
-
function
|
|
1618
|
+
function bt(e) {
|
|
1619
1619
|
return globalThis.btoa(e);
|
|
1620
1620
|
}
|
|
1621
|
-
function
|
|
1621
|
+
function xt(e) {
|
|
1622
1622
|
return globalThis.atob(e);
|
|
1623
1623
|
}
|
|
1624
1624
|
//#endregion
|
|
1625
1625
|
//#region node_modules/@xmpp/sasl/lib/SASLError.js
|
|
1626
|
-
var
|
|
1626
|
+
var St = class extends ge {
|
|
1627
1627
|
constructor(...e) {
|
|
1628
1628
|
super(...e), this.name = "SASLError";
|
|
1629
1629
|
}
|
|
1630
|
-
},
|
|
1631
|
-
function
|
|
1630
|
+
}, Ct = "urn:ietf:params:xml:ns:xmpp-sasl";
|
|
1631
|
+
function wt(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
|
|
1635
|
+
async function Tt({ 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 Dt({ saslFactory: e, entity: t, mechanism: n, credentials: r }) {
|
|
|
1645
1645
|
serviceName: a,
|
|
1646
1646
|
...r
|
|
1647
1647
|
};
|
|
1648
|
-
await
|
|
1649
|
-
xmlns:
|
|
1648
|
+
await oe(t, i.clientFirst && R("auth", {
|
|
1649
|
+
xmlns: Ct,
|
|
1650
1650
|
mechanism: i.name
|
|
1651
|
-
},
|
|
1652
|
-
if (e.getNS() ===
|
|
1651
|
+
}, bt(await i.response(o))), async (e, n) => {
|
|
1652
|
+
if (e.getNS() === Ct) {
|
|
1653
1653
|
if (e.name === "challenge") {
|
|
1654
|
-
await i.challenge(
|
|
1654
|
+
await i.challenge(xt(e.text()));
|
|
1655
1655
|
let n = await i.response(o);
|
|
1656
|
-
await t.send(
|
|
1657
|
-
xmlns:
|
|
1656
|
+
await t.send(R("response", {
|
|
1657
|
+
xmlns: Ct,
|
|
1658
1658
|
mechanism: i.name
|
|
1659
|
-
}, typeof n == "string" ?
|
|
1659
|
+
}, typeof n == "string" ? bt(n) : ""));
|
|
1660
1660
|
return;
|
|
1661
1661
|
}
|
|
1662
|
-
if (e.name === "failure") throw
|
|
1662
|
+
if (e.name === "failure") throw St.fromElement(e);
|
|
1663
1663
|
if (e.name === "success") return n();
|
|
1664
1664
|
}
|
|
1665
1665
|
});
|
|
1666
1666
|
}
|
|
1667
|
-
function
|
|
1668
|
-
e.use("mechanisms",
|
|
1669
|
-
let a =
|
|
1670
|
-
if (a.length === 0) throw new
|
|
1667
|
+
function Et({ streamFeatures: e, saslFactory: t }, n) {
|
|
1668
|
+
e.use("mechanisms", Ct, async ({ entity: e }, r, i) => {
|
|
1669
|
+
let a = wt(i, Ct, t);
|
|
1670
|
+
if (a.length === 0) throw new St("SASL: No compatible mechanism available.");
|
|
1671
1671
|
async function o(n, r) {
|
|
1672
|
-
await
|
|
1672
|
+
await Tt({
|
|
1673
1673
|
saslFactory: t,
|
|
1674
1674
|
entity: e,
|
|
1675
1675
|
mechanism: r,
|
|
@@ -1681,8 +1681,8 @@ function Ot({ streamFeatures: e, saslFactory: t }, n) {
|
|
|
1681
1681
|
}
|
|
1682
1682
|
//#endregion
|
|
1683
1683
|
//#region node_modules/@xmpp/sasl2/index.js
|
|
1684
|
-
var
|
|
1685
|
-
async function
|
|
1684
|
+
var Dt = "urn:xmpp:sasl:2";
|
|
1685
|
+
async function Ot({ 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 At({ saslFactory: e, entity: t, mechanism: n, credentials: r, use
|
|
|
1695
1695
|
serviceName: c,
|
|
1696
1696
|
...r
|
|
1697
1697
|
};
|
|
1698
|
-
await
|
|
1699
|
-
xmlns:
|
|
1698
|
+
await oe(t, R("authenticate", {
|
|
1699
|
+
xmlns: Dt,
|
|
1700
1700
|
mechanism: s.name
|
|
1701
1701
|
}, [
|
|
1702
|
-
s.clientFirst &&
|
|
1702
|
+
s.clientFirst && R("initial-response", {}, bt(await s.response(l))),
|
|
1703
1703
|
i,
|
|
1704
1704
|
...a
|
|
1705
1705
|
]), async (e, n) => {
|
|
1706
|
-
if (e.getNS() ===
|
|
1706
|
+
if (e.getNS() === Dt) {
|
|
1707
1707
|
if (e.name === "challenge") {
|
|
1708
|
-
await s.challenge(
|
|
1708
|
+
await s.challenge(xt(e.text()));
|
|
1709
1709
|
let n = await s.response(l);
|
|
1710
|
-
await t.send(
|
|
1711
|
-
xmlns:
|
|
1710
|
+
await t.send(R("response", {
|
|
1711
|
+
xmlns: Dt,
|
|
1712
1712
|
mechanism: s.name
|
|
1713
|
-
}, typeof n == "string" ?
|
|
1713
|
+
}, typeof n == "string" ? bt(n) : ""));
|
|
1714
1714
|
return;
|
|
1715
1715
|
}
|
|
1716
|
-
if (e.name === "failure") throw
|
|
1716
|
+
if (e.name === "failure") throw St.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(
|
|
1720
|
+
r && s.final && await s.final(xt(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 At({ saslFactory: e, entity: t, mechanism: n, credentials: r, use
|
|
|
1726
1726
|
}
|
|
1727
1727
|
});
|
|
1728
1728
|
}
|
|
1729
|
-
function
|
|
1729
|
+
function kt({ streamFeatures: e, saslFactory: t }, n) {
|
|
1730
1730
|
let r = /* @__PURE__ */ new Map(), i;
|
|
1731
|
-
return e.use("authentication",
|
|
1732
|
-
let s =
|
|
1731
|
+
return e.use("authentication", Dt, async ({ entity: e }, a, o) => {
|
|
1732
|
+
let s = wt(o, Dt, t), c = await At({
|
|
1733
1733
|
element: o,
|
|
1734
1734
|
features: r
|
|
1735
1735
|
}), l = !!i?.mechanism;
|
|
1736
|
-
if (s.length === 0 && !l) throw new
|
|
1736
|
+
if (s.length === 0 && !l) throw new St("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:
|
|
1740
|
+
authenticate: Ot,
|
|
1741
1741
|
entity: e,
|
|
1742
1742
|
userAgent: o,
|
|
1743
1743
|
streamFeatures: c,
|
|
1744
1744
|
features: r,
|
|
1745
1745
|
credentials: n
|
|
1746
|
-
}) || await
|
|
1746
|
+
}) || await Ot({
|
|
1747
1747
|
entity: e,
|
|
1748
1748
|
userAgent: o,
|
|
1749
1749
|
streamFeatures: c,
|
|
@@ -1762,7 +1762,7 @@ function jt({ streamFeatures: e, saslFactory: t }, n) {
|
|
|
1762
1762
|
}
|
|
1763
1763
|
};
|
|
1764
1764
|
}
|
|
1765
|
-
async function
|
|
1765
|
+
async function At({ 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 Mt({ element: e, features: t }) {
|
|
|
1773
1773
|
}
|
|
1774
1774
|
//#endregion
|
|
1775
1775
|
//#region node_modules/@xmpp/resource-binding/index.js
|
|
1776
|
-
var
|
|
1777
|
-
function
|
|
1778
|
-
return
|
|
1776
|
+
var jt = "urn:ietf:params:xml:ns:xmpp-bind";
|
|
1777
|
+
function Mt(e) {
|
|
1778
|
+
return R("bind", { xmlns: jt }, e && R("resource", {}, e));
|
|
1779
1779
|
}
|
|
1780
|
-
async function
|
|
1781
|
-
let r = (await t.set(
|
|
1780
|
+
async function Nt(e, t, n) {
|
|
1781
|
+
let r = (await t.set(Mt(n))).getChildText("jid");
|
|
1782
1782
|
return e._jid(r), e._ready(!1), r;
|
|
1783
1783
|
}
|
|
1784
|
-
function
|
|
1784
|
+
function Pt({ iqCaller: e }, t) {
|
|
1785
1785
|
return async ({ entity: n }, r) => {
|
|
1786
|
-
t = typeof t == "function" ? await t() : t, await
|
|
1786
|
+
t = typeof t == "function" ? await t() : t, await Nt(n, e, t), r();
|
|
1787
1787
|
};
|
|
1788
1788
|
}
|
|
1789
|
-
function
|
|
1790
|
-
e.use("bind",
|
|
1789
|
+
function Ft({ streamFeatures: e, iqCaller: t }, n) {
|
|
1790
|
+
e.use("bind", jt, Pt({ iqCaller: t }, n));
|
|
1791
1791
|
}
|
|
1792
1792
|
//#endregion
|
|
1793
1793
|
//#region node_modules/@xmpp/time/index.js
|
|
1794
|
-
function
|
|
1794
|
+
function It(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
|
|
1800
|
-
e.use(
|
|
1799
|
+
function Lt({ bind2: e, sm: t, failed: n, enabled: r }) {
|
|
1800
|
+
e.use(H, (e) => Ht({ 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
|
|
1807
|
-
e.use(
|
|
1808
|
-
if (e.is("sm") && t.id) return
|
|
1806
|
+
function Rt({ sasl2: e, sm: t, failed: n, resumed: r }) {
|
|
1807
|
+
e.use(H, (e) => {
|
|
1808
|
+
if (e.is("sm") && t.id) return Ut({ 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
|
|
1816
|
-
e.use("sm",
|
|
1815
|
+
function zt({ streamFeatures: e, sm: t, entity: n, resumed: r, failed: i, enabled: a }) {
|
|
1816
|
+
e.use("sm", H, async (e, o) => {
|
|
1817
1817
|
if (t.id) try {
|
|
1818
|
-
await r(await
|
|
1818
|
+
await r(await Vt(n, t));
|
|
1819
1819
|
return;
|
|
1820
1820
|
} catch {
|
|
1821
1821
|
i();
|
|
1822
1822
|
}
|
|
1823
1823
|
await o();
|
|
1824
|
-
let s =
|
|
1824
|
+
let s = Bt(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 Vt({ streamFeatures: e, sm: t, entity: n, resumed: r, failed: i, enable
|
|
|
1831
1831
|
}
|
|
1832
1832
|
});
|
|
1833
1833
|
}
|
|
1834
|
-
function
|
|
1835
|
-
return
|
|
1834
|
+
function Bt(e, t) {
|
|
1835
|
+
return oe(e, Ht({ 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
|
|
1837
|
+
if (e.is("failed", "urn:xmpp:sm:3")) throw ge.fromElement(e);
|
|
1838
1838
|
});
|
|
1839
1839
|
}
|
|
1840
|
-
async function
|
|
1841
|
-
return
|
|
1840
|
+
async function Vt(e, t) {
|
|
1841
|
+
return oe(e, Ut({ 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
|
|
1843
|
+
if (e.is("failed", "urn:xmpp:sm:3")) throw ge.fromElement(e);
|
|
1844
1844
|
});
|
|
1845
1845
|
}
|
|
1846
1846
|
//#endregion
|
|
1847
1847
|
//#region node_modules/@xmpp/stream-management/index.js
|
|
1848
|
-
var
|
|
1849
|
-
function
|
|
1850
|
-
return
|
|
1851
|
-
xmlns:
|
|
1848
|
+
var H = "urn:xmpp:sm:3";
|
|
1849
|
+
function Ht({ sm: e }) {
|
|
1850
|
+
return R("enable", {
|
|
1851
|
+
xmlns: H,
|
|
1852
1852
|
max: e.preferredMaximum,
|
|
1853
1853
|
resume: "true"
|
|
1854
1854
|
});
|
|
1855
1855
|
}
|
|
1856
|
-
function
|
|
1857
|
-
return
|
|
1858
|
-
xmlns:
|
|
1856
|
+
function Ut({ sm: e }) {
|
|
1857
|
+
return R("resume", {
|
|
1858
|
+
xmlns: H,
|
|
1859
1859
|
h: e.inbound,
|
|
1860
1860
|
previd: e.id
|
|
1861
1861
|
});
|
|
1862
1862
|
}
|
|
1863
|
-
function
|
|
1864
|
-
let a = null, o = null, s = null, c = new
|
|
1863
|
+
function Wt({ streamFeatures: e, entity: t, middleware: n, bind2: r, sasl2: i }) {
|
|
1864
|
+
let a = null, o = null, s = null, c = new F.EventEmitter();
|
|
1865
1865
|
Object.assign(c, {
|
|
1866
1866
|
preferredMaximum: null,
|
|
1867
1867
|
enabled: !1,
|
|
@@ -1877,8 +1877,8 @@ function Kt({ streamFeatures: e, entity: t, middleware: n, bind2: r, sasl2: i })
|
|
|
1877
1877
|
});
|
|
1878
1878
|
async function l() {
|
|
1879
1879
|
try {
|
|
1880
|
-
await t.send(
|
|
1881
|
-
xmlns:
|
|
1880
|
+
await t.send(R("a", {
|
|
1881
|
+
xmlns: H,
|
|
1882
1882
|
h: c.inbound
|
|
1883
1883
|
}));
|
|
1884
1884
|
} catch {}
|
|
@@ -1891,7 +1891,7 @@ function Kt({ 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) =>
|
|
1894
|
+
c.outbound_q = [], await t.sendMany(n.map((e) => Gt({
|
|
1895
1895
|
entity: t,
|
|
1896
1896
|
item: e
|
|
1897
1897
|
}))), c.emit("resumed"), t._ready(!0), h();
|
|
@@ -1923,12 +1923,12 @@ function Kt({ 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 &&
|
|
1926
|
+
}), r && Lt({
|
|
1927
1927
|
bind2: r,
|
|
1928
1928
|
sm: c,
|
|
1929
1929
|
failed: d,
|
|
1930
1930
|
enabled: m
|
|
1931
|
-
}), i &&
|
|
1931
|
+
}), i && Rt({
|
|
1932
1932
|
sasl2: i,
|
|
1933
1933
|
sm: c,
|
|
1934
1934
|
failed: d,
|
|
@@ -1940,7 +1940,7 @@ function Kt({ 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(
|
|
1943
|
+
}, c.timeout)), t.send(R("r", { xmlns: H })).catch(() => {}), h());
|
|
1944
1944
|
}
|
|
1945
1945
|
return n.filter((e, t) => {
|
|
1946
1946
|
let { stanza: n } = e;
|
|
@@ -1950,9 +1950,9 @@ function Kt({ 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:
|
|
1953
|
+
stamp: It()
|
|
1954
1954
|
}), clearTimeout(o), clearTimeout(s), s = setTimeout(g, c.requestAckDebounce), t());
|
|
1955
|
-
}), e &&
|
|
1955
|
+
}), e && zt({
|
|
1956
1956
|
streamFeatures: e,
|
|
1957
1957
|
sm: c,
|
|
1958
1958
|
entity: t,
|
|
@@ -1961,9 +1961,9 @@ function Kt({ streamFeatures: e, entity: t, middleware: n, bind2: r, sasl2: i })
|
|
|
1961
1961
|
enabled: m
|
|
1962
1962
|
}), c;
|
|
1963
1963
|
}
|
|
1964
|
-
function
|
|
1964
|
+
function Gt({ 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(
|
|
1966
|
+
return n.name === "message" && !n.getChild("delay", "urn:xmpp:delay") && n.append(R("delay", {
|
|
1967
1967
|
xmlns: "urn:xmpp:delay",
|
|
1968
1968
|
from: e.jid.toString(),
|
|
1969
1969
|
stamp: r
|
|
@@ -1971,17 +1971,17 @@ function qt({ entity: e, item: t }) {
|
|
|
1971
1971
|
}
|
|
1972
1972
|
//#endregion
|
|
1973
1973
|
//#region node_modules/@xmpp/client-core/src/bind2/bind2.js
|
|
1974
|
-
var
|
|
1975
|
-
function
|
|
1974
|
+
var Kt = "urn:xmpp:bind:0";
|
|
1975
|
+
function qt({ sasl2: e, entity: t }, n) {
|
|
1976
1976
|
let r = /* @__PURE__ */ new Map();
|
|
1977
|
-
return e.use(
|
|
1978
|
-
if (!e.is("bind",
|
|
1977
|
+
return e.use(Kt, async (e) => {
|
|
1978
|
+
if (!e.is("bind", Kt)) return;
|
|
1979
1979
|
n = typeof n == "function" ? await n() : n;
|
|
1980
|
-
let t = await
|
|
1980
|
+
let t = await Jt({
|
|
1981
1981
|
element: e,
|
|
1982
1982
|
features: r
|
|
1983
1983
|
});
|
|
1984
|
-
return
|
|
1984
|
+
return R("bind", { xmlns: "urn:xmpp:bind:0" }, n && R("tag", null, n), ...t);
|
|
1985
1985
|
}, (e) => {
|
|
1986
1986
|
if (e.is("bound")) {
|
|
1987
1987
|
t._ready(!1);
|
|
@@ -1991,7 +1991,7 @@ function Yt({ sasl2: e, entity: t }, n) {
|
|
|
1991
1991
|
r.set(e, [t, n]);
|
|
1992
1992
|
} };
|
|
1993
1993
|
}
|
|
1994
|
-
function
|
|
1994
|
+
function Jt({ 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 Xt({ element: e, features: t }) {
|
|
|
2002
2002
|
}
|
|
2003
2003
|
//#endregion
|
|
2004
2004
|
//#region node_modules/saslmechanisms/lib/factory.js
|
|
2005
|
-
var
|
|
2005
|
+
var Yt = /* @__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 Zt = /* @__PURE__ */ y(((e, t) => {
|
|
|
2022
2022
|
return null;
|
|
2023
2023
|
}, e = t.exports = n;
|
|
2024
2024
|
});
|
|
2025
|
-
})),
|
|
2025
|
+
})), Xt = /* @__PURE__ */ x((/* @__PURE__ */ y(((e, t) => {
|
|
2026
2026
|
(function(n, r) {
|
|
2027
|
-
typeof e == "object" ? r(e, t,
|
|
2027
|
+
typeof e == "object" ? r(e, t, Yt()) : typeof define == "function" && define.amd && define([
|
|
2028
2028
|
"exports",
|
|
2029
2029
|
"module",
|
|
2030
2030
|
"./lib/factory"
|
|
@@ -2032,9 +2032,9 @@ var Zt = /* @__PURE__ */ y(((e, t) => {
|
|
|
2032
2032
|
})(e, function(e, t, n) {
|
|
2033
2033
|
e = t.exports = n, e.Factory = n;
|
|
2034
2034
|
});
|
|
2035
|
-
})))(), 1),
|
|
2036
|
-
function
|
|
2037
|
-
let n = new
|
|
2035
|
+
})))(), 1), Zt = "urn:xmpp:fast:0";
|
|
2036
|
+
function Qt({ sasl2: e, entity: t }) {
|
|
2037
|
+
let n = new Xt.default(), r, i = new F.EventEmitter();
|
|
2038
2038
|
Object.assign(i, {
|
|
2039
2039
|
mechanism: null,
|
|
2040
2040
|
mechanisms: [],
|
|
@@ -2072,7 +2072,7 @@ function $t({ 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 (
|
|
2075
|
+
if (!$t(c, i.mechanisms)) return l();
|
|
2076
2076
|
try {
|
|
2077
2077
|
return await e({
|
|
2078
2078
|
saslFactory: i.saslFactory,
|
|
@@ -2081,13 +2081,13 @@ function $t({ sasl2: e, entity: t }) {
|
|
|
2081
2081
|
...r,
|
|
2082
2082
|
password: c.token
|
|
2083
2083
|
},
|
|
2084
|
-
streamFeatures: [...o,
|
|
2084
|
+
streamFeatures: [...o, R("fast", { xmlns: Zt })],
|
|
2085
2085
|
entity: t,
|
|
2086
2086
|
userAgent: n,
|
|
2087
2087
|
features: s
|
|
2088
2088
|
}), !0;
|
|
2089
2089
|
} catch (e) {
|
|
2090
|
-
return e instanceof
|
|
2090
|
+
return e instanceof St && ["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 $t({ sasl2: e, entity: t }) {
|
|
|
2095
2095
|
}
|
|
2096
2096
|
});
|
|
2097
2097
|
function a(e) {
|
|
2098
|
-
e.push(
|
|
2099
|
-
xmlns:
|
|
2098
|
+
e.push(R("request-token", {
|
|
2099
|
+
xmlns: Zt,
|
|
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(
|
|
2107
|
-
if (!e.is("fast",
|
|
2106
|
+
return o(), e.use(Zt, async (e) => {
|
|
2107
|
+
if (!e.is("fast", Zt)) return o();
|
|
2108
2108
|
i.available = !0;
|
|
2109
|
-
let t =
|
|
2109
|
+
let t = wt(e, Zt, 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",
|
|
2113
|
+
e.is("token", Zt) && 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
|
|
2120
|
+
function $t(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
|
|
2125
|
+
var en = /* @__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 tn = /* @__PURE__ */ y(((e, t) => {
|
|
|
2134
2134
|
return this;
|
|
2135
2135
|
}, e = t.exports = n;
|
|
2136
2136
|
});
|
|
2137
|
-
})),
|
|
2137
|
+
})), tn = /* @__PURE__ */ x((/* @__PURE__ */ y(((e, t) => {
|
|
2138
2138
|
(function(n, r) {
|
|
2139
|
-
typeof e == "object" ? r(e, t,
|
|
2139
|
+
typeof e == "object" ? r(e, t, en()) : typeof define == "function" && define.amd && define([
|
|
2140
2140
|
"exports",
|
|
2141
2141
|
"module",
|
|
2142
2142
|
"./lib/mechanism"
|
|
@@ -2145,12 +2145,12 @@ var tn = /* @__PURE__ */ y(((e, t) => {
|
|
|
2145
2145
|
e = t.exports = n, e.Mechanism = n;
|
|
2146
2146
|
});
|
|
2147
2147
|
})))(), 1);
|
|
2148
|
-
function
|
|
2149
|
-
e.use(
|
|
2148
|
+
function nn(e) {
|
|
2149
|
+
e.use(tn.default);
|
|
2150
2150
|
}
|
|
2151
2151
|
//#endregion
|
|
2152
2152
|
//#region node_modules/sasl-anonymous/lib/mechanism.js
|
|
2153
|
-
var
|
|
2153
|
+
var rn = /* @__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 an = /* @__PURE__ */ y(((e, t) => {
|
|
|
2159
2159
|
return e.trace || "";
|
|
2160
2160
|
}, n.prototype.challenge = function(e) {}, e = t.exports = n;
|
|
2161
2161
|
});
|
|
2162
|
-
})),
|
|
2162
|
+
})), an = /* @__PURE__ */ x((/* @__PURE__ */ y(((e, t) => {
|
|
2163
2163
|
(function(n, r) {
|
|
2164
|
-
typeof e == "object" ? r(e, t,
|
|
2164
|
+
typeof e == "object" ? r(e, t, rn()) : typeof define == "function" && define.amd && define([
|
|
2165
2165
|
"exports",
|
|
2166
2166
|
"module",
|
|
2167
2167
|
"./lib/mechanism"
|
|
@@ -2170,99 +2170,99 @@ var an = /* @__PURE__ */ y(((e, t) => {
|
|
|
2170
2170
|
e = t.exports = n, e.Mechanism = n;
|
|
2171
2171
|
});
|
|
2172
2172
|
})))(), 1);
|
|
2173
|
-
function
|
|
2174
|
-
e.use(
|
|
2173
|
+
function on(e) {
|
|
2174
|
+
e.use(an.default);
|
|
2175
2175
|
}
|
|
2176
2176
|
//#endregion
|
|
2177
2177
|
//#region node_modules/@xmpp/sasl-ht-sha-256-none/index.js
|
|
2178
|
-
function
|
|
2179
|
-
|
|
2178
|
+
function U() {}
|
|
2179
|
+
U.prototype.Mechanism = U, U.prototype.name = "HT-SHA-256-NONE", U.prototype.clientFirst = !0, U.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
|
-
},
|
|
2186
|
+
}, U.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
|
|
2191
|
-
e.use(
|
|
2190
|
+
function sn(e) {
|
|
2191
|
+
e.use(U);
|
|
2192
2192
|
}
|
|
2193
2193
|
//#endregion
|
|
2194
2194
|
//#region node_modules/@xmpp/client/lib/createOnAuthenticate.js
|
|
2195
|
-
var
|
|
2196
|
-
function
|
|
2195
|
+
var cn = "ANONYMOUS", ln = "PLAIN";
|
|
2196
|
+
function un(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,
|
|
2203
|
+
e.token ??= await a?.fetch(), await r(e, dn({
|
|
2204
2204
|
mechanisms: i,
|
|
2205
2205
|
entity: o,
|
|
2206
2206
|
credentials: e
|
|
2207
2207
|
}), t);
|
|
2208
2208
|
};
|
|
2209
2209
|
}
|
|
2210
|
-
function
|
|
2211
|
-
return !n?.username && !n?.password && !n?.token && e.includes(
|
|
2210
|
+
function dn({ mechanisms: e, entity: t, credentials: n }) {
|
|
2211
|
+
return !n?.username && !n?.password && !n?.token && e.includes(cn) ? cn : t.isSecure() ? e[0] : e.find((e) => e !== ln);
|
|
2212
2212
|
}
|
|
2213
2213
|
//#endregion
|
|
2214
2214
|
//#region node_modules/@xmpp/client/lib/getDomain.js
|
|
2215
|
-
function
|
|
2215
|
+
function fn(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
|
|
2220
|
+
function pn(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 =
|
|
2223
|
-
let l = new
|
|
2224
|
-
r && o.domain && (l.jid =
|
|
2225
|
-
let u =
|
|
2222
|
+
!s && c && (o.domain = fn(c));
|
|
2223
|
+
let l = new we(o);
|
|
2224
|
+
r && o.domain && (l.jid = B(r, o.domain));
|
|
2225
|
+
let u = Ee({ entity: l }), d = Ne({ entity: l }), f = mn(V.default, { entity: l }), p = mn(V.default, { entity: l }), m = He({ entity: l }), h = Ue({ middleware: m }), g = Je({
|
|
2226
2226
|
middleware: m,
|
|
2227
2227
|
entity: l
|
|
2228
|
-
}), _ =
|
|
2228
|
+
}), _ = it({
|
|
2229
2229
|
middleware: m,
|
|
2230
2230
|
entity: l
|
|
2231
|
-
}), v =
|
|
2232
|
-
...typeof
|
|
2233
|
-
plain:
|
|
2234
|
-
anonymous:
|
|
2231
|
+
}), v = yt({ entity: l }), y = new Xt.default(), b = Object.entries({
|
|
2232
|
+
...typeof V.default == "function" && { scramsha1: V.default },
|
|
2233
|
+
plain: nn,
|
|
2234
|
+
anonymous: on
|
|
2235
2235
|
}).map(([e, t]) => ({ [e]: t(y) }));
|
|
2236
|
-
a ??=
|
|
2237
|
-
let x =
|
|
2236
|
+
a ??= R("user-agent", { id: globalThis.crypto.randomUUID() });
|
|
2237
|
+
let x = mn(V.default, { streamFeatures: h }), S = kt({
|
|
2238
2238
|
streamFeatures: h,
|
|
2239
2239
|
saslFactory: y
|
|
2240
|
-
},
|
|
2240
|
+
}, un(n ?? {
|
|
2241
2241
|
username: r,
|
|
2242
2242
|
password: i
|
|
2243
|
-
}, a)), C =
|
|
2243
|
+
}, a)), C = Qt({
|
|
2244
2244
|
sasl2: S,
|
|
2245
2245
|
entity: l
|
|
2246
2246
|
});
|
|
2247
2247
|
S.setup({ fast: C });
|
|
2248
|
-
let w =
|
|
2248
|
+
let w = qt({
|
|
2249
2249
|
sasl2: S,
|
|
2250
2250
|
entity: l
|
|
2251
2251
|
}, t);
|
|
2252
|
-
|
|
2253
|
-
let T =
|
|
2252
|
+
sn(C.saslFactory);
|
|
2253
|
+
let T = Et({
|
|
2254
2254
|
streamFeatures: h,
|
|
2255
2255
|
saslFactory: y
|
|
2256
|
-
},
|
|
2256
|
+
}, un(n ?? {
|
|
2257
2257
|
username: r,
|
|
2258
2258
|
password: i
|
|
2259
|
-
}, a)), E =
|
|
2259
|
+
}, a)), E = Wt({
|
|
2260
2260
|
streamFeatures: h,
|
|
2261
2261
|
entity: l,
|
|
2262
2262
|
middleware: m,
|
|
2263
2263
|
bind2: w,
|
|
2264
2264
|
sasl2: S
|
|
2265
|
-
}), D =
|
|
2265
|
+
}), D = Ft({
|
|
2266
2266
|
iqCaller: g,
|
|
2267
2267
|
streamFeatures: h
|
|
2268
2268
|
}, t);
|
|
@@ -2288,12 +2288,12 @@ function mn(e = {}) {
|
|
|
2288
2288
|
fast: C
|
|
2289
2289
|
});
|
|
2290
2290
|
}
|
|
2291
|
-
function
|
|
2291
|
+
function mn(e, ...t) {
|
|
2292
2292
|
if (typeof e == "function") return e(...t);
|
|
2293
2293
|
}
|
|
2294
2294
|
//#endregion
|
|
2295
2295
|
//#region src/xmpp.ts
|
|
2296
|
-
var
|
|
2296
|
+
var hn = "chat.internal", W = {
|
|
2297
2297
|
carbons: "urn:xmpp:carbons:2",
|
|
2298
2298
|
forward: "urn:xmpp:forward:0",
|
|
2299
2299
|
mam: "urn:xmpp:mam:2",
|
|
@@ -2323,7 +2323,7 @@ var gn = "chat.internal", U = {
|
|
|
2323
2323
|
reactions: "urn:xmpp:reactions:0",
|
|
2324
2324
|
reply: "urn:xmpp:reply:0",
|
|
2325
2325
|
fallback: "urn:xmpp:fallback:0"
|
|
2326
|
-
},
|
|
2326
|
+
}, gn = 3e4, _n = class {
|
|
2327
2327
|
xmpp;
|
|
2328
2328
|
me;
|
|
2329
2329
|
domain;
|
|
@@ -2341,9 +2341,9 @@ var gn = "chat.internal", U = {
|
|
|
2341
2341
|
cfg;
|
|
2342
2342
|
h;
|
|
2343
2343
|
constructor(e, t) {
|
|
2344
|
-
this.cfg = e, this.h = t, this.domain =
|
|
2344
|
+
this.cfg = e, this.h = t, this.domain = hn, this.mucHost = `conference.${hn}`, this.me = `${e.username}@${hn}`, this.xmpp = pn({
|
|
2345
2345
|
service: `wss://${e.host}/xmpp-websocket`,
|
|
2346
|
-
domain:
|
|
2346
|
+
domain: hn,
|
|
2347
2347
|
username: e.username,
|
|
2348
2348
|
password: e.token,
|
|
2349
2349
|
resource: "chat-island." + Math.random().toString(36).slice(2, 8)
|
|
@@ -2351,7 +2351,7 @@ var gn = "chat.internal", U = {
|
|
|
2351
2351
|
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());
|
|
2352
2352
|
}), this.xmpp.on("error", (e) => {
|
|
2353
2353
|
if (!this.stopped) {
|
|
2354
|
-
if (
|
|
2354
|
+
if (yn(e)) {
|
|
2355
2355
|
this.unauthorized = !0, window.clearTimeout(this.retryTimer), this.h.status("unauthorized", e.message);
|
|
2356
2356
|
return;
|
|
2357
2357
|
}
|
|
@@ -2364,14 +2364,14 @@ var gn = "chat.internal", U = {
|
|
|
2364
2364
|
}
|
|
2365
2365
|
this.attempt = 0, this.connected = !0;
|
|
2366
2366
|
try {
|
|
2367
|
-
await this.xmpp.send(
|
|
2367
|
+
await this.xmpp.send(R("iq", {
|
|
2368
2368
|
type: "set",
|
|
2369
2369
|
id: "carbons"
|
|
2370
|
-
},
|
|
2370
|
+
}, R("enable", { xmlns: W.carbons }))), await this.xmpp.send(R("presence"));
|
|
2371
2371
|
} catch {
|
|
2372
2372
|
return;
|
|
2373
2373
|
}
|
|
2374
|
-
window.clearInterval(this.pingTimer), this.pingTimer = window.setInterval(() => this.ping(),
|
|
2374
|
+
window.clearInterval(this.pingTimer), this.pingTimer = window.setInterval(() => this.ping(), gn), this.h.status("online");
|
|
2375
2375
|
}), this.xmpp.on("stanza", (e) => this.onStanza(e));
|
|
2376
2376
|
}
|
|
2377
2377
|
start() {
|
|
@@ -2393,10 +2393,10 @@ var gn = "chat.internal", U = {
|
|
|
2393
2393
|
document.visibilityState === "visible" && this.wake();
|
|
2394
2394
|
};
|
|
2395
2395
|
ping() {
|
|
2396
|
-
this.connected && this.xmpp.iqCaller.request(
|
|
2396
|
+
this.connected && this.xmpp.iqCaller.request(R("iq", {
|
|
2397
2397
|
type: "get",
|
|
2398
2398
|
to: this.domain
|
|
2399
|
-
},
|
|
2399
|
+
}, R("ping", { xmlns: W.ping })), 1e4).catch((e) => {
|
|
2400
2400
|
!this.stopped && this.connected && e.name !== "StanzaError" && this.xmpp.disconnect().catch(() => {});
|
|
2401
2401
|
});
|
|
2402
2402
|
}
|
|
@@ -2410,7 +2410,7 @@ var gn = "chat.internal", U = {
|
|
|
2410
2410
|
let e = this.xmpp;
|
|
2411
2411
|
(e.status === "offline" ? this.xmpp.start() : e.connect(e.options.service).then(() => e.open({ domain: e.options.domain }))).catch((e) => {
|
|
2412
2412
|
if (!this.stopped) {
|
|
2413
|
-
if (
|
|
2413
|
+
if (yn(e)) {
|
|
2414
2414
|
this.unauthorized = !0, this.h.status("unauthorized", e.message);
|
|
2415
2415
|
return;
|
|
2416
2416
|
}
|
|
@@ -2428,24 +2428,24 @@ var gn = "chat.internal", U = {
|
|
|
2428
2428
|
}
|
|
2429
2429
|
async send(e, t, n, r) {
|
|
2430
2430
|
let i = crypto.randomUUID(), a = this.isGroup(e), o = r ? `> ${r.quote ?? ""}\n` : "", s = [
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
xmlns:
|
|
2431
|
+
R("body", {}, o + t),
|
|
2432
|
+
R("origin-id", {
|
|
2433
|
+
xmlns: W.sid,
|
|
2434
2434
|
id: i
|
|
2435
2435
|
}),
|
|
2436
|
-
|
|
2436
|
+
R("store", { xmlns: W.hints })
|
|
2437
2437
|
];
|
|
2438
|
-
return n && s.push(
|
|
2439
|
-
xmlns:
|
|
2438
|
+
return n && s.push(R("x", { xmlns: W.oob }, R("url", {}, n))), r && (s.push(R("reply", {
|
|
2439
|
+
xmlns: W.reply,
|
|
2440
2440
|
id: r.id,
|
|
2441
2441
|
to: a ? `${e}/${r.author}` : `${r.author}@${this.domain}`
|
|
2442
|
-
})), s.push(
|
|
2443
|
-
xmlns:
|
|
2444
|
-
for:
|
|
2445
|
-
},
|
|
2442
|
+
})), s.push(R("fallback", {
|
|
2443
|
+
xmlns: W.fallback,
|
|
2444
|
+
for: W.reply
|
|
2445
|
+
}, R("body", {
|
|
2446
2446
|
start: "0",
|
|
2447
2447
|
end: String([...o].length)
|
|
2448
|
-
})))), a ? (await this.xmpp.send(
|
|
2448
|
+
})))), a ? (await this.xmpp.send(R("message", {
|
|
2449
2449
|
to: e,
|
|
2450
2450
|
type: "groupchat",
|
|
2451
2451
|
id: i
|
|
@@ -2461,7 +2461,7 @@ var gn = "chat.internal", U = {
|
|
|
2461
2461
|
room: e,
|
|
2462
2462
|
nick: this.cfg.username,
|
|
2463
2463
|
reply: r
|
|
2464
|
-
}) : (s.push(
|
|
2464
|
+
}) : (s.push(R("active", { xmlns: W.chatstates })), await this.xmpp.send(R("message", {
|
|
2465
2465
|
to: `${e}@${this.domain}`,
|
|
2466
2466
|
type: "chat",
|
|
2467
2467
|
id: i
|
|
@@ -2478,35 +2478,35 @@ var gn = "chat.internal", U = {
|
|
|
2478
2478
|
});
|
|
2479
2479
|
}
|
|
2480
2480
|
async react(e, t, n) {
|
|
2481
|
-
let r = this.isGroup(e), i =
|
|
2482
|
-
xmlns:
|
|
2481
|
+
let r = this.isGroup(e), i = R("reactions", {
|
|
2482
|
+
xmlns: W.reactions,
|
|
2483
2483
|
id: t
|
|
2484
|
-
}, ...n.map((e) =>
|
|
2485
|
-
await this.xmpp.send(
|
|
2484
|
+
}, ...n.map((e) => R("reaction", {}, e)));
|
|
2485
|
+
await this.xmpp.send(R("message", {
|
|
2486
2486
|
to: r ? e : `${e}@${this.domain}`,
|
|
2487
2487
|
type: r ? "groupchat" : "chat",
|
|
2488
2488
|
id: crypto.randomUUID()
|
|
2489
|
-
}, i,
|
|
2489
|
+
}, i, R("store", { xmlns: W.hints })));
|
|
2490
2490
|
}
|
|
2491
2491
|
async announce(e) {
|
|
2492
|
-
for (let t of e) await this.xmpp.send(
|
|
2492
|
+
for (let t of e) await this.xmpp.send(R("presence", { to: `${t}@${this.domain}` }, R("x", { xmlns: W.hello }))).catch(() => {});
|
|
2493
2493
|
}
|
|
2494
2494
|
typing(e, t) {
|
|
2495
|
-
return this.isGroup(e) ? Promise.resolve() : this.xmpp.send(
|
|
2495
|
+
return this.isGroup(e) ? Promise.resolve() : this.xmpp.send(R("message", {
|
|
2496
2496
|
to: `${e}@${this.domain}`,
|
|
2497
2497
|
type: "chat"
|
|
2498
|
-
},
|
|
2498
|
+
}, R(t ? "composing" : "paused", { xmlns: W.chatstates })));
|
|
2499
2499
|
}
|
|
2500
2500
|
enablePush(e, t) {
|
|
2501
|
-
return this.xmpp.iqCaller.request(
|
|
2502
|
-
xmlns:
|
|
2501
|
+
return this.xmpp.iqCaller.request(R("iq", { type: "set" }, R("enable", {
|
|
2502
|
+
xmlns: W.push,
|
|
2503
2503
|
jid: e,
|
|
2504
2504
|
node: t
|
|
2505
2505
|
})), 15e3);
|
|
2506
2506
|
}
|
|
2507
2507
|
disablePush(e, t) {
|
|
2508
|
-
return this.xmpp.iqCaller.request(
|
|
2509
|
-
xmlns:
|
|
2508
|
+
return this.xmpp.iqCaller.request(R("iq", { type: "set" }, R("disable", {
|
|
2509
|
+
xmlns: W.push,
|
|
2510
2510
|
jid: e,
|
|
2511
2511
|
node: t
|
|
2512
2512
|
})), 5e3);
|
|
@@ -2520,27 +2520,27 @@ var gn = "chat.internal", U = {
|
|
|
2520
2520
|
async mam(e, t, n) {
|
|
2521
2521
|
let r = crypto.randomUUID();
|
|
2522
2522
|
this.mamQueries.set(r, []), this.mamReactions.set(r, []);
|
|
2523
|
-
let i =
|
|
2523
|
+
let i = R("set", { xmlns: W.rsm }, R("max", {}, String(n)), R("before", {}, t ?? "")), a = [R("field", {
|
|
2524
2524
|
var: "FORM_TYPE",
|
|
2525
2525
|
type: "hidden"
|
|
2526
|
-
},
|
|
2527
|
-
e && a.push(
|
|
2528
|
-
let o =
|
|
2529
|
-
xmlns:
|
|
2526
|
+
}, R("value", {}, W.mam))];
|
|
2527
|
+
e && a.push(R("field", { var: "with" }, R("value", {}, this.isGroup(e) ? e : `${e}@${this.domain}`)));
|
|
2528
|
+
let o = R("x", {
|
|
2529
|
+
xmlns: W.data,
|
|
2530
2530
|
type: "submit"
|
|
2531
2531
|
}, ...a), s, c, l;
|
|
2532
2532
|
try {
|
|
2533
|
-
s = await this.xmpp.iqCaller.request(
|
|
2533
|
+
s = await this.xmpp.iqCaller.request(R("iq", {
|
|
2534
2534
|
type: "set",
|
|
2535
2535
|
id: r
|
|
2536
|
-
},
|
|
2537
|
-
xmlns:
|
|
2536
|
+
}, R("query", {
|
|
2537
|
+
xmlns: W.mam,
|
|
2538
2538
|
queryid: r
|
|
2539
2539
|
}, o, i)), 3e4);
|
|
2540
2540
|
} finally {
|
|
2541
2541
|
c = this.mamQueries.get(r) ?? [], l = this.mamReactions.get(r) ?? [], this.mamQueries.delete(r), this.mamReactions.delete(r);
|
|
2542
2542
|
}
|
|
2543
|
-
let u = s.getChild("fin",
|
|
2543
|
+
let u = s.getChild("fin", W.mam), d = u?.getChild("set", W.rsm)?.getChildText("first") ?? void 0;
|
|
2544
2544
|
return {
|
|
2545
2545
|
messages: c,
|
|
2546
2546
|
reactions: l,
|
|
@@ -2549,103 +2549,103 @@ var gn = "chat.internal", U = {
|
|
|
2549
2549
|
};
|
|
2550
2550
|
}
|
|
2551
2551
|
async createGroup(e, t, n) {
|
|
2552
|
-
let r = `g-${Math.random().toString(36).slice(2, 10)}@${this.mucHost}`, i = this.cfg.username, a = this.waitFor((e) => e.is("presence") &&
|
|
2553
|
-
await this.xmpp.send(
|
|
2554
|
-
let o = (e, t) =>
|
|
2555
|
-
await this.xmpp.iqCaller.request(
|
|
2552
|
+
let r = `g-${Math.random().toString(36).slice(2, 10)}@${this.mucHost}`, i = this.cfg.username, a = this.waitFor((e) => e.is("presence") && G(e.attrs.from) === r, 1e4);
|
|
2553
|
+
await this.xmpp.send(R("presence", { to: `${r}/${i}` }, R("x", { xmlns: W.muc }))), await a;
|
|
2554
|
+
let o = (e, t) => R("field", { var: e }, R("value", {}, t));
|
|
2555
|
+
await this.xmpp.iqCaller.request(R("iq", {
|
|
2556
2556
|
type: "set",
|
|
2557
2557
|
to: r
|
|
2558
|
-
},
|
|
2559
|
-
xmlns:
|
|
2558
|
+
}, R("query", { xmlns: W.mucOwner }, R("x", {
|
|
2559
|
+
xmlns: W.data,
|
|
2560
2560
|
type: "submit"
|
|
2561
2561
|
}, o("FORM_TYPE", "http://jabber.org/protocol/muc#roomconfig"), o("muc#roomconfig_roomname", e), o("muc#roomconfig_persistentroom", "1"), o("muc#roomconfig_membersonly", "1"), o("muc#roomconfig_publicroom", "0"), o("muc#roomconfig_whois", "anyone"), o("allow_subscription", "1"), o("mam", "1")))), 15e3), n && await this.setGroupAvatar(r, n).catch(() => {});
|
|
2562
2562
|
let s = t.filter((e) => e && e !== this.cfg.username), c = Date.now();
|
|
2563
|
-
await this.xmpp.iqCaller.request(
|
|
2563
|
+
await this.xmpp.iqCaller.request(R("iq", {
|
|
2564
2564
|
type: "set",
|
|
2565
2565
|
to: r
|
|
2566
|
-
},
|
|
2566
|
+
}, R("query", { xmlns: W.mucAdmin }, ...s.map((e, t) => R("item", {
|
|
2567
2567
|
affiliation: "member",
|
|
2568
2568
|
jid: `${e}@${this.domain}`
|
|
2569
|
-
},
|
|
2570
|
-
for (let e of s) await this.xmpp.iqCaller.request(
|
|
2569
|
+
}, R("reason", {}, String(c + t)))))), 15e3);
|
|
2570
|
+
for (let e of s) await this.xmpp.iqCaller.request(R("iq", {
|
|
2571
2571
|
type: "set",
|
|
2572
2572
|
to: r
|
|
2573
|
-
},
|
|
2574
|
-
xmlns:
|
|
2573
|
+
}, R("subscribe", {
|
|
2574
|
+
xmlns: W.mucsub,
|
|
2575
2575
|
jid: `${e}@${this.domain}`,
|
|
2576
2576
|
nick: e
|
|
2577
|
-
},
|
|
2578
|
-
await this.xmpp.iqCaller.request(
|
|
2577
|
+
}, R("event", { node: W.mucsubMessages }), R("event", { node: W.mucsubConfig }))), 15e3).catch(() => {});
|
|
2578
|
+
await this.xmpp.iqCaller.request(R("iq", {
|
|
2579
2579
|
type: "set",
|
|
2580
2580
|
to: r
|
|
2581
|
-
},
|
|
2582
|
-
xmlns:
|
|
2581
|
+
}, R("subscribe", {
|
|
2582
|
+
xmlns: W.mucsub,
|
|
2583
2583
|
nick: i
|
|
2584
|
-
},
|
|
2584
|
+
}, R("event", { node: W.mucsubMessages }), R("event", { node: W.mucsubConfig }))), 15e3), await this.xmpp.send(R("presence", {
|
|
2585
2585
|
to: `${r}/${i}`,
|
|
2586
2586
|
type: "unavailable"
|
|
2587
2587
|
}));
|
|
2588
|
-
for (let t of s) await this.xmpp.send(
|
|
2589
|
-
xmlns:
|
|
2588
|
+
for (let t of s) await this.xmpp.send(R("message", { to: `${t}@${this.domain}` }, R("x", {
|
|
2589
|
+
xmlns: W.conference,
|
|
2590
2590
|
jid: r,
|
|
2591
2591
|
reason: e
|
|
2592
2592
|
}))).catch(() => {});
|
|
2593
2593
|
return r;
|
|
2594
2594
|
}
|
|
2595
2595
|
async leaveGroup(e, t) {
|
|
2596
|
-
t ? await this.xmpp.iqCaller.request(
|
|
2596
|
+
t ? await this.xmpp.iqCaller.request(R("iq", {
|
|
2597
2597
|
type: "set",
|
|
2598
2598
|
to: e
|
|
2599
|
-
},
|
|
2599
|
+
}, R("query", { xmlns: W.mucOwner }, R("destroy", {}))), 1e4) : await this.xmpp.iqCaller.request(R("iq", {
|
|
2600
2600
|
type: "set",
|
|
2601
2601
|
to: e
|
|
2602
|
-
},
|
|
2602
|
+
}, R("unsubscribe", { xmlns: W.mucsub })), 1e4);
|
|
2603
2603
|
}
|
|
2604
2604
|
async setGroupAvatar(e, t) {
|
|
2605
2605
|
let n = /^data:(image\/[a-z+]+);base64,(.+)$/i.exec(t);
|
|
2606
|
-
n && await this.xmpp.iqCaller.request(
|
|
2606
|
+
n && await this.xmpp.iqCaller.request(R("iq", {
|
|
2607
2607
|
type: "set",
|
|
2608
2608
|
to: e
|
|
2609
|
-
},
|
|
2609
|
+
}, R("vCard", { xmlns: W.vcard }, R("PHOTO", {}, R("TYPE", {}, n[1]), R("BINVAL", {}, n[2])))), 15e3);
|
|
2610
2610
|
}
|
|
2611
2611
|
async groupAvatar(e) {
|
|
2612
|
-
let t = (await this.xmpp.iqCaller.request(
|
|
2612
|
+
let t = (await this.xmpp.iqCaller.request(R("iq", {
|
|
2613
2613
|
type: "get",
|
|
2614
2614
|
to: e
|
|
2615
|
-
},
|
|
2615
|
+
}, R("vCard", { xmlns: W.vcard })), 1e4)).getChild("vCard", W.vcard)?.getChild("PHOTO"), n = t?.getChildText("BINVAL");
|
|
2616
2616
|
return n ? `data:${t?.getChildText("TYPE") || "image/jpeg"};base64,${n.replace(/\s+/g, "")}` : void 0;
|
|
2617
2617
|
}
|
|
2618
2618
|
async listGroups() {
|
|
2619
|
-
let e = ((await this.xmpp.iqCaller.request(
|
|
2619
|
+
let e = ((await this.xmpp.iqCaller.request(R("iq", {
|
|
2620
2620
|
type: "get",
|
|
2621
2621
|
to: this.mucHost
|
|
2622
|
-
},
|
|
2622
|
+
}, R("subscriptions", { xmlns: W.mucsub })), 15e3)).getChild("subscriptions", W.mucsub)?.getChildren("subscription") ?? []).map((e) => e.attrs.jid);
|
|
2623
2623
|
return Promise.all(e.map((e) => this.groupInfo(e)));
|
|
2624
2624
|
}
|
|
2625
2625
|
async subscribed(e) {
|
|
2626
|
-
return ((await this.xmpp.iqCaller.request(
|
|
2626
|
+
return ((await this.xmpp.iqCaller.request(R("iq", {
|
|
2627
2627
|
type: "get",
|
|
2628
2628
|
to: this.mucHost
|
|
2629
|
-
},
|
|
2629
|
+
}, R("subscriptions", { xmlns: W.mucsub })), 15e3)).getChild("subscriptions", W.mucsub)?.getChildren("subscription") ?? []).some((t) => G(t.attrs.jid) === e);
|
|
2630
2630
|
}
|
|
2631
2631
|
async groupInfo(e) {
|
|
2632
2632
|
let t = e.split("@")[0], n = [], r = !1;
|
|
2633
2633
|
try {
|
|
2634
|
-
t = (await this.xmpp.iqCaller.request(
|
|
2634
|
+
t = (await this.xmpp.iqCaller.request(R("iq", {
|
|
2635
2635
|
type: "get",
|
|
2636
2636
|
to: e
|
|
2637
|
-
},
|
|
2637
|
+
}, R("query", { xmlns: W.discoInfo })), 1e4)).getChild("query", W.discoInfo)?.getChild("identity")?.attrs.name || t;
|
|
2638
2638
|
} catch {}
|
|
2639
2639
|
try {
|
|
2640
|
-
n = ((await this.xmpp.iqCaller.request(
|
|
2640
|
+
n = ((await this.xmpp.iqCaller.request(R("iq", {
|
|
2641
2641
|
type: "get",
|
|
2642
2642
|
to: e
|
|
2643
|
-
},
|
|
2644
|
-
let t = await this.xmpp.iqCaller.request(
|
|
2643
|
+
}, R("query", { xmlns: W.mucAdmin }, R("item", { affiliation: "member" }))), 1e4)).getChild("query", W.mucAdmin)?.getChildren("item") ?? []).map((e) => K(e.attrs.jid));
|
|
2644
|
+
let t = await this.xmpp.iqCaller.request(R("iq", {
|
|
2645
2645
|
type: "get",
|
|
2646
2646
|
to: e
|
|
2647
|
-
},
|
|
2648
|
-
for (let e of t.getChild("query",
|
|
2647
|
+
}, R("query", { xmlns: W.mucAdmin }, R("item", { affiliation: "owner" }))), 1e4);
|
|
2648
|
+
for (let e of t.getChild("query", W.mucAdmin)?.getChildren("item") ?? []) n.push(K(e.attrs.jid)), K(e.attrs.jid) === this.cfg.username && (r = !0);
|
|
2649
2649
|
} catch {}
|
|
2650
2650
|
let i = await this.groupAvatar(e).catch(() => void 0);
|
|
2651
2651
|
return {
|
|
@@ -2657,15 +2657,15 @@ var gn = "chat.internal", U = {
|
|
|
2657
2657
|
};
|
|
2658
2658
|
}
|
|
2659
2659
|
async upload(e) {
|
|
2660
|
-
let t = await this.findUploadService(), n = (await this.xmpp.iqCaller.request(
|
|
2660
|
+
let t = await this.findUploadService(), n = (await this.xmpp.iqCaller.request(R("iq", {
|
|
2661
2661
|
type: "get",
|
|
2662
2662
|
to: t
|
|
2663
|
-
},
|
|
2664
|
-
xmlns:
|
|
2663
|
+
}, R("request", {
|
|
2664
|
+
xmlns: W.upload,
|
|
2665
2665
|
filename: e.name,
|
|
2666
2666
|
size: String(e.size),
|
|
2667
2667
|
"content-type": e.type || "application/octet-stream"
|
|
2668
|
-
})), 3e4)).getChild("slot",
|
|
2668
|
+
})), 3e4)).getChild("slot", W.upload), r = n?.getChild("put"), i = n?.getChild("get")?.attrs.url;
|
|
2669
2669
|
if (!r || !i) throw Error("upload: no slot");
|
|
2670
2670
|
let a = { "Content-Type": e.type || "application/octet-stream" };
|
|
2671
2671
|
for (let e of r.getChildren("header")) a[e.attrs.name] = e.text();
|
|
@@ -2681,20 +2681,20 @@ var gn = "chat.internal", U = {
|
|
|
2681
2681
|
if (this.uploadService) return this.uploadService;
|
|
2682
2682
|
let e = async (e) => {
|
|
2683
2683
|
try {
|
|
2684
|
-
return (await this.xmpp.iqCaller.request(
|
|
2684
|
+
return (await this.xmpp.iqCaller.request(R("iq", {
|
|
2685
2685
|
type: "get",
|
|
2686
2686
|
to: e
|
|
2687
|
-
},
|
|
2687
|
+
}, R("query", { xmlns: W.discoInfo })), 1e4)).getChild("query", W.discoInfo)?.getChildren("feature").some((e) => e.attrs.var === W.upload) ?? !1;
|
|
2688
2688
|
} catch {
|
|
2689
2689
|
return !1;
|
|
2690
2690
|
}
|
|
2691
2691
|
}, t = [`upload.${this.domain}`];
|
|
2692
2692
|
try {
|
|
2693
|
-
let e = await this.xmpp.iqCaller.request(
|
|
2693
|
+
let e = await this.xmpp.iqCaller.request(R("iq", {
|
|
2694
2694
|
type: "get",
|
|
2695
2695
|
to: this.domain
|
|
2696
|
-
},
|
|
2697
|
-
for (let n of e.getChild("query",
|
|
2696
|
+
}, R("query", { xmlns: W.disco })), 1e4);
|
|
2697
|
+
for (let n of e.getChild("query", W.disco)?.getChildren("item") ?? []) t.includes(n.attrs.jid) || t.push(n.attrs.jid);
|
|
2698
2698
|
} catch {}
|
|
2699
2699
|
for (let n of t) if (await e(n)) return this.uploadService = n, n;
|
|
2700
2700
|
throw Error("upload: service not found");
|
|
@@ -2715,46 +2715,46 @@ var gn = "chat.internal", U = {
|
|
|
2715
2715
|
onStanza(e) {
|
|
2716
2716
|
for (let t of [...this.waiters]) t.test(e) && (this.waiters.splice(this.waiters.indexOf(t), 1), t.resolve());
|
|
2717
2717
|
if (e.is("presence")) {
|
|
2718
|
-
let t = e.attrs.from ?? "", n =
|
|
2718
|
+
let t = e.attrs.from ?? "", n = G(t);
|
|
2719
2719
|
if (!n || n === this.me || n.endsWith("@" + this.mucHost) || e.attrs.type === "error" || e.attrs.type?.startsWith("subscribe")) return;
|
|
2720
|
-
let r =
|
|
2720
|
+
let r = K(n), i = this.online.get(r) ?? /* @__PURE__ */ new Set();
|
|
2721
2721
|
e.attrs.type === "unavailable" ? i.delete(t) : i.add(t), this.online.set(r, i), this.h.presence(r, i.size > 0);
|
|
2722
|
-
let a = e.getChild("x",
|
|
2723
|
-
a && !a.attrs.reply && e.attrs.type !== "unavailable" && this.xmpp.send(
|
|
2724
|
-
xmlns:
|
|
2722
|
+
let a = e.getChild("x", W.hello);
|
|
2723
|
+
a && !a.attrs.reply && e.attrs.type !== "unavailable" && this.xmpp.send(R("presence", { to: n }, R("x", {
|
|
2724
|
+
xmlns: W.hello,
|
|
2725
2725
|
reply: "1"
|
|
2726
2726
|
}))).catch(() => {});
|
|
2727
2727
|
return;
|
|
2728
2728
|
}
|
|
2729
2729
|
if (!e.is("message")) return;
|
|
2730
|
-
let t = !e.attrs.from ||
|
|
2730
|
+
let t = !e.attrs.from || G(e.attrs.from) === this.me, n = e.getChild("result", W.mam);
|
|
2731
2731
|
if (n) {
|
|
2732
2732
|
if (!t) return;
|
|
2733
|
-
let e = n.getChild("forwarded",
|
|
2733
|
+
let e = n.getChild("forwarded", W.forward)?.getChild("message"), r = this.mamQueries.get(n.attrs.queryid);
|
|
2734
2734
|
if (e && r) {
|
|
2735
2735
|
let t = this.reactionOf(e);
|
|
2736
2736
|
t && this.mamReactions.get(n.attrs.queryid)?.push(t);
|
|
2737
|
-
let i = t ? void 0 : this.toMessage(e, n.attrs.id,
|
|
2737
|
+
let i = t ? void 0 : this.toMessage(e, n.attrs.id, bn(n.getChild("forwarded", W.forward)));
|
|
2738
2738
|
i && r.push(i);
|
|
2739
2739
|
}
|
|
2740
2740
|
return;
|
|
2741
2741
|
}
|
|
2742
|
-
let r = e.getChild("received",
|
|
2742
|
+
let r = e.getChild("received", W.carbons) ?? e.getChild("sent", W.carbons);
|
|
2743
2743
|
if (r) {
|
|
2744
2744
|
if (!t) return;
|
|
2745
|
-
let e = r.getChild("forwarded",
|
|
2745
|
+
let e = r.getChild("forwarded", W.forward)?.getChild("message");
|
|
2746
2746
|
e && this.deliver(e);
|
|
2747
2747
|
return;
|
|
2748
2748
|
}
|
|
2749
|
-
let i = e.getChild("event",
|
|
2750
|
-
if (i?.getChild("items")?.attrs.node ===
|
|
2751
|
-
let t =
|
|
2752
|
-
this.isGroup(t) &&
|
|
2749
|
+
let i = e.getChild("event", W.pubsubEvent);
|
|
2750
|
+
if (i?.getChild("items")?.attrs.node === W.mucsubConfig) {
|
|
2751
|
+
let t = G(e.attrs.from);
|
|
2752
|
+
this.isGroup(t) && xn(i, "presence")?.getChild("x", W.mucUser)?.getChild("destroy") && this.h.groupDestroyed(t);
|
|
2753
2753
|
return;
|
|
2754
2754
|
}
|
|
2755
|
-
let a = e.getChild("x",
|
|
2755
|
+
let a = e.getChild("x", W.conference);
|
|
2756
2756
|
if (a) {
|
|
2757
|
-
let e =
|
|
2757
|
+
let e = G(a.attrs.jid);
|
|
2758
2758
|
this.isGroup(e) && this.h.groupInvite(e);
|
|
2759
2759
|
return;
|
|
2760
2760
|
}
|
|
@@ -2766,24 +2766,24 @@ var gn = "chat.internal", U = {
|
|
|
2766
2766
|
this.h.reaction(t);
|
|
2767
2767
|
return;
|
|
2768
2768
|
}
|
|
2769
|
-
let n = this.toMessage(e, e.getChild("stanza-id",
|
|
2769
|
+
let n = this.toMessage(e, e.getChild("stanza-id", W.sid)?.attrs.id, bn(e));
|
|
2770
2770
|
if (n) {
|
|
2771
2771
|
this.h.message(n);
|
|
2772
2772
|
return;
|
|
2773
2773
|
}
|
|
2774
2774
|
if (e.attrs.type !== "chat") return;
|
|
2775
|
-
let r =
|
|
2776
|
-
!e.getChild("body") && a && this.h.typing(
|
|
2775
|
+
let r = G(e.attrs.from), i = r === this.me ? G(e.attrs.to) : r, a = e.getChildByAttr("xmlns", W.chatstates);
|
|
2776
|
+
!e.getChild("body") && a && this.h.typing(K(i), a.name === "composing");
|
|
2777
2777
|
}
|
|
2778
2778
|
reactionOf(e) {
|
|
2779
|
-
let t = e.getChild("event",
|
|
2780
|
-
if (t && t.getChild("items")?.attrs.node ===
|
|
2781
|
-
r =
|
|
2782
|
-
let i =
|
|
2783
|
-
if (!this.isGroup(r) || !i ||
|
|
2779
|
+
let t = e.getChild("event", W.pubsubEvent), n = e, r;
|
|
2780
|
+
if (t && t.getChild("items")?.attrs.node === W.mucsubMessages) {
|
|
2781
|
+
r = G(e.attrs.from);
|
|
2782
|
+
let i = Sn(t);
|
|
2783
|
+
if (!this.isGroup(r) || !i || G(i.attrs.from) !== r) return;
|
|
2784
2784
|
n = i;
|
|
2785
|
-
} else if (e.attrs.type === "groupchat" && (r =
|
|
2786
|
-
let i = n.getChild("reactions",
|
|
2785
|
+
} else if (e.attrs.type === "groupchat" && (r = G(e.attrs.from), !this.isGroup(r))) return;
|
|
2786
|
+
let i = n.getChild("reactions", W.reactions), a = i?.attrs.id;
|
|
2787
2787
|
if (!i || !a) return;
|
|
2788
2788
|
let o = [...new Set(i.getChildren("reaction").map((e) => e.text().trim()).filter((e) => e && e.length <= 16))].slice(0, 5);
|
|
2789
2789
|
if (r) {
|
|
@@ -2796,11 +2796,11 @@ var gn = "chat.internal", U = {
|
|
|
2796
2796
|
} : void 0;
|
|
2797
2797
|
}
|
|
2798
2798
|
if (n.attrs.type !== "chat") return;
|
|
2799
|
-
let s =
|
|
2799
|
+
let s = G(n.attrs.from), c = s === this.me || !n.attrs.from, l = K(c ? G(n.attrs.to) : s);
|
|
2800
2800
|
return l ? {
|
|
2801
2801
|
peer: l,
|
|
2802
2802
|
target: a,
|
|
2803
|
-
user: c ? this.cfg.username :
|
|
2803
|
+
user: c ? this.cfg.username : K(s),
|
|
2804
2804
|
emojis: o
|
|
2805
2805
|
} : void 0;
|
|
2806
2806
|
}
|
|
@@ -2810,48 +2810,48 @@ var gn = "chat.internal", U = {
|
|
|
2810
2810
|
let e = this.uploadUrl(r.oob);
|
|
2811
2811
|
r.body = r.body === r.oob ? e : r.body, r.oob = e;
|
|
2812
2812
|
}
|
|
2813
|
-
return r &&
|
|
2813
|
+
return r && vn(r, xn(e, "reply") ? e.getChild("event", W.pubsubEvent) ? Sn(e.getChild("event", W.pubsubEvent)) : e : void 0);
|
|
2814
2814
|
}
|
|
2815
2815
|
uploadUrl(e) {
|
|
2816
2816
|
let t = e.indexOf("/upload/");
|
|
2817
2817
|
return /^https:\/\/[^/]+\/upload\//.test(e) ? `https://${this.cfg.host}${e.slice(t)}` : e;
|
|
2818
2818
|
}
|
|
2819
2819
|
parseMessage(e, t, n) {
|
|
2820
|
-
let r = e.getChild("event",
|
|
2821
|
-
if (r && r.getChild("items")?.attrs.node ===
|
|
2822
|
-
let i =
|
|
2820
|
+
let r = e.getChild("event", W.pubsubEvent);
|
|
2821
|
+
if (r && r.getChild("items")?.attrs.node === W.mucsubMessages) {
|
|
2822
|
+
let i = G(e.attrs.from);
|
|
2823
2823
|
if (!this.isGroup(i)) return;
|
|
2824
|
-
let a =
|
|
2825
|
-
if (!a ||
|
|
2824
|
+
let a = Sn(r);
|
|
2825
|
+
if (!a || G(a.attrs.from) !== i) return;
|
|
2826
2826
|
let o = (a.attrs.from ?? "").split("/")[1] ?? "", s = a.getChildText("body");
|
|
2827
2827
|
return s == null ? void 0 : {
|
|
2828
|
-
id: a.getChild("origin-id",
|
|
2829
|
-
oid: a.getChild("origin-id",
|
|
2828
|
+
id: a.getChild("origin-id", W.sid)?.attrs.id ?? t ?? a.getChild("stanza-id", W.sid)?.attrs.id ?? a.attrs.id ?? crypto.randomUUID(),
|
|
2829
|
+
oid: a.getChild("origin-id", W.sid)?.attrs.id ?? a.attrs.id,
|
|
2830
2830
|
from: i,
|
|
2831
2831
|
to: this.cfg.username,
|
|
2832
2832
|
body: s,
|
|
2833
|
-
ts:
|
|
2833
|
+
ts: bn(a) !== n && a.getChild("delay", W.delay) ? bn(a) : n,
|
|
2834
2834
|
mine: o === this.cfg.username,
|
|
2835
|
-
oob: a.getChild("x",
|
|
2835
|
+
oob: a.getChild("x", W.oob)?.getChildText("url") ?? void 0,
|
|
2836
2836
|
room: i,
|
|
2837
2837
|
nick: o
|
|
2838
2838
|
};
|
|
2839
2839
|
}
|
|
2840
2840
|
let i = e.getChildText("body");
|
|
2841
2841
|
if (i == null) return;
|
|
2842
|
-
let a =
|
|
2842
|
+
let a = G(e.attrs.from);
|
|
2843
2843
|
if (e.attrs.type === "groupchat") {
|
|
2844
2844
|
if (!this.isGroup(a)) return;
|
|
2845
2845
|
let r = (e.attrs.from ?? "").split("/")[1] ?? "";
|
|
2846
2846
|
return {
|
|
2847
|
-
id: t ?? e.getChild("origin-id",
|
|
2848
|
-
oid: e.getChild("origin-id",
|
|
2847
|
+
id: t ?? e.getChild("origin-id", W.sid)?.attrs.id ?? e.attrs.id ?? crypto.randomUUID(),
|
|
2848
|
+
oid: e.getChild("origin-id", W.sid)?.attrs.id ?? e.attrs.id,
|
|
2849
2849
|
from: a,
|
|
2850
2850
|
to: this.cfg.username,
|
|
2851
2851
|
body: i,
|
|
2852
2852
|
ts: n,
|
|
2853
2853
|
mine: r === this.cfg.username,
|
|
2854
|
-
oob: e.getChild("x",
|
|
2854
|
+
oob: e.getChild("x", W.oob)?.getChildText("url") ?? void 0,
|
|
2855
2855
|
room: a,
|
|
2856
2856
|
nick: r
|
|
2857
2857
|
};
|
|
@@ -2859,21 +2859,21 @@ var gn = "chat.internal", U = {
|
|
|
2859
2859
|
if (e.attrs.type !== "chat") return;
|
|
2860
2860
|
let o = a === this.me;
|
|
2861
2861
|
return {
|
|
2862
|
-
id: t ?? e.getChild("origin-id",
|
|
2863
|
-
oid: e.getChild("origin-id",
|
|
2864
|
-
from:
|
|
2865
|
-
to: G(
|
|
2862
|
+
id: t ?? e.getChild("origin-id", W.sid)?.attrs.id ?? e.attrs.id ?? crypto.randomUUID(),
|
|
2863
|
+
oid: e.getChild("origin-id", W.sid)?.attrs.id ?? e.attrs.id,
|
|
2864
|
+
from: K(a),
|
|
2865
|
+
to: K(G(e.attrs.to)),
|
|
2866
2866
|
body: i,
|
|
2867
2867
|
ts: n,
|
|
2868
2868
|
mine: o,
|
|
2869
|
-
oob: e.getChild("x",
|
|
2869
|
+
oob: e.getChild("x", W.oob)?.getChildText("url") ?? void 0
|
|
2870
2870
|
};
|
|
2871
2871
|
}
|
|
2872
|
-
},
|
|
2873
|
-
function
|
|
2874
|
-
let n = t?.getChild("reply",
|
|
2872
|
+
}, G = (e = "") => e.split("/")[0];
|
|
2873
|
+
function vn(e, t) {
|
|
2874
|
+
let n = t?.getChild("reply", W.reply);
|
|
2875
2875
|
if (!n?.attrs.id) return e;
|
|
2876
|
-
let r = n.attrs.to ?? "", i = e.room ? r.split("/")[1] ?? "" : G(
|
|
2876
|
+
let r = n.attrs.to ?? "", i = e.room ? r.split("/")[1] ?? "" : K(G(r)), a = t.getChildren("fallback", W.fallback).find((e) => e.attrs.for === W.reply)?.getChild("body"), o = [...e.body], s = Number(a?.attrs.start ?? 0), c = Number(a?.attrs.end ?? 0);
|
|
2877
2877
|
if (!a || !(c > s) || c > o.length) return {
|
|
2878
2878
|
...e,
|
|
2879
2879
|
reply: {
|
|
@@ -2892,23 +2892,23 @@ function yn(e, t) {
|
|
|
2892
2892
|
}
|
|
2893
2893
|
};
|
|
2894
2894
|
}
|
|
2895
|
-
var
|
|
2896
|
-
let t = e?.getChild("delay",
|
|
2895
|
+
var yn = (e) => e.name === "SASLError" || e.condition === "not-authorized", K = (e = "") => e.split("@")[0], bn = (e) => {
|
|
2896
|
+
let t = e?.getChild("delay", W.delay)?.attrs.stamp;
|
|
2897
2897
|
return t ? Date.parse(t) : Date.now();
|
|
2898
2898
|
};
|
|
2899
|
-
function
|
|
2899
|
+
function xn(e, t) {
|
|
2900
2900
|
for (let n of e.children) {
|
|
2901
2901
|
if (typeof n == "string") continue;
|
|
2902
2902
|
if (n.name === t) return n;
|
|
2903
|
-
let e =
|
|
2903
|
+
let e = xn(n, t);
|
|
2904
2904
|
if (e) return e;
|
|
2905
2905
|
}
|
|
2906
2906
|
}
|
|
2907
|
-
var
|
|
2908
|
-
function
|
|
2907
|
+
var Sn = (e) => xn(e, "message"), q;
|
|
2908
|
+
function Cn() {
|
|
2909
2909
|
try {
|
|
2910
|
-
|
|
2911
|
-
let e =
|
|
2910
|
+
q ??= new AudioContext(), q.state === "suspended" && q.resume();
|
|
2911
|
+
let e = q.currentTime;
|
|
2912
2912
|
for (let [t, n, r] of [[
|
|
2913
2913
|
880,
|
|
2914
2914
|
0,
|
|
@@ -2918,14 +2918,14 @@ function wn() {
|
|
|
2918
2918
|
.1,
|
|
2919
2919
|
.16
|
|
2920
2920
|
]]) {
|
|
2921
|
-
let i =
|
|
2922
|
-
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(
|
|
2921
|
+
let i = q.createOscillator(), a = q.createGain();
|
|
2922
|
+
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(q.destination), i.start(e + n), i.stop(e + n + r + .02);
|
|
2923
2923
|
}
|
|
2924
2924
|
} catch {}
|
|
2925
2925
|
}
|
|
2926
2926
|
//#endregion
|
|
2927
2927
|
//#region node_modules/zustand/esm/vanilla.mjs
|
|
2928
|
-
var
|
|
2928
|
+
var wn = (e) => {
|
|
2929
2929
|
let t, n = /* @__PURE__ */ new Set(), r = (e, r) => {
|
|
2930
2930
|
let i = typeof e == "function" ? e(t) : e;
|
|
2931
2931
|
if (!Object.is(i, t)) {
|
|
@@ -2942,15 +2942,15 @@ var Tn = (e) => {
|
|
|
2942
2942
|
}
|
|
2943
2943
|
}, o = t = e(r, i, a);
|
|
2944
2944
|
return a;
|
|
2945
|
-
},
|
|
2946
|
-
function
|
|
2947
|
-
let r =
|
|
2948
|
-
return
|
|
2945
|
+
}, Tn = (e) => e ? wn(e) : wn, { useDebugValue: En } = e, { useSyncExternalStoreWithSelector: Dn } = l, On = (e) => e;
|
|
2946
|
+
function kn(e, t = On, n) {
|
|
2947
|
+
let r = Dn(e.subscribe, e.getState, e.getServerState || e.getInitialState, t, n);
|
|
2948
|
+
return En(r), r;
|
|
2949
2949
|
}
|
|
2950
|
-
var
|
|
2951
|
-
let t = typeof e == "function" ?
|
|
2950
|
+
var An = (e) => {
|
|
2951
|
+
let t = typeof e == "function" ? Tn(e) : e, n = (e, n) => kn(t, e, n);
|
|
2952
2952
|
return Object.assign(n, t), n;
|
|
2953
|
-
},
|
|
2953
|
+
}, jn = (e) => e ? An(e) : An, Mn = (e) => e.room ?? (e.mine ? e.to : e.from), J = (e, t) => ({
|
|
2954
2954
|
peer: e,
|
|
2955
2955
|
kind: t && e.endsWith("@" + t) ? "group" : "chat",
|
|
2956
2956
|
messages: [],
|
|
@@ -2958,13 +2958,18 @@ var jn = (e) => {
|
|
|
2958
2958
|
typing: !1,
|
|
2959
2959
|
loaded: !1,
|
|
2960
2960
|
complete: !1
|
|
2961
|
-
}),
|
|
2962
|
-
|
|
2963
|
-
|
|
2964
|
-
|
|
2965
|
-
|
|
2966
|
-
|
|
2967
|
-
|
|
2961
|
+
}), Nn = (e, t, n, r) => {
|
|
2962
|
+
let i = e.indexOf(t);
|
|
2963
|
+
if (i >= 0 && i < n) return e;
|
|
2964
|
+
let a = [t, ...e.filter((e) => e !== t)].slice(0, 100);
|
|
2965
|
+
if (!r || a.indexOf(r) < n) return a;
|
|
2966
|
+
let o = a.filter((e) => e !== r);
|
|
2967
|
+
return [
|
|
2968
|
+
...o.slice(0, n - 1),
|
|
2969
|
+
r,
|
|
2970
|
+
...o.slice(n - 1)
|
|
2971
|
+
];
|
|
2972
|
+
}, Pn = (e, t) => e.id === t.id || !!e.oid && e.oid === t.oid, Y = jn((e, t) => ({
|
|
2968
2973
|
me: "",
|
|
2969
2974
|
myName: "",
|
|
2970
2975
|
mucHost: "",
|
|
@@ -3010,14 +3015,14 @@ var jn = (e) => {
|
|
|
3010
3015
|
ensure: (n) => {
|
|
3011
3016
|
let r = t().conversations[n];
|
|
3012
3017
|
if (r) return r;
|
|
3013
|
-
let i =
|
|
3018
|
+
let i = J(n, t().mucHost);
|
|
3014
3019
|
return e((e) => ({ conversations: {
|
|
3015
3020
|
...e.conversations,
|
|
3016
3021
|
[n]: i
|
|
3017
3022
|
} })), i;
|
|
3018
3023
|
},
|
|
3019
3024
|
setGroup: (t, n, r, i, a) => e((e) => {
|
|
3020
|
-
let o = e.conversations[t] ??
|
|
3025
|
+
let o = e.conversations[t] ?? J(t, e.mucHost);
|
|
3021
3026
|
return { conversations: {
|
|
3022
3027
|
...e.conversations,
|
|
3023
3028
|
[t]: {
|
|
@@ -3033,10 +3038,10 @@ var jn = (e) => {
|
|
|
3033
3038
|
seed: (t, n) => e((e) => {
|
|
3034
3039
|
let r = { ...e.conversations };
|
|
3035
3040
|
for (let i of t) {
|
|
3036
|
-
let t =
|
|
3041
|
+
let t = Mn(i);
|
|
3037
3042
|
if (!t || t === n) continue;
|
|
3038
|
-
let a = r[t] ??
|
|
3039
|
-
if (a.messages.some((e) =>
|
|
3043
|
+
let a = r[t] ?? J(t, e.mucHost);
|
|
3044
|
+
if (a.messages.some((e) => Pn(e, i))) continue;
|
|
3040
3045
|
if (a.loaded) {
|
|
3041
3046
|
r[t] = {
|
|
3042
3047
|
...a,
|
|
@@ -3053,10 +3058,10 @@ var jn = (e) => {
|
|
|
3053
3058
|
return { conversations: r };
|
|
3054
3059
|
}),
|
|
3055
3060
|
addMessage: (t, n, r) => e((e) => {
|
|
3056
|
-
let i = e.conversations[t] ??
|
|
3061
|
+
let i = e.conversations[t] ?? J(t, e.mucHost), a = i.messages.filter((e) => !Pn(e, n) && !(e.pending && n.mine && e.body === n.body && e.oob === n.oob)), o = a.length;
|
|
3057
3062
|
for (; o > 0 && a[o - 1].ts > n.ts;) o--;
|
|
3058
3063
|
a.splice(o, 0, n);
|
|
3059
|
-
let s = e.open === t, c = r?.live && !n.mine && !s ? i.unread + 1 : i.unread, l =
|
|
3064
|
+
let s = e.open === t, c = r?.live && !n.mine && !s ? i.unread + 1 : i.unread, l = Nn(e.order, t, e.maxHeads, e.open);
|
|
3060
3065
|
return {
|
|
3061
3066
|
conversations: {
|
|
3062
3067
|
...e.conversations,
|
|
@@ -3071,7 +3076,7 @@ var jn = (e) => {
|
|
|
3071
3076
|
};
|
|
3072
3077
|
}),
|
|
3073
3078
|
prependHistory: (t, n, r, i) => e((e) => {
|
|
3074
|
-
let a = e.conversations[t] ??
|
|
3079
|
+
let a = e.conversations[t] ?? J(t, e.mucHost), o = [...n.filter((e) => !a.messages.some((t) => Pn(t, e))), ...a.messages].sort((e, t) => e.ts - t.ts);
|
|
3075
3080
|
return { conversations: {
|
|
3076
3081
|
...e.conversations,
|
|
3077
3082
|
[t]: {
|
|
@@ -3087,7 +3092,7 @@ var jn = (e) => {
|
|
|
3087
3092
|
if (!t.length) return {};
|
|
3088
3093
|
let n = { ...e.conversations };
|
|
3089
3094
|
for (let r of t) {
|
|
3090
|
-
let t = n[r.peer] ??
|
|
3095
|
+
let t = n[r.peer] ?? J(r.peer, e.mucHost), i = { ...t.reactions ?? {} }, a = { ...i[r.target] ?? {} };
|
|
3091
3096
|
r.emojis.length ? a[r.user] = r.emojis : delete a[r.user], i[r.target] = a, n[r.peer] = {
|
|
3092
3097
|
...t,
|
|
3093
3098
|
reactions: i
|
|
@@ -3105,9 +3110,9 @@ var jn = (e) => {
|
|
|
3105
3110
|
openChat: (t) => e((e) => ({
|
|
3106
3111
|
conversations: e.conversations[t] ? e.conversations : {
|
|
3107
3112
|
...e.conversations,
|
|
3108
|
-
[t]:
|
|
3113
|
+
[t]: J(t, e.mucHost)
|
|
3109
3114
|
},
|
|
3110
|
-
order:
|
|
3115
|
+
order: Nn(e.order, t, e.maxHeads, e.open),
|
|
3111
3116
|
open: t,
|
|
3112
3117
|
picker: !1
|
|
3113
3118
|
})),
|
|
@@ -3136,7 +3141,7 @@ var jn = (e) => {
|
|
|
3136
3141
|
}));
|
|
3137
3142
|
//#endregion
|
|
3138
3143
|
//#region src/contacts.ts
|
|
3139
|
-
function
|
|
3144
|
+
function Fn(e, t, n) {
|
|
3140
3145
|
return Object.values(e ?? {}).filter((e) => e?.username && e.username !== n).map((e) => ({
|
|
3141
3146
|
username: e.username,
|
|
3142
3147
|
name: e.name || e.username,
|
|
@@ -3147,31 +3152,31 @@ function In(e, t, n) {
|
|
|
3147
3152
|
}
|
|
3148
3153
|
//#endregion
|
|
3149
3154
|
//#region src/api.ts
|
|
3150
|
-
async function
|
|
3155
|
+
async function In(e, t, n) {
|
|
3151
3156
|
let r = await fetch(`https://${e}/api${n}`, { headers: { Authorization: `Bearer ${t}` } });
|
|
3152
3157
|
if (!r.ok) throw Error(`${n}: HTTP ${r.status}`);
|
|
3153
3158
|
return await r.json();
|
|
3154
3159
|
}
|
|
3155
|
-
async function
|
|
3156
|
-
let i = await
|
|
3160
|
+
async function Ln(e, t, n, r) {
|
|
3161
|
+
let i = await In(e, t, "/user/endpoints/all"), a = {};
|
|
3157
3162
|
try {
|
|
3158
|
-
a = await
|
|
3163
|
+
a = await In(e, t, "/user/all_avatars");
|
|
3159
3164
|
} catch {}
|
|
3160
3165
|
let o = Object.values(i).find((e) => e.username === n)?.name;
|
|
3161
|
-
return o && r?.(o),
|
|
3166
|
+
return o && r?.(o), Fn(i, a, n).sort((e, t) => e.name.localeCompare(t.name));
|
|
3162
3167
|
}
|
|
3163
|
-
async function
|
|
3168
|
+
async function Rn(e, t) {
|
|
3164
3169
|
let n = await fetch(`https://${e}/chat-gw/push/mobile`, { headers: { Authorization: `Bearer ${t}` } });
|
|
3165
3170
|
if (!n.ok) throw Error(`push/mobile: HTTP ${n.status}`);
|
|
3166
3171
|
return (await n.json()).users;
|
|
3167
3172
|
}
|
|
3168
|
-
async function
|
|
3173
|
+
async function zn(e, t) {
|
|
3169
3174
|
let n = await fetch(`https://${e}/chat-gw/users/inactive`, { headers: { Authorization: `Bearer ${t}` } });
|
|
3170
3175
|
if (!n.ok) throw Error(`users/inactive: HTTP ${n.status}`);
|
|
3171
3176
|
let { users: r } = await n.json();
|
|
3172
3177
|
return Object.fromEntries(r.map((e) => [e.username, e.name || e.username]));
|
|
3173
3178
|
}
|
|
3174
|
-
async function
|
|
3179
|
+
async function Bn(e, t, n) {
|
|
3175
3180
|
let r = await fetch(`https://${e}/chat-gw/conversations/${encodeURIComponent(n)}`, {
|
|
3176
3181
|
method: "DELETE",
|
|
3177
3182
|
headers: { Authorization: `Bearer ${t}` }
|
|
@@ -3180,16 +3185,16 @@ async function Vn(e, t, n) {
|
|
|
3180
3185
|
}
|
|
3181
3186
|
//#endregion
|
|
3182
3187
|
//#region src/push.ts
|
|
3183
|
-
var
|
|
3188
|
+
var Vn = (e) => {
|
|
3184
3189
|
let t = atob((e + "=".repeat((4 - e.length % 4) % 4)).replace(/-/g, "+").replace(/_/g, "/"));
|
|
3185
3190
|
return Uint8Array.from(t, (e) => e.charCodeAt(0));
|
|
3186
|
-
},
|
|
3187
|
-
function
|
|
3188
|
-
|
|
3191
|
+
}, Hn = !1;
|
|
3192
|
+
function Un() {
|
|
3193
|
+
Hn || (Hn = !0, navigator.serviceWorker.addEventListener("message", (e) => {
|
|
3189
3194
|
e.data?.type === "chat-island-open" && typeof e.data.username == "string" && window.dispatchEvent(new CustomEvent("chat-island-open", { detail: { username: e.data.username } }));
|
|
3190
3195
|
}));
|
|
3191
3196
|
}
|
|
3192
|
-
async function
|
|
3197
|
+
async function Wn(e, t) {
|
|
3193
3198
|
if (!("serviceWorker" in navigator) || !("PushManager" in window)) throw Error("push not supported by this browser");
|
|
3194
3199
|
if (Notification.permission === "denied" || Notification.permission !== "granted" && await Notification.requestPermission() !== "granted") return null;
|
|
3195
3200
|
let n = `https://${e.host}/chat-gw`, r = await fetch(`${n}/push/vapid`);
|
|
@@ -3198,7 +3203,7 @@ async function Gn(e, t) {
|
|
|
3198
3203
|
await navigator.serviceWorker.ready;
|
|
3199
3204
|
let o = await a.pushManager.getSubscription() ?? await a.pushManager.subscribe({
|
|
3200
3205
|
userVisibleOnly: !0,
|
|
3201
|
-
applicationServerKey:
|
|
3206
|
+
applicationServerKey: Vn(i.publicKey)
|
|
3202
3207
|
}), s = await fetch(`${n}/push/web`, {
|
|
3203
3208
|
method: "POST",
|
|
3204
3209
|
headers: {
|
|
@@ -3209,24 +3214,24 @@ async function Gn(e, t) {
|
|
|
3209
3214
|
});
|
|
3210
3215
|
if (!s.ok) throw Error(`push/web: HTTP ${s.status} ${(await s.text()).slice(0, 120)}`);
|
|
3211
3216
|
let c = await s.json();
|
|
3212
|
-
return
|
|
3217
|
+
return Un(), {
|
|
3213
3218
|
node: c.node,
|
|
3214
3219
|
service: c.service
|
|
3215
3220
|
};
|
|
3216
3221
|
}
|
|
3217
3222
|
//#endregion
|
|
3218
3223
|
//#region src/events.ts
|
|
3219
|
-
function
|
|
3224
|
+
function X(e, t) {
|
|
3220
3225
|
window.dispatchEvent(new CustomEvent(e, { detail: t }));
|
|
3221
3226
|
}
|
|
3222
|
-
function
|
|
3227
|
+
function Z(e, t) {
|
|
3223
3228
|
let n = (e) => t(e.detail);
|
|
3224
3229
|
return window.addEventListener(e, n), () => window.removeEventListener(e, n);
|
|
3225
3230
|
}
|
|
3226
3231
|
//#endregion
|
|
3227
3232
|
//#region src/components/Avatar.tsx
|
|
3228
|
-
var
|
|
3229
|
-
function
|
|
3233
|
+
var Gn = (e) => e.split(/\s+/).slice(0, 2).map((e) => e[0]?.toUpperCase() ?? "").join("");
|
|
3234
|
+
function Kn({ contact: e, username: t, size: n = 40 }) {
|
|
3230
3235
|
let r = e?.name || t, i = {
|
|
3231
3236
|
width: n,
|
|
3232
3237
|
height: n,
|
|
@@ -3241,13 +3246,13 @@ function qn({ contact: e, username: t, size: n = 40 }) {
|
|
|
3241
3246
|
}) : /* @__PURE__ */ d("div", {
|
|
3242
3247
|
style: i,
|
|
3243
3248
|
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",
|
|
3244
|
-
children:
|
|
3249
|
+
children: Gn(r)
|
|
3245
3250
|
});
|
|
3246
3251
|
}
|
|
3247
|
-
function
|
|
3252
|
+
function qn({ online: e, presence: t, mobile: n }) {
|
|
3248
3253
|
return /* @__PURE__ */ d("span", { className: `ci-absolute ci-bottom-0 ci-right-0 ci-w-3 ci-h-3 ci-rounded-full ci-ring-2 ci-ring-gray-50 dark:ci-ring-gray-950 ${t === "dnd" || t === "busy" ? "ci-bg-phoneIslandClose dark:ci-bg-phoneIslandCloseDark" : e || n ? "ci-bg-phoneIslandCall dark:ci-bg-phoneIslandCallDark" : "ci-bg-gray-400 dark:ci-bg-gray-600"}` });
|
|
3249
3254
|
}
|
|
3250
|
-
function
|
|
3255
|
+
function Jn({ name: e, size: t = 40, avatar: n }) {
|
|
3251
3256
|
let r = {
|
|
3252
3257
|
width: t,
|
|
3253
3258
|
height: t,
|
|
@@ -3262,12 +3267,12 @@ function Yn({ name: e, size: t = 40, avatar: n }) {
|
|
|
3262
3267
|
}) : /* @__PURE__ */ d("div", {
|
|
3263
3268
|
style: r,
|
|
3264
3269
|
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",
|
|
3265
|
-
children:
|
|
3270
|
+
children: Gn(e || "G")
|
|
3266
3271
|
});
|
|
3267
3272
|
}
|
|
3268
3273
|
//#endregion
|
|
3269
3274
|
//#region src/components/Button.tsx
|
|
3270
|
-
var
|
|
3275
|
+
var Yn = "ci-flex ci-content-center ci-items-center ci-justify-center ci-tracking-wide ci-duration-200 ci-transform ci-outline-none focus:ci-ring-2 focus:ci-z-20 focus:ci-ring-offset-2 disabled:ci-opacity-40 disabled:ci-cursor-not-allowed ci-border ci-border-transparent focus:ci-ring-offset-white dark:focus:ci-ring-offset-black ci-text-sm ci-leading-4 ci-transition-colors ci-shrink-0 ci-font-light", Xn = {
|
|
3271
3276
|
default: "ci-bg-phoneIslandActive dark:ci-bg-phoneIslandActiveDark hover:ci-bg-gray-500 dark:hover:ci-bg-gray-50 focus:ci-ring-emerald-500 dark:focus:ci-ring-emerald-300 ci-text-primaryInvert dark:ci-text-primaryInvertDark ci-h-12 ci-w-12 ci-rounded-full",
|
|
3272
3277
|
green: "ci-bg-phoneIslandCall dark:ci-bg-phoneIslandCallDark hover:ci-bg-phoneIslandCallHover dark:hover:ci-bg-phoneIslandCallHoverDark focus:ci-ring-green-500 ci-text-white dark:ci-text-gray-950 ci-h-12 ci-w-12 ci-rounded-full",
|
|
3273
3278
|
red: "ci-bg-phoneIslandClose dark:ci-bg-phoneIslandCloseDark hover:ci-bg-phoneIslandCloseHover dark:hover:ci-bg-phoneIslandCloseHoverDark focus:ci-ring-emerald-500 ci-text-white dark:ci-text-gray-950 ci-h-12 ci-w-12 ci-rounded-full",
|
|
@@ -3276,16 +3281,16 @@ var Xn = "ci-flex ci-content-center ci-items-center ci-justify-center ci-trackin
|
|
|
3276
3281
|
call: "ci-bg-phoneIslandCall dark:ci-bg-phoneIslandCallDark hover:ci-bg-phoneIslandCallHover dark:hover:ci-bg-phoneIslandCallHoverDark focus:ci-ring-green-500 ci-text-white dark:ci-text-gray-950 ci-h-8 ci-w-8 ci-rounded-full",
|
|
3277
3282
|
small: "ci-bg-transparent dark:hover:ci-bg-gray-600 hover:ci-bg-gray-300 focus:ci-ring-gray-400 dark:focus:ci-ring-gray-500 ci-text-gray-700 dark:ci-text-white ci-h-8 ci-w-8 ci-rounded"
|
|
3278
3283
|
};
|
|
3279
|
-
function
|
|
3284
|
+
function Q({ variant: e, className: t = "", children: n, ...r }) {
|
|
3280
3285
|
return /* @__PURE__ */ d("button", {
|
|
3281
3286
|
type: "button",
|
|
3282
3287
|
"aria-label": r["aria-label"] ?? r.title,
|
|
3283
|
-
className: `${
|
|
3288
|
+
className: `${Yn} ${Xn[e]} ${t}`,
|
|
3284
3289
|
...r,
|
|
3285
3290
|
children: n
|
|
3286
3291
|
});
|
|
3287
3292
|
}
|
|
3288
|
-
var
|
|
3293
|
+
var $ = {
|
|
3289
3294
|
chat: /* @__PURE__ */ d("svg", {
|
|
3290
3295
|
width: "20",
|
|
3291
3296
|
height: "20",
|
|
@@ -3385,6 +3390,82 @@ var Q = {
|
|
|
3385
3390
|
strokeLinejoin: "round",
|
|
3386
3391
|
children: [/* @__PURE__ */ d("path", { d: "M9 17l-5-5 5-5" }), /* @__PURE__ */ d("path", { d: "M20 18v-2a4 4 0 0 0-4-4H4" })]
|
|
3387
3392
|
}),
|
|
3393
|
+
dots: /* @__PURE__ */ f("svg", {
|
|
3394
|
+
width: "16",
|
|
3395
|
+
height: "16",
|
|
3396
|
+
viewBox: "0 0 24 24",
|
|
3397
|
+
fill: "currentColor",
|
|
3398
|
+
children: [
|
|
3399
|
+
/* @__PURE__ */ d("circle", {
|
|
3400
|
+
cx: "12",
|
|
3401
|
+
cy: "5",
|
|
3402
|
+
r: "2"
|
|
3403
|
+
}),
|
|
3404
|
+
/* @__PURE__ */ d("circle", {
|
|
3405
|
+
cx: "12",
|
|
3406
|
+
cy: "12",
|
|
3407
|
+
r: "2"
|
|
3408
|
+
}),
|
|
3409
|
+
/* @__PURE__ */ d("circle", {
|
|
3410
|
+
cx: "12",
|
|
3411
|
+
cy: "19",
|
|
3412
|
+
r: "2"
|
|
3413
|
+
})
|
|
3414
|
+
]
|
|
3415
|
+
}),
|
|
3416
|
+
sun: /* @__PURE__ */ f("svg", {
|
|
3417
|
+
width: "16",
|
|
3418
|
+
height: "16",
|
|
3419
|
+
viewBox: "0 0 24 24",
|
|
3420
|
+
fill: "none",
|
|
3421
|
+
stroke: "currentColor",
|
|
3422
|
+
strokeWidth: "2",
|
|
3423
|
+
strokeLinecap: "round",
|
|
3424
|
+
children: [/* @__PURE__ */ d("circle", {
|
|
3425
|
+
cx: "12",
|
|
3426
|
+
cy: "12",
|
|
3427
|
+
r: "4"
|
|
3428
|
+
}), /* @__PURE__ */ d("path", { d: "M12 2v2M12 20v2M4.93 4.93l1.41 1.41M17.66 17.66l1.41 1.41M2 12h2M20 12h2M4.93 19.07l1.41-1.41M17.66 6.34l1.41-1.41" })]
|
|
3429
|
+
}),
|
|
3430
|
+
moon: /* @__PURE__ */ d("svg", {
|
|
3431
|
+
width: "16",
|
|
3432
|
+
height: "16",
|
|
3433
|
+
viewBox: "0 0 24 24",
|
|
3434
|
+
fill: "none",
|
|
3435
|
+
stroke: "currentColor",
|
|
3436
|
+
strokeWidth: "2",
|
|
3437
|
+
strokeLinecap: "round",
|
|
3438
|
+
strokeLinejoin: "round",
|
|
3439
|
+
children: /* @__PURE__ */ d("path", { d: "M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z" })
|
|
3440
|
+
}),
|
|
3441
|
+
monitor: /* @__PURE__ */ f("svg", {
|
|
3442
|
+
width: "16",
|
|
3443
|
+
height: "16",
|
|
3444
|
+
viewBox: "0 0 24 24",
|
|
3445
|
+
fill: "none",
|
|
3446
|
+
stroke: "currentColor",
|
|
3447
|
+
strokeWidth: "2",
|
|
3448
|
+
strokeLinecap: "round",
|
|
3449
|
+
strokeLinejoin: "round",
|
|
3450
|
+
children: [/* @__PURE__ */ d("rect", {
|
|
3451
|
+
x: "2",
|
|
3452
|
+
y: "3",
|
|
3453
|
+
width: "20",
|
|
3454
|
+
height: "14",
|
|
3455
|
+
rx: "2"
|
|
3456
|
+
}), /* @__PURE__ */ d("path", { d: "M8 21h8M12 17v4" })]
|
|
3457
|
+
}),
|
|
3458
|
+
check: /* @__PURE__ */ d("svg", {
|
|
3459
|
+
width: "16",
|
|
3460
|
+
height: "16",
|
|
3461
|
+
viewBox: "0 0 24 24",
|
|
3462
|
+
fill: "none",
|
|
3463
|
+
stroke: "currentColor",
|
|
3464
|
+
strokeWidth: "2.5",
|
|
3465
|
+
strokeLinecap: "round",
|
|
3466
|
+
strokeLinejoin: "round",
|
|
3467
|
+
children: /* @__PURE__ */ d("path", { d: "M20 6L9 17l-5-5" })
|
|
3468
|
+
}),
|
|
3388
3469
|
minus: /* @__PURE__ */ d("svg", {
|
|
3389
3470
|
width: "16",
|
|
3390
3471
|
height: "16",
|
|
@@ -3448,8 +3529,8 @@ var Q = {
|
|
|
3448
3529
|
};
|
|
3449
3530
|
//#endregion
|
|
3450
3531
|
//#region src/components/Dock.tsx
|
|
3451
|
-
function
|
|
3452
|
-
let { order: n, open: r, conversations: i, contacts: a, inactive: o, online: s, mobile: c, openChat: l, removeHead: p, picker: m, setPicker: h, status: g, push: _, enablePush: v, newChatButton: y } =
|
|
3532
|
+
function Zn({ onDragStart: e, pushButton: t = !0 }) {
|
|
3533
|
+
let { order: n, open: r, conversations: i, contacts: a, inactive: o, online: s, mobile: c, openChat: l, removeHead: p, picker: m, setPicker: h, status: g, push: _, enablePush: v, newChatButton: y, maxHeads: b } = Y(w((e) => ({
|
|
3453
3534
|
order: e.order,
|
|
3454
3535
|
open: e.open,
|
|
3455
3536
|
conversations: e.conversations,
|
|
@@ -3464,30 +3545,31 @@ function Qn({ onDragStart: e, pushButton: t = !0 }) {
|
|
|
3464
3545
|
status: e.status,
|
|
3465
3546
|
push: e.push,
|
|
3466
3547
|
enablePush: e.enablePush,
|
|
3467
|
-
newChatButton: e.newChatButton
|
|
3548
|
+
newChatButton: e.newChatButton,
|
|
3549
|
+
maxHeads: e.maxHeads
|
|
3468
3550
|
})));
|
|
3469
3551
|
return /* @__PURE__ */ f("div", {
|
|
3470
3552
|
className: `ci-flex ci-flex-col-reverse ci-items-center ci-gap-3 ci-mb-3 ${e ? "ci-cursor-grab active:ci-cursor-grabbing ci-touch-none" : ""}`,
|
|
3471
3553
|
onPointerDown: e,
|
|
3472
3554
|
children: [
|
|
3473
|
-
n.map((e) => {
|
|
3555
|
+
n.slice(0, b).map((e) => {
|
|
3474
3556
|
let t = i[e], n = r === e;
|
|
3475
3557
|
return /* @__PURE__ */ f("div", {
|
|
3476
3558
|
className: "ci-relative ci-group",
|
|
3477
3559
|
children: [/* @__PURE__ */ f("button", {
|
|
3478
3560
|
type: "button",
|
|
3479
3561
|
title: t?.kind === "group" ? t.name ?? e : a[e]?.name ?? o[e] ?? e,
|
|
3480
|
-
onClick: () => n ?
|
|
3562
|
+
onClick: () => n ? Y.getState().closeChat() : l(e),
|
|
3481
3563
|
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"}`,
|
|
3482
|
-
children: [t?.kind === "group" ? /* @__PURE__ */ d(
|
|
3564
|
+
children: [t?.kind === "group" ? /* @__PURE__ */ d(Jn, {
|
|
3483
3565
|
name: t.name ?? e,
|
|
3484
3566
|
size: 48,
|
|
3485
3567
|
avatar: t.avatar
|
|
3486
|
-
}) : /* @__PURE__ */ f(u, { children: [/* @__PURE__ */ d(
|
|
3568
|
+
}) : /* @__PURE__ */ f(u, { children: [/* @__PURE__ */ d(Kn, {
|
|
3487
3569
|
contact: a[e],
|
|
3488
3570
|
username: e,
|
|
3489
3571
|
size: 48
|
|
3490
|
-
}), /* @__PURE__ */ d(
|
|
3572
|
+
}), /* @__PURE__ */ d(qn, {
|
|
3491
3573
|
online: s[e],
|
|
3492
3574
|
presence: a[e]?.presence,
|
|
3493
3575
|
mobile: c[e]
|
|
@@ -3500,27 +3582,115 @@ function Qn({ onDragStart: e, pushButton: t = !0 }) {
|
|
|
3500
3582
|
"aria-label": `Remove ${t?.kind === "group" ? t.name ?? e : a[e]?.name ?? o[e] ?? e} from the dock`,
|
|
3501
3583
|
onClick: () => p(e),
|
|
3502
3584
|
className: "ci-absolute ci--top-1 ci--left-1 ci-hidden group-hover:ci-flex group-focus-within:ci-flex ci-w-5 ci-h-5 ci-rounded-full ci-border-0 ci-p-0 ci-bg-gray-700 dark:ci-bg-gray-300 ci-text-gray-50 dark:ci-text-gray-900 ci-items-center ci-justify-center",
|
|
3503
|
-
children:
|
|
3585
|
+
children: $.close
|
|
3504
3586
|
})]
|
|
3505
3587
|
}, e);
|
|
3506
3588
|
}),
|
|
3507
|
-
|
|
3589
|
+
n.length > b && /* @__PURE__ */ d(Qn, { peers: n.slice(b) }),
|
|
3590
|
+
y && /* @__PURE__ */ f(Q, {
|
|
3508
3591
|
variant: "default",
|
|
3509
3592
|
title: g === "online" ? "New chat" : `Chat ${g}`,
|
|
3510
3593
|
onClick: () => h(!m),
|
|
3511
3594
|
className: "ci-relative ci-shadow-lg",
|
|
3512
|
-
children: [
|
|
3595
|
+
children: [$.chat, g !== "online" && /* @__PURE__ */ d("span", { className: "ci-absolute ci-bottom-0 ci-right-0 ci-w-3 ci-h-3 ci-rounded-full ci-bg-phoneIslandClose dark:ci-bg-phoneIslandCloseDark ci-ring-2 ci-ring-gray-50 dark:ci-ring-gray-950" })]
|
|
3513
3596
|
}),
|
|
3514
|
-
t && _ === "ask" && g === "online" && /* @__PURE__ */ d(
|
|
3597
|
+
t && _ === "ask" && g === "online" && /* @__PURE__ */ d(Q, {
|
|
3515
3598
|
variant: "neutral",
|
|
3516
3599
|
title: "Enable notifications when the tab is closed",
|
|
3517
3600
|
onClick: v,
|
|
3518
3601
|
className: "ci-shadow-lg ci-bg-gray-50 dark:ci-bg-gray-950",
|
|
3519
|
-
children:
|
|
3602
|
+
children: $.bell
|
|
3520
3603
|
})
|
|
3521
3604
|
]
|
|
3522
3605
|
});
|
|
3523
3606
|
}
|
|
3607
|
+
function Qn({ peers: e }) {
|
|
3608
|
+
let { conversations: t, contacts: n, inactive: r, online: a, mobile: o, openChat: l, removeHead: p } = Y(w((e) => ({
|
|
3609
|
+
conversations: e.conversations,
|
|
3610
|
+
contacts: e.contacts,
|
|
3611
|
+
inactive: e.inactive,
|
|
3612
|
+
online: e.online,
|
|
3613
|
+
mobile: e.mobile,
|
|
3614
|
+
openChat: e.openChat,
|
|
3615
|
+
removeHead: e.removeHead
|
|
3616
|
+
}))), [m, h] = c(!1), g = s(null), _ = e.reduce((e, n) => e + (t[n]?.unread ?? 0), 0), v = (e) => t[e]?.kind === "group" ? t[e]?.name ?? e : n[e]?.name ?? r[e] ?? e;
|
|
3617
|
+
return i(() => {
|
|
3618
|
+
if (!m) return;
|
|
3619
|
+
let e = (e) => g.current && !g.current.contains(e.target) && h(!1), t = (e) => e.key === "Escape" && h(!1);
|
|
3620
|
+
return document.addEventListener("pointerdown", e, !0), document.addEventListener("keydown", t, !0), () => {
|
|
3621
|
+
document.removeEventListener("pointerdown", e, !0), document.removeEventListener("keydown", t, !0);
|
|
3622
|
+
};
|
|
3623
|
+
}, [m]), /* @__PURE__ */ f("div", {
|
|
3624
|
+
ref: g,
|
|
3625
|
+
className: "ci-relative",
|
|
3626
|
+
children: [/* @__PURE__ */ f(Q, {
|
|
3627
|
+
variant: "default",
|
|
3628
|
+
title: `${e.length} more chats`,
|
|
3629
|
+
"aria-expanded": m,
|
|
3630
|
+
onClick: () => h((e) => !e),
|
|
3631
|
+
className: "ci-relative ci-shadow-lg ci-font-medium ci-ring-2 ci-ring-gray-50 dark:ci-ring-gray-950",
|
|
3632
|
+
children: [
|
|
3633
|
+
"+",
|
|
3634
|
+
e.length,
|
|
3635
|
+
_ > 0 && /* @__PURE__ */ d("span", {
|
|
3636
|
+
className: "ci-absolute ci--top-1 ci--right-1 ci-min-w-5 ci-h-5 ci-px-1 ci-rounded-full ci-bg-phoneIslandClose dark:ci-bg-phoneIslandCloseDark ci-text-white dark:ci-text-gray-950 ci-text-xs ci-font-medium ci-flex ci-items-center ci-justify-center",
|
|
3637
|
+
children: _ > 99 ? "99+" : _
|
|
3638
|
+
})
|
|
3639
|
+
]
|
|
3640
|
+
}), m && /* @__PURE__ */ d("div", {
|
|
3641
|
+
role: "menu",
|
|
3642
|
+
onPointerDown: (e) => e.stopPropagation(),
|
|
3643
|
+
className: "ci-anim-drop ci-absolute ci-right-full ci-mr-3 ci-top-0 ci-z-30 ci-w-64 ci-max-h-80 ci-overflow-y-auto ci-py-2 ci-rounded-2xl ci-bg-gray-50 dark:ci-bg-gray-950 ci-shadow-2xl ci-border ci-border-solid ci-border-gray-300 dark:ci-border-gray-600 ci-text-gray-900 dark:ci-text-white ci-text-sm ci-cursor-default",
|
|
3644
|
+
children: e.map((e) => {
|
|
3645
|
+
let r = t[e];
|
|
3646
|
+
return /* @__PURE__ */ f("div", {
|
|
3647
|
+
className: "ci-group ci-flex ci-items-center ci-pr-2 hover:ci-bg-gray-200 dark:hover:ci-bg-gray-700",
|
|
3648
|
+
children: [/* @__PURE__ */ f("button", {
|
|
3649
|
+
type: "button",
|
|
3650
|
+
role: "menuitem",
|
|
3651
|
+
onClick: () => {
|
|
3652
|
+
h(!1), l(e);
|
|
3653
|
+
},
|
|
3654
|
+
className: "ci-flex-1 ci-min-w-0 ci-flex ci-items-center ci-gap-3 ci-px-3 ci-py-2 ci-border-0 ci-bg-transparent ci-text-left ci-text-inherit",
|
|
3655
|
+
children: [
|
|
3656
|
+
/* @__PURE__ */ d("span", {
|
|
3657
|
+
className: "ci-relative",
|
|
3658
|
+
children: r?.kind === "group" ? /* @__PURE__ */ d(Jn, {
|
|
3659
|
+
name: v(e),
|
|
3660
|
+
size: 32,
|
|
3661
|
+
avatar: r.avatar
|
|
3662
|
+
}) : /* @__PURE__ */ f(u, { children: [/* @__PURE__ */ d(Kn, {
|
|
3663
|
+
contact: n[e],
|
|
3664
|
+
username: e,
|
|
3665
|
+
size: 32
|
|
3666
|
+
}), /* @__PURE__ */ d(qn, {
|
|
3667
|
+
online: a[e],
|
|
3668
|
+
presence: n[e]?.presence,
|
|
3669
|
+
mobile: o[e]
|
|
3670
|
+
})] })
|
|
3671
|
+
}),
|
|
3672
|
+
/* @__PURE__ */ d("span", {
|
|
3673
|
+
className: "ci-flex-1 ci-truncate",
|
|
3674
|
+
children: v(e)
|
|
3675
|
+
}),
|
|
3676
|
+
(r?.unread ?? 0) > 0 && /* @__PURE__ */ d("span", {
|
|
3677
|
+
className: "ci-min-w-5 ci-h-5 ci-px-1 ci-rounded-full ci-bg-phoneIslandClose dark:ci-bg-phoneIslandCloseDark ci-text-white dark:ci-text-gray-950 ci-text-xs ci-font-medium ci-flex ci-items-center ci-justify-center",
|
|
3678
|
+
children: r.unread > 99 ? "99+" : r.unread
|
|
3679
|
+
})
|
|
3680
|
+
]
|
|
3681
|
+
}), /* @__PURE__ */ d(Q, {
|
|
3682
|
+
variant: "small",
|
|
3683
|
+
"aria-label": `Remove ${v(e)} from the dock`,
|
|
3684
|
+
title: "Remove from the dock",
|
|
3685
|
+
onClick: () => p(e),
|
|
3686
|
+
className: "ci-opacity-0 group-hover:ci-opacity-100 focus:ci-opacity-100",
|
|
3687
|
+
children: $.close
|
|
3688
|
+
})]
|
|
3689
|
+
}, e);
|
|
3690
|
+
})
|
|
3691
|
+
})]
|
|
3692
|
+
});
|
|
3693
|
+
}
|
|
3524
3694
|
//#endregion
|
|
3525
3695
|
//#region src/shortcodes.ts
|
|
3526
3696
|
var $n = {
|
|
@@ -3718,12 +3888,12 @@ var $n = {
|
|
|
3718
3888
|
sweat_drops: "💦",
|
|
3719
3889
|
dash: "💨"
|
|
3720
3890
|
}, er = /(```[\s\S]*?(?:```|$)|`[^`\n]*`?)/g, tr = /:([a-z0-9_+-]+):/g, nr = (e) => e.replace(tr, (e, t) => $n[t] ?? e);
|
|
3721
|
-
function
|
|
3891
|
+
function rr(e) {
|
|
3722
3892
|
return e.includes(":") ? e.split(er).map((e, t) => t % 2 ? e : nr(e)).join("") : e;
|
|
3723
3893
|
}
|
|
3724
3894
|
//#endregion
|
|
3725
3895
|
//#region src/components/EmojiPicker.tsx
|
|
3726
|
-
var
|
|
3896
|
+
var ir = [
|
|
3727
3897
|
{
|
|
3728
3898
|
label: "Smileys",
|
|
3729
3899
|
icon: "😀",
|
|
@@ -3754,7 +3924,7 @@ var rr = [
|
|
|
3754
3924
|
icon: "☕",
|
|
3755
3925
|
emojis: "☕ 🍵 🥤 🍕 🍔 🍟 🌭 🥪 🌮 🍝 🍣 🍩 🍪 🍫 🍎 🍌 🍓 🥐 🚗 🚕 🚌 🚆 ✈️ 🚀 🏠 🏢 🏖️ 🌍 ☀️ 🌤️ 🌧️ ⛈️ ❄️ ⚡ 🌈 🌙"
|
|
3756
3926
|
}
|
|
3757
|
-
],
|
|
3927
|
+
], ar = [
|
|
3758
3928
|
"👍",
|
|
3759
3929
|
"❤️",
|
|
3760
3930
|
"😂",
|
|
@@ -3762,7 +3932,7 @@ var rr = [
|
|
|
3762
3932
|
"😢",
|
|
3763
3933
|
"🙏"
|
|
3764
3934
|
];
|
|
3765
|
-
function
|
|
3935
|
+
function or({ onPick: e, onClose: t, className: n = "" }) {
|
|
3766
3936
|
let [r, a] = c(0), o = s(null);
|
|
3767
3937
|
return i(() => {
|
|
3768
3938
|
let e = (e) => o.current && !o.current.contains(e.target) && t(), n = (e) => {
|
|
@@ -3775,10 +3945,10 @@ function ar({ onPick: e, onClose: t, className: n = "" }) {
|
|
|
3775
3945
|
ref: o,
|
|
3776
3946
|
role: "dialog",
|
|
3777
3947
|
"aria-label": "Emoji",
|
|
3778
|
-
className: `ci-z-30 ci-w-[21rem] ci-max-w-full ci-rounded-2xl ci-bg-gray-50 dark:ci-bg-gray-950 ci-shadow-2xl ci-
|
|
3948
|
+
className: `ci-z-30 ci-w-[21rem] ci-max-w-full ci-rounded-2xl ci-bg-gray-50 dark:ci-bg-gray-950 ci-shadow-2xl ci-border ci-border-solid ci-border-gray-300 dark:ci-border-gray-600 ci-select-none ${n}`,
|
|
3779
3949
|
children: [/* @__PURE__ */ d("div", {
|
|
3780
3950
|
className: "ci-flex ci-gap-1 ci-px-2 ci-pt-2 ci-border-b ci-border-gray-300 dark:ci-border-gray-700",
|
|
3781
|
-
children:
|
|
3951
|
+
children: ir.map((e, t) => /* @__PURE__ */ d("button", {
|
|
3782
3952
|
type: "button",
|
|
3783
3953
|
title: e.label,
|
|
3784
3954
|
"aria-label": e.label,
|
|
@@ -3792,7 +3962,7 @@ function ar({ onPick: e, onClose: t, className: n = "" }) {
|
|
|
3792
3962
|
}, e.label))
|
|
3793
3963
|
}), /* @__PURE__ */ d("div", {
|
|
3794
3964
|
className: "ci-grid ci-grid-cols-7 ci-gap-1 ci-p-2 ci-h-64 ci-overflow-y-auto",
|
|
3795
|
-
children:
|
|
3965
|
+
children: ir[r].emojis.split(" ").map((t) => /* @__PURE__ */ d("button", {
|
|
3796
3966
|
type: "button",
|
|
3797
3967
|
onClick: () => e(t),
|
|
3798
3968
|
style: {
|
|
@@ -3807,27 +3977,27 @@ function ar({ onPick: e, onClose: t, className: n = "" }) {
|
|
|
3807
3977
|
}
|
|
3808
3978
|
//#endregion
|
|
3809
3979
|
//#region src/components/MessageList.tsx
|
|
3810
|
-
var
|
|
3980
|
+
var sr = (e) => /\.(png|jpe?g|gif|webp|avif|svg)(\?|$)/i.test(e), cr = (e) => /\.(webm|ogg|oga|opus|mp3|m4a|wav)(\?|$)/i.test(e), lr = (e) => {
|
|
3811
3981
|
let t = e.split("/").pop() || "file";
|
|
3812
3982
|
try {
|
|
3813
3983
|
return decodeURIComponent(t);
|
|
3814
3984
|
} catch {
|
|
3815
3985
|
return t;
|
|
3816
3986
|
}
|
|
3817
|
-
},
|
|
3987
|
+
}, ur = (e) => {
|
|
3818
3988
|
try {
|
|
3819
3989
|
return new URL(e).protocol === "https:";
|
|
3820
3990
|
} catch {
|
|
3821
3991
|
return !1;
|
|
3822
3992
|
}
|
|
3823
|
-
},
|
|
3993
|
+
}, dr = (e) => new Date(e).toLocaleTimeString([], {
|
|
3824
3994
|
hour: "2-digit",
|
|
3825
3995
|
minute: "2-digit"
|
|
3826
|
-
}),
|
|
3996
|
+
}), fr = (e) => new Date(e).toLocaleDateString([], {
|
|
3827
3997
|
weekday: "short",
|
|
3828
3998
|
day: "numeric",
|
|
3829
3999
|
month: "short"
|
|
3830
|
-
}),
|
|
4000
|
+
}), pr = (e, t) => new Date(e).toDateString() === new Date(t).toDateString(), mr = (e) => {
|
|
3831
4001
|
if (!e.startsWith("{\"")) return null;
|
|
3832
4002
|
try {
|
|
3833
4003
|
let t = JSON.parse(e);
|
|
@@ -3838,17 +4008,17 @@ var or = (e) => /\.(png|jpe?g|gif|webp|avif|svg)(\?|$)/i.test(e), sr = (e) => /\
|
|
|
3838
4008
|
} catch {
|
|
3839
4009
|
return null;
|
|
3840
4010
|
}
|
|
3841
|
-
},
|
|
3842
|
-
return
|
|
4011
|
+
}, hr = n(function({ url: e }) {
|
|
4012
|
+
return ur(e) ? sr(e) ? /* @__PURE__ */ d("a", {
|
|
3843
4013
|
href: e,
|
|
3844
4014
|
target: "_blank",
|
|
3845
4015
|
rel: "noreferrer",
|
|
3846
4016
|
children: /* @__PURE__ */ d("img", {
|
|
3847
4017
|
src: e,
|
|
3848
|
-
alt:
|
|
4018
|
+
alt: lr(e),
|
|
3849
4019
|
className: "ci-max-w-full ci-max-h-60 ci-rounded-2xl ci-block"
|
|
3850
4020
|
})
|
|
3851
|
-
}) :
|
|
4021
|
+
}) : cr(e) ? /* @__PURE__ */ d("audio", {
|
|
3852
4022
|
controls: !0,
|
|
3853
4023
|
src: e,
|
|
3854
4024
|
className: "ci-max-w-full"
|
|
@@ -3865,17 +4035,17 @@ var or = (e) => /\.(png|jpe?g|gif|webp|avif|svg)(\?|$)/i.test(e), sr = (e) => /\
|
|
|
3865
4035
|
stroke: "currentColor",
|
|
3866
4036
|
strokeWidth: "2",
|
|
3867
4037
|
children: /* @__PURE__ */ d("path", { d: "M21.44 11.05l-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48" })
|
|
3868
|
-
}),
|
|
4038
|
+
}), lr(e)]
|
|
3869
4039
|
}) : /* @__PURE__ */ d("span", {
|
|
3870
4040
|
className: "ci-break-all",
|
|
3871
4041
|
children: e
|
|
3872
4042
|
});
|
|
3873
|
-
}),
|
|
3874
|
-
function
|
|
4043
|
+
}), gr = /(`[^`\n]+`)|(\*\*[^*\n]+\*\*|__[^_\n]+__)|(~~[^~\n]+~~)|(\*[^*\s][^*\n]*\*|_[^_\s][^_\n]*_)|\[([^\]\n]+)\]\((https?:\/\/[^\s)]+)\)|(https?:\/\/[^\s<]+)/g;
|
|
4044
|
+
function _r({ text: e }) {
|
|
3875
4045
|
let t = [], n = 0;
|
|
3876
|
-
for (let r of e.matchAll(
|
|
4046
|
+
for (let r of e.matchAll(gr)) {
|
|
3877
4047
|
let i = r[0], a = r.index ?? 0;
|
|
3878
|
-
a > n && t.push(
|
|
4048
|
+
a > n && t.push(rr(e.slice(n, a))), r[1] ? t.push(/* @__PURE__ */ d("code", {
|
|
3879
4049
|
className: "ci-px-1 ci-py-0.5 ci-rounded ci-bg-black/10 dark:ci-bg-white/10 ci-font-mono ci-text-[0.85em]",
|
|
3880
4050
|
children: i.slice(1, -1)
|
|
3881
4051
|
}, a)) : r[2] ? t.push(/* @__PURE__ */ d("strong", { children: i.slice(2, -2) }, a)) : r[3] ? t.push(/* @__PURE__ */ d("s", { children: i.slice(2, -2) }, a)) : r[4] ? t.push(/* @__PURE__ */ d("em", { children: i.slice(1, -1) }, a)) : r[5] ? t.push(/* @__PURE__ */ d("a", {
|
|
@@ -3892,19 +4062,19 @@ function gr({ text: e }) {
|
|
|
3892
4062
|
children: i
|
|
3893
4063
|
}, a)), n = a + i.length;
|
|
3894
4064
|
}
|
|
3895
|
-
return n < e.length && t.push(
|
|
4065
|
+
return n < e.length && t.push(rr(e.slice(n))), /* @__PURE__ */ d(u, { children: t });
|
|
3896
4066
|
}
|
|
3897
|
-
var
|
|
4067
|
+
var vr = n(function({ text: e }) {
|
|
3898
4068
|
let t = e.split(/```[^\n]*\n?([\s\S]*?)```/g);
|
|
3899
4069
|
return /* @__PURE__ */ d("span", {
|
|
3900
4070
|
className: "ci-whitespace-pre-wrap ci-break-words",
|
|
3901
4071
|
children: t.map((e, t) => t % 2 ? /* @__PURE__ */ d("pre", {
|
|
3902
4072
|
className: "ci-my-1 ci-p-2 ci-rounded-xl ci-bg-black/10 dark:ci-bg-white/10 ci-font-mono ci-text-xs ci-overflow-x-auto ci-whitespace-pre",
|
|
3903
4073
|
children: e.replace(/\n$/, "")
|
|
3904
|
-
}, t) : /* @__PURE__ */ d(
|
|
4074
|
+
}, t) : /* @__PURE__ */ d(_r, { text: e.replace(/^(\s*)[-*] (?=\S)/gm, "$1• ") }, t))
|
|
3905
4075
|
});
|
|
3906
4076
|
});
|
|
3907
|
-
function
|
|
4077
|
+
function yr({ text: e, count: t }) {
|
|
3908
4078
|
return /* @__PURE__ */ f("span", {
|
|
3909
4079
|
className: "ci-italic ci-opacity-80",
|
|
3910
4080
|
children: [
|
|
@@ -3917,7 +4087,7 @@ function vr({ text: e, count: t }) {
|
|
|
3917
4087
|
]
|
|
3918
4088
|
});
|
|
3919
4089
|
}
|
|
3920
|
-
function
|
|
4090
|
+
function br({ forMsg: e, me: t, onReact: n, nameOf: r, mine: i }) {
|
|
3921
4091
|
if (!e) return null;
|
|
3922
4092
|
let a = /* @__PURE__ */ new Map();
|
|
3923
4093
|
for (let [t, n] of Object.entries(e)) for (let e of n) a.set(e, [...a.get(e) ?? [], t]);
|
|
@@ -3942,7 +4112,7 @@ function yr({ forMsg: e, me: t, onReact: n, nameOf: r, mine: i }) {
|
|
|
3942
4112
|
})
|
|
3943
4113
|
}) : null;
|
|
3944
4114
|
}
|
|
3945
|
-
function
|
|
4115
|
+
function xr({ reply: e, messages: t, mine: n, name: r }) {
|
|
3946
4116
|
let i = t.find((t) => t.oid === e.id), a = i ? i.oob ? "Attachment" : i.body : e.quote?.replace(/^[^:]*: /, "") ?? "", o = (t) => {
|
|
3947
4117
|
t.stopPropagation();
|
|
3948
4118
|
let n = document.querySelector(`.chat-island-root [data-oid="${CSS.escape(e.id)}"]`);
|
|
@@ -3966,8 +4136,8 @@ function br({ reply: e, messages: t, mine: n, name: r }) {
|
|
|
3966
4136
|
})]
|
|
3967
4137
|
});
|
|
3968
4138
|
}
|
|
3969
|
-
function
|
|
3970
|
-
let m =
|
|
4139
|
+
function Sr({ messages: e, typing: t, onLoadOlder: n, hasOlder: r, group: a, reactions: o, me: l = "", onReact: u, onReply: p }) {
|
|
4140
|
+
let m = Y((e) => e.contacts), h = s(null), g = s(!0), [_, v] = c(null), [y, b] = c(null), x = (e) => m[e]?.name ?? e;
|
|
3971
4141
|
i(() => {
|
|
3972
4142
|
let e = h.current;
|
|
3973
4143
|
e && g.current && (e.scrollTop = e.scrollHeight);
|
|
@@ -4000,7 +4170,7 @@ function xr({ messages: e, typing: t, onLoadOlder: n, hasOlder: r, group: a, rea
|
|
|
4000
4170
|
children: "Scroll up for older messages"
|
|
4001
4171
|
}),
|
|
4002
4172
|
e.map((t, n) => {
|
|
4003
|
-
let r = e[n - 1], i = !r || !
|
|
4173
|
+
let r = e[n - 1], i = !r || !pr(r.ts, t.ts), s = r && !i && r.mine === t.mine && r.nick === t.nick && t.ts - r.ts < 12e4, c = a && !t.mine && t.nick ? x(t.nick) : null, h = t.oid, g = !!u && !!h && !t.pending, y = g && /* @__PURE__ */ d("button", {
|
|
4004
4174
|
type: "button",
|
|
4005
4175
|
title: "React",
|
|
4006
4176
|
"aria-label": "React to this message",
|
|
@@ -4008,7 +4178,7 @@ function xr({ messages: e, typing: t, onLoadOlder: n, hasOlder: r, group: a, rea
|
|
|
4008
4178
|
e.stopPropagation(), v(_ === h ? null : h);
|
|
4009
4179
|
},
|
|
4010
4180
|
className: `ci-self-center ci-h-7 ci-w-7 ci-shrink-0 ci-flex ci-items-center ci-justify-center ci-rounded-full ci-border-0 ci-bg-transparent ci-text-gray-500 dark:ci-text-gray-400 hover:ci-bg-gray-200 dark:hover:ci-bg-gray-800 focus:ci-opacity-100 ${_ === h ? "ci-opacity-100" : "ci-opacity-0 group-hover:ci-opacity-100"}`,
|
|
4011
|
-
children:
|
|
4181
|
+
children: $.react
|
|
4012
4182
|
}), S = !!p && !!h && !t.pending && /* @__PURE__ */ d("button", {
|
|
4013
4183
|
type: "button",
|
|
4014
4184
|
title: "Reply",
|
|
@@ -4017,20 +4187,20 @@ function xr({ messages: e, typing: t, onLoadOlder: n, hasOlder: r, group: a, rea
|
|
|
4017
4187
|
e.stopPropagation(), p(t);
|
|
4018
4188
|
},
|
|
4019
4189
|
className: "ci-self-center ci-h-7 ci-w-7 ci-shrink-0 ci-flex ci-items-center ci-justify-center ci-rounded-full ci-border-0 ci-bg-transparent ci-text-gray-500 dark:ci-text-gray-400 hover:ci-bg-gray-200 dark:hover:ci-bg-gray-800 focus:ci-opacity-100 ci-opacity-0 group-hover:ci-opacity-100",
|
|
4020
|
-
children:
|
|
4190
|
+
children: $.reply
|
|
4021
4191
|
});
|
|
4022
4192
|
return /* @__PURE__ */ f("div", {
|
|
4023
4193
|
"data-oid": t.oid,
|
|
4024
4194
|
children: [i && /* @__PURE__ */ d("div", {
|
|
4025
4195
|
className: "ci-text-center ci-text-xs ci-text-gray-500 dark:ci-text-gray-400 ci-py-2",
|
|
4026
|
-
children:
|
|
4196
|
+
children: fr(t.ts)
|
|
4027
4197
|
}), /* @__PURE__ */ f("div", {
|
|
4028
4198
|
className: `ci-group ci-flex ci-items-start ci-gap-1.5 ${t.mine ? "ci-justify-end" : "ci-justify-start"} ${s ? "ci-mt-0.5" : "ci-mt-2"}`,
|
|
4029
4199
|
children: [
|
|
4030
4200
|
c && /* @__PURE__ */ d("span", {
|
|
4031
4201
|
className: "ci-w-7 ci-shrink-0",
|
|
4032
4202
|
title: c,
|
|
4033
|
-
children: !s && /* @__PURE__ */ d(
|
|
4203
|
+
children: !s && /* @__PURE__ */ d(Kn, {
|
|
4034
4204
|
contact: m[t.nick],
|
|
4035
4205
|
username: t.nick,
|
|
4036
4206
|
size: 28
|
|
@@ -4044,8 +4214,8 @@ function xr({ messages: e, typing: t, onLoadOlder: n, hasOlder: r, group: a, rea
|
|
|
4044
4214
|
_ === h && h && /* @__PURE__ */ f("div", {
|
|
4045
4215
|
role: "menu",
|
|
4046
4216
|
onClick: (e) => e.stopPropagation(),
|
|
4047
|
-
className: `ci-absolute ci-bottom-full ci-mb-1 ci-z-20 ci-flex ci-items-center ci-gap-0.5 ci-p-1 ci-rounded-full ci-bg-gray-50 dark:ci-bg-gray-950 ci-shadow-xl ci-
|
|
4048
|
-
children: [
|
|
4217
|
+
className: `ci-absolute ci-bottom-full ci-mb-1 ci-z-20 ci-flex ci-items-center ci-gap-0.5 ci-p-1 ci-rounded-full ci-bg-gray-50 dark:ci-bg-gray-950 ci-shadow-xl ci-border ci-border-solid ci-border-gray-300 dark:ci-border-gray-600 ${t.mine ? "ci-right-0" : "ci-left-0"}`,
|
|
4218
|
+
children: [ar.map((e) => /* @__PURE__ */ d("button", {
|
|
4049
4219
|
type: "button",
|
|
4050
4220
|
role: "menuitem",
|
|
4051
4221
|
"aria-label": e,
|
|
@@ -4069,28 +4239,28 @@ function xr({ messages: e, typing: t, onLoadOlder: n, hasOlder: r, group: a, rea
|
|
|
4069
4239
|
})]
|
|
4070
4240
|
}),
|
|
4071
4241
|
/* @__PURE__ */ f("div", {
|
|
4072
|
-
title:
|
|
4073
|
-
onDoubleClick: () => g && C(h,
|
|
4242
|
+
title: dr(t.ts),
|
|
4243
|
+
onDoubleClick: () => g && C(h, ar[0]),
|
|
4074
4244
|
className: `ci-px-3.5 ci-py-2 ci-rounded-3xl ci-text-sm ci-select-text ci-cursor-text ${t.mine ? "ci-bg-gray-700 ci-text-gray-50 dark:ci-bg-gray-300 dark:ci-text-gray-900 ci-rounded-br-lg" : "ci-bg-elevationL2 ci-text-gray-900 dark:ci-bg-elevationL2Dark dark:ci-text-white ci-rounded-bl-lg"} ${t.pending ? "ci-opacity-60" : ""}`,
|
|
4075
4245
|
children: [
|
|
4076
|
-
t.reply && /* @__PURE__ */ d(
|
|
4246
|
+
t.reply && /* @__PURE__ */ d(xr, {
|
|
4077
4247
|
reply: t.reply,
|
|
4078
4248
|
messages: e,
|
|
4079
4249
|
mine: t.mine,
|
|
4080
4250
|
name: (e) => e === l ? "You" : x(e)
|
|
4081
4251
|
}),
|
|
4082
|
-
t.oob ? /* @__PURE__ */ d(
|
|
4083
|
-
t.oob && t.body && t.body !== t.oob && t.body !==
|
|
4252
|
+
t.oob ? /* @__PURE__ */ d(hr, { url: t.oob }) : mr(t.body) ? /* @__PURE__ */ d(yr, { ...mr(t.body) }) : /* @__PURE__ */ d(vr, { text: t.body }),
|
|
4253
|
+
t.oob && t.body && t.body !== t.oob && t.body !== lr(t.oob) && /* @__PURE__ */ d("div", {
|
|
4084
4254
|
className: "ci-text-xs ci-opacity-80 ci-mt-1",
|
|
4085
4255
|
children: t.body
|
|
4086
4256
|
}),
|
|
4087
4257
|
/* @__PURE__ */ d("span", {
|
|
4088
4258
|
className: "ci-block ci-text-right ci-text-[10px] ci-leading-none ci-opacity-60 ci-mt-1",
|
|
4089
|
-
children:
|
|
4259
|
+
children: dr(t.ts)
|
|
4090
4260
|
})
|
|
4091
4261
|
]
|
|
4092
4262
|
}),
|
|
4093
|
-
h && /* @__PURE__ */ d(
|
|
4263
|
+
h && /* @__PURE__ */ d(br, {
|
|
4094
4264
|
forMsg: o?.[h],
|
|
4095
4265
|
me: l,
|
|
4096
4266
|
mine: t.mine,
|
|
@@ -4113,7 +4283,7 @@ function xr({ messages: e, typing: t, onLoadOlder: n, hasOlder: r, group: a, rea
|
|
|
4113
4283
|
})
|
|
4114
4284
|
})
|
|
4115
4285
|
]
|
|
4116
|
-
}), y && /* @__PURE__ */ d(
|
|
4286
|
+
}), y && /* @__PURE__ */ d(or, {
|
|
4117
4287
|
className: "ci-absolute ci-bottom-2 ci-left-1/2 ci--translate-x-1/2",
|
|
4118
4288
|
onPick: (e) => C(y, e),
|
|
4119
4289
|
onClose: () => b(null)
|
|
@@ -4122,7 +4292,7 @@ function xr({ messages: e, typing: t, onLoadOlder: n, hasOlder: r, group: a, rea
|
|
|
4122
4292
|
}
|
|
4123
4293
|
//#endregion
|
|
4124
4294
|
//#region src/ogg.ts
|
|
4125
|
-
function
|
|
4295
|
+
function Cr(e, t, n) {
|
|
4126
4296
|
let r = e[t];
|
|
4127
4297
|
if (r === void 0) return null;
|
|
4128
4298
|
let i = 1;
|
|
@@ -4136,7 +4306,7 @@ function Sr(e, t, n) {
|
|
|
4136
4306
|
unknown: !n && o
|
|
4137
4307
|
};
|
|
4138
4308
|
}
|
|
4139
|
-
var
|
|
4309
|
+
var wr = /* @__PURE__ */ new Set([
|
|
4140
4310
|
408125543,
|
|
4141
4311
|
524531317,
|
|
4142
4312
|
374648427,
|
|
@@ -4144,18 +4314,18 @@ var Cr = /* @__PURE__ */ new Set([
|
|
|
4144
4314
|
225,
|
|
4145
4315
|
160
|
|
4146
4316
|
]);
|
|
4147
|
-
function
|
|
4317
|
+
function Tr(e) {
|
|
4148
4318
|
let t = {
|
|
4149
4319
|
channels: 1,
|
|
4150
4320
|
packets: []
|
|
4151
4321
|
}, n = 0;
|
|
4152
4322
|
for (; n < e.length;) {
|
|
4153
|
-
let r =
|
|
4323
|
+
let r = Cr(e, n, !0);
|
|
4154
4324
|
if (!r) break;
|
|
4155
|
-
let i =
|
|
4325
|
+
let i = Cr(e, n + r.len, !1);
|
|
4156
4326
|
if (!i) break;
|
|
4157
4327
|
let a = n + r.len + i.len;
|
|
4158
|
-
if (
|
|
4328
|
+
if (wr.has(r.value)) {
|
|
4159
4329
|
n = a;
|
|
4160
4330
|
continue;
|
|
4161
4331
|
}
|
|
@@ -4164,14 +4334,14 @@ function wr(e) {
|
|
|
4164
4334
|
if (r.value === 25506) t.head = e.slice(a, o);
|
|
4165
4335
|
else if (r.value === 159) t.channels = e[a] || 1;
|
|
4166
4336
|
else if (r.value === 163 || r.value === 161) {
|
|
4167
|
-
let n =
|
|
4337
|
+
let n = Cr(e, a, !1);
|
|
4168
4338
|
n && (e[a + n.len + 2] >> 1 & 3 || t.packets.push(e.slice(a + n.len + 3, o)));
|
|
4169
4339
|
}
|
|
4170
4340
|
n = o;
|
|
4171
4341
|
}
|
|
4172
4342
|
return t;
|
|
4173
4343
|
}
|
|
4174
|
-
function
|
|
4344
|
+
function Er(e) {
|
|
4175
4345
|
if (!e.length) return 0;
|
|
4176
4346
|
let t = e[0], n = t >> 3, r;
|
|
4177
4347
|
r = n < 12 ? [
|
|
@@ -4188,7 +4358,7 @@ function Tr(e) {
|
|
|
4188
4358
|
let i = t & 3, a = i === 0 ? 1 : i === 3 ? (e[1] ?? 0) & 63 : 2;
|
|
4189
4359
|
return Math.round(a * r * 48);
|
|
4190
4360
|
}
|
|
4191
|
-
var
|
|
4361
|
+
var Dr = (() => {
|
|
4192
4362
|
let e = /* @__PURE__ */ new Uint32Array(256);
|
|
4193
4363
|
for (let t = 0; t < 256; t++) {
|
|
4194
4364
|
let n = t << 24;
|
|
@@ -4197,12 +4367,12 @@ var Er = (() => {
|
|
|
4197
4367
|
}
|
|
4198
4368
|
return e;
|
|
4199
4369
|
})();
|
|
4200
|
-
function
|
|
4370
|
+
function Or(e) {
|
|
4201
4371
|
let t = 0;
|
|
4202
|
-
for (let n = 0; n < e.length; n++) t = (t << 8 ^
|
|
4372
|
+
for (let n = 0; n < e.length; n++) t = (t << 8 ^ Dr[(t >>> 24 ^ e[n]) & 255]) >>> 0;
|
|
4203
4373
|
return t;
|
|
4204
4374
|
}
|
|
4205
|
-
function
|
|
4375
|
+
function kr(e, t, n, r, i) {
|
|
4206
4376
|
let a = [];
|
|
4207
4377
|
for (let t of e) {
|
|
4208
4378
|
let e = t.length;
|
|
@@ -4218,29 +4388,29 @@ function Or(e, t, n, r, i) {
|
|
|
4218
4388
|
], 0), s[5] = i, c.setUint32(6, t % 4294967296, !0), c.setUint32(10, Math.floor(t / 4294967296), !0), c.setUint32(14, n, !0), c.setUint32(18, r, !0), s[26] = a.length, s.set(a, 27);
|
|
4219
4389
|
let l = 27 + a.length;
|
|
4220
4390
|
for (let t of e) s.set(t, l), l += t.length;
|
|
4221
|
-
return c.setUint32(22,
|
|
4391
|
+
return c.setUint32(22, Or(s), !0), s;
|
|
4222
4392
|
}
|
|
4223
|
-
function
|
|
4393
|
+
function Ar(e) {
|
|
4224
4394
|
let t = /* @__PURE__ */ new Uint8Array(19), n = new DataView(t.buffer);
|
|
4225
4395
|
return t.set(new TextEncoder().encode("OpusHead"), 0), t[8] = 1, t[9] = e, n.setUint16(10, 312, !0), n.setUint32(12, 48e3, !0), t;
|
|
4226
4396
|
}
|
|
4227
|
-
function
|
|
4397
|
+
function jr() {
|
|
4228
4398
|
let e = new TextEncoder().encode("chat-island"), t = new Uint8Array(12 + e.length + 4);
|
|
4229
4399
|
return t.set(new TextEncoder().encode("OpusTags"), 0), new DataView(t.buffer).setUint32(8, e.length, !0), t.set(e, 12), t;
|
|
4230
4400
|
}
|
|
4231
|
-
function
|
|
4232
|
-
let { head: t, channels: n, packets: r } =
|
|
4401
|
+
function Mr(e) {
|
|
4402
|
+
let { head: t, channels: n, packets: r } = Tr(e);
|
|
4233
4403
|
if (!r.length) return null;
|
|
4234
|
-
let i = t && t.length >= 19 && new TextDecoder().decode(t.slice(0, 8)) === "OpusHead", a = Math.random() * 4294967295 >>> 0, o = [
|
|
4404
|
+
let i = t && t.length >= 19 && new TextDecoder().decode(t.slice(0, 8)) === "OpusHead", a = Math.random() * 4294967295 >>> 0, o = [kr([i ? t : Ar(n)], 0, a, 0, 2), kr([jr()], 0, a, 1, 0)], s = 0, c = 2;
|
|
4235
4405
|
for (let e = 0; e < r.length;) {
|
|
4236
4406
|
let t = [], n = 0;
|
|
4237
4407
|
for (; e < r.length && t.length < 50;) {
|
|
4238
4408
|
let i = Math.floor(r[e].length / 255) + 1;
|
|
4239
4409
|
if (n + i > 255) break;
|
|
4240
|
-
t.push(r[e]), n += i, s +=
|
|
4410
|
+
t.push(r[e]), n += i, s += Er(r[e]), e++;
|
|
4241
4411
|
}
|
|
4242
4412
|
if (!t.length) return null;
|
|
4243
|
-
o.push(
|
|
4413
|
+
o.push(kr(t, s, a, c++, e >= r.length ? 4 : 0));
|
|
4244
4414
|
}
|
|
4245
4415
|
let l = o.reduce((e, t) => e + t.length, 0), u = new Uint8Array(l), d = 0;
|
|
4246
4416
|
for (let e of o) u.set(e, d), d += e.length;
|
|
@@ -4248,22 +4418,22 @@ function jr(e) {
|
|
|
4248
4418
|
}
|
|
4249
4419
|
//#endregion
|
|
4250
4420
|
//#region src/components/Composer.tsx
|
|
4251
|
-
var
|
|
4421
|
+
var Nr = [
|
|
4252
4422
|
"audio/ogg;codecs=opus",
|
|
4253
4423
|
"audio/webm;codecs=opus",
|
|
4254
4424
|
"audio/mp4",
|
|
4255
4425
|
"audio/webm"
|
|
4256
4426
|
];
|
|
4257
|
-
async function
|
|
4427
|
+
async function Pr(e, t) {
|
|
4258
4428
|
let n = Date.now();
|
|
4259
4429
|
if (/webm/.test(t) && /opus/.test(t)) try {
|
|
4260
|
-
let t =
|
|
4430
|
+
let t = Mr(new Uint8Array(await new Blob(e).arrayBuffer()));
|
|
4261
4431
|
if (t) return new File([t], `voice-${n}.ogg`, { type: "audio/ogg" });
|
|
4262
4432
|
} catch {}
|
|
4263
|
-
return new File(e, `voice-${n}.${
|
|
4433
|
+
return new File(e, `voice-${n}.${Fr(t)}`, { type: t.split(";")[0] });
|
|
4264
4434
|
}
|
|
4265
|
-
var
|
|
4266
|
-
function
|
|
4435
|
+
var Fr = (e) => /mp4/.test(e) ? "m4a" : /ogg/.test(e) ? "ogg" : "webm", Ir = (e) => `${Math.floor(e / 6e4)}:${String(Math.floor(e % 6e4 / 1e3)).padStart(2, "0")}`;
|
|
4436
|
+
function Lr({ onSend: e, onTyping: t, onFile: n, disabled: r, disabledText: o, focusKey: l }) {
|
|
4267
4437
|
let [u, p] = c(""), [m, h] = c(!1), g = s(null), _ = s(null), v = s(null), y = s(), b = s(!1), [x, S] = c(null), [C, w] = c(0), T = s(!1), E = s(!1), D = s(!1), O = s({});
|
|
4268
4438
|
i(() => v.current?.focus(), []), i(() => () => {
|
|
4269
4439
|
D.current = !0, T.current = !0, window.clearTimeout(y.current);
|
|
@@ -4279,21 +4449,21 @@ function Ir({ onSend: e, onTyping: t, onFile: n, disabled: r, disabledText: o, f
|
|
|
4279
4449
|
let k = (e) => {
|
|
4280
4450
|
b.current !== e && (b.current = e, t(e));
|
|
4281
4451
|
}, A = (e) => {
|
|
4282
|
-
let t = e.includes(":") ?
|
|
4452
|
+
let t = e.includes(":") ? rr(e) : e;
|
|
4283
4453
|
t !== e && (g.current = Math.max(0, (v.current?.selectionStart ?? e.length) - (e.length - t.length))), p(t), t ? (k(!0), window.clearTimeout(y.current), y.current = window.setTimeout(() => k(!1), 4e3)) : k(!1);
|
|
4284
4454
|
};
|
|
4285
4455
|
a(() => {
|
|
4286
4456
|
g.current !== null && (v.current?.setSelectionRange(g.current, g.current), g.current = null);
|
|
4287
4457
|
}, [u]);
|
|
4288
|
-
let
|
|
4458
|
+
let j = (e) => {
|
|
4289
4459
|
let t = v.current, n = t?.selectionStart ?? u.length, r = t?.selectionEnd ?? n;
|
|
4290
4460
|
A(u.slice(0, n) + e + u.slice(r)), requestAnimationFrame(() => {
|
|
4291
4461
|
t?.focus(), t?.setSelectionRange(n + e.length, n + e.length);
|
|
4292
4462
|
});
|
|
4293
|
-
},
|
|
4463
|
+
}, M = () => {
|
|
4294
4464
|
let t = u.trim();
|
|
4295
4465
|
t && (p(""), Promise.resolve(e(t)).catch(() => p((e) => e || t)), window.clearTimeout(y.current), b.current = !1);
|
|
4296
|
-
},
|
|
4466
|
+
}, N = async () => {
|
|
4297
4467
|
if (E.current || x) return;
|
|
4298
4468
|
E.current = !0;
|
|
4299
4469
|
let e;
|
|
@@ -4304,9 +4474,9 @@ function Ir({ onSend: e, onTyping: t, onFile: n, disabled: r, disabledText: o, f
|
|
|
4304
4474
|
t.getTracks().forEach((e) => e.stop());
|
|
4305
4475
|
return;
|
|
4306
4476
|
}
|
|
4307
|
-
let r =
|
|
4477
|
+
let r = Nr.find((e) => MediaRecorder.isTypeSupported(e)), i = new MediaRecorder(e, r ? { mimeType: r } : void 0), a = [];
|
|
4308
4478
|
i.ondataavailable = (e) => e.data.size && a.push(e.data), i.onstop = () => {
|
|
4309
|
-
t.getTracks().forEach((e) => e.stop()), O.current = {}, S(null), !T.current && a.length &&
|
|
4479
|
+
t.getTracks().forEach((e) => e.stop()), O.current = {}, S(null), !T.current && a.length && Pr(a, i.mimeType || r || "").then(n);
|
|
4310
4480
|
}, T.current = !1, i.start(), O.current = {
|
|
4311
4481
|
r: i,
|
|
4312
4482
|
stream: t
|
|
@@ -4319,39 +4489,39 @@ function Ir({ onSend: e, onTyping: t, onFile: n, disabled: r, disabledText: o, f
|
|
|
4319
4489
|
} finally {
|
|
4320
4490
|
E.current = !1;
|
|
4321
4491
|
}
|
|
4322
|
-
},
|
|
4492
|
+
}, P = (e) => {
|
|
4323
4493
|
T.current = e, x?.r.stop();
|
|
4324
4494
|
};
|
|
4325
4495
|
return x ? /* @__PURE__ */ f("div", {
|
|
4326
4496
|
className: "ci-flex ci-items-center ci-gap-2 ci-px-3 ci-py-3",
|
|
4327
4497
|
children: [
|
|
4328
|
-
/* @__PURE__ */ d(
|
|
4498
|
+
/* @__PURE__ */ d(Q, {
|
|
4329
4499
|
variant: "transparent",
|
|
4330
4500
|
title: "Discard",
|
|
4331
4501
|
"aria-label": "Discard",
|
|
4332
|
-
onClick: () =>
|
|
4502
|
+
onClick: () => P(!0),
|
|
4333
4503
|
className: "ci-h-10 ci-w-10",
|
|
4334
|
-
children:
|
|
4504
|
+
children: $.close
|
|
4335
4505
|
}),
|
|
4336
4506
|
/* @__PURE__ */ f("div", {
|
|
4337
4507
|
className: "ci-flex-1 ci-flex ci-items-center ci-gap-2 ci-px-4 ci-py-2.5 ci-rounded-3xl ci-bg-elevationL2 dark:ci-bg-elevationL2Dark ci-text-sm",
|
|
4338
|
-
children: [/* @__PURE__ */ d("span", { className: "ci-w-2.5 ci-h-2.5 ci-rounded-full ci-bg-phoneIslandClose dark:ci-bg-phoneIslandCloseDark ci-animate-pulse" }), /* @__PURE__ */ f("span", { children: ["Recording ",
|
|
4508
|
+
children: [/* @__PURE__ */ d("span", { className: "ci-w-2.5 ci-h-2.5 ci-rounded-full ci-bg-phoneIslandClose dark:ci-bg-phoneIslandCloseDark ci-animate-pulse" }), /* @__PURE__ */ f("span", { children: ["Recording ", Ir(C)] })]
|
|
4339
4509
|
}),
|
|
4340
|
-
/* @__PURE__ */ d(
|
|
4510
|
+
/* @__PURE__ */ d(Q, {
|
|
4341
4511
|
variant: "green",
|
|
4342
4512
|
title: "Send voice note",
|
|
4343
4513
|
"aria-label": "Send voice note",
|
|
4344
|
-
onClick: () =>
|
|
4514
|
+
onClick: () => P(!1),
|
|
4345
4515
|
className: "ci-h-10 ci-w-10",
|
|
4346
|
-
children:
|
|
4516
|
+
children: $.send
|
|
4347
4517
|
})
|
|
4348
4518
|
]
|
|
4349
4519
|
}) : /* @__PURE__ */ f("div", {
|
|
4350
4520
|
className: "ci-relative ci-flex ci-items-center ci-gap-2 ci-px-3 ci-py-3",
|
|
4351
4521
|
children: [
|
|
4352
|
-
m && /* @__PURE__ */ d(
|
|
4522
|
+
m && /* @__PURE__ */ d(or, {
|
|
4353
4523
|
className: "ci-absolute ci-bottom-full ci-left-3 ci-mb-1",
|
|
4354
|
-
onPick:
|
|
4524
|
+
onPick: j,
|
|
4355
4525
|
onClose: () => h(!1)
|
|
4356
4526
|
}),
|
|
4357
4527
|
/* @__PURE__ */ d("input", {
|
|
@@ -4360,13 +4530,13 @@ function Ir({ onSend: e, onTyping: t, onFile: n, disabled: r, disabledText: o, f
|
|
|
4360
4530
|
hidden: !0,
|
|
4361
4531
|
onChange: (e) => e.target.files?.[0] && (n(e.target.files[0]), e.target.value = "")
|
|
4362
4532
|
}),
|
|
4363
|
-
/* @__PURE__ */ d(
|
|
4533
|
+
/* @__PURE__ */ d(Q, {
|
|
4364
4534
|
variant: "transparent",
|
|
4365
4535
|
disabled: r,
|
|
4366
4536
|
title: "Attach a file",
|
|
4367
4537
|
onClick: () => _.current?.click(),
|
|
4368
4538
|
className: "ci-h-10 ci-w-10",
|
|
4369
|
-
children:
|
|
4539
|
+
children: $.clip
|
|
4370
4540
|
}),
|
|
4371
4541
|
/* @__PURE__ */ f("div", {
|
|
4372
4542
|
className: "ci-relative ci-flex-1 ci-min-w-0",
|
|
@@ -4378,7 +4548,7 @@ function Ir({ onSend: e, onTyping: t, onFile: n, disabled: r, disabledText: o, f
|
|
|
4378
4548
|
"aria-expanded": m,
|
|
4379
4549
|
onClick: () => h((e) => !e),
|
|
4380
4550
|
className: "ci-absolute ci-left-2 ci-bottom-1 ci-z-10 ci-h-8 ci-w-8 ci-flex ci-items-center ci-justify-center ci-rounded-full ci-border-0 ci-bg-transparent ci-text-secondaryNeutral dark:ci-text-secondaryNeutralDark hover:ci-bg-gray-300/70 dark:hover:ci-bg-gray-700/30 disabled:ci-opacity-40",
|
|
4381
|
-
children:
|
|
4551
|
+
children: $.smile
|
|
4382
4552
|
}), /* @__PURE__ */ d("textarea", {
|
|
4383
4553
|
ref: v,
|
|
4384
4554
|
value: u,
|
|
@@ -4388,42 +4558,42 @@ function Ir({ onSend: e, onTyping: t, onFile: n, disabled: r, disabledText: o, f
|
|
|
4388
4558
|
onChange: (e) => A(e.target.value),
|
|
4389
4559
|
onKeyDown: (e) => {
|
|
4390
4560
|
let t = (u.match(/```/g) ?? []).length % 2 == 1;
|
|
4391
|
-
e.key === "Enter" && !e.shiftKey && !t && (e.preventDefault(),
|
|
4561
|
+
e.key === "Enter" && !e.shiftKey && !t && (e.preventDefault(), M());
|
|
4392
4562
|
},
|
|
4393
4563
|
className: `${r ? "ci-overflow-hidden" : ""} 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`,
|
|
4394
4564
|
style: { height: Math.min(128, 40 + 20 * (u.split("\n").length - 1)) }
|
|
4395
4565
|
})]
|
|
4396
4566
|
}),
|
|
4397
|
-
u.trim() ? /* @__PURE__ */ d(
|
|
4567
|
+
u.trim() ? /* @__PURE__ */ d(Q, {
|
|
4398
4568
|
variant: "default",
|
|
4399
4569
|
disabled: r,
|
|
4400
|
-
onClick:
|
|
4570
|
+
onClick: M,
|
|
4401
4571
|
title: "Send",
|
|
4402
4572
|
className: "ci-h-10 ci-w-10",
|
|
4403
|
-
children:
|
|
4404
|
-
}) : /* @__PURE__ */ d(
|
|
4573
|
+
children: $.send
|
|
4574
|
+
}) : /* @__PURE__ */ d(Q, {
|
|
4405
4575
|
variant: "default",
|
|
4406
4576
|
disabled: r || typeof MediaRecorder > "u",
|
|
4407
|
-
onClick:
|
|
4577
|
+
onClick: N,
|
|
4408
4578
|
title: "Record a voice note",
|
|
4409
4579
|
"aria-label": "Record a voice note",
|
|
4410
4580
|
className: "ci-h-10 ci-w-10",
|
|
4411
|
-
children:
|
|
4581
|
+
children: $.mic
|
|
4412
4582
|
})
|
|
4413
4583
|
]
|
|
4414
4584
|
});
|
|
4415
4585
|
}
|
|
4416
4586
|
//#endregion
|
|
4417
4587
|
//#region src/components/ChatWindow.tsx
|
|
4418
|
-
var
|
|
4588
|
+
var Rr = (e) => !!e && ![
|
|
4419
4589
|
"offline",
|
|
4420
4590
|
"dnd",
|
|
4421
4591
|
"busy",
|
|
4422
4592
|
"ringing",
|
|
4423
4593
|
"onhold"
|
|
4424
4594
|
].includes(e);
|
|
4425
|
-
function
|
|
4426
|
-
let { c:
|
|
4595
|
+
function zr({ peer: e, actions: t, theme: n, onDragStart: r }) {
|
|
4596
|
+
let { c: a, contacts: o, online: s, mobile: l, inactive: p, status: m, closeChat: h, openChat: g, markRead: _, order: v, me: y } = Y(w((t) => ({
|
|
4427
4597
|
c: t.conversations[e],
|
|
4428
4598
|
contacts: t.contacts,
|
|
4429
4599
|
online: t.online,
|
|
@@ -4435,131 +4605,143 @@ function Rr({ peer: e, actions: t, onDragStart: n }) {
|
|
|
4435
4605
|
markRead: t.markRead,
|
|
4436
4606
|
order: t.order,
|
|
4437
4607
|
me: t.me
|
|
4438
|
-
}))),
|
|
4608
|
+
}))), b = Math.max(0, v.indexOf(e)), x = o[e], [S, C] = c(!1), [T, E] = c(!1), [D, O] = c(null), [k, A] = c(0), j = (e) => e === y ? "You" : o[e]?.name ?? e, M = [...a?.members ?? []].sort((e, t) => Number(e === y) - Number(t === y));
|
|
4439
4609
|
i(() => {
|
|
4440
|
-
|
|
4441
|
-
}, [e,
|
|
4442
|
-
|
|
4443
|
-
}, [e,
|
|
4444
|
-
|
|
4610
|
+
a && !a.loaded && t.loadOlder(e);
|
|
4611
|
+
}, [e, a?.loaded]), i(() => {
|
|
4612
|
+
_(e);
|
|
4613
|
+
}, [e, a?.messages.length]), i(() => {
|
|
4614
|
+
C(!1), E(!1), O(null);
|
|
4445
4615
|
}, [e]);
|
|
4446
|
-
let
|
|
4616
|
+
let N = (t) => {
|
|
4447
4617
|
if (!t.oid) return;
|
|
4448
|
-
let n =
|
|
4449
|
-
|
|
4618
|
+
let n = a?.kind === "group" ? t.nick ?? "" : t.mine ? y : e, r = t.oob ? "Attachment" : t.body.replace(/```/g, "").replace(/\s+/g, " ").trim().slice(0, 100), i = n === y ? Y.getState().myName || y : o[n]?.name ?? n;
|
|
4619
|
+
O({
|
|
4450
4620
|
id: t.oid,
|
|
4451
4621
|
author: n,
|
|
4452
|
-
quote: `${
|
|
4453
|
-
}),
|
|
4454
|
-
},
|
|
4455
|
-
e.key === "Escape" && (e.stopPropagation(),
|
|
4622
|
+
quote: `${i}: ${r}`
|
|
4623
|
+
}), A((e) => e + 1);
|
|
4624
|
+
}, P = (e) => {
|
|
4625
|
+
e.key === "Escape" && (e.stopPropagation(), T ? E(!1) : D ? O(null) : S ? C(!1) : h());
|
|
4456
4626
|
};
|
|
4457
|
-
if (!
|
|
4458
|
-
let
|
|
4627
|
+
if (!a) return null;
|
|
4628
|
+
let F = a.kind !== "group" && !!p[e];
|
|
4459
4629
|
return /* @__PURE__ */ f("div", {
|
|
4460
4630
|
role: "dialog",
|
|
4461
|
-
"aria-label":
|
|
4462
|
-
onKeyDown:
|
|
4463
|
-
className: "ci-relative ci-w-[22rem] ci-h-[30rem] ci-flex ci-flex-col ci-rounded-3xl ci-shadow-2xl ci-bg-gray-50 dark:ci-bg-gray-950 ci-text-gray-900 dark:ci-text-white",
|
|
4631
|
+
"aria-label": a.kind === "group" ? a.name ?? e : x?.name ?? p[e] ?? e,
|
|
4632
|
+
onKeyDown: P,
|
|
4633
|
+
className: "ci-relative ci-w-[22rem] ci-h-[30rem] ci-flex ci-flex-col ci-rounded-3xl ci-shadow-2xl ci-bg-gray-50 dark:ci-bg-gray-950 dark:ci-border dark:ci-border-solid dark:ci-border-gray-700 ci-text-gray-900 dark:ci-text-white",
|
|
4464
4634
|
children: [
|
|
4465
4635
|
/* @__PURE__ */ d("span", {
|
|
4466
|
-
className: "ci-absolute ci--right-1.5 ci-w-3 ci-h-3 ci-rotate-45 ci-bg-gray-50 dark:ci-bg-gray-950 ci-shadow-2xl ci-transition-all ci-duration-200",
|
|
4467
|
-
style: { bottom: `calc(1.875rem + ${
|
|
4636
|
+
className: "ci-absolute ci--right-1.5 ci-w-3 ci-h-3 ci-rotate-45 ci-bg-gray-50 dark:ci-bg-gray-950 dark:ci-border-0 dark:ci-border-t dark:ci-border-r dark:ci-border-solid dark:ci-border-gray-700 ci-shadow-2xl ci-transition-all ci-duration-200",
|
|
4637
|
+
style: { bottom: `calc(1.875rem + ${b} * 3.75rem)` },
|
|
4468
4638
|
"aria-hidden": "true"
|
|
4469
4639
|
}),
|
|
4470
4640
|
/* @__PURE__ */ f("div", {
|
|
4471
|
-
className: `ci-flex ci-items-center ci-gap-3 ci-px-4 ci-py-3 ci-rounded-t-3xl ${
|
|
4472
|
-
onPointerDown:
|
|
4641
|
+
className: `ci-flex ci-items-center ci-gap-3 ci-px-4 ci-py-3 ci-rounded-t-3xl ${r ? "ci-cursor-grab active:ci-cursor-grabbing ci-touch-none" : ""}`,
|
|
4642
|
+
onPointerDown: r,
|
|
4473
4643
|
children: [
|
|
4474
|
-
|
|
4475
|
-
name:
|
|
4644
|
+
a.kind === "group" ? /* @__PURE__ */ d(Jn, {
|
|
4645
|
+
name: a.name ?? e,
|
|
4476
4646
|
size: 36,
|
|
4477
|
-
avatar:
|
|
4647
|
+
avatar: a.avatar
|
|
4478
4648
|
}) : /* @__PURE__ */ f("span", {
|
|
4479
4649
|
className: "ci-relative",
|
|
4480
|
-
children: [/* @__PURE__ */ d(
|
|
4481
|
-
contact:
|
|
4650
|
+
children: [/* @__PURE__ */ d(Kn, {
|
|
4651
|
+
contact: x,
|
|
4482
4652
|
username: e,
|
|
4483
4653
|
size: 36
|
|
4484
|
-
}), /* @__PURE__ */ d(
|
|
4485
|
-
online:
|
|
4486
|
-
presence:
|
|
4487
|
-
mobile:
|
|
4654
|
+
}), /* @__PURE__ */ d(qn, {
|
|
4655
|
+
online: s[e],
|
|
4656
|
+
presence: x?.presence,
|
|
4657
|
+
mobile: l[e]
|
|
4488
4658
|
})]
|
|
4489
4659
|
}),
|
|
4490
4660
|
/* @__PURE__ */ f("div", {
|
|
4491
|
-
className: `ci-flex-1 ci-min-w-0 ${
|
|
4492
|
-
...
|
|
4661
|
+
className: `ci-flex-1 ci-min-w-0 ${a.kind === "group" ? "ci-cursor-pointer" : ""}`,
|
|
4662
|
+
...a.kind === "group" ? {
|
|
4493
4663
|
role: "button",
|
|
4494
4664
|
tabIndex: 0,
|
|
4495
|
-
"aria-expanded":
|
|
4496
|
-
onKeyDown: (e) => (e.key === "Enter" || e.key === " ") && (e.preventDefault(),
|
|
4665
|
+
"aria-expanded": S,
|
|
4666
|
+
onKeyDown: (e) => (e.key === "Enter" || e.key === " ") && (e.preventDefault(), C((e) => !e))
|
|
4497
4667
|
} : {},
|
|
4498
|
-
onClick: () =>
|
|
4668
|
+
onClick: () => a.kind === "group" && C((e) => !e),
|
|
4499
4669
|
children: [/* @__PURE__ */ d("div", {
|
|
4500
4670
|
className: "ci-font-medium ci-truncate ci-text-sm",
|
|
4501
|
-
children:
|
|
4671
|
+
children: a.kind === "group" ? a.name ?? e : x?.name ?? p[e] ?? e
|
|
4502
4672
|
}), /* @__PURE__ */ d("div", {
|
|
4503
4673
|
className: "ci-text-xs ci-text-gray-500 dark:ci-text-gray-400 ci-truncate",
|
|
4504
|
-
children:
|
|
4674
|
+
children: F ? "No longer active" : m === "online" ? a.kind === "group" ? M.map(j).join(", ") : a.typing ? "typing…" : s[e] ? "online" : l[e] ? "Mobile" : "offline" : m
|
|
4505
4675
|
})]
|
|
4506
4676
|
}),
|
|
4507
|
-
!
|
|
4677
|
+
!F && a.kind !== "group" && x?.number && Rr(x.presence) && /* @__PURE__ */ d(Q, {
|
|
4508
4678
|
variant: "call",
|
|
4509
|
-
title: `Call ${
|
|
4679
|
+
title: `Call ${x.number}`,
|
|
4510
4680
|
"aria-label": "Call",
|
|
4511
|
-
onClick: () =>
|
|
4681
|
+
onClick: () => X("chat-island-call", {
|
|
4512
4682
|
username: e,
|
|
4513
|
-
number:
|
|
4683
|
+
number: x.number
|
|
4514
4684
|
}),
|
|
4515
|
-
children:
|
|
4685
|
+
children: $.phone
|
|
4516
4686
|
}),
|
|
4517
|
-
/* @__PURE__ */ d(
|
|
4687
|
+
/* @__PURE__ */ d(Q, {
|
|
4518
4688
|
variant: "small",
|
|
4519
|
-
onClick: () =>
|
|
4689
|
+
onClick: () => h(),
|
|
4520
4690
|
"aria-label": "Minimize",
|
|
4521
4691
|
title: "Minimize",
|
|
4522
|
-
children:
|
|
4692
|
+
children: $.minus
|
|
4693
|
+
}),
|
|
4694
|
+
/* @__PURE__ */ d(Q, {
|
|
4695
|
+
variant: "small",
|
|
4696
|
+
onClick: () => E((e) => !e),
|
|
4697
|
+
"aria-label": "Menu",
|
|
4698
|
+
title: "Menu",
|
|
4699
|
+
"aria-expanded": T,
|
|
4700
|
+
children: $.dots
|
|
4523
4701
|
})
|
|
4524
4702
|
]
|
|
4525
4703
|
}),
|
|
4526
4704
|
/* @__PURE__ */ d("div", { className: "ci-border-t ci-border-gray-300 dark:ci-border-gray-700" }),
|
|
4527
|
-
|
|
4528
|
-
|
|
4529
|
-
|
|
4705
|
+
T && /* @__PURE__ */ d(Vr, {
|
|
4706
|
+
theme: n,
|
|
4707
|
+
onClose: () => E(!1)
|
|
4708
|
+
}),
|
|
4709
|
+
S && a.kind === "group" && /* @__PURE__ */ d("div", {
|
|
4710
|
+
className: "ci-anim-drop ci-absolute ci-left-3 ci-right-3 ci-top-16 ci-z-10 ci-max-h-64 ci-overflow-y-auto ci-rounded-2xl ci-bg-gray-50 dark:ci-bg-gray-950 ci-shadow-2xl ci-border ci-border-solid ci-border-gray-300 dark:ci-border-gray-600 ci-p-2",
|
|
4711
|
+
children: M.map((e) => /* @__PURE__ */ f("div", {
|
|
4530
4712
|
className: "ci-flex ci-items-center ci-gap-3 ci-px-2 ci-py-1.5 ci-text-sm",
|
|
4531
4713
|
children: [
|
|
4532
4714
|
/* @__PURE__ */ f("span", {
|
|
4533
4715
|
className: "ci-relative",
|
|
4534
|
-
children: [/* @__PURE__ */ d(
|
|
4535
|
-
contact:
|
|
4716
|
+
children: [/* @__PURE__ */ d(Kn, {
|
|
4717
|
+
contact: o[e],
|
|
4536
4718
|
username: e,
|
|
4537
4719
|
size: 28
|
|
4538
|
-
}), e !==
|
|
4539
|
-
online:
|
|
4540
|
-
presence:
|
|
4541
|
-
mobile:
|
|
4720
|
+
}), e !== y && /* @__PURE__ */ d(qn, {
|
|
4721
|
+
online: s[e],
|
|
4722
|
+
presence: o[e]?.presence,
|
|
4723
|
+
mobile: l[e]
|
|
4542
4724
|
})]
|
|
4543
4725
|
}),
|
|
4544
4726
|
/* @__PURE__ */ d("span", {
|
|
4545
4727
|
className: "ci-truncate ci-flex-1",
|
|
4546
|
-
children:
|
|
4728
|
+
children: j(e)
|
|
4547
4729
|
}),
|
|
4548
|
-
e !==
|
|
4730
|
+
e !== y && /* @__PURE__ */ f(u, { children: [/* @__PURE__ */ d(Q, {
|
|
4549
4731
|
variant: "small",
|
|
4550
4732
|
title: "Chat",
|
|
4551
4733
|
"aria-label": "Chat",
|
|
4552
|
-
onClick: () =>
|
|
4553
|
-
children:
|
|
4554
|
-
}),
|
|
4734
|
+
onClick: () => g(e),
|
|
4735
|
+
children: $.chat
|
|
4736
|
+
}), o[e]?.number && Rr(o[e]?.presence) && /* @__PURE__ */ d(Q, {
|
|
4555
4737
|
variant: "call",
|
|
4556
|
-
title: `Call ${
|
|
4738
|
+
title: `Call ${o[e]?.number}`,
|
|
4557
4739
|
"aria-label": "Call",
|
|
4558
|
-
onClick: () =>
|
|
4740
|
+
onClick: () => X("chat-island-call", {
|
|
4559
4741
|
username: e,
|
|
4560
|
-
number:
|
|
4742
|
+
number: o[e].number
|
|
4561
4743
|
}),
|
|
4562
|
-
children:
|
|
4744
|
+
children: $.phone
|
|
4563
4745
|
})] })
|
|
4564
4746
|
]
|
|
4565
4747
|
}, e))
|
|
@@ -4567,41 +4749,41 @@ function Rr({ peer: e, actions: t, onDragStart: n }) {
|
|
|
4567
4749
|
/* @__PURE__ */ f("div", {
|
|
4568
4750
|
className: "ci-flex-1 ci-min-h-0 ci-flex ci-flex-col ci-overflow-hidden ci-rounded-b-3xl",
|
|
4569
4751
|
children: [
|
|
4570
|
-
/* @__PURE__ */ d(
|
|
4571
|
-
messages:
|
|
4572
|
-
typing:
|
|
4573
|
-
group:
|
|
4574
|
-
hasOlder:
|
|
4752
|
+
/* @__PURE__ */ d(Sr, {
|
|
4753
|
+
messages: a.messages,
|
|
4754
|
+
typing: a.typing,
|
|
4755
|
+
group: a.kind === "group",
|
|
4756
|
+
hasOlder: a.loaded && !a.complete,
|
|
4575
4757
|
onLoadOlder: () => t.loadOlder(e),
|
|
4576
|
-
reactions:
|
|
4577
|
-
me:
|
|
4758
|
+
reactions: a.reactions,
|
|
4759
|
+
me: y,
|
|
4578
4760
|
onReact: (n, r) => t.react(e, n, r),
|
|
4579
|
-
onReply:
|
|
4761
|
+
onReply: N
|
|
4580
4762
|
}),
|
|
4581
|
-
|
|
4763
|
+
D && /* @__PURE__ */ f("div", {
|
|
4582
4764
|
className: "ci-mx-3 ci-mt-1 ci-flex ci-items-center ci-gap-2 ci-pl-3 ci-pr-1 ci-py-1.5 ci-rounded-2xl ci-bg-elevationL2 dark:ci-bg-elevationL2Dark ci-border-0 ci-border-l-4 ci-border-solid ci-border-iconSecondary dark:ci-border-iconSecondaryDark",
|
|
4583
4765
|
children: [/* @__PURE__ */ f("div", {
|
|
4584
4766
|
className: "ci-flex-1 ci-min-w-0 ci-text-xs",
|
|
4585
4767
|
children: [/* @__PURE__ */ d("div", {
|
|
4586
4768
|
className: "ci-font-medium ci-text-gray-900 dark:ci-text-white",
|
|
4587
|
-
children:
|
|
4769
|
+
children: D.author === y ? "You" : o[D.author]?.name ?? D.author
|
|
4588
4770
|
}), /* @__PURE__ */ d("div", {
|
|
4589
4771
|
className: "ci-truncate ci-text-gray-500 dark:ci-text-gray-400",
|
|
4590
|
-
children:
|
|
4772
|
+
children: D.quote?.replace(/^[^:]*: /, "")
|
|
4591
4773
|
})]
|
|
4592
|
-
}), /* @__PURE__ */ d(
|
|
4774
|
+
}), /* @__PURE__ */ d(Q, {
|
|
4593
4775
|
variant: "small",
|
|
4594
|
-
onClick: () =>
|
|
4776
|
+
onClick: () => O(null),
|
|
4595
4777
|
"aria-label": "Cancel reply",
|
|
4596
4778
|
title: "Cancel reply",
|
|
4597
|
-
children:
|
|
4779
|
+
children: $.close
|
|
4598
4780
|
})]
|
|
4599
4781
|
}),
|
|
4600
|
-
/* @__PURE__ */ d(
|
|
4601
|
-
focusKey:
|
|
4602
|
-
disabled:
|
|
4603
|
-
disabledText:
|
|
4604
|
-
onSend: (n) => t.send(e, n,
|
|
4782
|
+
/* @__PURE__ */ d(Lr, {
|
|
4783
|
+
focusKey: k,
|
|
4784
|
+
disabled: m !== "online" || F,
|
|
4785
|
+
disabledText: F ? "No longer active" : void 0,
|
|
4786
|
+
onSend: (n) => t.send(e, n, D ?? void 0).then(() => O(null)),
|
|
4605
4787
|
onTyping: (n) => t.typing(e, n),
|
|
4606
4788
|
onFile: (n) => t.upload(e, n)
|
|
4607
4789
|
}, e)
|
|
@@ -4610,14 +4792,65 @@ function Rr({ peer: e, actions: t, onDragStart: n }) {
|
|
|
4610
4792
|
]
|
|
4611
4793
|
});
|
|
4612
4794
|
}
|
|
4795
|
+
var Br = [
|
|
4796
|
+
{
|
|
4797
|
+
value: "light",
|
|
4798
|
+
label: "Light",
|
|
4799
|
+
icon: $.sun
|
|
4800
|
+
},
|
|
4801
|
+
{
|
|
4802
|
+
value: "dark",
|
|
4803
|
+
label: "Dark",
|
|
4804
|
+
icon: $.moon
|
|
4805
|
+
},
|
|
4806
|
+
{
|
|
4807
|
+
value: "system",
|
|
4808
|
+
label: "System",
|
|
4809
|
+
icon: $.monitor
|
|
4810
|
+
}
|
|
4811
|
+
];
|
|
4812
|
+
function Vr({ theme: e, onClose: t }) {
|
|
4813
|
+
let n = s(null);
|
|
4814
|
+
return i(() => {
|
|
4815
|
+
let e = (e) => n.current && !n.current.contains(e.target) && !e.target.closest("[aria-label=\"Menu\"]") && t();
|
|
4816
|
+
return document.addEventListener("pointerdown", e, !0), () => document.removeEventListener("pointerdown", e, !0);
|
|
4817
|
+
}, [t]), /* @__PURE__ */ f("div", {
|
|
4818
|
+
ref: n,
|
|
4819
|
+
role: "menu",
|
|
4820
|
+
className: "ci-anim-drop ci-absolute ci-right-3 ci-top-14 ci-z-20 ci-w-44 ci-py-2 ci-rounded-2xl ci-bg-gray-50 dark:ci-bg-gray-950 ci-shadow-2xl ci-border ci-border-solid ci-border-gray-300 dark:ci-border-gray-600 ci-text-sm",
|
|
4821
|
+
children: [/* @__PURE__ */ d("div", {
|
|
4822
|
+
className: "ci-px-4 ci-py-1 ci-font-semibold ci-text-gray-600 dark:ci-text-gray-50",
|
|
4823
|
+
children: "Theme"
|
|
4824
|
+
}), Br.map((n) => /* @__PURE__ */ f("button", {
|
|
4825
|
+
type: "button",
|
|
4826
|
+
role: "menuitemradio",
|
|
4827
|
+
"aria-checked": e === n.value,
|
|
4828
|
+
onClick: () => {
|
|
4829
|
+
X("chat-island-theme-change", { theme: n.value }), t();
|
|
4830
|
+
},
|
|
4831
|
+
className: "ci-w-full ci-flex ci-items-center ci-gap-2 ci-px-3 ci-py-2 ci-border-0 ci-bg-transparent ci-text-left ci-text-gray-700 dark:ci-text-gray-50 hover:ci-bg-gray-200 dark:hover:ci-bg-gray-700",
|
|
4832
|
+
children: [
|
|
4833
|
+
/* @__PURE__ */ d("span", {
|
|
4834
|
+
className: "ci-w-4 ci-text-green-600 dark:ci-text-green-400",
|
|
4835
|
+
children: e === n.value && $.check
|
|
4836
|
+
}),
|
|
4837
|
+
/* @__PURE__ */ d("span", {
|
|
4838
|
+
className: "ci-text-gray-600 dark:ci-text-gray-100",
|
|
4839
|
+
children: n.icon
|
|
4840
|
+
}),
|
|
4841
|
+
n.label
|
|
4842
|
+
]
|
|
4843
|
+
}, n.value))]
|
|
4844
|
+
});
|
|
4845
|
+
}
|
|
4613
4846
|
//#endregion
|
|
4614
4847
|
//#region src/components/NewChat.tsx
|
|
4615
|
-
async function
|
|
4848
|
+
async function Hr(e) {
|
|
4616
4849
|
let t = await createImageBitmap(e), n = Math.min(t.width, t.height), r = document.createElement("canvas");
|
|
4617
4850
|
return r.width = r.height = 128, r.getContext("2d")?.drawImage(t, (t.width - n) / 2, (t.height - n) / 2, n, n, 0, 0, 128, 128), r.toDataURL("image/jpeg", .8);
|
|
4618
4851
|
}
|
|
4619
|
-
function
|
|
4620
|
-
let { contacts: r, online: i, mobile: a, setPicker: l } =
|
|
4852
|
+
function Ur({ onOpen: e, onCreateGroup: t, onDragStart: n }) {
|
|
4853
|
+
let { contacts: r, online: i, mobile: a, setPicker: l } = Y(), [p, m] = c(""), [h, g] = c([]), [_, v] = c(""), [y, b] = c(!1), [x, S] = c(), C = s(null), w = o(() => {
|
|
4621
4854
|
let e = Object.values(r), t = p.trim().toLowerCase();
|
|
4622
4855
|
return t ? e.filter((e) => (e.name ?? "").toLowerCase().includes(t) || e.username.includes(t)) : e;
|
|
4623
4856
|
}, [r, p]), T = (e) => g((t) => t.includes(e) ? t.filter((t) => t !== e) : [...t, e]), E = async () => {
|
|
@@ -4629,25 +4862,25 @@ function Br({ onOpen: e, onCreateGroup: t, onDragStart: n }) {
|
|
|
4629
4862
|
}
|
|
4630
4863
|
};
|
|
4631
4864
|
return /* @__PURE__ */ f("div", {
|
|
4632
|
-
className: "ci-w-[22rem] ci-max-h-[30rem] ci-flex ci-flex-col ci-rounded-3xl ci-shadow-2xl ci-overflow-hidden ci-bg-gray-50 dark:ci-bg-gray-950 ci-text-gray-900 dark:ci-text-white",
|
|
4865
|
+
className: "ci-w-[22rem] ci-max-h-[30rem] ci-flex ci-flex-col ci-rounded-3xl ci-shadow-2xl dark:ci-border dark:ci-border-solid dark:ci-border-gray-700 ci-overflow-hidden ci-bg-gray-50 dark:ci-bg-gray-950 ci-text-gray-900 dark:ci-text-white",
|
|
4633
4866
|
children: [
|
|
4634
4867
|
/* @__PURE__ */ f("div", {
|
|
4635
4868
|
className: `ci-px-4 ci-py-3 ci-flex ci-items-center ci-gap-2 ${n ? "ci-cursor-grab active:ci-cursor-grabbing ci-touch-none" : ""}`,
|
|
4636
4869
|
onPointerDown: (e) => !e.target.closest("input, button") && n?.(e),
|
|
4637
4870
|
children: [/* @__PURE__ */ f("div", {
|
|
4638
4871
|
className: "ci-flex-1 ci-flex ci-items-center ci-gap-2 ci-px-4 ci-py-2 ci-rounded-3xl ci-bg-elevationL2 dark:ci-bg-elevationL2Dark ci-text-gray-500 dark:ci-text-gray-400",
|
|
4639
|
-
children: [
|
|
4872
|
+
children: [$.search, /* @__PURE__ */ d("input", {
|
|
4640
4873
|
autoFocus: !0,
|
|
4641
4874
|
value: p,
|
|
4642
4875
|
onChange: (e) => m(e.target.value),
|
|
4643
4876
|
placeholder: "Search operators",
|
|
4644
4877
|
className: "ci-flex-1 ci-bg-transparent ci-border-0 ci-outline-none ci-text-sm ci-text-gray-900 dark:ci-text-white placeholder:ci-text-gray-500 dark:placeholder:ci-text-gray-400"
|
|
4645
4878
|
})]
|
|
4646
|
-
}), /* @__PURE__ */ d(
|
|
4879
|
+
}), /* @__PURE__ */ d(Q, {
|
|
4647
4880
|
variant: "small",
|
|
4648
4881
|
onClick: () => l(!1),
|
|
4649
4882
|
"aria-label": "Close",
|
|
4650
|
-
children:
|
|
4883
|
+
children: $.close
|
|
4651
4884
|
})]
|
|
4652
4885
|
}),
|
|
4653
4886
|
h.length > 0 && /* @__PURE__ */ d("div", {
|
|
@@ -4656,7 +4889,7 @@ function Br({ onOpen: e, onCreateGroup: t, onDragStart: n }) {
|
|
|
4656
4889
|
type: "button",
|
|
4657
4890
|
onClick: () => T(e),
|
|
4658
4891
|
className: "ci-flex ci-items-center ci-gap-1 ci-pl-2.5 ci-pr-1.5 ci-py-1 ci-rounded-full ci-text-xs ci-bg-gray-700 ci-text-gray-50 dark:ci-bg-gray-300 dark:ci-text-gray-900 ci-border-0",
|
|
4659
|
-
children: [r[e]?.name ?? e,
|
|
4892
|
+
children: [r[e]?.name ?? e, $.close]
|
|
4660
4893
|
}, e))
|
|
4661
4894
|
}),
|
|
4662
4895
|
/* @__PURE__ */ d("div", { className: "ci-border-t ci-border-gray-300 dark:ci-border-gray-700" }),
|
|
@@ -4674,11 +4907,11 @@ function Br({ onOpen: e, onCreateGroup: t, onDragStart: n }) {
|
|
|
4674
4907
|
children: [
|
|
4675
4908
|
/* @__PURE__ */ f("span", {
|
|
4676
4909
|
className: "ci-relative",
|
|
4677
|
-
children: [/* @__PURE__ */ d(
|
|
4910
|
+
children: [/* @__PURE__ */ d(Kn, {
|
|
4678
4911
|
contact: e,
|
|
4679
4912
|
username: e.username,
|
|
4680
4913
|
size: 36
|
|
4681
|
-
}), /* @__PURE__ */ d(
|
|
4914
|
+
}), /* @__PURE__ */ d(qn, {
|
|
4682
4915
|
online: i[e.username],
|
|
4683
4916
|
presence: e.presence,
|
|
4684
4917
|
mobile: a[e.username]
|
|
@@ -4714,7 +4947,7 @@ function Br({ onOpen: e, onCreateGroup: t, onDragStart: n }) {
|
|
|
4714
4947
|
}),
|
|
4715
4948
|
h.length > 0 && /* @__PURE__ */ d("div", {
|
|
4716
4949
|
className: "ci-border-t ci-border-gray-300 dark:ci-border-gray-700 ci-px-4 ci-py-3 ci-flex ci-items-center ci-gap-2",
|
|
4717
|
-
children: h.length === 1 ? /* @__PURE__ */ d(
|
|
4950
|
+
children: h.length === 1 ? /* @__PURE__ */ d(Q, {
|
|
4718
4951
|
variant: "default",
|
|
4719
4952
|
className: "ci-w-auto ci-h-10 ci-px-5",
|
|
4720
4953
|
onClick: () => e(h[0]),
|
|
@@ -4725,7 +4958,7 @@ function Br({ onOpen: e, onCreateGroup: t, onDragStart: n }) {
|
|
|
4725
4958
|
type: "file",
|
|
4726
4959
|
accept: "image/*",
|
|
4727
4960
|
hidden: !0,
|
|
4728
|
-
onChange: (e) => e.target.files?.[0] &&
|
|
4961
|
+
onChange: (e) => e.target.files?.[0] && Hr(e.target.files[0]).then(S).catch(() => {})
|
|
4729
4962
|
}),
|
|
4730
4963
|
/* @__PURE__ */ d("button", {
|
|
4731
4964
|
type: "button",
|
|
@@ -4737,7 +4970,7 @@ function Br({ onOpen: e, onCreateGroup: t, onDragStart: n }) {
|
|
|
4737
4970
|
alt: "",
|
|
4738
4971
|
draggable: !1,
|
|
4739
4972
|
className: "ci-w-full ci-h-full ci-object-cover"
|
|
4740
|
-
}) :
|
|
4973
|
+
}) : $.camera
|
|
4741
4974
|
}),
|
|
4742
4975
|
/* @__PURE__ */ d("input", {
|
|
4743
4976
|
value: _,
|
|
@@ -4746,7 +4979,7 @@ function Br({ onOpen: e, onCreateGroup: t, onDragStart: n }) {
|
|
|
4746
4979
|
onKeyDown: (e) => e.key === "Enter" && _.trim() && !y && E(),
|
|
4747
4980
|
className: "ci-flex-1 ci-min-w-0 ci-w-0 ci-px-4 ci-py-2 ci-rounded-3xl ci-border-0 ci-bg-elevationL2 dark:ci-bg-elevationL2Dark ci-text-sm 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"
|
|
4748
4981
|
}),
|
|
4749
|
-
/* @__PURE__ */ d(
|
|
4982
|
+
/* @__PURE__ */ d(Q, {
|
|
4750
4983
|
variant: "green",
|
|
4751
4984
|
className: "ci-w-auto ci-h-10 ci-px-4 ci-shrink-0 ci-whitespace-nowrap",
|
|
4752
4985
|
disabled: !_.trim() || y,
|
|
@@ -4760,22 +4993,22 @@ function Br({ onOpen: e, onCreateGroup: t, onDragStart: n }) {
|
|
|
4760
4993
|
}
|
|
4761
4994
|
//#endregion
|
|
4762
4995
|
//#region src/theme.ts
|
|
4763
|
-
var
|
|
4996
|
+
var Wr = "chat-island-theme", Gr = () => {
|
|
4764
4997
|
try {
|
|
4765
|
-
let e = localStorage.getItem(
|
|
4998
|
+
let e = localStorage.getItem(Wr);
|
|
4766
4999
|
return e === "light" || e === "dark" || e === "system" ? e : void 0;
|
|
4767
5000
|
} catch {
|
|
4768
5001
|
return;
|
|
4769
5002
|
}
|
|
4770
5003
|
};
|
|
4771
|
-
function
|
|
4772
|
-
let [t, n] = c(() => e ??
|
|
4773
|
-
return i(() => n(e ??
|
|
5004
|
+
function Kr(e) {
|
|
5005
|
+
let [t, n] = c(() => e ?? Gr()), [r, a] = c(!1);
|
|
5006
|
+
return i(() => n(e ?? Gr()), [e]), i(() => {
|
|
4774
5007
|
let e = (e) => {
|
|
4775
5008
|
let t = e.detail?.theme;
|
|
4776
5009
|
if (t === "light" || t === "dark" || t === "system") {
|
|
4777
5010
|
try {
|
|
4778
|
-
localStorage.setItem(
|
|
5011
|
+
localStorage.setItem(Wr, t);
|
|
4779
5012
|
} catch {}
|
|
4780
5013
|
n(t);
|
|
4781
5014
|
}
|
|
@@ -4797,12 +5030,12 @@ function Ur(e) {
|
|
|
4797
5030
|
attributes: !0,
|
|
4798
5031
|
attributeFilter: ["class"]
|
|
4799
5032
|
}), () => r.disconnect();
|
|
4800
|
-
}, [t]), r;
|
|
5033
|
+
}, [t]), [r, t];
|
|
4801
5034
|
}
|
|
4802
5035
|
//#endregion
|
|
4803
5036
|
//#region src/ChatIsland.tsx
|
|
4804
|
-
function
|
|
4805
|
-
let e =
|
|
5037
|
+
function qr() {
|
|
5038
|
+
let e = Y.getState();
|
|
4806
5039
|
return Object.values(e.conversations).map((t) => {
|
|
4807
5040
|
let n = t.messages[t.messages.length - 1], r = e.contacts[t.peer];
|
|
4808
5041
|
return {
|
|
@@ -4817,7 +5050,7 @@ function Wr() {
|
|
|
4817
5050
|
unread: t.unread,
|
|
4818
5051
|
members: t.members,
|
|
4819
5052
|
last: n ? {
|
|
4820
|
-
body:
|
|
5053
|
+
body: Xr(n.body),
|
|
4821
5054
|
ts: n.ts,
|
|
4822
5055
|
mine: n.mine,
|
|
4823
5056
|
oob: n.oob,
|
|
@@ -4826,25 +5059,25 @@ function Wr() {
|
|
|
4826
5059
|
};
|
|
4827
5060
|
}).filter((e) => e.last || e.kind === "group").sort((e, t) => (t.last?.ts ?? 0) - (e.last?.ts ?? 0));
|
|
4828
5061
|
}
|
|
4829
|
-
var
|
|
5062
|
+
var Jr = class extends t {
|
|
4830
5063
|
state = { failed: !1 };
|
|
4831
5064
|
failures = [];
|
|
4832
5065
|
static getDerivedStateFromError() {
|
|
4833
5066
|
return { failed: !0 };
|
|
4834
5067
|
}
|
|
4835
5068
|
componentDidCatch(e) {
|
|
4836
|
-
|
|
5069
|
+
X("chat-island-error", {
|
|
4837
5070
|
scope: "render",
|
|
4838
5071
|
message: e.message
|
|
4839
5072
|
});
|
|
4840
5073
|
let t = Date.now();
|
|
4841
|
-
this.failures = [...this.failures.filter((e) => t - e < 1e4), t], !(this.failures.length >= 3) && (
|
|
5074
|
+
this.failures = [...this.failures.filter((e) => t - e < 1e4), t], !(this.failures.length >= 3) && (Y.getState().closeChat(), window.setTimeout(() => this.setState({ failed: !1 }), 0));
|
|
4842
5075
|
}
|
|
4843
5076
|
render() {
|
|
4844
5077
|
return this.state.failed ? null : this.props.children;
|
|
4845
5078
|
}
|
|
4846
5079
|
};
|
|
4847
|
-
function
|
|
5080
|
+
function Yr(e) {
|
|
4848
5081
|
try {
|
|
4849
5082
|
let [t, n, r] = atob(e).split(":");
|
|
4850
5083
|
return t && n && r ? {
|
|
@@ -4856,135 +5089,147 @@ function Kr(e) {
|
|
|
4856
5089
|
return null;
|
|
4857
5090
|
}
|
|
4858
5091
|
}
|
|
4859
|
-
var
|
|
4860
|
-
function
|
|
4861
|
-
let
|
|
5092
|
+
var Xr = (e) => (mr(e) ? "Attachment" : rr(e)).replace(/```[^\n]*\n?/g, "").replace(/(\*\*|__|~~|`)/g, "").replace(/(^|\s)[*_](\S[^*_]*)[*_]/g, "$1$2").replace(/\s+/g, " ").trim();
|
|
5093
|
+
function Zr(e, t = !1) {
|
|
5094
|
+
let [n, r] = c(e);
|
|
5095
|
+
return i(() => {
|
|
5096
|
+
if (e || t) return r(e);
|
|
5097
|
+
let n = window.setTimeout(() => r(e), matchMedia("(prefers-reduced-motion: reduce)").matches ? 0 : 400);
|
|
5098
|
+
return () => window.clearTimeout(n);
|
|
5099
|
+
}, [e]), [
|
|
5100
|
+
e || (t ? e : n),
|
|
5101
|
+
!e && !t && !!n,
|
|
5102
|
+
(t) => !e && t.target === t.currentTarget && r(e)
|
|
5103
|
+
];
|
|
5104
|
+
}
|
|
5105
|
+
function Qr({ dataConfig: e, position: t = "bottom-right", theme: n, serviceWorker: r, maxHeads: a = 5, newChatButton: l = !0, notifications: u = "click", sound: p = !0, drag: m = !0, onDragStart: h }) {
|
|
5106
|
+
let g = o(() => Yr(e), [e]), [_, v] = Kr(n), y = s(g), b = s(p), x = s(u);
|
|
4862
5107
|
i(() => {
|
|
4863
|
-
|
|
5108
|
+
y.current = g, b.current = p, x.current = u;
|
|
4864
5109
|
}, [
|
|
4865
5110
|
g,
|
|
4866
5111
|
p,
|
|
4867
5112
|
u
|
|
4868
|
-
]), i(() =>
|
|
5113
|
+
]), i(() => Y.setState({
|
|
4869
5114
|
maxHeads: a,
|
|
4870
5115
|
newChatButton: l
|
|
4871
5116
|
}), [a, l]);
|
|
4872
|
-
let [
|
|
5117
|
+
let [S, C] = c(0);
|
|
4873
5118
|
i(() => {
|
|
4874
|
-
let e = (e) => e.persisted &&
|
|
5119
|
+
let e = (e) => e.persisted && C((e) => e + 1);
|
|
4875
5120
|
return window.addEventListener("pageshow", e), () => window.removeEventListener("pageshow", e);
|
|
4876
5121
|
}, []);
|
|
4877
|
-
let
|
|
5122
|
+
let T = s(null), D = s(/* @__PURE__ */ new Set()), O = s(!1), k = s(null), A = s(null), j = E(A, `chat-island-pos:${g?.host ?? ""}:${g?.username ?? ""}`), { open: M, picker: N, status: P } = Y(w((e) => ({
|
|
4878
5123
|
open: e.open,
|
|
4879
5124
|
picker: e.picker,
|
|
4880
5125
|
status: e.status
|
|
4881
|
-
}))),
|
|
5126
|
+
}))), F = o(() => ({
|
|
4882
5127
|
send: async (e, t, n) => {
|
|
4883
|
-
let r =
|
|
5128
|
+
let r = T.current;
|
|
4884
5129
|
if (!r) throw Error("not connected");
|
|
4885
5130
|
try {
|
|
4886
|
-
|
|
5131
|
+
Y.getState().addMessage(e, await r.send(e, rr(t), void 0, n));
|
|
4887
5132
|
} catch (e) {
|
|
4888
|
-
throw
|
|
5133
|
+
throw X("chat-island-error", {
|
|
4889
5134
|
scope: "send",
|
|
4890
5135
|
message: e.message
|
|
4891
5136
|
}), e;
|
|
4892
5137
|
}
|
|
4893
5138
|
},
|
|
4894
|
-
typing: (e, t) =>
|
|
5139
|
+
typing: (e, t) => Y.getState().online[e] && T.current?.typing(e, t).catch(() => {}),
|
|
4895
5140
|
upload: async (e, t) => {
|
|
4896
|
-
let n =
|
|
5141
|
+
let n = T.current;
|
|
4897
5142
|
if (n) try {
|
|
4898
5143
|
let r = await n.upload(t);
|
|
4899
|
-
|
|
5144
|
+
Y.getState().addMessage(e, await n.send(e, t.name, r));
|
|
4900
5145
|
} catch (e) {
|
|
4901
|
-
|
|
5146
|
+
X("chat-island-error", {
|
|
4902
5147
|
scope: "upload",
|
|
4903
5148
|
message: e.message
|
|
4904
5149
|
});
|
|
4905
5150
|
}
|
|
4906
5151
|
},
|
|
4907
5152
|
createGroup: async (e, t, n) => {
|
|
4908
|
-
let r =
|
|
5153
|
+
let r = T.current, i = y.current;
|
|
4909
5154
|
if (r && i) try {
|
|
4910
|
-
let a = await r.createGroup(e, t, n), o =
|
|
5155
|
+
let a = await r.createGroup(e, t, n), o = Y.getState();
|
|
4911
5156
|
o.setGroup(a, e, [...t, i.username], n), o.openChat(a);
|
|
4912
5157
|
} catch (e) {
|
|
4913
|
-
|
|
5158
|
+
X("chat-island-error", {
|
|
4914
5159
|
scope: "group",
|
|
4915
5160
|
message: e.message
|
|
4916
5161
|
});
|
|
4917
5162
|
}
|
|
4918
5163
|
},
|
|
4919
5164
|
remove: async (e) => {
|
|
4920
|
-
let t =
|
|
5165
|
+
let t = T.current, n = y.current;
|
|
4921
5166
|
if (!t || !n) return;
|
|
4922
|
-
let r =
|
|
5167
|
+
let r = Y.getState().conversations[e];
|
|
4923
5168
|
try {
|
|
4924
|
-
r?.kind === "group" && await t.leaveGroup(e, !!r.owner).catch(() => {}), await
|
|
5169
|
+
r?.kind === "group" && await t.leaveGroup(e, !!r.owner).catch(() => {}), await Bn(n.host, n.token, e), Y.getState().removeConversation(e);
|
|
4925
5170
|
} catch (e) {
|
|
4926
|
-
|
|
5171
|
+
X("chat-island-error", {
|
|
4927
5172
|
scope: "delete",
|
|
4928
5173
|
message: e.message
|
|
4929
5174
|
});
|
|
4930
5175
|
}
|
|
4931
5176
|
},
|
|
4932
5177
|
react: async (e, t, n) => {
|
|
4933
|
-
let r =
|
|
5178
|
+
let r = T.current, i = y.current?.username;
|
|
4934
5179
|
if (!r || !i) return;
|
|
4935
|
-
let a = (
|
|
5180
|
+
let a = (Y.getState().conversations[e]?.reactions?.[t]?.[i] ?? []).includes(n) ? [] : [n];
|
|
4936
5181
|
try {
|
|
4937
|
-
await r.react(e, t, a),
|
|
5182
|
+
await r.react(e, t, a), Y.getState().applyReactions([{
|
|
4938
5183
|
peer: e,
|
|
4939
5184
|
target: t,
|
|
4940
5185
|
user: i,
|
|
4941
5186
|
emojis: a
|
|
4942
5187
|
}]);
|
|
4943
5188
|
} catch (e) {
|
|
4944
|
-
|
|
5189
|
+
X("chat-island-error", {
|
|
4945
5190
|
scope: "reaction",
|
|
4946
5191
|
message: e.message
|
|
4947
5192
|
});
|
|
4948
5193
|
}
|
|
4949
5194
|
},
|
|
4950
5195
|
loadOlder: async (e) => {
|
|
4951
|
-
let t =
|
|
4952
|
-
if (!(!t || n.complete ||
|
|
4953
|
-
|
|
5196
|
+
let t = T.current, n = Y.getState().ensure(e);
|
|
5197
|
+
if (!(!t || n.complete || D.current.has(e))) {
|
|
5198
|
+
D.current.add(e);
|
|
4954
5199
|
try {
|
|
4955
5200
|
let r = await t.history(e, n.oldest);
|
|
4956
|
-
|
|
5201
|
+
Y.getState().prependHistory(e, r.messages, r.complete, r.first), Y.getState().applyReactions(r.reactions);
|
|
4957
5202
|
} catch (e) {
|
|
4958
|
-
|
|
5203
|
+
X("chat-island-error", {
|
|
4959
5204
|
scope: "history",
|
|
4960
5205
|
message: e.message
|
|
4961
5206
|
});
|
|
4962
5207
|
} finally {
|
|
4963
|
-
|
|
5208
|
+
D.current.delete(e);
|
|
4964
5209
|
}
|
|
4965
5210
|
}
|
|
4966
5211
|
}
|
|
4967
5212
|
}), []);
|
|
4968
5213
|
i(() => {
|
|
4969
5214
|
if (!g) return;
|
|
4970
|
-
let e =
|
|
4971
|
-
e.reset(),
|
|
5215
|
+
let e = Y.getState();
|
|
5216
|
+
e.reset(), Y.setState({
|
|
4972
5217
|
me: g.username,
|
|
4973
|
-
mucHost: `conference.${
|
|
5218
|
+
mucHost: `conference.${hn}`,
|
|
4974
5219
|
maxHeads: a,
|
|
4975
5220
|
newChatButton: l
|
|
4976
5221
|
});
|
|
4977
|
-
let t = new
|
|
5222
|
+
let t = new _n(g, {
|
|
4978
5223
|
status: (n, a) => {
|
|
4979
|
-
if (e.setStatus(n, a),
|
|
5224
|
+
if (e.setStatus(n, a), X("chat-island-status", {
|
|
4980
5225
|
status: n,
|
|
4981
5226
|
error: a
|
|
4982
|
-
}), n === "online" && r && !
|
|
5227
|
+
}), n === "online" && r && !O.current && typeof Notification < "u") {
|
|
4983
5228
|
let e = Notification.permission;
|
|
4984
|
-
(e === "granted" ||
|
|
5229
|
+
(e === "granted" || x.current === "auto" && e === "default") && i();
|
|
4985
5230
|
}
|
|
4986
5231
|
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) => {
|
|
4987
|
-
e && (
|
|
5232
|
+
e && (Y.getState().seed(e.messages, g.username), Y.getState().applyReactions(e.reactions));
|
|
4988
5233
|
}).catch(() => {});
|
|
4989
5234
|
},
|
|
4990
5235
|
typing: (t, n) => e.setTyping(t, n),
|
|
@@ -4999,19 +5244,19 @@ function Jr({ dataConfig: e, position: t = "bottom-right", theme: n, serviceWork
|
|
|
4999
5244
|
}).catch(() => {});
|
|
5000
5245
|
},
|
|
5001
5246
|
message: (r) => {
|
|
5002
|
-
let i =
|
|
5003
|
-
r.room && !
|
|
5247
|
+
let i = Mn(r);
|
|
5248
|
+
r.room && !Y.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 }), X("chat-island-message", {
|
|
5004
5249
|
...r,
|
|
5005
5250
|
peer: i
|
|
5006
|
-
}),
|
|
5251
|
+
}), X("chat-island-unread", { total: Y.getState().totalUnread() }), r.mine || n(i, r);
|
|
5007
5252
|
}
|
|
5008
5253
|
}), n = (e, t) => {
|
|
5009
|
-
let n =
|
|
5254
|
+
let n = Y.getState(), r = document.visibilityState === "visible";
|
|
5010
5255
|
if (r && n.open === e) return;
|
|
5011
|
-
let i = n.conversations[e], a = i?.kind === "group" ? i.name ?? e : n.contacts[e]?.name ?? n.inactive[e] ?? e, o = t.oob ? "Attachment" :
|
|
5012
|
-
|
|
5256
|
+
let i = n.conversations[e], a = i?.kind === "group" ? i.name ?? e : n.contacts[e]?.name ?? n.inactive[e] ?? e, o = t.oob ? "Attachment" : rr(t.body), s = i?.kind === "group", c = s && t.nick ? n.contacts[t.nick]?.name ?? t.nick : a, l = s && t.nick ? `${c}: ${o}` : o;
|
|
5257
|
+
b.current && Cn();
|
|
5013
5258
|
let u = s ? i?.avatar : n.contacts[e]?.avatar;
|
|
5014
|
-
if (
|
|
5259
|
+
if (X("chat-island-notify", {
|
|
5015
5260
|
peer: e,
|
|
5016
5261
|
name: a,
|
|
5017
5262
|
body: l,
|
|
@@ -5027,86 +5272,103 @@ function Jr({ dataConfig: e, position: t = "bottom-right", theme: n, serviceWork
|
|
|
5027
5272
|
tag: `chat-${e}`
|
|
5028
5273
|
});
|
|
5029
5274
|
t.onclick = () => {
|
|
5030
|
-
window.focus(),
|
|
5275
|
+
window.focus(), Y.getState().openChat(e), t.close();
|
|
5031
5276
|
};
|
|
5032
5277
|
} catch {}
|
|
5033
5278
|
};
|
|
5034
|
-
|
|
5279
|
+
T.current = t;
|
|
5035
5280
|
let i = () => {
|
|
5036
|
-
r && !
|
|
5281
|
+
r && !O.current && (O.current = !0, Wn(g, r).then((e) => {
|
|
5037
5282
|
if (!e) {
|
|
5038
|
-
|
|
5283
|
+
O.current = !1, Y.setState({ push: Notification.permission === "denied" ? "denied" : "ask" });
|
|
5039
5284
|
return;
|
|
5040
5285
|
}
|
|
5041
5286
|
return t.enablePush(e.service, e.node).then(() => {
|
|
5042
|
-
|
|
5287
|
+
k.current = e, Y.setState({ push: "enabled" }), X("chat-island-push", { enabled: !0 });
|
|
5043
5288
|
});
|
|
5044
5289
|
}).catch((e) => {
|
|
5045
|
-
|
|
5290
|
+
O.current = !1, X("chat-island-error", {
|
|
5046
5291
|
scope: "push",
|
|
5047
5292
|
message: e.message
|
|
5048
5293
|
});
|
|
5049
5294
|
}));
|
|
5050
5295
|
}, o = !!r && "serviceWorker" in navigator && "PushManager" in window && typeof Notification < "u";
|
|
5051
|
-
|
|
5296
|
+
Y.setState({
|
|
5052
5297
|
push: o ? Notification.permission === "denied" ? "denied" : "ask" : "unavailable",
|
|
5053
5298
|
enablePush: i
|
|
5054
5299
|
});
|
|
5055
5300
|
let s = () => t.stop();
|
|
5056
5301
|
window.addEventListener("pagehide", s), t.start();
|
|
5057
5302
|
let c = () => {
|
|
5058
|
-
|
|
5303
|
+
Rn(g.host, g.token).then(e.setMobile).catch(() => {}), zn(g.host, g.token).then(e.setInactive).catch(() => {});
|
|
5059
5304
|
};
|
|
5060
5305
|
c();
|
|
5061
5306
|
let u = window.setInterval(c, 12e4);
|
|
5062
|
-
|
|
5307
|
+
Ln(g.host, g.token, g.username, (e) => Y.setState({ myName: e })).then(e.setContacts).catch((e) => X("chat-island-error", {
|
|
5063
5308
|
scope: "contacts",
|
|
5064
5309
|
message: e.message
|
|
5065
5310
|
}));
|
|
5066
|
-
let d =
|
|
5311
|
+
let d = Z("chat-island-open", ({ username: t }) => t && e.openChat(t)), f = Z("chat-island-close", () => e.closeChat()), p = Z("chat-island-new", () => e.setPicker(!0)), m = Z("chat-island-delete", ({ username: e }) => e && F.remove(e)), h = Z("chat-island-send", ({ username: e, text: t }) => e && t && F.send(e, t).catch(() => {})), _ = Z("chat-island-group-create", ({ name: e, members: t }) => e && t?.length && F.createGroup(e, t)), v = Z("chat-island-contacts", ({ contacts: t }) => t && e.setContacts(t)), y = Z("chat-island-conversations-request", () => X("chat-island-conversations", { conversations: qr() }));
|
|
5067
5312
|
return () => {
|
|
5068
|
-
window.removeEventListener("pagehide", s), window.clearInterval(u),
|
|
5313
|
+
window.removeEventListener("pagehide", s), window.clearInterval(u), y(), p(), m(), h(), _(), d(), f(), v(), k.current && t.disablePush(k.current.service, k.current.node).catch(() => {}), k.current = null, t.stop(), T.current = null, O.current = !1;
|
|
5069
5314
|
};
|
|
5070
5315
|
}, [
|
|
5071
5316
|
g,
|
|
5072
5317
|
r,
|
|
5073
|
-
|
|
5318
|
+
S
|
|
5074
5319
|
]);
|
|
5075
|
-
let
|
|
5320
|
+
let ee = Y((e) => Object.keys(e.contacts).join(","));
|
|
5076
5321
|
i(() => {
|
|
5077
|
-
|
|
5078
|
-
}, [
|
|
5079
|
-
let te =
|
|
5080
|
-
i(() =>
|
|
5081
|
-
let ne =
|
|
5082
|
-
|
|
5083
|
-
let re =
|
|
5084
|
-
|
|
5085
|
-
|
|
5086
|
-
}
|
|
5322
|
+
P === "online" && ee && T.current?.announce(ee.split(","));
|
|
5323
|
+
}, [P, ee]);
|
|
5324
|
+
let te = Y((e) => Object.values(e.conversations).map((e) => `${e.peer}:${e.kind}:${e.name ?? ""}:${(e.members ?? []).length}:${e.unread}:${e.messages[e.messages.length - 1]?.id ?? ""}`).join("|") + "#" + Object.keys(e.contacts).length + "#" + Object.values(e.online).filter(Boolean).length + "#" + Object.keys(e.inactive).length);
|
|
5325
|
+
i(() => X("chat-island-conversations", { conversations: qr() }), [te]);
|
|
5326
|
+
let ne = Y((e) => Object.values(e.conversations).reduce((e, t) => e + t.unread, 0));
|
|
5327
|
+
i(() => X("chat-island-unread", { total: ne }), [ne]);
|
|
5328
|
+
let re = s(null), ie = s(M), I = s(null), L = !N && !!M && M !== ie.current && !!re.current;
|
|
5329
|
+
L && (I.current = re.current.offsetHeight), i(() => {
|
|
5330
|
+
ie.current = M, M || (I.current = null);
|
|
5331
|
+
}, [M]);
|
|
5332
|
+
let [ae, oe, se] = Zr(M), [ce, le, R] = Zr(N, L);
|
|
5333
|
+
if (!g) return null;
|
|
5334
|
+
let ue = m && !h && j.anchor ? {
|
|
5335
|
+
right: j.anchor.right,
|
|
5336
|
+
bottom: j.anchor.bottom
|
|
5337
|
+
} : void 0, de = ue ? "" : t === "bottom-left" ? "ci-left-4 ci-bottom-5" : "ci-right-4 ci-bottom-5";
|
|
5087
5338
|
return /* @__PURE__ */ d("div", {
|
|
5088
|
-
ref:
|
|
5089
|
-
style:
|
|
5090
|
-
onClickCapture:
|
|
5091
|
-
className: `chat-island-root ${_ ? "ci-dark" : ""} ci-fixed ${
|
|
5092
|
-
"data-status":
|
|
5093
|
-
children: /* @__PURE__ */ f(
|
|
5094
|
-
|
|
5095
|
-
|
|
5096
|
-
|
|
5097
|
-
|
|
5339
|
+
ref: A,
|
|
5340
|
+
style: ue,
|
|
5341
|
+
onClickCapture: j.onClickCapture,
|
|
5342
|
+
className: `chat-island-root ${_ ? "ci-dark" : ""} ci-fixed ${de} ci-z-[9999] ci-flex ci-items-end ci-gap-3 ci-font-sans ci-select-none`,
|
|
5343
|
+
"data-status": P,
|
|
5344
|
+
children: /* @__PURE__ */ f(Jr, { children: [
|
|
5345
|
+
ae && /* @__PURE__ */ d("div", {
|
|
5346
|
+
className: oe ? "ci-anim-close" : I.current ? "ci-anim-morph" : "ci-anim-open",
|
|
5347
|
+
style: I.current ? { "--ci-from": `${I.current}px` } : void 0,
|
|
5348
|
+
onAnimationEnd: se,
|
|
5349
|
+
children: /* @__PURE__ */ d(zr, {
|
|
5350
|
+
peer: ae,
|
|
5351
|
+
actions: F,
|
|
5352
|
+
theme: v,
|
|
5353
|
+
onDragStart: h ?? (m ? j.start : void 0)
|
|
5354
|
+
})
|
|
5098
5355
|
}),
|
|
5099
|
-
|
|
5100
|
-
|
|
5101
|
-
|
|
5102
|
-
|
|
5356
|
+
ce && /* @__PURE__ */ d("div", {
|
|
5357
|
+
ref: re,
|
|
5358
|
+
className: le ? "ci-anim-close" : "ci-anim-open",
|
|
5359
|
+
onAnimationEnd: R,
|
|
5360
|
+
children: /* @__PURE__ */ d(Ur, {
|
|
5361
|
+
onOpen: (e) => Y.getState().openChat(e),
|
|
5362
|
+
onCreateGroup: F.createGroup,
|
|
5363
|
+
onDragStart: h ?? (m ? j.start : void 0)
|
|
5364
|
+
})
|
|
5103
5365
|
}),
|
|
5104
|
-
/* @__PURE__ */ d(
|
|
5105
|
-
onDragStart: h ?? (m ?
|
|
5366
|
+
/* @__PURE__ */ d(Zn, {
|
|
5367
|
+
onDragStart: h ?? (m ? j.start : void 0),
|
|
5106
5368
|
pushButton: u !== "auto"
|
|
5107
5369
|
})
|
|
5108
5370
|
] })
|
|
5109
5371
|
});
|
|
5110
5372
|
}
|
|
5111
5373
|
//#endregion
|
|
5112
|
-
export {
|
|
5374
|
+
export { Qr as ChatIsland, Fn as contactsFromOperators };
|