@nethesis/chat-island 0.1.7 → 0.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api.d.ts +1 -1
- package/dist/components/Button.d.ts +1 -0
- package/dist/components/ChatWindow.d.ts +2 -1
- package/dist/components/Composer.d.ts +2 -1
- package/dist/components/MessageList.d.ts +2 -1
- package/dist/index.css +1 -1
- package/dist/index.js +670 -534
- package/dist/store.d.ts +1 -0
- package/dist/types.d.ts +7 -0
- package/dist/xmpp.d.ts +4 -3
- package/dist-widget/index.widget.css +1 -1
- package/dist-widget/index.widget.js +3 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -43,7 +43,7 @@ function w(e) {
|
|
|
43
43
|
//#endregion
|
|
44
44
|
//#region src/drag.ts
|
|
45
45
|
var T = 8;
|
|
46
|
-
function
|
|
46
|
+
function ee(e, t) {
|
|
47
47
|
let [n, a] = c(() => {
|
|
48
48
|
try {
|
|
49
49
|
let e = localStorage.getItem(t);
|
|
@@ -103,7 +103,7 @@ function E(e, t) {
|
|
|
103
103
|
}
|
|
104
104
|
//#endregion
|
|
105
105
|
//#region node_modules/ltx/lib/escape.js
|
|
106
|
-
var
|
|
106
|
+
var E = /* @__PURE__ */ y(((e) => {
|
|
107
107
|
var t = {
|
|
108
108
|
"&": "&",
|
|
109
109
|
"<": "<",
|
|
@@ -145,8 +145,8 @@ var D = /* @__PURE__ */ y(((e) => {
|
|
|
145
145
|
return e.replace(/&(amp|#38|lt|#60|gt|#62);/g, i);
|
|
146
146
|
}
|
|
147
147
|
e.escapeXML = a, e.escapeXMLText = s, e.unescapeXML = o, e.unescapeXMLText = c;
|
|
148
|
-
})),
|
|
149
|
-
var n =
|
|
148
|
+
})), D = /* @__PURE__ */ y(((e, t) => {
|
|
149
|
+
var n = E(), r = class e {
|
|
150
150
|
constructor(e, t) {
|
|
151
151
|
this.name = e, this.parent = null, this.children = [], this.attrs = {}, this.setAttrs(t);
|
|
152
152
|
}
|
|
@@ -277,8 +277,8 @@ var D = /* @__PURE__ */ y(((e) => {
|
|
|
277
277
|
}
|
|
278
278
|
};
|
|
279
279
|
r.prototype.tree = r.prototype.root, t.exports = r;
|
|
280
|
-
})),
|
|
281
|
-
var n =
|
|
280
|
+
})), O = /* @__PURE__ */ y(((e, t) => {
|
|
281
|
+
var n = D();
|
|
282
282
|
function r(e, t) {
|
|
283
283
|
if (Array.isArray(t)) {
|
|
284
284
|
for (let n of t) r(e, n);
|
|
@@ -472,7 +472,7 @@ var D = /* @__PURE__ */ y(((e) => {
|
|
|
472
472
|
else throw TypeError("The \"emitter\" argument must be of type EventEmitter. Received type " + typeof e);
|
|
473
473
|
}
|
|
474
474
|
})), te = /* @__PURE__ */ y(((e, t) => {
|
|
475
|
-
var n = k(), r =
|
|
475
|
+
var n = k(), r = E(), i = 0, a = 1, o = 2, s = 3, c = 4, l = 5, u = 6, d = 7, f = 8, p = 9, m = 10;
|
|
476
476
|
t.exports = class extends n.EventEmitter {
|
|
477
477
|
constructor() {
|
|
478
478
|
super();
|
|
@@ -565,14 +565,14 @@ var D = /* @__PURE__ */ y(((e) => {
|
|
|
565
565
|
e && this.write(e), this.write = function() {};
|
|
566
566
|
}
|
|
567
567
|
};
|
|
568
|
-
})), A =
|
|
568
|
+
})), A = E(), j = /* @__PURE__ */ x(D(), 1), M = /* @__PURE__ */ x(O(), 1), N = k(), ne = /* @__PURE__ */ x(te(), 1), re = 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 ie(e) {
|
|
576
576
|
let t, n = new Promise((n) => {
|
|
577
577
|
t = setTimeout(n, e);
|
|
578
578
|
});
|
|
@@ -580,32 +580,32 @@ function ae(e) {
|
|
|
580
580
|
}
|
|
581
581
|
//#endregion
|
|
582
582
|
//#region node_modules/@xmpp/events/lib/timeout.js
|
|
583
|
-
function
|
|
584
|
-
let n =
|
|
583
|
+
function ae(e, t) {
|
|
584
|
+
let n = ie(t);
|
|
585
585
|
function r() {
|
|
586
586
|
clearTimeout(n.timeout);
|
|
587
587
|
}
|
|
588
|
-
let i = new
|
|
588
|
+
let i = new re();
|
|
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 oe = /* @__PURE__ */ new WeakMap();
|
|
596
|
+
function se(e) {
|
|
597
|
+
let t = oe.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
|
+
}, oe.set(e, t)), t;
|
|
603
603
|
}
|
|
604
604
|
//#endregion
|
|
605
605
|
//#region node_modules/@xmpp/events/lib/promise.js
|
|
606
|
-
function
|
|
606
|
+
function P(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 } = se(e), l = () => {
|
|
609
609
|
clearTimeout(o), s(t, d), s(n, u);
|
|
610
610
|
};
|
|
611
611
|
function u(e) {
|
|
@@ -615,7 +615,7 @@ function N(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 re();
|
|
619
619
|
o = setTimeout(() => {
|
|
620
620
|
l(), a(e);
|
|
621
621
|
}, r);
|
|
@@ -624,14 +624,14 @@ function N(e, t, n = "error", r) {
|
|
|
624
624
|
}
|
|
625
625
|
//#endregion
|
|
626
626
|
//#region node_modules/@xmpp/events/lib/Deferred.js
|
|
627
|
-
function
|
|
627
|
+
function ce() {
|
|
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 le(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,28 +651,28 @@ function ue(e, t = null, n) {
|
|
|
651
651
|
}
|
|
652
652
|
//#endregion
|
|
653
653
|
//#region node_modules/@xmpp/events/lib/listeners.js
|
|
654
|
-
function
|
|
654
|
+
function ue(e) {
|
|
655
655
|
return {
|
|
656
656
|
subscribe(t) {
|
|
657
|
-
let { on: n } =
|
|
657
|
+
let { on: n } = se(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 } = se(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 F = class extends Error {
|
|
669
669
|
constructor(...e) {
|
|
670
670
|
super(...e), this.name = "XMLError";
|
|
671
671
|
}
|
|
672
|
-
},
|
|
672
|
+
}, de = class extends N.EventEmitter {
|
|
673
673
|
constructor() {
|
|
674
674
|
super();
|
|
675
|
-
let e = new
|
|
675
|
+
let e = new ne.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) {
|
|
@@ -682,7 +682,7 @@ var fe = class extends Error {
|
|
|
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 F(`${n.name} must be closed.`));
|
|
686
686
|
return;
|
|
687
687
|
}
|
|
688
688
|
if (n === t) {
|
|
@@ -698,7 +698,7 @@ var fe = 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 F(`${e} must be a child.`));
|
|
702
702
|
return;
|
|
703
703
|
}
|
|
704
704
|
t.t(e);
|
|
@@ -710,37 +710,37 @@ var fe = class extends Error {
|
|
|
710
710
|
e && this.parser.write(e);
|
|
711
711
|
}
|
|
712
712
|
};
|
|
713
|
-
|
|
713
|
+
de.XMLError = F;
|
|
714
714
|
//#endregion
|
|
715
715
|
//#region node_modules/@xmpp/xml/index.js
|
|
716
|
-
function
|
|
717
|
-
return (0,
|
|
716
|
+
function I(...e) {
|
|
717
|
+
return (0, M.default)(...e);
|
|
718
718
|
}
|
|
719
|
-
Object.assign(
|
|
719
|
+
Object.assign(I, {
|
|
720
720
|
Element: j.default,
|
|
721
|
-
createElement:
|
|
722
|
-
Parser:
|
|
721
|
+
createElement: M.default,
|
|
722
|
+
Parser: de,
|
|
723
723
|
escapeXML: A.escapeXML,
|
|
724
724
|
unescapeXML: A.unescapeXML,
|
|
725
725
|
escapeXMLText: A.escapeXMLText,
|
|
726
726
|
unescapeXMLText: A.unescapeXMLText,
|
|
727
|
-
XMLError:
|
|
728
|
-
xml:
|
|
727
|
+
XMLError: F,
|
|
728
|
+
xml: I
|
|
729
729
|
});
|
|
730
730
|
//#endregion
|
|
731
731
|
//#region node_modules/@xmpp/jid/lib/escaping.js
|
|
732
|
-
function
|
|
732
|
+
function fe(e) {
|
|
733
733
|
return !(!e || e.replaceAll(String.raw`\20`, "").replaceAll(String.raw`\22`, "").replaceAll(String.raw`\26`, "").replaceAll(String.raw`\27`, "").replaceAll(String.raw`\2f`, "").replaceAll(String.raw`\3a`, "").replaceAll(String.raw`\3c`, "").replaceAll(String.raw`\3e`, "").replaceAll(String.raw`\40`, "").replaceAll(String.raw`\5c`, "").search(/[ "&'/:<>@\\]/g) === -1);
|
|
734
734
|
}
|
|
735
|
-
function
|
|
735
|
+
function pe(e) {
|
|
736
736
|
return e === null ? null : e.replaceAll(/^\s+|\s+$/g, "").replaceAll("\\", String.raw`\5c`).replaceAll(" ", String.raw`\20`).replaceAll("\"", String.raw`\22`).replaceAll("&", String.raw`\26`).replaceAll("'", String.raw`\27`).replaceAll("/", String.raw`\2f`).replaceAll(":", String.raw`\3a`).replaceAll("<", String.raw`\3c`).replaceAll(">", String.raw`\3e`).replaceAll("@", String.raw`\40`);
|
|
737
737
|
}
|
|
738
|
-
function
|
|
738
|
+
function me(e) {
|
|
739
739
|
return e === null ? null : e.replaceAll(String.raw`\20`, " ").replaceAll(String.raw`\22`, "\"").replaceAll(String.raw`\26`, "&").replaceAll(String.raw`\27`, "'").replaceAll(String.raw`\2f`, "/").replaceAll(String.raw`\3a`, ":").replaceAll(String.raw`\3c`, "<").replaceAll(String.raw`\3e`, ">").replaceAll(String.raw`\40`, "@").replaceAll(String.raw`\5c`, "\\");
|
|
740
740
|
}
|
|
741
741
|
//#endregion
|
|
742
742
|
//#region node_modules/@xmpp/jid/lib/JID.js
|
|
743
|
-
var
|
|
743
|
+
var L = class e {
|
|
744
744
|
constructor(e, t, n) {
|
|
745
745
|
if (typeof t != "string" || !t) throw TypeError("Invalid domain.");
|
|
746
746
|
this.setDomain(t), this.setLocal(typeof e == "string" ? e : ""), this.setResource(typeof n == "string" ? n : "");
|
|
@@ -759,11 +759,11 @@ var F = 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 ||= fe(e), t && (e = pe(e)), this._local = e && e.toLowerCase(), this;
|
|
763
763
|
}
|
|
764
764
|
getLocal(e = !1) {
|
|
765
765
|
let t = null;
|
|
766
|
-
return t = e ?
|
|
766
|
+
return t = e ? me(this._local) : this._local, t;
|
|
767
767
|
}
|
|
768
768
|
setDomain(e) {
|
|
769
769
|
return this._domain = e.toLowerCase(), this;
|
|
@@ -778,37 +778,37 @@ var F = 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(L.prototype, "local", {
|
|
782
|
+
get: L.prototype.getLocal,
|
|
783
|
+
set: L.prototype.setLocal
|
|
784
|
+
}), Object.defineProperty(L.prototype, "domain", {
|
|
785
|
+
get: L.prototype.getDomain,
|
|
786
|
+
set: L.prototype.setDomain
|
|
787
|
+
}), Object.defineProperty(L.prototype, "resource", {
|
|
788
|
+
get: L.prototype.getResource,
|
|
789
|
+
set: L.prototype.setResource
|
|
790
790
|
});
|
|
791
791
|
//#endregion
|
|
792
792
|
//#region node_modules/@xmpp/jid/lib/parse.js
|
|
793
|
-
function
|
|
793
|
+
function he(e) {
|
|
794
794
|
let t, n, r = e.indexOf("/");
|
|
795
795
|
r !== -1 && (n = e.slice(r + 1), e = e.slice(0, r));
|
|
796
796
|
let i = e.indexOf("@");
|
|
797
|
-
return i !== -1 && (t = e.slice(0, i), e = e.slice(i + 1)), new
|
|
797
|
+
return i !== -1 && (t = e.slice(0, i), e = e.slice(i + 1)), new L(t, e, n);
|
|
798
798
|
}
|
|
799
799
|
//#endregion
|
|
800
800
|
//#region node_modules/@xmpp/jid/index.js
|
|
801
|
-
function
|
|
801
|
+
function ge(e, t) {
|
|
802
802
|
return e.equals(t);
|
|
803
803
|
}
|
|
804
|
-
function
|
|
805
|
-
return !e[1] && !e[2] ?
|
|
804
|
+
function _e(...e) {
|
|
805
|
+
return !e[1] && !e[2] ? he(...e) : new L(...e);
|
|
806
806
|
}
|
|
807
|
-
var
|
|
808
|
-
|
|
807
|
+
var R = _e.bind();
|
|
808
|
+
R.jid = _e, R.JID = L, R.parse = he, R.equal = ge, R.detectEscape = fe, R.escapeLocal = pe, R.unescapeLocal = me;
|
|
809
809
|
//#endregion
|
|
810
810
|
//#region node_modules/@xmpp/error/index.js
|
|
811
|
-
var
|
|
811
|
+
var ve = class extends Error {
|
|
812
812
|
constructor(e, t, n) {
|
|
813
813
|
super(e + (t ? ` - ${t}` : "")), this.name = "XMPPError", this.condition = e, this.text = t, this.application = n;
|
|
814
814
|
}
|
|
@@ -818,14 +818,14 @@ var L = 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
|
+
}, ye = class extends ve {
|
|
822
822
|
constructor(...e) {
|
|
823
823
|
super(...e), this.name = "StreamError";
|
|
824
824
|
}
|
|
825
825
|
};
|
|
826
826
|
//#endregion
|
|
827
827
|
//#region node_modules/@xmpp/connection/lib/util.js
|
|
828
|
-
function
|
|
828
|
+
function be(e) {
|
|
829
829
|
let { port: t, hostname: n, protocol: r } = new URL(e);
|
|
830
830
|
return n === "[::1]" && (n = "::1"), {
|
|
831
831
|
port: t,
|
|
@@ -833,19 +833,19 @@ function xe(e) {
|
|
|
833
833
|
protocol: r
|
|
834
834
|
};
|
|
835
835
|
}
|
|
836
|
-
function
|
|
837
|
-
let { port: t, hostname: n } =
|
|
836
|
+
function xe(e) {
|
|
837
|
+
let { port: t, hostname: n } = be(`http://${e}`);
|
|
838
838
|
return {
|
|
839
839
|
port: t,
|
|
840
840
|
hostname: n
|
|
841
841
|
};
|
|
842
842
|
}
|
|
843
|
-
function
|
|
844
|
-
return e.includes("://") ?
|
|
843
|
+
function Se(e) {
|
|
844
|
+
return e.includes("://") ? be(e) : xe(e);
|
|
845
845
|
}
|
|
846
846
|
//#endregion
|
|
847
847
|
//#region node_modules/@xmpp/connection/index.js
|
|
848
|
-
var
|
|
848
|
+
var Ce = "urn:ietf:params:xml:ns:xmpp-streams", we = "http://etherx.jabber.org/streams", Te = class extends N.EventEmitter {
|
|
849
849
|
#e = null;
|
|
850
850
|
#t = null;
|
|
851
851
|
constructor(e = {}) {
|
|
@@ -856,7 +856,7 @@ var we = "urn:ietf:params:xml:ns:xmpp-streams", Te = "http://etherx.jabber.org/s
|
|
|
856
856
|
}
|
|
857
857
|
async _streamError(e, t) {
|
|
858
858
|
try {
|
|
859
|
-
await this.send(
|
|
859
|
+
await this.send(I("stream:error", {}, [I(e, { xmlns: Ce }, t)]));
|
|
860
860
|
} catch {}
|
|
861
861
|
return this.disconnect();
|
|
862
862
|
}
|
|
@@ -880,7 +880,7 @@ var we = "urn:ietf:params:xml:ns:xmpp-streams", Te = "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 ??= ue({
|
|
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 we = "urn:ietf:params:xml:ns:xmpp-streams", Te = "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", we);
|
|
895
895
|
t && this._onStreamError(e), this.emit("element", e), this.emit(this.isStanza(e) ? "stanza" : "nonza", e), t && this.disconnect();
|
|
896
896
|
}
|
|
897
897
|
_onStreamError(e) {
|
|
898
|
-
let t =
|
|
898
|
+
let t = ye.fromElement(e);
|
|
899
899
|
if (t.condition === "see-other-host") return this._onSeeOtherHost(t);
|
|
900
900
|
this.emit("error", t);
|
|
901
901
|
}
|
|
902
902
|
async _onSeeOtherHost(e) {
|
|
903
|
-
let { protocol: t } =
|
|
903
|
+
let { protocol: t } = Se(this.options.service), n = e.element.getChildText("see-other-host"), { port: r } = xe(n), i;
|
|
904
904
|
i = r ? `${t || "xmpp:"}//${n}` : (t ? `${t}//` : "") + n;
|
|
905
905
|
try {
|
|
906
|
-
await
|
|
906
|
+
await P(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 we = "urn:ietf:params:xml:ns:xmpp-streams", Te = "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 ??= ue({
|
|
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 we = "urn:ietf:params:xml:ns:xmpp-streams", Te = "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 = R(e), this.jid;
|
|
929
929
|
}
|
|
930
930
|
_status(e, ...t) {
|
|
931
931
|
this.status !== e && (this.status = e, this.emit("status", e, ...t), this.emit(e, ...t));
|
|
@@ -951,7 +951,7 @@ var we = "urn:ietf:params:xml:ns:xmpp-streams", Te = "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 = P(this, "online");
|
|
955
955
|
return await this.open({
|
|
956
956
|
domain: t,
|
|
957
957
|
lang: n
|
|
@@ -960,15 +960,15 @@ var we = "urn:ietf:params:xml:ns:xmpp-streams", Te = "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)), P(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 P(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)), P(this, "open", "error", this.timeout);
|
|
972
972
|
}
|
|
973
973
|
async stop() {
|
|
974
974
|
let e = await this.disconnect();
|
|
@@ -977,7 +977,7 @@ var we = "urn:ietf:params:xml:ns:xmpp-streams", Te = "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"), P(this.parser, "end", "error", e);
|
|
981
981
|
}
|
|
982
982
|
async restart() {
|
|
983
983
|
this._detachParser();
|
|
@@ -991,7 +991,7 @@ var we = "urn:ietf:params:xml:ns:xmpp-streams", Te = "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), P(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 we = "urn:ietf:params:xml:ns:xmpp-streams", Te = "http://etherx.jabber.org/s
|
|
|
1010
1010
|
return e.toString();
|
|
1011
1011
|
}
|
|
1012
1012
|
headerElement() {
|
|
1013
|
-
return new
|
|
1013
|
+
return new I.Element("", {
|
|
1014
1014
|
version: "1.0",
|
|
1015
1015
|
xmlns: this.NS
|
|
1016
1016
|
});
|
|
@@ -1045,10 +1045,10 @@ var we = "urn:ietf:params:xml:ns:xmpp-streams", Te = "http://etherx.jabber.org/s
|
|
|
1045
1045
|
}));
|
|
1046
1046
|
}
|
|
1047
1047
|
};
|
|
1048
|
-
|
|
1048
|
+
Te.prototype.NS = "", Te.prototype.Socket = null, Te.prototype.Parser = null;
|
|
1049
1049
|
//#endregion
|
|
1050
1050
|
//#region node_modules/@xmpp/client-core/lib/Client.js
|
|
1051
|
-
var Ee = class extends
|
|
1051
|
+
var Ee = class extends Te {
|
|
1052
1052
|
constructor(e) {
|
|
1053
1053
|
super(e), this.transports = [];
|
|
1054
1054
|
}
|
|
@@ -1092,7 +1092,7 @@ var Ee = class extends R {
|
|
|
1092
1092
|
Ee.prototype.NS = "jabber:client";
|
|
1093
1093
|
//#endregion
|
|
1094
1094
|
//#region node_modules/@xmpp/reconnect/index.js
|
|
1095
|
-
var De = class extends
|
|
1095
|
+
var De = class extends N.EventEmitter {
|
|
1096
1096
|
constructor(e) {
|
|
1097
1097
|
super(), this.delay = 1e3, this.entity = e, this._timeout = null;
|
|
1098
1098
|
}
|
|
@@ -1133,14 +1133,14 @@ function Oe({ entity: e }) {
|
|
|
1133
1133
|
//#region node_modules/@xmpp/websocket/lib/Socket.js
|
|
1134
1134
|
var ke = "ECONNERROR";
|
|
1135
1135
|
function Ae(e) {
|
|
1136
|
-
let t =
|
|
1136
|
+
let t = be(e);
|
|
1137
1137
|
return !!(t.protocol === "wss:" || [
|
|
1138
1138
|
"localhost",
|
|
1139
1139
|
"127.0.0.1",
|
|
1140
1140
|
"::1"
|
|
1141
1141
|
].includes(t.hostname));
|
|
1142
1142
|
}
|
|
1143
|
-
var je = class extends
|
|
1143
|
+
var je = class extends N.EventEmitter {
|
|
1144
1144
|
#e = null;
|
|
1145
1145
|
socket = null;
|
|
1146
1146
|
url = null;
|
|
@@ -1149,7 +1149,7 @@ var je = class extends M.EventEmitter {
|
|
|
1149
1149
|
this.url = e, this.secure = Ae(e), this._attachSocket(new WebSocket(e, ["xmpp"]));
|
|
1150
1150
|
}
|
|
1151
1151
|
_attachSocket(e) {
|
|
1152
|
-
this.socket = e, this.#e ??=
|
|
1152
|
+
this.socket = e, this.#e ??= ue({
|
|
1153
1153
|
open: () => this.emit("connect"),
|
|
1154
1154
|
message: ({ data: e }) => this.emit("data", e),
|
|
1155
1155
|
error: (e) => {
|
|
@@ -1179,7 +1179,7 @@ var je = class extends M.EventEmitter {
|
|
|
1179
1179
|
}
|
|
1180
1180
|
n();
|
|
1181
1181
|
}
|
|
1182
|
-
}, Me = class extends
|
|
1182
|
+
}, Me = class extends de {
|
|
1183
1183
|
onStartElement(e, t) {
|
|
1184
1184
|
let n = new j.default(e, t), { cursor: r } = this;
|
|
1185
1185
|
r && r.append(n), this.cursor = n;
|
|
@@ -1187,7 +1187,7 @@ var je = class extends M.EventEmitter {
|
|
|
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 F(`${t.name} must be closed.`));
|
|
1191
1191
|
return;
|
|
1192
1192
|
}
|
|
1193
1193
|
if (t.parent) {
|
|
@@ -1196,7 +1196,7 @@ var je = class extends M.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
|
-
}, Ne = "urn:ietf:params:xml:ns:xmpp-framing", Pe = class extends
|
|
1199
|
+
}, Ne = "urn:ietf:params:xml:ns:xmpp-framing", Pe = class extends Te {
|
|
1200
1200
|
send(e, ...t) {
|
|
1201
1201
|
return e.attrs.xmlns ??= this.NS, super.send(e, ...t);
|
|
1202
1202
|
}
|
|
@@ -1204,7 +1204,7 @@ var je = class extends M.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 I.Element("close", { xmlns: Ne });
|
|
1208
1208
|
}
|
|
1209
1209
|
headerElement() {
|
|
1210
1210
|
let e = super.headerElement();
|
|
@@ -1255,13 +1255,13 @@ var Ie = /* @__PURE__ */ y(((e, t) => {
|
|
|
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 R(i)), a && (this.from = new R(a), this.local = this.from.local, this.domain = this.from.domain, this.resource = this.from.resource);
|
|
1259
1259
|
}
|
|
1260
1260
|
}, Ve = class extends ze {
|
|
1261
1261
|
constructor(e, t) {
|
|
1262
1262
|
super(e, t);
|
|
1263
1263
|
let { jid: n } = e, { domain: r } = e.options ?? {}, i = t.attrs.from || n?.toString(), a = t.attrs.to || r;
|
|
1264
|
-
i && (this.from = new
|
|
1264
|
+
i && (this.from = new R(i)), a && (this.to = new R(a), this.local = this.to.local, this.domain = this.to.domain, this.resource = this.to.resource);
|
|
1265
1265
|
}
|
|
1266
1266
|
};
|
|
1267
1267
|
//#endregion
|
|
@@ -1310,7 +1310,7 @@ function Ke() {
|
|
|
1310
1310
|
}
|
|
1311
1311
|
//#endregion
|
|
1312
1312
|
//#region node_modules/@xmpp/middleware/lib/StanzaError.js
|
|
1313
|
-
var qe = class extends
|
|
1313
|
+
var qe = class extends ve {
|
|
1314
1314
|
constructor(e, t, n, r) {
|
|
1315
1315
|
super(e, t, n), this.type = r, this.name = "StanzaError";
|
|
1316
1316
|
}
|
|
@@ -1342,10 +1342,10 @@ var Ye = class {
|
|
|
1342
1342
|
}
|
|
1343
1343
|
async request(e, t = 3e4) {
|
|
1344
1344
|
e.attrs.id || (e.attrs.id = Ke());
|
|
1345
|
-
let n = new
|
|
1345
|
+
let n = new ce();
|
|
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 ae(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(I("iq", {
|
|
1357
1357
|
type: e,
|
|
1358
1358
|
to: n
|
|
1359
1359
|
}, t), ...r).then((e) => e.getChild(i, a));
|
|
@@ -1379,7 +1379,7 @@ function $e({ type: e }, t, n) {
|
|
|
1379
1379
|
return !(e !== "get" && e !== "set" || t.length !== 1 || !n);
|
|
1380
1380
|
}
|
|
1381
1381
|
function et({ stanza: e }) {
|
|
1382
|
-
return
|
|
1382
|
+
return I("iq", {
|
|
1383
1383
|
to: e.attrs.from,
|
|
1384
1384
|
from: e.attrs.to,
|
|
1385
1385
|
id: e.attrs.id
|
|
@@ -1394,7 +1394,7 @@ function nt(e, t, n) {
|
|
|
1394
1394
|
return r.attrs.type = "error", n && r.append(n), r.append(t), r;
|
|
1395
1395
|
}
|
|
1396
1396
|
function rt(e, t) {
|
|
1397
|
-
return
|
|
1397
|
+
return I("error", { type: e }, I(t, Ze));
|
|
1398
1398
|
}
|
|
1399
1399
|
function it(e) {
|
|
1400
1400
|
return async function(t, n) {
|
|
@@ -1408,7 +1408,7 @@ function it(e) {
|
|
|
1408
1408
|
} catch (t) {
|
|
1409
1409
|
e.emit("error", t), o = rt("cancel", "internal-server-error");
|
|
1410
1410
|
}
|
|
1411
|
-
return o ||= rt("cancel", "service-unavailable"), o instanceof
|
|
1411
|
+
return o ||= rt("cancel", "service-unavailable"), o instanceof I.Element && o.is("error") ? nt(t, o, a) : tt(t, o instanceof I.Element ? o : void 0);
|
|
1412
1412
|
};
|
|
1413
1413
|
}
|
|
1414
1414
|
function at(e, t, n, r) {
|
|
@@ -1532,7 +1532,7 @@ function ft(e, t = {}) {
|
|
|
1532
1532
|
//#endregion
|
|
1533
1533
|
//#region node_modules/@xmpp/xml/lib/parse.js
|
|
1534
1534
|
function pt(e) {
|
|
1535
|
-
let t = new
|
|
1535
|
+
let t = new de(), n = null, r = null;
|
|
1536
1536
|
if (t.on("start", (e) => {
|
|
1537
1537
|
n = e;
|
|
1538
1538
|
}), t.on("element", (e) => {
|
|
@@ -1594,7 +1594,7 @@ async function bt(e, t) {
|
|
|
1594
1594
|
e._status("connecting", n);
|
|
1595
1595
|
let i = r.prototype.socketParameters(n), a = new r.prototype.Socket();
|
|
1596
1596
|
try {
|
|
1597
|
-
a.connect(i), await
|
|
1597
|
+
a.connect(i), await P(a, "connect");
|
|
1598
1598
|
} catch {
|
|
1599
1599
|
return bt(e, t);
|
|
1600
1600
|
}
|
|
@@ -1623,7 +1623,7 @@ function Ct(e) {
|
|
|
1623
1623
|
}
|
|
1624
1624
|
//#endregion
|
|
1625
1625
|
//#region node_modules/@xmpp/sasl/lib/SASLError.js
|
|
1626
|
-
var wt = class extends
|
|
1626
|
+
var wt = class extends ve {
|
|
1627
1627
|
constructor(...e) {
|
|
1628
1628
|
super(...e), this.name = "SASLError";
|
|
1629
1629
|
}
|
|
@@ -1645,7 +1645,7 @@ async function Dt({ saslFactory: e, entity: t, mechanism: n, credentials: r }) {
|
|
|
1645
1645
|
serviceName: a,
|
|
1646
1646
|
...r
|
|
1647
1647
|
};
|
|
1648
|
-
await
|
|
1648
|
+
await le(t, i.clientFirst && I("auth", {
|
|
1649
1649
|
xmlns: Tt,
|
|
1650
1650
|
mechanism: i.name
|
|
1651
1651
|
}, St(await i.response(o))), async (e, n) => {
|
|
@@ -1653,7 +1653,7 @@ async function Dt({ saslFactory: e, entity: t, mechanism: n, credentials: r }) {
|
|
|
1653
1653
|
if (e.name === "challenge") {
|
|
1654
1654
|
await i.challenge(Ct(e.text()));
|
|
1655
1655
|
let n = await i.response(o);
|
|
1656
|
-
await t.send(
|
|
1656
|
+
await t.send(I("response", {
|
|
1657
1657
|
xmlns: Tt,
|
|
1658
1658
|
mechanism: i.name
|
|
1659
1659
|
}, typeof n == "string" ? St(n) : ""));
|
|
@@ -1695,11 +1695,11 @@ async function At({ saslFactory: e, entity: t, mechanism: n, credentials: r, use
|
|
|
1695
1695
|
serviceName: c,
|
|
1696
1696
|
...r
|
|
1697
1697
|
};
|
|
1698
|
-
await
|
|
1698
|
+
await le(t, I("authenticate", {
|
|
1699
1699
|
xmlns: kt,
|
|
1700
1700
|
mechanism: s.name
|
|
1701
1701
|
}, [
|
|
1702
|
-
s.clientFirst &&
|
|
1702
|
+
s.clientFirst && I("initial-response", {}, St(await s.response(l))),
|
|
1703
1703
|
i,
|
|
1704
1704
|
...a
|
|
1705
1705
|
]), async (e, n) => {
|
|
@@ -1707,7 +1707,7 @@ async function At({ saslFactory: e, entity: t, mechanism: n, credentials: r, use
|
|
|
1707
1707
|
if (e.name === "challenge") {
|
|
1708
1708
|
await s.challenge(Ct(e.text()));
|
|
1709
1709
|
let n = await s.response(l);
|
|
1710
|
-
await t.send(
|
|
1710
|
+
await t.send(I("response", {
|
|
1711
1711
|
xmlns: kt,
|
|
1712
1712
|
mechanism: s.name
|
|
1713
1713
|
}, typeof n == "string" ? St(n) : ""));
|
|
@@ -1775,7 +1775,7 @@ async function Mt({ element: e, features: t }) {
|
|
|
1775
1775
|
//#region node_modules/@xmpp/resource-binding/index.js
|
|
1776
1776
|
var Nt = "urn:ietf:params:xml:ns:xmpp-bind";
|
|
1777
1777
|
function Pt(e) {
|
|
1778
|
-
return
|
|
1778
|
+
return I("bind", { xmlns: Nt }, e && I("resource", {}, e));
|
|
1779
1779
|
}
|
|
1780
1780
|
async function Ft(e, t, n) {
|
|
1781
1781
|
let r = (await t.set(Pt(n))).getChildText("jid");
|
|
@@ -1832,36 +1832,36 @@ function Vt({ streamFeatures: e, sm: t, entity: n, resumed: r, failed: i, enable
|
|
|
1832
1832
|
});
|
|
1833
1833
|
}
|
|
1834
1834
|
function Ht(e, t) {
|
|
1835
|
-
return
|
|
1835
|
+
return le(e, Wt({ sm: t }), (e, t) => {
|
|
1836
1836
|
if (e.is("enabled", "urn:xmpp:sm:3")) return t(e);
|
|
1837
|
-
if (e.is("failed", "urn:xmpp:sm:3")) throw
|
|
1837
|
+
if (e.is("failed", "urn:xmpp:sm:3")) throw ve.fromElement(e);
|
|
1838
1838
|
});
|
|
1839
1839
|
}
|
|
1840
1840
|
async function Ut(e, t) {
|
|
1841
|
-
return
|
|
1841
|
+
return le(e, Gt({ sm: t }), (e, t) => {
|
|
1842
1842
|
if (e.is("resumed", "urn:xmpp:sm:3")) return t(e);
|
|
1843
|
-
if (e.is("failed", "urn:xmpp:sm:3")) throw
|
|
1843
|
+
if (e.is("failed", "urn:xmpp:sm:3")) throw ve.fromElement(e);
|
|
1844
1844
|
});
|
|
1845
1845
|
}
|
|
1846
1846
|
//#endregion
|
|
1847
1847
|
//#region node_modules/@xmpp/stream-management/index.js
|
|
1848
1848
|
var B = "urn:xmpp:sm:3";
|
|
1849
1849
|
function Wt({ sm: e }) {
|
|
1850
|
-
return
|
|
1850
|
+
return I("enable", {
|
|
1851
1851
|
xmlns: B,
|
|
1852
1852
|
max: e.preferredMaximum,
|
|
1853
1853
|
resume: "true"
|
|
1854
1854
|
});
|
|
1855
1855
|
}
|
|
1856
1856
|
function Gt({ sm: e }) {
|
|
1857
|
-
return
|
|
1857
|
+
return I("resume", {
|
|
1858
1858
|
xmlns: B,
|
|
1859
1859
|
h: e.inbound,
|
|
1860
1860
|
previd: e.id
|
|
1861
1861
|
});
|
|
1862
1862
|
}
|
|
1863
1863
|
function Kt({ streamFeatures: e, entity: t, middleware: n, bind2: r, sasl2: i }) {
|
|
1864
|
-
let a = null, o = null, s = null, c = new
|
|
1864
|
+
let a = null, o = null, s = null, c = new N.EventEmitter();
|
|
1865
1865
|
Object.assign(c, {
|
|
1866
1866
|
preferredMaximum: null,
|
|
1867
1867
|
enabled: !1,
|
|
@@ -1877,7 +1877,7 @@ 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(
|
|
1880
|
+
await t.send(I("a", {
|
|
1881
1881
|
xmlns: B,
|
|
1882
1882
|
h: c.inbound
|
|
1883
1883
|
}));
|
|
@@ -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(I("r", { xmlns: B })).catch(() => {}), h());
|
|
1944
1944
|
}
|
|
1945
1945
|
return n.filter((e, t) => {
|
|
1946
1946
|
let { stanza: n } = e;
|
|
@@ -1963,7 +1963,7 @@ function Kt({ streamFeatures: e, entity: t, middleware: n, bind2: r, sasl2: i })
|
|
|
1963
1963
|
}
|
|
1964
1964
|
function qt({ entity: e, item: t }) {
|
|
1965
1965
|
let { stanza: n, stamp: r } = t;
|
|
1966
|
-
return n.name === "message" && !n.getChild("delay", "urn:xmpp:delay") && n.append(
|
|
1966
|
+
return n.name === "message" && !n.getChild("delay", "urn:xmpp:delay") && n.append(I("delay", {
|
|
1967
1967
|
xmlns: "urn:xmpp:delay",
|
|
1968
1968
|
from: e.jid.toString(),
|
|
1969
1969
|
stamp: r
|
|
@@ -1981,7 +1981,7 @@ function Yt({ sasl2: e, entity: t }, n) {
|
|
|
1981
1981
|
element: e,
|
|
1982
1982
|
features: r
|
|
1983
1983
|
});
|
|
1984
|
-
return
|
|
1984
|
+
return I("bind", { xmlns: "urn:xmpp:bind:0" }, n && I("tag", null, n), ...t);
|
|
1985
1985
|
}, (e) => {
|
|
1986
1986
|
if (e.is("bound")) {
|
|
1987
1987
|
t._ready(!1);
|
|
@@ -2034,7 +2034,7 @@ var Zt = /* @__PURE__ */ y(((e, t) => {
|
|
|
2034
2034
|
});
|
|
2035
2035
|
})))(), 1), V = "urn:xmpp:fast:0";
|
|
2036
2036
|
function $t({ sasl2: e, entity: t }) {
|
|
2037
|
-
let n = new Qt.default(), r, i = new
|
|
2037
|
+
let n = new Qt.default(), r, i = new N.EventEmitter();
|
|
2038
2038
|
Object.assign(i, {
|
|
2039
2039
|
mechanism: null,
|
|
2040
2040
|
mechanisms: [],
|
|
@@ -2081,7 +2081,7 @@ function $t({ sasl2: e, entity: t }) {
|
|
|
2081
2081
|
...r,
|
|
2082
2082
|
password: c.token
|
|
2083
2083
|
},
|
|
2084
|
-
streamFeatures: [...o,
|
|
2084
|
+
streamFeatures: [...o, I("fast", { xmlns: V })],
|
|
2085
2085
|
entity: t,
|
|
2086
2086
|
userAgent: n,
|
|
2087
2087
|
features: s
|
|
@@ -2095,7 +2095,7 @@ function $t({ sasl2: e, entity: t }) {
|
|
|
2095
2095
|
}
|
|
2096
2096
|
});
|
|
2097
2097
|
function a(e) {
|
|
2098
|
-
e.push(
|
|
2098
|
+
e.push(I("request-token", {
|
|
2099
2099
|
xmlns: V,
|
|
2100
2100
|
mechanism: i.mechanism
|
|
2101
2101
|
}));
|
|
@@ -2221,7 +2221,7 @@ function mn(e = {}) {
|
|
|
2221
2221
|
let { resource: t, credentials: n, username: r, password: i, userAgent: a, ...o } = e, { domain: s, service: c } = o;
|
|
2222
2222
|
!s && c && (o.domain = pn(c));
|
|
2223
2223
|
let l = new Ee(o);
|
|
2224
|
-
r && o.domain && (l.jid =
|
|
2224
|
+
r && o.domain && (l.jid = R(r, o.domain));
|
|
2225
2225
|
let u = Oe({ entity: l }), d = Fe({ entity: l }), f = hn(z.default, { entity: l }), p = hn(z.default, { entity: l }), m = We({ entity: l }), h = Ge({ middleware: m }), g = Xe({
|
|
2226
2226
|
middleware: m,
|
|
2227
2227
|
entity: l
|
|
@@ -2233,7 +2233,7 @@ function mn(e = {}) {
|
|
|
2233
2233
|
plain: rn,
|
|
2234
2234
|
anonymous: sn
|
|
2235
2235
|
}).map(([e, t]) => ({ [e]: t(y) }));
|
|
2236
|
-
a ??=
|
|
2236
|
+
a ??= I("user-agent", { id: globalThis.crypto.randomUUID() });
|
|
2237
2237
|
let x = hn(z.default, { streamFeatures: h }), S = jt({
|
|
2238
2238
|
streamFeatures: h,
|
|
2239
2239
|
saslFactory: y
|
|
@@ -2256,13 +2256,13 @@ function mn(e = {}) {
|
|
|
2256
2256
|
}, dn(n ?? {
|
|
2257
2257
|
username: r,
|
|
2258
2258
|
password: i
|
|
2259
|
-
}, a)),
|
|
2259
|
+
}, a)), ee = Kt({
|
|
2260
2260
|
streamFeatures: h,
|
|
2261
2261
|
entity: l,
|
|
2262
2262
|
middleware: m,
|
|
2263
2263
|
bind2: w,
|
|
2264
2264
|
sasl2: S
|
|
2265
|
-
}),
|
|
2265
|
+
}), E = Lt({
|
|
2266
2266
|
iqCaller: g,
|
|
2267
2267
|
streamFeatures: h
|
|
2268
2268
|
}, t);
|
|
@@ -2281,8 +2281,8 @@ function mn(e = {}) {
|
|
|
2281
2281
|
saslFactory: y,
|
|
2282
2282
|
sasl2: S,
|
|
2283
2283
|
sasl: T,
|
|
2284
|
-
resourceBinding:
|
|
2285
|
-
streamManagement:
|
|
2284
|
+
resourceBinding: E,
|
|
2285
|
+
streamManagement: ee,
|
|
2286
2286
|
mechanisms: b,
|
|
2287
2287
|
bind2: w,
|
|
2288
2288
|
fast: C
|
|
@@ -2320,7 +2320,9 @@ var U = {
|
|
|
2320
2320
|
conference: "jabber:x:conference",
|
|
2321
2321
|
vcard: "vcard-temp",
|
|
2322
2322
|
ping: "urn:xmpp:ping",
|
|
2323
|
-
reactions: "urn:xmpp:reactions:0"
|
|
2323
|
+
reactions: "urn:xmpp:reactions:0",
|
|
2324
|
+
reply: "urn:xmpp:reply:0",
|
|
2325
|
+
fallback: "urn:xmpp:fallback:0"
|
|
2324
2326
|
}, gn = 3e4, _n = class {
|
|
2325
2327
|
xmpp;
|
|
2326
2328
|
me;
|
|
@@ -2349,7 +2351,7 @@ var U = {
|
|
|
2349
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());
|
|
2350
2352
|
}), this.xmpp.on("error", (e) => {
|
|
2351
2353
|
if (!this.stopped) {
|
|
2352
|
-
if (
|
|
2354
|
+
if (yn(e)) {
|
|
2353
2355
|
this.unauthorized = !0, window.clearTimeout(this.retryTimer), this.h.status("unauthorized", e.message);
|
|
2354
2356
|
return;
|
|
2355
2357
|
}
|
|
@@ -2362,10 +2364,10 @@ var U = {
|
|
|
2362
2364
|
}
|
|
2363
2365
|
this.attempt = 0, this.connected = !0;
|
|
2364
2366
|
try {
|
|
2365
|
-
await this.xmpp.send(
|
|
2367
|
+
await this.xmpp.send(I("iq", {
|
|
2366
2368
|
type: "set",
|
|
2367
2369
|
id: "carbons"
|
|
2368
|
-
},
|
|
2370
|
+
}, I("enable", { xmlns: U.carbons }))), await this.xmpp.send(I("presence"));
|
|
2369
2371
|
} catch {
|
|
2370
2372
|
return;
|
|
2371
2373
|
}
|
|
@@ -2391,10 +2393,10 @@ var U = {
|
|
|
2391
2393
|
document.visibilityState === "visible" && this.wake();
|
|
2392
2394
|
};
|
|
2393
2395
|
ping() {
|
|
2394
|
-
this.connected && this.xmpp.iqCaller.request(
|
|
2396
|
+
this.connected && this.xmpp.iqCaller.request(I("iq", {
|
|
2395
2397
|
type: "get",
|
|
2396
2398
|
to: this.domain
|
|
2397
|
-
},
|
|
2399
|
+
}, I("ping", { xmlns: U.ping })), 1e4).catch((e) => {
|
|
2398
2400
|
!this.stopped && this.connected && e.name !== "StanzaError" && this.xmpp.disconnect().catch(() => {});
|
|
2399
2401
|
});
|
|
2400
2402
|
}
|
|
@@ -2408,7 +2410,7 @@ var U = {
|
|
|
2408
2410
|
let e = this.xmpp;
|
|
2409
2411
|
(e.status === "offline" ? this.xmpp.start() : e.connect(e.options.service).then(() => e.open({ domain: e.options.domain }))).catch((e) => {
|
|
2410
2412
|
if (!this.stopped) {
|
|
2411
|
-
if (
|
|
2413
|
+
if (yn(e)) {
|
|
2412
2414
|
this.unauthorized = !0, this.h.status("unauthorized", e.message);
|
|
2413
2415
|
return;
|
|
2414
2416
|
}
|
|
@@ -2424,22 +2426,32 @@ var U = {
|
|
|
2424
2426
|
isGroup(e) {
|
|
2425
2427
|
return e.endsWith("@" + this.mucHost);
|
|
2426
2428
|
}
|
|
2427
|
-
async send(e, t, n) {
|
|
2428
|
-
let
|
|
2429
|
-
|
|
2430
|
-
|
|
2429
|
+
async send(e, t, n, r) {
|
|
2430
|
+
let i = crypto.randomUUID(), a = this.isGroup(e), o = r ? `> ${r.quote ?? ""}\n` : "", s = [
|
|
2431
|
+
I("body", {}, o + t),
|
|
2432
|
+
I("origin-id", {
|
|
2431
2433
|
xmlns: U.sid,
|
|
2432
|
-
id:
|
|
2434
|
+
id: i
|
|
2433
2435
|
}),
|
|
2434
|
-
|
|
2436
|
+
I("store", { xmlns: U.hints })
|
|
2435
2437
|
];
|
|
2436
|
-
return n &&
|
|
2438
|
+
return n && s.push(I("x", { xmlns: U.oob }, I("url", {}, n))), r && (s.push(I("reply", {
|
|
2439
|
+
xmlns: U.reply,
|
|
2440
|
+
id: r.id,
|
|
2441
|
+
to: a ? `${e}/${r.author}` : `${r.author}@${this.domain}`
|
|
2442
|
+
})), s.push(I("fallback", {
|
|
2443
|
+
xmlns: U.fallback,
|
|
2444
|
+
for: U.reply
|
|
2445
|
+
}, I("body", {
|
|
2446
|
+
start: "0",
|
|
2447
|
+
end: String([...o].length)
|
|
2448
|
+
})))), a ? (await this.xmpp.send(I("message", {
|
|
2437
2449
|
to: e,
|
|
2438
2450
|
type: "groupchat",
|
|
2439
|
-
id:
|
|
2440
|
-
}, ...
|
|
2441
|
-
id:
|
|
2442
|
-
oid:
|
|
2451
|
+
id: i
|
|
2452
|
+
}, ...s)), {
|
|
2453
|
+
id: i,
|
|
2454
|
+
oid: i,
|
|
2443
2455
|
from: e,
|
|
2444
2456
|
to: this.cfg.username,
|
|
2445
2457
|
body: t,
|
|
@@ -2447,51 +2459,53 @@ var U = {
|
|
|
2447
2459
|
mine: !0,
|
|
2448
2460
|
oob: n,
|
|
2449
2461
|
room: e,
|
|
2450
|
-
nick: this.cfg.username
|
|
2451
|
-
|
|
2462
|
+
nick: this.cfg.username,
|
|
2463
|
+
reply: r
|
|
2464
|
+
}) : (s.push(I("active", { xmlns: U.chatstates })), await this.xmpp.send(I("message", {
|
|
2452
2465
|
to: `${e}@${this.domain}`,
|
|
2453
2466
|
type: "chat",
|
|
2454
|
-
id:
|
|
2455
|
-
}, ...
|
|
2456
|
-
id:
|
|
2457
|
-
oid:
|
|
2467
|
+
id: i
|
|
2468
|
+
}, ...s)), {
|
|
2469
|
+
id: i,
|
|
2470
|
+
oid: i,
|
|
2458
2471
|
from: this.cfg.username,
|
|
2459
2472
|
to: e,
|
|
2460
2473
|
body: t,
|
|
2461
2474
|
ts: Date.now(),
|
|
2462
2475
|
mine: !0,
|
|
2463
|
-
oob: n
|
|
2476
|
+
oob: n,
|
|
2477
|
+
reply: r
|
|
2464
2478
|
});
|
|
2465
2479
|
}
|
|
2466
2480
|
async react(e, t, n) {
|
|
2467
|
-
let r = this.isGroup(e), i =
|
|
2481
|
+
let r = this.isGroup(e), i = I("reactions", {
|
|
2468
2482
|
xmlns: U.reactions,
|
|
2469
2483
|
id: t
|
|
2470
|
-
}, ...n.map((e) =>
|
|
2471
|
-
await this.xmpp.send(
|
|
2484
|
+
}, ...n.map((e) => I("reaction", {}, e)));
|
|
2485
|
+
await this.xmpp.send(I("message", {
|
|
2472
2486
|
to: r ? e : `${e}@${this.domain}`,
|
|
2473
2487
|
type: r ? "groupchat" : "chat",
|
|
2474
2488
|
id: crypto.randomUUID()
|
|
2475
|
-
}, i,
|
|
2489
|
+
}, i, I("store", { xmlns: U.hints })));
|
|
2476
2490
|
}
|
|
2477
2491
|
async announce(e) {
|
|
2478
|
-
for (let t of e) await this.xmpp.send(
|
|
2492
|
+
for (let t of e) await this.xmpp.send(I("presence", { to: `${t}@${this.domain}` }, I("x", { xmlns: U.hello }))).catch(() => {});
|
|
2479
2493
|
}
|
|
2480
2494
|
typing(e, t) {
|
|
2481
|
-
return this.isGroup(e) ? Promise.resolve() : this.xmpp.send(
|
|
2495
|
+
return this.isGroup(e) ? Promise.resolve() : this.xmpp.send(I("message", {
|
|
2482
2496
|
to: `${e}@${this.domain}`,
|
|
2483
2497
|
type: "chat"
|
|
2484
|
-
},
|
|
2498
|
+
}, I(t ? "composing" : "paused", { xmlns: U.chatstates })));
|
|
2485
2499
|
}
|
|
2486
2500
|
enablePush(e, t) {
|
|
2487
|
-
return this.xmpp.iqCaller.request(
|
|
2501
|
+
return this.xmpp.iqCaller.request(I("iq", { type: "set" }, I("enable", {
|
|
2488
2502
|
xmlns: U.push,
|
|
2489
2503
|
jid: e,
|
|
2490
2504
|
node: t
|
|
2491
2505
|
})), 15e3);
|
|
2492
2506
|
}
|
|
2493
2507
|
disablePush(e, t) {
|
|
2494
|
-
return this.xmpp.iqCaller.request(
|
|
2508
|
+
return this.xmpp.iqCaller.request(I("iq", { type: "set" }, I("disable", {
|
|
2495
2509
|
xmlns: U.push,
|
|
2496
2510
|
jid: e,
|
|
2497
2511
|
node: t
|
|
@@ -2506,20 +2520,20 @@ var U = {
|
|
|
2506
2520
|
async mam(e, t, n) {
|
|
2507
2521
|
let r = crypto.randomUUID();
|
|
2508
2522
|
this.mamQueries.set(r, []), this.mamReactions.set(r, []);
|
|
2509
|
-
let i =
|
|
2523
|
+
let i = I("set", { xmlns: U.rsm }, I("max", {}, String(n)), I("before", {}, t ?? "")), a = [I("field", {
|
|
2510
2524
|
var: "FORM_TYPE",
|
|
2511
2525
|
type: "hidden"
|
|
2512
|
-
},
|
|
2513
|
-
e && a.push(
|
|
2514
|
-
let o =
|
|
2526
|
+
}, I("value", {}, U.mam))];
|
|
2527
|
+
e && a.push(I("field", { var: "with" }, I("value", {}, this.isGroup(e) ? e : `${e}@${this.domain}`)));
|
|
2528
|
+
let o = I("x", {
|
|
2515
2529
|
xmlns: U.data,
|
|
2516
2530
|
type: "submit"
|
|
2517
2531
|
}, ...a), s, c, l;
|
|
2518
2532
|
try {
|
|
2519
|
-
s = await this.xmpp.iqCaller.request(
|
|
2533
|
+
s = await this.xmpp.iqCaller.request(I("iq", {
|
|
2520
2534
|
type: "set",
|
|
2521
2535
|
id: r
|
|
2522
|
-
},
|
|
2536
|
+
}, I("query", {
|
|
2523
2537
|
xmlns: U.mam,
|
|
2524
2538
|
queryid: r
|
|
2525
2539
|
}, o, i)), 3e4);
|
|
@@ -2536,42 +2550,42 @@ var U = {
|
|
|
2536
2550
|
}
|
|
2537
2551
|
async createGroup(e, t, n) {
|
|
2538
2552
|
let r = `g-${Math.random().toString(36).slice(2, 10)}@${this.mucHost}`, i = this.cfg.username, a = this.waitFor((e) => e.is("presence") && W(e.attrs.from) === r, 1e4);
|
|
2539
|
-
await this.xmpp.send(
|
|
2540
|
-
let o = (e, t) =>
|
|
2541
|
-
await this.xmpp.iqCaller.request(
|
|
2553
|
+
await this.xmpp.send(I("presence", { to: `${r}/${i}` }, I("x", { xmlns: U.muc }))), await a;
|
|
2554
|
+
let o = (e, t) => I("field", { var: e }, I("value", {}, t));
|
|
2555
|
+
await this.xmpp.iqCaller.request(I("iq", {
|
|
2542
2556
|
type: "set",
|
|
2543
2557
|
to: r
|
|
2544
|
-
},
|
|
2558
|
+
}, I("query", { xmlns: U.mucOwner }, I("x", {
|
|
2545
2559
|
xmlns: U.data,
|
|
2546
2560
|
type: "submit"
|
|
2547
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(() => {});
|
|
2548
2562
|
let s = t.filter((e) => e && e !== this.cfg.username);
|
|
2549
|
-
await this.xmpp.iqCaller.request(
|
|
2563
|
+
await this.xmpp.iqCaller.request(I("iq", {
|
|
2550
2564
|
type: "set",
|
|
2551
2565
|
to: r
|
|
2552
|
-
},
|
|
2566
|
+
}, I("query", { xmlns: U.mucAdmin }, ...s.map((e) => I("item", {
|
|
2553
2567
|
affiliation: "member",
|
|
2554
2568
|
jid: `${e}@${this.domain}`
|
|
2555
2569
|
})))), 15e3);
|
|
2556
|
-
for (let e of s) await this.xmpp.iqCaller.request(
|
|
2570
|
+
for (let e of s) await this.xmpp.iqCaller.request(I("iq", {
|
|
2557
2571
|
type: "set",
|
|
2558
2572
|
to: r
|
|
2559
|
-
},
|
|
2573
|
+
}, I("subscribe", {
|
|
2560
2574
|
xmlns: U.mucsub,
|
|
2561
2575
|
jid: `${e}@${this.domain}`,
|
|
2562
2576
|
nick: e
|
|
2563
|
-
},
|
|
2564
|
-
await this.xmpp.iqCaller.request(
|
|
2577
|
+
}, I("event", { node: U.mucsubMessages }), I("event", { node: U.mucsubConfig }))), 15e3).catch(() => {});
|
|
2578
|
+
await this.xmpp.iqCaller.request(I("iq", {
|
|
2565
2579
|
type: "set",
|
|
2566
2580
|
to: r
|
|
2567
|
-
},
|
|
2581
|
+
}, I("subscribe", {
|
|
2568
2582
|
xmlns: U.mucsub,
|
|
2569
2583
|
nick: i
|
|
2570
|
-
},
|
|
2584
|
+
}, I("event", { node: U.mucsubMessages }), I("event", { node: U.mucsubConfig }))), 15e3), await this.xmpp.send(I("presence", {
|
|
2571
2585
|
to: `${r}/${i}`,
|
|
2572
2586
|
type: "unavailable"
|
|
2573
2587
|
}));
|
|
2574
|
-
for (let t of s) await this.xmpp.send(
|
|
2588
|
+
for (let t of s) await this.xmpp.send(I("message", { to: `${t}@${this.domain}` }, I("x", {
|
|
2575
2589
|
xmlns: U.conference,
|
|
2576
2590
|
jid: r,
|
|
2577
2591
|
reason: e
|
|
@@ -2579,58 +2593,58 @@ var U = {
|
|
|
2579
2593
|
return r;
|
|
2580
2594
|
}
|
|
2581
2595
|
async leaveGroup(e, t) {
|
|
2582
|
-
t ? await this.xmpp.iqCaller.request(
|
|
2596
|
+
t ? await this.xmpp.iqCaller.request(I("iq", {
|
|
2583
2597
|
type: "set",
|
|
2584
2598
|
to: e
|
|
2585
|
-
},
|
|
2599
|
+
}, I("query", { xmlns: U.mucOwner }, I("destroy", {}))), 1e4) : await this.xmpp.iqCaller.request(I("iq", {
|
|
2586
2600
|
type: "set",
|
|
2587
2601
|
to: e
|
|
2588
|
-
},
|
|
2602
|
+
}, I("unsubscribe", { xmlns: U.mucsub })), 1e4);
|
|
2589
2603
|
}
|
|
2590
2604
|
async setGroupAvatar(e, t) {
|
|
2591
2605
|
let n = /^data:(image\/[a-z+]+);base64,(.+)$/i.exec(t);
|
|
2592
|
-
n && await this.xmpp.iqCaller.request(
|
|
2606
|
+
n && await this.xmpp.iqCaller.request(I("iq", {
|
|
2593
2607
|
type: "set",
|
|
2594
2608
|
to: e
|
|
2595
|
-
},
|
|
2609
|
+
}, I("vCard", { xmlns: U.vcard }, I("PHOTO", {}, I("TYPE", {}, n[1]), I("BINVAL", {}, n[2])))), 15e3);
|
|
2596
2610
|
}
|
|
2597
2611
|
async groupAvatar(e) {
|
|
2598
|
-
let t = (await this.xmpp.iqCaller.request(
|
|
2612
|
+
let t = (await this.xmpp.iqCaller.request(I("iq", {
|
|
2599
2613
|
type: "get",
|
|
2600
2614
|
to: e
|
|
2601
|
-
},
|
|
2615
|
+
}, I("vCard", { xmlns: U.vcard })), 1e4)).getChild("vCard", U.vcard)?.getChild("PHOTO"), n = t?.getChildText("BINVAL");
|
|
2602
2616
|
return n ? `data:${t?.getChildText("TYPE") || "image/jpeg"};base64,${n.replace(/\s+/g, "")}` : void 0;
|
|
2603
2617
|
}
|
|
2604
2618
|
async listGroups() {
|
|
2605
|
-
let e = ((await this.xmpp.iqCaller.request(
|
|
2619
|
+
let e = ((await this.xmpp.iqCaller.request(I("iq", {
|
|
2606
2620
|
type: "get",
|
|
2607
2621
|
to: this.mucHost
|
|
2608
|
-
},
|
|
2622
|
+
}, I("subscriptions", { xmlns: U.mucsub })), 15e3)).getChild("subscriptions", U.mucsub)?.getChildren("subscription") ?? []).map((e) => e.attrs.jid);
|
|
2609
2623
|
return Promise.all(e.map((e) => this.groupInfo(e)));
|
|
2610
2624
|
}
|
|
2611
2625
|
async subscribed(e) {
|
|
2612
|
-
return ((await this.xmpp.iqCaller.request(
|
|
2626
|
+
return ((await this.xmpp.iqCaller.request(I("iq", {
|
|
2613
2627
|
type: "get",
|
|
2614
2628
|
to: this.mucHost
|
|
2615
|
-
},
|
|
2629
|
+
}, I("subscriptions", { xmlns: U.mucsub })), 15e3)).getChild("subscriptions", U.mucsub)?.getChildren("subscription") ?? []).some((t) => W(t.attrs.jid) === e);
|
|
2616
2630
|
}
|
|
2617
2631
|
async groupInfo(e) {
|
|
2618
2632
|
let t = e.split("@")[0], n = [], r = !1;
|
|
2619
2633
|
try {
|
|
2620
|
-
t = (await this.xmpp.iqCaller.request(
|
|
2634
|
+
t = (await this.xmpp.iqCaller.request(I("iq", {
|
|
2621
2635
|
type: "get",
|
|
2622
2636
|
to: e
|
|
2623
|
-
},
|
|
2637
|
+
}, I("query", { xmlns: U.discoInfo })), 1e4)).getChild("query", U.discoInfo)?.getChild("identity")?.attrs.name || t;
|
|
2624
2638
|
} catch {}
|
|
2625
2639
|
try {
|
|
2626
|
-
n = ((await this.xmpp.iqCaller.request(
|
|
2640
|
+
n = ((await this.xmpp.iqCaller.request(I("iq", {
|
|
2627
2641
|
type: "get",
|
|
2628
2642
|
to: e
|
|
2629
|
-
},
|
|
2630
|
-
let t = await this.xmpp.iqCaller.request(
|
|
2643
|
+
}, I("query", { xmlns: U.mucAdmin }, I("item", { affiliation: "member" }))), 1e4)).getChild("query", U.mucAdmin)?.getChildren("item") ?? []).map((e) => G(e.attrs.jid));
|
|
2644
|
+
let t = await this.xmpp.iqCaller.request(I("iq", {
|
|
2631
2645
|
type: "get",
|
|
2632
2646
|
to: e
|
|
2633
|
-
},
|
|
2647
|
+
}, I("query", { xmlns: U.mucAdmin }, I("item", { affiliation: "owner" }))), 1e4);
|
|
2634
2648
|
for (let e of t.getChild("query", U.mucAdmin)?.getChildren("item") ?? []) n.push(G(e.attrs.jid)), G(e.attrs.jid) === this.cfg.username && (r = !0);
|
|
2635
2649
|
} catch {}
|
|
2636
2650
|
let i = await this.groupAvatar(e).catch(() => void 0);
|
|
@@ -2643,10 +2657,10 @@ var U = {
|
|
|
2643
2657
|
};
|
|
2644
2658
|
}
|
|
2645
2659
|
async upload(e) {
|
|
2646
|
-
let t = await this.findUploadService(), n = (await this.xmpp.iqCaller.request(
|
|
2660
|
+
let t = await this.findUploadService(), n = (await this.xmpp.iqCaller.request(I("iq", {
|
|
2647
2661
|
type: "get",
|
|
2648
2662
|
to: t
|
|
2649
|
-
},
|
|
2663
|
+
}, I("request", {
|
|
2650
2664
|
xmlns: U.upload,
|
|
2651
2665
|
filename: e.name,
|
|
2652
2666
|
size: String(e.size),
|
|
@@ -2667,19 +2681,19 @@ var U = {
|
|
|
2667
2681
|
if (this.uploadService) return this.uploadService;
|
|
2668
2682
|
let e = async (e) => {
|
|
2669
2683
|
try {
|
|
2670
|
-
return (await this.xmpp.iqCaller.request(
|
|
2684
|
+
return (await this.xmpp.iqCaller.request(I("iq", {
|
|
2671
2685
|
type: "get",
|
|
2672
2686
|
to: e
|
|
2673
|
-
},
|
|
2687
|
+
}, I("query", { xmlns: U.discoInfo })), 1e4)).getChild("query", U.discoInfo)?.getChildren("feature").some((e) => e.attrs.var === U.upload) ?? !1;
|
|
2674
2688
|
} catch {
|
|
2675
2689
|
return !1;
|
|
2676
2690
|
}
|
|
2677
2691
|
}, t = [`upload.${this.domain}`];
|
|
2678
2692
|
try {
|
|
2679
|
-
let e = await this.xmpp.iqCaller.request(
|
|
2693
|
+
let e = await this.xmpp.iqCaller.request(I("iq", {
|
|
2680
2694
|
type: "get",
|
|
2681
2695
|
to: this.domain
|
|
2682
|
-
},
|
|
2696
|
+
}, I("query", { xmlns: U.disco })), 1e4);
|
|
2683
2697
|
for (let n of e.getChild("query", U.disco)?.getChildren("item") ?? []) t.includes(n.attrs.jid) || t.push(n.attrs.jid);
|
|
2684
2698
|
} catch {}
|
|
2685
2699
|
for (let n of t) if (await e(n)) return this.uploadService = n, n;
|
|
@@ -2706,7 +2720,7 @@ var U = {
|
|
|
2706
2720
|
let r = G(n), i = this.online.get(r) ?? /* @__PURE__ */ new Set();
|
|
2707
2721
|
e.attrs.type === "unavailable" ? i.delete(t) : i.add(t), this.online.set(r, i), this.h.presence(r, i.size > 0);
|
|
2708
2722
|
let a = e.getChild("x", U.hello);
|
|
2709
|
-
a && !a.attrs.reply && e.attrs.type !== "unavailable" && this.xmpp.send(
|
|
2723
|
+
a && !a.attrs.reply && e.attrs.type !== "unavailable" && this.xmpp.send(I("presence", { to: n }, I("x", {
|
|
2710
2724
|
xmlns: U.hello,
|
|
2711
2725
|
reply: "1"
|
|
2712
2726
|
}))).catch(() => {});
|
|
@@ -2720,7 +2734,7 @@ var U = {
|
|
|
2720
2734
|
if (e && r) {
|
|
2721
2735
|
let t = this.reactionOf(e);
|
|
2722
2736
|
t && this.mamReactions.get(n.attrs.queryid)?.push(t);
|
|
2723
|
-
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", U.forward)));
|
|
2724
2738
|
i && r.push(i);
|
|
2725
2739
|
}
|
|
2726
2740
|
return;
|
|
@@ -2735,7 +2749,7 @@ var U = {
|
|
|
2735
2749
|
let i = e.getChild("event", U.pubsubEvent);
|
|
2736
2750
|
if (i?.getChild("items")?.attrs.node === U.mucsubConfig) {
|
|
2737
2751
|
let t = W(e.attrs.from);
|
|
2738
|
-
this.isGroup(t) &&
|
|
2752
|
+
this.isGroup(t) && xn(i, "presence")?.getChild("x", U.mucUser)?.getChild("destroy") && this.h.groupDestroyed(t);
|
|
2739
2753
|
return;
|
|
2740
2754
|
}
|
|
2741
2755
|
let a = e.getChild("x", U.conference);
|
|
@@ -2752,7 +2766,7 @@ var U = {
|
|
|
2752
2766
|
this.h.reaction(t);
|
|
2753
2767
|
return;
|
|
2754
2768
|
}
|
|
2755
|
-
let n = this.toMessage(e, e.getChild("stanza-id", U.sid)?.attrs.id,
|
|
2769
|
+
let n = this.toMessage(e, e.getChild("stanza-id", U.sid)?.attrs.id, bn(e));
|
|
2756
2770
|
if (n) {
|
|
2757
2771
|
this.h.message(n);
|
|
2758
2772
|
return;
|
|
@@ -2765,7 +2779,7 @@ var U = {
|
|
|
2765
2779
|
let t = e.getChild("event", U.pubsubEvent), n = e, r;
|
|
2766
2780
|
if (t && t.getChild("items")?.attrs.node === U.mucsubMessages) {
|
|
2767
2781
|
r = W(e.attrs.from);
|
|
2768
|
-
let i =
|
|
2782
|
+
let i = Sn(t);
|
|
2769
2783
|
if (!this.isGroup(r) || !i || W(i.attrs.from) !== r) return;
|
|
2770
2784
|
n = i;
|
|
2771
2785
|
} else if (e.attrs.type === "groupchat" && (r = W(e.attrs.from), !this.isGroup(r))) return;
|
|
@@ -2791,11 +2805,15 @@ var U = {
|
|
|
2791
2805
|
} : void 0;
|
|
2792
2806
|
}
|
|
2793
2807
|
toMessage(e, t, n) {
|
|
2808
|
+
let r = this.parseMessage(e, t, n);
|
|
2809
|
+
return r && vn(r, xn(e, "reply") ? e.getChild("event", U.pubsubEvent) ? Sn(e.getChild("event", U.pubsubEvent)) : e : void 0);
|
|
2810
|
+
}
|
|
2811
|
+
parseMessage(e, t, n) {
|
|
2794
2812
|
let r = e.getChild("event", U.pubsubEvent);
|
|
2795
2813
|
if (r && r.getChild("items")?.attrs.node === U.mucsubMessages) {
|
|
2796
2814
|
let i = W(e.attrs.from);
|
|
2797
2815
|
if (!this.isGroup(i)) return;
|
|
2798
|
-
let a =
|
|
2816
|
+
let a = Sn(r);
|
|
2799
2817
|
if (!a || W(a.attrs.from) !== i) return;
|
|
2800
2818
|
let o = (a.attrs.from ?? "").split("/")[1] ?? "", s = a.getChildText("body");
|
|
2801
2819
|
return s == null ? void 0 : {
|
|
@@ -2804,7 +2822,7 @@ var U = {
|
|
|
2804
2822
|
from: i,
|
|
2805
2823
|
to: this.cfg.username,
|
|
2806
2824
|
body: s,
|
|
2807
|
-
ts:
|
|
2825
|
+
ts: bn(a) !== n && a.getChild("delay", U.delay) ? bn(a) : n,
|
|
2808
2826
|
mine: o === this.cfg.username,
|
|
2809
2827
|
oob: a.getChild("x", U.oob)?.getChildText("url") ?? void 0,
|
|
2810
2828
|
room: i,
|
|
@@ -2843,20 +2861,43 @@ var U = {
|
|
|
2843
2861
|
oob: e.getChild("x", U.oob)?.getChildText("url") ?? void 0
|
|
2844
2862
|
};
|
|
2845
2863
|
}
|
|
2846
|
-
}, W = (e = "") => e.split("/")[0]
|
|
2864
|
+
}, W = (e = "") => e.split("/")[0];
|
|
2865
|
+
function vn(e, t) {
|
|
2866
|
+
let n = t?.getChild("reply", U.reply);
|
|
2867
|
+
if (!n?.attrs.id) return e;
|
|
2868
|
+
let r = n.attrs.to ?? "", i = e.room ? r.split("/")[1] ?? "" : G(W(r)), a = t.getChildren("fallback", U.fallback).find((e) => e.attrs.for === U.reply)?.getChild("body"), o = [...e.body], s = Number(a?.attrs.start ?? 0), c = Number(a?.attrs.end ?? 0);
|
|
2869
|
+
if (!a || !(c > s) || c > o.length) return {
|
|
2870
|
+
...e,
|
|
2871
|
+
reply: {
|
|
2872
|
+
id: n.attrs.id,
|
|
2873
|
+
author: i
|
|
2874
|
+
}
|
|
2875
|
+
};
|
|
2876
|
+
let l = o.slice(s, c).join("").replace(/^> ?/gm, "").trim();
|
|
2877
|
+
return {
|
|
2878
|
+
...e,
|
|
2879
|
+
body: (o.slice(0, s).join("") + o.slice(c).join("")).trim(),
|
|
2880
|
+
reply: {
|
|
2881
|
+
id: n.attrs.id,
|
|
2882
|
+
author: i,
|
|
2883
|
+
quote: l
|
|
2884
|
+
}
|
|
2885
|
+
};
|
|
2886
|
+
}
|
|
2887
|
+
var yn = (e) => e.name === "SASLError" || e.condition === "not-authorized", G = (e = "") => e.split("@")[0], bn = (e) => {
|
|
2847
2888
|
let t = e?.getChild("delay", U.delay)?.attrs.stamp;
|
|
2848
2889
|
return t ? Date.parse(t) : Date.now();
|
|
2849
2890
|
};
|
|
2850
|
-
function
|
|
2891
|
+
function xn(e, t) {
|
|
2851
2892
|
for (let n of e.children) {
|
|
2852
2893
|
if (typeof n == "string") continue;
|
|
2853
2894
|
if (n.name === t) return n;
|
|
2854
|
-
let e =
|
|
2895
|
+
let e = xn(n, t);
|
|
2855
2896
|
if (e) return e;
|
|
2856
2897
|
}
|
|
2857
2898
|
}
|
|
2858
|
-
var
|
|
2859
|
-
function
|
|
2899
|
+
var Sn = (e) => xn(e, "message"), K;
|
|
2900
|
+
function Cn() {
|
|
2860
2901
|
try {
|
|
2861
2902
|
K ??= new AudioContext(), K.state === "suspended" && K.resume();
|
|
2862
2903
|
let e = K.currentTime;
|
|
@@ -2876,7 +2917,7 @@ function Sn() {
|
|
|
2876
2917
|
}
|
|
2877
2918
|
//#endregion
|
|
2878
2919
|
//#region node_modules/zustand/esm/vanilla.mjs
|
|
2879
|
-
var
|
|
2920
|
+
var wn = (e) => {
|
|
2880
2921
|
let t, n = /* @__PURE__ */ new Set(), r = (e, r) => {
|
|
2881
2922
|
let i = typeof e == "function" ? e(t) : e;
|
|
2882
2923
|
if (!Object.is(i, t)) {
|
|
@@ -2893,15 +2934,15 @@ var Cn = (e) => {
|
|
|
2893
2934
|
}
|
|
2894
2935
|
}, o = t = e(r, i, a);
|
|
2895
2936
|
return a;
|
|
2896
|
-
},
|
|
2897
|
-
function
|
|
2898
|
-
let r =
|
|
2899
|
-
return
|
|
2937
|
+
}, Tn = (e) => e ? wn(e) : wn, { useDebugValue: En } = e, { useSyncExternalStoreWithSelector: Dn } = l, On = (e) => e;
|
|
2938
|
+
function kn(e, t = On, n) {
|
|
2939
|
+
let r = Dn(e.subscribe, e.getState, e.getServerState || e.getInitialState, t, n);
|
|
2940
|
+
return En(r), r;
|
|
2900
2941
|
}
|
|
2901
|
-
var
|
|
2902
|
-
let t = typeof e == "function" ?
|
|
2942
|
+
var An = (e) => {
|
|
2943
|
+
let t = typeof e == "function" ? Tn(e) : e, n = (e, n) => kn(t, e, n);
|
|
2903
2944
|
return Object.assign(n, t), n;
|
|
2904
|
-
},
|
|
2945
|
+
}, jn = (e) => e ? An(e) : An, Mn = (e) => e.room ?? (e.mine ? e.to : e.from), q = (e, t) => ({
|
|
2905
2946
|
peer: e,
|
|
2906
2947
|
kind: t && e.endsWith("@" + t) ? "group" : "chat",
|
|
2907
2948
|
messages: [],
|
|
@@ -2909,14 +2950,15 @@ var kn = (e) => {
|
|
|
2909
2950
|
typing: !1,
|
|
2910
2951
|
loaded: !1,
|
|
2911
2952
|
complete: !1
|
|
2912
|
-
}),
|
|
2953
|
+
}), Nn = (e, t, n, r) => {
|
|
2913
2954
|
if (e.includes(t)) return e;
|
|
2914
2955
|
let i = [t, ...e];
|
|
2915
2956
|
if (i.length <= n) return i;
|
|
2916
2957
|
let a = [...i].reverse().find((e) => e !== r);
|
|
2917
2958
|
return i.filter((e) => e !== a);
|
|
2918
|
-
}, J =
|
|
2959
|
+
}, J = jn((e, t) => ({
|
|
2919
2960
|
me: "",
|
|
2961
|
+
myName: "",
|
|
2920
2962
|
mucHost: "",
|
|
2921
2963
|
status: "connecting",
|
|
2922
2964
|
contacts: {},
|
|
@@ -2980,7 +3022,7 @@ var kn = (e) => {
|
|
|
2980
3022
|
seed: (t, n) => e((e) => {
|
|
2981
3023
|
let r = { ...e.conversations };
|
|
2982
3024
|
for (let i of t) {
|
|
2983
|
-
let t =
|
|
3025
|
+
let t = Mn(i);
|
|
2984
3026
|
if (!t || t === n) continue;
|
|
2985
3027
|
let a = r[t] ?? q(t, e.mucHost);
|
|
2986
3028
|
if (a.messages.some((e) => e.id === i.id)) continue;
|
|
@@ -3003,7 +3045,7 @@ var kn = (e) => {
|
|
|
3003
3045
|
let i = e.conversations[t] ?? q(t, e.mucHost), a = i.messages.filter((e) => e.id !== n.id && !(e.pending && n.mine && e.body === n.body && e.oob === n.oob)), o = a.length;
|
|
3004
3046
|
for (; o > 0 && a[o - 1].ts > n.ts;) o--;
|
|
3005
3047
|
a.splice(o, 0, n);
|
|
3006
|
-
let s = e.open === t, c = r?.live && !n.mine && !s ? i.unread + 1 : i.unread, l =
|
|
3048
|
+
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);
|
|
3007
3049
|
return {
|
|
3008
3050
|
conversations: {
|
|
3009
3051
|
...e.conversations,
|
|
@@ -3054,7 +3096,7 @@ var kn = (e) => {
|
|
|
3054
3096
|
...e.conversations,
|
|
3055
3097
|
[t]: q(t, e.mucHost)
|
|
3056
3098
|
},
|
|
3057
|
-
order:
|
|
3099
|
+
order: Nn(e.order, t, e.maxHeads, e.open),
|
|
3058
3100
|
open: t,
|
|
3059
3101
|
picker: !1
|
|
3060
3102
|
})),
|
|
@@ -3083,29 +3125,30 @@ var kn = (e) => {
|
|
|
3083
3125
|
}));
|
|
3084
3126
|
//#endregion
|
|
3085
3127
|
//#region src/api.ts
|
|
3086
|
-
async function
|
|
3128
|
+
async function Pn(e, t, n) {
|
|
3087
3129
|
let r = await fetch(`https://${e}/api${n}`, { headers: { Authorization: `Bearer ${t}` } });
|
|
3088
3130
|
if (!r.ok) throw Error(`${n}: HTTP ${r.status}`);
|
|
3089
3131
|
return await r.json();
|
|
3090
3132
|
}
|
|
3091
|
-
async function
|
|
3092
|
-
let
|
|
3133
|
+
async function Fn(e, t, n, r) {
|
|
3134
|
+
let i = await Pn(e, t, "/user/endpoints/all"), a = {};
|
|
3093
3135
|
try {
|
|
3094
|
-
|
|
3136
|
+
a = await Pn(e, t, "/user/all_avatars");
|
|
3095
3137
|
} catch {}
|
|
3096
|
-
|
|
3138
|
+
let o = Object.values(i).find((e) => e.username === n)?.name;
|
|
3139
|
+
return o && r?.(o), Object.values(i).filter((e) => e.username && e.username !== n).map((e) => ({
|
|
3097
3140
|
username: e.username,
|
|
3098
3141
|
name: e.name || e.username,
|
|
3099
|
-
avatar:
|
|
3142
|
+
avatar: a[e.username],
|
|
3100
3143
|
presence: e.mainPresence
|
|
3101
3144
|
})).sort((e, t) => e.name.localeCompare(t.name));
|
|
3102
3145
|
}
|
|
3103
|
-
async function
|
|
3146
|
+
async function In(e, t) {
|
|
3104
3147
|
let n = await fetch(`https://${e}/chat-gw/push/mobile`, { headers: { Authorization: `Bearer ${t}` } });
|
|
3105
3148
|
if (!n.ok) throw Error(`push/mobile: HTTP ${n.status}`);
|
|
3106
3149
|
return (await n.json()).users;
|
|
3107
3150
|
}
|
|
3108
|
-
async function
|
|
3151
|
+
async function Ln(e, t, n) {
|
|
3109
3152
|
let r = await fetch(`https://${e}/chat-gw/conversations/${encodeURIComponent(n)}`, {
|
|
3110
3153
|
method: "DELETE",
|
|
3111
3154
|
headers: { Authorization: `Bearer ${t}` }
|
|
@@ -3114,16 +3157,16 @@ async function In(e, t, n) {
|
|
|
3114
3157
|
}
|
|
3115
3158
|
//#endregion
|
|
3116
3159
|
//#region src/push.ts
|
|
3117
|
-
var
|
|
3160
|
+
var Rn = (e) => {
|
|
3118
3161
|
let t = atob((e + "=".repeat((4 - e.length % 4) % 4)).replace(/-/g, "+").replace(/_/g, "/"));
|
|
3119
3162
|
return Uint8Array.from(t, (e) => e.charCodeAt(0));
|
|
3120
|
-
},
|
|
3121
|
-
function
|
|
3122
|
-
|
|
3163
|
+
}, zn = !1;
|
|
3164
|
+
function Bn() {
|
|
3165
|
+
zn || (zn = !0, navigator.serviceWorker.addEventListener("message", (e) => {
|
|
3123
3166
|
e.data?.type === "chat-island-open" && typeof e.data.username == "string" && window.dispatchEvent(new CustomEvent("chat-island-open", { detail: { username: e.data.username } }));
|
|
3124
3167
|
}));
|
|
3125
3168
|
}
|
|
3126
|
-
async function
|
|
3169
|
+
async function Vn(e, t) {
|
|
3127
3170
|
if (!("serviceWorker" in navigator) || !("PushManager" in window)) throw Error("push not supported by this browser");
|
|
3128
3171
|
if (Notification.permission === "denied" || Notification.permission !== "granted" && await Notification.requestPermission() !== "granted") return null;
|
|
3129
3172
|
let n = `https://${e.host}/chat-gw`, r = await fetch(`${n}/push/vapid`);
|
|
@@ -3132,7 +3175,7 @@ async function Bn(e, t) {
|
|
|
3132
3175
|
await navigator.serviceWorker.ready;
|
|
3133
3176
|
let o = await a.pushManager.getSubscription() ?? await a.pushManager.subscribe({
|
|
3134
3177
|
userVisibleOnly: !0,
|
|
3135
|
-
applicationServerKey:
|
|
3178
|
+
applicationServerKey: Rn(i.publicKey)
|
|
3136
3179
|
}), s = await fetch(`${n}/push/web`, {
|
|
3137
3180
|
method: "POST",
|
|
3138
3181
|
headers: {
|
|
@@ -3143,7 +3186,7 @@ async function Bn(e, t) {
|
|
|
3143
3186
|
});
|
|
3144
3187
|
if (!s.ok) throw Error(`push/web: HTTP ${s.status} ${(await s.text()).slice(0, 120)}`);
|
|
3145
3188
|
let c = await s.json();
|
|
3146
|
-
return
|
|
3189
|
+
return Bn(), {
|
|
3147
3190
|
node: c.node,
|
|
3148
3191
|
service: c.service
|
|
3149
3192
|
};
|
|
@@ -3159,8 +3202,8 @@ function X(e, t) {
|
|
|
3159
3202
|
}
|
|
3160
3203
|
//#endregion
|
|
3161
3204
|
//#region src/components/Avatar.tsx
|
|
3162
|
-
var
|
|
3163
|
-
function
|
|
3205
|
+
var Hn = (e) => e.split(/\s+/).slice(0, 2).map((e) => e[0]?.toUpperCase() ?? "").join("");
|
|
3206
|
+
function Un({ contact: e, username: t, size: n = 40 }) {
|
|
3164
3207
|
let r = e?.name || t, i = {
|
|
3165
3208
|
width: n,
|
|
3166
3209
|
height: n,
|
|
@@ -3175,13 +3218,13 @@ function Hn({ contact: e, username: t, size: n = 40 }) {
|
|
|
3175
3218
|
}) : /* @__PURE__ */ d("div", {
|
|
3176
3219
|
style: i,
|
|
3177
3220
|
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",
|
|
3178
|
-
children:
|
|
3221
|
+
children: Hn(r)
|
|
3179
3222
|
});
|
|
3180
3223
|
}
|
|
3181
|
-
function
|
|
3224
|
+
function Wn({ online: e, presence: t, mobile: n }) {
|
|
3182
3225
|
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"}` });
|
|
3183
3226
|
}
|
|
3184
|
-
function
|
|
3227
|
+
function Gn({ name: e, size: t = 40, avatar: n }) {
|
|
3185
3228
|
let r = {
|
|
3186
3229
|
width: t,
|
|
3187
3230
|
height: t,
|
|
@@ -3196,12 +3239,12 @@ function Wn({ name: e, size: t = 40, avatar: n }) {
|
|
|
3196
3239
|
}) : /* @__PURE__ */ d("div", {
|
|
3197
3240
|
style: r,
|
|
3198
3241
|
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",
|
|
3199
|
-
children:
|
|
3242
|
+
children: Hn(e || "G")
|
|
3200
3243
|
});
|
|
3201
3244
|
}
|
|
3202
3245
|
//#endregion
|
|
3203
3246
|
//#region src/components/Button.tsx
|
|
3204
|
-
var
|
|
3247
|
+
var Kn = "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", qn = {
|
|
3205
3248
|
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",
|
|
3206
3249
|
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",
|
|
3207
3250
|
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",
|
|
@@ -3214,7 +3257,7 @@ function Z({ variant: e, className: t = "", children: n, ...r }) {
|
|
|
3214
3257
|
return /* @__PURE__ */ d("button", {
|
|
3215
3258
|
type: "button",
|
|
3216
3259
|
"aria-label": r["aria-label"] ?? r.title,
|
|
3217
|
-
className: `${
|
|
3260
|
+
className: `${Kn} ${qn[e]} ${t}`,
|
|
3218
3261
|
...r,
|
|
3219
3262
|
children: n
|
|
3220
3263
|
});
|
|
@@ -3308,6 +3351,17 @@ var Q = {
|
|
|
3308
3351
|
strokeLinejoin: "round",
|
|
3309
3352
|
children: /* @__PURE__ */ d("path", { d: "M3 6h18M8 6V4h8v2M19 6l-1 14H6L5 6M10 11v6M14 11v6" })
|
|
3310
3353
|
}),
|
|
3354
|
+
reply: /* @__PURE__ */ f("svg", {
|
|
3355
|
+
width: "16",
|
|
3356
|
+
height: "16",
|
|
3357
|
+
viewBox: "0 0 24 24",
|
|
3358
|
+
fill: "none",
|
|
3359
|
+
stroke: "currentColor",
|
|
3360
|
+
strokeWidth: "2",
|
|
3361
|
+
strokeLinecap: "round",
|
|
3362
|
+
strokeLinejoin: "round",
|
|
3363
|
+
children: [/* @__PURE__ */ d("path", { d: "M9 17l-5-5 5-5" }), /* @__PURE__ */ d("path", { d: "M20 18v-2a4 4 0 0 0-4-4H4" })]
|
|
3364
|
+
}),
|
|
3311
3365
|
minus: /* @__PURE__ */ d("svg", {
|
|
3312
3366
|
width: "16",
|
|
3313
3367
|
height: "16",
|
|
@@ -3371,7 +3425,7 @@ var Q = {
|
|
|
3371
3425
|
};
|
|
3372
3426
|
//#endregion
|
|
3373
3427
|
//#region src/components/Dock.tsx
|
|
3374
|
-
function
|
|
3428
|
+
function Jn({ onDragStart: e, pushButton: t = !0 }) {
|
|
3375
3429
|
let { order: n, open: r, conversations: i, contacts: a, online: o, mobile: s, openChat: c, removeHead: l, picker: p, setPicker: m, status: h, push: g, enablePush: _, newChatButton: v } = J(w((e) => ({
|
|
3376
3430
|
order: e.order,
|
|
3377
3431
|
open: e.open,
|
|
@@ -3401,15 +3455,15 @@ function qn({ onDragStart: e, pushButton: t = !0 }) {
|
|
|
3401
3455
|
title: t?.kind === "group" ? t.name ?? e : a[e]?.name ?? e,
|
|
3402
3456
|
onClick: () => n ? J.getState().closeChat() : c(e),
|
|
3403
3457
|
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"}`,
|
|
3404
|
-
children: [t?.kind === "group" ? /* @__PURE__ */ d(
|
|
3458
|
+
children: [t?.kind === "group" ? /* @__PURE__ */ d(Gn, {
|
|
3405
3459
|
name: t.name ?? e,
|
|
3406
3460
|
size: 48,
|
|
3407
3461
|
avatar: t.avatar
|
|
3408
|
-
}) : /* @__PURE__ */ f(u, { children: [/* @__PURE__ */ d(
|
|
3462
|
+
}) : /* @__PURE__ */ f(u, { children: [/* @__PURE__ */ d(Un, {
|
|
3409
3463
|
contact: a[e],
|
|
3410
3464
|
username: e,
|
|
3411
3465
|
size: 48
|
|
3412
|
-
}), /* @__PURE__ */ d(
|
|
3466
|
+
}), /* @__PURE__ */ d(Wn, {
|
|
3413
3467
|
online: o[e],
|
|
3414
3468
|
presence: a[e]?.presence,
|
|
3415
3469
|
mobile: s[e]
|
|
@@ -3445,7 +3499,7 @@ function qn({ onDragStart: e, pushButton: t = !0 }) {
|
|
|
3445
3499
|
}
|
|
3446
3500
|
//#endregion
|
|
3447
3501
|
//#region src/shortcodes.ts
|
|
3448
|
-
var
|
|
3502
|
+
var Yn = {
|
|
3449
3503
|
"+1": "👍",
|
|
3450
3504
|
thumbsup: "👍",
|
|
3451
3505
|
"-1": "👎",
|
|
@@ -3639,13 +3693,13 @@ var Jn = {
|
|
|
3639
3693
|
zzz: "💤",
|
|
3640
3694
|
sweat_drops: "💦",
|
|
3641
3695
|
dash: "💨"
|
|
3642
|
-
},
|
|
3696
|
+
}, Xn = /(```[\s\S]*?(?:```|$)|`[^`\n]*`?)/g, Zn = /:([a-z0-9_+-]+):/g, Qn = (e) => e.replace(Zn, (e, t) => Yn[t] ?? e);
|
|
3643
3697
|
function $(e) {
|
|
3644
|
-
return e.includes(":") ? e.split(
|
|
3698
|
+
return e.includes(":") ? e.split(Xn).map((e, t) => t % 2 ? e : Qn(e)).join("") : e;
|
|
3645
3699
|
}
|
|
3646
3700
|
//#endregion
|
|
3647
3701
|
//#region src/components/EmojiPicker.tsx
|
|
3648
|
-
var
|
|
3702
|
+
var $n = [
|
|
3649
3703
|
{
|
|
3650
3704
|
label: "Smileys",
|
|
3651
3705
|
icon: "😀",
|
|
@@ -3676,7 +3730,7 @@ var Qn = [
|
|
|
3676
3730
|
icon: "☕",
|
|
3677
3731
|
emojis: "☕ 🍵 🥤 🍕 🍔 🍟 🌭 🥪 🌮 🍝 🍣 🍩 🍪 🍫 🍎 🍌 🍓 🥐 🚗 🚕 🚌 🚆 ✈️ 🚀 🏠 🏢 🏖️ 🌍 ☀️ 🌤️ 🌧️ ⛈️ ❄️ ⚡ 🌈 🌙"
|
|
3678
3732
|
}
|
|
3679
|
-
],
|
|
3733
|
+
], er = [
|
|
3680
3734
|
"👍",
|
|
3681
3735
|
"❤️",
|
|
3682
3736
|
"😂",
|
|
@@ -3684,7 +3738,7 @@ var Qn = [
|
|
|
3684
3738
|
"😢",
|
|
3685
3739
|
"🙏"
|
|
3686
3740
|
];
|
|
3687
|
-
function
|
|
3741
|
+
function tr({ onPick: e, onClose: t, className: n = "" }) {
|
|
3688
3742
|
let [r, a] = c(0), o = s(null);
|
|
3689
3743
|
return i(() => {
|
|
3690
3744
|
let e = (e) => o.current && !o.current.contains(e.target) && t(), n = (e) => {
|
|
@@ -3700,7 +3754,7 @@ function er({ onPick: e, onClose: t, className: n = "" }) {
|
|
|
3700
3754
|
className: `ci-z-30 ci-w-[21rem] ci-max-w-full ci-rounded-2xl ci-bg-gray-50 dark:ci-bg-gray-950 ci-shadow-2xl ci-ring-1 ci-ring-gray-300 dark:ci-ring-gray-700 ci-select-none ${n}`,
|
|
3701
3755
|
children: [/* @__PURE__ */ d("div", {
|
|
3702
3756
|
className: "ci-flex ci-gap-1 ci-px-2 ci-pt-2 ci-border-b ci-border-gray-300 dark:ci-border-gray-700",
|
|
3703
|
-
children:
|
|
3757
|
+
children: $n.map((e, t) => /* @__PURE__ */ d("button", {
|
|
3704
3758
|
type: "button",
|
|
3705
3759
|
title: e.label,
|
|
3706
3760
|
"aria-label": e.label,
|
|
@@ -3714,7 +3768,7 @@ function er({ onPick: e, onClose: t, className: n = "" }) {
|
|
|
3714
3768
|
}, e.label))
|
|
3715
3769
|
}), /* @__PURE__ */ d("div", {
|
|
3716
3770
|
className: "ci-grid ci-grid-cols-7 ci-gap-1 ci-p-2 ci-h-64 ci-overflow-y-auto",
|
|
3717
|
-
children:
|
|
3771
|
+
children: $n[r].emojis.split(" ").map((t) => /* @__PURE__ */ d("button", {
|
|
3718
3772
|
type: "button",
|
|
3719
3773
|
onClick: () => e(t),
|
|
3720
3774
|
style: {
|
|
@@ -3729,27 +3783,27 @@ function er({ onPick: e, onClose: t, className: n = "" }) {
|
|
|
3729
3783
|
}
|
|
3730
3784
|
//#endregion
|
|
3731
3785
|
//#region src/components/MessageList.tsx
|
|
3732
|
-
var
|
|
3786
|
+
var nr = (e) => /\.(png|jpe?g|gif|webp|avif|svg)(\?|$)/i.test(e), rr = (e) => /\.(webm|ogg|oga|opus|mp3|m4a|wav)(\?|$)/i.test(e), ir = (e) => {
|
|
3733
3787
|
let t = e.split("/").pop() || "file";
|
|
3734
3788
|
try {
|
|
3735
3789
|
return decodeURIComponent(t);
|
|
3736
3790
|
} catch {
|
|
3737
3791
|
return t;
|
|
3738
3792
|
}
|
|
3739
|
-
},
|
|
3793
|
+
}, ar = (e) => {
|
|
3740
3794
|
try {
|
|
3741
3795
|
return new URL(e).protocol === "https:";
|
|
3742
3796
|
} catch {
|
|
3743
3797
|
return !1;
|
|
3744
3798
|
}
|
|
3745
|
-
},
|
|
3799
|
+
}, or = (e) => new Date(e).toLocaleTimeString([], {
|
|
3746
3800
|
hour: "2-digit",
|
|
3747
3801
|
minute: "2-digit"
|
|
3748
|
-
}),
|
|
3802
|
+
}), sr = (e) => new Date(e).toLocaleDateString([], {
|
|
3749
3803
|
weekday: "short",
|
|
3750
3804
|
day: "numeric",
|
|
3751
3805
|
month: "short"
|
|
3752
|
-
}),
|
|
3806
|
+
}), cr = (e, t) => new Date(e).toDateString() === new Date(t).toDateString(), lr = (e) => {
|
|
3753
3807
|
if (!e.startsWith("{\"")) return null;
|
|
3754
3808
|
try {
|
|
3755
3809
|
let t = JSON.parse(e);
|
|
@@ -3760,17 +3814,17 @@ var tr = (e) => /\.(png|jpe?g|gif|webp|avif|svg)(\?|$)/i.test(e), nr = (e) => /\
|
|
|
3760
3814
|
} catch {
|
|
3761
3815
|
return null;
|
|
3762
3816
|
}
|
|
3763
|
-
},
|
|
3764
|
-
return
|
|
3817
|
+
}, ur = n(function({ url: e }) {
|
|
3818
|
+
return ar(e) ? nr(e) ? /* @__PURE__ */ d("a", {
|
|
3765
3819
|
href: e,
|
|
3766
3820
|
target: "_blank",
|
|
3767
3821
|
rel: "noreferrer",
|
|
3768
3822
|
children: /* @__PURE__ */ d("img", {
|
|
3769
3823
|
src: e,
|
|
3770
|
-
alt:
|
|
3824
|
+
alt: ir(e),
|
|
3771
3825
|
className: "ci-max-w-full ci-max-h-60 ci-rounded-2xl ci-block"
|
|
3772
3826
|
})
|
|
3773
|
-
}) :
|
|
3827
|
+
}) : rr(e) ? /* @__PURE__ */ d("audio", {
|
|
3774
3828
|
controls: !0,
|
|
3775
3829
|
src: e,
|
|
3776
3830
|
className: "ci-max-w-full"
|
|
@@ -3787,15 +3841,15 @@ var tr = (e) => /\.(png|jpe?g|gif|webp|avif|svg)(\?|$)/i.test(e), nr = (e) => /\
|
|
|
3787
3841
|
stroke: "currentColor",
|
|
3788
3842
|
strokeWidth: "2",
|
|
3789
3843
|
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" })
|
|
3790
|
-
}),
|
|
3844
|
+
}), ir(e)]
|
|
3791
3845
|
}) : /* @__PURE__ */ d("span", {
|
|
3792
3846
|
className: "ci-break-all",
|
|
3793
3847
|
children: e
|
|
3794
3848
|
});
|
|
3795
|
-
}),
|
|
3796
|
-
function
|
|
3849
|
+
}), dr = /(`[^`\n]+`)|(\*\*[^*\n]+\*\*|__[^_\n]+__)|(~~[^~\n]+~~)|(\*[^*\s][^*\n]*\*|_[^_\s][^_\n]*_)|\[([^\]\n]+)\]\((https?:\/\/[^\s)]+)\)|(https?:\/\/[^\s<]+)/g;
|
|
3850
|
+
function fr({ text: e }) {
|
|
3797
3851
|
let t = [], n = 0;
|
|
3798
|
-
for (let r of e.matchAll(
|
|
3852
|
+
for (let r of e.matchAll(dr)) {
|
|
3799
3853
|
let i = r[0], a = r.index ?? 0;
|
|
3800
3854
|
a > n && t.push($(e.slice(n, a))), r[1] ? t.push(/* @__PURE__ */ d("code", {
|
|
3801
3855
|
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]",
|
|
@@ -3816,17 +3870,17 @@ function dr({ text: e }) {
|
|
|
3816
3870
|
}
|
|
3817
3871
|
return n < e.length && t.push($(e.slice(n))), /* @__PURE__ */ d(u, { children: t });
|
|
3818
3872
|
}
|
|
3819
|
-
var
|
|
3873
|
+
var pr = n(function({ text: e }) {
|
|
3820
3874
|
let t = e.split(/```[^\n]*\n?([\s\S]*?)```/g);
|
|
3821
3875
|
return /* @__PURE__ */ d("span", {
|
|
3822
3876
|
className: "ci-whitespace-pre-wrap ci-break-words",
|
|
3823
3877
|
children: t.map((e, t) => t % 2 ? /* @__PURE__ */ d("pre", {
|
|
3824
3878
|
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",
|
|
3825
3879
|
children: e.replace(/\n$/, "")
|
|
3826
|
-
}, t) : /* @__PURE__ */ d(
|
|
3880
|
+
}, t) : /* @__PURE__ */ d(fr, { text: e.replace(/^(\s*)[-*] (?=\S)/gm, "$1• ") }, t))
|
|
3827
3881
|
});
|
|
3828
3882
|
});
|
|
3829
|
-
function
|
|
3883
|
+
function mr({ text: e, count: t }) {
|
|
3830
3884
|
return /* @__PURE__ */ f("span", {
|
|
3831
3885
|
className: "ci-italic ci-opacity-80",
|
|
3832
3886
|
children: [
|
|
@@ -3839,7 +3893,7 @@ function pr({ text: e, count: t }) {
|
|
|
3839
3893
|
]
|
|
3840
3894
|
});
|
|
3841
3895
|
}
|
|
3842
|
-
function
|
|
3896
|
+
function hr({ forMsg: e, me: t, onReact: n, nameOf: r, mine: i }) {
|
|
3843
3897
|
if (!e) return null;
|
|
3844
3898
|
let a = /* @__PURE__ */ new Map();
|
|
3845
3899
|
for (let [t, n] of Object.entries(e)) for (let e of n) a.set(e, [...a.get(e) ?? [], t]);
|
|
@@ -3864,33 +3918,57 @@ function mr({ forMsg: e, me: t, onReact: n, nameOf: r, mine: i }) {
|
|
|
3864
3918
|
})
|
|
3865
3919
|
}) : null;
|
|
3866
3920
|
}
|
|
3867
|
-
function
|
|
3868
|
-
let
|
|
3921
|
+
function gr({ reply: e, messages: t, mine: n, name: r }) {
|
|
3922
|
+
let i = t.find((t) => t.oid === e.id), a = i ? i.oob ? "Attachment" : i.body : e.quote?.replace(/^[^:]*: /, "") ?? "", o = (t) => {
|
|
3923
|
+
t.stopPropagation();
|
|
3924
|
+
let n = document.querySelector(`.chat-island-root [data-oid="${CSS.escape(e.id)}"]`);
|
|
3925
|
+
n && (n.scrollIntoView({
|
|
3926
|
+
block: "center",
|
|
3927
|
+
behavior: "smooth"
|
|
3928
|
+
}), n.animate([{ opacity: .4 }, { opacity: 1 }], { duration: 900 }));
|
|
3929
|
+
};
|
|
3930
|
+
return /* @__PURE__ */ f("div", {
|
|
3931
|
+
role: "button",
|
|
3932
|
+
tabIndex: 0,
|
|
3933
|
+
onClick: o,
|
|
3934
|
+
onKeyDown: (e) => e.key === "Enter" && o(e),
|
|
3935
|
+
className: `ci-mb-1.5 ci-px-2.5 ci-py-1 ci-rounded-xl ci-cursor-pointer ci-border-0 ci-border-l-4 ci-border-solid ci-text-xs ${n ? "ci-bg-black/20 dark:ci-bg-black/10 ci-border-gray-400 dark:ci-border-gray-600" : "ci-bg-black/5 dark:ci-bg-white/10 ci-border-iconSecondary dark:ci-border-iconSecondaryDark"}`,
|
|
3936
|
+
children: [/* @__PURE__ */ d("div", {
|
|
3937
|
+
className: "ci-font-medium",
|
|
3938
|
+
children: r(e.author)
|
|
3939
|
+
}), /* @__PURE__ */ d("div", {
|
|
3940
|
+
className: "ci-line-clamp-2 ci-break-words ci-opacity-80",
|
|
3941
|
+
children: a
|
|
3942
|
+
})]
|
|
3943
|
+
});
|
|
3944
|
+
}
|
|
3945
|
+
function _r({ messages: e, typing: t, onLoadOlder: n, hasOlder: r, group: a, reactions: o, me: l = "", onReact: u, onReply: p }) {
|
|
3946
|
+
let m = J((e) => e.contacts), h = s(null), g = s(!0), [_, v] = c(null), [y, b] = c(null), x = (e) => m[e]?.name ?? e;
|
|
3869
3947
|
i(() => {
|
|
3870
|
-
let e =
|
|
3871
|
-
e &&
|
|
3948
|
+
let e = h.current;
|
|
3949
|
+
e && g.current && (e.scrollTop = e.scrollHeight);
|
|
3872
3950
|
}, [
|
|
3873
3951
|
e.length,
|
|
3874
3952
|
t,
|
|
3875
3953
|
o
|
|
3876
3954
|
]), i(() => {
|
|
3877
|
-
if (!
|
|
3878
|
-
let e = () =>
|
|
3955
|
+
if (!_) return;
|
|
3956
|
+
let e = () => v(null), t = window.setTimeout(() => document.addEventListener("click", e, { once: !0 }), 0);
|
|
3879
3957
|
return () => {
|
|
3880
3958
|
window.clearTimeout(t), document.removeEventListener("click", e);
|
|
3881
3959
|
};
|
|
3882
|
-
}, [
|
|
3883
|
-
let
|
|
3884
|
-
let e =
|
|
3885
|
-
e && (
|
|
3886
|
-
},
|
|
3887
|
-
|
|
3960
|
+
}, [_]);
|
|
3961
|
+
let S = () => {
|
|
3962
|
+
let e = h.current;
|
|
3963
|
+
e && (g.current = e.scrollHeight - e.scrollTop - e.clientHeight < 40, e.scrollTop < 30 && r && n());
|
|
3964
|
+
}, C = (e, t) => {
|
|
3965
|
+
v(null), b(null), u?.(e, t);
|
|
3888
3966
|
};
|
|
3889
3967
|
return /* @__PURE__ */ f("div", {
|
|
3890
3968
|
className: "ci-relative ci-flex-1 ci-min-h-0 ci-flex ci-flex-col",
|
|
3891
3969
|
children: [/* @__PURE__ */ f("div", {
|
|
3892
|
-
ref:
|
|
3893
|
-
onScroll:
|
|
3970
|
+
ref: h,
|
|
3971
|
+
onScroll: S,
|
|
3894
3972
|
className: "ci-flex-1 ci-overflow-y-auto ci-px-4 ci-py-2 ci-space-y-1",
|
|
3895
3973
|
children: [
|
|
3896
3974
|
r && /* @__PURE__ */ d("div", {
|
|
@@ -3898,90 +3976,110 @@ function hr({ messages: e, typing: t, onLoadOlder: n, hasOlder: r, group: a, rea
|
|
|
3898
3976
|
children: "Scroll up for older messages"
|
|
3899
3977
|
}),
|
|
3900
3978
|
e.map((t, n) => {
|
|
3901
|
-
let r = e[n - 1], i = !r || !
|
|
3979
|
+
let r = e[n - 1], i = !r || !cr(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", {
|
|
3902
3980
|
type: "button",
|
|
3903
3981
|
title: "React",
|
|
3904
3982
|
"aria-label": "React to this message",
|
|
3905
3983
|
onClick: (e) => {
|
|
3906
|
-
e.stopPropagation(), _
|
|
3984
|
+
e.stopPropagation(), v(_ === h ? null : h);
|
|
3907
3985
|
},
|
|
3908
|
-
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 ${
|
|
3986
|
+
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"}`,
|
|
3909
3987
|
children: Q.react
|
|
3988
|
+
}), S = !!p && !!h && !t.pending && /* @__PURE__ */ d("button", {
|
|
3989
|
+
type: "button",
|
|
3990
|
+
title: "Reply",
|
|
3991
|
+
"aria-label": "Reply to this message",
|
|
3992
|
+
onClick: (e) => {
|
|
3993
|
+
e.stopPropagation(), p(t);
|
|
3994
|
+
},
|
|
3995
|
+
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",
|
|
3996
|
+
children: Q.reply
|
|
3910
3997
|
});
|
|
3911
|
-
return /* @__PURE__ */ f("div", {
|
|
3912
|
-
|
|
3913
|
-
children:
|
|
3914
|
-
|
|
3915
|
-
|
|
3916
|
-
|
|
3917
|
-
|
|
3918
|
-
|
|
3919
|
-
|
|
3920
|
-
|
|
3921
|
-
|
|
3922
|
-
|
|
3923
|
-
|
|
3924
|
-
|
|
3925
|
-
|
|
3926
|
-
t.mine && v,
|
|
3927
|
-
/* @__PURE__ */ f("div", {
|
|
3928
|
-
className: `ci-relative ci-flex ci-flex-col ci-max-w-[80%] ${t.mine ? "ci-items-end" : "ci-items-start"}`,
|
|
3929
|
-
children: [
|
|
3930
|
-
g === m && m && /* @__PURE__ */ f("div", {
|
|
3931
|
-
role: "menu",
|
|
3932
|
-
onClick: (e) => e.stopPropagation(),
|
|
3933
|
-
className: `ci-absolute ci-bottom-full ci-mb-1 ci-z-20 ci-flex ci-items-center ci-gap-0.5 ci-p-1 ci-rounded-full ci-bg-gray-50 dark:ci-bg-gray-950 ci-shadow-xl ci-ring-1 ci-ring-gray-300 dark:ci-ring-gray-700 ${t.mine ? "ci-right-0" : "ci-left-0"}`,
|
|
3934
|
-
children: [$n.map((e) => /* @__PURE__ */ d("button", {
|
|
3935
|
-
type: "button",
|
|
3936
|
-
role: "menuitem",
|
|
3937
|
-
"aria-label": e,
|
|
3938
|
-
onClick: () => S(m, e),
|
|
3939
|
-
style: {
|
|
3940
|
-
fontSize: 22,
|
|
3941
|
-
lineHeight: "32px"
|
|
3942
|
-
},
|
|
3943
|
-
className: `ci-h-9 ci-w-9 ci-flex ci-items-center ci-justify-center ci-rounded-full ci-border-0 hover:ci-scale-125 ci-transition-transform ${o?.[m]?.[l]?.includes(e) ? "ci-bg-gray-200 dark:ci-bg-gray-800" : "ci-bg-transparent"}`,
|
|
3944
|
-
children: e
|
|
3945
|
-
}, e)), /* @__PURE__ */ d("button", {
|
|
3946
|
-
type: "button",
|
|
3947
|
-
role: "menuitem",
|
|
3948
|
-
title: "More emojis",
|
|
3949
|
-
"aria-label": "More emojis",
|
|
3950
|
-
onClick: () => {
|
|
3951
|
-
_(null), y(m);
|
|
3952
|
-
},
|
|
3953
|
-
className: "ci-h-8 ci-w-8 ci-flex ci-items-center ci-justify-center ci-rounded-full ci-border-0 ci-bg-gray-200 dark:ci-bg-gray-800 ci-text-gray-700 dark:ci-text-gray-200 ci-text-lg",
|
|
3954
|
-
children: "+"
|
|
3955
|
-
})]
|
|
3956
|
-
}),
|
|
3957
|
-
/* @__PURE__ */ f("div", {
|
|
3958
|
-
title: ar(t.ts),
|
|
3959
|
-
onDoubleClick: () => h && S(m, $n[0]),
|
|
3960
|
-
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" : ""}`,
|
|
3961
|
-
children: [
|
|
3962
|
-
t.oob ? /* @__PURE__ */ d(lr, { url: t.oob }) : cr(t.body) ? /* @__PURE__ */ d(pr, { ...cr(t.body) }) : /* @__PURE__ */ d(fr, { text: t.body }),
|
|
3963
|
-
t.oob && t.body && t.body !== t.oob && t.body !== rr(t.oob) && /* @__PURE__ */ d("div", {
|
|
3964
|
-
className: "ci-text-xs ci-opacity-80 ci-mt-1",
|
|
3965
|
-
children: t.body
|
|
3966
|
-
}),
|
|
3967
|
-
/* @__PURE__ */ d("span", {
|
|
3968
|
-
className: "ci-block ci-text-right ci-text-[10px] ci-leading-none ci-opacity-60 ci-mt-1",
|
|
3969
|
-
children: ar(t.ts)
|
|
3970
|
-
})
|
|
3971
|
-
]
|
|
3972
|
-
}),
|
|
3973
|
-
m && /* @__PURE__ */ d(mr, {
|
|
3974
|
-
forMsg: o?.[m],
|
|
3975
|
-
me: l,
|
|
3976
|
-
mine: t.mine,
|
|
3977
|
-
nameOf: b,
|
|
3978
|
-
onReact: (e) => h && S(m, e)
|
|
3998
|
+
return /* @__PURE__ */ f("div", {
|
|
3999
|
+
"data-oid": t.oid,
|
|
4000
|
+
children: [i && /* @__PURE__ */ d("div", {
|
|
4001
|
+
className: "ci-text-center ci-text-xs ci-text-gray-500 dark:ci-text-gray-400 ci-py-2",
|
|
4002
|
+
children: sr(t.ts)
|
|
4003
|
+
}), /* @__PURE__ */ f("div", {
|
|
4004
|
+
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"}`,
|
|
4005
|
+
children: [
|
|
4006
|
+
c && /* @__PURE__ */ d("span", {
|
|
4007
|
+
className: "ci-w-7 ci-shrink-0",
|
|
4008
|
+
title: c,
|
|
4009
|
+
children: !s && /* @__PURE__ */ d(Un, {
|
|
4010
|
+
contact: m[t.nick],
|
|
4011
|
+
username: t.nick,
|
|
4012
|
+
size: 28
|
|
3979
4013
|
})
|
|
3980
|
-
|
|
3981
|
-
|
|
3982
|
-
|
|
3983
|
-
|
|
3984
|
-
|
|
4014
|
+
}),
|
|
4015
|
+
t.mine && S,
|
|
4016
|
+
t.mine && y,
|
|
4017
|
+
/* @__PURE__ */ f("div", {
|
|
4018
|
+
className: `ci-relative ci-flex ci-flex-col ci-max-w-[80%] ${t.mine ? "ci-items-end" : "ci-items-start"}`,
|
|
4019
|
+
children: [
|
|
4020
|
+
_ === h && h && /* @__PURE__ */ f("div", {
|
|
4021
|
+
role: "menu",
|
|
4022
|
+
onClick: (e) => e.stopPropagation(),
|
|
4023
|
+
className: `ci-absolute ci-bottom-full ci-mb-1 ci-z-20 ci-flex ci-items-center ci-gap-0.5 ci-p-1 ci-rounded-full ci-bg-gray-50 dark:ci-bg-gray-950 ci-shadow-xl ci-ring-1 ci-ring-gray-300 dark:ci-ring-gray-700 ${t.mine ? "ci-right-0" : "ci-left-0"}`,
|
|
4024
|
+
children: [er.map((e) => /* @__PURE__ */ d("button", {
|
|
4025
|
+
type: "button",
|
|
4026
|
+
role: "menuitem",
|
|
4027
|
+
"aria-label": e,
|
|
4028
|
+
onClick: () => C(h, e),
|
|
4029
|
+
style: {
|
|
4030
|
+
fontSize: 22,
|
|
4031
|
+
lineHeight: "32px"
|
|
4032
|
+
},
|
|
4033
|
+
className: `ci-h-9 ci-w-9 ci-flex ci-items-center ci-justify-center ci-rounded-full ci-border-0 hover:ci-scale-125 ci-transition-transform ${o?.[h]?.[l]?.includes(e) ? "ci-bg-gray-200 dark:ci-bg-gray-800" : "ci-bg-transparent"}`,
|
|
4034
|
+
children: e
|
|
4035
|
+
}, e)), /* @__PURE__ */ d("button", {
|
|
4036
|
+
type: "button",
|
|
4037
|
+
role: "menuitem",
|
|
4038
|
+
title: "More emojis",
|
|
4039
|
+
"aria-label": "More emojis",
|
|
4040
|
+
onClick: () => {
|
|
4041
|
+
v(null), b(h);
|
|
4042
|
+
},
|
|
4043
|
+
className: "ci-h-8 ci-w-8 ci-flex ci-items-center ci-justify-center ci-rounded-full ci-border-0 ci-bg-gray-200 dark:ci-bg-gray-800 ci-text-gray-700 dark:ci-text-gray-200 ci-text-lg",
|
|
4044
|
+
children: "+"
|
|
4045
|
+
})]
|
|
4046
|
+
}),
|
|
4047
|
+
/* @__PURE__ */ f("div", {
|
|
4048
|
+
title: or(t.ts),
|
|
4049
|
+
onDoubleClick: () => g && C(h, er[0]),
|
|
4050
|
+
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" : ""}`,
|
|
4051
|
+
children: [
|
|
4052
|
+
t.reply && /* @__PURE__ */ d(gr, {
|
|
4053
|
+
reply: t.reply,
|
|
4054
|
+
messages: e,
|
|
4055
|
+
mine: t.mine,
|
|
4056
|
+
name: (e) => e === l ? "You" : x(e)
|
|
4057
|
+
}),
|
|
4058
|
+
t.oob ? /* @__PURE__ */ d(ur, { url: t.oob }) : lr(t.body) ? /* @__PURE__ */ d(mr, { ...lr(t.body) }) : /* @__PURE__ */ d(pr, { text: t.body }),
|
|
4059
|
+
t.oob && t.body && t.body !== t.oob && t.body !== ir(t.oob) && /* @__PURE__ */ d("div", {
|
|
4060
|
+
className: "ci-text-xs ci-opacity-80 ci-mt-1",
|
|
4061
|
+
children: t.body
|
|
4062
|
+
}),
|
|
4063
|
+
/* @__PURE__ */ d("span", {
|
|
4064
|
+
className: "ci-block ci-text-right ci-text-[10px] ci-leading-none ci-opacity-60 ci-mt-1",
|
|
4065
|
+
children: or(t.ts)
|
|
4066
|
+
})
|
|
4067
|
+
]
|
|
4068
|
+
}),
|
|
4069
|
+
h && /* @__PURE__ */ d(hr, {
|
|
4070
|
+
forMsg: o?.[h],
|
|
4071
|
+
me: l,
|
|
4072
|
+
mine: t.mine,
|
|
4073
|
+
nameOf: x,
|
|
4074
|
+
onReact: (e) => g && C(h, e)
|
|
4075
|
+
})
|
|
4076
|
+
]
|
|
4077
|
+
}),
|
|
4078
|
+
!t.mine && y,
|
|
4079
|
+
!t.mine && S
|
|
4080
|
+
]
|
|
4081
|
+
})]
|
|
4082
|
+
}, t.id);
|
|
3985
4083
|
}),
|
|
3986
4084
|
t && /* @__PURE__ */ d("div", {
|
|
3987
4085
|
className: "ci-flex ci-justify-start ci-mt-2",
|
|
@@ -3991,16 +4089,16 @@ function hr({ messages: e, typing: t, onLoadOlder: n, hasOlder: r, group: a, rea
|
|
|
3991
4089
|
})
|
|
3992
4090
|
})
|
|
3993
4091
|
]
|
|
3994
|
-
}),
|
|
4092
|
+
}), y && /* @__PURE__ */ d(tr, {
|
|
3995
4093
|
className: "ci-absolute ci-bottom-2 ci-left-1/2 ci--translate-x-1/2",
|
|
3996
|
-
onPick: (e) =>
|
|
3997
|
-
onClose: () =>
|
|
4094
|
+
onPick: (e) => C(y, e),
|
|
4095
|
+
onClose: () => b(null)
|
|
3998
4096
|
})]
|
|
3999
4097
|
});
|
|
4000
4098
|
}
|
|
4001
4099
|
//#endregion
|
|
4002
4100
|
//#region src/ogg.ts
|
|
4003
|
-
function
|
|
4101
|
+
function vr(e, t, n) {
|
|
4004
4102
|
let r = e[t];
|
|
4005
4103
|
if (r === void 0) return null;
|
|
4006
4104
|
let i = 1;
|
|
@@ -4014,7 +4112,7 @@ function gr(e, t, n) {
|
|
|
4014
4112
|
unknown: !n && o
|
|
4015
4113
|
};
|
|
4016
4114
|
}
|
|
4017
|
-
var
|
|
4115
|
+
var yr = /* @__PURE__ */ new Set([
|
|
4018
4116
|
408125543,
|
|
4019
4117
|
524531317,
|
|
4020
4118
|
374648427,
|
|
@@ -4022,18 +4120,18 @@ var _r = /* @__PURE__ */ new Set([
|
|
|
4022
4120
|
225,
|
|
4023
4121
|
160
|
|
4024
4122
|
]);
|
|
4025
|
-
function
|
|
4123
|
+
function br(e) {
|
|
4026
4124
|
let t = {
|
|
4027
4125
|
channels: 1,
|
|
4028
4126
|
packets: []
|
|
4029
4127
|
}, n = 0;
|
|
4030
4128
|
for (; n < e.length;) {
|
|
4031
|
-
let r =
|
|
4129
|
+
let r = vr(e, n, !0);
|
|
4032
4130
|
if (!r) break;
|
|
4033
|
-
let i =
|
|
4131
|
+
let i = vr(e, n + r.len, !1);
|
|
4034
4132
|
if (!i) break;
|
|
4035
4133
|
let a = n + r.len + i.len;
|
|
4036
|
-
if (
|
|
4134
|
+
if (yr.has(r.value)) {
|
|
4037
4135
|
n = a;
|
|
4038
4136
|
continue;
|
|
4039
4137
|
}
|
|
@@ -4042,14 +4140,14 @@ function vr(e) {
|
|
|
4042
4140
|
if (r.value === 25506) t.head = e.slice(a, o);
|
|
4043
4141
|
else if (r.value === 159) t.channels = e[a] || 1;
|
|
4044
4142
|
else if (r.value === 163 || r.value === 161) {
|
|
4045
|
-
let n =
|
|
4143
|
+
let n = vr(e, a, !1);
|
|
4046
4144
|
n && (e[a + n.len + 2] >> 1 & 3 || t.packets.push(e.slice(a + n.len + 3, o)));
|
|
4047
4145
|
}
|
|
4048
4146
|
n = o;
|
|
4049
4147
|
}
|
|
4050
4148
|
return t;
|
|
4051
4149
|
}
|
|
4052
|
-
function
|
|
4150
|
+
function xr(e) {
|
|
4053
4151
|
if (!e.length) return 0;
|
|
4054
4152
|
let t = e[0], n = t >> 3, r;
|
|
4055
4153
|
r = n < 12 ? [
|
|
@@ -4066,7 +4164,7 @@ function yr(e) {
|
|
|
4066
4164
|
let i = t & 3, a = i === 0 ? 1 : i === 3 ? (e[1] ?? 0) & 63 : 2;
|
|
4067
4165
|
return Math.round(a * r * 48);
|
|
4068
4166
|
}
|
|
4069
|
-
var
|
|
4167
|
+
var Sr = (() => {
|
|
4070
4168
|
let e = /* @__PURE__ */ new Uint32Array(256);
|
|
4071
4169
|
for (let t = 0; t < 256; t++) {
|
|
4072
4170
|
let n = t << 24;
|
|
@@ -4075,12 +4173,12 @@ var br = (() => {
|
|
|
4075
4173
|
}
|
|
4076
4174
|
return e;
|
|
4077
4175
|
})();
|
|
4078
|
-
function
|
|
4176
|
+
function Cr(e) {
|
|
4079
4177
|
let t = 0;
|
|
4080
|
-
for (let n = 0; n < e.length; n++) t = (t << 8 ^
|
|
4178
|
+
for (let n = 0; n < e.length; n++) t = (t << 8 ^ Sr[(t >>> 24 ^ e[n]) & 255]) >>> 0;
|
|
4081
4179
|
return t;
|
|
4082
4180
|
}
|
|
4083
|
-
function
|
|
4181
|
+
function wr(e, t, n, r, i) {
|
|
4084
4182
|
let a = [];
|
|
4085
4183
|
for (let t of e) {
|
|
4086
4184
|
let e = t.length;
|
|
@@ -4096,29 +4194,29 @@ function Sr(e, t, n, r, i) {
|
|
|
4096
4194
|
], 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);
|
|
4097
4195
|
let l = 27 + a.length;
|
|
4098
4196
|
for (let t of e) s.set(t, l), l += t.length;
|
|
4099
|
-
return c.setUint32(22,
|
|
4197
|
+
return c.setUint32(22, Cr(s), !0), s;
|
|
4100
4198
|
}
|
|
4101
|
-
function
|
|
4199
|
+
function Tr(e) {
|
|
4102
4200
|
let t = /* @__PURE__ */ new Uint8Array(19), n = new DataView(t.buffer);
|
|
4103
4201
|
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;
|
|
4104
4202
|
}
|
|
4105
|
-
function
|
|
4203
|
+
function Er() {
|
|
4106
4204
|
let e = new TextEncoder().encode("chat-island"), t = new Uint8Array(12 + e.length + 4);
|
|
4107
4205
|
return t.set(new TextEncoder().encode("OpusTags"), 0), new DataView(t.buffer).setUint32(8, e.length, !0), t.set(e, 12), t;
|
|
4108
4206
|
}
|
|
4109
|
-
function
|
|
4110
|
-
let { head: t, channels: n, packets: r } =
|
|
4207
|
+
function Dr(e) {
|
|
4208
|
+
let { head: t, channels: n, packets: r } = br(e);
|
|
4111
4209
|
if (!r.length) return null;
|
|
4112
|
-
let i = t && t.length >= 19 && new TextDecoder().decode(t.slice(0, 8)) === "OpusHead", a = Math.random() * 4294967295 >>> 0, o = [
|
|
4210
|
+
let i = t && t.length >= 19 && new TextDecoder().decode(t.slice(0, 8)) === "OpusHead", a = Math.random() * 4294967295 >>> 0, o = [wr([i ? t : Tr(n)], 0, a, 0, 2), wr([Er()], 0, a, 1, 0)], s = 0, c = 2;
|
|
4113
4211
|
for (let e = 0; e < r.length;) {
|
|
4114
4212
|
let t = [], n = 0;
|
|
4115
4213
|
for (; e < r.length && t.length < 50;) {
|
|
4116
4214
|
let i = Math.floor(r[e].length / 255) + 1;
|
|
4117
4215
|
if (n + i > 255) break;
|
|
4118
|
-
t.push(r[e]), n += i, s +=
|
|
4216
|
+
t.push(r[e]), n += i, s += xr(r[e]), e++;
|
|
4119
4217
|
}
|
|
4120
4218
|
if (!t.length) return null;
|
|
4121
|
-
o.push(
|
|
4219
|
+
o.push(wr(t, s, a, c++, e >= r.length ? 4 : 0));
|
|
4122
4220
|
}
|
|
4123
4221
|
let l = o.reduce((e, t) => e + t.length, 0), u = new Uint8Array(l), d = 0;
|
|
4124
4222
|
for (let e of o) u.set(e, d), d += e.length;
|
|
@@ -4126,98 +4224,100 @@ function Tr(e) {
|
|
|
4126
4224
|
}
|
|
4127
4225
|
//#endregion
|
|
4128
4226
|
//#region src/components/Composer.tsx
|
|
4129
|
-
var
|
|
4227
|
+
var Or = [
|
|
4130
4228
|
"audio/ogg;codecs=opus",
|
|
4131
4229
|
"audio/webm;codecs=opus",
|
|
4132
4230
|
"audio/mp4",
|
|
4133
4231
|
"audio/webm"
|
|
4134
4232
|
];
|
|
4135
|
-
async function
|
|
4233
|
+
async function kr(e, t) {
|
|
4136
4234
|
let n = Date.now();
|
|
4137
4235
|
if (/webm/.test(t) && /opus/.test(t)) try {
|
|
4138
|
-
let t =
|
|
4236
|
+
let t = Dr(new Uint8Array(await new Blob(e).arrayBuffer()));
|
|
4139
4237
|
if (t) return new File([t], `voice-${n}.ogg`, { type: "audio/ogg" });
|
|
4140
4238
|
} catch {}
|
|
4141
|
-
return new File(e, `voice-${n}.${
|
|
4239
|
+
return new File(e, `voice-${n}.${Ar(t)}`, { type: t.split(";")[0] });
|
|
4142
4240
|
}
|
|
4143
|
-
var
|
|
4144
|
-
function
|
|
4145
|
-
let [
|
|
4146
|
-
i(() =>
|
|
4147
|
-
|
|
4241
|
+
var Ar = (e) => /mp4/.test(e) ? "m4a" : /ogg/.test(e) ? "ogg" : "webm", jr = (e) => `${Math.floor(e / 6e4)}:${String(Math.floor(e % 6e4 / 1e3)).padStart(2, "0")}`;
|
|
4242
|
+
function Mr({ onSend: e, onTyping: t, onFile: n, disabled: r, focusKey: o }) {
|
|
4243
|
+
let [l, u] = c(""), [p, m] = c(!1), h = s(null), g = s(null), _ = s(null), v = s(), y = s(!1), [b, x] = c(null), [S, C] = c(0), w = s(!1), T = s(!1), ee = s(!1), E = s({});
|
|
4244
|
+
i(() => _.current?.focus(), []), i(() => () => {
|
|
4245
|
+
ee.current = !0, w.current = !0, window.clearTimeout(v.current);
|
|
4148
4246
|
let { r: e, stream: t } = E.current;
|
|
4149
4247
|
e && e.state !== "inactive" && e.stop(), t?.getTracks().forEach((e) => e.stop()), E.current = {};
|
|
4150
4248
|
}, []), i(() => {
|
|
4151
|
-
if (!
|
|
4152
|
-
let e = window.setInterval(() =>
|
|
4249
|
+
if (!b) return;
|
|
4250
|
+
let e = window.setInterval(() => C(Date.now() - b.since), 250);
|
|
4153
4251
|
return () => window.clearInterval(e);
|
|
4154
|
-
}, [
|
|
4252
|
+
}, [b]), i(() => {
|
|
4253
|
+
o && _.current?.focus();
|
|
4254
|
+
}, [o]);
|
|
4155
4255
|
let D = (e) => {
|
|
4156
|
-
|
|
4256
|
+
y.current !== e && (y.current = e, t(e));
|
|
4157
4257
|
}, O = (e) => {
|
|
4158
4258
|
let t = e.includes(":") ? $(e) : e;
|
|
4159
|
-
t !== e && (
|
|
4259
|
+
t !== e && (h.current = Math.max(0, (_.current?.selectionStart ?? e.length) - (e.length - t.length))), u(t), t ? (D(!0), window.clearTimeout(v.current), v.current = window.setTimeout(() => D(!1), 4e3)) : D(!1);
|
|
4160
4260
|
};
|
|
4161
4261
|
a(() => {
|
|
4162
|
-
|
|
4163
|
-
}, [
|
|
4164
|
-
let
|
|
4165
|
-
let t =
|
|
4166
|
-
O(
|
|
4262
|
+
h.current !== null && (_.current?.setSelectionRange(h.current, h.current), h.current = null);
|
|
4263
|
+
}, [l]);
|
|
4264
|
+
let k = (e) => {
|
|
4265
|
+
let t = _.current, n = t?.selectionStart ?? l.length, r = t?.selectionEnd ?? n;
|
|
4266
|
+
O(l.slice(0, n) + e + l.slice(r)), requestAnimationFrame(() => {
|
|
4167
4267
|
t?.focus(), t?.setSelectionRange(n + e.length, n + e.length);
|
|
4168
4268
|
});
|
|
4169
|
-
},
|
|
4170
|
-
let t =
|
|
4171
|
-
t && (
|
|
4172
|
-
},
|
|
4173
|
-
if (
|
|
4174
|
-
|
|
4269
|
+
}, te = () => {
|
|
4270
|
+
let t = l.trim();
|
|
4271
|
+
t && (u(""), Promise.resolve(e(t)).catch(() => u((e) => e || t)), window.clearTimeout(v.current), y.current = !1);
|
|
4272
|
+
}, A = async () => {
|
|
4273
|
+
if (T.current || b) return;
|
|
4274
|
+
T.current = !0;
|
|
4175
4275
|
let e;
|
|
4176
4276
|
try {
|
|
4177
4277
|
e = await navigator.mediaDevices.getUserMedia({ audio: !0 });
|
|
4178
4278
|
let t = e;
|
|
4179
|
-
if (
|
|
4279
|
+
if (ee.current) {
|
|
4180
4280
|
t.getTracks().forEach((e) => e.stop());
|
|
4181
4281
|
return;
|
|
4182
4282
|
}
|
|
4183
|
-
let r =
|
|
4283
|
+
let r = Or.find((e) => MediaRecorder.isTypeSupported(e)), i = new MediaRecorder(e, r ? { mimeType: r } : void 0), a = [];
|
|
4184
4284
|
i.ondataavailable = (e) => e.data.size && a.push(e.data), i.onstop = () => {
|
|
4185
|
-
t.getTracks().forEach((e) => e.stop()), E.current = {},
|
|
4186
|
-
},
|
|
4285
|
+
t.getTracks().forEach((e) => e.stop()), E.current = {}, x(null), !w.current && a.length && kr(a, i.mimeType || r || "").then(n);
|
|
4286
|
+
}, w.current = !1, i.start(), E.current = {
|
|
4187
4287
|
r: i,
|
|
4188
4288
|
stream: t
|
|
4189
|
-
},
|
|
4289
|
+
}, C(0), x({
|
|
4190
4290
|
r: i,
|
|
4191
4291
|
since: Date.now()
|
|
4192
4292
|
});
|
|
4193
4293
|
} catch {
|
|
4194
4294
|
e?.getTracks().forEach((e) => e.stop());
|
|
4195
4295
|
} finally {
|
|
4196
|
-
|
|
4296
|
+
T.current = !1;
|
|
4197
4297
|
}
|
|
4198
|
-
},
|
|
4199
|
-
|
|
4298
|
+
}, j = (e) => {
|
|
4299
|
+
w.current = e, b?.r.stop();
|
|
4200
4300
|
};
|
|
4201
|
-
return
|
|
4301
|
+
return b ? /* @__PURE__ */ f("div", {
|
|
4202
4302
|
className: "ci-flex ci-items-center ci-gap-2 ci-px-3 ci-py-3",
|
|
4203
4303
|
children: [
|
|
4204
4304
|
/* @__PURE__ */ d(Z, {
|
|
4205
4305
|
variant: "transparent",
|
|
4206
4306
|
title: "Discard",
|
|
4207
4307
|
"aria-label": "Discard",
|
|
4208
|
-
onClick: () =>
|
|
4308
|
+
onClick: () => j(!0),
|
|
4209
4309
|
className: "ci-h-10 ci-w-10",
|
|
4210
4310
|
children: Q.close
|
|
4211
4311
|
}),
|
|
4212
4312
|
/* @__PURE__ */ f("div", {
|
|
4213
4313
|
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",
|
|
4214
|
-
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 ",
|
|
4314
|
+
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 ", jr(S)] })]
|
|
4215
4315
|
}),
|
|
4216
4316
|
/* @__PURE__ */ d(Z, {
|
|
4217
4317
|
variant: "green",
|
|
4218
4318
|
title: "Send voice note",
|
|
4219
4319
|
"aria-label": "Send voice note",
|
|
4220
|
-
onClick: () =>
|
|
4320
|
+
onClick: () => j(!1),
|
|
4221
4321
|
className: "ci-h-10 ci-w-10",
|
|
4222
4322
|
children: Q.send
|
|
4223
4323
|
})
|
|
@@ -4225,13 +4325,13 @@ function Ar({ onSend: e, onTyping: t, onFile: n, disabled: r }) {
|
|
|
4225
4325
|
}) : /* @__PURE__ */ f("div", {
|
|
4226
4326
|
className: "ci-relative ci-flex ci-items-center ci-gap-2 ci-px-3 ci-py-3",
|
|
4227
4327
|
children: [
|
|
4228
|
-
|
|
4328
|
+
p && /* @__PURE__ */ d(tr, {
|
|
4229
4329
|
className: "ci-absolute ci-bottom-full ci-left-3 ci-mb-1",
|
|
4230
|
-
onPick:
|
|
4231
|
-
onClose: () =>
|
|
4330
|
+
onPick: k,
|
|
4331
|
+
onClose: () => m(!1)
|
|
4232
4332
|
}),
|
|
4233
4333
|
/* @__PURE__ */ d("input", {
|
|
4234
|
-
ref:
|
|
4334
|
+
ref: g,
|
|
4235
4335
|
type: "file",
|
|
4236
4336
|
hidden: !0,
|
|
4237
4337
|
onChange: (e) => e.target.files?.[0] && (n(e.target.files[0]), e.target.value = "")
|
|
@@ -4240,7 +4340,7 @@ function Ar({ onSend: e, onTyping: t, onFile: n, disabled: r }) {
|
|
|
4240
4340
|
variant: "transparent",
|
|
4241
4341
|
disabled: r,
|
|
4242
4342
|
title: "Attach a file",
|
|
4243
|
-
onClick: () =>
|
|
4343
|
+
onClick: () => g.current?.click(),
|
|
4244
4344
|
className: "ci-h-10 ci-w-10",
|
|
4245
4345
|
children: Q.clip
|
|
4246
4346
|
}),
|
|
@@ -4251,36 +4351,36 @@ function Ar({ onSend: e, onTyping: t, onFile: n, disabled: r }) {
|
|
|
4251
4351
|
disabled: r,
|
|
4252
4352
|
title: "Emoji",
|
|
4253
4353
|
"aria-label": "Emoji",
|
|
4254
|
-
"aria-expanded":
|
|
4255
|
-
onClick: () =>
|
|
4354
|
+
"aria-expanded": p,
|
|
4355
|
+
onClick: () => m((e) => !e),
|
|
4256
4356
|
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",
|
|
4257
4357
|
children: Q.smile
|
|
4258
4358
|
}), /* @__PURE__ */ d("textarea", {
|
|
4259
|
-
ref:
|
|
4260
|
-
value:
|
|
4359
|
+
ref: _,
|
|
4360
|
+
value: l,
|
|
4261
4361
|
disabled: r,
|
|
4262
4362
|
rows: 1,
|
|
4263
4363
|
placeholder: r ? "Connecting…" : "Write a message",
|
|
4264
4364
|
onChange: (e) => O(e.target.value),
|
|
4265
4365
|
onKeyDown: (e) => {
|
|
4266
|
-
let t = (
|
|
4267
|
-
e.key === "Enter" && !e.shiftKey && !t && (e.preventDefault(),
|
|
4366
|
+
let t = (l.match(/```/g) ?? []).length % 2 == 1;
|
|
4367
|
+
e.key === "Enter" && !e.shiftKey && !t && (e.preventDefault(), te());
|
|
4268
4368
|
},
|
|
4269
4369
|
className: "ci-block ci-w-full ci-resize-none ci-max-h-32 ci-pl-11 ci-pr-4 ci-py-2.5 ci-rounded-3xl ci-border-0 ci-bg-elevationL2 dark:ci-bg-elevationL2Dark ci-text-gray-900 dark:ci-text-white placeholder:ci-text-gray-500 dark:placeholder:ci-text-gray-400 ci-outline-none focus:ci-ring-2 focus:ci-ring-gray-400 dark:focus:ci-ring-gray-500 ci-text-sm",
|
|
4270
|
-
style: { height: Math.min(128, 40 + 20 * (
|
|
4370
|
+
style: { height: Math.min(128, 40 + 20 * (l.split("\n").length - 1)) }
|
|
4271
4371
|
})]
|
|
4272
4372
|
}),
|
|
4273
|
-
|
|
4373
|
+
l.trim() ? /* @__PURE__ */ d(Z, {
|
|
4274
4374
|
variant: "default",
|
|
4275
4375
|
disabled: r,
|
|
4276
|
-
onClick:
|
|
4376
|
+
onClick: te,
|
|
4277
4377
|
title: "Send",
|
|
4278
4378
|
className: "ci-h-10 ci-w-10",
|
|
4279
4379
|
children: Q.send
|
|
4280
4380
|
}) : /* @__PURE__ */ d(Z, {
|
|
4281
4381
|
variant: "default",
|
|
4282
4382
|
disabled: r || typeof MediaRecorder > "u",
|
|
4283
|
-
onClick:
|
|
4383
|
+
onClick: A,
|
|
4284
4384
|
title: "Record a voice note",
|
|
4285
4385
|
"aria-label": "Record a voice note",
|
|
4286
4386
|
className: "ci-h-10 ci-w-10",
|
|
@@ -4291,14 +4391,14 @@ function Ar({ onSend: e, onTyping: t, onFile: n, disabled: r }) {
|
|
|
4291
4391
|
}
|
|
4292
4392
|
//#endregion
|
|
4293
4393
|
//#region src/components/ChatWindow.tsx
|
|
4294
|
-
var
|
|
4394
|
+
var Nr = (e) => !!e && ![
|
|
4295
4395
|
"offline",
|
|
4296
4396
|
"dnd",
|
|
4297
4397
|
"busy",
|
|
4298
4398
|
"ringing",
|
|
4299
4399
|
"onhold"
|
|
4300
4400
|
].includes(e);
|
|
4301
|
-
function
|
|
4401
|
+
function Pr({ peer: e, actions: t, onDragStart: n }) {
|
|
4302
4402
|
let { c: r, contacts: a, online: o, mobile: s, status: l, closeChat: p, openChat: m, markRead: h, order: g, me: _ } = J(w((t) => ({
|
|
4303
4403
|
c: t.conversations[e],
|
|
4304
4404
|
contacts: t.contacts,
|
|
@@ -4310,16 +4410,28 @@ function Mr({ peer: e, actions: t, onDragStart: n }) {
|
|
|
4310
4410
|
markRead: t.markRead,
|
|
4311
4411
|
order: t.order,
|
|
4312
4412
|
me: t.me
|
|
4313
|
-
}))), v = Math.max(0, g.indexOf(e)), y = a[e], [b, x] = c(!1), S = (e) => e === _ ? "You" : a[e]?.name ?? e,
|
|
4314
|
-
|
|
4413
|
+
}))), v = Math.max(0, g.indexOf(e)), y = a[e], [b, x] = c(!1), [S, C] = c(null), [T, ee] = c(0), E = (e) => e === _ ? "You" : a[e]?.name ?? e, D = [...r?.members ?? []].sort((e, t) => Number(e === _) - Number(t === _));
|
|
4414
|
+
i(() => {
|
|
4315
4415
|
r && !r.loaded && t.loadOlder(e);
|
|
4316
4416
|
}, [e, r?.loaded]), i(() => {
|
|
4317
4417
|
h(e);
|
|
4318
|
-
}, [e, r?.messages.length]), i(() =>
|
|
4418
|
+
}, [e, r?.messages.length]), i(() => {
|
|
4419
|
+
x(!1), C(null);
|
|
4420
|
+
}, [e]);
|
|
4421
|
+
let O = (t) => {
|
|
4422
|
+
if (!t.oid) return;
|
|
4423
|
+
let n = r?.kind === "group" ? t.nick ?? "" : t.mine ? _ : e, i = t.oob ? "Attachment" : t.body.replace(/```/g, "").replace(/\s+/g, " ").trim().slice(0, 100), o = n === _ ? J.getState().myName || _ : a[n]?.name ?? n;
|
|
4424
|
+
C({
|
|
4425
|
+
id: t.oid,
|
|
4426
|
+
author: n,
|
|
4427
|
+
quote: `${o}: ${i}`
|
|
4428
|
+
}), ee((e) => e + 1);
|
|
4429
|
+
};
|
|
4430
|
+
return r ? /* @__PURE__ */ f("div", {
|
|
4319
4431
|
role: "dialog",
|
|
4320
4432
|
"aria-label": r.kind === "group" ? r.name ?? e : y?.name ?? e,
|
|
4321
4433
|
onKeyDown: (e) => {
|
|
4322
|
-
e.key === "Escape" && (e.stopPropagation(), b ? x(!1) : p());
|
|
4434
|
+
e.key === "Escape" && (e.stopPropagation(), S ? C(null) : b ? x(!1) : p());
|
|
4323
4435
|
},
|
|
4324
4436
|
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",
|
|
4325
4437
|
children: [
|
|
@@ -4332,17 +4444,17 @@ function Mr({ peer: e, actions: t, onDragStart: n }) {
|
|
|
4332
4444
|
className: `ci-flex ci-items-center ci-gap-3 ci-px-4 ci-py-3 ci-rounded-t-3xl ${n ? "ci-cursor-grab active:ci-cursor-grabbing ci-touch-none" : ""}`,
|
|
4333
4445
|
onPointerDown: n,
|
|
4334
4446
|
children: [
|
|
4335
|
-
r.kind === "group" ? /* @__PURE__ */ d(
|
|
4447
|
+
r.kind === "group" ? /* @__PURE__ */ d(Gn, {
|
|
4336
4448
|
name: r.name ?? e,
|
|
4337
4449
|
size: 36,
|
|
4338
4450
|
avatar: r.avatar
|
|
4339
4451
|
}) : /* @__PURE__ */ f("span", {
|
|
4340
4452
|
className: "ci-relative",
|
|
4341
|
-
children: [/* @__PURE__ */ d(
|
|
4453
|
+
children: [/* @__PURE__ */ d(Un, {
|
|
4342
4454
|
contact: y,
|
|
4343
4455
|
username: e,
|
|
4344
4456
|
size: 36
|
|
4345
|
-
}), /* @__PURE__ */ d(
|
|
4457
|
+
}), /* @__PURE__ */ d(Wn, {
|
|
4346
4458
|
online: o[e],
|
|
4347
4459
|
presence: y?.presence,
|
|
4348
4460
|
mobile: s[e]
|
|
@@ -4362,10 +4474,10 @@ function Mr({ peer: e, actions: t, onDragStart: n }) {
|
|
|
4362
4474
|
children: r.kind === "group" ? r.name ?? e : y?.name ?? e
|
|
4363
4475
|
}), /* @__PURE__ */ d("div", {
|
|
4364
4476
|
className: "ci-text-xs ci-text-gray-500 dark:ci-text-gray-400 ci-truncate",
|
|
4365
|
-
children: l === "online" ? r.kind === "group" ?
|
|
4477
|
+
children: l === "online" ? r.kind === "group" ? D.map(E).join(", ") : r.typing ? "typing…" : o[e] ? "online" : s[e] ? "Mobile" : "offline" : l
|
|
4366
4478
|
})]
|
|
4367
4479
|
}),
|
|
4368
|
-
r.kind !== "group" && y?.number &&
|
|
4480
|
+
r.kind !== "group" && y?.number && Nr(y.presence) && /* @__PURE__ */ d(Z, {
|
|
4369
4481
|
variant: "call",
|
|
4370
4482
|
title: `Call ${y.number}`,
|
|
4371
4483
|
"aria-label": "Call",
|
|
@@ -4387,16 +4499,16 @@ function Mr({ peer: e, actions: t, onDragStart: n }) {
|
|
|
4387
4499
|
/* @__PURE__ */ d("div", { className: "ci-border-t ci-border-gray-300 dark:ci-border-gray-700" }),
|
|
4388
4500
|
b && r.kind === "group" && /* @__PURE__ */ d("div", {
|
|
4389
4501
|
className: "ci-absolute ci-left-3 ci-right-3 ci-top-16 ci-z-10 ci-max-h-64 ci-overflow-y-auto ci-rounded-2xl ci-bg-gray-50 dark:ci-bg-gray-950 ci-shadow-2xl ci-ring-1 ci-ring-gray-300 dark:ci-ring-gray-700 ci-p-2",
|
|
4390
|
-
children:
|
|
4502
|
+
children: D.map((e) => /* @__PURE__ */ f("div", {
|
|
4391
4503
|
className: "ci-flex ci-items-center ci-gap-3 ci-px-2 ci-py-1.5 ci-text-sm",
|
|
4392
4504
|
children: [
|
|
4393
4505
|
/* @__PURE__ */ f("span", {
|
|
4394
4506
|
className: "ci-relative",
|
|
4395
|
-
children: [/* @__PURE__ */ d(
|
|
4507
|
+
children: [/* @__PURE__ */ d(Un, {
|
|
4396
4508
|
contact: a[e],
|
|
4397
4509
|
username: e,
|
|
4398
4510
|
size: 28
|
|
4399
|
-
}), e !== _ && /* @__PURE__ */ d(
|
|
4511
|
+
}), e !== _ && /* @__PURE__ */ d(Wn, {
|
|
4400
4512
|
online: o[e],
|
|
4401
4513
|
presence: a[e]?.presence,
|
|
4402
4514
|
mobile: s[e]
|
|
@@ -4404,7 +4516,7 @@ function Mr({ peer: e, actions: t, onDragStart: n }) {
|
|
|
4404
4516
|
}),
|
|
4405
4517
|
/* @__PURE__ */ d("span", {
|
|
4406
4518
|
className: "ci-truncate ci-flex-1",
|
|
4407
|
-
children:
|
|
4519
|
+
children: E(e)
|
|
4408
4520
|
}),
|
|
4409
4521
|
e !== _ && /* @__PURE__ */ f(u, { children: [/* @__PURE__ */ d(Z, {
|
|
4410
4522
|
variant: "small",
|
|
@@ -4412,7 +4524,7 @@ function Mr({ peer: e, actions: t, onDragStart: n }) {
|
|
|
4412
4524
|
"aria-label": "Chat",
|
|
4413
4525
|
onClick: () => m(e),
|
|
4414
4526
|
children: Q.chat
|
|
4415
|
-
}), a[e]?.number &&
|
|
4527
|
+
}), a[e]?.number && Nr(a[e]?.presence) && /* @__PURE__ */ d(Z, {
|
|
4416
4528
|
variant: "call",
|
|
4417
4529
|
title: `Call ${a[e]?.number}`,
|
|
4418
4530
|
"aria-label": "Call",
|
|
@@ -4427,32 +4539,56 @@ function Mr({ peer: e, actions: t, onDragStart: n }) {
|
|
|
4427
4539
|
}),
|
|
4428
4540
|
/* @__PURE__ */ f("div", {
|
|
4429
4541
|
className: "ci-flex-1 ci-min-h-0 ci-flex ci-flex-col ci-overflow-hidden ci-rounded-b-3xl",
|
|
4430
|
-
children: [
|
|
4431
|
-
|
|
4432
|
-
|
|
4433
|
-
|
|
4434
|
-
|
|
4435
|
-
|
|
4436
|
-
|
|
4437
|
-
|
|
4438
|
-
|
|
4439
|
-
|
|
4440
|
-
|
|
4441
|
-
|
|
4442
|
-
|
|
4443
|
-
|
|
4444
|
-
|
|
4542
|
+
children: [
|
|
4543
|
+
/* @__PURE__ */ d(_r, {
|
|
4544
|
+
messages: r.messages,
|
|
4545
|
+
typing: r.typing,
|
|
4546
|
+
group: r.kind === "group",
|
|
4547
|
+
hasOlder: r.loaded && !r.complete,
|
|
4548
|
+
onLoadOlder: () => t.loadOlder(e),
|
|
4549
|
+
reactions: r.reactions,
|
|
4550
|
+
me: _,
|
|
4551
|
+
onReact: (n, r) => t.react(e, n, r),
|
|
4552
|
+
onReply: O
|
|
4553
|
+
}),
|
|
4554
|
+
S && /* @__PURE__ */ f("div", {
|
|
4555
|
+
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",
|
|
4556
|
+
children: [/* @__PURE__ */ f("div", {
|
|
4557
|
+
className: "ci-flex-1 ci-min-w-0 ci-text-xs",
|
|
4558
|
+
children: [/* @__PURE__ */ d("div", {
|
|
4559
|
+
className: "ci-font-medium ci-text-gray-900 dark:ci-text-white",
|
|
4560
|
+
children: S.author === _ ? "You" : a[S.author]?.name ?? S.author
|
|
4561
|
+
}), /* @__PURE__ */ d("div", {
|
|
4562
|
+
className: "ci-truncate ci-text-gray-500 dark:ci-text-gray-400",
|
|
4563
|
+
children: S.quote?.replace(/^[^:]*: /, "")
|
|
4564
|
+
})]
|
|
4565
|
+
}), /* @__PURE__ */ d(Z, {
|
|
4566
|
+
variant: "small",
|
|
4567
|
+
onClick: () => C(null),
|
|
4568
|
+
"aria-label": "Cancel reply",
|
|
4569
|
+
title: "Cancel reply",
|
|
4570
|
+
children: Q.close
|
|
4571
|
+
})]
|
|
4572
|
+
}),
|
|
4573
|
+
/* @__PURE__ */ d(Mr, {
|
|
4574
|
+
focusKey: T,
|
|
4575
|
+
disabled: l !== "online",
|
|
4576
|
+
onSend: (n) => t.send(e, n, S ?? void 0).then(() => C(null)),
|
|
4577
|
+
onTyping: (n) => t.typing(e, n),
|
|
4578
|
+
onFile: (n) => t.upload(e, n)
|
|
4579
|
+
}, e)
|
|
4580
|
+
]
|
|
4445
4581
|
})
|
|
4446
4582
|
]
|
|
4447
4583
|
}) : null;
|
|
4448
4584
|
}
|
|
4449
4585
|
//#endregion
|
|
4450
4586
|
//#region src/components/NewChat.tsx
|
|
4451
|
-
async function
|
|
4587
|
+
async function Fr(e) {
|
|
4452
4588
|
let t = await createImageBitmap(e), n = Math.min(t.width, t.height), r = document.createElement("canvas");
|
|
4453
4589
|
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);
|
|
4454
4590
|
}
|
|
4455
|
-
function
|
|
4591
|
+
function Ir({ onOpen: e, onCreateGroup: t }) {
|
|
4456
4592
|
let { contacts: n, online: r, mobile: i, setPicker: a } = J(), [l, p] = c(""), [m, h] = c([]), [g, _] = c(""), [v, y] = c(!1), [b, x] = c(), S = s(null), C = o(() => {
|
|
4457
4593
|
let e = Object.values(n), t = l.trim().toLowerCase();
|
|
4458
4594
|
return t ? e.filter((e) => (e.name ?? "").toLowerCase().includes(t) || e.username.includes(t)) : e;
|
|
@@ -4509,11 +4645,11 @@ function Pr({ onOpen: e, onCreateGroup: t }) {
|
|
|
4509
4645
|
children: [
|
|
4510
4646
|
/* @__PURE__ */ f("span", {
|
|
4511
4647
|
className: "ci-relative",
|
|
4512
|
-
children: [/* @__PURE__ */ d(
|
|
4648
|
+
children: [/* @__PURE__ */ d(Un, {
|
|
4513
4649
|
contact: e,
|
|
4514
4650
|
username: e.username,
|
|
4515
4651
|
size: 36
|
|
4516
|
-
}), /* @__PURE__ */ d(
|
|
4652
|
+
}), /* @__PURE__ */ d(Wn, {
|
|
4517
4653
|
online: r[e.username],
|
|
4518
4654
|
presence: e.presence,
|
|
4519
4655
|
mobile: i[e.username]
|
|
@@ -4560,7 +4696,7 @@ function Pr({ onOpen: e, onCreateGroup: t }) {
|
|
|
4560
4696
|
type: "file",
|
|
4561
4697
|
accept: "image/*",
|
|
4562
4698
|
hidden: !0,
|
|
4563
|
-
onChange: (e) => e.target.files?.[0] &&
|
|
4699
|
+
onChange: (e) => e.target.files?.[0] && Fr(e.target.files[0]).then(x).catch(() => {})
|
|
4564
4700
|
}),
|
|
4565
4701
|
/* @__PURE__ */ d("button", {
|
|
4566
4702
|
type: "button",
|
|
@@ -4595,22 +4731,22 @@ function Pr({ onOpen: e, onCreateGroup: t }) {
|
|
|
4595
4731
|
}
|
|
4596
4732
|
//#endregion
|
|
4597
4733
|
//#region src/theme.ts
|
|
4598
|
-
var
|
|
4734
|
+
var Lr = "chat-island-theme", Rr = () => {
|
|
4599
4735
|
try {
|
|
4600
|
-
let e = localStorage.getItem(
|
|
4736
|
+
let e = localStorage.getItem(Lr);
|
|
4601
4737
|
return e === "light" || e === "dark" || e === "system" ? e : void 0;
|
|
4602
4738
|
} catch {
|
|
4603
4739
|
return;
|
|
4604
4740
|
}
|
|
4605
4741
|
};
|
|
4606
|
-
function
|
|
4607
|
-
let [t, n] = c(() => e ??
|
|
4608
|
-
return i(() => n(e ??
|
|
4742
|
+
function zr(e) {
|
|
4743
|
+
let [t, n] = c(() => e ?? Rr()), [r, a] = c(!1);
|
|
4744
|
+
return i(() => n(e ?? Rr()), [e]), i(() => {
|
|
4609
4745
|
let e = (e) => {
|
|
4610
4746
|
let t = e.detail?.theme;
|
|
4611
4747
|
if (t === "light" || t === "dark" || t === "system") {
|
|
4612
4748
|
try {
|
|
4613
|
-
localStorage.setItem(
|
|
4749
|
+
localStorage.setItem(Lr, t);
|
|
4614
4750
|
} catch {}
|
|
4615
4751
|
n(t);
|
|
4616
4752
|
}
|
|
@@ -4636,7 +4772,7 @@ function Lr(e) {
|
|
|
4636
4772
|
}
|
|
4637
4773
|
//#endregion
|
|
4638
4774
|
//#region src/ChatIsland.tsx
|
|
4639
|
-
function
|
|
4775
|
+
function Br() {
|
|
4640
4776
|
let e = J.getState();
|
|
4641
4777
|
return Object.values(e.conversations).map((t) => {
|
|
4642
4778
|
let n = t.messages[t.messages.length - 1], r = e.contacts[t.peer];
|
|
@@ -4651,7 +4787,7 @@ function Rr() {
|
|
|
4651
4787
|
unread: t.unread,
|
|
4652
4788
|
members: t.members,
|
|
4653
4789
|
last: n ? {
|
|
4654
|
-
body:
|
|
4790
|
+
body: Ur(n.body),
|
|
4655
4791
|
ts: n.ts,
|
|
4656
4792
|
mine: n.mine,
|
|
4657
4793
|
oob: n.oob,
|
|
@@ -4660,7 +4796,7 @@ function Rr() {
|
|
|
4660
4796
|
};
|
|
4661
4797
|
}).filter((e) => e.last || e.kind === "group").sort((e, t) => (t.last?.ts ?? 0) - (e.last?.ts ?? 0));
|
|
4662
4798
|
}
|
|
4663
|
-
var
|
|
4799
|
+
var Vr = class extends t {
|
|
4664
4800
|
state = { failed: !1 };
|
|
4665
4801
|
failures = [];
|
|
4666
4802
|
static getDerivedStateFromError() {
|
|
@@ -4678,7 +4814,7 @@ var zr = class extends t {
|
|
|
4678
4814
|
return this.state.failed ? null : this.props.children;
|
|
4679
4815
|
}
|
|
4680
4816
|
};
|
|
4681
|
-
function
|
|
4817
|
+
function Hr(e) {
|
|
4682
4818
|
try {
|
|
4683
4819
|
let [t, n, r] = atob(e).split(":");
|
|
4684
4820
|
return t && n && r ? {
|
|
@@ -4690,9 +4826,9 @@ function Br(e) {
|
|
|
4690
4826
|
return null;
|
|
4691
4827
|
}
|
|
4692
4828
|
}
|
|
4693
|
-
var
|
|
4694
|
-
function
|
|
4695
|
-
let g = o(() =>
|
|
4829
|
+
var Ur = (e) => (lr(e) ? "Attachment" : $(e)).replace(/```[^\n]*\n?/g, "").replace(/(\*\*|__|~~|`)/g, "").replace(/(^|\s)[*_](\S[^*_]*)[*_]/g, "$1$2").replace(/\s+/g, " ").trim();
|
|
4830
|
+
function Wr({ 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 }) {
|
|
4831
|
+
let g = o(() => Hr(e), [e]), _ = zr(n), v = s(g), y = s(p), b = s(u);
|
|
4696
4832
|
i(() => {
|
|
4697
4833
|
v.current = g, y.current = p, b.current = u;
|
|
4698
4834
|
}, [
|
|
@@ -4708,16 +4844,16 @@ function Hr({ dataConfig: e, position: t = "bottom-right", theme: n, serviceWork
|
|
|
4708
4844
|
let e = (e) => e.persisted && S((e) => e + 1);
|
|
4709
4845
|
return window.addEventListener("pageshow", e), () => window.removeEventListener("pageshow", e);
|
|
4710
4846
|
}, []);
|
|
4711
|
-
let C = s(null), T = s(/* @__PURE__ */ new Set()),
|
|
4847
|
+
let C = s(null), T = s(/* @__PURE__ */ new Set()), E = s(!1), D = s(null), O = s(null), k = ee(O, `chat-island-pos:${g?.host ?? ""}:${g?.username ?? ""}`), { open: te, picker: A, status: j } = J(w((e) => ({
|
|
4712
4848
|
open: e.open,
|
|
4713
4849
|
picker: e.picker,
|
|
4714
4850
|
status: e.status
|
|
4715
|
-
}))),
|
|
4716
|
-
send: async (e, t) => {
|
|
4717
|
-
let
|
|
4718
|
-
if (!
|
|
4851
|
+
}))), M = o(() => ({
|
|
4852
|
+
send: async (e, t, n) => {
|
|
4853
|
+
let r = C.current;
|
|
4854
|
+
if (!r) throw Error("not connected");
|
|
4719
4855
|
try {
|
|
4720
|
-
J.getState().addMessage(e, await
|
|
4856
|
+
J.getState().addMessage(e, await r.send(e, $(t), void 0, n));
|
|
4721
4857
|
} catch (e) {
|
|
4722
4858
|
throw Y("chat-island-error", {
|
|
4723
4859
|
scope: "send",
|
|
@@ -4755,7 +4891,7 @@ function Hr({ dataConfig: e, position: t = "bottom-right", theme: n, serviceWork
|
|
|
4755
4891
|
if (!t || !n) return;
|
|
4756
4892
|
let r = J.getState().conversations[e];
|
|
4757
4893
|
try {
|
|
4758
|
-
r?.kind === "group" && await t.leaveGroup(e, !!r.owner).catch(() => {}), await
|
|
4894
|
+
r?.kind === "group" && await t.leaveGroup(e, !!r.owner).catch(() => {}), await Ln(n.host, n.token, e), J.getState().removeConversation(e);
|
|
4759
4895
|
} catch (e) {
|
|
4760
4896
|
Y("chat-island-error", {
|
|
4761
4897
|
scope: "delete",
|
|
@@ -4813,7 +4949,7 @@ function Hr({ dataConfig: e, position: t = "bottom-right", theme: n, serviceWork
|
|
|
4813
4949
|
if (e.setStatus(n, a), Y("chat-island-status", {
|
|
4814
4950
|
status: n,
|
|
4815
4951
|
error: a
|
|
4816
|
-
}), n === "online" && r && !
|
|
4952
|
+
}), n === "online" && r && !E.current && typeof Notification < "u") {
|
|
4817
4953
|
let e = Notification.permission;
|
|
4818
4954
|
(e === "granted" || b.current === "auto" && e === "default") && i();
|
|
4819
4955
|
}
|
|
@@ -4833,7 +4969,7 @@ function Hr({ dataConfig: e, position: t = "bottom-right", theme: n, serviceWork
|
|
|
4833
4969
|
}).catch(() => {});
|
|
4834
4970
|
},
|
|
4835
4971
|
message: (r) => {
|
|
4836
|
-
let i =
|
|
4972
|
+
let i = Mn(r);
|
|
4837
4973
|
r.room && !J.getState().conversations[r.room]?.name && t.groupInfo(r.room).then((t) => e.setGroup(t.peer, t.name, t.members, t.avatar, t.owner)).catch(() => {}), e.addMessage(i, r, { live: !0 }), Y("chat-island-message", {
|
|
4838
4974
|
...r,
|
|
4839
4975
|
peer: i
|
|
@@ -4843,7 +4979,7 @@ function Hr({ dataConfig: e, position: t = "bottom-right", theme: n, serviceWork
|
|
|
4843
4979
|
let n = J.getState(), r = document.visibilityState === "visible";
|
|
4844
4980
|
if (r && n.open === e) return;
|
|
4845
4981
|
let i = n.conversations[e], a = i?.kind === "group" ? i.name ?? e : n.contacts[e]?.name ?? e, o = t.oob ? "Attachment" : $(t.body), s = i?.kind === "group", c = s && t.nick ? n.contacts[t.nick]?.name ?? t.nick : a, l = s && t.nick ? `${c}: ${o}` : o;
|
|
4846
|
-
y.current &&
|
|
4982
|
+
y.current && Cn();
|
|
4847
4983
|
let u = s ? i?.avatar : n.contacts[e]?.avatar;
|
|
4848
4984
|
if (Y("chat-island-notify", {
|
|
4849
4985
|
peer: e,
|
|
@@ -4867,16 +5003,16 @@ function Hr({ dataConfig: e, position: t = "bottom-right", theme: n, serviceWork
|
|
|
4867
5003
|
};
|
|
4868
5004
|
C.current = t;
|
|
4869
5005
|
let i = () => {
|
|
4870
|
-
r && !
|
|
5006
|
+
r && !E.current && (E.current = !0, Vn(g, r).then((e) => {
|
|
4871
5007
|
if (!e) {
|
|
4872
|
-
|
|
5008
|
+
E.current = !1, J.setState({ push: Notification.permission === "denied" ? "denied" : "ask" });
|
|
4873
5009
|
return;
|
|
4874
5010
|
}
|
|
4875
5011
|
return t.enablePush(e.service, e.node).then(() => {
|
|
4876
|
-
|
|
5012
|
+
D.current = e, J.setState({ push: "enabled" }), Y("chat-island-push", { enabled: !0 });
|
|
4877
5013
|
});
|
|
4878
5014
|
}).catch((e) => {
|
|
4879
|
-
|
|
5015
|
+
E.current = !1, Y("chat-island-error", {
|
|
4880
5016
|
scope: "push",
|
|
4881
5017
|
message: e.message
|
|
4882
5018
|
});
|
|
@@ -4888,51 +5024,51 @@ function Hr({ dataConfig: e, position: t = "bottom-right", theme: n, serviceWork
|
|
|
4888
5024
|
});
|
|
4889
5025
|
let s = () => t.stop();
|
|
4890
5026
|
window.addEventListener("pagehide", s), t.start();
|
|
4891
|
-
let c = () =>
|
|
5027
|
+
let c = () => In(g.host, g.token).then(e.setMobile).catch(() => {});
|
|
4892
5028
|
c();
|
|
4893
5029
|
let u = window.setInterval(c, 12e4);
|
|
4894
|
-
|
|
5030
|
+
Fn(g.host, g.token, g.username, (e) => J.setState({ myName: e })).then(e.setContacts).catch((e) => Y("chat-island-error", {
|
|
4895
5031
|
scope: "contacts",
|
|
4896
5032
|
message: e.message
|
|
4897
5033
|
}));
|
|
4898
|
-
let d = X("chat-island-open", ({ username: t }) => t && e.openChat(t)), f = X("chat-island-close", () => e.closeChat()), p = X("chat-island-new", () => e.setPicker(!0)), m = X("chat-island-delete", ({ username: e }) => e &&
|
|
5034
|
+
let d = X("chat-island-open", ({ username: t }) => t && e.openChat(t)), f = X("chat-island-close", () => e.closeChat()), p = X("chat-island-new", () => e.setPicker(!0)), m = X("chat-island-delete", ({ username: e }) => e && M.remove(e)), h = X("chat-island-contacts", ({ contacts: t }) => t && e.setContacts(t)), _ = X("chat-island-conversations-request", () => Y("chat-island-conversations", { conversations: Br() }));
|
|
4899
5035
|
return () => {
|
|
4900
|
-
window.removeEventListener("pagehide", s), window.clearInterval(u), _(), p(), m(), d(), f(), h(),
|
|
5036
|
+
window.removeEventListener("pagehide", s), window.clearInterval(u), _(), p(), m(), d(), f(), h(), D.current && t.disablePush(D.current.service, D.current.node).catch(() => {}), D.current = null, t.stop(), C.current = null, E.current = !1;
|
|
4901
5037
|
};
|
|
4902
5038
|
}, [
|
|
4903
5039
|
g,
|
|
4904
5040
|
r,
|
|
4905
5041
|
x
|
|
4906
5042
|
]);
|
|
4907
|
-
let
|
|
5043
|
+
let N = J((e) => Object.keys(e.contacts).join(","));
|
|
4908
5044
|
i(() => {
|
|
4909
|
-
j === "online" &&
|
|
4910
|
-
}, [j,
|
|
4911
|
-
let
|
|
4912
|
-
i(() => Y("chat-island-conversations", { conversations:
|
|
4913
|
-
let
|
|
4914
|
-
if (i(() => Y("chat-island-unread", { total:
|
|
4915
|
-
let
|
|
5045
|
+
j === "online" && N && C.current?.announce(N.split(","));
|
|
5046
|
+
}, [j, N]);
|
|
5047
|
+
let ne = J((e) => Object.values(e.conversations).map((e) => `${e.peer}:${e.kind}:${e.name ?? ""}:${(e.members ?? []).length}:${e.unread}:${e.messages[e.messages.length - 1]?.id ?? ""}`).join("|") + "#" + Object.keys(e.contacts).length + "#" + Object.values(e.online).filter(Boolean).length);
|
|
5048
|
+
i(() => Y("chat-island-conversations", { conversations: Br() }), [ne]);
|
|
5049
|
+
let re = J((e) => Object.values(e.conversations).reduce((e, t) => e + t.unread, 0));
|
|
5050
|
+
if (i(() => Y("chat-island-unread", { total: re }), [re]), !g) return null;
|
|
5051
|
+
let ie = m && !h && k.anchor ? {
|
|
4916
5052
|
right: k.anchor.right,
|
|
4917
5053
|
bottom: k.anchor.bottom
|
|
4918
|
-
} : void 0,
|
|
5054
|
+
} : void 0, ae = ie ? "" : t === "bottom-left" ? "ci-left-4 ci-bottom-5" : "ci-right-4 ci-bottom-5";
|
|
4919
5055
|
return /* @__PURE__ */ d("div", {
|
|
4920
|
-
ref:
|
|
4921
|
-
style:
|
|
5056
|
+
ref: O,
|
|
5057
|
+
style: ie,
|
|
4922
5058
|
onClickCapture: k.onClickCapture,
|
|
4923
|
-
className: `chat-island-root ${_ ? "ci-dark" : ""} ci-fixed ${
|
|
5059
|
+
className: `chat-island-root ${_ ? "ci-dark" : ""} ci-fixed ${ae} ci-z-[9999] ci-flex ci-items-end ci-gap-3 ci-font-sans ci-select-none`,
|
|
4924
5060
|
"data-status": j,
|
|
4925
|
-
children: /* @__PURE__ */ f(
|
|
4926
|
-
te && /* @__PURE__ */ d(
|
|
5061
|
+
children: /* @__PURE__ */ f(Vr, { children: [
|
|
5062
|
+
te && /* @__PURE__ */ d(Pr, {
|
|
4927
5063
|
peer: te,
|
|
4928
|
-
actions:
|
|
5064
|
+
actions: M,
|
|
4929
5065
|
onDragStart: h ?? (m ? k.start : void 0)
|
|
4930
5066
|
}),
|
|
4931
|
-
A && /* @__PURE__ */ d(
|
|
5067
|
+
A && /* @__PURE__ */ d(Ir, {
|
|
4932
5068
|
onOpen: (e) => J.getState().openChat(e),
|
|
4933
|
-
onCreateGroup:
|
|
5069
|
+
onCreateGroup: M.createGroup
|
|
4934
5070
|
}),
|
|
4935
|
-
/* @__PURE__ */ d(
|
|
5071
|
+
/* @__PURE__ */ d(Jn, {
|
|
4936
5072
|
onDragStart: h ?? (m ? k.start : void 0),
|
|
4937
5073
|
pushButton: u !== "auto"
|
|
4938
5074
|
})
|
|
@@ -4940,4 +5076,4 @@ function Hr({ dataConfig: e, position: t = "bottom-right", theme: n, serviceWork
|
|
|
4940
5076
|
});
|
|
4941
5077
|
}
|
|
4942
5078
|
//#endregion
|
|
4943
|
-
export {
|
|
5079
|
+
export { Wr as ChatIsland };
|