@codingfactory/messenger-client 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,84 +1,91 @@
1
- import { ref as J, getCurrentInstance as Fe, computed as K, onUnmounted as Ee, toValue as Be, watch as me } from "vue";
2
- import { defineStore as Ve, storeToRefs as He } from "pinia";
3
- import Ye, { isAxiosError as je } from "axios";
4
- import { isAxiosError as jt } from "axios";
5
- import { useRoute as We } from "vue-router";
6
- const Te = () => () => {
7
- }, xe = () => {
8
- }, qe = () => {
9
- }, Pe = () => {
10
- }, Le = () => {
1
+ import { ref as Q, getCurrentInstance as Me, computed as J, onUnmounted as we, toValue as Oe, watch as de } from "vue";
2
+ import { defineStore as Ge, storeToRefs as ke } from "pinia";
3
+ import Ve, { isAxiosError as Be } from "axios";
4
+ import { isAxiosError as Wt } from "axios";
5
+ import { useRoute as He } from "vue-router";
6
+ const Re = () => () => {
7
+ }, Ae = () => {
8
+ }, Ee = () => {
9
+ }, Fe = () => {
10
+ }, Te = () => {
11
11
  throw new Error("messenger-client subscribeToConversation is not configured");
12
- };
13
- let W = "messenger-client:echo-initialized", P = () => null, Z = Te, oe = xe, ae = qe, ce = Le, ue = Pe;
12
+ }, _ = {
13
+ ECHO_INITIALIZED_EVENT: "messenger-client:echo-initialized",
14
+ getEcho: () => null,
15
+ onConnectionStatusChange: Re,
16
+ subscribeToPresenceStatus: Ae,
17
+ unsubscribeFromPresenceStatus: Ee,
18
+ subscribeToConversation: Te,
19
+ unsubscribeFromConversation: Fe
20
+ }, le = () => _.ECHO_INITIALIZED_EVENT, O = () => _.getEcho(), xe = (e) => _.onConnectionStatusChange(e), Ye = (e) => _.subscribeToPresenceStatus(e), je = () => _.unsubscribeFromPresenceStatus(), We = (e, t) => _.subscribeToConversation(e, t), Ze = (e) => _.unsubscribeFromConversation(e);
14
21
  function Xe(e) {
15
- e.initializedEvent && (W = e.initializedEvent), e.getEcho && (P = e.getEcho), e.onConnectionStatusChange && (Z = e.onConnectionStatusChange), e.subscribeToPresenceStatus && (oe = e.subscribeToPresenceStatus), e.unsubscribeFromPresenceStatus && (ae = e.unsubscribeFromPresenceStatus), e.subscribeToConversation && (ce = e.subscribeToConversation), e.unsubscribeFromConversation && (ue = e.unsubscribeFromConversation);
22
+ e.initializedEvent && (_.ECHO_INITIALIZED_EVENT = e.initializedEvent), e.getEcho && (_.getEcho = e.getEcho), e.onConnectionStatusChange && (_.onConnectionStatusChange = e.onConnectionStatusChange), e.subscribeToPresenceStatus && (_.subscribeToPresenceStatus = e.subscribeToPresenceStatus), e.unsubscribeFromPresenceStatus && (_.unsubscribeFromPresenceStatus = e.unsubscribeFromPresenceStatus), e.subscribeToConversation && (_.subscribeToConversation = e.subscribeToConversation), e.unsubscribeFromConversation && (_.unsubscribeFromConversation = e.unsubscribeFromConversation);
16
23
  }
17
24
  function Qe() {
18
- W = "messenger-client:echo-initialized", P = () => null, Z = Te, oe = xe, ae = qe, ce = Le, ue = Pe;
25
+ _.ECHO_INITIALIZED_EVENT = "messenger-client:echo-initialized", _.getEcho = () => null, _.onConnectionStatusChange = Re, _.subscribeToPresenceStatus = Ae, _.unsubscribeFromPresenceStatus = Ee, _.subscribeToConversation = Te, _.unsubscribeFromConversation = Fe;
19
26
  }
20
- function X(e) {
27
+ function Z(e) {
21
28
  return typeof e == "object" && e !== null;
22
29
  }
23
- function Ze(e) {
24
- return X(e) && typeof e.conversation_id == "string" && X(e.message) && typeof e.message.id == "string" && typeof e.message.conversation_id == "string" && typeof e.message.author_id == "string";
25
- }
26
30
  function Je(e) {
27
- return X(e) && typeof e.conversation_id == "string" && typeof e.user_id == "string" && typeof e.message_id == "string";
31
+ return Z(e) && typeof e.conversation_id == "string" && Z(e.message) && typeof e.message.id == "string" && typeof e.message.conversation_id == "string" && typeof e.message.author_id == "string";
28
32
  }
29
33
  function Ke(e) {
30
- return X(e) && typeof e.conversation_id == "string";
34
+ return Z(e) && typeof e.conversation_id == "string" && typeof e.user_id == "string" && typeof e.message_id == "string";
31
35
  }
32
- const Ue = Ye;
33
- let l = Ue;
34
36
  function et(e) {
37
+ return Z(e) && typeof e.conversation_id == "string";
38
+ }
39
+ const qe = Ve;
40
+ let l = qe;
41
+ function tt(e) {
35
42
  l = e;
36
43
  }
37
- function tt() {
38
- l = Ue;
44
+ function st() {
45
+ l = qe;
39
46
  }
40
- const ze = {
47
+ const Pe = {
41
48
  currentUser: null
42
49
  };
43
- let L = () => ze;
44
- function st(e) {
50
+ let L = () => Pe;
51
+ function nt(e) {
45
52
  L = e;
46
53
  }
47
- function nt() {
48
- L = () => ze;
54
+ function rt() {
55
+ L = () => Pe;
49
56
  }
50
57
  function m(e) {
51
- if (je(e)) {
58
+ if (Be(e)) {
52
59
  const t = e.response?.data?.message || e.message || "An error occurred";
53
60
  return t.includes("SQLSTATE") || t.includes("Connection:") || t.includes("\\Illuminate\\") ? "Something went wrong. Please try again later." : t;
54
61
  }
55
62
  return e instanceof Error ? e.message : typeof e == "string" ? e : typeof e == "object" && e !== null && "message" in e && typeof e.message == "string" ? e.message : "An unexpected error occurred";
56
63
  }
57
- function It(e) {
64
+ function Ot(e) {
58
65
  return e instanceof Error;
59
66
  }
60
- function Ot(e) {
67
+ function Gt(e) {
61
68
  return typeof e == "object" && e !== null && "response" in e && typeof e.response == "object";
62
69
  }
63
- const $e = {
70
+ const Le = {
64
71
  async uploadImage() {
65
72
  throw new Error("messenger-client mediaApi.uploadImage is not configured");
66
73
  }
67
74
  };
68
- let de = $e;
69
- function rt(e) {
70
- de = e;
75
+ let ie = Le;
76
+ function it(e) {
77
+ ie = e;
71
78
  }
72
- function it() {
73
- de = $e;
79
+ function ot() {
80
+ ie = Le;
74
81
  }
75
- function ot(e) {
82
+ function at(e) {
76
83
  return e !== null && typeof e == "object" && "id" in e && "type" in e && "participants" in e;
77
84
  }
78
85
  function Ne(e) {
79
86
  return typeof e == "object" && e !== null;
80
87
  }
81
- function N(e) {
88
+ function D(e) {
82
89
  return !Ne(e) || !("data" in e) ? e : e.data;
83
90
  }
84
91
  function B(e, t) {
@@ -87,7 +94,7 @@ function B(e, t) {
87
94
  throw new Error(`Invalid messaging folder payload: missing string ${t}`);
88
95
  return s;
89
96
  }
90
- function pe(e, t) {
97
+ function fe(e, t) {
91
98
  const s = e[t];
92
99
  if (s == null)
93
100
  return null;
@@ -95,7 +102,7 @@ function pe(e, t) {
95
102
  throw new Error(`Invalid messaging folder payload: ${t} must be a string or null`);
96
103
  return s;
97
104
  }
98
- function ee(e, t) {
105
+ function K(e, t) {
99
106
  const s = e[t];
100
107
  if (typeof s == "number" && Number.isFinite(s))
101
108
  return s;
@@ -106,43 +113,43 @@ function ee(e, t) {
106
113
  }
107
114
  throw new Error(`Invalid messaging folder payload: missing numeric ${t}`);
108
115
  }
109
- function re(e) {
116
+ function ne(e) {
110
117
  if (!Ne(e))
111
118
  throw new Error("Invalid messaging folder payload: expected object");
112
119
  return {
113
120
  id: B(e, "id"),
114
121
  name: B(e, "name"),
115
- color: pe(e, "color"),
116
- icon: pe(e, "icon"),
117
- sort_order: ee(e, "sort_order"),
118
- conversation_count: ee(e, "conversation_count"),
119
- unread_count: ee(e, "unread_count"),
122
+ color: fe(e, "color"),
123
+ icon: fe(e, "icon"),
124
+ sort_order: K(e, "sort_order"),
125
+ conversation_count: K(e, "conversation_count"),
126
+ unread_count: K(e, "unread_count"),
120
127
  created_at: B(e, "created_at"),
121
128
  updated_at: B(e, "updated_at")
122
129
  };
123
130
  }
124
- function at(e) {
131
+ function ct(e) {
125
132
  if (!Array.isArray(e))
126
133
  throw new Error("Invalid messaging folder payload: expected array");
127
- return e.map((t) => re(t));
134
+ return e.map((t) => ne(t));
128
135
  }
129
- function ve(e) {
130
- if (!ot(e))
136
+ function he(e) {
137
+ if (!at(e))
131
138
  throw new Error("Invalid conversation payload from folder assignment endpoint");
132
139
  return e;
133
140
  }
134
- const q = {
141
+ const P = {
135
142
  async fetchFolders() {
136
143
  const e = await l.get("/v1/messaging/folders");
137
- return at(N(e.data));
144
+ return ct(D(e.data));
138
145
  },
139
146
  async createFolder(e) {
140
147
  const t = await l.post("/v1/messaging/folders", e);
141
- return re(N(t.data));
148
+ return ne(D(t.data));
142
149
  },
143
150
  async updateFolder(e, t) {
144
151
  const s = await l.patch(`/v1/messaging/folders/${e}`, t);
145
- return re(N(s.data));
152
+ return ne(D(s.data));
146
153
  },
147
154
  async deleteFolder(e) {
148
155
  await l.delete(`/v1/messaging/folders/${e}`);
@@ -154,16 +161,16 @@ const q = {
154
161
  const s = await l.patch(`/v1/messaging/conversations/${e}/folder`, {
155
162
  folder_id: t
156
163
  });
157
- return ve(N(s.data));
164
+ return he(D(s.data));
158
165
  },
159
166
  async acceptRequest(e) {
160
167
  const t = await l.post(`/v1/messaging/conversations/${e}/accept`);
161
- return ve(N(t.data));
168
+ return he(D(t.data));
162
169
  },
163
170
  async declineRequest(e) {
164
171
  await l.post(`/v1/messaging/conversations/${e}/decline`);
165
172
  }
166
- }, _e = 1e3, le = 4e3, ct = 12e4, ut = 300, dt = 1, lt = 1600, fe = (e) => {
173
+ }, ge = 1e3, oe = 4e3, ut = 12e4, dt = 300, lt = 1, ft = 1600, ae = (e) => {
167
174
  if (typeof e == "number" && Number.isFinite(e))
168
175
  return e;
169
176
  if (typeof e == "string") {
@@ -171,32 +178,32 @@ const q = {
171
178
  if (Number.isFinite(t))
172
179
  return t;
173
180
  }
174
- }, De = (e) => typeof e == "number" && e >= 500 && e < 600, ye = (e) => {
175
- const s = fe(e.response?.status);
176
- return s === void 0 ? !0 : s === 429 || De(s);
177
- }, Ie = (e) => {
181
+ }, Ue = (e) => typeof e == "number" && e >= 500 && e < 600, me = (e) => {
182
+ const s = ae(e.response?.status);
183
+ return s === void 0 ? !0 : s === 429 || Ue(s);
184
+ }, ze = (e) => {
178
185
  if (typeof e == "number" && Number.isFinite(e) && e > 0)
179
- return Math.max(_e, e * 1e3);
186
+ return Math.max(ge, e * 1e3);
180
187
  if (typeof e == "string") {
181
188
  const t = Number.parseInt(e, 10);
182
189
  if (Number.isFinite(t) && t > 0)
183
- return Math.max(_e, t * 1e3);
190
+ return Math.max(ge, t * 1e3);
184
191
  }
185
- return le;
186
- }, ft = (e) => {
187
- const t = Math.max(0, e), s = 2 ** Math.min(t, 6), n = le * s;
188
- return Math.min(ct, n);
192
+ return oe;
189
193
  }, ht = (e) => {
194
+ const t = Math.max(0, e), s = 2 ** Math.min(t, 6), n = oe * s;
195
+ return Math.min(ut, n);
196
+ }, gt = (e) => {
190
197
  const t = e;
191
- return fe(t.response?.status) === 429 ? Ie(t.response?.headers?.["retry-after"]) : ut;
192
- }, be = async (e) => {
198
+ return ae(t.response?.status) === 429 ? ze(t.response?.headers?.["retry-after"]) : dt;
199
+ }, pe = async (e) => {
193
200
  await new Promise((t) => {
194
201
  setTimeout(t, e);
195
202
  });
196
- }, gt = (e) => {
197
- if (!S(e))
203
+ }, mt = (e) => {
204
+ if (!M(e))
198
205
  return !1;
199
- const s = (S(e.data) ? e.data : e).throttled;
206
+ const s = (M(e.data) ? e.data : e).throttled;
200
207
  if (typeof s == "boolean")
201
208
  return s;
202
209
  if (typeof s == "number")
@@ -207,7 +214,7 @@ const q = {
207
214
  }
208
215
  return !1;
209
216
  };
210
- function mt(e, t, s) {
217
+ function pt(e, t, s) {
211
218
  const n = typeof e == "string" && e.trim().length > 0 ? e.trim().toLowerCase() : void 0;
212
219
  if (n)
213
220
  return n;
@@ -217,17 +224,17 @@ function mt(e, t, s) {
217
224
  const i = typeof s == "string" && s.trim().length > 0 ? s.trim().toLowerCase() : void 0;
218
225
  return i ? i === "image" ? "image/*" : i === "video" ? "video/*" : i === "audio" ? "audio/*" : i : "application/octet-stream";
219
226
  }
220
- function pt(e) {
227
+ function vt(e) {
221
228
  const t = e.url || "", s = e.thumbnail_url ?? e.thumbnail, n = {
222
229
  id: e.media_id ?? e.id ?? "",
223
- name: e.name ?? vt(t),
230
+ name: e.name ?? _t(t),
224
231
  url: t,
225
- type: mt(e.mime, e.mime_type, e.type),
232
+ type: pt(e.mime, e.mime_type, e.type),
226
233
  size: e.size ?? 0
227
234
  };
228
235
  return s !== void 0 && (n.thumbnail = s), n;
229
236
  }
230
- function vt(e) {
237
+ function _t(e) {
231
238
  if (!e) return "attachment";
232
239
  try {
233
240
  const s = new URL(e).pathname.split("/");
@@ -236,20 +243,20 @@ function vt(e) {
236
243
  return "attachment";
237
244
  }
238
245
  }
239
- function _t(e) {
240
- return !Array.isArray(e) || e.length === 0 ? [] : e.map(pt);
246
+ function yt(e) {
247
+ return !Array.isArray(e) || e.length === 0 ? [] : e.map(vt);
241
248
  }
242
- function Q(e) {
249
+ function X(e) {
243
250
  if (typeof e != "string")
244
251
  return;
245
252
  const t = e.trim();
246
253
  if (t.length !== 0)
247
254
  return t;
248
255
  }
249
- function yt(e) {
256
+ function bt(e) {
250
257
  if (!e)
251
258
  return;
252
- const t = Q(e.avatar) ?? Q(e.avatar_url), s = typeof e.handle == "string" && e.handle.length > 0 ? e.handle : void 0;
259
+ const t = X(e.avatar) ?? X(e.avatar_url), s = typeof e.handle == "string" && e.handle.length > 0 ? e.handle : void 0;
253
260
  return {
254
261
  id: e.id ?? "",
255
262
  name: e.name ?? "",
@@ -257,7 +264,7 @@ function yt(e) {
257
264
  ...s ? { handle: s } : {}
258
265
  };
259
266
  }
260
- function Y(e) {
267
+ function j(e) {
261
268
  const t = e.shared_post, s = e.author, n = t && typeof t == "object" ? {
262
269
  id: t.id ?? "",
263
270
  title: t.title ?? "",
@@ -273,34 +280,34 @@ function Y(e) {
273
280
  } : null;
274
281
  return {
275
282
  ...e,
276
- ...s ? { author: yt(s) } : {},
283
+ ...s ? { author: bt(s) } : {},
277
284
  shared_post: n,
278
- attachments: _t(e.attachments)
285
+ attachments: yt(e.attachments)
279
286
  };
280
287
  }
281
- function bt(e) {
288
+ function Ct(e) {
282
289
  return typeof e != "string" || e.length === 0 ? null : e;
283
290
  }
284
- function Ce(e) {
291
+ function ve(e) {
285
292
  if (!(typeof e != "string" || e.length === 0))
286
293
  return e;
287
294
  }
288
- function ie(e) {
295
+ function re(e) {
289
296
  return typeof e == "string" && e.length > 0 && !e.startsWith("temp-");
290
297
  }
291
- function Ct(e, t = []) {
298
+ function St(e, t = []) {
292
299
  const s = /* @__PURE__ */ new Map();
293
300
  for (const n of t) {
294
- const r = Ce(n.last_read_message_id);
301
+ const r = ve(n.last_read_message_id);
295
302
  r && s.set(n.user_id, r);
296
303
  }
297
304
  return e.map((n) => {
298
- const r = Q(n.user?.avatar) ?? Q(n.user?.avatar_url), i = n.user ? {
305
+ const r = X(n.user?.avatar) ?? X(n.user?.avatar_url), i = n.user ? {
299
306
  id: n.user.id,
300
307
  name: n.user.name,
301
308
  ...r ? { avatar: r } : {},
302
309
  ...n.user.handle ? { handle: n.user.handle } : {}
303
- } : void 0, o = Ce(n.last_read_message_id);
310
+ } : void 0, o = ve(n.last_read_message_id);
304
311
  if (o)
305
312
  return {
306
313
  ...n,
@@ -319,8 +326,8 @@ function Ct(e, t = []) {
319
326
  };
320
327
  });
321
328
  }
322
- function D(e, t) {
323
- const s = bt(e.muted_until), n = e.is_muted ?? s !== null, r = e.last_message ? Y(e.last_message) : t?.last_message, i = e.last_message_at ?? t?.last_message_at, o = (() => {
329
+ function I(e, t) {
330
+ const s = Ct(e.muted_until), n = e.is_muted ?? s !== null, r = e.last_message ? j(e.last_message) : t?.last_message, i = e.last_message_at ?? t?.last_message_at, o = (() => {
324
331
  if (!t || t.unread_count !== 0 || e.unread_count <= 0)
325
332
  return !1;
326
333
  const a = t.last_message?.id, u = e.last_message?.id;
@@ -329,43 +336,43 @@ function D(e, t) {
329
336
  return {
330
337
  ...e,
331
338
  unread_count: n || o ? 0 : e.unread_count,
332
- participants: Ct(e.participants, t?.participants),
339
+ participants: St(e.participants, t?.participants),
333
340
  is_muted: n,
334
341
  muted_until: s,
335
342
  ...r ? { last_message: r } : {},
336
343
  ...i ? { last_message_at: i } : {}
337
344
  };
338
345
  }
339
- function St(e) {
346
+ function Mt(e) {
340
347
  return e.is_muted ? !0 : typeof e.muted_until == "string" && e.muted_until.length > 0;
341
348
  }
342
- function te(e) {
343
- return St(e) ? 0 : e.unread_count || 0;
349
+ function ee(e) {
350
+ return Mt(e) ? 0 : e.unread_count || 0;
344
351
  }
345
- function Se(e, t) {
352
+ function _e(e, t) {
346
353
  const s = t[e.id];
347
354
  if (Array.isArray(s))
348
355
  for (let n = s.length - 1; n >= 0; n -= 1) {
349
356
  const r = s[n]?.id;
350
- if (ie(r))
357
+ if (re(r))
351
358
  return r;
352
359
  }
353
- return ie(e.last_message?.id) ? e.last_message.id : null;
360
+ return re(e.last_message?.id) ? e.last_message.id : null;
354
361
  }
355
- function S(e) {
362
+ function M(e) {
356
363
  return typeof e == "object" && e !== null;
357
364
  }
358
- function Mt(e) {
359
- return S(e) ? (S(e.response) ? e.response : null)?.status === 401 : !1;
365
+ function wt(e) {
366
+ return M(e) ? (M(e.response) ? e.response : null)?.status === 401 : !1;
360
367
  }
361
- function Me(e) {
368
+ function ye(e) {
362
369
  if (!Array.isArray(e))
363
370
  return [];
364
371
  const t = [];
365
372
  for (const s of e) {
366
- if (!S(s) || typeof s.reaction != "string" || typeof s.count != "number" || !Array.isArray(s.users))
373
+ if (!M(s) || typeof s.reaction != "string" || typeof s.count != "number" || !Array.isArray(s.users))
367
374
  continue;
368
- const n = s.users.filter((r) => S(r)).filter(
375
+ const n = s.users.filter((r) => M(r)).filter(
369
376
  (r) => typeof r.id == "string" && typeof r.name == "string"
370
377
  ).map((r) => ({
371
378
  id: r.id,
@@ -379,58 +386,58 @@ function Me(e) {
379
386
  }
380
387
  return t;
381
388
  }
382
- function wt(e, t) {
383
- const s = S(t) ? t : null, n = s?.next ?? s?.next_cursor ?? e.next_cursor;
389
+ function Rt(e, t) {
390
+ const s = M(t) ? t : null, n = s?.next ?? s?.next_cursor ?? e.next_cursor;
384
391
  if (!(typeof n != "string" || n.length === 0))
385
392
  return n;
386
393
  }
387
- function V(e, t) {
388
- const s = S(e) ? e : {}, n = s.data ?? e;
394
+ function H(e, t) {
395
+ const s = M(e) ? e : {}, n = s.data ?? e;
389
396
  let r = [];
390
- return Array.isArray(n) ? r = n : S(n) && (Array.isArray(n.items) ? r = n.items : Array.isArray(n[t]) ? r = n[t] : Array.isArray(n.data) && (r = n.data)), {
397
+ return Array.isArray(n) ? r = n : M(n) && (Array.isArray(n.items) ? r = n.items : Array.isArray(n[t]) ? r = n[t] : Array.isArray(n.data) && (r = n.data)), {
391
398
  items: r,
392
- nextCursor: wt(s, n)
399
+ nextCursor: Rt(s, n)
393
400
  };
394
401
  }
395
- function we(e) {
396
- return S(e) && typeof e.id == "string" && e.id.length > 0;
402
+ function be(e) {
403
+ return M(e) && typeof e.id == "string" && e.id.length > 0;
397
404
  }
398
- function Re(e) {
399
- return S(e) ? typeof e.id == "string" && (e.type === "dm" || e.type === "group") && Array.isArray(e.participants) : !1;
405
+ function Ce(e) {
406
+ return M(e) ? typeof e.id == "string" && (e.type === "dm" || e.type === "group") && Array.isArray(e.participants) : !1;
400
407
  }
401
- function j(e, t) {
408
+ function W(e, t) {
402
409
  if (e.is_pinned !== t.is_pinned)
403
410
  return e.is_pinned ? -1 : 1;
404
411
  const s = e.last_message_at ?? e.created_at, r = (t.last_message_at ?? t.created_at).localeCompare(s);
405
412
  return r !== 0 ? r : e.id.localeCompare(t.id);
406
413
  }
407
- function H(e, t) {
414
+ function Y(e, t) {
408
415
  return [t, ...e.filter((s) => s.id !== t.id)];
409
416
  }
410
- function I(e) {
417
+ function $(e) {
411
418
  return [...e].sort((t, s) => t.sort_order !== s.sort_order ? t.sort_order - s.sort_order : t.name.localeCompare(s.name));
412
419
  }
413
- function Rt(e, t) {
420
+ function At(e, t) {
414
421
  return typeof e != "string" || e.length === 0 ? null : t.has(e) ? e : null;
415
422
  }
416
- function Ae(e, t) {
423
+ function Se(e, t) {
417
424
  return e.map((s) => {
418
- const n = Rt(s.folder_id, t);
425
+ const n = At(s.folder_id, t);
419
426
  return (s.folder_id ?? null) === n ? s : {
420
427
  ...s,
421
428
  folder_id: n
422
429
  };
423
430
  });
424
431
  }
425
- function se(e) {
432
+ function te(e) {
426
433
  const t = /* @__PURE__ */ new Map();
427
434
  for (const s of e.requests)
428
435
  s.is_request === !0 && t.set(s.id, s);
429
436
  for (const s of e.conversations)
430
437
  s.is_request === !0 && t.set(s.id, s);
431
- return Array.from(t.values()).sort(j);
438
+ return Array.from(t.values()).sort(W);
432
439
  }
433
- const Oe = Ve("messaging", {
440
+ const De = Ge("messaging", {
434
441
  state: () => ({
435
442
  conversations: [],
436
443
  requests: [],
@@ -457,46 +464,46 @@ const Oe = Ve("messaging", {
457
464
  getConversationById: (e) => (t) => e.conversations.find((s) => s.id === t),
458
465
  getMessagesByConversationId: (e) => (t) => e.messages[t] || [],
459
466
  getTypingUsers: (e) => (t) => e.typingUsers[t] || [],
460
- unreadConversationsCount: (e) => e.conversations.filter((t) => te(t) > 0).length,
461
- unreadCount: (e) => e.conversations.reduce((t, s) => t + te(s), 0),
462
- totalUnreadCount: (e) => e.conversations.reduce((t, s) => t + te(s), 0),
463
- sortedFolders: (e) => I(e.folders),
467
+ unreadConversationsCount: (e) => e.conversations.filter((t) => ee(t) > 0).length,
468
+ unreadCount: (e) => e.conversations.reduce((t, s) => t + ee(s), 0),
469
+ totalUnreadCount: (e) => e.conversations.reduce((t, s) => t + ee(s), 0),
470
+ sortedFolders: (e) => $(e.folders),
464
471
  folderById: (e) => (t) => e.folders.find((s) => s.id === t),
465
472
  conversationsInFolder: (e) => (t) => e.conversations.filter((s) => s.folder_id === t),
466
473
  hasMoreMessages: (e) => (t) => e.conversationHasMore[t] ?? !1,
467
474
  isLoadingMessages: (e) => (t) => e.loadingMessages[t] ?? !1,
468
475
  // Message request getters
469
- requestConversations: (e) => se(e),
470
- requestCount: (e) => se(e).length,
471
- unreadRequestCount: (e) => se(e).filter((t) => t.unread_count > 0).length
476
+ requestConversations: (e) => te(e),
477
+ requestCount: (e) => te(e).length,
478
+ unreadRequestCount: (e) => te(e).filter((t) => t.unread_count > 0).length
472
479
  },
473
480
  actions: {
474
481
  normalizeFolderAssignmentsState() {
475
482
  if (!this.foldersLoaded)
476
483
  return;
477
484
  const e = new Set(this.folders.map((t) => t.id));
478
- this.conversations = Ae(this.conversations, e), this.requests = Ae(this.requests, e), this.activeFolderId !== null && !e.has(this.activeFolderId) && (this.activeFolderId = null);
485
+ this.conversations = Se(this.conversations, e), this.requests = Se(this.requests, e), this.activeFolderId !== null && !e.has(this.activeFolderId) && (this.activeFolderId = null);
479
486
  },
480
487
  async fetchFolders() {
481
488
  try {
482
- const e = await q.fetchFolders();
483
- return this.folders = I(e), this.foldersLoaded = !0, this.normalizeFolderAssignmentsState(), this.folders;
489
+ const e = await P.fetchFolders();
490
+ return this.folders = $(e), this.foldersLoaded = !0, this.normalizeFolderAssignmentsState(), this.folders;
484
491
  } catch (e) {
485
492
  throw this.error = m(e), e;
486
493
  }
487
494
  },
488
495
  async createFolder(e) {
489
496
  try {
490
- const t = await q.createFolder(e);
491
- return this.folders = I([...this.folders, t]), t;
497
+ const t = await P.createFolder(e);
498
+ return this.folders = $([...this.folders, t]), t;
492
499
  } catch (t) {
493
500
  throw this.error = m(t), t;
494
501
  }
495
502
  },
496
503
  async updateFolder(e, t) {
497
504
  try {
498
- const s = await q.updateFolder(e, t);
499
- return this.folders = I(
505
+ const s = await P.updateFolder(e, t);
506
+ return this.folders = $(
500
507
  this.folders.map((n) => n.id === e ? s : n)
501
508
  ), s;
502
509
  } catch (s) {
@@ -505,14 +512,14 @@ const Oe = Ve("messaging", {
505
512
  },
506
513
  async deleteFolder(e) {
507
514
  try {
508
- await q.deleteFolder(e), this.folders = this.folders.filter((t) => t.id !== e), this.foldersLoaded = !0, this.activeFolderId === e && (this.activeFolderId = null), this.normalizeFolderAssignmentsState();
515
+ await P.deleteFolder(e), this.folders = this.folders.filter((t) => t.id !== e), this.foldersLoaded = !0, this.activeFolderId === e && (this.activeFolderId = null), this.normalizeFolderAssignmentsState();
509
516
  } catch (t) {
510
517
  throw this.error = m(t), t;
511
518
  }
512
519
  },
513
520
  async reorderFolders(e) {
514
521
  try {
515
- await q.reorderFolders(e);
522
+ await P.reorderFolders(e);
516
523
  const t = new Map(this.folders.map((r) => [r.id, r])), s = [];
517
524
  for (const r of e) {
518
525
  const i = t.get(r);
@@ -521,7 +528,7 @@ const Oe = Ve("messaging", {
521
528
  sort_order: s.length + 1
522
529
  }), t.delete(r));
523
530
  }
524
- const n = I(Array.from(t.values()));
531
+ const n = $(Array.from(t.values()));
525
532
  for (const r of n)
526
533
  s.push({
527
534
  ...r,
@@ -534,7 +541,7 @@ const Oe = Ve("messaging", {
534
541
  },
535
542
  async assignToFolder(e, t) {
536
543
  try {
537
- const s = await q.assignFolder(e, t), n = this.conversations.findIndex((o) => o.id === e);
544
+ const s = await P.assignFolder(e, t), n = this.conversations.findIndex((o) => o.id === e);
538
545
  if (n < 0)
539
546
  return;
540
547
  const r = this.conversations[n];
@@ -554,23 +561,23 @@ const Oe = Ve("messaging", {
554
561
  try {
555
562
  const r = n?.includePresence ?? !0, i = {};
556
563
  r && (i.include_presence = 1), e && (i.cursor = e), t && (i.filter = t), typeof s == "string" && s.length > 0 && (i.folder_id = s);
557
- const o = await l.get("/v1/messaging/conversations", { params: i }), { items: a, nextCursor: u } = V(
564
+ const o = await l.get("/v1/messaging/conversations", { params: i }), { items: a, nextCursor: u } = H(
558
565
  o.data,
559
566
  "conversations"
560
567
  ), f = a.map((d) => {
561
568
  const p = this.conversations.find(
562
569
  (F) => F.id === d.id
563
570
  );
564
- return D(d, p);
571
+ return I(d, p);
565
572
  });
566
573
  e ? this.conversations.push(...f) : this.conversations = f, this.normalizeFolderAssignmentsState(), this.lastFetch = Date.now();
567
- const _ = {
574
+ const y = {
568
575
  data: f,
569
576
  has_more: !!u
570
577
  };
571
- return u !== void 0 && (_.next_cursor = u), _;
578
+ return u !== void 0 && (y.next_cursor = u), y;
572
579
  } catch (r) {
573
- throw n?.background && ye(r) || (this.error = m(r)), r;
580
+ throw n?.background && me(r) || (this.error = m(r)), r;
574
581
  } finally {
575
582
  this.loading = !1;
576
583
  }
@@ -584,8 +591,8 @@ const Oe = Ve("messaging", {
584
591
  includePresence: !1
585
592
  }), this.backgroundPollRetryAfterUntil = 0, this.backgroundPollTransientFailureCount = 0, !0;
586
593
  } catch (e) {
587
- const t = e, s = fe(t.response?.status);
588
- return s === 429 ? (this.backgroundPollRetryAfterUntil = Date.now() + Ie(t.response?.headers?.["retry-after"]), !1) : (this.backgroundPollTransientFailureCount += 1, s === void 0 || De(s) ? (this.backgroundPollRetryAfterUntil = Date.now() + ft(this.backgroundPollTransientFailureCount), !1) : (this.backgroundPollRetryAfterUntil = Date.now() + le, !1));
594
+ const t = e, s = ae(t.response?.status);
595
+ return s === 429 ? (this.backgroundPollRetryAfterUntil = Date.now() + ze(t.response?.headers?.["retry-after"]), !1) : (this.backgroundPollTransientFailureCount += 1, s === void 0 || Ue(s) ? (this.backgroundPollRetryAfterUntil = Date.now() + ht(this.backgroundPollTransientFailureCount), !1) : (this.backgroundPollRetryAfterUntil = Date.now() + oe, !1));
589
596
  }
590
597
  },
591
598
  async fetchConversation(e) {
@@ -593,7 +600,7 @@ const Oe = Ve("messaging", {
593
600
  try {
594
601
  const t = await l.get(`/v1/messaging/conversations/${e}`, {
595
602
  params: { include_presence: 1 }
596
- }), s = this.conversations.find((o) => o.id === e), n = D(t.data.data || t.data, s), r = this.conversations.findIndex((o) => o.id === e);
603
+ }), s = this.conversations.find((o) => o.id === e), n = I(t.data.data || t.data, s), r = this.conversations.findIndex((o) => o.id === e);
597
604
  r >= 0 ? this.conversations[r] = n : this.conversations.push(n);
598
605
  const i = this.requests.findIndex((o) => o.id === e);
599
606
  return i >= 0 && (this.requests[i] = n), this.normalizeFolderAssignmentsState(), n;
@@ -611,12 +618,12 @@ const Oe = Ve("messaging", {
611
618
  filter: "requests"
612
619
  };
613
620
  e && (t.cursor = e);
614
- const s = await l.get("/v1/messaging/conversations", { params: t }), { items: n, nextCursor: r } = V(
621
+ const s = await l.get("/v1/messaging/conversations", { params: t }), { items: n, nextCursor: r } = H(
615
622
  s.data,
616
623
  "conversations"
617
624
  ), i = n.map((a) => {
618
625
  const u = this.requests.find((f) => f.id === a.id);
619
- return D(a, u);
626
+ return I(a, u);
620
627
  });
621
628
  e ? this.requests.push(...i) : this.requests = i, this.normalizeFolderAssignmentsState();
622
629
  const o = {
@@ -640,14 +647,14 @@ const Oe = Ve("messaging", {
640
647
  r = await l.get(`/v1/messaging/conversations/${e}/messages`, { params: s });
641
648
  break;
642
649
  } catch (d) {
643
- if (!(n < dt && ye(d)))
650
+ if (!(n < lt && me(d)))
644
651
  throw d;
645
- n += 1, await be(ht(d));
652
+ n += 1, await pe(gt(d));
646
653
  }
647
- const { items: i, nextCursor: o } = V(
654
+ const { items: i, nextCursor: o } = H(
648
655
  r.data,
649
656
  "messages"
650
- ), a = i.map(Y), u = [...a].reverse();
657
+ ), a = i.map(j), u = [...a].reverse();
651
658
  if (t ? this.messages[e] = [...u, ...this.messages[e] || []] : this.messages[e] = u, (() => {
652
659
  const d = this.conversations.find((p) => p.id === e) ?? this.requests.find((p) => p.id === e);
653
660
  return d ? !d.last_message || !d.last_message_at : !1;
@@ -656,11 +663,11 @@ const Oe = Ve("messaging", {
656
663
  d && this.updateConversationLastMessage(e, d);
657
664
  }
658
665
  o ? (this.conversationCursors[e] = o, this.conversationHasMore[e] = !0) : (delete this.conversationCursors[e], this.conversationHasMore[e] = !1);
659
- const _ = {
666
+ const y = {
660
667
  data: a,
661
668
  has_more: !!o
662
669
  };
663
- return o !== void 0 && (_.next_cursor = o), _;
670
+ return o !== void 0 && (y.next_cursor = o), y;
664
671
  } catch (s) {
665
672
  throw this.error = m(s), s;
666
673
  } finally {
@@ -668,7 +675,7 @@ const Oe = Ve("messaging", {
668
675
  }
669
676
  },
670
677
  async sendMessage(e, t, s, n, r, i) {
671
- const o = L(), a = `temp-${Date.now()}-${Math.random()}`, u = typeof i == "string" && i.trim().length > 0 ? i.trim() : null, f = o.currentUser, _ = {
678
+ const o = L(), a = `temp-${Date.now()}-${Math.random()}`, u = typeof i == "string" && i.trim().length > 0 ? i.trim() : null, f = o.currentUser, y = {
672
679
  id: a,
673
680
  conversation_id: e,
674
681
  author_id: f?.id || "",
@@ -679,12 +686,12 @@ const Oe = Ve("messaging", {
679
686
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
680
687
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
681
688
  };
682
- f && (_.author = {
689
+ f && (y.author = {
683
690
  id: f.id,
684
691
  name: f.name,
685
692
  ...f.avatar ? { avatar: f.avatar } : {},
686
693
  ...f.handle ? { handle: f.handle } : {}
687
- }), n != null && (_.reply_to_id = n), r != null && (_.reply_to = r), this.messages[e] || (this.messages[e] = []), this.messages[e].push(_), this._pendingSendIds.add(a);
694
+ }), n != null && (y.reply_to_id = n), r != null && (y.reply_to = r), this.messages[e] || (this.messages[e] = []), this.messages[e].push(y), this._pendingSendIds.add(a);
688
695
  try {
689
696
  let d;
690
697
  const p = {
@@ -694,12 +701,12 @@ const Oe = Ve("messaging", {
694
701
  };
695
702
  if (s && s.length > 0) {
696
703
  const v = await Promise.all(
697
- s.map(async (A) => {
698
- const y = await de.uploadImage(A);
704
+ s.map(async (E) => {
705
+ const b = await ie.uploadImage(E);
699
706
  return {
700
- media_id: y.id,
701
- mime: y.mime_type,
702
- size: y.size
707
+ media_id: b.id,
708
+ mime: b.mime_type,
709
+ size: b.size
703
710
  };
704
711
  })
705
712
  );
@@ -712,15 +719,15 @@ const Oe = Ve("messaging", {
712
719
  ...p,
713
720
  type: "text"
714
721
  });
715
- const F = d.data.data || d.data, U = { ..._, ...F, attachments: F.attachments ?? _.attachments }, R = Y(U), E = this.messages[e], T = E.findIndex((v) => v.id === a);
716
- T >= 0 && (E[T] = R), this._pendingSendIds.delete(a);
717
- const z = R.id;
722
+ const F = d.data.data || d.data, N = { ...y, ...F, attachments: F.attachments ?? y.attachments }, A = j(N), T = this.messages[e], x = T.findIndex((v) => v.id === a);
723
+ x >= 0 && (T[x] = A), this._pendingSendIds.delete(a);
724
+ const U = A.id;
718
725
  let h = 0;
719
- for (let v = E.length - 1; v >= 0; v--) {
720
- const A = E[v];
721
- A && A.id === z && (h++, h > 1 && E.splice(v, 1));
726
+ for (let v = T.length - 1; v >= 0; v--) {
727
+ const E = T[v];
728
+ E && E.id === U && (h++, h > 1 && T.splice(v, 1));
722
729
  }
723
- return this.updateConversationLastMessage(e, R), R;
730
+ return this.updateConversationLastMessage(e, A), A;
724
731
  } catch (d) {
725
732
  throw this._pendingSendIds.delete(a), this.messages[e] = this.messages[e].filter((p) => p.id !== a), this.error = m(d), d;
726
733
  }
@@ -762,11 +769,11 @@ const Oe = Ve("messaging", {
762
769
  return null;
763
770
  for (let i = r.length - 1; i >= 0; i -= 1) {
764
771
  const o = r[i]?.id;
765
- if (ie(o))
772
+ if (re(o))
766
773
  return o;
767
774
  }
768
775
  return null;
769
- })(), n = t ? Se(t, this.messages) : s;
776
+ })(), n = t ? _e(t, this.messages) : s;
770
777
  if (!n)
771
778
  return;
772
779
  await l.post(`/v1/messaging/conversations/${e}/read`, {
@@ -785,7 +792,7 @@ const Oe = Ve("messaging", {
785
792
  if (e.length === 0)
786
793
  return;
787
794
  const t = e.map((r) => {
788
- const i = Se(r, this.messages);
795
+ const i = _e(r, this.messages);
789
796
  return i ? {
790
797
  conversationId: r.id,
791
798
  messageId: i
@@ -817,9 +824,9 @@ const Oe = Ve("messaging", {
817
824
  async sendTyping(e, t = "start") {
818
825
  try {
819
826
  const s = await l.post(`/v1/messaging/conversations/${e}/typing`, { state: t });
820
- if (t !== "start" || !gt(s.data))
827
+ if (t !== "start" || !mt(s.data))
821
828
  return;
822
- await be(lt), await l.post(`/v1/messaging/conversations/${e}/typing`, { state: t });
829
+ await pe(ft), await l.post(`/v1/messaging/conversations/${e}/typing`, { state: t });
823
830
  } catch (s) {
824
831
  console.warn("Failed to send typing indicator:", s);
825
832
  }
@@ -859,7 +866,7 @@ const Oe = Ve("messaging", {
859
866
  try {
860
867
  await l.patch(`/v1/messaging/conversations/${e}/pin`, { pinned: t });
861
868
  const s = this.conversations.find((n) => n.id === e);
862
- s && (s.is_pinned = t), this.conversations.sort(j);
869
+ s && (s.is_pinned = t), this.conversations.sort(W);
863
870
  } catch (s) {
864
871
  throw this.error = m(s), s;
865
872
  }
@@ -885,10 +892,10 @@ const Oe = Ve("messaging", {
885
892
  };
886
893
  t && (s.message = t);
887
894
  const n = await l.post("/v1/messaging/conversations/dm", s), r = n.data.data || n.data;
888
- if (!we(r))
895
+ if (!be(r))
889
896
  throw new Error("Invalid conversation payload from DM create endpoint.");
890
- const i = Re(r) ? D(r) : await this.fetchConversation(r.id);
891
- return i.is_request === !0 ? (this.requests = H(this.requests, i), this.conversations = this.conversations.filter((o) => o.id !== i.id), i) : (this.conversations = H(this.conversations, i), this.requests = this.requests.filter((o) => o.id !== i.id), i);
897
+ const i = Ce(r) ? I(r) : await this.fetchConversation(r.id);
898
+ return i.is_request === !0 ? (this.requests = Y(this.requests, i), this.conversations = this.conversations.filter((o) => o.id !== i.id), i) : (this.conversations = Y(this.conversations, i), this.requests = this.requests.filter((o) => o.id !== i.id), i);
892
899
  } catch (s) {
893
900
  throw this.error = m(s), s;
894
901
  }
@@ -899,10 +906,10 @@ const Oe = Ve("messaging", {
899
906
  title: e,
900
907
  participant_ids: t
901
908
  }), n = s.data.data || s.data;
902
- if (!we(n))
909
+ if (!be(n))
903
910
  throw new Error("Invalid conversation payload from group create endpoint.");
904
- const r = Re(n) ? n : await this.fetchConversation(n.id);
905
- return this.conversations = H(this.conversations, r), r;
911
+ const r = Ce(n) ? n : await this.fetchConversation(n.id);
912
+ return this.conversations = Y(this.conversations, r), r;
906
913
  } catch (s) {
907
914
  throw this.error = m(s), s;
908
915
  }
@@ -938,7 +945,7 @@ const Oe = Ve("messaging", {
938
945
  if (!t)
939
946
  return;
940
947
  this.messages[t] || (this.messages[t] = []);
941
- const s = Y({ ...e, attachments: e.attachments ?? [] }), n = this.messages[t];
948
+ const s = j({ ...e, attachments: e.attachments ?? [] }), n = this.messages[t];
942
949
  if (n.find((u) => u.id === s.id))
943
950
  return;
944
951
  const i = L();
@@ -997,17 +1004,17 @@ const Oe = Ve("messaging", {
997
1004
  try {
998
1005
  a = await l.post(n, r);
999
1006
  } catch (d) {
1000
- if (!Mt(d))
1007
+ if (!wt(d))
1001
1008
  throw d;
1002
1009
  a = await l.post(n, r);
1003
1010
  }
1004
- const u = S(a.data) && "data" in a.data ? a.data.data : a.data, f = Me(
1005
- S(u) ? u.reactions : void 0
1011
+ const u = M(a.data) && "data" in a.data ? a.data.data : a.data, f = ye(
1012
+ M(u) ? u.reactions : void 0
1006
1013
  );
1007
1014
  (f.length > 0 || o.length === 0) && this.updateMessageReactions(e, t, f);
1008
1015
  try {
1009
- const d = await l.get(n), p = S(d.data) && "data" in d.data ? d.data.data : d.data, F = Me(
1010
- S(p) ? p.reactions : void 0
1016
+ const d = await l.get(n), p = M(d.data) && "data" in d.data ? d.data.data : d.data, F = ye(
1017
+ M(p) ? p.reactions : void 0
1011
1018
  );
1012
1019
  this.updateMessageReactions(e, t, F);
1013
1020
  } catch {
@@ -1038,7 +1045,7 @@ const Oe = Ve("messaging", {
1038
1045
  const o = i.find((a) => a.id === e);
1039
1046
  return o ? (o.last_message = t, o.last_message_at = t.created_at, !0) : !1;
1040
1047
  }, n = s(this.conversations), r = s(this.requests);
1041
- n && this.conversations.sort(j), r && this.requests.sort(j);
1048
+ n && this.conversations.sort(W), r && this.requests.sort(W);
1042
1049
  },
1043
1050
  updatePresenceForUser(e, t) {
1044
1051
  const s = t === "online" || t === "idle" || t === "dnd";
@@ -1047,22 +1054,22 @@ const Oe = Ve("messaging", {
1047
1054
  },
1048
1055
  async acceptRequest(e) {
1049
1056
  try {
1050
- const t = await q.acceptRequest(e);
1057
+ const t = await P.acceptRequest(e);
1051
1058
  this.requests = this.requests.filter((n) => n.id !== e);
1052
- const s = D({
1059
+ const s = I({
1053
1060
  ...t,
1054
1061
  is_pinned: t.is_pinned ?? !1,
1055
1062
  is_archived: t.is_archived ?? !1,
1056
1063
  is_muted: t.is_muted ?? !1
1057
1064
  });
1058
- this.conversations = H(this.conversations, s);
1065
+ this.conversations = Y(this.conversations, s);
1059
1066
  } catch (t) {
1060
1067
  throw this.error = m(t), t;
1061
1068
  }
1062
1069
  },
1063
1070
  async declineRequest(e) {
1064
1071
  try {
1065
- await q.declineRequest(e), this.requests = this.requests.filter((t) => t.id !== e);
1072
+ await P.declineRequest(e), this.requests = this.requests.filter((t) => t.id !== e);
1066
1073
  } catch (t) {
1067
1074
  throw this.error = m(t), t;
1068
1075
  }
@@ -1074,7 +1081,7 @@ const Oe = Ve("messaging", {
1074
1081
  t && (n.filter = t), typeof s == "string" && s.length > 0 && (n.folder_id = s);
1075
1082
  const r = await l.get("/v1/messaging/conversations", {
1076
1083
  params: n
1077
- }), { items: i } = V(
1084
+ }), { items: i } = H(
1078
1085
  r.data,
1079
1086
  "conversations"
1080
1087
  );
@@ -1133,117 +1140,117 @@ const Oe = Ve("messaging", {
1133
1140
  }
1134
1141
  }
1135
1142
  });
1136
- function Gt(e) {
1137
- const t = Oe(), s = L(), n = J(!1), r = J(null), i = J(null), o = Fe(), a = o !== null, u = 20, f = 250;
1138
- let _ = 0, d = null, p = null;
1139
- const F = K(() => s.currentUser?.id), U = () => Be(e)?.trim() ?? "", R = () => {
1140
- d && (clearTimeout(d), d = null), _ = 0;
1141
- }, E = () => {
1142
- !a || n.value || d || _ >= u || (d = setTimeout(() => {
1143
- d = null, _ += 1, T();
1144
- }, f));
1143
+ function kt(e) {
1144
+ const t = De(), s = L(), n = Q(!1), r = Q(null), i = Q(null), o = Me(), a = o !== null, u = 20, f = 250;
1145
+ let y = 0, d = null, p = null;
1146
+ const F = J(() => s.currentUser?.id), N = () => Oe(e)?.trim() ?? "", A = () => {
1147
+ d && (clearTimeout(d), d = null), y = 0;
1145
1148
  }, T = () => {
1146
- const c = U();
1149
+ !a || n.value || d || y >= u || (d = setTimeout(() => {
1150
+ d = null, y += 1, x();
1151
+ }, f));
1152
+ }, x = () => {
1153
+ const c = N();
1147
1154
  if (!(n.value || !c)) {
1148
- if (!P()) {
1149
- E();
1155
+ if (!O()) {
1156
+ T();
1150
1157
  return;
1151
1158
  }
1152
1159
  r.value = null;
1153
1160
  try {
1154
- p = ce(c, {
1155
- onMessageSent: A,
1156
- onMessageRead: y,
1157
- onMessageEdited: $,
1158
- onMessageDeleted: O,
1159
- onReactionToggled: G,
1160
- onRequestAccepted: k,
1161
- onParticipantRemoved: b
1162
- }), n.value = !0, i.value = c, t.registerDetailSubscription(c), R();
1161
+ p = We(c, {
1162
+ onMessageSent: E,
1163
+ onMessageRead: b,
1164
+ onMessageEdited: z,
1165
+ onMessageDeleted: G,
1166
+ onReactionToggled: k,
1167
+ onRequestAccepted: V,
1168
+ onParticipantRemoved: C
1169
+ }), n.value = !0, i.value = c, t.registerDetailSubscription(c), A();
1163
1170
  } catch (g) {
1164
1171
  r.value = g instanceof Error ? g.message : "Failed to subscribe to conversation", console.error("ConversationChannel: Subscribe error", g);
1165
1172
  }
1166
1173
  }
1167
- }, z = () => {
1168
- n.value || T();
1174
+ }, U = () => {
1175
+ n.value || x();
1169
1176
  };
1170
- typeof window < "u" && window.addEventListener(W, z);
1171
- const h = Z((c) => {
1177
+ typeof window < "u" && window.addEventListener(le(), U);
1178
+ const h = xe((c) => {
1172
1179
  if (c === "connected") {
1173
- n.value || T();
1180
+ n.value || x();
1174
1181
  return;
1175
1182
  }
1176
- (c === "disconnected" || c === "error") && (R(), p && (p(), p = null), i.value && (t.unregisterDetailSubscription(i.value), i.value = null), n.value = !1);
1183
+ (c === "disconnected" || c === "error") && (A(), p && (p(), p = null), i.value && (t.unregisterDetailSubscription(i.value), i.value = null), n.value = !1);
1177
1184
  }), v = () => {
1178
1185
  const c = i.value;
1179
- if (R(), !(!n.value || !c))
1186
+ if (A(), !(!n.value || !c))
1180
1187
  try {
1181
- p && (p(), p = null), t.hasGlobalConversationSubscription(c) || ue(c), n.value = !1, t.unregisterDetailSubscription(c), i.value = null, r.value = null;
1188
+ p && (p(), p = null), t.hasGlobalConversationSubscription(c) || Ze(c), n.value = !1, t.unregisterDetailSubscription(c), i.value = null, r.value = null;
1182
1189
  } catch (g) {
1183
1190
  r.value = g instanceof Error ? g.message : "Failed to unsubscribe from conversation", console.error("ConversationChannel: Unsubscribe error", g);
1184
1191
  }
1185
- }, A = (c) => {
1192
+ }, E = (c) => {
1186
1193
  if (t.addMessage(c.message), c.message.author_id !== F.value) {
1187
1194
  const g = t.getConversationById(c.conversation_id);
1188
1195
  g && (g.unread_count = 0), t.markAsRead(c.conversation_id).catch(() => {
1189
1196
  });
1190
1197
  }
1191
- }, y = (c) => {
1198
+ }, b = (c) => {
1192
1199
  const g = t.getConversationById(c.conversation_id);
1193
1200
  if (g) {
1194
- let M = !1;
1195
- const w = g.participants.map((C) => C.user_id !== c.user_id || C.last_read_message_id === c.message_id ? C : (M = !0, {
1196
- ...C,
1201
+ let w = !1;
1202
+ const R = g.participants.map((S) => S.user_id !== c.user_id || S.last_read_message_id === c.message_id ? S : (w = !0, {
1203
+ ...S,
1197
1204
  last_read_message_id: c.message_id
1198
1205
  }));
1199
- M && (g.participants = w);
1206
+ w && (g.participants = R);
1200
1207
  }
1201
- }, $ = (c) => {
1202
- const g = t.getMessagesByConversationId(c.conversation_id), M = g.findIndex((w) => w.id === c.message.id);
1203
- if (M >= 0) {
1204
- const w = g[M];
1205
- if (!w) return;
1206
- const C = { ...w };
1207
- c.message.body !== void 0 && (C.body = c.message.body), c.message.edited_at !== void 0 && (C.edited_at = c.message.edited_at), c.message.meta !== void 0 && (C.meta = c.message.meta), g[M] = C;
1208
- const x = t.getConversationById(c.conversation_id);
1209
- x && x.last_message?.id === c.message.id && (x.last_message = C);
1208
+ }, z = (c) => {
1209
+ const g = t.getMessagesByConversationId(c.conversation_id), w = g.findIndex((R) => R.id === c.message.id);
1210
+ if (w >= 0) {
1211
+ const R = g[w];
1212
+ if (!R) return;
1213
+ const S = { ...R };
1214
+ c.message.body !== void 0 && (S.body = c.message.body), c.message.edited_at !== void 0 && (S.edited_at = c.message.edited_at), c.message.meta !== void 0 && (S.meta = c.message.meta), g[w] = S;
1215
+ const q = t.getConversationById(c.conversation_id);
1216
+ q && q.last_message?.id === c.message.id && (q.last_message = S);
1210
1217
  }
1211
- }, O = (c) => {
1212
- t.removeMessage(c.conversation_id, c.message_id);
1213
1218
  }, G = (c) => {
1219
+ t.removeMessage(c.conversation_id, c.message_id);
1220
+ }, k = (c) => {
1214
1221
  t.updateMessageReactions(
1215
1222
  c.conversation_id,
1216
1223
  c.message_id,
1217
1224
  c.reactions
1218
1225
  );
1219
- }, k = (c) => {
1226
+ }, V = (c) => {
1220
1227
  const g = t.getConversationById(c.conversation_id);
1221
1228
  g && (g.is_request = !1), t.requests = t.requests.filter(
1222
- (M) => M.id !== c.conversation_id
1229
+ (w) => w.id !== c.conversation_id
1223
1230
  );
1224
- }, b = (c) => {
1231
+ }, C = (c) => {
1225
1232
  c.removed_user_id === F.value && (v(), t.deleteConversation(c.conversation_id).catch(() => {
1226
1233
  }));
1227
1234
  };
1228
- return o !== null && Ee(() => {
1229
- R(), h(), v(), typeof window < "u" && window.removeEventListener(W, z);
1235
+ return o !== null && we(() => {
1236
+ A(), h(), v(), typeof window < "u" && window.removeEventListener(le(), U);
1230
1237
  }), {
1231
- isSubscribed: K(() => n.value),
1232
- error: K(() => r.value),
1233
- subscribe: T,
1238
+ isSubscribed: J(() => n.value),
1239
+ error: J(() => r.value),
1240
+ subscribe: x,
1234
1241
  unsubscribe: v
1235
1242
  };
1236
1243
  }
1237
- const Ge = () => {
1244
+ const Ie = () => {
1238
1245
  };
1239
- let he = Ge;
1240
- function At(e) {
1241
- he = e;
1246
+ let ce = Ie;
1247
+ function Et(e) {
1248
+ ce = e;
1242
1249
  }
1243
1250
  function Ft() {
1244
- he = Ge;
1251
+ ce = Ie;
1245
1252
  }
1246
- const Et = {
1253
+ const Tt = {
1247
1254
  debug: () => {
1248
1255
  },
1249
1256
  info: () => {
@@ -1252,24 +1259,24 @@ const Et = {
1252
1259
  },
1253
1260
  error: () => {
1254
1261
  }
1255
- }, ke = () => Et;
1256
- let ge = ke;
1257
- function Tt(e) {
1258
- ge = e;
1262
+ }, $e = () => Tt;
1263
+ let ue = $e;
1264
+ function xt(e) {
1265
+ ue = e;
1259
1266
  }
1260
- function xt() {
1261
- ge = ke;
1267
+ function qt() {
1268
+ ue = $e;
1262
1269
  }
1263
- const ne = ge("GlobalMessaging"), qt = 3, Pt = (e) => e.replace(/\/+$/, ""), Lt = (e) => Pt(window.location.pathname) === `/messages/${e}`, Ut = (e) => e.is_muted ? !0 : typeof e.muted_until == "string" && e.muted_until.length > 0;
1264
- function kt() {
1265
- const e = Oe(), t = L(), s = We(), n = Fe(), { conversations: r } = He(e), i = /* @__PURE__ */ new Set(), o = /* @__PURE__ */ new Map();
1270
+ const se = ue("GlobalMessaging"), Pt = 3, Lt = (e) => e.replace(/\/+$/, ""), Nt = (e) => Lt(window.location.pathname) === `/messages/${e}`, Ut = (e) => e.is_muted ? !0 : typeof e.muted_until == "string" && e.muted_until.length > 0;
1271
+ function Vt() {
1272
+ const e = De(), t = L(), s = He(), n = Me(), { conversations: r } = ke(e), i = /* @__PURE__ */ new Set(), o = /* @__PURE__ */ new Map();
1266
1273
  let a = !1;
1267
1274
  function u(h) {
1268
1275
  const v = o.get(h);
1269
1276
  if (v && (o.delete(h), typeof v.channel.stopListening == "function"))
1270
- for (const A of v.bindings)
1277
+ for (const E of v.bindings)
1271
1278
  try {
1272
- v.channel.stopListening(A.event, A.handler);
1279
+ v.channel.stopListening(E.event, E.handler);
1273
1280
  } catch {
1274
1281
  }
1275
1282
  }
@@ -1278,68 +1285,68 @@ function kt() {
1278
1285
  u(h), e.unregisterGlobalConversationSubscription(h);
1279
1286
  i.clear();
1280
1287
  }
1281
- function _(h) {
1282
- const v = P();
1288
+ function y(h) {
1289
+ const v = O();
1283
1290
  if (!v || i.has(h)) return;
1284
- const A = (b) => {
1285
- const c = e.getConversationById(b.conversation_id);
1291
+ const E = (C) => {
1292
+ const c = e.getConversationById(C.conversation_id);
1286
1293
  if (!c)
1287
1294
  return;
1288
1295
  let g = !1;
1289
- const M = c.participants.map((w) => w.user_id !== b.user_id || w.last_read_message_id === b.message_id ? w : (g = !0, {
1290
- ...w,
1291
- last_read_message_id: b.message_id
1296
+ const w = c.participants.map((R) => R.user_id !== C.user_id || R.last_read_message_id === C.message_id ? R : (g = !0, {
1297
+ ...R,
1298
+ last_read_message_id: C.message_id
1292
1299
  }));
1293
- g && (c.participants = M);
1294
- }, y = `conversation.${h}`;
1300
+ g && (c.participants = w);
1301
+ }, b = `conversation.${h}`;
1295
1302
  u(h);
1296
- const $ = v.private(y), O = (b) => {
1297
- if (!Ze(b)) {
1298
- ne.warn("Dropping malformed ConversationMessageSent event", b);
1303
+ const z = v.private(b), G = (C) => {
1304
+ if (!Je(C)) {
1305
+ se.warn("Dropping malformed ConversationMessageSent event", C);
1299
1306
  return;
1300
1307
  }
1301
- const c = b, g = t.currentUser?.id;
1308
+ const c = C, g = t.currentUser?.id;
1302
1309
  if (!g || c.message.author_id === g) return;
1303
1310
  e.addMessage(c.message);
1304
- const M = e.hasDetailSubscription(c.conversation_id), w = Lt(c.conversation_id);
1305
- if (M || w) {
1306
- const x = e.getConversationById(c.conversation_id);
1307
- x && (x.unread_count = 0), e.markAsRead(c.conversation_id).catch(() => {
1311
+ const w = e.hasDetailSubscription(c.conversation_id), R = Nt(c.conversation_id);
1312
+ if (w || R) {
1313
+ const q = e.getConversationById(c.conversation_id);
1314
+ q && (q.unread_count = 0), e.markAsRead(c.conversation_id).catch(() => {
1308
1315
  });
1309
1316
  return;
1310
1317
  }
1311
- const C = e.getConversationById(c.conversation_id);
1312
- if (C) {
1313
- const x = Ut(C);
1314
- x || C.unread_count++, he(x);
1318
+ const S = e.getConversationById(c.conversation_id);
1319
+ if (S) {
1320
+ const q = Ut(S);
1321
+ q || S.unread_count++, ce(q);
1315
1322
  }
1316
- }, G = (b) => {
1317
- if (!Je(b)) {
1318
- ne.warn("Dropping malformed ConversationMessageRead event", b);
1323
+ }, k = (C) => {
1324
+ if (!Ke(C)) {
1325
+ se.warn("Dropping malformed ConversationMessageRead event", C);
1319
1326
  return;
1320
1327
  }
1321
- A(b);
1322
- }, k = (b) => {
1323
- if (!Ke(b)) {
1324
- ne.warn("Dropping malformed ConversationRequestAccepted event", b);
1328
+ E(C);
1329
+ }, V = (C) => {
1330
+ if (!et(C)) {
1331
+ se.warn("Dropping malformed ConversationRequestAccepted event", C);
1325
1332
  return;
1326
1333
  }
1327
- const c = b, g = e.getConversationById(c.conversation_id);
1334
+ const c = C, g = e.getConversationById(c.conversation_id);
1328
1335
  g && (g.is_request = !1), e.requests = e.requests.filter(
1329
- (M) => M.id !== c.conversation_id
1336
+ (w) => w.id !== c.conversation_id
1330
1337
  );
1331
1338
  };
1332
- $.listen(".ConversationMessageSent", O), $.listen(".ConversationMessageRead", G), $.listen(".ConversationRequestAccepted", k), o.set(h, {
1333
- channel: $,
1339
+ z.listen(".ConversationMessageSent", G), z.listen(".ConversationMessageRead", k), z.listen(".ConversationRequestAccepted", V), o.set(h, {
1340
+ channel: z,
1334
1341
  bindings: [
1335
- { event: ".ConversationMessageSent", handler: O },
1336
- { event: ".ConversationMessageRead", handler: G },
1337
- { event: ".ConversationRequestAccepted", handler: k }
1342
+ { event: ".ConversationMessageSent", handler: G },
1343
+ { event: ".ConversationMessageRead", handler: k },
1344
+ { event: ".ConversationRequestAccepted", handler: V }
1338
1345
  ]
1339
1346
  }), i.add(h), e.registerGlobalConversationSubscription(h);
1340
1347
  }
1341
1348
  function d() {
1342
- const h = P();
1349
+ const h = O();
1343
1350
  if (!h) {
1344
1351
  f();
1345
1352
  return;
@@ -1355,86 +1362,86 @@ function kt() {
1355
1362
  i.clear();
1356
1363
  }
1357
1364
  function p() {
1358
- const h = P();
1365
+ const h = O();
1359
1366
  if (!h) return;
1360
- const v = e.conversations.slice(0, qt), A = new Set(v.map((y) => y.id));
1361
- for (const y of i)
1362
- if (!A.has(y) && !e.hasDetailSubscription(y)) {
1367
+ const v = e.conversations.slice(0, Pt), E = new Set(v.map((b) => b.id));
1368
+ for (const b of i)
1369
+ if (!E.has(b) && !e.hasDetailSubscription(b)) {
1363
1370
  try {
1364
- u(y), h.leave(`conversation.${y}`);
1371
+ u(b), h.leave(`conversation.${b}`);
1365
1372
  } catch {
1366
1373
  }
1367
- i.delete(y), e.unregisterGlobalConversationSubscription(y);
1374
+ i.delete(b), e.unregisterGlobalConversationSubscription(b);
1368
1375
  }
1369
- for (const y of v)
1370
- _(y.id);
1376
+ for (const b of v)
1377
+ y(b.id);
1371
1378
  }
1372
1379
  function F(h) {
1373
1380
  e.updatePresenceForUser(h.user_id, h.status);
1374
1381
  }
1375
- function U() {
1376
- !P() || a || (oe(F), a = !0);
1382
+ function N() {
1383
+ !O() || a || (Ye(F), a = !0);
1377
1384
  }
1378
- function R() {
1379
- a && (ae(), a = !1);
1385
+ function A() {
1386
+ a && (je(), a = !1);
1380
1387
  }
1381
- const E = me(
1388
+ const T = de(
1382
1389
  r,
1383
1390
  () => {
1384
1391
  p();
1385
1392
  },
1386
1393
  { deep: !1, immediate: !0 }
1387
- ), T = me(
1394
+ ), x = de(
1388
1395
  () => s.fullPath,
1389
1396
  () => {
1390
1397
  p();
1391
1398
  }
1392
- ), z = Z((h) => {
1393
- h === "connected" ? (f(), p(), R(), U()) : (h === "disconnected" || h === "error") && (f(), R());
1399
+ ), U = xe((h) => {
1400
+ h === "connected" ? (f(), p(), A(), N()) : (h === "disconnected" || h === "error") && (f(), A());
1394
1401
  });
1395
- p(), U(), n !== null && Ee(() => {
1396
- E(), T(), z(), d(), R();
1402
+ p(), N(), n !== null && we(() => {
1403
+ T(), x(), U(), d(), A();
1397
1404
  });
1398
1405
  }
1399
1406
  function Bt(e) {
1400
- e.apiClient && et(e.apiClient), e.authStore && st(e.authStore), e.mediaApi && rt(e.mediaApi), e.createLogger && Tt(e.createLogger), e.playMessageNotification && At(e.playMessageNotification), e.echo && Xe(e.echo);
1407
+ e.apiClient && tt(e.apiClient), e.authStore && nt(e.authStore), e.mediaApi && it(e.mediaApi), e.createLogger && xt(e.createLogger), e.playMessageNotification && Et(e.playMessageNotification), e.echo && Xe(e.echo);
1401
1408
  }
1402
- function Vt() {
1403
- tt(), nt(), it(), xt(), Ft(), Qe();
1409
+ function Ht() {
1410
+ st(), rt(), ot(), qt(), Ft(), Qe();
1404
1411
  }
1405
1412
  export {
1406
- W as ECHO_INITIALIZED_EVENT,
1407
1413
  l as api,
1408
1414
  Bt as configureMessengerClient,
1409
- ge as createLogger,
1410
- P as getEcho,
1415
+ ue as createLogger,
1416
+ O as getEcho,
1417
+ le as getEchoInitializedEvent,
1411
1418
  m as getErrorMessage,
1412
- Ot as hasResponse,
1413
- jt as isAxiosError,
1414
- It as isError,
1415
- Je as isValidMessageReadEvent,
1416
- Ze as isValidMessageSentEvent,
1417
- Ke as isValidRequestAcceptedEvent,
1418
- de as mediaApi,
1419
- q as messagingApi,
1420
- Z as onConnectionStatusChange,
1419
+ Gt as hasResponse,
1420
+ Wt as isAxiosError,
1421
+ Ot as isError,
1422
+ Ke as isValidMessageReadEvent,
1423
+ Je as isValidMessageSentEvent,
1424
+ et as isValidRequestAcceptedEvent,
1425
+ ie as mediaApi,
1426
+ P as messagingApi,
1427
+ xe as onConnectionStatusChange,
1421
1428
  Qe as resetEchoRuntimeConfig,
1422
- xt as resetLoggerFactory,
1423
- tt as resetMessagingApiClient,
1424
- nt as resetMessagingAuthStoreResolver,
1425
- it as resetMessagingMediaApi,
1426
- Vt as resetMessengerClientConfig,
1429
+ qt as resetLoggerFactory,
1430
+ st as resetMessagingApiClient,
1431
+ rt as resetMessagingAuthStoreResolver,
1432
+ ot as resetMessagingMediaApi,
1433
+ Ht as resetMessengerClientConfig,
1427
1434
  Xe as setEchoRuntimeConfig,
1428
- Tt as setLoggerFactory,
1429
- et as setMessagingApiClient,
1430
- st as setMessagingAuthStoreResolver,
1431
- rt as setMessagingMediaApi,
1432
- ce as subscribeToConversation,
1433
- oe as subscribeToPresenceStatus,
1434
- ue as unsubscribeFromConversation,
1435
- ae as unsubscribeFromPresenceStatus,
1435
+ xt as setLoggerFactory,
1436
+ tt as setMessagingApiClient,
1437
+ nt as setMessagingAuthStoreResolver,
1438
+ it as setMessagingMediaApi,
1439
+ We as subscribeToConversation,
1440
+ Ye as subscribeToPresenceStatus,
1441
+ Ze as unsubscribeFromConversation,
1442
+ je as unsubscribeFromPresenceStatus,
1436
1443
  L as useAuthStore,
1437
- Gt as useConversationChannel,
1438
- kt as useGlobalMessaging,
1439
- Oe as useMessagingStore
1444
+ kt as useConversationChannel,
1445
+ Vt as useGlobalMessaging,
1446
+ De as useMessagingStore
1440
1447
  };