@codingfactory/messenger-client 0.1.5 → 0.1.6

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.
Files changed (2) hide show
  1. package/dist/index.js +352 -342
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,101 +1,101 @@
1
- import { ref as J, getCurrentInstance as Ae, computed as K, onUnmounted as Ee, toValue as Ve, watch as he } from "vue";
2
- import { defineStore as Be, storeToRefs as He } from "pinia";
3
- import je, { isAxiosError as Ye } from "axios";
4
- import { isAxiosError as es } from "axios";
5
- import { useRoute as We } from "vue-router";
6
- const Fe = () => () => {
1
+ import { ref as Q, getCurrentInstance as we, computed as J, onUnmounted as Ae, toValue as ke, watch as fe } from "vue";
2
+ import { defineStore as Ve, storeToRefs as Be } from "pinia";
3
+ import He, { isAxiosError as je } from "axios";
4
+ import { isAxiosError as Kt } from "axios";
5
+ import { useRoute as Ye } from "vue-router";
6
+ const Ee = () => () => {
7
+ }, Fe = () => {
7
8
  }, Te = () => {
8
9
  }, xe = () => {
9
10
  }, qe = () => {
10
- }, Pe = () => {
11
11
  throw new Error("messenger-client subscribeToConversation is not configured");
12
12
  }, y = {
13
13
  ECHO_INITIALIZED_EVENT: "messenger-client:echo-initialized",
14
14
  getEcho: () => null,
15
- onConnectionStatusChange: Fe,
16
- subscribeToPresenceStatus: Te,
17
- unsubscribeFromPresenceStatus: xe,
18
- subscribeToConversation: Pe,
19
- unsubscribeFromConversation: qe
20
- }, ge = () => y.ECHO_INITIALIZED_EVENT, G = () => y.getEcho(), Le = (e) => y.onConnectionStatusChange(e), Ze = (e) => y.subscribeToPresenceStatus(e), Xe = () => y.unsubscribeFromPresenceStatus(), Qe = (e, t) => y.subscribeToConversation(e, t), Je = (e) => y.unsubscribeFromConversation(e);
21
- function Ke(e) {
15
+ onConnectionStatusChange: Ee,
16
+ subscribeToPresenceStatus: Fe,
17
+ unsubscribeFromPresenceStatus: Te,
18
+ subscribeToConversation: qe,
19
+ unsubscribeFromConversation: xe
20
+ }, he = () => y.ECHO_INITIALIZED_EVENT, G = () => y.getEcho(), Pe = (e) => y.onConnectionStatusChange(e), We = (e) => y.subscribeToPresenceStatus(e), Ze = () => y.unsubscribeFromPresenceStatus(), Xe = (e, t) => y.subscribeToConversation(e, t), Qe = (e) => y.unsubscribeFromConversation(e);
21
+ function Je(e) {
22
22
  e.initializedEvent && (y.ECHO_INITIALIZED_EVENT = e.initializedEvent), e.getEcho && (y.getEcho = e.getEcho), e.onConnectionStatusChange && (y.onConnectionStatusChange = e.onConnectionStatusChange), e.subscribeToPresenceStatus && (y.subscribeToPresenceStatus = e.subscribeToPresenceStatus), e.unsubscribeFromPresenceStatus && (y.unsubscribeFromPresenceStatus = e.unsubscribeFromPresenceStatus), e.subscribeToConversation && (y.subscribeToConversation = e.subscribeToConversation), e.unsubscribeFromConversation && (y.unsubscribeFromConversation = e.unsubscribeFromConversation);
23
23
  }
24
- function et() {
25
- y.ECHO_INITIALIZED_EVENT = "messenger-client:echo-initialized", y.getEcho = () => null, y.onConnectionStatusChange = Fe, y.subscribeToPresenceStatus = Te, y.unsubscribeFromPresenceStatus = xe, y.subscribeToConversation = Pe, y.unsubscribeFromConversation = qe;
24
+ function Ke() {
25
+ y.ECHO_INITIALIZED_EVENT = "messenger-client:echo-initialized", y.getEcho = () => null, y.onConnectionStatusChange = Ee, y.subscribeToPresenceStatus = Fe, y.unsubscribeFromPresenceStatus = Te, y.subscribeToConversation = qe, y.unsubscribeFromConversation = xe;
26
26
  }
27
27
  function Z(e) {
28
28
  return typeof e == "object" && e !== null;
29
29
  }
30
- function tt(e) {
30
+ function et(e) {
31
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";
32
32
  }
33
- function st(e) {
33
+ function tt(e) {
34
34
  return Z(e) && typeof e.conversation_id == "string" && typeof e.user_id == "string" && typeof e.message_id == "string";
35
35
  }
36
- function nt(e) {
36
+ function st(e) {
37
37
  return Z(e) && typeof e.conversation_id == "string";
38
38
  }
39
- const Ne = je;
40
- let oe = Ne;
39
+ const Le = He;
40
+ let ie = Le;
41
41
  function h() {
42
- return oe;
42
+ return ie;
43
43
  }
44
- function rt(e) {
45
- oe = e;
44
+ function nt(e) {
45
+ ie = e;
46
46
  }
47
- function it() {
48
- oe = Ne;
47
+ function rt() {
48
+ ie = Le;
49
49
  }
50
- const Ue = {
50
+ const Ne = {
51
51
  currentUser: null
52
52
  };
53
- let ae = () => Ue;
53
+ let oe = () => Ne;
54
54
  function k() {
55
- return ae;
55
+ return oe;
56
56
  }
57
- function ot(e) {
58
- ae = e;
57
+ function it(e) {
58
+ oe = e;
59
59
  }
60
- function at() {
61
- ae = () => Ue;
60
+ function ot() {
61
+ oe = () => Ne;
62
62
  }
63
63
  function g(e) {
64
- if (Ye(e)) {
64
+ if (je(e)) {
65
65
  const t = e.response?.data?.message || e.message || "An error occurred";
66
66
  return t.includes("SQLSTATE") || t.includes("Connection:") || t.includes("\\Illuminate\\") ? "Something went wrong. Please try again later." : t;
67
67
  }
68
68
  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";
69
69
  }
70
- function jt(e) {
70
+ function Ht(e) {
71
71
  return e instanceof Error;
72
72
  }
73
- function Yt(e) {
73
+ function jt(e) {
74
74
  return typeof e == "object" && e !== null && "response" in e && typeof e.response == "object";
75
75
  }
76
- const ze = {
76
+ const Ue = {
77
77
  async uploadImage() {
78
78
  throw new Error("messenger-client mediaApi.uploadImage is not configured");
79
79
  }
80
80
  };
81
- let ce = ze;
82
- function ct() {
83
- return ce;
81
+ let ae = Ue;
82
+ function at() {
83
+ return ae;
84
84
  }
85
- function ut(e) {
86
- ce = e;
85
+ function ct(e) {
86
+ ae = e;
87
87
  }
88
- function dt() {
89
- ce = ze;
88
+ function ut() {
89
+ ae = Ue;
90
90
  }
91
- function lt(e) {
91
+ function dt(e) {
92
92
  return e !== null && typeof e == "object" && "id" in e && "type" in e && "participants" in e;
93
93
  }
94
- function Ie(e) {
94
+ function ze(e) {
95
95
  return typeof e == "object" && e !== null;
96
96
  }
97
97
  function D(e) {
98
- return !Ie(e) || !("data" in e) ? e : e.data;
98
+ return !ze(e) || !("data" in e) ? e : e.data;
99
99
  }
100
100
  function B(e, t) {
101
101
  const s = e[t];
@@ -103,7 +103,7 @@ function B(e, t) {
103
103
  throw new Error(`Invalid messaging folder payload: missing string ${t}`);
104
104
  return s;
105
105
  }
106
- function me(e, t) {
106
+ function ge(e, t) {
107
107
  const s = e[t];
108
108
  if (s == null)
109
109
  return null;
@@ -111,7 +111,7 @@ function me(e, t) {
111
111
  throw new Error(`Invalid messaging folder payload: ${t} must be a string or null`);
112
112
  return s;
113
113
  }
114
- function ee(e, t) {
114
+ function K(e, t) {
115
115
  const s = e[t];
116
116
  if (typeof s == "number" && Number.isFinite(s))
117
117
  return s;
@@ -122,43 +122,43 @@ function ee(e, t) {
122
122
  }
123
123
  throw new Error(`Invalid messaging folder payload: missing numeric ${t}`);
124
124
  }
125
- function re(e) {
126
- if (!Ie(e))
125
+ function ne(e) {
126
+ if (!ze(e))
127
127
  throw new Error("Invalid messaging folder payload: expected object");
128
128
  return {
129
129
  id: B(e, "id"),
130
130
  name: B(e, "name"),
131
- color: me(e, "color"),
132
- icon: me(e, "icon"),
133
- sort_order: ee(e, "sort_order"),
134
- conversation_count: ee(e, "conversation_count"),
135
- unread_count: ee(e, "unread_count"),
131
+ color: ge(e, "color"),
132
+ icon: ge(e, "icon"),
133
+ sort_order: K(e, "sort_order"),
134
+ conversation_count: K(e, "conversation_count"),
135
+ unread_count: K(e, "unread_count"),
136
136
  created_at: B(e, "created_at"),
137
137
  updated_at: B(e, "updated_at")
138
138
  };
139
139
  }
140
- function ft(e) {
140
+ function lt(e) {
141
141
  if (!Array.isArray(e))
142
142
  throw new Error("Invalid messaging folder payload: expected array");
143
- return e.map((t) => re(t));
143
+ return e.map((t) => ne(t));
144
144
  }
145
- function pe(e) {
146
- if (!lt(e))
145
+ function me(e) {
146
+ if (!dt(e))
147
147
  throw new Error("Invalid conversation payload from folder assignment endpoint");
148
148
  return e;
149
149
  }
150
150
  const x = {
151
151
  async fetchFolders() {
152
152
  const e = await h().get("/v1/messaging/folders");
153
- return ft(D(e.data));
153
+ return lt(D(e.data));
154
154
  },
155
155
  async createFolder(e) {
156
156
  const t = await h().post("/v1/messaging/folders", e);
157
- return re(D(t.data));
157
+ return ne(D(t.data));
158
158
  },
159
159
  async updateFolder(e, t) {
160
160
  const s = await h().patch(`/v1/messaging/folders/${e}`, t);
161
- return re(D(s.data));
161
+ return ne(D(s.data));
162
162
  },
163
163
  async deleteFolder(e) {
164
164
  await h().delete(`/v1/messaging/folders/${e}`);
@@ -170,16 +170,16 @@ const x = {
170
170
  const s = await h().patch(`/v1/messaging/conversations/${e}/folder`, {
171
171
  folder_id: t
172
172
  });
173
- return pe(D(s.data));
173
+ return me(D(s.data));
174
174
  },
175
175
  async acceptRequest(e) {
176
176
  const t = await h().post(`/v1/messaging/conversations/${e}/accept`);
177
- return pe(D(t.data));
177
+ return me(D(t.data));
178
178
  },
179
179
  async declineRequest(e) {
180
180
  await h().post(`/v1/messaging/conversations/${e}/decline`);
181
181
  }
182
- }, ve = 1e3, ue = 4e3, ht = 12e4, gt = 300, mt = 1, pt = 1600, de = (e) => {
182
+ }, pe = 1e3, ce = 4e3, ft = 12e4, ht = 300, gt = 1, mt = 1600, ue = (e) => {
183
183
  if (typeof e == "number" && Number.isFinite(e))
184
184
  return e;
185
185
  if (typeof e == "string") {
@@ -187,32 +187,32 @@ const x = {
187
187
  if (Number.isFinite(t))
188
188
  return t;
189
189
  }
190
- }, De = (e) => typeof e == "number" && e >= 500 && e < 600, _e = (e) => {
191
- const s = de(e.response?.status);
192
- return s === void 0 ? !0 : s === 429 || De(s);
193
- }, $e = (e) => {
190
+ }, Ie = (e) => typeof e == "number" && e >= 500 && e < 600, ve = (e) => {
191
+ const s = ue(e.response?.status);
192
+ return s === void 0 ? !0 : s === 429 || Ie(s);
193
+ }, De = (e) => {
194
194
  if (typeof e == "number" && Number.isFinite(e) && e > 0)
195
- return Math.max(ve, e * 1e3);
195
+ return Math.max(pe, e * 1e3);
196
196
  if (typeof e == "string") {
197
197
  const t = Number.parseInt(e, 10);
198
198
  if (Number.isFinite(t) && t > 0)
199
- return Math.max(ve, t * 1e3);
199
+ return Math.max(pe, t * 1e3);
200
200
  }
201
- return ue;
201
+ return ce;
202
+ }, pt = (e) => {
203
+ const t = Math.max(0, e), s = 2 ** Math.min(t, 6), n = ce * s;
204
+ return Math.min(ft, n);
202
205
  }, vt = (e) => {
203
- const t = Math.max(0, e), s = 2 ** Math.min(t, 6), n = ue * s;
204
- return Math.min(ht, n);
205
- }, _t = (e) => {
206
206
  const t = e;
207
- return de(t.response?.status) === 429 ? $e(t.response?.headers?.["retry-after"]) : gt;
208
- }, ye = async (e) => {
207
+ return ue(t.response?.status) === 429 ? De(t.response?.headers?.["retry-after"]) : ht;
208
+ }, _e = async (e) => {
209
209
  await new Promise((t) => {
210
210
  setTimeout(t, e);
211
211
  });
212
- }, yt = (e) => {
213
- if (!C(e))
212
+ }, _t = (e) => {
213
+ if (!S(e))
214
214
  return !1;
215
- const s = (C(e.data) ? e.data : e).throttled;
215
+ const s = (S(e.data) ? e.data : e).throttled;
216
216
  if (typeof s == "boolean")
217
217
  return s;
218
218
  if (typeof s == "number")
@@ -223,7 +223,7 @@ const x = {
223
223
  }
224
224
  return !1;
225
225
  };
226
- function bt(e, t, s) {
226
+ function yt(e, t, s) {
227
227
  const n = typeof e == "string" && e.trim().length > 0 ? e.trim().toLowerCase() : void 0;
228
228
  if (n)
229
229
  return n;
@@ -233,17 +233,17 @@ function bt(e, t, s) {
233
233
  const i = typeof s == "string" && s.trim().length > 0 ? s.trim().toLowerCase() : void 0;
234
234
  return i ? i === "image" ? "image/*" : i === "video" ? "video/*" : i === "audio" ? "audio/*" : i : "application/octet-stream";
235
235
  }
236
- function Ct(e) {
236
+ function bt(e) {
237
237
  const t = e.url || "", s = e.thumbnail_url ?? e.thumbnail, n = {
238
238
  id: e.media_id ?? e.id ?? "",
239
- name: e.name ?? St(t),
239
+ name: e.name ?? Ct(t),
240
240
  url: t,
241
- type: bt(e.mime, e.mime_type, e.type),
241
+ type: yt(e.mime, e.mime_type, e.type),
242
242
  size: e.size ?? 0
243
243
  };
244
244
  return s !== void 0 && (n.thumbnail = s), n;
245
245
  }
246
- function St(e) {
246
+ function Ct(e) {
247
247
  if (!e) return "attachment";
248
248
  try {
249
249
  const s = new URL(e).pathname.split("/");
@@ -252,8 +252,8 @@ function St(e) {
252
252
  return "attachment";
253
253
  }
254
254
  }
255
- function Mt(e) {
256
- return !Array.isArray(e) || e.length === 0 ? [] : e.map(Ct);
255
+ function St(e) {
256
+ return !Array.isArray(e) || e.length === 0 ? [] : e.map(bt);
257
257
  }
258
258
  function X(e) {
259
259
  if (typeof e != "string")
@@ -262,7 +262,7 @@ function X(e) {
262
262
  if (t.length !== 0)
263
263
  return t;
264
264
  }
265
- function Rt(e) {
265
+ function Mt(e) {
266
266
  if (!e)
267
267
  return;
268
268
  const t = X(e.avatar) ?? X(e.avatar_url), s = typeof e.handle == "string" && e.handle.length > 0 ? e.handle : void 0;
@@ -289,25 +289,25 @@ function Y(e) {
289
289
  } : null;
290
290
  return {
291
291
  ...e,
292
- ...s ? { author: Rt(s) } : {},
292
+ ...s ? { author: Mt(s) } : {},
293
293
  shared_post: n,
294
- attachments: Mt(e.attachments)
294
+ attachments: St(e.attachments)
295
295
  };
296
296
  }
297
- function wt(e) {
297
+ function Rt(e) {
298
298
  return typeof e != "string" || e.length === 0 ? null : e;
299
299
  }
300
- function be(e) {
300
+ function ye(e) {
301
301
  if (!(typeof e != "string" || e.length === 0))
302
302
  return e;
303
303
  }
304
- function ie(e) {
304
+ function re(e) {
305
305
  return typeof e == "string" && e.length > 0 && !e.startsWith("temp-");
306
306
  }
307
- function At(e, t = []) {
307
+ function wt(e, t = []) {
308
308
  const s = /* @__PURE__ */ new Map();
309
309
  for (const n of t) {
310
- const r = be(n.last_read_message_id);
310
+ const r = ye(n.last_read_message_id);
311
311
  r && s.set(n.user_id, r);
312
312
  }
313
313
  return e.map((n) => {
@@ -316,7 +316,7 @@ function At(e, t = []) {
316
316
  name: n.user.name,
317
317
  ...i ? { avatar: i } : {},
318
318
  ...n.user.handle ? { handle: n.user.handle } : {}
319
- } : void 0, a = be(n.last_read_message_id);
319
+ } : void 0, a = ye(n.last_read_message_id);
320
320
  if (a)
321
321
  return {
322
322
  ...n,
@@ -342,7 +342,7 @@ function At(e, t = []) {
342
342
  });
343
343
  }
344
344
  function $(e, t) {
345
- const s = wt(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 = (() => {
345
+ const s = Rt(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 = (() => {
346
346
  if (!t || t.unread_count !== 0 || e.unread_count <= 0)
347
347
  return !1;
348
348
  const a = t.last_message?.id, c = e.last_message?.id;
@@ -351,43 +351,43 @@ function $(e, t) {
351
351
  return {
352
352
  ...e,
353
353
  unread_count: n || o ? 0 : e.unread_count,
354
- participants: At(e.participants, t?.participants),
354
+ participants: wt(e.participants, t?.participants),
355
355
  is_muted: n,
356
356
  muted_until: s,
357
357
  ...r ? { last_message: r } : {},
358
358
  ...i ? { last_message_at: i } : {}
359
359
  };
360
360
  }
361
- function Et(e) {
361
+ function At(e) {
362
362
  return e.is_muted ? !0 : typeof e.muted_until == "string" && e.muted_until.length > 0;
363
363
  }
364
- function te(e) {
365
- return Et(e) ? 0 : e.unread_count || 0;
364
+ function ee(e) {
365
+ return At(e) ? 0 : e.unread_count || 0;
366
366
  }
367
- function Ce(e, t) {
367
+ function be(e, t) {
368
368
  const s = t[e.id];
369
369
  if (Array.isArray(s))
370
370
  for (let n = s.length - 1; n >= 0; n -= 1) {
371
371
  const r = s[n]?.id;
372
- if (ie(r))
372
+ if (re(r))
373
373
  return r;
374
374
  }
375
- return ie(e.last_message?.id) ? e.last_message.id : null;
375
+ return re(e.last_message?.id) ? e.last_message.id : null;
376
376
  }
377
- function C(e) {
377
+ function S(e) {
378
378
  return typeof e == "object" && e !== null;
379
379
  }
380
- function Ft(e) {
381
- return C(e) ? (C(e.response) ? e.response : null)?.status === 401 : !1;
380
+ function Et(e) {
381
+ return S(e) ? (S(e.response) ? e.response : null)?.status === 401 : !1;
382
382
  }
383
- function Se(e) {
383
+ function Ce(e) {
384
384
  if (!Array.isArray(e))
385
385
  return [];
386
386
  const t = [];
387
387
  for (const s of e) {
388
- if (!C(s) || typeof s.reaction != "string" || typeof s.count != "number" || !Array.isArray(s.users))
388
+ if (!S(s) || typeof s.reaction != "string" || typeof s.count != "number" || !Array.isArray(s.users))
389
389
  continue;
390
- const n = s.users.filter((r) => C(r)).filter(
390
+ const n = s.users.filter((r) => S(r)).filter(
391
391
  (r) => typeof r.id == "string" && typeof r.name == "string"
392
392
  ).map((r) => ({
393
393
  id: r.id,
@@ -401,24 +401,24 @@ function Se(e) {
401
401
  }
402
402
  return t;
403
403
  }
404
- function Tt(e, t) {
405
- const s = C(t) ? t : null, n = s?.next ?? s?.next_cursor ?? e.next_cursor;
404
+ function Ft(e, t) {
405
+ const s = S(t) ? t : null, n = s?.next ?? s?.next_cursor ?? e.next_cursor;
406
406
  if (!(typeof n != "string" || n.length === 0))
407
407
  return n;
408
408
  }
409
409
  function H(e, t) {
410
- const s = C(e) ? e : {}, n = s.data ?? e;
410
+ const s = S(e) ? e : {}, n = s.data ?? e;
411
411
  let r = [];
412
- return Array.isArray(n) ? r = n : C(n) && (Array.isArray(n.items) ? r = n.items : Array.isArray(n[t]) ? r = n[t] : Array.isArray(n.data) && (r = n.data)), {
412
+ 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)), {
413
413
  items: r,
414
- nextCursor: Tt(s, n)
414
+ nextCursor: Ft(s, n)
415
415
  };
416
416
  }
417
- function Me(e) {
418
- return C(e) && typeof e.id == "string" && e.id.length > 0;
417
+ function Se(e) {
418
+ return S(e) && typeof e.id == "string" && e.id.length > 0;
419
419
  }
420
- function Re(e) {
421
- return C(e) ? typeof e.id == "string" && (e.type === "dm" || e.type === "group") && Array.isArray(e.participants) : !1;
420
+ function Me(e) {
421
+ return S(e) ? typeof e.id == "string" && (e.type === "dm" || e.type === "group") && Array.isArray(e.participants) : !1;
422
422
  }
423
423
  function W(e, t) {
424
424
  if (e.is_pinned !== t.is_pinned)
@@ -432,19 +432,19 @@ function j(e, t) {
432
432
  function O(e) {
433
433
  return [...e].sort((t, s) => t.sort_order !== s.sort_order ? t.sort_order - s.sort_order : t.name.localeCompare(s.name));
434
434
  }
435
- function xt(e, t) {
435
+ function Tt(e, t) {
436
436
  return typeof e != "string" || e.length === 0 ? null : t.has(e) ? e : null;
437
437
  }
438
- function we(e, t) {
438
+ function Re(e, t) {
439
439
  return e.map((s) => {
440
- const n = xt(s.folder_id, t);
440
+ const n = Tt(s.folder_id, t);
441
441
  return (s.folder_id ?? null) === n ? s : {
442
442
  ...s,
443
443
  folder_id: n
444
444
  };
445
445
  });
446
446
  }
447
- function se(e) {
447
+ function te(e) {
448
448
  const t = /* @__PURE__ */ new Map();
449
449
  for (const s of e.requests)
450
450
  s.is_request === !0 && t.set(s.id, s);
@@ -452,7 +452,7 @@ function se(e) {
452
452
  s.is_request === !0 && t.set(s.id, s);
453
453
  return Array.from(t.values()).sort(W);
454
454
  }
455
- const Oe = Be("messaging", {
455
+ const $e = Ve("messaging", {
456
456
  state: () => ({
457
457
  conversations: [],
458
458
  requests: [],
@@ -479,25 +479,25 @@ const Oe = Be("messaging", {
479
479
  getConversationById: (e) => (t) => e.conversations.find((s) => s.id === t),
480
480
  getMessagesByConversationId: (e) => (t) => e.messages[t] || [],
481
481
  getTypingUsers: (e) => (t) => e.typingUsers[t] || [],
482
- unreadConversationsCount: (e) => e.conversations.filter((t) => te(t) > 0).length,
483
- unreadCount: (e) => e.conversations.reduce((t, s) => t + te(s), 0),
484
- totalUnreadCount: (e) => e.conversations.reduce((t, s) => t + te(s), 0),
482
+ unreadConversationsCount: (e) => e.conversations.filter((t) => ee(t) > 0).length,
483
+ unreadCount: (e) => e.conversations.reduce((t, s) => t + ee(s), 0),
484
+ totalUnreadCount: (e) => e.conversations.reduce((t, s) => t + ee(s), 0),
485
485
  sortedFolders: (e) => O(e.folders),
486
486
  folderById: (e) => (t) => e.folders.find((s) => s.id === t),
487
487
  conversationsInFolder: (e) => (t) => e.conversations.filter((s) => s.folder_id === t),
488
488
  hasMoreMessages: (e) => (t) => e.conversationHasMore[t] ?? !1,
489
489
  isLoadingMessages: (e) => (t) => e.loadingMessages[t] ?? !1,
490
490
  // Message request getters
491
- requestConversations: (e) => se(e),
492
- requestCount: (e) => se(e).length,
493
- unreadRequestCount: (e) => se(e).filter((t) => t.unread_count > 0).length
491
+ requestConversations: (e) => te(e),
492
+ requestCount: (e) => te(e).length,
493
+ unreadRequestCount: (e) => te(e).filter((t) => t.unread_count > 0).length
494
494
  },
495
495
  actions: {
496
496
  normalizeFolderAssignmentsState() {
497
497
  if (!this.foldersLoaded)
498
498
  return;
499
499
  const e = new Set(this.folders.map((t) => t.id));
500
- this.conversations = we(this.conversations, e), this.requests = we(this.requests, e), this.activeFolderId !== null && !e.has(this.activeFolderId) && (this.activeFolderId = null);
500
+ this.conversations = Re(this.conversations, e), this.requests = Re(this.requests, e), this.activeFolderId !== null && !e.has(this.activeFolderId) && (this.activeFolderId = null);
501
501
  },
502
502
  async fetchFolders() {
503
503
  try {
@@ -581,18 +581,18 @@ const Oe = Be("messaging", {
581
581
  "conversations"
582
582
  ), f = a.map((d) => {
583
583
  const m = this.conversations.find(
584
- (S) => S.id === d.id
584
+ (M) => M.id === d.id
585
585
  );
586
586
  return $(d, m);
587
587
  });
588
588
  e ? this.conversations.push(...f) : this.conversations = f, this.normalizeFolderAssignmentsState(), this.lastFetch = Date.now();
589
- const p = {
589
+ const v = {
590
590
  data: f,
591
591
  has_more: !!c
592
592
  };
593
- return c !== void 0 && (p.next_cursor = c), p;
593
+ return c !== void 0 && (v.next_cursor = c), v;
594
594
  } catch (r) {
595
- throw n?.background && _e(r) || (this.error = g(r)), r;
595
+ throw n?.background && ve(r) || (this.error = g(r)), r;
596
596
  } finally {
597
597
  this.loading = !1;
598
598
  }
@@ -606,8 +606,8 @@ const Oe = Be("messaging", {
606
606
  includePresence: !1
607
607
  }), this.backgroundPollRetryAfterUntil = 0, this.backgroundPollTransientFailureCount = 0, !0;
608
608
  } catch (e) {
609
- const t = e, s = de(t.response?.status);
610
- return s === 429 ? (this.backgroundPollRetryAfterUntil = Date.now() + $e(t.response?.headers?.["retry-after"]), !1) : (this.backgroundPollTransientFailureCount += 1, s === void 0 || De(s) ? (this.backgroundPollRetryAfterUntil = Date.now() + vt(this.backgroundPollTransientFailureCount), !1) : (this.backgroundPollRetryAfterUntil = Date.now() + ue, !1));
609
+ const t = e, s = ue(t.response?.status);
610
+ return s === 429 ? (this.backgroundPollRetryAfterUntil = Date.now() + De(t.response?.headers?.["retry-after"]), !1) : (this.backgroundPollTransientFailureCount += 1, s === void 0 || Ie(s) ? (this.backgroundPollRetryAfterUntil = Date.now() + pt(this.backgroundPollTransientFailureCount), !1) : (this.backgroundPollRetryAfterUntil = Date.now() + ce, !1));
611
611
  }
612
612
  },
613
613
  async fetchConversation(e) {
@@ -662,9 +662,9 @@ const Oe = Be("messaging", {
662
662
  r = await h().get(`/v1/messaging/conversations/${e}/messages`, { params: s });
663
663
  break;
664
664
  } catch (d) {
665
- if (!(n < mt && _e(d)))
665
+ if (!(n < gt && ve(d)))
666
666
  throw d;
667
- n += 1, await ye(_t(d));
667
+ n += 1, await _e(vt(d));
668
668
  }
669
669
  const { items: i, nextCursor: o } = H(
670
670
  r.data,
@@ -678,11 +678,11 @@ const Oe = Be("messaging", {
678
678
  d && this.updateConversationLastMessage(e, d);
679
679
  }
680
680
  o ? (this.conversationCursors[e] = o, this.conversationHasMore[e] = !0) : (delete this.conversationCursors[e], this.conversationHasMore[e] = !1);
681
- const p = {
681
+ const v = {
682
682
  data: a,
683
683
  has_more: !!o
684
684
  };
685
- return o !== void 0 && (p.next_cursor = o), p;
685
+ return o !== void 0 && (v.next_cursor = o), v;
686
686
  } catch (s) {
687
687
  throw this.error = g(s), s;
688
688
  } finally {
@@ -690,7 +690,7 @@ const Oe = Be("messaging", {
690
690
  }
691
691
  },
692
692
  async sendMessage(e, t, s, n, r, i) {
693
- const o = k()(), a = `temp-${Date.now()}-${Math.random()}`, c = typeof i == "string" && i.trim().length > 0 ? i.trim() : null, f = o.currentUser, p = {
693
+ const o = k()(), a = `temp-${Date.now()}-${Math.random()}`, c = typeof i == "string" && i.trim().length > 0 ? i.trim() : null, f = o.currentUser, v = {
694
694
  id: a,
695
695
  conversation_id: e,
696
696
  author_id: f?.id || "",
@@ -701,12 +701,12 @@ const Oe = Be("messaging", {
701
701
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
702
702
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
703
703
  };
704
- f && (p.author = {
704
+ f && (v.author = {
705
705
  id: f.id,
706
706
  name: f.name,
707
707
  ...f.avatar ? { avatar: f.avatar } : {},
708
708
  ...f.handle ? { handle: f.handle } : {}
709
- }), n != null && (p.reply_to_id = n), r != null && (p.reply_to = r), this.messages[e] || (this.messages[e] = []), this.messages[e].push(p), this._pendingSendIds.add(a);
709
+ }), n != null && (v.reply_to_id = n), r != null && (v.reply_to = r), this.messages[e] || (this.messages[e] = []), this.messages[e].push(v), this._pendingSendIds.add(a);
710
710
  try {
711
711
  let d;
712
712
  const m = {
@@ -716,12 +716,12 @@ const Oe = Be("messaging", {
716
716
  };
717
717
  if (s && s.length > 0) {
718
718
  const l = await Promise.all(
719
- s.map(async (v) => {
720
- const A = await ct().uploadImage(v);
719
+ s.map(async (_) => {
720
+ const w = await at().uploadImage(_);
721
721
  return {
722
- media_id: A.id,
723
- mime: A.mime_type,
724
- size: A.size
722
+ media_id: w.id,
723
+ mime: w.mime_type,
724
+ size: w.size
725
725
  };
726
726
  })
727
727
  );
@@ -734,15 +734,15 @@ const Oe = Be("messaging", {
734
734
  ...m,
735
735
  type: "text"
736
736
  });
737
- const S = d.data.data || d.data, U = { ...p, ...S, attachments: S.attachments ?? p.attachments }, w = Y(U), E = this.messages[e], L = E.findIndex((l) => l.id === a);
738
- L >= 0 && (E[L] = w), this._pendingSendIds.delete(a);
739
- const z = w.id;
740
- let N = 0;
741
- for (let l = E.length - 1; l >= 0; l--) {
742
- const v = E[l];
743
- v && v.id === z && (N++, N > 1 && E.splice(l, 1));
737
+ const M = d.data.data || d.data, U = { ...v, ...M, attachments: M.attachments ?? v.attachments }, R = Y(U), A = this.messages[e], P = A.findIndex((l) => l.id === a);
738
+ P >= 0 && (A[P] = R), this._pendingSendIds.delete(a);
739
+ const z = R.id;
740
+ let L = 0;
741
+ for (let l = A.length - 1; l >= 0; l--) {
742
+ const _ = A[l];
743
+ _ && _.id === z && (L++, L > 1 && A.splice(l, 1));
744
744
  }
745
- return this.updateConversationLastMessage(e, w), w;
745
+ return this.updateConversationLastMessage(e, R), R;
746
746
  } catch (d) {
747
747
  throw this._pendingSendIds.delete(a), this.messages[e] = this.messages[e].filter((m) => m.id !== a), this.error = g(d), d;
748
748
  }
@@ -784,11 +784,11 @@ const Oe = Be("messaging", {
784
784
  return null;
785
785
  for (let i = r.length - 1; i >= 0; i -= 1) {
786
786
  const o = r[i]?.id;
787
- if (ie(o))
787
+ if (re(o))
788
788
  return o;
789
789
  }
790
790
  return null;
791
- })(), n = t ? Ce(t, this.messages) : s;
791
+ })(), n = t ? be(t, this.messages) : s;
792
792
  if (!n)
793
793
  return;
794
794
  await h().post(`/v1/messaging/conversations/${e}/read`, {
@@ -807,7 +807,7 @@ const Oe = Be("messaging", {
807
807
  if (e.length === 0)
808
808
  return;
809
809
  const t = e.map((r) => {
810
- const i = Ce(r, this.messages);
810
+ const i = be(r, this.messages);
811
811
  return i ? {
812
812
  conversationId: r.id,
813
813
  messageId: i
@@ -839,9 +839,9 @@ const Oe = Be("messaging", {
839
839
  async sendTyping(e, t = "start") {
840
840
  try {
841
841
  const s = await h().post(`/v1/messaging/conversations/${e}/typing`, { state: t });
842
- if (t !== "start" || !yt(s.data))
842
+ if (t !== "start" || !_t(s.data))
843
843
  return;
844
- await ye(pt), await h().post(`/v1/messaging/conversations/${e}/typing`, { state: t });
844
+ await _e(mt), await h().post(`/v1/messaging/conversations/${e}/typing`, { state: t });
845
845
  } catch (s) {
846
846
  console.warn("Failed to send typing indicator:", s);
847
847
  }
@@ -907,9 +907,9 @@ const Oe = Be("messaging", {
907
907
  };
908
908
  t && (s.message = t);
909
909
  const n = await h().post("/v1/messaging/conversations/dm", s), r = n.data.data || n.data;
910
- if (!Me(r))
910
+ if (!Se(r))
911
911
  throw new Error("Invalid conversation payload from DM create endpoint.");
912
- const i = Re(r) ? $(r) : await this.fetchConversation(r.id);
912
+ const i = Me(r) ? $(r) : await this.fetchConversation(r.id);
913
913
  return i.is_request === !0 ? (this.requests = j(this.requests, i), this.conversations = this.conversations.filter((o) => o.id !== i.id), i) : (this.conversations = j(this.conversations, i), this.requests = this.requests.filter((o) => o.id !== i.id), i);
914
914
  } catch (s) {
915
915
  throw this.error = g(s), s;
@@ -921,9 +921,9 @@ const Oe = Be("messaging", {
921
921
  title: e,
922
922
  participant_ids: t
923
923
  }), n = s.data.data || s.data;
924
- if (!Me(n))
924
+ if (!Se(n))
925
925
  throw new Error("Invalid conversation payload from group create endpoint.");
926
- const r = Re(n) ? n : await this.fetchConversation(n.id);
926
+ const r = Me(n) ? n : await this.fetchConversation(n.id);
927
927
  return this.conversations = j(this.conversations, r), r;
928
928
  } catch (s) {
929
929
  throw this.error = g(s), s;
@@ -1031,19 +1031,19 @@ const Oe = Be("messaging", {
1031
1031
  try {
1032
1032
  a = await h().post(n, r);
1033
1033
  } catch (d) {
1034
- if (!Ft(d))
1034
+ if (!Et(d))
1035
1035
  throw d;
1036
1036
  a = await h().post(n, r);
1037
1037
  }
1038
- const c = C(a.data) && "data" in a.data ? a.data.data : a.data, f = Se(
1039
- C(c) ? c.reactions : void 0
1038
+ const c = S(a.data) && "data" in a.data ? a.data.data : a.data, f = Ce(
1039
+ S(c) ? c.reactions : void 0
1040
1040
  );
1041
1041
  (f.length > 0 || o.length === 0) && this.updateMessageReactions(e, t, f);
1042
1042
  try {
1043
- const d = await h().get(n), m = C(d.data) && "data" in d.data ? d.data.data : d.data, S = Se(
1044
- C(m) ? m.reactions : void 0
1043
+ const d = await h().get(n), m = S(d.data) && "data" in d.data ? d.data.data : d.data, M = Ce(
1044
+ S(m) ? m.reactions : void 0
1045
1045
  );
1046
- this.updateMessageReactions(e, t, S);
1046
+ this.updateMessageReactions(e, t, M);
1047
1047
  } catch {
1048
1048
  }
1049
1049
  } catch (a) {
@@ -1167,114 +1167,124 @@ const Oe = Be("messaging", {
1167
1167
  }
1168
1168
  }
1169
1169
  });
1170
- function Wt(e) {
1171
- const t = Oe(), s = k()(), n = J(!1), r = J(null), i = J(null), o = Ae(), a = o !== null, c = 20, f = 250;
1172
- let p = 0, d = null, m = null;
1173
- const S = K(() => s.currentUser?.id), U = () => Ve(e)?.trim() ?? "", w = () => {
1174
- d && (clearTimeout(d), d = null), p = 0;
1175
- }, E = () => {
1176
- !a || n.value || d || p >= c || (d = setTimeout(() => {
1177
- d = null, p += 1, q();
1170
+ function Yt(e) {
1171
+ const t = $e(), s = k()(), n = Q(!1), r = Q(null), i = Q(null), o = we(), a = o !== null, c = 20, f = 250;
1172
+ let v = 0, d = null, m = null;
1173
+ const M = J(() => s.currentUser?.id), U = () => ke(e)?.trim() ?? "";
1174
+ function R() {
1175
+ d && (clearTimeout(d), d = null), v = 0;
1176
+ }
1177
+ function A() {
1178
+ !a || n.value || d || v >= c || (d = setTimeout(() => {
1179
+ d = null, v += 1, q();
1178
1180
  }, f));
1179
- }, L = (u) => {
1180
- if (t.addMessage(u.message), u.message.author_id !== S.value) {
1181
- const _ = t.getConversationById(u.conversation_id);
1182
- _ && (_.unread_count = 0), t.markAsRead(u.conversation_id).catch(() => {
1181
+ }
1182
+ function P(u) {
1183
+ if (t.addMessage(u.message), u.message.author_id !== M.value) {
1184
+ const p = t.getConversationById(u.conversation_id);
1185
+ p && (p.unread_count = 0), t.markAsRead(u.conversation_id).catch(() => {
1183
1186
  });
1184
1187
  }
1185
- }, z = (u) => {
1188
+ }
1189
+ function z(u) {
1186
1190
  t.applyParticipantReadState(u);
1187
- }, N = (u) => {
1188
- const _ = t.getMessagesByConversationId(u.conversation_id), P = _.findIndex((T) => T.id === u.message.id);
1189
- if (P >= 0) {
1190
- const T = _[P];
1191
- if (!T) return;
1192
- const F = { ...T };
1193
- u.message.body !== void 0 && (F.body = u.message.body), u.message.edited_at !== void 0 && (F.edited_at = u.message.edited_at), u.message.meta !== void 0 && (F.meta = u.message.meta), _[P] = F;
1194
- const Q = t.getConversationById(u.conversation_id);
1195
- Q && Q.last_message?.id === u.message.id && (Q.last_message = F);
1191
+ }
1192
+ function L(u) {
1193
+ const p = t.getMessagesByConversationId(u.conversation_id), E = p.findIndex((N) => N.id === u.message.id);
1194
+ if (E >= 0) {
1195
+ const N = p[E];
1196
+ if (!N) return;
1197
+ const F = { ...N };
1198
+ u.message.body !== void 0 && (F.body = u.message.body), u.message.edited_at !== void 0 && (F.edited_at = u.message.edited_at), u.message.meta !== void 0 && (F.meta = u.message.meta), p[E] = F;
1199
+ const T = t.getConversationById(u.conversation_id);
1200
+ T && T.last_message?.id === u.message.id && (T.last_message = F);
1196
1201
  }
1197
- }, l = (u) => {
1202
+ }
1203
+ function l(u) {
1198
1204
  t.removeMessage(u.conversation_id, u.message_id);
1199
- }, v = (u) => {
1205
+ }
1206
+ function _(u) {
1200
1207
  t.updateMessageReactions(
1201
1208
  u.conversation_id,
1202
1209
  u.message_id,
1203
1210
  u.reactions
1204
1211
  );
1205
- }, A = (u) => {
1206
- const _ = t.getConversationById(u.conversation_id);
1207
- _ && (_.is_request = !1), t.requests = t.requests.filter(
1208
- (P) => P.id !== u.conversation_id
1212
+ }
1213
+ function w(u) {
1214
+ const p = t.getConversationById(u.conversation_id);
1215
+ p && (p.is_request = !1), t.requests = t.requests.filter(
1216
+ (E) => E.id !== u.conversation_id
1209
1217
  );
1210
- };
1211
- let b = null;
1212
- const V = (u) => {
1213
- u.removed_user_id === S.value && (b?.(), t.deleteConversation(u.conversation_id).catch(() => {
1218
+ }
1219
+ function b(u) {
1220
+ u.removed_user_id === M.value && (C(), t.deleteConversation(u.conversation_id).catch(() => {
1214
1221
  }));
1215
- }, q = () => {
1222
+ }
1223
+ function q() {
1216
1224
  const u = U();
1217
1225
  if (!(n.value || !u)) {
1218
1226
  if (!G()) {
1219
- E();
1227
+ A();
1220
1228
  return;
1221
1229
  }
1222
1230
  r.value = null;
1223
1231
  try {
1224
- m = Qe(u, {
1225
- onMessageSent: L,
1232
+ m = Xe(u, {
1233
+ onMessageSent: P,
1226
1234
  onMessageRead: z,
1227
- onMessageEdited: N,
1235
+ onMessageEdited: L,
1228
1236
  onMessageDeleted: l,
1229
- onReactionToggled: v,
1230
- onRequestAccepted: A,
1231
- onParticipantRemoved: V
1232
- }), n.value = !0, i.value = u, t.registerDetailSubscription(u), w();
1233
- } catch (_) {
1234
- r.value = _ instanceof Error ? _.message : "Failed to subscribe to conversation", console.error("ConversationChannel: Subscribe error", _);
1237
+ onReactionToggled: _,
1238
+ onRequestAccepted: w,
1239
+ onParticipantRemoved: b
1240
+ }), n.value = !0, i.value = u, t.registerDetailSubscription(u), R();
1241
+ } catch (p) {
1242
+ r.value = p instanceof Error ? p.message : "Failed to subscribe to conversation", console.error("ConversationChannel: Subscribe error", p);
1235
1243
  }
1236
1244
  }
1237
- }, I = () => {
1245
+ }
1246
+ function I() {
1238
1247
  n.value || q();
1239
- };
1240
- typeof window < "u" && window.addEventListener(ge(), I);
1241
- const R = Le((u) => {
1248
+ }
1249
+ typeof window < "u" && window.addEventListener(he(), I);
1250
+ const V = Pe((u) => {
1242
1251
  if (u === "connected") {
1243
1252
  n.value || q();
1244
1253
  return;
1245
1254
  }
1246
- (u === "disconnected" || u === "error") && (w(), m && (m(), m = null), i.value && (t.unregisterDetailSubscription(i.value), i.value = null), n.value = !1);
1247
- }), M = () => {
1255
+ (u === "disconnected" || u === "error") && (R(), m && (m(), m = null), i.value && (t.unregisterDetailSubscription(i.value), i.value = null), n.value = !1);
1256
+ });
1257
+ function C() {
1248
1258
  const u = i.value;
1249
- if (w(), !(!n.value || !u))
1259
+ if (R(), !(!n.value || !u))
1250
1260
  try {
1251
- m && (m(), m = null), t.hasGlobalConversationSubscription(u) || Je(u), n.value = !1, t.unregisterDetailSubscription(u), i.value = null, r.value = null;
1252
- } catch (_) {
1253
- r.value = _ instanceof Error ? _.message : "Failed to unsubscribe from conversation", console.error("ConversationChannel: Unsubscribe error", _);
1261
+ m && (m(), m = null), t.hasGlobalConversationSubscription(u) || Qe(u), n.value = !1, t.unregisterDetailSubscription(u), i.value = null, r.value = null;
1262
+ } catch (p) {
1263
+ r.value = p instanceof Error ? p.message : "Failed to unsubscribe from conversation", console.error("ConversationChannel: Unsubscribe error", p);
1254
1264
  }
1255
- };
1256
- return b = M, o !== null && Ee(() => {
1257
- w(), R(), M(), typeof window < "u" && window.removeEventListener(ge(), I);
1265
+ }
1266
+ return o !== null && Ae(() => {
1267
+ R(), V(), C(), typeof window < "u" && window.removeEventListener(he(), I);
1258
1268
  }), {
1259
- isSubscribed: K(() => n.value),
1260
- error: K(() => r.value),
1269
+ isSubscribed: J(() => n.value),
1270
+ error: J(() => r.value),
1261
1271
  subscribe: q,
1262
- unsubscribe: M
1272
+ unsubscribe: C
1263
1273
  };
1264
1274
  }
1265
- const Ge = () => {
1275
+ const Oe = () => {
1266
1276
  };
1267
- let le = Ge;
1268
- function qt() {
1269
- return le;
1277
+ let de = Oe;
1278
+ function xt() {
1279
+ return de;
1270
1280
  }
1271
- function Pt(e) {
1272
- le = e;
1281
+ function qt(e) {
1282
+ de = e;
1273
1283
  }
1274
- function Lt() {
1275
- le = Ge;
1284
+ function Pt() {
1285
+ de = Oe;
1276
1286
  }
1277
- const Nt = {
1287
+ const Lt = {
1278
1288
  debug: () => {
1279
1289
  },
1280
1290
  info: () => {
@@ -1283,182 +1293,182 @@ const Nt = {
1283
1293
  },
1284
1294
  error: () => {
1285
1295
  }
1286
- }, ke = () => Nt;
1287
- let fe = ke;
1288
- function Ut() {
1289
- return fe;
1296
+ }, Ge = () => Lt;
1297
+ let le = Ge;
1298
+ function Nt() {
1299
+ return le;
1290
1300
  }
1291
- function zt(e) {
1292
- fe = e;
1301
+ function Ut(e) {
1302
+ le = e;
1293
1303
  }
1294
- function It() {
1295
- fe = ke;
1304
+ function zt() {
1305
+ le = Ge;
1296
1306
  }
1297
- const ne = Ut()("GlobalMessaging"), Dt = 3, $t = (e) => e.replace(/\/+$/, ""), Ot = (e) => $t(window.location.pathname) === `/messages/${e}`, Gt = (e) => e.is_muted ? !0 : typeof e.muted_until == "string" && e.muted_until.length > 0;
1298
- function Zt() {
1299
- const e = Oe(), t = k()(), s = qt(), n = We(), r = Ae(), { conversations: i } = He(e), o = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Map();
1307
+ const se = Nt()("GlobalMessaging"), It = 3, Dt = (e) => e.replace(/\/+$/, ""), $t = (e) => Dt(window.location.pathname) === `/messages/${e}`, Ot = (e) => e.is_muted ? !0 : typeof e.muted_until == "string" && e.muted_until.length > 0;
1308
+ function Wt() {
1309
+ const e = $e(), t = k()(), s = xt(), n = Ye(), r = we(), { conversations: i } = Be(e), o = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Map();
1300
1310
  let c = !1;
1301
1311
  function f(l) {
1302
- const v = a.get(l);
1303
- if (v && (a.delete(l), typeof v.channel.stopListening == "function"))
1304
- for (const A of v.bindings)
1312
+ const _ = a.get(l);
1313
+ if (_ && (a.delete(l), typeof _.channel.stopListening == "function"))
1314
+ for (const w of _.bindings)
1305
1315
  try {
1306
- v.channel.stopListening(A.event, A.handler);
1316
+ _.channel.stopListening(w.event, w.handler);
1307
1317
  } catch {
1308
1318
  }
1309
1319
  }
1310
- function p() {
1320
+ function v() {
1311
1321
  for (const l of o)
1312
1322
  f(l), e.unregisterGlobalConversationSubscription(l);
1313
1323
  o.clear();
1314
1324
  }
1315
1325
  function d(l) {
1316
- const v = G();
1317
- if (!v || o.has(l)) return;
1318
- const A = `conversation.${l}`;
1326
+ const _ = G();
1327
+ if (!_ || o.has(l)) return;
1328
+ const w = `conversation.${l}`;
1319
1329
  f(l);
1320
- const b = v.private(A), V = (R) => {
1321
- if (!tt(R)) {
1322
- ne.warn("Dropping malformed ConversationMessageSent event", R);
1330
+ const b = _.private(w), q = (C) => {
1331
+ if (!et(C)) {
1332
+ se.warn("Dropping malformed ConversationMessageSent event", C);
1323
1333
  return;
1324
1334
  }
1325
- const M = R, u = t.currentUser?.id;
1326
- if (!u || M.message.author_id === u) return;
1327
- e.addMessage(M.message);
1328
- const _ = e.hasDetailSubscription(M.conversation_id), P = Ot(M.conversation_id);
1329
- if (_ || P) {
1330
- const F = e.getConversationById(M.conversation_id);
1331
- F && (F.unread_count = 0), e.markAsRead(M.conversation_id).catch(() => {
1335
+ const u = C, p = t.currentUser?.id;
1336
+ if (!p || u.message.author_id === p) return;
1337
+ e.addMessage(u.message);
1338
+ const E = e.hasDetailSubscription(u.conversation_id), N = $t(u.conversation_id);
1339
+ if (E || N) {
1340
+ const T = e.getConversationById(u.conversation_id);
1341
+ T && (T.unread_count = 0), e.markAsRead(u.conversation_id).catch(() => {
1332
1342
  });
1333
1343
  return;
1334
1344
  }
1335
- const T = e.getConversationById(M.conversation_id);
1336
- if (T) {
1337
- const F = Gt(T);
1338
- F || T.unread_count++, s(F);
1345
+ const F = e.getConversationById(u.conversation_id);
1346
+ if (F) {
1347
+ const T = Ot(F);
1348
+ T || F.unread_count++, s(T);
1339
1349
  }
1340
- }, q = (R) => {
1341
- if (!st(R)) {
1342
- ne.warn("Dropping malformed ConversationMessageRead event", R);
1350
+ }, I = (C) => {
1351
+ if (!tt(C)) {
1352
+ se.warn("Dropping malformed ConversationMessageRead event", C);
1343
1353
  return;
1344
1354
  }
1345
- e.applyParticipantReadState(R);
1346
- }, I = (R) => {
1347
- if (!nt(R)) {
1348
- ne.warn("Dropping malformed ConversationRequestAccepted event", R);
1355
+ e.applyParticipantReadState(C);
1356
+ }, V = (C) => {
1357
+ if (!st(C)) {
1358
+ se.warn("Dropping malformed ConversationRequestAccepted event", C);
1349
1359
  return;
1350
1360
  }
1351
- const M = R, u = e.getConversationById(M.conversation_id);
1352
- u && (u.is_request = !1), e.requests = e.requests.filter(
1353
- (_) => _.id !== M.conversation_id
1361
+ const u = C, p = e.getConversationById(u.conversation_id);
1362
+ p && (p.is_request = !1), e.requests = e.requests.filter(
1363
+ (E) => E.id !== u.conversation_id
1354
1364
  );
1355
1365
  };
1356
- b.listen(".ConversationMessageSent", V), b.listen(".ConversationMessageRead", q), b.listen(".ConversationRequestAccepted", I), a.set(l, {
1366
+ b.listen(".ConversationMessageSent", q), b.listen(".ConversationMessageRead", I), b.listen(".ConversationRequestAccepted", V), a.set(l, {
1357
1367
  channel: b,
1358
1368
  bindings: [
1359
- { event: ".ConversationMessageSent", handler: V },
1360
- { event: ".ConversationMessageRead", handler: q },
1361
- { event: ".ConversationRequestAccepted", handler: I }
1369
+ { event: ".ConversationMessageSent", handler: q },
1370
+ { event: ".ConversationMessageRead", handler: I },
1371
+ { event: ".ConversationRequestAccepted", handler: V }
1362
1372
  ]
1363
1373
  }), o.add(l), e.registerGlobalConversationSubscription(l);
1364
1374
  }
1365
1375
  function m() {
1366
1376
  const l = G();
1367
1377
  if (!l) {
1368
- p();
1378
+ v();
1369
1379
  return;
1370
1380
  }
1371
- for (const v of o) {
1372
- f(v);
1381
+ for (const _ of o) {
1382
+ f(_);
1373
1383
  try {
1374
- l.leave(`conversation.${v}`);
1384
+ l.leave(`conversation.${_}`);
1375
1385
  } catch {
1376
1386
  }
1377
- e.unregisterGlobalConversationSubscription(v);
1387
+ e.unregisterGlobalConversationSubscription(_);
1378
1388
  }
1379
1389
  o.clear();
1380
1390
  }
1381
- function S() {
1391
+ function M() {
1382
1392
  const l = G();
1383
1393
  if (!l) return;
1384
- const v = e.conversations.slice(0, Dt), A = new Set(v.map((b) => b.id));
1394
+ const _ = e.conversations.slice(0, It), w = new Set(_.map((b) => b.id));
1385
1395
  for (const b of o)
1386
- if (!A.has(b) && !e.hasDetailSubscription(b)) {
1396
+ if (!w.has(b) && !e.hasDetailSubscription(b)) {
1387
1397
  try {
1388
1398
  f(b), l.leave(`conversation.${b}`);
1389
1399
  } catch {
1390
1400
  }
1391
1401
  o.delete(b), e.unregisterGlobalConversationSubscription(b);
1392
1402
  }
1393
- for (const b of v)
1403
+ for (const b of _)
1394
1404
  d(b.id);
1395
1405
  }
1396
1406
  function U(l) {
1397
1407
  e.updatePresenceForUser(l.user_id, l.status);
1398
1408
  }
1399
- function w() {
1400
- !G() || c || (Ze(U), c = !0);
1409
+ function R() {
1410
+ !G() || c || (We(U), c = !0);
1401
1411
  }
1402
- function E() {
1403
- c && (Xe(), c = !1);
1412
+ function A() {
1413
+ c && (Ze(), c = !1);
1404
1414
  }
1405
- const L = he(
1415
+ const P = fe(
1406
1416
  i,
1407
1417
  () => {
1408
- S();
1418
+ M();
1409
1419
  },
1410
1420
  { deep: !1, immediate: !0 }
1411
- ), z = he(
1421
+ ), z = fe(
1412
1422
  () => n.fullPath,
1413
1423
  () => {
1414
- S();
1424
+ M();
1415
1425
  }
1416
- ), N = Le((l) => {
1417
- l === "connected" ? (p(), S(), E(), w()) : (l === "disconnected" || l === "error") && (p(), E());
1426
+ ), L = Pe((l) => {
1427
+ l === "connected" ? (v(), M(), A(), R()) : (l === "disconnected" || l === "error") && (v(), A());
1418
1428
  });
1419
- S(), w(), r !== null && Ee(() => {
1420
- L(), z(), N(), m(), E();
1429
+ M(), R(), r !== null && Ae(() => {
1430
+ P(), z(), L(), m(), A();
1421
1431
  });
1422
1432
  }
1423
- function Xt(e) {
1424
- e.apiClient && rt(e.apiClient), e.authStore && ot(e.authStore), e.mediaApi && ut(e.mediaApi), e.createLogger && zt(e.createLogger), e.playMessageNotification && Pt(e.playMessageNotification), e.echo && Ke(e.echo);
1433
+ function Zt(e) {
1434
+ e.apiClient && nt(e.apiClient), e.authStore && it(e.authStore), e.mediaApi && ct(e.mediaApi), e.createLogger && Ut(e.createLogger), e.playMessageNotification && qt(e.playMessageNotification), e.echo && Je(e.echo);
1425
1435
  }
1426
- function Qt() {
1427
- it(), at(), dt(), It(), Lt(), et();
1436
+ function Xt() {
1437
+ rt(), ot(), ut(), zt(), Pt(), Ke();
1428
1438
  }
1429
1439
  export {
1430
- Xt as configureMessengerClient,
1440
+ Zt as configureMessengerClient,
1431
1441
  h as getApi,
1432
1442
  k as getAuthStore,
1433
1443
  G as getEcho,
1434
- ge as getEchoInitializedEvent,
1444
+ he as getEchoInitializedEvent,
1435
1445
  g as getErrorMessage,
1436
- Ut as getLoggerFactory,
1437
- ct as getMediaApi,
1438
- Yt as hasResponse,
1439
- es as isAxiosError,
1440
- jt as isError,
1441
- st as isValidMessageReadEvent,
1442
- tt as isValidMessageSentEvent,
1443
- nt as isValidRequestAcceptedEvent,
1446
+ Nt as getLoggerFactory,
1447
+ at as getMediaApi,
1448
+ jt as hasResponse,
1449
+ Kt as isAxiosError,
1450
+ Ht as isError,
1451
+ tt as isValidMessageReadEvent,
1452
+ et as isValidMessageSentEvent,
1453
+ st as isValidRequestAcceptedEvent,
1444
1454
  x as messagingApi,
1445
- Le as onConnectionStatusChange,
1446
- et as resetEchoRuntimeConfig,
1447
- It as resetLoggerFactory,
1448
- it as resetMessagingApiClient,
1449
- at as resetMessagingAuthStoreResolver,
1450
- dt as resetMessagingMediaApi,
1451
- Qt as resetMessengerClientConfig,
1452
- Ke as setEchoRuntimeConfig,
1453
- zt as setLoggerFactory,
1454
- rt as setMessagingApiClient,
1455
- ot as setMessagingAuthStoreResolver,
1456
- ut as setMessagingMediaApi,
1457
- Qe as subscribeToConversation,
1458
- Ze as subscribeToPresenceStatus,
1459
- Je as unsubscribeFromConversation,
1460
- Xe as unsubscribeFromPresenceStatus,
1461
- Wt as useConversationChannel,
1462
- Zt as useGlobalMessaging,
1463
- Oe as useMessagingStore
1455
+ Pe as onConnectionStatusChange,
1456
+ Ke as resetEchoRuntimeConfig,
1457
+ zt as resetLoggerFactory,
1458
+ rt as resetMessagingApiClient,
1459
+ ot as resetMessagingAuthStoreResolver,
1460
+ ut as resetMessagingMediaApi,
1461
+ Xt as resetMessengerClientConfig,
1462
+ Je as setEchoRuntimeConfig,
1463
+ Ut as setLoggerFactory,
1464
+ nt as setMessagingApiClient,
1465
+ it as setMessagingAuthStoreResolver,
1466
+ ct as setMessagingMediaApi,
1467
+ Xe as subscribeToConversation,
1468
+ We as subscribeToPresenceStatus,
1469
+ Qe as unsubscribeFromConversation,
1470
+ Ze as unsubscribeFromPresenceStatus,
1471
+ Yt as useConversationChannel,
1472
+ Wt as useGlobalMessaging,
1473
+ $e as useMessagingStore
1464
1474
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codingfactory/messenger-client",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "description": "Shared messaging frontend state, API helpers, and realtime composables.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",