@codingfactory/messenger-client 0.2.29 → 0.2.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +898 -859
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ref as
|
|
1
|
+
import { ref as ye, getCurrentInstance as zt, computed as re, watch as ot, onUnmounted as qe, toValue as is, onMounted as jt } from "vue";
|
|
2
2
|
import { defineStore as Di, storeToRefs as Ni } from "pinia";
|
|
3
3
|
import $t, { isAxiosError as qi, AxiosHeaders as An } from "axios";
|
|
4
4
|
import { isAxiosError as vc } from "axios";
|
|
@@ -14,7 +14,7 @@ const os = () => () => {
|
|
|
14
14
|
throw new Error("messenger-client subscribeToConversation is not configured");
|
|
15
15
|
}, ps = () => {
|
|
16
16
|
throw new Error("messenger-client subscribeToTyping is not configured");
|
|
17
|
-
}, gs = async () => null,
|
|
17
|
+
}, gs = async () => null, $ = {
|
|
18
18
|
ECHO_INITIALIZED_EVENT: "messenger-client:echo-initialized",
|
|
19
19
|
getEcho: () => null,
|
|
20
20
|
waitForEcho: gs,
|
|
@@ -29,14 +29,14 @@ const os = () => () => {
|
|
|
29
29
|
unsubscribeFromConversation: ds,
|
|
30
30
|
subscribeToTyping: ps,
|
|
31
31
|
unsubscribeFromTyping: hs
|
|
32
|
-
}, Je = () =>
|
|
33
|
-
await
|
|
34
|
-
}, Hi = (e) =>
|
|
32
|
+
}, Je = () => $.ECHO_INITIALIZED_EVENT, Ae = () => $.getEcho(), ms = async () => $.waitForEcho(), vs = () => $.getConnectionStatus(), Rn = () => vs(), Ot = () => $.getAccessState(), ht = (e) => $.onConnectionStatusChange(e), ji = (e) => $.onAccessStateChange(e), $i = async () => {
|
|
33
|
+
await $.reconnect();
|
|
34
|
+
}, Hi = (e) => $.subscribeToPresenceStatus(e), Bi = () => $.unsubscribeFromPresenceStatus(), Vi = (e, n) => $.subscribeToConversation(e, n), Xi = (e) => $.unsubscribeFromConversation(e), Wi = (e, n) => $.subscribeToTyping(e, n), Gi = (e) => $.unsubscribeFromTyping(e);
|
|
35
35
|
function Ji(e) {
|
|
36
|
-
e.initializedEvent && (
|
|
36
|
+
e.initializedEvent && ($.ECHO_INITIALIZED_EVENT = e.initializedEvent), e.getEcho && ($.getEcho = e.getEcho), e.waitForEcho && ($.waitForEcho = e.waitForEcho), e.getConnectionStatus && ($.getConnectionStatus = e.getConnectionStatus), e.getAccessState && ($.getAccessState = e.getAccessState), e.onConnectionStatusChange && ($.onConnectionStatusChange = e.onConnectionStatusChange), e.onAccessStateChange && ($.onAccessStateChange = e.onAccessStateChange), e.reconnect && ($.reconnect = e.reconnect), e.subscribeToPresenceStatus && ($.subscribeToPresenceStatus = e.subscribeToPresenceStatus), e.unsubscribeFromPresenceStatus && ($.unsubscribeFromPresenceStatus = e.unsubscribeFromPresenceStatus), e.subscribeToConversation && ($.subscribeToConversation = e.subscribeToConversation), e.unsubscribeFromConversation && ($.unsubscribeFromConversation = e.unsubscribeFromConversation), e.subscribeToTyping && ($.subscribeToTyping = e.subscribeToTyping), e.unsubscribeFromTyping && ($.unsubscribeFromTyping = e.unsubscribeFromTyping);
|
|
37
37
|
}
|
|
38
38
|
function Ki() {
|
|
39
|
-
|
|
39
|
+
$.ECHO_INITIALIZED_EVENT = "messenger-client:echo-initialized", $.getEcho = () => null, $.waitForEcho = gs, $.getConnectionStatus = () => "disconnected", $.getAccessState = () => "available", $.onConnectionStatusChange = os, $.onAccessStateChange = as, $.reconnect = cs, $.subscribeToPresenceStatus = us, $.unsubscribeFromPresenceStatus = ls, $.subscribeToConversation = fs, $.unsubscribeFromConversation = ds, $.subscribeToTyping = ps, $.unsubscribeFromTyping = hs;
|
|
40
40
|
}
|
|
41
41
|
function xe(e) {
|
|
42
42
|
return typeof e == "object" && e !== null;
|
|
@@ -61,7 +61,7 @@ function no(e) {
|
|
|
61
61
|
}
|
|
62
62
|
const bs = $t;
|
|
63
63
|
let Ht = bs;
|
|
64
|
-
function
|
|
64
|
+
function W() {
|
|
65
65
|
return Ht;
|
|
66
66
|
}
|
|
67
67
|
function so(e) {
|
|
@@ -94,7 +94,7 @@ function ao(e) {
|
|
|
94
94
|
function co() {
|
|
95
95
|
Xt = () => _s;
|
|
96
96
|
}
|
|
97
|
-
function
|
|
97
|
+
function Z(e) {
|
|
98
98
|
if (qi(e)) {
|
|
99
99
|
const n = e.response?.data?.message || e.message || "An error occurred";
|
|
100
100
|
return n.includes("SQLSTATE") || n.includes("Connection:") || n.includes("\\Illuminate\\") ? "Something went wrong. Please try again later." : n;
|
|
@@ -183,35 +183,35 @@ function Mn(e) {
|
|
|
183
183
|
}
|
|
184
184
|
const Pe = {
|
|
185
185
|
async fetchFolders() {
|
|
186
|
-
const e = await
|
|
186
|
+
const e = await W().get("/v1/messaging/folders");
|
|
187
187
|
return po($e(e.data));
|
|
188
188
|
},
|
|
189
189
|
async createFolder(e) {
|
|
190
|
-
const n = await
|
|
190
|
+
const n = await W().post("/v1/messaging/folders", e);
|
|
191
191
|
return Ft($e(n.data));
|
|
192
192
|
},
|
|
193
193
|
async updateFolder(e, n) {
|
|
194
|
-
const r = await
|
|
194
|
+
const r = await W().patch(`/v1/messaging/folders/${e}`, n);
|
|
195
195
|
return Ft($e(r.data));
|
|
196
196
|
},
|
|
197
197
|
async deleteFolder(e) {
|
|
198
|
-
await
|
|
198
|
+
await W().delete(`/v1/messaging/folders/${e}`);
|
|
199
199
|
},
|
|
200
200
|
async reorderFolders(e) {
|
|
201
|
-
await
|
|
201
|
+
await W().patch("/v1/messaging/folders/reorder", { order: e });
|
|
202
202
|
},
|
|
203
203
|
async assignFolder(e, n) {
|
|
204
|
-
const r = await
|
|
204
|
+
const r = await W().patch(`/v1/messaging/conversations/${e}/folder`, {
|
|
205
205
|
folder_id: n
|
|
206
206
|
});
|
|
207
207
|
return Mn($e(r.data));
|
|
208
208
|
},
|
|
209
209
|
async acceptRequest(e) {
|
|
210
|
-
const n = await
|
|
210
|
+
const n = await W().post(`/v1/messaging/conversations/${e}/accept`);
|
|
211
211
|
return Mn($e(n.data));
|
|
212
212
|
},
|
|
213
213
|
async declineRequest(e) {
|
|
214
|
-
await
|
|
214
|
+
await W().post(`/v1/messaging/conversations/${e}/decline`);
|
|
215
215
|
}
|
|
216
216
|
}, go = 6e4;
|
|
217
217
|
function mo(e) {
|
|
@@ -288,9 +288,9 @@ const kn = 1e3, Gt = 4e3, yo = 12e4, _o = 300, So = 1, Co = 1600, Jt = (e) => {
|
|
|
288
288
|
data: [],
|
|
289
289
|
has_more: !1
|
|
290
290
|
}), Un = () => Ot() === "account_suspended", Eo = (e) => {
|
|
291
|
-
if (!
|
|
291
|
+
if (!he(e))
|
|
292
292
|
return !1;
|
|
293
|
-
const r = (
|
|
293
|
+
const r = (he(e.data) ? e.data : e).throttled;
|
|
294
294
|
if (typeof r == "boolean")
|
|
295
295
|
return r;
|
|
296
296
|
if (typeof r == "number")
|
|
@@ -373,12 +373,12 @@ function at(e) {
|
|
|
373
373
|
};
|
|
374
374
|
}
|
|
375
375
|
function xo(e) {
|
|
376
|
-
if (!e || !
|
|
376
|
+
if (!e || !he(e))
|
|
377
377
|
return;
|
|
378
378
|
const n = typeof e.id == "string" ? e.id.trim() : "", r = typeof e.title == "string" ? e.title.trim() : "", o = typeof e.url == "string" ? e.url.trim() : "";
|
|
379
379
|
if (n.length === 0 || r.length === 0 || o.length === 0)
|
|
380
380
|
return;
|
|
381
|
-
const c = typeof e.excerpt == "string" && e.excerpt.trim().length > 0 ? e.excerpt.trim() : null, u = typeof e.media_thumbnail == "string" && e.media_thumbnail.trim().length > 0 ? e.media_thumbnail.trim() : null, d =
|
|
381
|
+
const c = typeof e.excerpt == "string" && e.excerpt.trim().length > 0 ? e.excerpt.trim() : null, u = typeof e.media_thumbnail == "string" && e.media_thumbnail.trim().length > 0 ? e.media_thumbnail.trim() : null, d = he(e.author) ? e.author : null, f = d && typeof d.id == "string" ? d.id.trim() : "", h = d && typeof d.name == "string" ? d.name.trim() : "", R = d && typeof d.avatar == "string" && d.avatar.trim().length > 0 ? d.avatar.trim() : null, C = d && typeof d.handle == "string" && d.handle.trim().length > 0 ? d.handle.trim() : null;
|
|
382
382
|
return {
|
|
383
383
|
id: n,
|
|
384
384
|
title: r,
|
|
@@ -389,7 +389,7 @@ function xo(e) {
|
|
|
389
389
|
author: {
|
|
390
390
|
id: f,
|
|
391
391
|
name: h,
|
|
392
|
-
...
|
|
392
|
+
...R ? { avatar: R } : {},
|
|
393
393
|
...C ? { handle: C } : {}
|
|
394
394
|
}
|
|
395
395
|
} : {}
|
|
@@ -449,7 +449,7 @@ function Uo(e, n) {
|
|
|
449
449
|
return Object.prototype.hasOwnProperty.call(e, "folder_id") ? e.folder_id ?? null : e.me?.folder_id === null ? null : typeof e.me?.folder_id == "string" ? e.me.folder_id : n?.folder_id;
|
|
450
450
|
}
|
|
451
451
|
function He(e, n) {
|
|
452
|
-
const r = Io(e, n), o = typeof e.is_muted == "boolean" ? e.is_muted : r !== null || n?.is_muted === !0, c = e.last_message ? at(e.last_message) : n?.last_message, u = e.last_message_at ?? n?.last_message_at, d = typeof e.unread_count == "number" ? e.unread_count : n?.unread_count ?? 0, f = typeof e.is_pinned == "boolean" ? e.is_pinned : e.me?.is_pinned ?? n?.is_pinned ?? !1, h = typeof e.is_archived == "boolean" ? e.is_archived : e.me?.is_archived ?? n?.is_archived ?? !1,
|
|
452
|
+
const r = Io(e, n), o = typeof e.is_muted == "boolean" ? e.is_muted : r !== null || n?.is_muted === !0, c = e.last_message ? at(e.last_message) : n?.last_message, u = e.last_message_at ?? n?.last_message_at, d = typeof e.unread_count == "number" ? e.unread_count : n?.unread_count ?? 0, f = typeof e.is_pinned == "boolean" ? e.is_pinned : e.me?.is_pinned ?? n?.is_pinned ?? !1, h = typeof e.is_archived == "boolean" ? e.is_archived : e.me?.is_archived ?? n?.is_archived ?? !1, R = Uo(e, n), C = typeof e.created_at == "string" ? e.created_at : n?.created_at ?? "", v = (() => {
|
|
453
453
|
if (!n || n.unread_count !== 0 || d <= 0)
|
|
454
454
|
return !1;
|
|
455
455
|
const E = n.last_message?.id, b = e.last_message?.id;
|
|
@@ -463,7 +463,7 @@ function He(e, n) {
|
|
|
463
463
|
muted_until: r,
|
|
464
464
|
is_pinned: f,
|
|
465
465
|
is_archived: h,
|
|
466
|
-
folder_id:
|
|
466
|
+
folder_id: R,
|
|
467
467
|
created_at: C,
|
|
468
468
|
...c ? { last_message: c } : {},
|
|
469
469
|
...u ? { last_message_at: u } : {}
|
|
@@ -485,20 +485,20 @@ function Fn(e, n) {
|
|
|
485
485
|
}
|
|
486
486
|
return qt(e.last_message?.id) ? e.last_message.id : null;
|
|
487
487
|
}
|
|
488
|
-
function
|
|
488
|
+
function he(e) {
|
|
489
489
|
return typeof e == "object" && e !== null;
|
|
490
490
|
}
|
|
491
491
|
function Fo(e) {
|
|
492
|
-
return
|
|
492
|
+
return he(e) ? (he(e.response) ? e.response : null)?.status === 401 : !1;
|
|
493
493
|
}
|
|
494
494
|
function Dn(e) {
|
|
495
495
|
if (!Array.isArray(e))
|
|
496
496
|
return [];
|
|
497
497
|
const n = [];
|
|
498
498
|
for (const r of e) {
|
|
499
|
-
if (!
|
|
499
|
+
if (!he(r) || typeof r.reaction != "string" || typeof r.count != "number" || !Array.isArray(r.users))
|
|
500
500
|
continue;
|
|
501
|
-
const o = r.users.filter((c) =>
|
|
501
|
+
const o = r.users.filter((c) => he(c)).filter(
|
|
502
502
|
(c) => typeof c.id == "string" && typeof c.name == "string"
|
|
503
503
|
).map((c) => ({
|
|
504
504
|
id: c.id,
|
|
@@ -513,23 +513,23 @@ function Dn(e) {
|
|
|
513
513
|
return n;
|
|
514
514
|
}
|
|
515
515
|
function Do(e, n) {
|
|
516
|
-
const r =
|
|
516
|
+
const r = he(n) ? n : null, o = r?.next ?? r?.next_cursor ?? e.next_cursor;
|
|
517
517
|
if (!(typeof o != "string" || o.length === 0))
|
|
518
518
|
return o;
|
|
519
519
|
}
|
|
520
520
|
function st(e, n) {
|
|
521
|
-
const r =
|
|
521
|
+
const r = he(e) ? e : {}, o = r.data ?? e;
|
|
522
522
|
let c = [];
|
|
523
|
-
return Array.isArray(o) ? c = o :
|
|
523
|
+
return Array.isArray(o) ? c = o : he(o) && (Array.isArray(o.items) ? c = o.items : Array.isArray(o[n]) ? c = o[n] : Array.isArray(o.data) && (c = o.data)), {
|
|
524
524
|
items: c,
|
|
525
525
|
nextCursor: Do(r, o)
|
|
526
526
|
};
|
|
527
527
|
}
|
|
528
528
|
function Nn(e) {
|
|
529
|
-
return
|
|
529
|
+
return he(e) && typeof e.id == "string" && e.id.length > 0;
|
|
530
530
|
}
|
|
531
531
|
function qn(e) {
|
|
532
|
-
return
|
|
532
|
+
return he(e) ? typeof e.id == "string" && (e.type === "dm" || e.type === "group") && Array.isArray(e.participants) : !1;
|
|
533
533
|
}
|
|
534
534
|
function Kt(e, n) {
|
|
535
535
|
if (e.type !== "dm")
|
|
@@ -541,7 +541,7 @@ function Kt(e, n) {
|
|
|
541
541
|
return r.user.id === n && o.length > 0 && o.toLowerCase() !== "pending user";
|
|
542
542
|
}
|
|
543
543
|
function zn(e) {
|
|
544
|
-
if (!
|
|
544
|
+
if (!he(e) || typeof e.id != "string" || typeof e.name != "string")
|
|
545
545
|
return null;
|
|
546
546
|
const n = {
|
|
547
547
|
id: e.id,
|
|
@@ -552,8 +552,8 @@ function zn(e) {
|
|
|
552
552
|
return c && (n.avatar = c, n.avatar_url = c), n;
|
|
553
553
|
}
|
|
554
554
|
function No(e) {
|
|
555
|
-
const r = (
|
|
556
|
-
return Array.isArray(r) ? r.map((o) => zn(o)).filter((o) => o !== null) :
|
|
555
|
+
const r = (he(e) ? e : {}).data ?? e;
|
|
556
|
+
return Array.isArray(r) ? r.map((o) => zn(o)).filter((o) => o !== null) : he(r) ? Object.values(r).map((o) => zn(o)).filter((o) => o !== null) : [];
|
|
557
557
|
}
|
|
558
558
|
function As(e) {
|
|
559
559
|
if (e.type !== "dm")
|
|
@@ -738,7 +738,7 @@ const Qt = Di("messaging", {
|
|
|
738
738
|
const e = await Pe.fetchFolders();
|
|
739
739
|
return this.folders = Be(e), this.foldersLoaded = !0, this.normalizeFolderAssignmentsState(), this.folders;
|
|
740
740
|
} catch (e) {
|
|
741
|
-
throw this.error =
|
|
741
|
+
throw this.error = Z(e), e;
|
|
742
742
|
}
|
|
743
743
|
},
|
|
744
744
|
async createFolder(e) {
|
|
@@ -746,7 +746,7 @@ const Qt = Di("messaging", {
|
|
|
746
746
|
const n = await Pe.createFolder(e);
|
|
747
747
|
return this.folders = Be([...this.folders, n]), n;
|
|
748
748
|
} catch (n) {
|
|
749
|
-
throw this.error =
|
|
749
|
+
throw this.error = Z(n), n;
|
|
750
750
|
}
|
|
751
751
|
},
|
|
752
752
|
async updateFolder(e, n) {
|
|
@@ -756,14 +756,14 @@ const Qt = Di("messaging", {
|
|
|
756
756
|
this.folders.map((o) => o.id === e ? r : o)
|
|
757
757
|
), r;
|
|
758
758
|
} catch (r) {
|
|
759
|
-
throw this.error =
|
|
759
|
+
throw this.error = Z(r), r;
|
|
760
760
|
}
|
|
761
761
|
},
|
|
762
762
|
async deleteFolder(e) {
|
|
763
763
|
try {
|
|
764
764
|
await Pe.deleteFolder(e), this.folders = this.folders.filter((n) => n.id !== e), this.foldersLoaded = !0, this.activeFolderId === e && (this.activeFolderId = null), this.normalizeFolderAssignmentsState();
|
|
765
765
|
} catch (n) {
|
|
766
|
-
throw this.error =
|
|
766
|
+
throw this.error = Z(n), n;
|
|
767
767
|
}
|
|
768
768
|
},
|
|
769
769
|
async reorderFolders(e) {
|
|
@@ -785,7 +785,7 @@ const Qt = Di("messaging", {
|
|
|
785
785
|
});
|
|
786
786
|
this.folders = r;
|
|
787
787
|
} catch (n) {
|
|
788
|
-
throw this.error =
|
|
788
|
+
throw this.error = Z(n), n;
|
|
789
789
|
}
|
|
790
790
|
},
|
|
791
791
|
async assignToFolder(e, n) {
|
|
@@ -812,7 +812,7 @@ const Qt = Di("messaging", {
|
|
|
812
812
|
u
|
|
813
813
|
);
|
|
814
814
|
} catch (r) {
|
|
815
|
-
throw this.error =
|
|
815
|
+
throw this.error = Z(r), r;
|
|
816
816
|
}
|
|
817
817
|
},
|
|
818
818
|
async fetchConversations(e, n, r, o) {
|
|
@@ -822,15 +822,15 @@ const Qt = Di("messaging", {
|
|
|
822
822
|
return e || (this.conversations = [], this.normalizeFolderAssignmentsState()), In();
|
|
823
823
|
const c = o?.includePresence ?? !0, u = {};
|
|
824
824
|
c && (u.include_presence = 1), e && (u.cursor = e), n && (u.filter = n), typeof r == "string" && r.length > 0 && (u.folder_id = r);
|
|
825
|
-
const d = await
|
|
825
|
+
const d = await W().get("/v1/messaging/conversations", { params: u }), { items: f, nextCursor: h } = st(
|
|
826
826
|
d.data,
|
|
827
827
|
"conversations"
|
|
828
|
-
),
|
|
828
|
+
), R = f.map((E) => {
|
|
829
829
|
const b = this.conversations.find(
|
|
830
830
|
(A) => A.id === E.id
|
|
831
831
|
);
|
|
832
832
|
return He(E, b);
|
|
833
|
-
}), C = await $n(
|
|
833
|
+
}), C = await $n(R);
|
|
834
834
|
e ? this.conversations.push(...C) : this.conversations = C, this.normalizeFolderAssignmentsState(), this.lastFetch = Date.now();
|
|
835
835
|
const v = {
|
|
836
836
|
data: C,
|
|
@@ -838,7 +838,7 @@ const Qt = Di("messaging", {
|
|
|
838
838
|
};
|
|
839
839
|
return h !== void 0 && (v.next_cursor = h), v;
|
|
840
840
|
} catch (c) {
|
|
841
|
-
throw o?.background && xn(c) || (this.error =
|
|
841
|
+
throw o?.background && xn(c) || (this.error = Z(c)), c;
|
|
842
842
|
} finally {
|
|
843
843
|
this.loading = !1;
|
|
844
844
|
}
|
|
@@ -859,7 +859,7 @@ const Qt = Di("messaging", {
|
|
|
859
859
|
async fetchConversation(e) {
|
|
860
860
|
this.loading = !0, this.error = null;
|
|
861
861
|
try {
|
|
862
|
-
const n = await
|
|
862
|
+
const n = await W().get(`/v1/messaging/conversations/${e}`, {
|
|
863
863
|
params: { include_presence: 1 }
|
|
864
864
|
}), r = this.conversations.find((f) => f.id === e);
|
|
865
865
|
let o = He(n.data.data || n.data, r);
|
|
@@ -870,7 +870,7 @@ const Qt = Di("messaging", {
|
|
|
870
870
|
const d = this.requests.findIndex((f) => f.id === e);
|
|
871
871
|
return d >= 0 && (this.requests[d] = o), this.normalizeFolderAssignmentsState(), o;
|
|
872
872
|
} catch (n) {
|
|
873
|
-
throw this.error =
|
|
873
|
+
throw this.error = Z(n), n;
|
|
874
874
|
} finally {
|
|
875
875
|
this.loading = !1;
|
|
876
876
|
}
|
|
@@ -885,12 +885,12 @@ const Qt = Di("messaging", {
|
|
|
885
885
|
filter: "requests"
|
|
886
886
|
};
|
|
887
887
|
e && (n.cursor = e);
|
|
888
|
-
const r = await
|
|
888
|
+
const r = await W().get("/v1/messaging/conversations", { params: n }), { items: o, nextCursor: c } = st(
|
|
889
889
|
r.data,
|
|
890
890
|
"conversations"
|
|
891
891
|
), u = o.map((h) => {
|
|
892
|
-
const
|
|
893
|
-
return He(h,
|
|
892
|
+
const R = this.requests.find((C) => C.id === h.id);
|
|
893
|
+
return He(h, R);
|
|
894
894
|
}), d = await $n(u);
|
|
895
895
|
e ? this.requests.push(...d) : this.requests = d, this.normalizeFolderAssignmentsState();
|
|
896
896
|
const f = {
|
|
@@ -899,7 +899,7 @@ const Qt = Di("messaging", {
|
|
|
899
899
|
};
|
|
900
900
|
return c !== void 0 && (f.next_cursor = c), f;
|
|
901
901
|
} catch (n) {
|
|
902
|
-
throw this.error =
|
|
902
|
+
throw this.error = Z(n), n;
|
|
903
903
|
} finally {
|
|
904
904
|
this.loading = !1;
|
|
905
905
|
}
|
|
@@ -911,7 +911,7 @@ const Qt = Di("messaging", {
|
|
|
911
911
|
let o = 0, c;
|
|
912
912
|
for (; ; )
|
|
913
913
|
try {
|
|
914
|
-
c = await
|
|
914
|
+
c = await W().get(`/v1/messaging/conversations/${e}/messages`, { params: r });
|
|
915
915
|
break;
|
|
916
916
|
} catch (v) {
|
|
917
917
|
if (!(o < So && xn(v)))
|
|
@@ -936,19 +936,19 @@ const Qt = Di("messaging", {
|
|
|
936
936
|
};
|
|
937
937
|
return d !== void 0 && (C.next_cursor = d), C;
|
|
938
938
|
} catch (r) {
|
|
939
|
-
throw this.error =
|
|
939
|
+
throw this.error = Z(r), r;
|
|
940
940
|
} finally {
|
|
941
941
|
this.loadingMessages[e] = !1, this.loading = !1;
|
|
942
942
|
}
|
|
943
943
|
},
|
|
944
944
|
async sendMessage(e, n, r, o, c, u, d) {
|
|
945
|
-
const f = ke()(), h = `temp-${Date.now()}-${Math.random()}`,
|
|
945
|
+
const f = ke()(), h = `temp-${Date.now()}-${Math.random()}`, R = typeof u == "string" && u.trim().length > 0 ? u.trim() : null, C = xo(d), v = f.currentUser, E = {
|
|
946
946
|
id: h,
|
|
947
947
|
conversation_id: e,
|
|
948
948
|
author_id: v?.id || "",
|
|
949
949
|
body: n || "",
|
|
950
950
|
attachments: [],
|
|
951
|
-
meta:
|
|
951
|
+
meta: R ? { shared_post_id: R } : {},
|
|
952
952
|
...C ? { shared_post: C } : {},
|
|
953
953
|
is_deleted: !1,
|
|
954
954
|
created_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -965,11 +965,11 @@ const Qt = Di("messaging", {
|
|
|
965
965
|
const A = {
|
|
966
966
|
body: n || "",
|
|
967
967
|
...o ? { reply_to_id: o } : {},
|
|
968
|
-
...
|
|
968
|
+
...R ? { shared_post_id: R } : {},
|
|
969
969
|
...C ? { shared_post_preview: C } : {}
|
|
970
970
|
};
|
|
971
971
|
if (r && r.length > 0) {
|
|
972
|
-
const
|
|
972
|
+
const G = await Promise.all(
|
|
973
973
|
r.map(async (te) => {
|
|
974
974
|
const k = await uo().uploadImage(te);
|
|
975
975
|
return {
|
|
@@ -979,31 +979,31 @@ const Qt = Di("messaging", {
|
|
|
979
979
|
};
|
|
980
980
|
})
|
|
981
981
|
);
|
|
982
|
-
b = await
|
|
982
|
+
b = await W().post(`/v1/messaging/conversations/${e}/messages`, {
|
|
983
983
|
...A,
|
|
984
|
-
attachments:
|
|
984
|
+
attachments: G
|
|
985
985
|
});
|
|
986
986
|
} else
|
|
987
|
-
b = await
|
|
987
|
+
b = await W().post(`/v1/messaging/conversations/${e}/messages`, {
|
|
988
988
|
...A,
|
|
989
989
|
type: "text"
|
|
990
990
|
});
|
|
991
|
-
const w = b.data.data || b.data, p = { ...E, ...w, attachments: w.attachments ?? E.attachments }, m = at(p), y = this.messages[e],
|
|
992
|
-
|
|
993
|
-
const
|
|
991
|
+
const w = b.data.data || b.data, p = { ...E, ...w, attachments: w.attachments ?? E.attachments }, m = at(p), y = this.messages[e], F = y.findIndex((G) => G.id === h);
|
|
992
|
+
F >= 0 && (y[F] = m), this._pendingSendIds.delete(h);
|
|
993
|
+
const q = m.id;
|
|
994
994
|
let J = 0;
|
|
995
|
-
for (let
|
|
996
|
-
const te = y[
|
|
997
|
-
te && te.id ===
|
|
995
|
+
for (let G = y.length - 1; G >= 0; G--) {
|
|
996
|
+
const te = y[G];
|
|
997
|
+
te && te.id === q && (J++, J > 1 && y.splice(G, 1));
|
|
998
998
|
}
|
|
999
999
|
return this.updateConversationLastMessage(e, m), m;
|
|
1000
1000
|
} catch (b) {
|
|
1001
|
-
throw this._pendingSendIds.delete(h), this.messages[e] = this.messages[e].filter((A) => A.id !== h), this.error =
|
|
1001
|
+
throw this._pendingSendIds.delete(h), this.messages[e] = this.messages[e].filter((A) => A.id !== h), this.error = Z(b), b;
|
|
1002
1002
|
}
|
|
1003
1003
|
},
|
|
1004
1004
|
async editMessage(e, n, r) {
|
|
1005
1005
|
try {
|
|
1006
|
-
const o = await
|
|
1006
|
+
const o = await W().patch(`/v1/messaging/conversations/${e}/messages/${n}`, {
|
|
1007
1007
|
body: r
|
|
1008
1008
|
}), c = o.data.data || o.data, u = this.messages[e] || [], d = u.findIndex((f) => f.id === n);
|
|
1009
1009
|
if (d >= 0) {
|
|
@@ -1012,22 +1012,29 @@ const Qt = Di("messaging", {
|
|
|
1012
1012
|
}
|
|
1013
1013
|
return c;
|
|
1014
1014
|
} catch (o) {
|
|
1015
|
-
throw this.error =
|
|
1015
|
+
throw this.error = Z(o), o;
|
|
1016
1016
|
}
|
|
1017
1017
|
},
|
|
1018
1018
|
async deleteMessage(e, n) {
|
|
1019
1019
|
try {
|
|
1020
|
-
await
|
|
1021
|
-
const r = this.messages[e]
|
|
1022
|
-
if (
|
|
1023
|
-
const
|
|
1024
|
-
if (
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1020
|
+
await W().delete(`/v1/messaging/conversations/${e}/messages/${n}`);
|
|
1021
|
+
const r = this.messages[e];
|
|
1022
|
+
if (r) {
|
|
1023
|
+
const o = r.findIndex((c) => c.id === n);
|
|
1024
|
+
if (o >= 0) {
|
|
1025
|
+
const c = r[o];
|
|
1026
|
+
if (c) {
|
|
1027
|
+
const u = { ...c, is_deleted: !0 };
|
|
1028
|
+
delete u.body, this.messages[e] = [
|
|
1029
|
+
...r.slice(0, o),
|
|
1030
|
+
u,
|
|
1031
|
+
...r.slice(o + 1)
|
|
1032
|
+
];
|
|
1033
|
+
}
|
|
1034
|
+
}
|
|
1028
1035
|
}
|
|
1029
1036
|
} catch (r) {
|
|
1030
|
-
throw this.error =
|
|
1037
|
+
throw this.error = Z(r), r;
|
|
1031
1038
|
}
|
|
1032
1039
|
},
|
|
1033
1040
|
async markAsRead(e) {
|
|
@@ -1045,7 +1052,7 @@ const Qt = Di("messaging", {
|
|
|
1045
1052
|
})(), o = n ? Fn(n, this.messages) : r;
|
|
1046
1053
|
if (!o)
|
|
1047
1054
|
return;
|
|
1048
|
-
await
|
|
1055
|
+
await W().post(`/v1/messaging/conversations/${e}/read`, {
|
|
1049
1056
|
message_id: o
|
|
1050
1057
|
}), this.conversations.forEach((c) => {
|
|
1051
1058
|
c.id === e && (c.unread_count = 0);
|
|
@@ -1053,7 +1060,7 @@ const Qt = Di("messaging", {
|
|
|
1053
1060
|
c.id === e && (c.unread_count = 0);
|
|
1054
1061
|
});
|
|
1055
1062
|
} catch (n) {
|
|
1056
|
-
throw this.error =
|
|
1063
|
+
throw this.error = Z(n), n;
|
|
1057
1064
|
}
|
|
1058
1065
|
},
|
|
1059
1066
|
async markAllAsRead() {
|
|
@@ -1071,7 +1078,7 @@ const Qt = Di("messaging", {
|
|
|
1071
1078
|
return;
|
|
1072
1079
|
const r = await Promise.allSettled(
|
|
1073
1080
|
n.map(
|
|
1074
|
-
(c) =>
|
|
1081
|
+
(c) => W().post(`/v1/messaging/conversations/${c.conversationId}/read`, {
|
|
1075
1082
|
message_id: c.messageId
|
|
1076
1083
|
})
|
|
1077
1084
|
)
|
|
@@ -1088,39 +1095,39 @@ const Qt = Di("messaging", {
|
|
|
1088
1095
|
o === null && (o = c.reason);
|
|
1089
1096
|
}
|
|
1090
1097
|
}), o !== null)
|
|
1091
|
-
throw this.error =
|
|
1098
|
+
throw this.error = Z(o), o;
|
|
1092
1099
|
},
|
|
1093
1100
|
async sendTyping(e, n = "start") {
|
|
1094
1101
|
try {
|
|
1095
|
-
const r = await
|
|
1102
|
+
const r = await W().post(`/v1/messaging/conversations/${e}/typing`, { state: n });
|
|
1096
1103
|
if (n !== "start" || !Eo(r.data))
|
|
1097
1104
|
return;
|
|
1098
|
-
await Ln(Co), await
|
|
1105
|
+
await Ln(Co), await W().post(`/v1/messaging/conversations/${e}/typing`, { state: n });
|
|
1099
1106
|
} catch (r) {
|
|
1100
1107
|
console.warn("Failed to send typing indicator:", r);
|
|
1101
1108
|
}
|
|
1102
1109
|
},
|
|
1103
1110
|
async muteConversation(e, n) {
|
|
1104
1111
|
try {
|
|
1105
|
-
const r = { minutes: n }, o = await
|
|
1112
|
+
const r = { minutes: n }, o = await W().patch(`/v1/messaging/conversations/${e}/mute`, r), u = (o.data.data || o.data).muted_until || null, d = this.conversations.find((f) => f.id === e);
|
|
1106
1113
|
d && (d.is_muted = u !== null, d.muted_until = u);
|
|
1107
1114
|
} catch (r) {
|
|
1108
|
-
throw this.error =
|
|
1115
|
+
throw this.error = Z(r), r;
|
|
1109
1116
|
}
|
|
1110
1117
|
},
|
|
1111
1118
|
async unmuteConversation(e) {
|
|
1112
1119
|
try {
|
|
1113
|
-
const n = await
|
|
1120
|
+
const n = await W().patch(`/v1/messaging/conversations/${e}/mute`, {
|
|
1114
1121
|
minutes: 0
|
|
1115
1122
|
}), o = (n.data.data || n.data).muted_until || null, c = this.conversations.find((u) => u.id === e);
|
|
1116
1123
|
c && (c.is_muted = o !== null, c.muted_until = o);
|
|
1117
1124
|
} catch (n) {
|
|
1118
|
-
throw this.error =
|
|
1125
|
+
throw this.error = Z(n), n;
|
|
1119
1126
|
}
|
|
1120
1127
|
},
|
|
1121
1128
|
async updateConversationTitle(e, n) {
|
|
1122
1129
|
try {
|
|
1123
|
-
const r = await
|
|
1130
|
+
const r = await W().patch(`/v1/messaging/conversations/${e}`, {
|
|
1124
1131
|
title: n
|
|
1125
1132
|
}), o = r.data.data || r.data, c = typeof o?.title == "string" ? o.title : n, u = (d) => d.map((f) => f.id !== e ? f : {
|
|
1126
1133
|
...f,
|
|
@@ -1128,32 +1135,32 @@ const Qt = Di("messaging", {
|
|
|
1128
1135
|
});
|
|
1129
1136
|
this.conversations = u(this.conversations), this.requests = u(this.requests);
|
|
1130
1137
|
} catch (r) {
|
|
1131
|
-
throw this.error =
|
|
1138
|
+
throw this.error = Z(r), r;
|
|
1132
1139
|
}
|
|
1133
1140
|
},
|
|
1134
1141
|
async pinConversation(e, n) {
|
|
1135
1142
|
const r = this.conversations.find((c) => c.id === e), o = r?.is_pinned;
|
|
1136
1143
|
r && (r.is_pinned = n), this.conversations.sort(Xe);
|
|
1137
1144
|
try {
|
|
1138
|
-
await
|
|
1145
|
+
await W().patch(`/v1/messaging/conversations/${e}/pin`, { pinned: n });
|
|
1139
1146
|
} catch (c) {
|
|
1140
|
-
throw r && o !== void 0 && (r.is_pinned = o, this.conversations.sort(Xe)), this.error =
|
|
1147
|
+
throw r && o !== void 0 && (r.is_pinned = o, this.conversations.sort(Xe)), this.error = Z(c), c;
|
|
1141
1148
|
}
|
|
1142
1149
|
},
|
|
1143
1150
|
async archiveConversation(e, n) {
|
|
1144
1151
|
try {
|
|
1145
|
-
await
|
|
1152
|
+
await W().patch(`/v1/messaging/conversations/${e}/archive`, { archived: n });
|
|
1146
1153
|
const r = this.conversations.find((o) => o.id === e);
|
|
1147
1154
|
r && (r.is_archived = n);
|
|
1148
1155
|
} catch (r) {
|
|
1149
|
-
throw this.error =
|
|
1156
|
+
throw this.error = Z(r), r;
|
|
1150
1157
|
}
|
|
1151
1158
|
},
|
|
1152
1159
|
async deleteConversation(e) {
|
|
1153
1160
|
try {
|
|
1154
|
-
await
|
|
1161
|
+
await W().delete(`/v1/messaging/conversations/${e}`), this.conversations = this.conversations.filter((n) => n.id !== e), delete this.messages[e], delete this.typingUsers[e], delete this.conversationCursors[e], delete this.conversationHasMore[e], delete this.loadingMessages[e];
|
|
1155
1162
|
} catch (n) {
|
|
1156
|
-
throw this.error =
|
|
1163
|
+
throw this.error = Z(n), n;
|
|
1157
1164
|
}
|
|
1158
1165
|
},
|
|
1159
1166
|
async createDMConversation(e, n) {
|
|
@@ -1162,18 +1169,18 @@ const Qt = Di("messaging", {
|
|
|
1162
1169
|
user_id: e
|
|
1163
1170
|
};
|
|
1164
1171
|
n && (r.message = n);
|
|
1165
|
-
const o = await
|
|
1172
|
+
const o = await W().post("/v1/messaging/conversations/dm", r), c = o.data.data || o.data;
|
|
1166
1173
|
if (!Nn(c))
|
|
1167
1174
|
throw new Error("Invalid conversation payload from DM create endpoint.");
|
|
1168
1175
|
let u = qn(c) && Kt(c, e) ? He(c) : await this.fetchConversation(c.id);
|
|
1169
1176
|
return u = await jn(u, e), u.is_request === !0 ? (this.requests = rt(this.requests, u), this.conversations = this.conversations.filter((d) => d.id !== u.id), u) : (this.conversations = rt(this.conversations, u), this.requests = this.requests.filter((d) => d.id !== u.id), u);
|
|
1170
1177
|
} catch (r) {
|
|
1171
|
-
throw this.error =
|
|
1178
|
+
throw this.error = Z(r), r;
|
|
1172
1179
|
}
|
|
1173
1180
|
},
|
|
1174
1181
|
async createGroupConversation(e, n) {
|
|
1175
1182
|
try {
|
|
1176
|
-
const r = await
|
|
1183
|
+
const r = await W().post("/v1/messaging/conversations/group", {
|
|
1177
1184
|
title: e,
|
|
1178
1185
|
participant_ids: n
|
|
1179
1186
|
}), o = r.data.data || r.data;
|
|
@@ -1182,22 +1189,22 @@ const Qt = Di("messaging", {
|
|
|
1182
1189
|
const c = qn(o) ? o : await this.fetchConversation(o.id);
|
|
1183
1190
|
return this.conversations = rt(this.conversations, c), c;
|
|
1184
1191
|
} catch (r) {
|
|
1185
|
-
throw this.error =
|
|
1192
|
+
throw this.error = Z(r), r;
|
|
1186
1193
|
}
|
|
1187
1194
|
},
|
|
1188
1195
|
async addParticipants(e, n) {
|
|
1189
1196
|
try {
|
|
1190
|
-
await
|
|
1197
|
+
await W().post(`/v1/messaging/conversations/${e}/participants`, {
|
|
1191
1198
|
user_ids: n
|
|
1192
1199
|
// Changed from participant_ids to user_ids to match backend
|
|
1193
1200
|
}), await this.fetchConversation(e);
|
|
1194
1201
|
} catch (r) {
|
|
1195
|
-
throw this.error =
|
|
1202
|
+
throw this.error = Z(r), r;
|
|
1196
1203
|
}
|
|
1197
1204
|
},
|
|
1198
1205
|
async removeParticipant(e, n) {
|
|
1199
1206
|
try {
|
|
1200
|
-
await
|
|
1207
|
+
await W().delete(`/v1/messaging/conversations/${e}/participants/${n}`);
|
|
1201
1208
|
const r = ke()();
|
|
1202
1209
|
if (n === r.currentUser?.id) {
|
|
1203
1210
|
this.conversations = this.conversations.filter((o) => o.id !== e), this.requests = this.requests.filter((o) => o.id !== e), delete this.messages[e], delete this.typingUsers[e], delete this.conversationCursors[e], delete this.conversationHasMore[e], delete this.loadingMessages[e];
|
|
@@ -1205,7 +1212,7 @@ const Qt = Di("messaging", {
|
|
|
1205
1212
|
}
|
|
1206
1213
|
await this.fetchConversation(e);
|
|
1207
1214
|
} catch (r) {
|
|
1208
|
-
throw this.error =
|
|
1215
|
+
throw this.error = Z(r), r;
|
|
1209
1216
|
}
|
|
1210
1217
|
},
|
|
1211
1218
|
applyParticipantReadState(e) {
|
|
@@ -1229,28 +1236,28 @@ const Qt = Di("messaging", {
|
|
|
1229
1236
|
return;
|
|
1230
1237
|
this.messages[n] || (this.messages[n] = []);
|
|
1231
1238
|
const r = at({ ...e, attachments: e.attachments ?? [] }), o = this.messages[n];
|
|
1232
|
-
if (o.find((
|
|
1239
|
+
if (o.find((R) => R.id === r.id))
|
|
1233
1240
|
return;
|
|
1234
1241
|
const u = ke()();
|
|
1235
1242
|
if (r.author_id === u.currentUser?.id) {
|
|
1236
|
-
const
|
|
1237
|
-
if (
|
|
1238
|
-
const C = o[
|
|
1243
|
+
const R = o.findIndex((C) => C.id.startsWith("temp-"));
|
|
1244
|
+
if (R >= 0) {
|
|
1245
|
+
const C = o[R]?.id ?? "";
|
|
1239
1246
|
this.messages[n] = [
|
|
1240
|
-
...o.slice(0,
|
|
1247
|
+
...o.slice(0, R),
|
|
1241
1248
|
r,
|
|
1242
|
-
...o.slice(
|
|
1249
|
+
...o.slice(R + 1)
|
|
1243
1250
|
], this._pendingSendIds.delete(C), this.updateConversationLastMessage(n, r);
|
|
1244
1251
|
return;
|
|
1245
1252
|
}
|
|
1246
1253
|
}
|
|
1247
1254
|
const d = r.created_at;
|
|
1248
1255
|
let f = o.length;
|
|
1249
|
-
for (let
|
|
1250
|
-
const C = o[
|
|
1256
|
+
for (let R = o.length - 1; R >= 0; R--) {
|
|
1257
|
+
const C = o[R];
|
|
1251
1258
|
if (C && C.created_at <= d)
|
|
1252
1259
|
break;
|
|
1253
|
-
f =
|
|
1260
|
+
f = R;
|
|
1254
1261
|
}
|
|
1255
1262
|
const h = f === o.length;
|
|
1256
1263
|
this.messages[n] = [
|
|
@@ -1265,8 +1272,8 @@ const Qt = Di("messaging", {
|
|
|
1265
1272
|
},
|
|
1266
1273
|
removeMessage(e, n) {
|
|
1267
1274
|
const r = (h) => {
|
|
1268
|
-
const
|
|
1269
|
-
return delete
|
|
1275
|
+
const R = { ...h, is_deleted: !0 };
|
|
1276
|
+
return delete R.body, R;
|
|
1270
1277
|
};
|
|
1271
1278
|
let o = null;
|
|
1272
1279
|
const c = this.conversations.find((h) => h.id === e);
|
|
@@ -1284,7 +1291,11 @@ const Qt = Di("messaging", {
|
|
|
1284
1291
|
const f = d.findIndex((h) => h.id === n);
|
|
1285
1292
|
if (f >= 0) {
|
|
1286
1293
|
const h = d[f];
|
|
1287
|
-
h && (
|
|
1294
|
+
h && (this.messages[e] = [
|
|
1295
|
+
...d.slice(0, f),
|
|
1296
|
+
r(h),
|
|
1297
|
+
...d.slice(f + 1)
|
|
1298
|
+
]);
|
|
1288
1299
|
return;
|
|
1289
1300
|
}
|
|
1290
1301
|
o && this.addMessage(o);
|
|
@@ -1294,25 +1305,25 @@ const Qt = Di("messaging", {
|
|
|
1294
1305
|
try {
|
|
1295
1306
|
let f;
|
|
1296
1307
|
try {
|
|
1297
|
-
f = await
|
|
1308
|
+
f = await W().post(o, c);
|
|
1298
1309
|
} catch (v) {
|
|
1299
1310
|
if (!Fo(v))
|
|
1300
1311
|
throw v;
|
|
1301
|
-
f = await
|
|
1312
|
+
f = await W().post(o, c);
|
|
1302
1313
|
}
|
|
1303
|
-
const h =
|
|
1304
|
-
|
|
1314
|
+
const h = he(f.data) && "data" in f.data ? f.data.data : f.data, R = Dn(
|
|
1315
|
+
he(h) ? h.reactions : void 0
|
|
1305
1316
|
);
|
|
1306
|
-
(
|
|
1317
|
+
(R.length > 0 || d.length === 0) && this.updateMessageReactions(e, n, R);
|
|
1307
1318
|
try {
|
|
1308
|
-
const v = await
|
|
1309
|
-
|
|
1319
|
+
const v = await W().get(o), E = he(v.data) && "data" in v.data ? v.data.data : v.data, b = Dn(
|
|
1320
|
+
he(E) ? E.reactions : void 0
|
|
1310
1321
|
);
|
|
1311
1322
|
this.updateMessageReactions(e, n, b);
|
|
1312
1323
|
} catch {
|
|
1313
1324
|
}
|
|
1314
1325
|
} catch (f) {
|
|
1315
|
-
throw this.error =
|
|
1326
|
+
throw this.error = Z(f), f;
|
|
1316
1327
|
}
|
|
1317
1328
|
},
|
|
1318
1329
|
updateMessageReactions(e, n, r) {
|
|
@@ -1334,9 +1345,13 @@ const Qt = Di("messaging", {
|
|
|
1334
1345
|
const f = u[d];
|
|
1335
1346
|
if (!f) return;
|
|
1336
1347
|
const h = { ...f };
|
|
1337
|
-
r !== void 0 && (h.body = r), o !== void 0 && (h.edited_at = o), c !== void 0 && (h.meta = c),
|
|
1338
|
-
|
|
1339
|
-
|
|
1348
|
+
r !== void 0 && (h.body = r), o !== void 0 && (h.edited_at = o), c !== void 0 && (h.meta = c), this.messages[e] = [
|
|
1349
|
+
...u.slice(0, d),
|
|
1350
|
+
h,
|
|
1351
|
+
...u.slice(d + 1)
|
|
1352
|
+
];
|
|
1353
|
+
const R = this.conversations.find((v) => v.id === e);
|
|
1354
|
+
R?.last_message?.id === n && (R.last_message = h);
|
|
1340
1355
|
const C = this.requests.find((v) => v.id === e);
|
|
1341
1356
|
C?.last_message?.id === n && (C.last_message = h);
|
|
1342
1357
|
},
|
|
@@ -1367,7 +1382,7 @@ const Qt = Di("messaging", {
|
|
|
1367
1382
|
)];
|
|
1368
1383
|
if (n.length === 0)
|
|
1369
1384
|
return;
|
|
1370
|
-
const r = await
|
|
1385
|
+
const r = await W().get("/v1/presence/users", {
|
|
1371
1386
|
params: { ids: n }
|
|
1372
1387
|
}), o = r.data?.data?.items ?? r.data?.items ?? [];
|
|
1373
1388
|
for (const c of o) {
|
|
@@ -1387,14 +1402,14 @@ const Qt = Di("messaging", {
|
|
|
1387
1402
|
});
|
|
1388
1403
|
this.conversations = rt(this.conversations, r);
|
|
1389
1404
|
} catch (n) {
|
|
1390
|
-
throw this.error =
|
|
1405
|
+
throw this.error = Z(n), n;
|
|
1391
1406
|
}
|
|
1392
1407
|
},
|
|
1393
1408
|
async declineRequest(e) {
|
|
1394
1409
|
try {
|
|
1395
1410
|
await Pe.declineRequest(e), this.requests = this.requests.filter((n) => n.id !== e);
|
|
1396
1411
|
} catch (n) {
|
|
1397
|
-
throw this.error =
|
|
1412
|
+
throw this.error = Z(n), n;
|
|
1398
1413
|
}
|
|
1399
1414
|
},
|
|
1400
1415
|
async searchConversations(e, n, r) {
|
|
@@ -1402,7 +1417,7 @@ const Qt = Di("messaging", {
|
|
|
1402
1417
|
try {
|
|
1403
1418
|
const o = { search: e, limit: 20 };
|
|
1404
1419
|
n && (o.filter = n), typeof r == "string" && r.length > 0 && (o.folder_id = r);
|
|
1405
|
-
const c = await
|
|
1420
|
+
const c = await W().get("/v1/messaging/conversations", {
|
|
1406
1421
|
params: o
|
|
1407
1422
|
}), { items: u } = st(
|
|
1408
1423
|
c.data,
|
|
@@ -1410,7 +1425,7 @@ const Qt = Di("messaging", {
|
|
|
1410
1425
|
);
|
|
1411
1426
|
return u;
|
|
1412
1427
|
} catch (o) {
|
|
1413
|
-
return this.error =
|
|
1428
|
+
return this.error = Z(o), [];
|
|
1414
1429
|
} finally {
|
|
1415
1430
|
this.searchLoading = !1;
|
|
1416
1431
|
}
|
|
@@ -1418,12 +1433,12 @@ const Qt = Di("messaging", {
|
|
|
1418
1433
|
async searchMessages(e, n) {
|
|
1419
1434
|
this.searchLoading = !0;
|
|
1420
1435
|
try {
|
|
1421
|
-
const r = await
|
|
1436
|
+
const r = await W().get(`/v1/messaging/conversations/${e}/search`, {
|
|
1422
1437
|
params: { q: n }
|
|
1423
1438
|
}), o = r.data.data || r.data || [];
|
|
1424
1439
|
return this.searchResults = o, o;
|
|
1425
1440
|
} catch (r) {
|
|
1426
|
-
return this.error =
|
|
1441
|
+
return this.error = Z(r), [];
|
|
1427
1442
|
} finally {
|
|
1428
1443
|
this.searchLoading = !1;
|
|
1429
1444
|
}
|
|
@@ -1464,28 +1479,28 @@ const Qt = Di("messaging", {
|
|
|
1464
1479
|
}
|
|
1465
1480
|
});
|
|
1466
1481
|
function oc(e) {
|
|
1467
|
-
const n = Qt(), r = ke()(), o =
|
|
1482
|
+
const n = Qt(), r = ke()(), o = ye(!1), c = ye(null), u = ye(null), d = zt(), f = d !== null, h = 20, R = 250;
|
|
1468
1483
|
let C = 0, v = null, E = null;
|
|
1469
|
-
const b =
|
|
1484
|
+
const b = re(() => r.currentUser?.id), A = () => is(e)?.trim() ?? "";
|
|
1470
1485
|
function w() {
|
|
1471
1486
|
v && (clearTimeout(v), v = null), C = 0;
|
|
1472
1487
|
}
|
|
1473
1488
|
function p() {
|
|
1474
1489
|
!f || o.value || v || C >= h || (v = setTimeout(() => {
|
|
1475
|
-
v = null, C += 1,
|
|
1476
|
-
},
|
|
1490
|
+
v = null, C += 1, L();
|
|
1491
|
+
}, R));
|
|
1477
1492
|
}
|
|
1478
1493
|
function m(_) {
|
|
1479
1494
|
if (n.addMessage(_.message), _.message.author_id !== b.value) {
|
|
1480
|
-
const
|
|
1481
|
-
|
|
1495
|
+
const I = n.getConversationById(_.conversation_id);
|
|
1496
|
+
I && (I.unread_count = 0), n.markAsRead(_.conversation_id).catch(() => {
|
|
1482
1497
|
});
|
|
1483
1498
|
}
|
|
1484
1499
|
}
|
|
1485
1500
|
function y(_) {
|
|
1486
1501
|
n.applyParticipantReadState(_);
|
|
1487
1502
|
}
|
|
1488
|
-
function
|
|
1503
|
+
function F(_) {
|
|
1489
1504
|
n.applyMessageEdit(
|
|
1490
1505
|
_.conversation_id,
|
|
1491
1506
|
_.message.id,
|
|
@@ -1494,7 +1509,7 @@ function oc(e) {
|
|
|
1494
1509
|
_.message.meta
|
|
1495
1510
|
);
|
|
1496
1511
|
}
|
|
1497
|
-
function
|
|
1512
|
+
function q(_) {
|
|
1498
1513
|
n.removeMessage(_.conversation_id, _.message_id);
|
|
1499
1514
|
}
|
|
1500
1515
|
function J(_) {
|
|
@@ -1504,21 +1519,21 @@ function oc(e) {
|
|
|
1504
1519
|
_.reactions
|
|
1505
1520
|
);
|
|
1506
1521
|
}
|
|
1507
|
-
function
|
|
1508
|
-
const
|
|
1509
|
-
|
|
1510
|
-
(
|
|
1522
|
+
function G(_) {
|
|
1523
|
+
const I = n.getConversationById(_.conversation_id);
|
|
1524
|
+
I && (I.is_request = !1), n.requests = n.requests.filter(
|
|
1525
|
+
(fe) => fe.id !== _.conversation_id
|
|
1511
1526
|
);
|
|
1512
1527
|
}
|
|
1513
1528
|
function te(_) {
|
|
1514
|
-
_.removed_user_id === b.value && (
|
|
1529
|
+
_.removed_user_id === b.value && (X(), n.deleteConversation(_.conversation_id).catch(() => {
|
|
1515
1530
|
}));
|
|
1516
1531
|
}
|
|
1517
1532
|
function k(_) {
|
|
1518
|
-
const
|
|
1519
|
-
E && (E(), E = null),
|
|
1533
|
+
const I = u.value;
|
|
1534
|
+
E && (E(), E = null), I && (_ && !n.hasGlobalConversationSubscription(I) && Xi(I), n.unregisterDetailSubscription(I), u.value = null), o.value = !1;
|
|
1520
1535
|
}
|
|
1521
|
-
function
|
|
1536
|
+
function L() {
|
|
1522
1537
|
const _ = A();
|
|
1523
1538
|
if (!(o.value || !_)) {
|
|
1524
1539
|
if (!Ae()) {
|
|
@@ -1530,29 +1545,29 @@ function oc(e) {
|
|
|
1530
1545
|
E = Vi(_, {
|
|
1531
1546
|
onMessageSent: m,
|
|
1532
1547
|
onMessageRead: y,
|
|
1533
|
-
onMessageEdited:
|
|
1534
|
-
onMessageDeleted:
|
|
1548
|
+
onMessageEdited: F,
|
|
1549
|
+
onMessageDeleted: q,
|
|
1535
1550
|
onReactionToggled: J,
|
|
1536
|
-
onRequestAccepted:
|
|
1551
|
+
onRequestAccepted: G,
|
|
1537
1552
|
onParticipantRemoved: te
|
|
1538
1553
|
}), o.value = !0, u.value = _, n.registerDetailSubscription(_), w();
|
|
1539
|
-
} catch (
|
|
1540
|
-
c.value =
|
|
1554
|
+
} catch (I) {
|
|
1555
|
+
c.value = I instanceof Error ? I.message : "Failed to subscribe to conversation", console.error("ConversationChannel: Subscribe error", I);
|
|
1541
1556
|
}
|
|
1542
1557
|
}
|
|
1543
1558
|
}
|
|
1544
|
-
function
|
|
1545
|
-
o.value ||
|
|
1559
|
+
function V() {
|
|
1560
|
+
o.value || L();
|
|
1546
1561
|
}
|
|
1547
|
-
typeof window < "u" && window.addEventListener(Je(),
|
|
1548
|
-
const
|
|
1562
|
+
typeof window < "u" && window.addEventListener(Je(), V);
|
|
1563
|
+
const H = ht((_) => {
|
|
1549
1564
|
if (_ === "connected") {
|
|
1550
|
-
o.value ||
|
|
1565
|
+
o.value || L();
|
|
1551
1566
|
return;
|
|
1552
1567
|
}
|
|
1553
1568
|
(_ === "disconnected" || _ === "error") && (w(), k(!1));
|
|
1554
1569
|
});
|
|
1555
|
-
function
|
|
1570
|
+
function X() {
|
|
1556
1571
|
if (w(), !(!o.value || !u.value))
|
|
1557
1572
|
try {
|
|
1558
1573
|
k(!0), c.value = null;
|
|
@@ -1562,27 +1577,27 @@ function oc(e) {
|
|
|
1562
1577
|
}
|
|
1563
1578
|
return ot(
|
|
1564
1579
|
() => A(),
|
|
1565
|
-
(_,
|
|
1566
|
-
if (_ !==
|
|
1580
|
+
(_, I) => {
|
|
1581
|
+
if (_ !== I) {
|
|
1567
1582
|
if (w(), o.value && k(!0), !_) {
|
|
1568
1583
|
c.value = null;
|
|
1569
1584
|
return;
|
|
1570
1585
|
}
|
|
1571
|
-
|
|
1586
|
+
L();
|
|
1572
1587
|
}
|
|
1573
1588
|
}
|
|
1574
1589
|
), d !== null && qe(() => {
|
|
1575
|
-
w(),
|
|
1590
|
+
w(), H(), X(), typeof window < "u" && window.removeEventListener(Je(), V);
|
|
1576
1591
|
}), {
|
|
1577
|
-
isSubscribed:
|
|
1578
|
-
error:
|
|
1579
|
-
subscribe:
|
|
1580
|
-
unsubscribe:
|
|
1592
|
+
isSubscribed: re(() => o.value),
|
|
1593
|
+
error: re(() => c.value),
|
|
1594
|
+
subscribe: L,
|
|
1595
|
+
unsubscribe: X
|
|
1581
1596
|
};
|
|
1582
1597
|
}
|
|
1583
1598
|
const Ps = () => () => {
|
|
1584
1599
|
}, Ms = async () => {
|
|
1585
|
-
},
|
|
1600
|
+
}, _e = {
|
|
1586
1601
|
initializedEvent: "messenger-client:main-echo-initialized",
|
|
1587
1602
|
getEcho: () => null,
|
|
1588
1603
|
getConnectionStatus: () => "disconnected",
|
|
@@ -1590,25 +1605,25 @@ const Ps = () => () => {
|
|
|
1590
1605
|
reconnect: Ms
|
|
1591
1606
|
};
|
|
1592
1607
|
function ct() {
|
|
1593
|
-
return
|
|
1608
|
+
return _e.initializedEvent;
|
|
1594
1609
|
}
|
|
1595
1610
|
function ut() {
|
|
1596
|
-
return
|
|
1611
|
+
return _e.getEcho();
|
|
1597
1612
|
}
|
|
1598
1613
|
function $o() {
|
|
1599
|
-
return
|
|
1614
|
+
return _e.getConnectionStatus();
|
|
1600
1615
|
}
|
|
1601
1616
|
function Ho(e) {
|
|
1602
|
-
return
|
|
1617
|
+
return _e.onConnectionStatusChange(e);
|
|
1603
1618
|
}
|
|
1604
1619
|
async function Bo() {
|
|
1605
|
-
await
|
|
1620
|
+
await _e.reconnect();
|
|
1606
1621
|
}
|
|
1607
1622
|
function Vo(e) {
|
|
1608
|
-
e.initializedEvent && (
|
|
1623
|
+
e.initializedEvent && (_e.initializedEvent = e.initializedEvent), e.getEcho && (_e.getEcho = e.getEcho), e.getConnectionStatus && (_e.getConnectionStatus = e.getConnectionStatus), e.onConnectionStatusChange && (_e.onConnectionStatusChange = e.onConnectionStatusChange), e.reconnect && (_e.reconnect = e.reconnect);
|
|
1609
1624
|
}
|
|
1610
1625
|
function Xo() {
|
|
1611
|
-
|
|
1626
|
+
_e.initializedEvent = "messenger-client:main-echo-initialized", _e.getEcho = () => null, _e.getConnectionStatus = () => "disconnected", _e.onConnectionStatusChange = Ps, _e.reconnect = Ms;
|
|
1612
1627
|
}
|
|
1613
1628
|
const Wo = {
|
|
1614
1629
|
debug: () => {
|
|
@@ -1662,9 +1677,9 @@ function ac(e = {}) {
|
|
|
1662
1677
|
const o = Qo(e.source ?? "app"), c = {
|
|
1663
1678
|
...Ko,
|
|
1664
1679
|
...e.icons
|
|
1665
|
-
}, u =
|
|
1680
|
+
}, u = ye(o.getConnectionStatus()), d = ye(null), f = ye(0), h = ye(!1), R = ye(!1), C = ye(!1), v = ye(!1);
|
|
1666
1681
|
let E = null, b = null, A = null, w = null, p = null, m = null, y = null;
|
|
1667
|
-
const
|
|
1682
|
+
const F = re(() => u.value === "connected"), q = re(() => u.value === "connecting"), J = re(() => u.value === "disconnected"), G = re(() => u.value === "error"), te = re(() => J.value || G.value), k = re(() => {
|
|
1668
1683
|
switch (u.value) {
|
|
1669
1684
|
case "connecting":
|
|
1670
1685
|
return f.value > 0 ? "Reconnecting..." : "Connecting...";
|
|
@@ -1677,7 +1692,7 @@ function ac(e = {}) {
|
|
|
1677
1692
|
default:
|
|
1678
1693
|
return "Unknown connection state";
|
|
1679
1694
|
}
|
|
1680
|
-
}),
|
|
1695
|
+
}), L = re(() => {
|
|
1681
1696
|
switch (u.value) {
|
|
1682
1697
|
case "connected":
|
|
1683
1698
|
return "success";
|
|
@@ -1689,7 +1704,7 @@ function ac(e = {}) {
|
|
|
1689
1704
|
default:
|
|
1690
1705
|
return "medium";
|
|
1691
1706
|
}
|
|
1692
|
-
}),
|
|
1707
|
+
}), V = re(() => {
|
|
1693
1708
|
switch (u.value) {
|
|
1694
1709
|
case "connected":
|
|
1695
1710
|
return c.connected;
|
|
@@ -1702,12 +1717,12 @@ function ac(e = {}) {
|
|
|
1702
1717
|
default:
|
|
1703
1718
|
return c.unknown;
|
|
1704
1719
|
}
|
|
1705
|
-
}),
|
|
1720
|
+
}), H = async () => {
|
|
1706
1721
|
Vn.debug("Manual reconnect triggered"), f.value += 1, await o.reconnect();
|
|
1707
|
-
},
|
|
1722
|
+
}, X = (B, K = u.value) => {
|
|
1708
1723
|
if (B !== "connecting" && b && (clearTimeout(b), b = null), B === "disconnected" || B === "error") {
|
|
1709
|
-
const
|
|
1710
|
-
if (C.value = !0,
|
|
1724
|
+
const N = !v.value && K === B, Y = !R.value && (N || K === "connected" || K === "connecting");
|
|
1725
|
+
if (C.value = !0, Y) {
|
|
1711
1726
|
h.value = !1, A && clearTimeout(A), A = setTimeout(() => {
|
|
1712
1727
|
A = null, u.value !== "connected" && (h.value = !0);
|
|
1713
1728
|
}, 5e3);
|
|
@@ -1717,11 +1732,11 @@ function ac(e = {}) {
|
|
|
1717
1732
|
return;
|
|
1718
1733
|
}
|
|
1719
1734
|
if (B === "connected") {
|
|
1720
|
-
A && (clearTimeout(A), A = null), h.value = !1,
|
|
1735
|
+
A && (clearTimeout(A), A = null), h.value = !1, R.value = !1, C.value = !1;
|
|
1721
1736
|
return;
|
|
1722
1737
|
}
|
|
1723
1738
|
if (B === "connecting") {
|
|
1724
|
-
if (A && (clearTimeout(A), A = null),
|
|
1739
|
+
if (A && (clearTimeout(A), A = null), R.value) {
|
|
1725
1740
|
h.value = !0;
|
|
1726
1741
|
return;
|
|
1727
1742
|
}
|
|
@@ -1733,34 +1748,34 @@ function ac(e = {}) {
|
|
|
1733
1748
|
_("connected");
|
|
1734
1749
|
return;
|
|
1735
1750
|
}
|
|
1736
|
-
|
|
1751
|
+
R.value = !0, Vn.warn("Still connecting after 10s, treating as disconnected"), _("disconnected"), f.value += 1, o.reconnect();
|
|
1737
1752
|
}
|
|
1738
1753
|
}, 1e4);
|
|
1739
1754
|
}
|
|
1740
1755
|
}, _ = (B) => {
|
|
1741
|
-
const
|
|
1742
|
-
if (B === "connecting" &&
|
|
1743
|
-
u.value = "disconnected",
|
|
1756
|
+
const K = u.value;
|
|
1757
|
+
if (B === "connecting" && R.value) {
|
|
1758
|
+
u.value = "disconnected", X("disconnected", K);
|
|
1744
1759
|
return;
|
|
1745
1760
|
}
|
|
1746
|
-
u.value = B, B === "connecting" && (
|
|
1747
|
-
},
|
|
1748
|
-
const B = Wn(o),
|
|
1749
|
-
if (B === "connected" &&
|
|
1761
|
+
u.value = B, B === "connecting" && (K === "disconnected" || K === "error") && f.value === 0 && (f.value = 1), B === "connected" && (d.value = /* @__PURE__ */ new Date(), f.value = 0), X(B, K);
|
|
1762
|
+
}, I = () => {
|
|
1763
|
+
const B = Wn(o), K = u.value;
|
|
1764
|
+
if (B === "connected" && K !== "connected") {
|
|
1750
1765
|
_("connected");
|
|
1751
1766
|
return;
|
|
1752
1767
|
}
|
|
1753
|
-
if (B === "connecting" &&
|
|
1768
|
+
if (B === "connecting" && K !== "connecting") {
|
|
1754
1769
|
_("connecting");
|
|
1755
1770
|
return;
|
|
1756
1771
|
}
|
|
1757
|
-
if ((B === "unavailable" || B === "failed" || B === "disconnected") &&
|
|
1772
|
+
if ((B === "unavailable" || B === "failed" || B === "disconnected") && K !== "disconnected") {
|
|
1758
1773
|
_("disconnected");
|
|
1759
1774
|
return;
|
|
1760
1775
|
}
|
|
1761
|
-
const
|
|
1762
|
-
!B &&
|
|
1763
|
-
},
|
|
1776
|
+
const N = o.getConnectionStatus();
|
|
1777
|
+
!B && N === "connected" && K !== "connected" && _("connected");
|
|
1778
|
+
}, fe = () => {
|
|
1764
1779
|
if (p?.unbind && y && (p.unbind("connected", y.connected), p.unbind("connecting", y.connecting), p.unbind("disconnected", y.disconnected), p.unbind("unavailable", y.unavailable), p.unbind("error", y.error), p.unbind("state_change", y.stateChange)), p = o.getEchoConnection(), y = null, !p?.bind)
|
|
1765
1780
|
return;
|
|
1766
1781
|
y = {
|
|
@@ -1769,17 +1784,17 @@ function ac(e = {}) {
|
|
|
1769
1784
|
disconnected: () => _("disconnected"),
|
|
1770
1785
|
unavailable: () => _("disconnected"),
|
|
1771
1786
|
error: () => _("error"),
|
|
1772
|
-
stateChange: (
|
|
1773
|
-
const
|
|
1774
|
-
if (
|
|
1787
|
+
stateChange: (K) => {
|
|
1788
|
+
const N = K?.current;
|
|
1789
|
+
if (N === "connected") {
|
|
1775
1790
|
_("connected");
|
|
1776
1791
|
return;
|
|
1777
1792
|
}
|
|
1778
|
-
if (
|
|
1793
|
+
if (N === "connecting") {
|
|
1779
1794
|
_("connecting");
|
|
1780
1795
|
return;
|
|
1781
1796
|
}
|
|
1782
|
-
(
|
|
1797
|
+
(N === "unavailable" || N === "failed" || N === "disconnected") && _("disconnected");
|
|
1783
1798
|
}
|
|
1784
1799
|
}, p.bind("connected", y.connected), p.bind("connecting", y.connecting), p.bind("disconnected", y.disconnected), p.bind("unavailable", y.unavailable), p.bind("error", y.error), p.bind("state_change", y.stateChange);
|
|
1785
1800
|
const B = p.state ?? null;
|
|
@@ -1792,35 +1807,35 @@ function ac(e = {}) {
|
|
|
1792
1807
|
return;
|
|
1793
1808
|
}
|
|
1794
1809
|
(B === "unavailable" || B === "failed" || B === "disconnected") && _("disconnected");
|
|
1795
|
-
}, Se =
|
|
1796
|
-
if (!d.value || !
|
|
1810
|
+
}, Se = re(() => {
|
|
1811
|
+
if (!d.value || !F.value)
|
|
1797
1812
|
return null;
|
|
1798
|
-
const B = Date.now() - d.value.getTime(),
|
|
1799
|
-
return
|
|
1813
|
+
const B = Date.now() - d.value.getTime(), K = Math.floor(B / 6e4), N = Math.floor(B % 6e4 / 1e3);
|
|
1814
|
+
return K > 0 ? `${K}m ${N}s` : `${N}s`;
|
|
1800
1815
|
});
|
|
1801
1816
|
return jt(() => {
|
|
1802
|
-
u.value = o.getConnectionStatus(), E = o.onConnectionStatusChange(_),
|
|
1803
|
-
|
|
1804
|
-
}, window.addEventListener(o.initializedEvent, m),
|
|
1805
|
-
|
|
1817
|
+
u.value = o.getConnectionStatus(), E = o.onConnectionStatusChange(_), F.value && (d.value = /* @__PURE__ */ new Date()), X(u.value, u.value), v.value = !0, fe(), m = () => {
|
|
1818
|
+
fe(), I();
|
|
1819
|
+
}, window.addEventListener(o.initializedEvent, m), I(), w = setInterval(() => {
|
|
1820
|
+
I();
|
|
1806
1821
|
}, 3e3);
|
|
1807
1822
|
}), qe(() => {
|
|
1808
1823
|
E?.(), b && (clearTimeout(b), b = null), A && (clearTimeout(A), A = null), w && (clearInterval(w), w = null), m && (window.removeEventListener(o.initializedEvent, m), m = null), p?.unbind && y && (p.unbind("connected", y.connected), p.unbind("connecting", y.connecting), p.unbind("disconnected", y.disconnected), p.unbind("unavailable", y.unavailable), p.unbind("error", y.error), p.unbind("state_change", y.stateChange)), p = null, y = null;
|
|
1809
1824
|
}), {
|
|
1810
|
-
connectionStatus:
|
|
1811
|
-
isConnected:
|
|
1812
|
-
isConnecting:
|
|
1825
|
+
connectionStatus: re(() => u.value),
|
|
1826
|
+
isConnected: F,
|
|
1827
|
+
isConnecting: q,
|
|
1813
1828
|
isDisconnected: J,
|
|
1814
|
-
isError:
|
|
1829
|
+
isError: G,
|
|
1815
1830
|
hasConnectionIssues: te,
|
|
1816
1831
|
statusMessage: k,
|
|
1817
|
-
statusColor:
|
|
1818
|
-
statusIcon:
|
|
1819
|
-
showConnectionBanner:
|
|
1820
|
-
lastConnectionTime:
|
|
1832
|
+
statusColor: L,
|
|
1833
|
+
statusIcon: V,
|
|
1834
|
+
showConnectionBanner: re(() => h.value),
|
|
1835
|
+
lastConnectionTime: re(() => d.value),
|
|
1821
1836
|
connectionUptime: Se,
|
|
1822
|
-
reconnectAttempts:
|
|
1823
|
-
reconnect:
|
|
1837
|
+
reconnectAttempts: re(() => f.value),
|
|
1838
|
+
reconnect: H
|
|
1824
1839
|
};
|
|
1825
1840
|
}
|
|
1826
1841
|
const xs = () => {
|
|
@@ -1837,16 +1852,28 @@ function ea() {
|
|
|
1837
1852
|
}
|
|
1838
1853
|
const Me = Zt()("GlobalMessaging"), ta = 3, na = (e) => e.replace(/\/+$/, ""), sa = (e) => na(window.location.pathname) === `/messages/${e}`, ra = (e) => e.is_muted ? !0 : typeof e.muted_until == "string" && e.muted_until.length > 0;
|
|
1839
1854
|
function cc() {
|
|
1840
|
-
const e = Qt(), n = ke()(), r = Yo(), o = Vt(), c = zi(), u = zt(), { conversations: d, requestConversations: f } = Ni(e), h = /* @__PURE__ */ new Set(),
|
|
1855
|
+
const e = Qt(), n = ke()(), r = Yo(), o = Vt(), c = zi(), u = zt(), { conversations: d, requestConversations: f } = Ni(e), h = /* @__PURE__ */ new Set(), R = /* @__PURE__ */ new Map();
|
|
1841
1856
|
let C = !1;
|
|
1842
1857
|
function v(k) {
|
|
1843
|
-
const
|
|
1844
|
-
if (
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1858
|
+
const L = R.get(k);
|
|
1859
|
+
if (L) {
|
|
1860
|
+
if (R.delete(k), L.directBound) {
|
|
1861
|
+
const V = L.channel.subscription;
|
|
1862
|
+
if (V)
|
|
1863
|
+
for (const H of L.bindings)
|
|
1864
|
+
try {
|
|
1865
|
+
V.unbind(H.event, H.handler);
|
|
1866
|
+
} catch {
|
|
1867
|
+
}
|
|
1868
|
+
return;
|
|
1869
|
+
}
|
|
1870
|
+
if (typeof L.channel.stopListening == "function")
|
|
1871
|
+
for (const V of L.bindings)
|
|
1872
|
+
try {
|
|
1873
|
+
L.channel.stopListening(V.event, V.handler);
|
|
1874
|
+
} catch {
|
|
1875
|
+
}
|
|
1876
|
+
}
|
|
1850
1877
|
}
|
|
1851
1878
|
function E() {
|
|
1852
1879
|
for (const k of h)
|
|
@@ -1854,84 +1881,96 @@ function cc() {
|
|
|
1854
1881
|
h.clear();
|
|
1855
1882
|
}
|
|
1856
1883
|
function b(k) {
|
|
1857
|
-
const
|
|
1858
|
-
if (!
|
|
1859
|
-
const
|
|
1884
|
+
const L = Ae();
|
|
1885
|
+
if (!L || h.has(k)) return;
|
|
1886
|
+
const V = `conversation.${k}`;
|
|
1860
1887
|
v(k);
|
|
1861
|
-
const
|
|
1862
|
-
if (!Qi(
|
|
1863
|
-
Me.warn("Dropping malformed ConversationMessageSent event",
|
|
1888
|
+
const H = L.private(V), X = (N) => {
|
|
1889
|
+
if (!Qi(N)) {
|
|
1890
|
+
Me.warn("Dropping malformed ConversationMessageSent event", N);
|
|
1864
1891
|
return;
|
|
1865
1892
|
}
|
|
1866
|
-
const
|
|
1867
|
-
if (!
|
|
1868
|
-
e.addMessage(
|
|
1869
|
-
const
|
|
1870
|
-
if (
|
|
1871
|
-
const
|
|
1872
|
-
|
|
1893
|
+
const Y = N, M = n.currentUser?.id;
|
|
1894
|
+
if (!M || Y.message.author_id === M) return;
|
|
1895
|
+
e.addMessage(Y.message);
|
|
1896
|
+
const U = e.hasDetailSubscription(Y.conversation_id), ne = sa(Y.conversation_id);
|
|
1897
|
+
if (U || ne) {
|
|
1898
|
+
const oe = e.getConversationById(Y.conversation_id);
|
|
1899
|
+
oe && (oe.unread_count = 0), e.markAsRead(Y.conversation_id).catch(() => {
|
|
1873
1900
|
});
|
|
1874
1901
|
return;
|
|
1875
1902
|
}
|
|
1876
|
-
const
|
|
1877
|
-
if (
|
|
1878
|
-
const
|
|
1879
|
-
|
|
1903
|
+
const ue = e.getConversationById(Y.conversation_id);
|
|
1904
|
+
if (ue) {
|
|
1905
|
+
const oe = ra(ue);
|
|
1906
|
+
oe || ue.unread_count++, r(oe);
|
|
1880
1907
|
}
|
|
1881
|
-
}, _ = (
|
|
1882
|
-
if (!Yi(
|
|
1883
|
-
Me.warn("Dropping malformed ConversationMessageRead event",
|
|
1908
|
+
}, _ = (N) => {
|
|
1909
|
+
if (!Yi(N)) {
|
|
1910
|
+
Me.warn("Dropping malformed ConversationMessageRead event", N);
|
|
1884
1911
|
return;
|
|
1885
1912
|
}
|
|
1886
|
-
e.applyParticipantReadState(
|
|
1887
|
-
},
|
|
1888
|
-
if (!to(
|
|
1889
|
-
Me.warn("Dropping malformed MessageReactionToggled event",
|
|
1913
|
+
e.applyParticipantReadState(N);
|
|
1914
|
+
}, I = (N) => {
|
|
1915
|
+
if (!to(N)) {
|
|
1916
|
+
Me.warn("Dropping malformed MessageReactionToggled event", N);
|
|
1890
1917
|
return;
|
|
1891
1918
|
}
|
|
1892
|
-
const
|
|
1893
|
-
e.updateMessageReactions(
|
|
1894
|
-
},
|
|
1895
|
-
if (!Zi(
|
|
1896
|
-
Me.warn("Dropping malformed ConversationMessageEdited event",
|
|
1919
|
+
const Y = N;
|
|
1920
|
+
e.updateMessageReactions(Y.conversation_id, Y.message_id, Y.reactions);
|
|
1921
|
+
}, fe = (N) => {
|
|
1922
|
+
if (!Zi(N)) {
|
|
1923
|
+
Me.warn("Dropping malformed ConversationMessageEdited event", N);
|
|
1897
1924
|
return;
|
|
1898
1925
|
}
|
|
1899
|
-
const
|
|
1926
|
+
const Y = N;
|
|
1900
1927
|
e.applyMessageEdit(
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1928
|
+
Y.conversation_id,
|
|
1929
|
+
Y.message.id,
|
|
1930
|
+
Y.message.body,
|
|
1931
|
+
Y.message.edited_at,
|
|
1932
|
+
Y.message.meta
|
|
1906
1933
|
);
|
|
1907
|
-
}, Se = (
|
|
1908
|
-
if (!eo(
|
|
1909
|
-
Me.warn("Dropping malformed ConversationMessageDeleted event",
|
|
1934
|
+
}, Se = (N) => {
|
|
1935
|
+
if (!eo(N)) {
|
|
1936
|
+
Me.warn("Dropping malformed ConversationMessageDeleted event", N);
|
|
1910
1937
|
return;
|
|
1911
1938
|
}
|
|
1912
|
-
const
|
|
1913
|
-
e.removeMessage(
|
|
1914
|
-
}, B = (
|
|
1915
|
-
if (!no(
|
|
1916
|
-
Me.warn("Dropping malformed ConversationRequestAccepted event",
|
|
1939
|
+
const Y = N;
|
|
1940
|
+
e.removeMessage(Y.conversation_id, Y.message_id);
|
|
1941
|
+
}, B = (N) => {
|
|
1942
|
+
if (!no(N)) {
|
|
1943
|
+
Me.warn("Dropping malformed ConversationRequestAccepted event", N);
|
|
1917
1944
|
return;
|
|
1918
1945
|
}
|
|
1919
|
-
const
|
|
1920
|
-
|
|
1921
|
-
(
|
|
1946
|
+
const Y = N, M = e.getConversationById(Y.conversation_id);
|
|
1947
|
+
M && (M.is_request = !1), e.requests = e.requests.filter(
|
|
1948
|
+
(U) => U.id !== Y.conversation_id
|
|
1922
1949
|
);
|
|
1923
|
-
};
|
|
1924
|
-
|
|
1925
|
-
channel:
|
|
1950
|
+
}, K = H.subscription;
|
|
1951
|
+
K ? (K.bind("ConversationMessageSent", X), K.bind("ConversationMessageRead", _), K.bind("ConversationMessageEdited", fe), K.bind("ConversationMessageDeleted", Se), K.bind("MessageReactionToggled", I), K.bind("ConversationRequestAccepted", B), R.set(k, {
|
|
1952
|
+
channel: H,
|
|
1953
|
+
directBound: !0,
|
|
1954
|
+
bindings: [
|
|
1955
|
+
{ event: "ConversationMessageSent", handler: X },
|
|
1956
|
+
{ event: "ConversationMessageRead", handler: _ },
|
|
1957
|
+
{ event: "ConversationMessageEdited", handler: fe },
|
|
1958
|
+
{ event: "ConversationMessageDeleted", handler: Se },
|
|
1959
|
+
{ event: "MessageReactionToggled", handler: I },
|
|
1960
|
+
{ event: "ConversationRequestAccepted", handler: B }
|
|
1961
|
+
]
|
|
1962
|
+
})) : (H.listen(".ConversationMessageSent", X), H.listen(".ConversationMessageRead", _), H.listen(".ConversationMessageEdited", fe), H.listen(".ConversationMessageDeleted", Se), H.listen(".MessageReactionToggled", I), H.listen(".ConversationRequestAccepted", B), R.set(k, {
|
|
1963
|
+
channel: H,
|
|
1964
|
+
directBound: !1,
|
|
1926
1965
|
bindings: [
|
|
1927
|
-
{ event: ".ConversationMessageSent", handler:
|
|
1966
|
+
{ event: ".ConversationMessageSent", handler: X },
|
|
1928
1967
|
{ event: ".ConversationMessageRead", handler: _ },
|
|
1929
|
-
{ event: ".ConversationMessageEdited", handler:
|
|
1968
|
+
{ event: ".ConversationMessageEdited", handler: fe },
|
|
1930
1969
|
{ event: ".ConversationMessageDeleted", handler: Se },
|
|
1931
|
-
{ event: ".MessageReactionToggled", handler:
|
|
1970
|
+
{ event: ".MessageReactionToggled", handler: I },
|
|
1932
1971
|
{ event: ".ConversationRequestAccepted", handler: B }
|
|
1933
1972
|
]
|
|
1934
|
-
}), h.add(k), e.registerGlobalConversationSubscription(k);
|
|
1973
|
+
})), h.add(k), e.registerGlobalConversationSubscription(k);
|
|
1935
1974
|
}
|
|
1936
1975
|
function A() {
|
|
1937
1976
|
const k = Ae();
|
|
@@ -1939,72 +1978,72 @@ function cc() {
|
|
|
1939
1978
|
E();
|
|
1940
1979
|
return;
|
|
1941
1980
|
}
|
|
1942
|
-
for (const
|
|
1943
|
-
v(
|
|
1981
|
+
for (const L of h) {
|
|
1982
|
+
v(L);
|
|
1944
1983
|
try {
|
|
1945
|
-
k.leave(`conversation.${
|
|
1984
|
+
k.leave(`conversation.${L}`);
|
|
1946
1985
|
} catch {
|
|
1947
1986
|
}
|
|
1948
|
-
e.unregisterGlobalConversationSubscription(
|
|
1987
|
+
e.unregisterGlobalConversationSubscription(L);
|
|
1949
1988
|
}
|
|
1950
1989
|
h.clear();
|
|
1951
1990
|
}
|
|
1952
1991
|
function w() {
|
|
1953
1992
|
const k = Ae();
|
|
1954
1993
|
if (!k) return;
|
|
1955
|
-
const
|
|
1956
|
-
const
|
|
1957
|
-
for (const
|
|
1958
|
-
if (!
|
|
1994
|
+
const L = (() => {
|
|
1995
|
+
const H = [...e.conversations, ...e.requestConversations], X = /* @__PURE__ */ new Set(), _ = [];
|
|
1996
|
+
for (const I of H)
|
|
1997
|
+
if (!X.has(I.id) && (X.add(I.id), _.push(I), _.length >= ta))
|
|
1959
1998
|
break;
|
|
1960
1999
|
return _;
|
|
1961
|
-
})(),
|
|
1962
|
-
for (const
|
|
1963
|
-
if (!
|
|
2000
|
+
})(), V = new Set(L.map((H) => H.id));
|
|
2001
|
+
for (const H of h)
|
|
2002
|
+
if (!V.has(H) && !e.hasDetailSubscription(H)) {
|
|
1964
2003
|
try {
|
|
1965
|
-
v(
|
|
2004
|
+
v(H), k.leave(`conversation.${H}`);
|
|
1966
2005
|
} catch {
|
|
1967
2006
|
}
|
|
1968
|
-
h.delete(
|
|
2007
|
+
h.delete(H), e.unregisterGlobalConversationSubscription(H);
|
|
1969
2008
|
}
|
|
1970
|
-
for (const
|
|
1971
|
-
b(
|
|
2009
|
+
for (const H of L)
|
|
2010
|
+
b(H.id);
|
|
1972
2011
|
}
|
|
1973
2012
|
function p(k) {
|
|
1974
|
-
const
|
|
2013
|
+
const L = Nt({
|
|
1975
2014
|
status: k.status,
|
|
1976
2015
|
last_seen_at: k.last_seen_at ?? null
|
|
1977
2016
|
});
|
|
1978
|
-
|
|
2017
|
+
L.status !== null && e.updatePresenceForUser(
|
|
1979
2018
|
k.user_id,
|
|
1980
|
-
|
|
1981
|
-
|
|
2019
|
+
L.status,
|
|
2020
|
+
L.lastSeenAt
|
|
1982
2021
|
);
|
|
1983
2022
|
}
|
|
1984
2023
|
async function m() {
|
|
1985
2024
|
const k = [...new Set(
|
|
1986
|
-
e.conversations.filter((
|
|
2025
|
+
e.conversations.filter((L) => L.type === "dm" && typeof L.other_user_id == "string" && L.other_user_id.length > 0).map((L) => L.other_user_id)
|
|
1987
2026
|
)];
|
|
1988
2027
|
if (k.length !== 0)
|
|
1989
2028
|
try {
|
|
1990
|
-
const
|
|
2029
|
+
const L = await o.get("/v1/presence/users", {
|
|
1991
2030
|
params: { ids: k }
|
|
1992
|
-
}),
|
|
1993
|
-
for (const
|
|
1994
|
-
const
|
|
1995
|
-
|
|
2031
|
+
}), V = L.data?.data?.items ?? L.data?.items ?? [];
|
|
2032
|
+
for (const H of V) {
|
|
2033
|
+
const X = Nt(H);
|
|
2034
|
+
X.status !== null && e.updatePresenceForUser(H.id, X.status, X.lastSeenAt);
|
|
1996
2035
|
}
|
|
1997
|
-
} catch (
|
|
1998
|
-
Me.warn("Failed to refresh messaging presence snapshot",
|
|
2036
|
+
} catch (L) {
|
|
2037
|
+
Me.warn("Failed to refresh messaging presence snapshot", L);
|
|
1999
2038
|
}
|
|
2000
2039
|
}
|
|
2001
2040
|
function y() {
|
|
2002
2041
|
!Ae() || C || (Hi(p), C = !0);
|
|
2003
2042
|
}
|
|
2004
|
-
function
|
|
2043
|
+
function F() {
|
|
2005
2044
|
C && (Bi(), C = !1);
|
|
2006
2045
|
}
|
|
2007
|
-
const
|
|
2046
|
+
const q = ot(
|
|
2008
2047
|
d,
|
|
2009
2048
|
() => {
|
|
2010
2049
|
w();
|
|
@@ -2016,24 +2055,24 @@ function cc() {
|
|
|
2016
2055
|
w();
|
|
2017
2056
|
},
|
|
2018
2057
|
{ deep: !1, immediate: !0 }
|
|
2019
|
-
),
|
|
2058
|
+
), G = ot(
|
|
2020
2059
|
() => c.fullPath,
|
|
2021
2060
|
() => {
|
|
2022
2061
|
w();
|
|
2023
2062
|
}
|
|
2024
2063
|
), te = ht((k) => {
|
|
2025
|
-
k === "connected" ? (E(), w(),
|
|
2064
|
+
k === "connected" ? (E(), w(), F(), y(), m()) : (k === "disconnected" || k === "error") && (E(), F());
|
|
2026
2065
|
});
|
|
2027
2066
|
w(), y(), m(), Ae() || ms().then((k) => {
|
|
2028
|
-
k && (E(), w(),
|
|
2067
|
+
k && (E(), w(), F(), y(), m());
|
|
2029
2068
|
}).catch((k) => {
|
|
2030
2069
|
Me.warn("Failed to eagerly initialize messenger echo", k);
|
|
2031
2070
|
}), u !== null && qe(() => {
|
|
2032
|
-
|
|
2071
|
+
q(), J(), G(), te(), A(), F();
|
|
2033
2072
|
});
|
|
2034
2073
|
}
|
|
2035
2074
|
function uc() {
|
|
2036
|
-
const e =
|
|
2075
|
+
const e = ye(Ot());
|
|
2037
2076
|
let n = null;
|
|
2038
2077
|
return jt(() => {
|
|
2039
2078
|
e.value = Ot(), n = ji((r) => {
|
|
@@ -2042,9 +2081,9 @@ function uc() {
|
|
|
2042
2081
|
}), qe(() => {
|
|
2043
2082
|
n?.(), n = null;
|
|
2044
2083
|
}), {
|
|
2045
|
-
accessState:
|
|
2046
|
-
isBlocked:
|
|
2047
|
-
isSuspended:
|
|
2084
|
+
accessState: re(() => e.value),
|
|
2085
|
+
isBlocked: re(() => e.value !== "available"),
|
|
2086
|
+
isSuspended: re(() => e.value === "account_suspended")
|
|
2048
2087
|
};
|
|
2049
2088
|
}
|
|
2050
2089
|
const Ls = () => null, Is = {
|
|
@@ -2186,43 +2225,43 @@ function Ta(e, n, r) {
|
|
|
2186
2225
|
}
|
|
2187
2226
|
function lc() {
|
|
2188
2227
|
const e = ke()(), n = ia(), r = Vt(), o = va(n.clientIdStorageKey);
|
|
2189
|
-
let c = null, u = null, d = !1, f = It(n.accountLimitedUntilStorageKey), h = !1,
|
|
2228
|
+
let c = null, u = null, d = !1, f = It(n.accountLimitedUntilStorageKey), h = !1, R = !1, C = null, v = 0;
|
|
2190
2229
|
const E = () => ca(n) ? n.authTokenResolver() !== null : !0, b = () => {
|
|
2191
2230
|
c && (clearInterval(c), c = null);
|
|
2192
2231
|
}, A = () => {
|
|
2193
2232
|
u && (clearTimeout(u), u = null);
|
|
2194
2233
|
}, w = () => {
|
|
2195
2234
|
b(), c = setInterval(() => {
|
|
2196
|
-
|
|
2235
|
+
L();
|
|
2197
2236
|
}, n.heartbeatIntervalMs);
|
|
2198
|
-
}, p = (
|
|
2199
|
-
f || console.warn(
|
|
2200
|
-
}, m = async (
|
|
2201
|
-
if (!(!d ||
|
|
2237
|
+
}, p = (I) => {
|
|
2238
|
+
f || console.warn(I), ya(n.accountLimitedUntilStorageKey), f = !0, d = !1, C = null, b(), A();
|
|
2239
|
+
}, m = async (I) => {
|
|
2240
|
+
if (!(!d || R || f || h) && E() && C !== I)
|
|
2202
2241
|
try {
|
|
2203
|
-
await r.patch(n.statusUrl, { status:
|
|
2204
|
-
} catch (
|
|
2205
|
-
if (xt(
|
|
2242
|
+
await r.patch(n.statusUrl, { status: I }), C = I;
|
|
2243
|
+
} catch (fe) {
|
|
2244
|
+
if (xt(fe)) {
|
|
2206
2245
|
p("[Presence] Presence updates paused: account is temporarily limited");
|
|
2207
2246
|
return;
|
|
2208
2247
|
}
|
|
2209
|
-
Lt(
|
|
2248
|
+
Lt(fe) && (h = !0, d = !1, C = null, b(), A());
|
|
2210
2249
|
}
|
|
2211
2250
|
}, y = () => {
|
|
2212
|
-
A(), !(!d ||
|
|
2251
|
+
A(), !(!d || R || f || h || document.visibilityState !== "visible") && (u = setTimeout(() => {
|
|
2213
2252
|
u = null, m("idle");
|
|
2214
2253
|
}, n.idleAfterMs));
|
|
2215
|
-
},
|
|
2216
|
-
if (
|
|
2254
|
+
}, F = () => {
|
|
2255
|
+
if (R || !d || f || h || document.visibilityState !== "visible")
|
|
2217
2256
|
return;
|
|
2218
|
-
const
|
|
2219
|
-
|
|
2220
|
-
},
|
|
2221
|
-
|
|
2257
|
+
const I = Date.now();
|
|
2258
|
+
I - v < n.activityDebounceMs || (v = I, m("online"), y());
|
|
2259
|
+
}, q = () => {
|
|
2260
|
+
F();
|
|
2222
2261
|
}, J = () => {
|
|
2223
|
-
typeof document > "u" || typeof window > "u" || (document.addEventListener("pointerdown",
|
|
2224
|
-
},
|
|
2225
|
-
typeof document > "u" || typeof window > "u" || (document.removeEventListener("pointerdown",
|
|
2262
|
+
typeof document > "u" || typeof window > "u" || (document.addEventListener("pointerdown", q, { passive: !0 }), document.addEventListener("keydown", q), document.addEventListener("touchstart", q, { passive: !0 }), window.addEventListener("focus", q));
|
|
2263
|
+
}, G = () => {
|
|
2264
|
+
typeof document > "u" || typeof window > "u" || (document.removeEventListener("pointerdown", q), document.removeEventListener("keydown", q), document.removeEventListener("touchstart", q), window.removeEventListener("focus", q));
|
|
2226
2265
|
}, te = async () => {
|
|
2227
2266
|
if (It(n.accountLimitedUntilStorageKey))
|
|
2228
2267
|
return f = !0, "account_limited";
|
|
@@ -2231,134 +2270,134 @@ function lc() {
|
|
|
2231
2270
|
client_id: o,
|
|
2232
2271
|
user_agent: n.userAgentResolver()
|
|
2233
2272
|
}), _a(n.accountLimitedUntilStorageKey), f = !1, h = !1, d = !0, C = null, "opened";
|
|
2234
|
-
} catch (
|
|
2235
|
-
return xt(
|
|
2273
|
+
} catch (I) {
|
|
2274
|
+
return xt(I) ? (p("[Presence] Session open skipped: account is temporarily limited"), "account_limited") : Lt(I) ? (h = !0, d = !1, C = null, b(), A(), "account_suspended") : "failed";
|
|
2236
2275
|
}
|
|
2237
2276
|
}, k = async () => {
|
|
2238
|
-
for (let
|
|
2277
|
+
for (let I = 0; I < ga; I += 1)
|
|
2239
2278
|
if (await te() !== "failed")
|
|
2240
2279
|
return;
|
|
2241
2280
|
console.warn("[Presence] Failed to open session");
|
|
2242
|
-
},
|
|
2281
|
+
}, L = async () => {
|
|
2243
2282
|
if (d && E())
|
|
2244
2283
|
try {
|
|
2245
2284
|
await r.post(n.sessionHeartbeatUrl, { client_id: o });
|
|
2246
|
-
} catch (
|
|
2247
|
-
if (xt(
|
|
2285
|
+
} catch (I) {
|
|
2286
|
+
if (xt(I)) {
|
|
2248
2287
|
p("[Presence] Heartbeat paused: account is temporarily limited");
|
|
2249
2288
|
return;
|
|
2250
2289
|
}
|
|
2251
|
-
Lt(
|
|
2290
|
+
Lt(I) && (h = !0, d = !1, C = null, b(), A());
|
|
2252
2291
|
}
|
|
2253
|
-
},
|
|
2292
|
+
}, V = () => {
|
|
2254
2293
|
if (!d)
|
|
2255
2294
|
return;
|
|
2256
2295
|
d = !1, C = null, A();
|
|
2257
|
-
const
|
|
2296
|
+
const I = Ta(
|
|
2258
2297
|
n.sessionCloseUrl,
|
|
2259
2298
|
o,
|
|
2260
2299
|
n.authTokenResolver()
|
|
2261
2300
|
);
|
|
2262
|
-
if (
|
|
2263
|
-
|
|
2301
|
+
if (I) {
|
|
2302
|
+
I.catch(() => {
|
|
2264
2303
|
});
|
|
2265
2304
|
return;
|
|
2266
2305
|
}
|
|
2267
2306
|
r.post(n.sessionCloseUrl, { client_id: o }).catch(() => {
|
|
2268
2307
|
});
|
|
2269
|
-
},
|
|
2270
|
-
if (!
|
|
2271
|
-
if (await k(),
|
|
2272
|
-
|
|
2308
|
+
}, H = async () => {
|
|
2309
|
+
if (!R) {
|
|
2310
|
+
if (await k(), R) {
|
|
2311
|
+
V();
|
|
2273
2312
|
return;
|
|
2274
2313
|
}
|
|
2275
2314
|
d && (w(), m("online"), y());
|
|
2276
2315
|
}
|
|
2277
|
-
},
|
|
2278
|
-
if (!
|
|
2316
|
+
}, X = () => {
|
|
2317
|
+
if (!R) {
|
|
2279
2318
|
if (document.visibilityState === "hidden") {
|
|
2280
|
-
|
|
2319
|
+
V(), b(), A();
|
|
2281
2320
|
return;
|
|
2282
2321
|
}
|
|
2283
2322
|
if (document.visibilityState === "visible" && !d) {
|
|
2284
|
-
f = It(n.accountLimitedUntilStorageKey), !f && !h &&
|
|
2323
|
+
f = It(n.accountLimitedUntilStorageKey), !f && !h && H();
|
|
2285
2324
|
return;
|
|
2286
2325
|
}
|
|
2287
|
-
document.visibilityState === "visible" && d && !f && !h &&
|
|
2326
|
+
document.visibilityState === "visible" && d && !f && !h && F();
|
|
2288
2327
|
}
|
|
2289
2328
|
}, _ = () => {
|
|
2290
|
-
|
|
2329
|
+
R || (V(), b(), A());
|
|
2291
2330
|
};
|
|
2292
2331
|
jt(async () => {
|
|
2293
2332
|
if (e.isAuthenticated ?? e.currentUser !== null) {
|
|
2294
|
-
if (await k(),
|
|
2295
|
-
|
|
2333
|
+
if (await k(), R) {
|
|
2334
|
+
V();
|
|
2296
2335
|
return;
|
|
2297
2336
|
}
|
|
2298
|
-
d && (w(), m("online"), y()), J(), document.addEventListener("visibilitychange",
|
|
2337
|
+
d && (w(), m("online"), y()), J(), document.addEventListener("visibilitychange", X), window.addEventListener("pagehide", _), window.addEventListener("beforeunload", _);
|
|
2299
2338
|
}
|
|
2300
2339
|
}), qe(() => {
|
|
2301
|
-
|
|
2340
|
+
R = !0, G(), A(), b(), V(), document.removeEventListener("visibilitychange", X), window.removeEventListener("pagehide", _), window.removeEventListener("beforeunload", _);
|
|
2302
2341
|
});
|
|
2303
2342
|
}
|
|
2304
2343
|
const Ea = 12e3;
|
|
2305
2344
|
function dc(e) {
|
|
2306
|
-
const n = Qt(), r = ke()(), o =
|
|
2345
|
+
const n = Qt(), r = ke()(), o = ye(!1), c = ye(null), u = ye(null), d = ye([]), f = /* @__PURE__ */ new Map(), h = zt(), R = h !== null, C = 20, v = 250;
|
|
2307
2346
|
let E = !1, b = null, A = 0, w = null;
|
|
2308
|
-
const p =
|
|
2347
|
+
const p = re(() => r.currentUser?.id), m = () => is(e)?.trim() ?? "", y = () => {
|
|
2309
2348
|
const M = u.value?.trim() ?? "";
|
|
2310
2349
|
if (M.length > 0)
|
|
2311
2350
|
return M;
|
|
2312
|
-
const
|
|
2313
|
-
return
|
|
2314
|
-
},
|
|
2315
|
-
const
|
|
2316
|
-
for (const
|
|
2317
|
-
n.removeTypingUser(M,
|
|
2351
|
+
const U = m();
|
|
2352
|
+
return U.length > 0 && (u.value = U), U;
|
|
2353
|
+
}, F = (M) => n.getTypingUsers(M), q = (M) => {
|
|
2354
|
+
const U = F(M);
|
|
2355
|
+
for (const ne of U)
|
|
2356
|
+
n.removeTypingUser(M, ne.id);
|
|
2318
2357
|
d.value = [];
|
|
2319
2358
|
}, J = (M) => {
|
|
2320
|
-
const
|
|
2321
|
-
|
|
2322
|
-
},
|
|
2359
|
+
const U = f.get(M);
|
|
2360
|
+
U && (clearTimeout(U), f.delete(M));
|
|
2361
|
+
}, G = () => {
|
|
2323
2362
|
for (const M of f.values())
|
|
2324
2363
|
clearTimeout(M);
|
|
2325
2364
|
f.clear();
|
|
2326
2365
|
}, te = () => {
|
|
2327
2366
|
w && (clearTimeout(w), w = null), A = 0;
|
|
2328
2367
|
}, k = () => {
|
|
2329
|
-
!
|
|
2330
|
-
w = null, A += 1,
|
|
2368
|
+
!R || o.value || w || A >= C || (w = setTimeout(() => {
|
|
2369
|
+
w = null, A += 1, X();
|
|
2331
2370
|
}, v));
|
|
2332
|
-
},
|
|
2371
|
+
}, L = (M, U) => {
|
|
2333
2372
|
J(M);
|
|
2334
|
-
const
|
|
2335
|
-
f.delete(M), n.removeTypingUser(
|
|
2373
|
+
const ne = setTimeout(() => {
|
|
2374
|
+
f.delete(M), n.removeTypingUser(U, M), d.value = d.value.filter((ue) => ue.id !== M);
|
|
2336
2375
|
}, Ea);
|
|
2337
|
-
f.set(M,
|
|
2338
|
-
},
|
|
2376
|
+
f.set(M, ne);
|
|
2377
|
+
}, V = () => {
|
|
2339
2378
|
E = !0, te();
|
|
2340
|
-
},
|
|
2379
|
+
}, H = (M) => {
|
|
2341
2380
|
try {
|
|
2342
2381
|
b && (b(), b = null), b = Wi(M, {
|
|
2343
|
-
onTypingStart:
|
|
2344
|
-
onTypingStop:
|
|
2382
|
+
onTypingStart: I,
|
|
2383
|
+
onTypingStop: fe
|
|
2345
2384
|
}), te(), o.value = !0, u.value = M;
|
|
2346
|
-
} catch (
|
|
2347
|
-
c.value =
|
|
2385
|
+
} catch (U) {
|
|
2386
|
+
c.value = U instanceof Error ? U.message : "Failed to subscribe to typing channel";
|
|
2348
2387
|
}
|
|
2349
|
-
},
|
|
2388
|
+
}, X = () => {
|
|
2350
2389
|
const M = m();
|
|
2351
2390
|
if (!(o.value || !M)) {
|
|
2352
2391
|
if (c.value = null, Ae() && Rn() === "connected") {
|
|
2353
|
-
|
|
2392
|
+
H(M);
|
|
2354
2393
|
return;
|
|
2355
2394
|
}
|
|
2356
|
-
E = !1, ms().then((
|
|
2357
|
-
if (E || o.value || !
|
|
2395
|
+
E = !1, ms().then((U) => {
|
|
2396
|
+
if (E || o.value || !U)
|
|
2358
2397
|
return;
|
|
2359
|
-
const
|
|
2360
|
-
if (
|
|
2361
|
-
|
|
2398
|
+
const ne = m();
|
|
2399
|
+
if (ne && ne === M && Ae() && Rn() === "connected") {
|
|
2400
|
+
H(ne);
|
|
2362
2401
|
return;
|
|
2363
2402
|
}
|
|
2364
2403
|
k();
|
|
@@ -2366,88 +2405,88 @@ function dc(e) {
|
|
|
2366
2405
|
}
|
|
2367
2406
|
}, _ = () => {
|
|
2368
2407
|
const M = u.value;
|
|
2369
|
-
if (
|
|
2408
|
+
if (V(), !(!o.value || !M))
|
|
2370
2409
|
try {
|
|
2371
|
-
b && (b(), b = null), Gi(M),
|
|
2372
|
-
} catch (
|
|
2373
|
-
c.value =
|
|
2410
|
+
b && (b(), b = null), Gi(M), G(), q(M), o.value = !1, u.value = null, c.value = null;
|
|
2411
|
+
} catch (U) {
|
|
2412
|
+
c.value = U instanceof Error ? U.message : "Failed to unsubscribe from typing channel";
|
|
2374
2413
|
}
|
|
2375
2414
|
};
|
|
2376
|
-
function
|
|
2415
|
+
function I(M) {
|
|
2377
2416
|
if (M.user_id === p.value)
|
|
2378
2417
|
return;
|
|
2379
|
-
const
|
|
2380
|
-
if (!
|
|
2418
|
+
const U = y();
|
|
2419
|
+
if (!U)
|
|
2381
2420
|
return;
|
|
2382
|
-
const
|
|
2421
|
+
const ne = {
|
|
2383
2422
|
id: M.user.id,
|
|
2384
2423
|
name: M.user.name,
|
|
2385
2424
|
...M.user.avatar !== void 0 ? { avatar: M.user.avatar } : {}
|
|
2386
2425
|
};
|
|
2387
|
-
d.value.some((
|
|
2426
|
+
d.value.some((ue) => ue.id === ne.id) || (d.value = [...d.value, ne]), n.addTypingUser(U, ne), L(M.user_id, U);
|
|
2388
2427
|
}
|
|
2389
|
-
function
|
|
2428
|
+
function fe(M) {
|
|
2390
2429
|
if (M.user_id === p.value)
|
|
2391
2430
|
return;
|
|
2392
2431
|
J(M.user_id);
|
|
2393
|
-
const
|
|
2394
|
-
|
|
2432
|
+
const U = y();
|
|
2433
|
+
U && (d.value = d.value.filter((ne) => ne.id !== M.user_id), n.removeTypingUser(U, M.user_id));
|
|
2395
2434
|
}
|
|
2396
|
-
const Se =
|
|
2435
|
+
const Se = re(() => {
|
|
2397
2436
|
const M = y();
|
|
2398
2437
|
if (!M)
|
|
2399
2438
|
return d.value;
|
|
2400
|
-
const
|
|
2439
|
+
const U = F(M);
|
|
2401
2440
|
if (d.value.length === 0)
|
|
2402
|
-
return
|
|
2403
|
-
if (
|
|
2441
|
+
return U;
|
|
2442
|
+
if (U.length === 0)
|
|
2404
2443
|
return d.value;
|
|
2405
|
-
const
|
|
2406
|
-
for (const
|
|
2407
|
-
|
|
2408
|
-
for (const
|
|
2409
|
-
|
|
2410
|
-
return [...
|
|
2411
|
-
}), B =
|
|
2444
|
+
const ne = /* @__PURE__ */ new Map();
|
|
2445
|
+
for (const ue of U)
|
|
2446
|
+
ne.set(ue.id, ue);
|
|
2447
|
+
for (const ue of d.value)
|
|
2448
|
+
ne.set(ue.id, ue);
|
|
2449
|
+
return [...ne.values()];
|
|
2450
|
+
}), B = re(() => {
|
|
2412
2451
|
const M = Se.value;
|
|
2413
2452
|
if (M.length === 0)
|
|
2414
2453
|
return "";
|
|
2415
|
-
const
|
|
2416
|
-
if (!
|
|
2454
|
+
const U = M[0];
|
|
2455
|
+
if (!U)
|
|
2417
2456
|
return "";
|
|
2418
2457
|
if (M.length === 1)
|
|
2419
|
-
return `${
|
|
2420
|
-
const
|
|
2421
|
-
if (!
|
|
2458
|
+
return `${U.name} is typing...`;
|
|
2459
|
+
const ne = M[1];
|
|
2460
|
+
if (!ne)
|
|
2422
2461
|
return `${M.length} people are typing...`;
|
|
2423
2462
|
if (M.length === 2)
|
|
2424
|
-
return `${
|
|
2425
|
-
const
|
|
2426
|
-
return
|
|
2427
|
-
}),
|
|
2428
|
-
m() && (b && (b(), b = null), o.value = !1, u.value = null,
|
|
2463
|
+
return `${U.name} and ${ne.name} are typing...`;
|
|
2464
|
+
const ue = M[2];
|
|
2465
|
+
return ue ? M.length === 3 ? `${U.name}, ${ne.name} and ${ue.name} are typing...` : `${M.length} people are typing...` : `${M.length} people are typing...`;
|
|
2466
|
+
}), K = re(() => Se.value.length > 0), N = () => {
|
|
2467
|
+
m() && (b && (b(), b = null), o.value = !1, u.value = null, X());
|
|
2429
2468
|
};
|
|
2430
|
-
typeof window < "u" && window.addEventListener(Je(),
|
|
2431
|
-
const
|
|
2469
|
+
typeof window < "u" && window.addEventListener(Je(), N);
|
|
2470
|
+
const Y = ht((M) => {
|
|
2432
2471
|
if (M === "connected") {
|
|
2433
|
-
o.value ||
|
|
2472
|
+
o.value || X();
|
|
2434
2473
|
return;
|
|
2435
2474
|
}
|
|
2436
2475
|
if (M === "disconnected" || M === "error") {
|
|
2437
|
-
|
|
2438
|
-
const
|
|
2439
|
-
|
|
2476
|
+
V(), b && (b(), b = null);
|
|
2477
|
+
const U = y();
|
|
2478
|
+
U && q(U), o.value = !1, u.value = null, G();
|
|
2440
2479
|
}
|
|
2441
2480
|
});
|
|
2442
2481
|
return h !== null && qe(() => {
|
|
2443
|
-
|
|
2482
|
+
V(), Y(), G(), _(), typeof window < "u" && window.removeEventListener(Je(), N);
|
|
2444
2483
|
}), {
|
|
2445
|
-
isSubscribed:
|
|
2446
|
-
error:
|
|
2484
|
+
isSubscribed: re(() => o.value),
|
|
2485
|
+
error: re(() => c.value),
|
|
2447
2486
|
typingUsers: Se,
|
|
2448
2487
|
formatTypingIndicator: B,
|
|
2449
|
-
hasTypingUsers:
|
|
2450
|
-
subscribe:
|
|
2488
|
+
hasTypingUsers: K,
|
|
2489
|
+
subscribe: X,
|
|
2451
2490
|
unsubscribe: _
|
|
2452
2491
|
};
|
|
2453
2492
|
}
|
|
@@ -3434,8 +3473,8 @@ function Oa() {
|
|
|
3434
3473
|
}, c.t = function(u, d) {
|
|
3435
3474
|
if (d & 1 && (u = c(u)), d & 8 || d & 4 && typeof u == "object" && u && u.__esModule) return u;
|
|
3436
3475
|
var f = /* @__PURE__ */ Object.create(null);
|
|
3437
|
-
if (c.r(f), Object.defineProperty(f, "default", { enumerable: !0, value: u }), d & 2 && typeof u != "string") for (var h in u) c.d(f, h, (function(
|
|
3438
|
-
return u[
|
|
3476
|
+
if (c.r(f), Object.defineProperty(f, "default", { enumerable: !0, value: u }), d & 2 && typeof u != "string") for (var h in u) c.d(f, h, (function(R) {
|
|
3477
|
+
return u[R];
|
|
3439
3478
|
}).bind(null, h));
|
|
3440
3479
|
return f;
|
|
3441
3480
|
}, c.n = function(u) {
|
|
@@ -3460,10 +3499,10 @@ function Oa() {
|
|
|
3460
3499
|
(function(r, o, c) {
|
|
3461
3500
|
var u = this && this.__extends || /* @__PURE__ */ (function() {
|
|
3462
3501
|
var w = function(p, m) {
|
|
3463
|
-
return w = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(y,
|
|
3464
|
-
y.__proto__ =
|
|
3465
|
-
} || function(y,
|
|
3466
|
-
for (var
|
|
3502
|
+
return w = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(y, F) {
|
|
3503
|
+
y.__proto__ = F;
|
|
3504
|
+
} || function(y, F) {
|
|
3505
|
+
for (var q in F) F.hasOwnProperty(q) && (y[q] = F[q]);
|
|
3467
3506
|
}, w(p, m);
|
|
3468
3507
|
};
|
|
3469
3508
|
return function(p, m) {
|
|
@@ -3485,13 +3524,13 @@ function Oa() {
|
|
|
3485
3524
|
return this._paddingCharacter ? (p + 2) / 3 * 4 | 0 : (p * 8 + 5) / 6 | 0;
|
|
3486
3525
|
}, w.prototype.encode = function(p) {
|
|
3487
3526
|
for (var m = "", y = 0; y < p.length - 2; y += 3) {
|
|
3488
|
-
var
|
|
3489
|
-
m += this._encodeByte(
|
|
3527
|
+
var F = p[y] << 16 | p[y + 1] << 8 | p[y + 2];
|
|
3528
|
+
m += this._encodeByte(F >>> 18 & 63), m += this._encodeByte(F >>> 12 & 63), m += this._encodeByte(F >>> 6 & 63), m += this._encodeByte(F >>> 0 & 63);
|
|
3490
3529
|
}
|
|
3491
|
-
var
|
|
3492
|
-
if (
|
|
3493
|
-
var
|
|
3494
|
-
m += this._encodeByte(
|
|
3530
|
+
var q = p.length - y;
|
|
3531
|
+
if (q > 0) {
|
|
3532
|
+
var F = p[y] << 16 | (q === 2 ? p[y + 1] << 8 : 0);
|
|
3533
|
+
m += this._encodeByte(F >>> 18 & 63), m += this._encodeByte(F >>> 12 & 63), q === 2 ? m += this._encodeByte(F >>> 6 & 63) : m += this._paddingCharacter || "", m += this._paddingCharacter || "";
|
|
3495
3534
|
}
|
|
3496
3535
|
return m;
|
|
3497
3536
|
}, w.prototype.maxDecodedLength = function(p) {
|
|
@@ -3501,11 +3540,11 @@ function Oa() {
|
|
|
3501
3540
|
}, w.prototype.decode = function(p) {
|
|
3502
3541
|
if (p.length === 0)
|
|
3503
3542
|
return new Uint8Array(0);
|
|
3504
|
-
for (var m = this._getPaddingLength(p), y = p.length - m,
|
|
3505
|
-
te = this._decodeChar(p.charCodeAt(J + 0)), k = this._decodeChar(p.charCodeAt(J + 1)),
|
|
3506
|
-
if (J < y - 1 && (te = this._decodeChar(p.charCodeAt(J)), k = this._decodeChar(p.charCodeAt(J + 1)),
|
|
3543
|
+
for (var m = this._getPaddingLength(p), y = p.length - m, F = new Uint8Array(this.maxDecodedLength(y)), q = 0, J = 0, G = 0, te = 0, k = 0, L = 0, V = 0; J < y - 4; J += 4)
|
|
3544
|
+
te = this._decodeChar(p.charCodeAt(J + 0)), k = this._decodeChar(p.charCodeAt(J + 1)), L = this._decodeChar(p.charCodeAt(J + 2)), V = this._decodeChar(p.charCodeAt(J + 3)), F[q++] = te << 2 | k >>> 4, F[q++] = k << 4 | L >>> 2, F[q++] = L << 6 | V, G |= te & d, G |= k & d, G |= L & d, G |= V & d;
|
|
3545
|
+
if (J < y - 1 && (te = this._decodeChar(p.charCodeAt(J)), k = this._decodeChar(p.charCodeAt(J + 1)), F[q++] = te << 2 | k >>> 4, G |= te & d, G |= k & d), J < y - 2 && (L = this._decodeChar(p.charCodeAt(J + 2)), F[q++] = k << 4 | L >>> 2, G |= L & d), J < y - 3 && (V = this._decodeChar(p.charCodeAt(J + 3)), F[q++] = L << 6 | V, G |= V & d), G !== 0)
|
|
3507
3546
|
throw new Error("Base64Coder: incorrect characters for decoding");
|
|
3508
|
-
return
|
|
3547
|
+
return F;
|
|
3509
3548
|
}, w.prototype._encodeByte = function(p) {
|
|
3510
3549
|
var m = p;
|
|
3511
3550
|
return m += 65, m += 25 - p >>> 8 & 6, m += 51 - p >>> 8 & -75, m += 61 - p >>> 8 & -15, m += 62 - p >>> 8 & 3, String.fromCharCode(m);
|
|
@@ -3526,10 +3565,10 @@ function Oa() {
|
|
|
3526
3565
|
);
|
|
3527
3566
|
o.Coder = f;
|
|
3528
3567
|
var h = new f();
|
|
3529
|
-
function
|
|
3568
|
+
function R(w) {
|
|
3530
3569
|
return h.encode(w);
|
|
3531
3570
|
}
|
|
3532
|
-
o.encode =
|
|
3571
|
+
o.encode = R;
|
|
3533
3572
|
function C(w) {
|
|
3534
3573
|
return h.decode(w);
|
|
3535
3574
|
}
|
|
@@ -3599,7 +3638,7 @@ function Oa() {
|
|
|
3599
3638
|
return v;
|
|
3600
3639
|
}
|
|
3601
3640
|
o.encodedLength = h;
|
|
3602
|
-
function
|
|
3641
|
+
function R(C) {
|
|
3603
3642
|
for (var v = [], E = 0; E < C.length; E++) {
|
|
3604
3643
|
var b = C[E];
|
|
3605
3644
|
if (b & 128) {
|
|
@@ -3639,7 +3678,7 @@ function Oa() {
|
|
|
3639
3678
|
}
|
|
3640
3679
|
return v.join("");
|
|
3641
3680
|
}
|
|
3642
|
-
o.decode =
|
|
3681
|
+
o.decode = R;
|
|
3643
3682
|
}),
|
|
3644
3683
|
/* 2 */
|
|
3645
3684
|
/***/
|
|
@@ -3693,7 +3732,7 @@ function Oa() {
|
|
|
3693
3732
|
cdn_https: "https://js.pusher.com",
|
|
3694
3733
|
dependency_suffix: ""
|
|
3695
3734
|
}, h = f;
|
|
3696
|
-
class
|
|
3735
|
+
class R {
|
|
3697
3736
|
constructor(t) {
|
|
3698
3737
|
this.options = t, this.receivers = t.receivers || d, this.loading = {};
|
|
3699
3738
|
}
|
|
@@ -3703,28 +3742,28 @@ function Oa() {
|
|
|
3703
3742
|
l.loading[t].push(a);
|
|
3704
3743
|
else {
|
|
3705
3744
|
l.loading[t] = [a];
|
|
3706
|
-
var g =
|
|
3745
|
+
var g = j.createScriptRequest(l.getPath(t, s)), S = l.receivers.create(function(x) {
|
|
3707
3746
|
if (l.receivers.remove(S), l.loading[t]) {
|
|
3708
|
-
var
|
|
3747
|
+
var z = l.loading[t];
|
|
3709
3748
|
delete l.loading[t];
|
|
3710
|
-
for (var Q = function(
|
|
3711
|
-
|
|
3712
|
-
}, ee = 0; ee <
|
|
3713
|
-
|
|
3749
|
+
for (var Q = function(de) {
|
|
3750
|
+
de || g.cleanup();
|
|
3751
|
+
}, ee = 0; ee < z.length; ee++)
|
|
3752
|
+
z[ee](x, Q);
|
|
3714
3753
|
}
|
|
3715
3754
|
});
|
|
3716
3755
|
g.send(S);
|
|
3717
3756
|
}
|
|
3718
3757
|
}
|
|
3719
3758
|
getRoot(t) {
|
|
3720
|
-
var s, a =
|
|
3759
|
+
var s, a = j.getDocument().location.protocol;
|
|
3721
3760
|
return t && t.useTLS || a === "https:" ? s = this.options.cdn_https : s = this.options.cdn_http, s.replace(/\/*$/, "") + "/" + this.options.version;
|
|
3722
3761
|
}
|
|
3723
3762
|
getPath(t, s) {
|
|
3724
3763
|
return this.getRoot(s) + "/" + t + this.options.suffix + ".js";
|
|
3725
3764
|
}
|
|
3726
3765
|
}
|
|
3727
|
-
var C = new u("_pusher_dependencies", "Pusher.DependenciesReceivers"), v = new
|
|
3766
|
+
var C = new u("_pusher_dependencies", "Pusher.DependenciesReceivers"), v = new R({
|
|
3728
3767
|
cdn_http: h.cdn_http,
|
|
3729
3768
|
cdn_https: h.cdn_https,
|
|
3730
3769
|
version: h.VERSION,
|
|
@@ -3776,12 +3815,12 @@ function Oa() {
|
|
|
3776
3815
|
super(t), Object.setPrototypeOf(this, new.target.prototype);
|
|
3777
3816
|
}
|
|
3778
3817
|
}
|
|
3779
|
-
class
|
|
3818
|
+
class F extends Error {
|
|
3780
3819
|
constructor(t) {
|
|
3781
3820
|
super(t), Object.setPrototypeOf(this, new.target.prototype);
|
|
3782
3821
|
}
|
|
3783
3822
|
}
|
|
3784
|
-
class
|
|
3823
|
+
class q extends Error {
|
|
3785
3824
|
constructor(t) {
|
|
3786
3825
|
super(t), Object.setPrototypeOf(this, new.target.prototype);
|
|
3787
3826
|
}
|
|
@@ -3791,7 +3830,7 @@ function Oa() {
|
|
|
3791
3830
|
super(t), Object.setPrototypeOf(this, new.target.prototype);
|
|
3792
3831
|
}
|
|
3793
3832
|
}
|
|
3794
|
-
class
|
|
3833
|
+
class G extends Error {
|
|
3795
3834
|
constructor(t) {
|
|
3796
3835
|
super(t), Object.setPrototypeOf(this, new.target.prototype);
|
|
3797
3836
|
}
|
|
@@ -3806,8 +3845,8 @@ function Oa() {
|
|
|
3806
3845
|
super(s), this.status = t, Object.setPrototypeOf(this, new.target.prototype);
|
|
3807
3846
|
}
|
|
3808
3847
|
}
|
|
3809
|
-
var
|
|
3810
|
-
const g =
|
|
3848
|
+
var V = function(i, t, s, a, l) {
|
|
3849
|
+
const g = j.createXHR();
|
|
3811
3850
|
g.open("POST", s.endpoint, !0), g.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
|
|
3812
3851
|
for (var S in s.headers)
|
|
3813
3852
|
g.setRequestHeader(S, s.headers[S]);
|
|
@@ -3819,13 +3858,13 @@ function Oa() {
|
|
|
3819
3858
|
return g.onreadystatechange = function() {
|
|
3820
3859
|
if (g.readyState === 4)
|
|
3821
3860
|
if (g.status === 200) {
|
|
3822
|
-
let x,
|
|
3861
|
+
let x, z = !1;
|
|
3823
3862
|
try {
|
|
3824
|
-
x = JSON.parse(g.responseText),
|
|
3863
|
+
x = JSON.parse(g.responseText), z = !0;
|
|
3825
3864
|
} catch {
|
|
3826
3865
|
l(new k(200, `JSON returned from ${a.toString()} endpoint was invalid, yet status code was 200. Data was: ${g.responseText}`), null);
|
|
3827
3866
|
}
|
|
3828
|
-
|
|
3867
|
+
z && l(null, x);
|
|
3829
3868
|
} else {
|
|
3830
3869
|
let x = "";
|
|
3831
3870
|
switch (a) {
|
|
@@ -3840,14 +3879,14 @@ function Oa() {
|
|
|
3840
3879
|
}
|
|
3841
3880
|
}, g.send(t), g;
|
|
3842
3881
|
};
|
|
3843
|
-
function
|
|
3844
|
-
return B(
|
|
3882
|
+
function H(i) {
|
|
3883
|
+
return B(fe(i));
|
|
3845
3884
|
}
|
|
3846
|
-
var
|
|
3885
|
+
var X = String.fromCharCode, _ = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", I = function(i) {
|
|
3847
3886
|
var t = i.charCodeAt(0);
|
|
3848
|
-
return t < 128 ? i : t < 2048 ?
|
|
3849
|
-
},
|
|
3850
|
-
return i.replace(/[^\x00-\x7F]/g,
|
|
3887
|
+
return t < 128 ? i : t < 2048 ? X(192 | t >>> 6) + X(128 | t & 63) : X(224 | t >>> 12 & 15) + X(128 | t >>> 6 & 63) + X(128 | t & 63);
|
|
3888
|
+
}, fe = function(i) {
|
|
3889
|
+
return i.replace(/[^\x00-\x7F]/g, I);
|
|
3851
3890
|
}, Se = function(i) {
|
|
3852
3891
|
var t = [0, 2, 1][i.length % 3], s = i.charCodeAt(0) << 16 | (i.length > 1 ? i.charCodeAt(1) : 0) << 8 | (i.length > 2 ? i.charCodeAt(2) : 0), a = [
|
|
3853
3892
|
_.charAt(s >>> 18),
|
|
@@ -3859,7 +3898,7 @@ function Oa() {
|
|
|
3859
3898
|
}, B = window.btoa || function(i) {
|
|
3860
3899
|
return i.replace(/[\s\S]{1,3}/g, Se);
|
|
3861
3900
|
};
|
|
3862
|
-
class
|
|
3901
|
+
class K {
|
|
3863
3902
|
constructor(t, s, a, l) {
|
|
3864
3903
|
this.clear = s, this.timer = t(() => {
|
|
3865
3904
|
this.timer && (this.timer = l(this.timer));
|
|
@@ -3872,33 +3911,33 @@ function Oa() {
|
|
|
3872
3911
|
this.timer && (this.clear(this.timer), this.timer = null);
|
|
3873
3912
|
}
|
|
3874
3913
|
}
|
|
3875
|
-
var
|
|
3876
|
-
function
|
|
3914
|
+
var N = K;
|
|
3915
|
+
function Y(i) {
|
|
3877
3916
|
window.clearTimeout(i);
|
|
3878
3917
|
}
|
|
3879
3918
|
function M(i) {
|
|
3880
3919
|
window.clearInterval(i);
|
|
3881
3920
|
}
|
|
3882
|
-
class
|
|
3921
|
+
class U extends N {
|
|
3883
3922
|
constructor(t, s) {
|
|
3884
|
-
super(setTimeout,
|
|
3923
|
+
super(setTimeout, Y, t, function(a) {
|
|
3885
3924
|
return s(), null;
|
|
3886
3925
|
});
|
|
3887
3926
|
}
|
|
3888
3927
|
}
|
|
3889
|
-
class
|
|
3928
|
+
class ne extends N {
|
|
3890
3929
|
constructor(t, s) {
|
|
3891
3930
|
super(setInterval, M, t, function(a) {
|
|
3892
3931
|
return s(), a;
|
|
3893
3932
|
});
|
|
3894
3933
|
}
|
|
3895
3934
|
}
|
|
3896
|
-
var
|
|
3935
|
+
var ue = {
|
|
3897
3936
|
now() {
|
|
3898
3937
|
return Date.now ? Date.now() : (/* @__PURE__ */ new Date()).valueOf();
|
|
3899
3938
|
},
|
|
3900
3939
|
defer(i) {
|
|
3901
|
-
return new
|
|
3940
|
+
return new U(0, i);
|
|
3902
3941
|
},
|
|
3903
3942
|
method(i, ...t) {
|
|
3904
3943
|
var s = Array.prototype.slice.call(arguments, 1);
|
|
@@ -3906,12 +3945,12 @@ function Oa() {
|
|
|
3906
3945
|
return a[i].apply(a, s.concat(arguments));
|
|
3907
3946
|
};
|
|
3908
3947
|
}
|
|
3909
|
-
},
|
|
3910
|
-
function
|
|
3948
|
+
}, oe = ue;
|
|
3949
|
+
function ve(i, ...t) {
|
|
3911
3950
|
for (var s = 0; s < t.length; s++) {
|
|
3912
3951
|
var a = t[s];
|
|
3913
3952
|
for (var l in a)
|
|
3914
|
-
a[l] && a[l].constructor && a[l].constructor === Object ? i[l] =
|
|
3953
|
+
a[l] && a[l].constructor && a[l].constructor === Object ? i[l] = ve(i[l] || {}, a[l]) : i[l] = a[l];
|
|
3915
3954
|
}
|
|
3916
3955
|
return i;
|
|
3917
3956
|
}
|
|
@@ -3935,34 +3974,34 @@ function Oa() {
|
|
|
3935
3974
|
for (var s in i)
|
|
3936
3975
|
Object.prototype.hasOwnProperty.call(i, s) && t(i[s], s, i);
|
|
3937
3976
|
}
|
|
3938
|
-
function
|
|
3977
|
+
function P(i) {
|
|
3939
3978
|
var t = [];
|
|
3940
3979
|
return T(i, function(s, a) {
|
|
3941
3980
|
t.push(a);
|
|
3942
3981
|
}), t;
|
|
3943
3982
|
}
|
|
3944
|
-
function
|
|
3983
|
+
function D(i) {
|
|
3945
3984
|
var t = [];
|
|
3946
3985
|
return T(i, function(s) {
|
|
3947
3986
|
t.push(s);
|
|
3948
3987
|
}), t;
|
|
3949
3988
|
}
|
|
3950
|
-
function
|
|
3989
|
+
function O(i, t, s) {
|
|
3951
3990
|
for (var a = 0; a < i.length; a++)
|
|
3952
3991
|
t.call(s || window, i[a], a, i);
|
|
3953
3992
|
}
|
|
3954
|
-
function
|
|
3993
|
+
function se(i, t) {
|
|
3955
3994
|
for (var s = [], a = 0; a < i.length; a++)
|
|
3956
3995
|
s.push(t(i[a], a, i, s));
|
|
3957
3996
|
return s;
|
|
3958
3997
|
}
|
|
3959
|
-
function
|
|
3998
|
+
function ae(i, t) {
|
|
3960
3999
|
var s = {};
|
|
3961
4000
|
return T(i, function(a, l) {
|
|
3962
4001
|
s[l] = t(a);
|
|
3963
4002
|
}), s;
|
|
3964
4003
|
}
|
|
3965
|
-
function
|
|
4004
|
+
function le(i, t) {
|
|
3966
4005
|
t = t || function(l) {
|
|
3967
4006
|
return !!l;
|
|
3968
4007
|
};
|
|
@@ -3988,27 +4027,27 @@ function Oa() {
|
|
|
3988
4027
|
return !0;
|
|
3989
4028
|
return !1;
|
|
3990
4029
|
}
|
|
3991
|
-
function
|
|
4030
|
+
function ge(i, t) {
|
|
3992
4031
|
for (var s = 0; s < i.length; s++)
|
|
3993
4032
|
if (!t(i[s], s, i))
|
|
3994
4033
|
return !1;
|
|
3995
4034
|
return !0;
|
|
3996
4035
|
}
|
|
3997
|
-
function
|
|
3998
|
-
return
|
|
3999
|
-
return typeof t == "object" && (t = Qe(t)), encodeURIComponent(
|
|
4036
|
+
function be(i) {
|
|
4037
|
+
return ae(i, function(t) {
|
|
4038
|
+
return typeof t == "object" && (t = Qe(t)), encodeURIComponent(H(t.toString()));
|
|
4000
4039
|
});
|
|
4001
4040
|
}
|
|
4002
4041
|
function Hs(i) {
|
|
4003
4042
|
var t = Re(i, function(a) {
|
|
4004
4043
|
return a !== void 0;
|
|
4005
|
-
}), s =
|
|
4044
|
+
}), s = se(Le(be(t)), oe.method("join", "=")).join("&");
|
|
4006
4045
|
return s;
|
|
4007
4046
|
}
|
|
4008
4047
|
function Bs(i) {
|
|
4009
4048
|
var t = [], s = [];
|
|
4010
4049
|
return (function a(l, g) {
|
|
4011
|
-
var S, x,
|
|
4050
|
+
var S, x, z;
|
|
4012
4051
|
switch (typeof l) {
|
|
4013
4052
|
case "object":
|
|
4014
4053
|
if (!l)
|
|
@@ -4017,14 +4056,14 @@ function Oa() {
|
|
|
4017
4056
|
if (t[S] === l)
|
|
4018
4057
|
return { $ref: s[S] };
|
|
4019
4058
|
if (t.push(l), s.push(g), Object.prototype.toString.apply(l) === "[object Array]")
|
|
4020
|
-
for (
|
|
4021
|
-
|
|
4059
|
+
for (z = [], S = 0; S < l.length; S += 1)
|
|
4060
|
+
z[S] = a(l[S], g + "[" + S + "]");
|
|
4022
4061
|
else {
|
|
4023
|
-
|
|
4062
|
+
z = {};
|
|
4024
4063
|
for (x in l)
|
|
4025
|
-
Object.prototype.hasOwnProperty.call(l, x) && (
|
|
4064
|
+
Object.prototype.hasOwnProperty.call(l, x) && (z[x] = a(l[x], g + "[" + JSON.stringify(x) + "]"));
|
|
4026
4065
|
}
|
|
4027
|
-
return
|
|
4066
|
+
return z;
|
|
4028
4067
|
case "number":
|
|
4029
4068
|
case "string":
|
|
4030
4069
|
case "boolean":
|
|
@@ -4065,16 +4104,16 @@ function Oa() {
|
|
|
4065
4104
|
Tt.log ? Tt.log(a) : Tt.logToConsole && t.bind(this)(a);
|
|
4066
4105
|
}
|
|
4067
4106
|
}
|
|
4068
|
-
var
|
|
4069
|
-
(s.headers !== void 0 || s.headersProvider != null) &&
|
|
4107
|
+
var ce = new Vs(), Xs = function(i, t, s, a, l) {
|
|
4108
|
+
(s.headers !== void 0 || s.headersProvider != null) && ce.warn(`To send headers with the ${a.toString()} request, you must use AJAX, rather than JSONP.`);
|
|
4070
4109
|
var g = i.nextAuthCallbackID.toString();
|
|
4071
4110
|
i.nextAuthCallbackID++;
|
|
4072
4111
|
var S = i.getDocument(), x = S.createElement("script");
|
|
4073
4112
|
i.auth_callbacks[g] = function(ee) {
|
|
4074
4113
|
l(null, ee);
|
|
4075
4114
|
};
|
|
4076
|
-
var
|
|
4077
|
-
x.src = s.endpoint + "?callback=" + encodeURIComponent(
|
|
4115
|
+
var z = "Pusher.auth_callbacks['" + g + "']";
|
|
4116
|
+
x.src = s.endpoint + "?callback=" + encodeURIComponent(z) + "&" + t;
|
|
4078
4117
|
var Q = S.getElementsByTagName("head")[0] || S.documentElement;
|
|
4079
4118
|
Q.insertBefore(x, Q.firstChild);
|
|
4080
4119
|
}, Ws = Xs;
|
|
@@ -4105,7 +4144,7 @@ function Oa() {
|
|
|
4105
4144
|
send(t) {
|
|
4106
4145
|
if (!this.request) {
|
|
4107
4146
|
var s = Hs(this.data), a = this.url + "/" + t.number + "?" + s;
|
|
4108
|
-
this.request =
|
|
4147
|
+
this.request = j.createScriptRequest(a), this.request.send(t);
|
|
4109
4148
|
}
|
|
4110
4149
|
}
|
|
4111
4150
|
cleanup() {
|
|
@@ -4114,8 +4153,8 @@ function Oa() {
|
|
|
4114
4153
|
}
|
|
4115
4154
|
var Ks = function(i, t) {
|
|
4116
4155
|
return function(s, a) {
|
|
4117
|
-
var l = "http" + (t ? "s" : "") + "://", g = l + (i.host || i.options.host) + i.options.path, S =
|
|
4118
|
-
d.remove(x), S.cleanup(), Q && Q.host && (i.host = Q.host), a && a(
|
|
4156
|
+
var l = "http" + (t ? "s" : "") + "://", g = l + (i.host || i.options.host) + i.options.path, S = j.createJSONPRequest(g, s), x = j.ScriptReceivers.create(function(z, Q) {
|
|
4157
|
+
d.remove(x), S.cleanup(), Q && Q.host && (i.host = Q.host), a && a(z, Q);
|
|
4119
4158
|
});
|
|
4120
4159
|
S.send(x);
|
|
4121
4160
|
};
|
|
@@ -4168,18 +4207,18 @@ function Oa() {
|
|
|
4168
4207
|
this._callbacks = {};
|
|
4169
4208
|
return;
|
|
4170
4209
|
}
|
|
4171
|
-
var l = t ? [mt(t)] :
|
|
4210
|
+
var l = t ? [mt(t)] : P(this._callbacks);
|
|
4172
4211
|
s || a ? this.removeCallback(l, s, a) : this.removeAllCallbacks(l);
|
|
4173
4212
|
}
|
|
4174
4213
|
removeCallback(t, s, a) {
|
|
4175
|
-
|
|
4176
|
-
this._callbacks[l] =
|
|
4214
|
+
O(t, function(l) {
|
|
4215
|
+
this._callbacks[l] = le(this._callbacks[l] || [], function(g) {
|
|
4177
4216
|
return s && s !== g.fn || a && a !== g.context;
|
|
4178
4217
|
}), this._callbacks[l].length === 0 && delete this._callbacks[l];
|
|
4179
4218
|
}, this);
|
|
4180
4219
|
}
|
|
4181
4220
|
removeAllCallbacks(t) {
|
|
4182
|
-
|
|
4221
|
+
O(t, function(s) {
|
|
4183
4222
|
delete this._callbacks[s];
|
|
4184
4223
|
}, this);
|
|
4185
4224
|
}
|
|
@@ -4201,7 +4240,7 @@ function Oa() {
|
|
|
4201
4240
|
return this.callbacks.remove(t, s, a), this;
|
|
4202
4241
|
}
|
|
4203
4242
|
unbind_global(t) {
|
|
4204
|
-
return t ? (this.global_callbacks =
|
|
4243
|
+
return t ? (this.global_callbacks = le(this.global_callbacks || [], (s) => s !== t), this) : (this.global_callbacks = [], this);
|
|
4205
4244
|
}
|
|
4206
4245
|
unbind_all() {
|
|
4207
4246
|
return this.unbind(), this.unbind_global(), this;
|
|
@@ -4219,7 +4258,7 @@ function Oa() {
|
|
|
4219
4258
|
}
|
|
4220
4259
|
class sr extends Te {
|
|
4221
4260
|
constructor(t, s, a, l, g) {
|
|
4222
|
-
super(), this.initialize =
|
|
4261
|
+
super(), this.initialize = j.transportConnectionInitializer, this.hooks = t, this.name = s, this.priority = a, this.key = l, this.options = g, this.state = "new", this.timeline = g.timeline, this.activityTimeout = g.activityTimeout, this.id = this.timeline.generateUniqueID();
|
|
4223
4262
|
}
|
|
4224
4263
|
handlesActivityChecks() {
|
|
4225
4264
|
return !!this.hooks.handlesActivityChecks;
|
|
@@ -4234,17 +4273,17 @@ function Oa() {
|
|
|
4234
4273
|
try {
|
|
4235
4274
|
this.socket = this.hooks.getSocket(t, this.options);
|
|
4236
4275
|
} catch (s) {
|
|
4237
|
-
return
|
|
4276
|
+
return oe.defer(() => {
|
|
4238
4277
|
this.onError(s), this.changeState("closed");
|
|
4239
4278
|
}), !1;
|
|
4240
4279
|
}
|
|
4241
|
-
return this.bindListeners(),
|
|
4280
|
+
return this.bindListeners(), ce.debug("Connecting", { transport: this.name, url: t }), this.changeState("connecting"), !0;
|
|
4242
4281
|
}
|
|
4243
4282
|
close() {
|
|
4244
4283
|
return this.socket ? (this.socket.close(), !0) : !1;
|
|
4245
4284
|
}
|
|
4246
4285
|
send(t) {
|
|
4247
|
-
return this.state === "open" ? (
|
|
4286
|
+
return this.state === "open" ? (oe.defer(() => {
|
|
4248
4287
|
this.socket && this.socket.send(t);
|
|
4249
4288
|
}), !0) : !1;
|
|
4250
4289
|
}
|
|
@@ -4293,7 +4332,7 @@ function Oa() {
|
|
|
4293
4332
|
})), this.emit(t, s);
|
|
4294
4333
|
}
|
|
4295
4334
|
buildTimelineMessage(t) {
|
|
4296
|
-
return
|
|
4335
|
+
return ve({ cid: this.id }, t);
|
|
4297
4336
|
}
|
|
4298
4337
|
}
|
|
4299
4338
|
class De {
|
|
@@ -4312,13 +4351,13 @@ function Oa() {
|
|
|
4312
4351
|
handlesActivityChecks: !1,
|
|
4313
4352
|
supportsPing: !1,
|
|
4314
4353
|
isInitialized: function() {
|
|
4315
|
-
return
|
|
4354
|
+
return !!j.getWebSocketAPI();
|
|
4316
4355
|
},
|
|
4317
4356
|
isSupported: function() {
|
|
4318
|
-
return
|
|
4357
|
+
return !!j.getWebSocketAPI();
|
|
4319
4358
|
},
|
|
4320
4359
|
getSocket: function(i) {
|
|
4321
|
-
return
|
|
4360
|
+
return j.createWebSocket(i);
|
|
4322
4361
|
}
|
|
4323
4362
|
}), on = {
|
|
4324
4363
|
urls: er,
|
|
@@ -4327,19 +4366,19 @@ function Oa() {
|
|
|
4327
4366
|
isInitialized: function() {
|
|
4328
4367
|
return !0;
|
|
4329
4368
|
}
|
|
4330
|
-
}, an =
|
|
4369
|
+
}, an = ve({
|
|
4331
4370
|
getSocket: function(i) {
|
|
4332
|
-
return
|
|
4371
|
+
return j.HTTPFactory.createStreamingSocket(i);
|
|
4333
4372
|
}
|
|
4334
|
-
}, on), cn =
|
|
4373
|
+
}, on), cn = ve({
|
|
4335
4374
|
getSocket: function(i) {
|
|
4336
|
-
return
|
|
4375
|
+
return j.HTTPFactory.createPollingSocket(i);
|
|
4337
4376
|
}
|
|
4338
4377
|
}, on), un = {
|
|
4339
4378
|
isSupported: function() {
|
|
4340
|
-
return
|
|
4379
|
+
return j.isXHRSupported();
|
|
4341
4380
|
}
|
|
4342
|
-
}, ir = new De(
|
|
4381
|
+
}, ir = new De(ve({}, an, un)), or = new De(ve({}, cn, un)), ar = {
|
|
4343
4382
|
ws: rr,
|
|
4344
4383
|
xhr_streaming: ir,
|
|
4345
4384
|
xhr_polling: or
|
|
@@ -4369,10 +4408,10 @@ function Oa() {
|
|
|
4369
4408
|
}
|
|
4370
4409
|
}), ln = {
|
|
4371
4410
|
isSupported: function(i) {
|
|
4372
|
-
var t =
|
|
4411
|
+
var t = j.isXDRSupported(i.useTLS);
|
|
4373
4412
|
return t;
|
|
4374
4413
|
}
|
|
4375
|
-
}, ur = new De(
|
|
4414
|
+
}, ur = new De(ve({}, an, ln)), lr = new De(ve({}, cn, ln));
|
|
4376
4415
|
Ye.xdr_streaming = ur, Ye.xdr_polling = lr, Ye.sockjs = cr;
|
|
4377
4416
|
var dr = Ye;
|
|
4378
4417
|
class hr extends Te {
|
|
@@ -4395,16 +4434,16 @@ function Oa() {
|
|
|
4395
4434
|
this.manager = t, this.transport = s, this.minPingDelay = a.minPingDelay, this.maxPingDelay = a.maxPingDelay, this.pingDelay = void 0;
|
|
4396
4435
|
}
|
|
4397
4436
|
createConnection(t, s, a, l) {
|
|
4398
|
-
l =
|
|
4437
|
+
l = ve({}, l, {
|
|
4399
4438
|
activityTimeout: this.pingDelay
|
|
4400
4439
|
});
|
|
4401
4440
|
var g = this.transport.createConnection(t, s, a, l), S = null, x = function() {
|
|
4402
|
-
g.unbind("open", x), g.bind("closed",
|
|
4403
|
-
},
|
|
4404
|
-
if (g.unbind("closed",
|
|
4441
|
+
g.unbind("open", x), g.bind("closed", z), S = oe.now();
|
|
4442
|
+
}, z = (Q) => {
|
|
4443
|
+
if (g.unbind("closed", z), Q.code === 1002 || Q.code === 1003)
|
|
4405
4444
|
this.manager.reportDeath();
|
|
4406
4445
|
else if (!Q.wasClean && S) {
|
|
4407
|
-
var ee =
|
|
4446
|
+
var ee = oe.now() - S;
|
|
4408
4447
|
ee < 2 * this.maxPingDelay && (this.manager.reportDeath(), this.pingDelay = Math.max(ee / 2, this.minPingDelay));
|
|
4409
4448
|
}
|
|
4410
4449
|
};
|
|
@@ -4481,7 +4520,7 @@ function Oa() {
|
|
|
4481
4520
|
}
|
|
4482
4521
|
send_event(t, s, a) {
|
|
4483
4522
|
var l = { event: t, data: s };
|
|
4484
|
-
return a && (l.channel = a),
|
|
4523
|
+
return a && (l.channel = a), ce.debug("Event sent", l), this.send(Ie.encodeMessage(l));
|
|
4485
4524
|
}
|
|
4486
4525
|
ping() {
|
|
4487
4526
|
this.transport.supportsPing() ? this.transport.ping() : this.send_event("pusher:ping", {});
|
|
@@ -4503,7 +4542,7 @@ function Oa() {
|
|
|
4503
4542
|
});
|
|
4504
4543
|
}
|
|
4505
4544
|
if (l !== void 0) {
|
|
4506
|
-
switch (
|
|
4545
|
+
switch (ce.debug("Event recd", l), l.event) {
|
|
4507
4546
|
case "pusher:error":
|
|
4508
4547
|
this.emit("error", {
|
|
4509
4548
|
type: "PusherError",
|
|
@@ -4574,7 +4613,7 @@ function Oa() {
|
|
|
4574
4613
|
this.transport.unbind("message", this.onMessage), this.transport.unbind("closed", this.onClosed);
|
|
4575
4614
|
}
|
|
4576
4615
|
finish(t, s) {
|
|
4577
|
-
this.callback(
|
|
4616
|
+
this.callback(ve({ transport: this.transport, action: t }, s));
|
|
4578
4617
|
}
|
|
4579
4618
|
}
|
|
4580
4619
|
class vr {
|
|
@@ -4582,13 +4621,13 @@ function Oa() {
|
|
|
4582
4621
|
this.timeline = t, this.options = s || {};
|
|
4583
4622
|
}
|
|
4584
4623
|
send(t, s) {
|
|
4585
|
-
this.timeline.isEmpty() || this.timeline.send(
|
|
4624
|
+
this.timeline.isEmpty() || this.timeline.send(j.TimelineTransport.getAgent(this, t), s);
|
|
4586
4625
|
}
|
|
4587
4626
|
}
|
|
4588
4627
|
class vt extends Te {
|
|
4589
4628
|
constructor(t, s) {
|
|
4590
4629
|
super(function(a, l) {
|
|
4591
|
-
|
|
4630
|
+
ce.debug("No callbacks on " + t + " for " + a);
|
|
4592
4631
|
}), this.name = t, this.pusher = s, this.subscribed = !1, this.subscriptionPending = !1, this.subscriptionCancelled = !1;
|
|
4593
4632
|
}
|
|
4594
4633
|
authorize(t, s) {
|
|
@@ -4599,7 +4638,7 @@ function Oa() {
|
|
|
4599
4638
|
throw new p("Event '" + t + "' does not start with 'client-'");
|
|
4600
4639
|
if (!this.subscribed) {
|
|
4601
4640
|
var a = A.buildLogSuffix("triggeringClientEvents");
|
|
4602
|
-
|
|
4641
|
+
ce.warn(`Client event triggered before channel 'subscription_succeeded' event . ${a}`);
|
|
4603
4642
|
}
|
|
4604
4643
|
return this.pusher.send_event(t, s, this.name);
|
|
4605
4644
|
}
|
|
@@ -4625,7 +4664,7 @@ function Oa() {
|
|
|
4625
4664
|
}
|
|
4626
4665
|
subscribe() {
|
|
4627
4666
|
this.subscribed || (this.subscriptionPending = !0, this.subscriptionCancelled = !1, this.authorize(this.pusher.connection.socket_id, (t, s) => {
|
|
4628
|
-
t ? (this.subscriptionPending = !1,
|
|
4667
|
+
t ? (this.subscriptionPending = !1, ce.error(t.toString()), this.emit("pusher:subscription_error", Object.assign({}, {
|
|
4629
4668
|
type: "AuthError",
|
|
4630
4669
|
error: t.message
|
|
4631
4670
|
}, t instanceof k ? { status: t.status } : {}))) : this.pusher.send_event("pusher:subscribe", {
|
|
@@ -4697,19 +4736,19 @@ function Oa() {
|
|
|
4697
4736
|
function x(ee) {
|
|
4698
4737
|
try {
|
|
4699
4738
|
Q(a.next(ee));
|
|
4700
|
-
} catch (
|
|
4701
|
-
S(
|
|
4739
|
+
} catch (de) {
|
|
4740
|
+
S(de);
|
|
4702
4741
|
}
|
|
4703
4742
|
}
|
|
4704
|
-
function
|
|
4743
|
+
function z(ee) {
|
|
4705
4744
|
try {
|
|
4706
4745
|
Q(a.throw(ee));
|
|
4707
|
-
} catch (
|
|
4708
|
-
S(
|
|
4746
|
+
} catch (de) {
|
|
4747
|
+
S(de);
|
|
4709
4748
|
}
|
|
4710
4749
|
}
|
|
4711
4750
|
function Q(ee) {
|
|
4712
|
-
ee.done ? g(ee.value) : l(ee.value).then(x,
|
|
4751
|
+
ee.done ? g(ee.value) : l(ee.value).then(x, z);
|
|
4713
4752
|
}
|
|
4714
4753
|
Q((a = a.apply(i, t || [])).next());
|
|
4715
4754
|
});
|
|
@@ -4728,7 +4767,7 @@ function Oa() {
|
|
|
4728
4767
|
this.members.setMyID(this.pusher.user.user_data.id);
|
|
4729
4768
|
else {
|
|
4730
4769
|
let S = A.buildLogSuffix("authorizationEndpoint");
|
|
4731
|
-
|
|
4770
|
+
ce.error(`Invalid auth response for channel '${this.name}', expected 'channel_data' field. ${S}, or the user should be signed in.`), s("Invalid auth response");
|
|
4732
4771
|
return;
|
|
4733
4772
|
}
|
|
4734
4773
|
s(a, l);
|
|
@@ -4801,32 +4840,32 @@ function Oa() {
|
|
|
4801
4840
|
}
|
|
4802
4841
|
handleEncryptedEvent(t, s) {
|
|
4803
4842
|
if (!this.key) {
|
|
4804
|
-
|
|
4843
|
+
ce.debug("Received encrypted event before key has been retrieved from the authEndpoint");
|
|
4805
4844
|
return;
|
|
4806
4845
|
}
|
|
4807
4846
|
if (!s.ciphertext || !s.nonce) {
|
|
4808
|
-
|
|
4847
|
+
ce.error("Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: " + s);
|
|
4809
4848
|
return;
|
|
4810
4849
|
}
|
|
4811
4850
|
let a = Object(yt.decode)(s.ciphertext);
|
|
4812
4851
|
if (a.length < this.nacl.secretbox.overheadLength) {
|
|
4813
|
-
|
|
4852
|
+
ce.error(`Expected encrypted event ciphertext length to be ${this.nacl.secretbox.overheadLength}, got: ${a.length}`);
|
|
4814
4853
|
return;
|
|
4815
4854
|
}
|
|
4816
4855
|
let l = Object(yt.decode)(s.nonce);
|
|
4817
4856
|
if (l.length < this.nacl.secretbox.nonceLength) {
|
|
4818
|
-
|
|
4857
|
+
ce.error(`Expected encrypted event nonce length to be ${this.nacl.secretbox.nonceLength}, got: ${l.length}`);
|
|
4819
4858
|
return;
|
|
4820
4859
|
}
|
|
4821
4860
|
let g = this.nacl.secretbox.open(a, l, this.key);
|
|
4822
4861
|
if (g === null) {
|
|
4823
|
-
|
|
4862
|
+
ce.debug("Failed to decrypt an event, probably because it was encrypted with a different key. Fetching a new key from the authEndpoint..."), this.authorize(this.pusher.connection.socket_id, (S, x) => {
|
|
4824
4863
|
if (S) {
|
|
4825
|
-
|
|
4864
|
+
ce.error(`Failed to make a request to the authEndpoint: ${x}. Unable to fetch new key, so dropping encrypted event`);
|
|
4826
4865
|
return;
|
|
4827
4866
|
}
|
|
4828
4867
|
if (g = this.nacl.secretbox.open(a, l, this.key), g === null) {
|
|
4829
|
-
|
|
4868
|
+
ce.error("Failed to decrypt event with new key. Dropping encrypted event");
|
|
4830
4869
|
return;
|
|
4831
4870
|
}
|
|
4832
4871
|
this.emit(t, this.getDataToEmit(g));
|
|
@@ -4847,7 +4886,7 @@ function Oa() {
|
|
|
4847
4886
|
class wr extends Te {
|
|
4848
4887
|
constructor(t, s) {
|
|
4849
4888
|
super(), this.state = "initialized", this.connection = null, this.key = t, this.options = s, this.timeline = this.options.timeline, this.usingTLS = this.options.useTLS, this.errorCallbacks = this.buildErrorCallbacks(), this.connectionCallbacks = this.buildConnectionCallbacks(this.errorCallbacks), this.handshakeCallbacks = this.buildHandshakeCallbacks(this.errorCallbacks);
|
|
4850
|
-
var a =
|
|
4889
|
+
var a = j.getNetwork();
|
|
4851
4890
|
a.bind("online", () => {
|
|
4852
4891
|
this.timeline.info({ netinfo: "online" }), (this.state === "connecting" || this.state === "unavailable") && this.retryIn(0);
|
|
4853
4892
|
}), a.bind("offline", () => {
|
|
@@ -4901,7 +4940,7 @@ function Oa() {
|
|
|
4901
4940
|
});
|
|
4902
4941
|
}
|
|
4903
4942
|
retryIn(t) {
|
|
4904
|
-
this.timeline.info({ action: "retry", delay: t }), t > 0 && this.emit("connecting_in", Math.round(t / 1e3)), this.retryTimer = new
|
|
4943
|
+
this.timeline.info({ action: "retry", delay: t }), t > 0 && this.emit("connecting_in", Math.round(t / 1e3)), this.retryTimer = new U(t || 0, () => {
|
|
4905
4944
|
this.disconnectInternally(), this.connect();
|
|
4906
4945
|
});
|
|
4907
4946
|
}
|
|
@@ -4909,7 +4948,7 @@ function Oa() {
|
|
|
4909
4948
|
this.retryTimer && (this.retryTimer.ensureAborted(), this.retryTimer = null);
|
|
4910
4949
|
}
|
|
4911
4950
|
setUnavailableTimer() {
|
|
4912
|
-
this.unavailableTimer = new
|
|
4951
|
+
this.unavailableTimer = new U(this.options.unavailableTimeout, () => {
|
|
4913
4952
|
this.updateState("unavailable");
|
|
4914
4953
|
});
|
|
4915
4954
|
}
|
|
@@ -4917,12 +4956,12 @@ function Oa() {
|
|
|
4917
4956
|
this.unavailableTimer && this.unavailableTimer.ensureAborted();
|
|
4918
4957
|
}
|
|
4919
4958
|
sendActivityCheck() {
|
|
4920
|
-
this.stopActivityCheck(), this.connection.ping(), this.activityTimer = new
|
|
4959
|
+
this.stopActivityCheck(), this.connection.ping(), this.activityTimer = new U(this.options.pongTimeout, () => {
|
|
4921
4960
|
this.timeline.error({ pong_timed_out: this.options.pongTimeout }), this.retryIn(0);
|
|
4922
4961
|
});
|
|
4923
4962
|
}
|
|
4924
4963
|
resetActivityCheck() {
|
|
4925
|
-
this.stopActivityCheck(), this.connection && !this.connection.handlesActivityChecks() && (this.activityTimer = new
|
|
4964
|
+
this.stopActivityCheck(), this.connection && !this.connection.handlesActivityChecks() && (this.activityTimer = new U(this.activityTimeout, () => {
|
|
4926
4965
|
this.sendActivityCheck();
|
|
4927
4966
|
}));
|
|
4928
4967
|
}
|
|
@@ -4930,7 +4969,7 @@ function Oa() {
|
|
|
4930
4969
|
this.activityTimer && this.activityTimer.ensureAborted();
|
|
4931
4970
|
}
|
|
4932
4971
|
buildConnectionCallbacks(t) {
|
|
4933
|
-
return
|
|
4972
|
+
return ve({}, t, {
|
|
4934
4973
|
message: (s) => {
|
|
4935
4974
|
this.resetActivityCheck(), this.emit("message", s);
|
|
4936
4975
|
},
|
|
@@ -4949,7 +4988,7 @@ function Oa() {
|
|
|
4949
4988
|
});
|
|
4950
4989
|
}
|
|
4951
4990
|
buildHandshakeCallbacks(t) {
|
|
4952
|
-
return
|
|
4991
|
+
return ve({}, t, {
|
|
4953
4992
|
connected: (s) => {
|
|
4954
4993
|
this.activityTimeout = Math.min(this.options.activityTimeout, s.activityTimeout, s.connection.activityTimeout || 1 / 0), this.clearUnavailableTimer(), this.setConnection(s.connection), this.socket_id = this.connection.id, this.updateState("connected", { socket_id: this.socket_id });
|
|
4955
4994
|
}
|
|
@@ -4993,7 +5032,7 @@ function Oa() {
|
|
|
4993
5032
|
var a = this.state;
|
|
4994
5033
|
if (this.state = t, a !== t) {
|
|
4995
5034
|
var l = t;
|
|
4996
|
-
l === "connected" && (l += " with new socket ID " + s.socket_id),
|
|
5035
|
+
l === "connected" && (l += " with new socket ID " + s.socket_id), ce.debug("State changed", a + " -> " + l), this.timeline.info({ state: t, params: s }), this.emit("state_change", { previous: a, current: t }), this.emit(t, s);
|
|
4997
5036
|
}
|
|
4998
5037
|
}
|
|
4999
5038
|
shouldRetry() {
|
|
@@ -5008,7 +5047,7 @@ function Oa() {
|
|
|
5008
5047
|
return this.channels[t] || (this.channels[t] = Er(t, s)), this.channels[t];
|
|
5009
5048
|
}
|
|
5010
5049
|
all() {
|
|
5011
|
-
return
|
|
5050
|
+
return D(this.channels);
|
|
5012
5051
|
}
|
|
5013
5052
|
find(t) {
|
|
5014
5053
|
return this.channels[t];
|
|
@@ -5090,27 +5129,27 @@ function Oa() {
|
|
|
5090
5129
|
this.strategies = t, this.loop = !!s.loop, this.failFast = !!s.failFast, this.timeout = s.timeout, this.timeoutLimit = s.timeoutLimit;
|
|
5091
5130
|
}
|
|
5092
5131
|
isSupported() {
|
|
5093
|
-
return we(this.strategies,
|
|
5132
|
+
return we(this.strategies, oe.method("isSupported"));
|
|
5094
5133
|
}
|
|
5095
5134
|
connect(t, s) {
|
|
5096
|
-
var a = this.strategies, l = 0, g = this.timeout, S = null, x = (
|
|
5135
|
+
var a = this.strategies, l = 0, g = this.timeout, S = null, x = (z, Q) => {
|
|
5097
5136
|
Q ? s(null, Q) : (l = l + 1, this.loop && (l = l % a.length), l < a.length ? (g && (g = g * 2, this.timeoutLimit && (g = Math.min(g, this.timeoutLimit))), S = this.tryStrategy(a[l], t, { timeout: g, failFast: this.failFast }, x)) : s(!0));
|
|
5098
5137
|
};
|
|
5099
5138
|
return S = this.tryStrategy(a[l], t, { timeout: g, failFast: this.failFast }, x), {
|
|
5100
5139
|
abort: function() {
|
|
5101
5140
|
S.abort();
|
|
5102
5141
|
},
|
|
5103
|
-
forceMinPriority: function(
|
|
5104
|
-
t =
|
|
5142
|
+
forceMinPriority: function(z) {
|
|
5143
|
+
t = z, S && S.forceMinPriority(z);
|
|
5105
5144
|
}
|
|
5106
5145
|
};
|
|
5107
5146
|
}
|
|
5108
5147
|
tryStrategy(t, s, a, l) {
|
|
5109
5148
|
var g = null, S = null;
|
|
5110
|
-
return a.timeout > 0 && (g = new
|
|
5149
|
+
return a.timeout > 0 && (g = new U(a.timeout, function() {
|
|
5111
5150
|
S.abort(), l(!0);
|
|
5112
|
-
})), S = t.connect(s, function(x,
|
|
5113
|
-
x && g && g.isRunning() && !a.failFast || (g && g.ensureAborted(), l(x,
|
|
5151
|
+
})), S = t.connect(s, function(x, z) {
|
|
5152
|
+
x && g && g.isRunning() && !a.failFast || (g && g.ensureAborted(), l(x, z));
|
|
5114
5153
|
}), {
|
|
5115
5154
|
abort: function() {
|
|
5116
5155
|
g && g.ensureAborted(), S.abort();
|
|
@@ -5126,7 +5165,7 @@ function Oa() {
|
|
|
5126
5165
|
this.strategies = t;
|
|
5127
5166
|
}
|
|
5128
5167
|
isSupported() {
|
|
5129
|
-
return we(this.strategies,
|
|
5168
|
+
return we(this.strategies, oe.method("isSupported"));
|
|
5130
5169
|
}
|
|
5131
5170
|
connect(t, s) {
|
|
5132
5171
|
return Rr(this.strategies, t, function(a, l) {
|
|
@@ -5135,7 +5174,7 @@ function Oa() {
|
|
|
5135
5174
|
Pr(l) && s(!0);
|
|
5136
5175
|
return;
|
|
5137
5176
|
}
|
|
5138
|
-
|
|
5177
|
+
O(l, function(x) {
|
|
5139
5178
|
x.forceMinPriority(S.transport.priority);
|
|
5140
5179
|
}), s(null, S);
|
|
5141
5180
|
};
|
|
@@ -5143,22 +5182,22 @@ function Oa() {
|
|
|
5143
5182
|
}
|
|
5144
5183
|
}
|
|
5145
5184
|
function Rr(i, t, s) {
|
|
5146
|
-
var a =
|
|
5185
|
+
var a = se(i, function(l, g, S, x) {
|
|
5147
5186
|
return l.connect(t, s(g, x));
|
|
5148
5187
|
});
|
|
5149
5188
|
return {
|
|
5150
5189
|
abort: function() {
|
|
5151
|
-
|
|
5190
|
+
O(a, Mr);
|
|
5152
5191
|
},
|
|
5153
5192
|
forceMinPriority: function(l) {
|
|
5154
|
-
|
|
5193
|
+
O(a, function(g) {
|
|
5155
5194
|
g.forceMinPriority(l);
|
|
5156
5195
|
});
|
|
5157
5196
|
}
|
|
5158
5197
|
};
|
|
5159
5198
|
}
|
|
5160
5199
|
function Pr(i) {
|
|
5161
|
-
return
|
|
5200
|
+
return ge(i, function(t) {
|
|
5162
5201
|
return !!t.error;
|
|
5163
5202
|
});
|
|
5164
5203
|
}
|
|
@@ -5174,7 +5213,7 @@ function Oa() {
|
|
|
5174
5213
|
}
|
|
5175
5214
|
connect(t, s) {
|
|
5176
5215
|
var a = this.usingTLS, l = xr(a), g = l && l.cacheSkipCount ? l.cacheSkipCount : 0, S = [this.strategy];
|
|
5177
|
-
if (l && l.timestamp + this.ttl >=
|
|
5216
|
+
if (l && l.timestamp + this.ttl >= oe.now()) {
|
|
5178
5217
|
var x = this.transports[l.transport];
|
|
5179
5218
|
x && (["ws", "wss"].includes(l.transport) || g > 3 ? (this.timeline.info({
|
|
5180
5219
|
cached: !0,
|
|
@@ -5185,8 +5224,8 @@ function Oa() {
|
|
|
5185
5224
|
failFast: !0
|
|
5186
5225
|
}))) : g++);
|
|
5187
5226
|
}
|
|
5188
|
-
var
|
|
5189
|
-
|
|
5227
|
+
var z = oe.now(), Q = S.pop().connect(t, function ee(de, tt) {
|
|
5228
|
+
de ? (fn(a), S.length > 0 ? (z = oe.now(), Q = S.pop().connect(t, ee)) : s(de)) : (Lr(a, tt.transport.name, oe.now() - z, g), s(null, tt));
|
|
5190
5229
|
});
|
|
5191
5230
|
return {
|
|
5192
5231
|
abort: function() {
|
|
@@ -5202,7 +5241,7 @@ function Oa() {
|
|
|
5202
5241
|
return "pusherTransport" + (i ? "TLS" : "NonTLS");
|
|
5203
5242
|
}
|
|
5204
5243
|
function xr(i) {
|
|
5205
|
-
var t =
|
|
5244
|
+
var t = j.getLocalStorage();
|
|
5206
5245
|
if (t)
|
|
5207
5246
|
try {
|
|
5208
5247
|
var s = t[St(i)];
|
|
@@ -5214,11 +5253,11 @@ function Oa() {
|
|
|
5214
5253
|
return null;
|
|
5215
5254
|
}
|
|
5216
5255
|
function Lr(i, t, s, a) {
|
|
5217
|
-
var l =
|
|
5256
|
+
var l = j.getLocalStorage();
|
|
5218
5257
|
if (l)
|
|
5219
5258
|
try {
|
|
5220
5259
|
l[St(i)] = Qe({
|
|
5221
|
-
timestamp:
|
|
5260
|
+
timestamp: oe.now(),
|
|
5222
5261
|
transport: t,
|
|
5223
5262
|
latency: s,
|
|
5224
5263
|
cacheSkipCount: a
|
|
@@ -5227,7 +5266,7 @@ function Oa() {
|
|
|
5227
5266
|
}
|
|
5228
5267
|
}
|
|
5229
5268
|
function fn(i) {
|
|
5230
|
-
var t =
|
|
5269
|
+
var t = j.getLocalStorage();
|
|
5231
5270
|
if (t)
|
|
5232
5271
|
try {
|
|
5233
5272
|
delete t[St(i)];
|
|
@@ -5242,7 +5281,7 @@ function Oa() {
|
|
|
5242
5281
|
return this.strategy.isSupported();
|
|
5243
5282
|
}
|
|
5244
5283
|
connect(t, s) {
|
|
5245
|
-
var a = this.strategy, l, g = new
|
|
5284
|
+
var a = this.strategy, l, g = new U(this.options.delay, function() {
|
|
5246
5285
|
l = a.connect(t, s);
|
|
5247
5286
|
});
|
|
5248
5287
|
return {
|
|
@@ -5303,7 +5342,7 @@ function Oa() {
|
|
|
5303
5342
|
hostNonTLS: i.httpHost + ":" + i.httpPort,
|
|
5304
5343
|
hostTLS: i.httpHost + ":" + i.httpsPort,
|
|
5305
5344
|
httpPath: i.httpPath
|
|
5306
|
-
}),
|
|
5345
|
+
}), z = {
|
|
5307
5346
|
loop: !0,
|
|
5308
5347
|
timeout: 15e3,
|
|
5309
5348
|
timeoutLimit: 6e4
|
|
@@ -5314,16 +5353,16 @@ function Oa() {
|
|
|
5314
5353
|
lives: 2,
|
|
5315
5354
|
minPingDelay: 1e4,
|
|
5316
5355
|
maxPingDelay: i.activityTimeout
|
|
5317
|
-
}),
|
|
5356
|
+
}), de = l("ws", "ws", 3, g, Q), tt = l("wss", "ws", 3, S, Q), Pi = l("sockjs", "sockjs", 1, x), bn = l("xhr_streaming", "xhr_streaming", 1, x, ee), Mi = l("xdr_streaming", "xdr_streaming", 1, x, ee), yn = l("xhr_polling", "xhr_polling", 1, x), ki = l("xdr_polling", "xdr_polling", 1, x), _n = new Ue([de], z), xi = new Ue([tt], z), Li = new Ue([Pi], z), Sn = new Ue([
|
|
5318
5357
|
new ze(je(bn), bn, Mi)
|
|
5319
|
-
],
|
|
5358
|
+
], z), Cn = new Ue([
|
|
5320
5359
|
new ze(je(yn), yn, ki)
|
|
5321
|
-
],
|
|
5360
|
+
], z), wn = new Ue([
|
|
5322
5361
|
new ze(je(Sn), new _t([
|
|
5323
5362
|
Sn,
|
|
5324
5363
|
new Ze(Cn, { delay: 4e3 })
|
|
5325
5364
|
]), Cn)
|
|
5326
|
-
],
|
|
5365
|
+
], z), Et = new ze(je(wn), wn, Li), At;
|
|
5327
5366
|
return t.useTLS ? At = new _t([
|
|
5328
5367
|
_n,
|
|
5329
5368
|
new Ze(Et, { delay: 2e3 })
|
|
@@ -5331,7 +5370,7 @@ function Oa() {
|
|
|
5331
5370
|
_n,
|
|
5332
5371
|
new Ze(xi, { delay: 2e3 }),
|
|
5333
5372
|
new Ze(Et, { delay: 5e3 })
|
|
5334
|
-
]), new kr(new Ir(new ze(je(
|
|
5373
|
+
]), new kr(new Ir(new ze(je(de), At, Et)), a, {
|
|
5335
5374
|
ttl: 18e5,
|
|
5336
5375
|
timeline: t.timeline,
|
|
5337
5376
|
useTLS: t.useTLS
|
|
@@ -5368,10 +5407,10 @@ function Oa() {
|
|
|
5368
5407
|
start(t) {
|
|
5369
5408
|
this.position = 0, this.xhr = this.hooks.getRequest(this), this.unloader = () => {
|
|
5370
5409
|
this.close();
|
|
5371
|
-
},
|
|
5410
|
+
}, j.addUnloadListener(this.unloader), this.xhr.open(this.method, this.url, !0), this.xhr.setRequestHeader && this.xhr.setRequestHeader("Content-Type", "application/json"), this.xhr.send(t);
|
|
5372
5411
|
}
|
|
5373
5412
|
close() {
|
|
5374
|
-
this.unloader && (
|
|
5413
|
+
this.unloader && (j.removeUnloadListener(this.unloader), this.unloader = null), this.xhr && (this.hooks.abortRequest(this.xhr), this.xhr = null);
|
|
5375
5414
|
}
|
|
5376
5415
|
onChunk(t, s) {
|
|
5377
5416
|
for (; ; ) {
|
|
@@ -5413,7 +5452,7 @@ function Oa() {
|
|
|
5413
5452
|
sendRaw(t) {
|
|
5414
5453
|
if (this.readyState === Oe.OPEN)
|
|
5415
5454
|
try {
|
|
5416
|
-
return
|
|
5455
|
+
return j.createSocketRequest("POST", pn(Br(this.location, this.session))).start(t), !0;
|
|
5417
5456
|
} catch {
|
|
5418
5457
|
return !1;
|
|
5419
5458
|
}
|
|
@@ -5468,7 +5507,7 @@ function Oa() {
|
|
|
5468
5507
|
this.onerror && this.onerror(t);
|
|
5469
5508
|
}
|
|
5470
5509
|
openStream() {
|
|
5471
|
-
this.stream =
|
|
5510
|
+
this.stream = j.createSocketRequest("POST", pn(this.hooks.getReceiveURL(this.location, this.session))), this.stream.bind("chunk", (t) => {
|
|
5472
5511
|
this.onChunk(t);
|
|
5473
5512
|
}), this.stream.bind("finished", (t) => {
|
|
5474
5513
|
this.hooks.onFinished(this, t);
|
|
@@ -5478,7 +5517,7 @@ function Oa() {
|
|
|
5478
5517
|
try {
|
|
5479
5518
|
this.stream.start();
|
|
5480
5519
|
} catch (t) {
|
|
5481
|
-
|
|
5520
|
+
oe.defer(() => {
|
|
5482
5521
|
this.onError(t), this.onClose(1006, "Could not start streaming", !1);
|
|
5483
5522
|
});
|
|
5484
5523
|
}
|
|
@@ -5506,7 +5545,7 @@ function Oa() {
|
|
|
5506
5545
|
return s[1] + t + s[3];
|
|
5507
5546
|
}
|
|
5508
5547
|
function gn(i) {
|
|
5509
|
-
return
|
|
5548
|
+
return j.randomInt(i);
|
|
5510
5549
|
}
|
|
5511
5550
|
function Xr(i) {
|
|
5512
5551
|
for (var t = [], s = 0; s < i; s++)
|
|
@@ -5540,7 +5579,7 @@ function Oa() {
|
|
|
5540
5579
|
}
|
|
5541
5580
|
}, Qr = Kr, Yr = {
|
|
5542
5581
|
getRequest: function(i) {
|
|
5543
|
-
var t =
|
|
5582
|
+
var t = j.getXHRAPI(), s = new t();
|
|
5544
5583
|
return s.onreadystatechange = s.onprogress = function() {
|
|
5545
5584
|
switch (s.readyState) {
|
|
5546
5585
|
case 3:
|
|
@@ -5605,7 +5644,7 @@ function Oa() {
|
|
|
5605
5644
|
return this.getDocument().location.protocol;
|
|
5606
5645
|
},
|
|
5607
5646
|
getAuthorizers() {
|
|
5608
|
-
return { ajax:
|
|
5647
|
+
return { ajax: V, jsonp: Ws };
|
|
5609
5648
|
},
|
|
5610
5649
|
onDocumentBody(i) {
|
|
5611
5650
|
document.body ? i() : setTimeout(() => {
|
|
@@ -5668,7 +5707,7 @@ function Oa() {
|
|
|
5668
5707
|
return (window.crypto || window.msCrypto).getRandomValues(new Uint32Array(1))[0] / Math.pow(2, 32);
|
|
5669
5708
|
}() * i);
|
|
5670
5709
|
}
|
|
5671
|
-
},
|
|
5710
|
+
}, j = ni, wt;
|
|
5672
5711
|
(function(i) {
|
|
5673
5712
|
i[i.ERROR = 3] = "ERROR", i[i.INFO = 6] = "INFO", i[i.DEBUG = 7] = "DEBUG";
|
|
5674
5713
|
})(wt || (wt = {}));
|
|
@@ -5678,7 +5717,7 @@ function Oa() {
|
|
|
5678
5717
|
this.key = t, this.session = s, this.events = [], this.options = a || {}, this.sent = 0, this.uniqueID = 0;
|
|
5679
5718
|
}
|
|
5680
5719
|
log(t, s) {
|
|
5681
|
-
t <= this.options.level && (this.events.push(
|
|
5720
|
+
t <= this.options.level && (this.events.push(ve({}, s, { timestamp: oe.now() })), this.options.limit && this.events.length > this.options.limit && this.events.shift());
|
|
5682
5721
|
}
|
|
5683
5722
|
error(t) {
|
|
5684
5723
|
this.log(et.ERROR, t);
|
|
@@ -5693,7 +5732,7 @@ function Oa() {
|
|
|
5693
5732
|
return this.events.length === 0;
|
|
5694
5733
|
}
|
|
5695
5734
|
send(t, s) {
|
|
5696
|
-
var a =
|
|
5735
|
+
var a = ve({
|
|
5697
5736
|
session: this.session,
|
|
5698
5737
|
bundle: this.sent + 1,
|
|
5699
5738
|
key: this.key,
|
|
@@ -5723,35 +5762,35 @@ function Oa() {
|
|
|
5723
5762
|
connect(t, s) {
|
|
5724
5763
|
if (this.isSupported()) {
|
|
5725
5764
|
if (this.priority < t)
|
|
5726
|
-
return vn(new
|
|
5765
|
+
return vn(new F(), s);
|
|
5727
5766
|
} else return vn(new te(), s);
|
|
5728
5767
|
var a = !1, l = this.transport.createConnection(this.name, this.priority, this.options.key, this.options), g = null, S = function() {
|
|
5729
5768
|
l.unbind("initialized", S), l.connect();
|
|
5730
5769
|
}, x = function() {
|
|
5731
|
-
g = Ee.createHandshake(l, function(
|
|
5732
|
-
a = !0, ee(), s(null,
|
|
5770
|
+
g = Ee.createHandshake(l, function(de) {
|
|
5771
|
+
a = !0, ee(), s(null, de);
|
|
5733
5772
|
});
|
|
5734
|
-
},
|
|
5735
|
-
ee(), s(
|
|
5773
|
+
}, z = function(de) {
|
|
5774
|
+
ee(), s(de);
|
|
5736
5775
|
}, Q = function() {
|
|
5737
5776
|
ee();
|
|
5738
|
-
var
|
|
5739
|
-
|
|
5777
|
+
var de;
|
|
5778
|
+
de = Qe(l), s(new q(de));
|
|
5740
5779
|
}, ee = function() {
|
|
5741
|
-
l.unbind("initialized", S), l.unbind("open", x), l.unbind("error",
|
|
5780
|
+
l.unbind("initialized", S), l.unbind("open", x), l.unbind("error", z), l.unbind("closed", Q);
|
|
5742
5781
|
};
|
|
5743
|
-
return l.bind("initialized", S), l.bind("open", x), l.bind("error",
|
|
5782
|
+
return l.bind("initialized", S), l.bind("open", x), l.bind("error", z), l.bind("closed", Q), l.initialize(), {
|
|
5744
5783
|
abort: () => {
|
|
5745
5784
|
a || (ee(), g ? g.close() : l.close());
|
|
5746
5785
|
},
|
|
5747
|
-
forceMinPriority: (
|
|
5748
|
-
a || this.priority <
|
|
5786
|
+
forceMinPriority: (de) => {
|
|
5787
|
+
a || this.priority < de && (g ? g.close() : l.close());
|
|
5749
5788
|
}
|
|
5750
5789
|
};
|
|
5751
5790
|
}
|
|
5752
5791
|
}
|
|
5753
5792
|
function vn(i, t) {
|
|
5754
|
-
return
|
|
5793
|
+
return oe.defer(function() {
|
|
5755
5794
|
t(i);
|
|
5756
5795
|
}), {
|
|
5757
5796
|
abort: function() {
|
|
@@ -5760,19 +5799,19 @@ function Oa() {
|
|
|
5760
5799
|
}
|
|
5761
5800
|
};
|
|
5762
5801
|
}
|
|
5763
|
-
const { Transports: ii } =
|
|
5802
|
+
const { Transports: ii } = j;
|
|
5764
5803
|
var oi = function(i, t, s, a, l, g) {
|
|
5765
5804
|
var S = ii[s];
|
|
5766
5805
|
if (!S)
|
|
5767
|
-
throw new
|
|
5768
|
-
var x = (!i.enabledTransports || ft(i.enabledTransports, t) !== -1) && (!i.disabledTransports || ft(i.disabledTransports, t) === -1),
|
|
5769
|
-
return x ? (l = Object.assign({ ignoreNullOrigin: i.ignoreNullOrigin }, l),
|
|
5806
|
+
throw new G(s);
|
|
5807
|
+
var x = (!i.enabledTransports || ft(i.enabledTransports, t) !== -1) && (!i.disabledTransports || ft(i.disabledTransports, t) === -1), z;
|
|
5808
|
+
return x ? (l = Object.assign({ ignoreNullOrigin: i.ignoreNullOrigin }, l), z = new ri(t, a, g ? g.getAssistant(S) : S, l)) : z = ai, z;
|
|
5770
5809
|
}, ai = {
|
|
5771
5810
|
isSupported: function() {
|
|
5772
5811
|
return !1;
|
|
5773
5812
|
},
|
|
5774
5813
|
connect: function(i, t) {
|
|
5775
|
-
var s =
|
|
5814
|
+
var s = oe.defer(function() {
|
|
5776
5815
|
t(new te());
|
|
5777
5816
|
});
|
|
5778
5817
|
return {
|
|
@@ -5789,7 +5828,7 @@ function Oa() {
|
|
|
5789
5828
|
throw "You must pass an options object";
|
|
5790
5829
|
if (i.cluster == null)
|
|
5791
5830
|
throw "Options object must provide a cluster";
|
|
5792
|
-
"disableStats" in i &&
|
|
5831
|
+
"disableStats" in i && ce.warn("The disableStats option is deprecated in favor of enableStats");
|
|
5793
5832
|
}
|
|
5794
5833
|
const ui = (i, t) => {
|
|
5795
5834
|
var s = "socket_id=" + encodeURIComponent(i.socketId);
|
|
@@ -5803,11 +5842,11 @@ function Oa() {
|
|
|
5803
5842
|
return s;
|
|
5804
5843
|
};
|
|
5805
5844
|
var li = (i) => {
|
|
5806
|
-
if (typeof
|
|
5845
|
+
if (typeof j.getAuthorizers()[i.transport] > "u")
|
|
5807
5846
|
throw `'${i.transport}' is not a recognized auth transport`;
|
|
5808
5847
|
return (t, s) => {
|
|
5809
5848
|
const a = ui(t, i);
|
|
5810
|
-
|
|
5849
|
+
j.getAuthorizers()[i.transport](j, a, i, w.UserAuthentication, s);
|
|
5811
5850
|
};
|
|
5812
5851
|
};
|
|
5813
5852
|
const di = (i, t) => {
|
|
@@ -5823,11 +5862,11 @@ function Oa() {
|
|
|
5823
5862
|
return s;
|
|
5824
5863
|
};
|
|
5825
5864
|
var hi = (i) => {
|
|
5826
|
-
if (typeof
|
|
5865
|
+
if (typeof j.getAuthorizers()[i.transport] > "u")
|
|
5827
5866
|
throw `'${i.transport}' is not a recognized auth transport`;
|
|
5828
5867
|
return (t, s) => {
|
|
5829
5868
|
const a = di(t, i);
|
|
5830
|
-
|
|
5869
|
+
j.getAuthorizers()[i.transport](j, a, i, w.ChannelAuthorization, s);
|
|
5831
5870
|
};
|
|
5832
5871
|
};
|
|
5833
5872
|
const fi = (i, t, s) => {
|
|
@@ -5876,7 +5915,7 @@ function Oa() {
|
|
|
5876
5915
|
return `ws-${i}.pusher.com`;
|
|
5877
5916
|
}
|
|
5878
5917
|
function bi(i) {
|
|
5879
|
-
return
|
|
5918
|
+
return j.getProtocol() === "https:" ? !0 : i.forceTLS !== !1;
|
|
5880
5919
|
}
|
|
5881
5920
|
function yi(i) {
|
|
5882
5921
|
return "enableStats" in i ? i.enableStats : "disableStats" in i ? !i.disableStats : !1;
|
|
@@ -5899,7 +5938,7 @@ function Oa() {
|
|
|
5899
5938
|
class wi extends Te {
|
|
5900
5939
|
constructor(t) {
|
|
5901
5940
|
super(function(s, a) {
|
|
5902
|
-
|
|
5941
|
+
ce.debug(`No callbacks on watchlist events for ${s}`);
|
|
5903
5942
|
}), this.pusher = t, this.bindWatchlistInternalEvent();
|
|
5904
5943
|
}
|
|
5905
5944
|
handleEvent(t) {
|
|
@@ -5924,10 +5963,10 @@ function Oa() {
|
|
|
5924
5963
|
class Ai extends Te {
|
|
5925
5964
|
constructor(t) {
|
|
5926
5965
|
super(function(s, a) {
|
|
5927
|
-
|
|
5966
|
+
ce.debug("No callbacks on user for " + s);
|
|
5928
5967
|
}), this.signin_requested = !1, this.user_data = null, this.serverToUserChannel = null, this.signinDonePromise = null, this._signinDoneResolve = null, this._onAuthorize = (s, a) => {
|
|
5929
5968
|
if (s) {
|
|
5930
|
-
|
|
5969
|
+
ce.warn(`Error during signin: ${s}`), this._cleanup();
|
|
5931
5970
|
return;
|
|
5932
5971
|
}
|
|
5933
5972
|
this.pusher.send_event("pusher:signin", {
|
|
@@ -5953,11 +5992,11 @@ function Oa() {
|
|
|
5953
5992
|
try {
|
|
5954
5993
|
this.user_data = JSON.parse(t.user_data);
|
|
5955
5994
|
} catch {
|
|
5956
|
-
|
|
5995
|
+
ce.error(`Failed parsing user data after signin: ${t.user_data}`), this._cleanup();
|
|
5957
5996
|
return;
|
|
5958
5997
|
}
|
|
5959
5998
|
if (typeof this.user_data.id != "string" || this.user_data.id === "") {
|
|
5960
|
-
|
|
5999
|
+
ce.error(`user_data doesn't contain an id. user_data: ${this.user_data}`), this._cleanup();
|
|
5961
6000
|
return;
|
|
5962
6001
|
}
|
|
5963
6002
|
this._signinDoneResolve(), this._subscribeChannels();
|
|
@@ -5984,30 +6023,30 @@ function Oa() {
|
|
|
5984
6023
|
t.then(a).catch(a), this.signinDonePromise = t, this._signinDoneResolve = s;
|
|
5985
6024
|
}
|
|
5986
6025
|
}
|
|
5987
|
-
class
|
|
6026
|
+
class me {
|
|
5988
6027
|
static ready() {
|
|
5989
|
-
|
|
5990
|
-
for (var t = 0, s =
|
|
5991
|
-
|
|
6028
|
+
me.isReady = !0;
|
|
6029
|
+
for (var t = 0, s = me.instances.length; t < s; t++)
|
|
6030
|
+
me.instances[t].connect();
|
|
5992
6031
|
}
|
|
5993
6032
|
static getClientFeatures() {
|
|
5994
|
-
return
|
|
6033
|
+
return P(Re({ ws: j.Transports.ws }, function(t) {
|
|
5995
6034
|
return t.isSupported({});
|
|
5996
6035
|
}));
|
|
5997
6036
|
}
|
|
5998
6037
|
constructor(t, s) {
|
|
5999
|
-
Ri(t), ci(s), this.key = t, this.config = pi(s, this), this.channels = Ee.createChannels(), this.global_emitter = new Te(), this.sessionID =
|
|
6038
|
+
Ri(t), ci(s), this.key = t, this.config = pi(s, this), this.channels = Ee.createChannels(), this.global_emitter = new Te(), this.sessionID = j.randomInt(1e9), this.timeline = new si(this.key, this.sessionID, {
|
|
6000
6039
|
cluster: this.config.cluster,
|
|
6001
|
-
features:
|
|
6040
|
+
features: me.getClientFeatures(),
|
|
6002
6041
|
params: this.config.timelineParams || {},
|
|
6003
6042
|
limit: 50,
|
|
6004
6043
|
level: et.INFO,
|
|
6005
6044
|
version: h.VERSION
|
|
6006
6045
|
}), this.config.enableStats && (this.timelineSender = Ee.createTimelineSender(this.timeline, {
|
|
6007
6046
|
host: this.config.statsHost,
|
|
6008
|
-
path: "/timeline/v2/" +
|
|
6047
|
+
path: "/timeline/v2/" + j.TimelineTransport.name
|
|
6009
6048
|
}));
|
|
6010
|
-
var a = (l) =>
|
|
6049
|
+
var a = (l) => j.getDefaultStrategy(this.config, l, oi);
|
|
6011
6050
|
this.connection = Ee.createConnectionManager(this.key, {
|
|
6012
6051
|
getStrategy: a,
|
|
6013
6052
|
timeline: this.timeline,
|
|
@@ -6029,8 +6068,8 @@ function Oa() {
|
|
|
6029
6068
|
}), this.connection.bind("disconnected", () => {
|
|
6030
6069
|
this.channels.disconnect();
|
|
6031
6070
|
}), this.connection.bind("error", (l) => {
|
|
6032
|
-
|
|
6033
|
-
}),
|
|
6071
|
+
ce.warn(l);
|
|
6072
|
+
}), me.instances.push(this), this.timeline.info({ instances: me.instances.length }), this.user = new Ai(this), me.isReady && this.connect();
|
|
6034
6073
|
}
|
|
6035
6074
|
channel(t) {
|
|
6036
6075
|
return this.channels.find(t);
|
|
@@ -6041,7 +6080,7 @@ function Oa() {
|
|
|
6041
6080
|
connect() {
|
|
6042
6081
|
if (this.connection.connect(), this.timelineSender && !this.timelineSenderTimer) {
|
|
6043
6082
|
var t = this.connection.isUsingTLS(), s = this.timelineSender;
|
|
6044
|
-
this.timelineSenderTimer = new
|
|
6083
|
+
this.timelineSenderTimer = new ne(6e4, function() {
|
|
6045
6084
|
s.send(t);
|
|
6046
6085
|
});
|
|
6047
6086
|
}
|
|
@@ -6087,13 +6126,13 @@ function Oa() {
|
|
|
6087
6126
|
this.user.signin();
|
|
6088
6127
|
}
|
|
6089
6128
|
}
|
|
6090
|
-
|
|
6091
|
-
var Tt = o.default =
|
|
6129
|
+
me.instances = [], me.isReady = !1, me.logToConsole = !1, me.Runtime = j, me.ScriptReceivers = j.ScriptReceivers, me.DependenciesReceivers = j.DependenciesReceivers, me.auth_callbacks = j.auth_callbacks;
|
|
6130
|
+
var Tt = o.default = me;
|
|
6092
6131
|
function Ri(i) {
|
|
6093
6132
|
if (i == null)
|
|
6094
6133
|
throw "You must pass your app key when you instantiate Pusher.";
|
|
6095
6134
|
}
|
|
6096
|
-
|
|
6135
|
+
j.setup(me);
|
|
6097
6136
|
})
|
|
6098
6137
|
/******/
|
|
6099
6138
|
])
|
|
@@ -6103,10 +6142,10 @@ function Oa() {
|
|
|
6103
6142
|
}
|
|
6104
6143
|
var Fa = Oa();
|
|
6105
6144
|
const Da = /* @__PURE__ */ Ua(Fa), Na = "/v1/messenger/bootstrap", qa = 3e4, za = 3e4, ja = 5 * 6e4;
|
|
6106
|
-
function
|
|
6145
|
+
function ie(e) {
|
|
6107
6146
|
return typeof e == "object" && e !== null;
|
|
6108
6147
|
}
|
|
6109
|
-
function
|
|
6148
|
+
function pe(e, n) {
|
|
6110
6149
|
return typeof e[n] == "string";
|
|
6111
6150
|
}
|
|
6112
6151
|
function Ce(e, n) {
|
|
@@ -6143,14 +6182,14 @@ function Ba(e) {
|
|
|
6143
6182
|
return e.startsWith("/") ? e : `/${e}`;
|
|
6144
6183
|
}
|
|
6145
6184
|
function Va(e) {
|
|
6146
|
-
const n =
|
|
6147
|
-
if (!
|
|
6185
|
+
const n = ie(e) && ie(e.data) ? e.data : e;
|
|
6186
|
+
if (!ie(n))
|
|
6148
6187
|
throw new Error("Invalid messenger bootstrap payload: expected object");
|
|
6149
6188
|
const r = n.auth, o = n.service;
|
|
6150
|
-
if (!
|
|
6189
|
+
if (!ie(r) || !ie(o))
|
|
6151
6190
|
throw new Error("Invalid messenger bootstrap payload: missing auth or service data");
|
|
6152
6191
|
const c = r.user, u = o.reverb;
|
|
6153
|
-
if (!
|
|
6192
|
+
if (!ie(c) || !ie(u))
|
|
6154
6193
|
throw new Error("Invalid messenger bootstrap payload: missing user or reverb data");
|
|
6155
6194
|
const d = Ba(Ve(u, "path"));
|
|
6156
6195
|
return {
|
|
@@ -6185,9 +6224,9 @@ function Xa(e) {
|
|
|
6185
6224
|
return e.replace(/^https?:\/\//, "").replace(/\/.*$/, "").replace(/:\d+$/, "");
|
|
6186
6225
|
}
|
|
6187
6226
|
function Wa(e) {
|
|
6188
|
-
if (!
|
|
6227
|
+
if (!ie(e))
|
|
6189
6228
|
return !1;
|
|
6190
|
-
const n =
|
|
6229
|
+
const n = ie(e.response) ? e.response : null;
|
|
6191
6230
|
if (n?.status !== 403)
|
|
6192
6231
|
return !1;
|
|
6193
6232
|
const r = n.data;
|
|
@@ -6198,7 +6237,7 @@ function Kn(e, n) {
|
|
|
6198
6237
|
e.headers.set("Authorization", `Bearer ${n}`), e.headers.set("Accept", "application/json"), e.headers.set("X-Requested-With", "XMLHttpRequest"), typeof FormData < "u" && e.data instanceof FormData && (e.headers.delete("Content-Type"), e.headers.delete("content-type"));
|
|
6199
6238
|
return;
|
|
6200
6239
|
}
|
|
6201
|
-
const r =
|
|
6240
|
+
const r = ie(e.headers) ? e.headers : {};
|
|
6202
6241
|
e.headers = new An({
|
|
6203
6242
|
...r,
|
|
6204
6243
|
Authorization: `Bearer ${n}`,
|
|
@@ -6220,7 +6259,7 @@ function Ga(e) {
|
|
|
6220
6259
|
return n === "online" || n === "idle" || n === "dnd" || n === "offline" ? n : null;
|
|
6221
6260
|
}
|
|
6222
6261
|
function Ja(e, n) {
|
|
6223
|
-
if (!
|
|
6262
|
+
if (!ie(e))
|
|
6224
6263
|
return null;
|
|
6225
6264
|
const r = Ge(e, "user_id", "userId"), o = Ga(e.status);
|
|
6226
6265
|
if (!r || !o)
|
|
@@ -6236,12 +6275,12 @@ function Ja(e, n) {
|
|
|
6236
6275
|
return typeof d == "string" ? c.last_seen_at = d : d === null && (c.last_seen_at = null), c;
|
|
6237
6276
|
}
|
|
6238
6277
|
function Qn(e) {
|
|
6239
|
-
if (!
|
|
6278
|
+
if (!ie(e))
|
|
6240
6279
|
return null;
|
|
6241
6280
|
const n = Ge(e, "user_id", "userId"), r = Ge(e, "conversation_id", "conversationId");
|
|
6242
6281
|
if (!n || !r)
|
|
6243
6282
|
return null;
|
|
6244
|
-
const o = e.user, c =
|
|
6283
|
+
const o = e.user, c = ie(o) ? {
|
|
6245
6284
|
id: typeof o.id == "string" && o.id !== "" ? o.id : n,
|
|
6246
6285
|
name: typeof o.name == "string" ? o.name : "",
|
|
6247
6286
|
...typeof o.avatar == "string" && o.avatar !== "" ? { avatar: o.avatar } : {}
|
|
@@ -6257,31 +6296,31 @@ function Qn(e) {
|
|
|
6257
6296
|
};
|
|
6258
6297
|
}
|
|
6259
6298
|
function Ka(e) {
|
|
6260
|
-
return
|
|
6299
|
+
return ie(e) && pe(e, "id") && pe(e, "name");
|
|
6261
6300
|
}
|
|
6262
6301
|
function Qa(e) {
|
|
6263
|
-
return !
|
|
6302
|
+
return !ie(e) || !pe(e, "reaction") || typeof e.count != "number" ? !1 : Array.isArray(e.users) && e.users.every((n) => Ka(n));
|
|
6264
6303
|
}
|
|
6265
6304
|
function Yn(e) {
|
|
6266
|
-
return
|
|
6305
|
+
return ie(e) && ie(e.message) && pe(e.message, "id") && pe(e.message, "conversation_id") && pe(e.message, "author_id");
|
|
6267
6306
|
}
|
|
6268
6307
|
function Zn(e) {
|
|
6269
|
-
return
|
|
6308
|
+
return ie(e) && pe(e, "conversation_id") && pe(e, "user_id") && pe(e, "message_id");
|
|
6270
6309
|
}
|
|
6271
6310
|
function es(e) {
|
|
6272
|
-
return
|
|
6311
|
+
return ie(e) && pe(e, "conversation_id") && ie(e.message) && pe(e.message, "id");
|
|
6273
6312
|
}
|
|
6274
6313
|
function ts(e) {
|
|
6275
|
-
return
|
|
6314
|
+
return ie(e) && pe(e, "conversation_id") && pe(e, "message_id");
|
|
6276
6315
|
}
|
|
6277
6316
|
function ns(e) {
|
|
6278
|
-
return
|
|
6317
|
+
return ie(e) && pe(e, "conversation_id") && pe(e, "message_id") && Array.isArray(e.reactions) && e.reactions.every((n) => Qa(n));
|
|
6279
6318
|
}
|
|
6280
6319
|
function ss(e) {
|
|
6281
|
-
return
|
|
6320
|
+
return ie(e) && pe(e, "conversation_id");
|
|
6282
6321
|
}
|
|
6283
6322
|
function rs(e) {
|
|
6284
|
-
return
|
|
6323
|
+
return ie(e) && pe(e, "conversation_id") && pe(e, "removed_user_id");
|
|
6285
6324
|
}
|
|
6286
6325
|
function Fe(e, n, r, o) {
|
|
6287
6326
|
const c = (u) => {
|
|
@@ -6292,121 +6331,121 @@ function Fe(e, n, r, o) {
|
|
|
6292
6331
|
function pc(e) {
|
|
6293
6332
|
const n = e.initializedEvent ?? "messenger-client:echo-initialized", r = e.bootstrapEndpoint ?? Na, o = e.bootstrapRefreshSkewMs ?? qa, c = e.presenceFreshnessTtlMs ?? ja, u = (e.createLogger ?? Zt())("MessengerEcho");
|
|
6294
6333
|
typeof window < "u" && (window.Pusher = Da);
|
|
6295
|
-
let d = null, f = null, h = null,
|
|
6334
|
+
let d = null, f = null, h = null, R = null, C = "disconnected", v = "available", E = null, b = null;
|
|
6296
6335
|
const A = /* @__PURE__ */ new Set(), w = /* @__PURE__ */ new Set(), p = /* @__PURE__ */ new Map(), m = (T) => {
|
|
6297
6336
|
C = T;
|
|
6298
|
-
for (const
|
|
6299
|
-
|
|
6337
|
+
for (const P of A)
|
|
6338
|
+
P(T);
|
|
6300
6339
|
}, y = (T) => {
|
|
6301
6340
|
v = T;
|
|
6302
|
-
for (const
|
|
6303
|
-
|
|
6304
|
-
},
|
|
6341
|
+
for (const P of w)
|
|
6342
|
+
P(T);
|
|
6343
|
+
}, F = () => {
|
|
6305
6344
|
b !== null && (clearTimeout(b), b = null);
|
|
6306
|
-
},
|
|
6307
|
-
h !== null && (h.disconnect(), h = null),
|
|
6345
|
+
}, q = (T = !0) => {
|
|
6346
|
+
h !== null && (h.disconnect(), h = null), R = null, T && m("disconnected");
|
|
6308
6347
|
}, J = () => {
|
|
6309
|
-
|
|
6310
|
-
},
|
|
6348
|
+
F(), d = null, f = null, E = null, y("available"), q(), p.clear();
|
|
6349
|
+
}, G = () => {
|
|
6311
6350
|
if (!e.getSourceToken)
|
|
6312
6351
|
return null;
|
|
6313
6352
|
const T = e.getSourceToken();
|
|
6314
|
-
return T === null ? (J(), null) : (E !== null && E !== T && (
|
|
6353
|
+
return T === null ? (J(), null) : (E !== null && E !== T && (F(), d = null, f = null, y("available"), q()), E = T, T);
|
|
6315
6354
|
}, te = (T) => {
|
|
6316
6355
|
if (T === null)
|
|
6317
6356
|
return !1;
|
|
6318
6357
|
if (T.auth.expiresAt === null)
|
|
6319
6358
|
return T.auth.token !== "";
|
|
6320
|
-
const
|
|
6321
|
-
return Number.isNaN(
|
|
6359
|
+
const P = Date.parse(T.auth.expiresAt);
|
|
6360
|
+
return Number.isNaN(P) ? !1 : P - Date.now() > o;
|
|
6322
6361
|
}, k = (T) => {
|
|
6323
|
-
if (
|
|
6362
|
+
if (F(), T.auth.expiresAt === null)
|
|
6324
6363
|
return;
|
|
6325
|
-
const
|
|
6326
|
-
if (Number.isNaN(
|
|
6364
|
+
const P = Date.parse(T.auth.expiresAt);
|
|
6365
|
+
if (Number.isNaN(P))
|
|
6327
6366
|
return;
|
|
6328
|
-
const
|
|
6367
|
+
const D = Math.max(0, P - Date.now() - o);
|
|
6329
6368
|
b = setTimeout(() => {
|
|
6330
|
-
|
|
6331
|
-
},
|
|
6332
|
-
},
|
|
6369
|
+
V();
|
|
6370
|
+
}, D);
|
|
6371
|
+
}, L = async (T = !1) => e.getSourceToken && G() === null || !T && v === "account_suspended" ? null : !T && te(d) ? d : !T && f !== null ? await f : (f = (async () => {
|
|
6333
6372
|
try {
|
|
6334
|
-
const
|
|
6373
|
+
const D = await e.bootstrapClient.get(
|
|
6335
6374
|
r,
|
|
6336
6375
|
T ? { params: { refresh: 1 } } : void 0
|
|
6337
|
-
),
|
|
6338
|
-
return d =
|
|
6339
|
-
} catch (
|
|
6340
|
-
if (Wa(
|
|
6341
|
-
return d = null,
|
|
6342
|
-
throw
|
|
6376
|
+
), O = Va(D.data);
|
|
6377
|
+
return d = O, y("available"), k(O), O;
|
|
6378
|
+
} catch (D) {
|
|
6379
|
+
if (Wa(D))
|
|
6380
|
+
return d = null, F(), y("account_suspended"), q(), m("disconnected"), null;
|
|
6381
|
+
throw D;
|
|
6343
6382
|
}
|
|
6344
6383
|
})().finally(() => {
|
|
6345
6384
|
f = null;
|
|
6346
|
-
}), await f),
|
|
6385
|
+
}), await f), V = async () => {
|
|
6347
6386
|
const T = h !== null;
|
|
6348
6387
|
try {
|
|
6349
|
-
if (await
|
|
6388
|
+
if (await L(!0), !T)
|
|
6350
6389
|
return;
|
|
6351
|
-
|
|
6352
|
-
} catch (
|
|
6353
|
-
u.warn("Failed to refresh messenger bootstrap",
|
|
6390
|
+
q(!1), await X(!0);
|
|
6391
|
+
} catch (P) {
|
|
6392
|
+
u.warn("Failed to refresh messenger bootstrap", P);
|
|
6354
6393
|
}
|
|
6355
|
-
},
|
|
6356
|
-
const
|
|
6357
|
-
if (!
|
|
6394
|
+
}, H = (T) => {
|
|
6395
|
+
const P = T.connector?.pusher?.connection;
|
|
6396
|
+
if (!P) {
|
|
6358
6397
|
u.warn("Messenger echo connector does not expose a Pusher connection");
|
|
6359
6398
|
return;
|
|
6360
6399
|
}
|
|
6361
|
-
|
|
6400
|
+
P.bind("connecting", () => {
|
|
6362
6401
|
m("connecting");
|
|
6363
|
-
}),
|
|
6402
|
+
}), P.bind("connected", () => {
|
|
6364
6403
|
m("connected");
|
|
6365
|
-
}),
|
|
6404
|
+
}), P.bind("disconnected", () => {
|
|
6366
6405
|
m("disconnected");
|
|
6367
|
-
}),
|
|
6406
|
+
}), P.bind("unavailable", () => {
|
|
6368
6407
|
m("disconnected");
|
|
6369
|
-
}),
|
|
6408
|
+
}), P.bind("error", () => {
|
|
6370
6409
|
m("error");
|
|
6371
|
-
}),
|
|
6372
|
-
const
|
|
6373
|
-
if (
|
|
6410
|
+
}), P.bind("state_change", (D) => {
|
|
6411
|
+
const O = typeof D == "object" && D !== null && "current" in D && typeof D.current == "string" ? D.current : P.state;
|
|
6412
|
+
if (O === "connected") {
|
|
6374
6413
|
m("connected");
|
|
6375
6414
|
return;
|
|
6376
6415
|
}
|
|
6377
|
-
if (
|
|
6416
|
+
if (O === "connecting") {
|
|
6378
6417
|
m("connecting");
|
|
6379
6418
|
return;
|
|
6380
6419
|
}
|
|
6381
|
-
(
|
|
6382
|
-
}),
|
|
6383
|
-
},
|
|
6384
|
-
const
|
|
6385
|
-
if (
|
|
6420
|
+
(O === "unavailable" || O === "failed" || O === "disconnected") && m("disconnected");
|
|
6421
|
+
}), P.state === "connected" && m("connected");
|
|
6422
|
+
}, X = async (T = !1) => !T && h !== null && te(d) ? h : !T && R !== null ? await R : (R = (async () => {
|
|
6423
|
+
const D = await L(T);
|
|
6424
|
+
if (D === null)
|
|
6386
6425
|
return null;
|
|
6387
|
-
h !== null &&
|
|
6388
|
-
const
|
|
6426
|
+
h !== null && q(!1);
|
|
6427
|
+
const O = D.service.reverb.scheme === "https", se = {
|
|
6389
6428
|
broadcaster: "reverb",
|
|
6390
|
-
key:
|
|
6391
|
-
wsHost: Xa(
|
|
6392
|
-
wsPort:
|
|
6393
|
-
wssPort:
|
|
6394
|
-
forceTLS:
|
|
6395
|
-
encrypted:
|
|
6429
|
+
key: D.service.reverb.appKey,
|
|
6430
|
+
wsHost: Xa(D.service.reverb.host),
|
|
6431
|
+
wsPort: D.service.reverb.port,
|
|
6432
|
+
wssPort: D.service.reverb.port,
|
|
6433
|
+
forceTLS: O,
|
|
6434
|
+
encrypted: O,
|
|
6396
6435
|
disableStats: !0,
|
|
6397
6436
|
enabledTransports: ["ws", "wss"],
|
|
6398
|
-
authEndpoint:
|
|
6437
|
+
authEndpoint: D.service.broadcastingAuthUrl,
|
|
6399
6438
|
auth: {
|
|
6400
6439
|
headers: {
|
|
6401
|
-
Authorization: `Bearer ${
|
|
6440
|
+
Authorization: `Bearer ${D.auth.token}`,
|
|
6402
6441
|
Accept: "application/json"
|
|
6403
6442
|
}
|
|
6404
6443
|
}
|
|
6405
6444
|
};
|
|
6406
|
-
return
|
|
6445
|
+
return D.service.reverb.path && (se.wsPath = D.service.reverb.path), h = new Ia(se), H(h), m("connecting"), typeof window < "u" && window.dispatchEvent(new CustomEvent(n)), h;
|
|
6407
6446
|
})().finally(() => {
|
|
6408
|
-
|
|
6409
|
-
}), await
|
|
6447
|
+
R = null;
|
|
6448
|
+
}), await R), _ = $t.create({
|
|
6410
6449
|
timeout: e.requestTimeoutMs ?? za,
|
|
6411
6450
|
withCredentials: !1,
|
|
6412
6451
|
headers: {
|
|
@@ -6415,47 +6454,47 @@ function pc(e) {
|
|
|
6415
6454
|
}
|
|
6416
6455
|
});
|
|
6417
6456
|
_.interceptors.request.use(async (T) => {
|
|
6418
|
-
const
|
|
6419
|
-
if (
|
|
6457
|
+
const P = await L();
|
|
6458
|
+
if (P === null)
|
|
6420
6459
|
throw new Error("Messenger bootstrap is unavailable.");
|
|
6421
|
-
return T.baseURL =
|
|
6460
|
+
return T.baseURL = P.service.apiBaseUrl, Kn(T, P.auth.token), T;
|
|
6422
6461
|
}), _.interceptors.response.use(
|
|
6423
6462
|
(T) => T,
|
|
6424
6463
|
async (T) => {
|
|
6425
|
-
const
|
|
6426
|
-
if (T.response?.status === 401 &&
|
|
6427
|
-
|
|
6428
|
-
const
|
|
6429
|
-
if (
|
|
6430
|
-
return
|
|
6464
|
+
const P = T.config;
|
|
6465
|
+
if (T.response?.status === 401 && P && P._messengerRetry !== !0) {
|
|
6466
|
+
P._messengerRetry = !0;
|
|
6467
|
+
const D = await L(!0);
|
|
6468
|
+
if (D !== null)
|
|
6469
|
+
return P.baseURL = D.service.apiBaseUrl, Kn(P, D.auth.token), await _(P);
|
|
6431
6470
|
}
|
|
6432
6471
|
return Promise.reject(T);
|
|
6433
6472
|
}
|
|
6434
6473
|
);
|
|
6435
|
-
const
|
|
6474
|
+
const I = () => v === "account_suspended" ? null : h, fe = (T) => (A.add(T), T(C), () => {
|
|
6436
6475
|
A.delete(T);
|
|
6437
6476
|
}), Se = (T) => (w.add(T), T(v), () => {
|
|
6438
6477
|
w.delete(T);
|
|
6439
|
-
}), B = () => d?.auth.tenantId ?? "global",
|
|
6440
|
-
const
|
|
6441
|
-
if (
|
|
6478
|
+
}), B = () => d?.auth.tenantId ?? "global", K = (T) => {
|
|
6479
|
+
const P = Dt(T.ts)?.getTime() ?? Dt(T.last_seen_at)?.getTime() ?? null;
|
|
6480
|
+
if (P === null)
|
|
6442
6481
|
return !0;
|
|
6443
|
-
const
|
|
6444
|
-
if (
|
|
6482
|
+
const D = `${T.tenant_scope ?? "global"}:${T.user_id}`, O = p.get(D);
|
|
6483
|
+
if (O && P < O.timestampMs)
|
|
6445
6484
|
return !1;
|
|
6446
|
-
const
|
|
6447
|
-
p.set(
|
|
6448
|
-
timestampMs:
|
|
6449
|
-
seenAt:
|
|
6485
|
+
const se = Date.now();
|
|
6486
|
+
p.set(D, {
|
|
6487
|
+
timestampMs: P,
|
|
6488
|
+
seenAt: se
|
|
6450
6489
|
});
|
|
6451
|
-
for (const [
|
|
6452
|
-
|
|
6490
|
+
for (const [ae, le] of p.entries())
|
|
6491
|
+
se - le.seenAt > c && p.delete(ae);
|
|
6453
6492
|
return !0;
|
|
6454
|
-
},
|
|
6455
|
-
const
|
|
6456
|
-
if (!
|
|
6493
|
+
}, N = (T) => {
|
|
6494
|
+
const P = I();
|
|
6495
|
+
if (!P || typeof P.join != "function")
|
|
6457
6496
|
return;
|
|
6458
|
-
const
|
|
6497
|
+
const D = P.join(`online-users.${B()}`), O = [
|
|
6459
6498
|
".PresenceStatusChanged",
|
|
6460
6499
|
"PresenceStatusChanged",
|
|
6461
6500
|
".presence.status.changed",
|
|
@@ -6465,152 +6504,152 @@ function pc(e) {
|
|
|
6465
6504
|
".Modules\\Presence\\Events\\UserPresenceStatusChanged",
|
|
6466
6505
|
"Modules\\Presence\\Events\\UserPresenceStatusChanged"
|
|
6467
6506
|
];
|
|
6468
|
-
for (const
|
|
6469
|
-
|
|
6470
|
-
const
|
|
6471
|
-
!
|
|
6507
|
+
for (const se of O)
|
|
6508
|
+
D.listen(se, (ae) => {
|
|
6509
|
+
const le = Ja(ae, B());
|
|
6510
|
+
!le || !K(le) || T(le);
|
|
6472
6511
|
});
|
|
6473
|
-
},
|
|
6512
|
+
}, Y = () => {
|
|
6474
6513
|
h?.leave(`online-users.${B()}`);
|
|
6475
6514
|
};
|
|
6476
|
-
function M(T,
|
|
6477
|
-
const
|
|
6478
|
-
function
|
|
6479
|
-
if (!
|
|
6515
|
+
function M(T, P) {
|
|
6516
|
+
const D = [];
|
|
6517
|
+
function O(se, ae, le) {
|
|
6518
|
+
if (!le)
|
|
6480
6519
|
return;
|
|
6481
6520
|
const Re = (Le) => {
|
|
6482
|
-
|
|
6521
|
+
ae(Le) && le(Le);
|
|
6483
6522
|
};
|
|
6484
|
-
T.bind(
|
|
6523
|
+
T.bind(se, Re), D.push({ event: se, handler: Re });
|
|
6485
6524
|
}
|
|
6486
|
-
return
|
|
6487
|
-
for (const
|
|
6488
|
-
T.unbind(
|
|
6525
|
+
return O("ConversationMessageSent", Yn, P.onMessageSent), O("ConversationMessageRead", Zn, P.onMessageRead), O("ConversationMessageEdited", es, P.onMessageEdited), O("ConversationMessageDeleted", ts, P.onMessageDeleted), O("MessageReactionToggled", ns, P.onReactionToggled), O("ConversationRequestAccepted", ss, P.onRequestAccepted), O("ConversationParticipantRemoved", rs, P.onParticipantRemoved), () => {
|
|
6526
|
+
for (const se of D)
|
|
6527
|
+
T.unbind(se.event, se.handler);
|
|
6489
6528
|
};
|
|
6490
6529
|
}
|
|
6491
|
-
const
|
|
6492
|
-
const
|
|
6493
|
-
if (!
|
|
6530
|
+
const U = (T, P) => {
|
|
6531
|
+
const D = I();
|
|
6532
|
+
if (!D)
|
|
6494
6533
|
return () => {
|
|
6495
6534
|
};
|
|
6496
|
-
const
|
|
6497
|
-
if (
|
|
6498
|
-
return M(
|
|
6499
|
-
const
|
|
6500
|
-
return
|
|
6535
|
+
const O = D.private(`conversation.${T}`), se = O.subscription;
|
|
6536
|
+
if (se)
|
|
6537
|
+
return M(se, P);
|
|
6538
|
+
const ae = [];
|
|
6539
|
+
return P.onMessageSent && ae.push({
|
|
6501
6540
|
event: ".ConversationMessageSent",
|
|
6502
|
-
handler: Fe(
|
|
6503
|
-
}),
|
|
6541
|
+
handler: Fe(O, ".ConversationMessageSent", Yn, P.onMessageSent)
|
|
6542
|
+
}), P.onMessageRead && ae.push({
|
|
6504
6543
|
event: ".ConversationMessageRead",
|
|
6505
|
-
handler: Fe(
|
|
6506
|
-
}),
|
|
6544
|
+
handler: Fe(O, ".ConversationMessageRead", Zn, P.onMessageRead)
|
|
6545
|
+
}), P.onMessageEdited && ae.push({
|
|
6507
6546
|
event: ".ConversationMessageEdited",
|
|
6508
|
-
handler: Fe(
|
|
6509
|
-
}),
|
|
6547
|
+
handler: Fe(O, ".ConversationMessageEdited", es, P.onMessageEdited)
|
|
6548
|
+
}), P.onMessageDeleted && ae.push({
|
|
6510
6549
|
event: ".ConversationMessageDeleted",
|
|
6511
|
-
handler: Fe(
|
|
6512
|
-
}),
|
|
6550
|
+
handler: Fe(O, ".ConversationMessageDeleted", ts, P.onMessageDeleted)
|
|
6551
|
+
}), P.onReactionToggled && ae.push({
|
|
6513
6552
|
event: ".MessageReactionToggled",
|
|
6514
|
-
handler: Fe(
|
|
6515
|
-
}),
|
|
6553
|
+
handler: Fe(O, ".MessageReactionToggled", ns, P.onReactionToggled)
|
|
6554
|
+
}), P.onRequestAccepted && ae.push({
|
|
6516
6555
|
event: ".ConversationRequestAccepted",
|
|
6517
|
-
handler: Fe(
|
|
6518
|
-
}),
|
|
6556
|
+
handler: Fe(O, ".ConversationRequestAccepted", ss, P.onRequestAccepted)
|
|
6557
|
+
}), P.onParticipantRemoved && ae.push({
|
|
6519
6558
|
event: ".ConversationParticipantRemoved",
|
|
6520
|
-
handler: Fe(
|
|
6559
|
+
handler: Fe(O, ".ConversationParticipantRemoved", rs, P.onParticipantRemoved)
|
|
6521
6560
|
}), () => {
|
|
6522
|
-
if (typeof
|
|
6523
|
-
for (const
|
|
6524
|
-
|
|
6561
|
+
if (typeof O.stopListening == "function")
|
|
6562
|
+
for (const le of ae)
|
|
6563
|
+
O.stopListening(le.event, le.handler);
|
|
6525
6564
|
};
|
|
6526
|
-
},
|
|
6565
|
+
}, ne = (T) => {
|
|
6527
6566
|
h?.leave(`conversation.${T}`);
|
|
6528
|
-
},
|
|
6529
|
-
const
|
|
6530
|
-
if (
|
|
6531
|
-
const we = (
|
|
6532
|
-
const
|
|
6533
|
-
if (
|
|
6534
|
-
if (
|
|
6535
|
-
|
|
6536
|
-
user_id:
|
|
6537
|
-
user:
|
|
6538
|
-
id:
|
|
6567
|
+
}, ue = (T, P, D) => {
|
|
6568
|
+
const O = T.private(`typing-conversation.${P}`), se = /* @__PURE__ */ new Set(["start", "typing"]), ae = /* @__PURE__ */ new Set(["stop", "idle", "viewing"]), le = O.subscription;
|
|
6569
|
+
if (le) {
|
|
6570
|
+
const we = (ge) => {
|
|
6571
|
+
const be = Qn(ge);
|
|
6572
|
+
if (be) {
|
|
6573
|
+
if (se.has(be.state)) {
|
|
6574
|
+
D.onTypingStart?.({
|
|
6575
|
+
user_id: be.user_id,
|
|
6576
|
+
user: be.user ?? {
|
|
6577
|
+
id: be.user_id,
|
|
6539
6578
|
name: ""
|
|
6540
6579
|
},
|
|
6541
|
-
conversation_id:
|
|
6542
|
-
started_at:
|
|
6580
|
+
conversation_id: be.conversation_id,
|
|
6581
|
+
started_at: be.started_at ?? be.ts ?? (/* @__PURE__ */ new Date()).toISOString()
|
|
6543
6582
|
});
|
|
6544
6583
|
return;
|
|
6545
6584
|
}
|
|
6546
|
-
|
|
6547
|
-
user_id:
|
|
6548
|
-
conversation_id:
|
|
6549
|
-
stopped_at:
|
|
6585
|
+
ae.has(be.state) && D.onTypingStop?.({
|
|
6586
|
+
user_id: be.user_id,
|
|
6587
|
+
conversation_id: be.conversation_id,
|
|
6588
|
+
stopped_at: be.stopped_at ?? be.ts ?? (/* @__PURE__ */ new Date()).toISOString()
|
|
6550
6589
|
});
|
|
6551
6590
|
}
|
|
6552
6591
|
};
|
|
6553
|
-
return
|
|
6554
|
-
|
|
6592
|
+
return le.bind("TypingStateChanged", we), () => {
|
|
6593
|
+
le.unbind("TypingStateChanged", we);
|
|
6555
6594
|
};
|
|
6556
6595
|
}
|
|
6557
6596
|
const Re = [], Le = (we) => {
|
|
6558
|
-
const
|
|
6559
|
-
if (
|
|
6560
|
-
if (
|
|
6561
|
-
|
|
6562
|
-
user_id:
|
|
6563
|
-
user:
|
|
6564
|
-
id:
|
|
6597
|
+
const ge = Qn(we);
|
|
6598
|
+
if (ge) {
|
|
6599
|
+
if (se.has(ge.state)) {
|
|
6600
|
+
D.onTypingStart?.({
|
|
6601
|
+
user_id: ge.user_id,
|
|
6602
|
+
user: ge.user ?? {
|
|
6603
|
+
id: ge.user_id,
|
|
6565
6604
|
name: ""
|
|
6566
6605
|
},
|
|
6567
|
-
conversation_id:
|
|
6568
|
-
started_at:
|
|
6606
|
+
conversation_id: ge.conversation_id,
|
|
6607
|
+
started_at: ge.started_at ?? ge.ts ?? (/* @__PURE__ */ new Date()).toISOString()
|
|
6569
6608
|
});
|
|
6570
6609
|
return;
|
|
6571
6610
|
}
|
|
6572
|
-
|
|
6573
|
-
user_id:
|
|
6574
|
-
conversation_id:
|
|
6575
|
-
stopped_at:
|
|
6611
|
+
ae.has(ge.state) && D.onTypingStop?.({
|
|
6612
|
+
user_id: ge.user_id,
|
|
6613
|
+
conversation_id: ge.conversation_id,
|
|
6614
|
+
stopped_at: ge.stopped_at ?? ge.ts ?? (/* @__PURE__ */ new Date()).toISOString()
|
|
6576
6615
|
});
|
|
6577
6616
|
}
|
|
6578
6617
|
};
|
|
6579
|
-
return
|
|
6580
|
-
if (typeof
|
|
6618
|
+
return O.listen(".TypingStateChanged", Le), Re.push({ event: ".TypingStateChanged", handler: Le }), () => {
|
|
6619
|
+
if (typeof O.stopListening == "function")
|
|
6581
6620
|
for (const we of Re)
|
|
6582
|
-
|
|
6621
|
+
O.stopListening(we.event, we.handler);
|
|
6583
6622
|
};
|
|
6584
6623
|
};
|
|
6585
6624
|
return {
|
|
6586
6625
|
apiClient: _,
|
|
6587
6626
|
initializedEvent: n,
|
|
6588
|
-
getEcho:
|
|
6589
|
-
waitForEcho: async () => v === "account_suspended" ? null : await
|
|
6627
|
+
getEcho: I,
|
|
6628
|
+
waitForEcho: async () => v === "account_suspended" ? null : await X(),
|
|
6590
6629
|
getConnectionStatus: () => C,
|
|
6591
6630
|
getAccessState: () => v,
|
|
6592
|
-
onConnectionStatusChange:
|
|
6631
|
+
onConnectionStatusChange: fe,
|
|
6593
6632
|
onAccessStateChange: Se,
|
|
6594
6633
|
reconnect: async () => {
|
|
6595
|
-
y("available"),
|
|
6634
|
+
y("available"), q(), await X(!0);
|
|
6596
6635
|
},
|
|
6597
|
-
subscribeToPresenceStatus:
|
|
6598
|
-
unsubscribeFromPresenceStatus:
|
|
6599
|
-
subscribeToConversation:
|
|
6600
|
-
unsubscribeFromConversation:
|
|
6601
|
-
subscribeToTyping: (T,
|
|
6602
|
-
const
|
|
6603
|
-
if (
|
|
6604
|
-
return
|
|
6605
|
-
let
|
|
6606
|
-
const
|
|
6607
|
-
if (
|
|
6636
|
+
subscribeToPresenceStatus: N,
|
|
6637
|
+
unsubscribeFromPresenceStatus: Y,
|
|
6638
|
+
subscribeToConversation: U,
|
|
6639
|
+
unsubscribeFromConversation: ne,
|
|
6640
|
+
subscribeToTyping: (T, P) => {
|
|
6641
|
+
const D = ut();
|
|
6642
|
+
if (D)
|
|
6643
|
+
return ue(D, T, P);
|
|
6644
|
+
let O = !1, se = null;
|
|
6645
|
+
const ae = () => {
|
|
6646
|
+
if (O)
|
|
6608
6647
|
return;
|
|
6609
|
-
const
|
|
6610
|
-
|
|
6648
|
+
const le = ut();
|
|
6649
|
+
le && (se = ue(le, T, P), typeof window < "u" && window.removeEventListener(ct(), ae));
|
|
6611
6650
|
};
|
|
6612
|
-
return typeof window < "u" && window.addEventListener(ct(),
|
|
6613
|
-
|
|
6651
|
+
return typeof window < "u" && window.addEventListener(ct(), ae), () => {
|
|
6652
|
+
O = !0, typeof window < "u" && window.removeEventListener(ct(), ae), se?.();
|
|
6614
6653
|
};
|
|
6615
6654
|
},
|
|
6616
6655
|
unsubscribeFromTyping: (T) => {
|
|
@@ -6623,13 +6662,13 @@ export {
|
|
|
6623
6662
|
go as DEFAULT_PRESENCE_STALE_AFTER_MS,
|
|
6624
6663
|
hc as configureMessengerClient,
|
|
6625
6664
|
pc as createMessengerEcho,
|
|
6626
|
-
|
|
6665
|
+
W as getApi,
|
|
6627
6666
|
ke as getAuthStore,
|
|
6628
6667
|
Rn as getConnectionStatus,
|
|
6629
6668
|
Ae as getEcho,
|
|
6630
6669
|
vs as getEchoConnectionStatus,
|
|
6631
6670
|
Je as getEchoInitializedEvent,
|
|
6632
|
-
|
|
6671
|
+
Z as getErrorMessage,
|
|
6633
6672
|
Zt as getLoggerFactory,
|
|
6634
6673
|
Vt as getMainApi,
|
|
6635
6674
|
ut as getMainEcho,
|