@bcc-code/vue-bcc-chat-ui 7.1.34 → 7.1.36

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.
@@ -4173,7 +4173,7 @@ function cc({ environment: e }) {
4173
4173
  p.value = !1, ye();
4174
4174
  return;
4175
4175
  }
4176
- se = !0, V || Se(!0);
4176
+ se = !0, V || Ce(!0);
4177
4177
  }
4178
4178
  }
4179
4179
  function ee(e) {
@@ -4193,7 +4193,11 @@ function cc({ environment: e }) {
4193
4193
  }
4194
4194
  let I = n(() => v.value.find((e) => e.id === T.value) ?? null), te = `bcc-ui-connection-${crypto.randomUUID()}`, L = `bcc-ui-message-${crypto.randomUUID()}`, R = !1, z = !1, ne = null, B = null, re = null, ie = null, ae = 0, oe = 0, se = !1, V = !1, U = null, ce = /* @__PURE__ */ new Map(), le = /* @__PURE__ */ new Set(), ue = null, de = null, fe = 0;
4195
4195
  async function pe() {
4196
- await lc(e), !t.value && (ve(), ft(), t.value = !0, await ut(), _.value && (dt(_.value.uid), ge(), Te(), !m.value && !V && Ce()));
4196
+ if (await lc(e), t.value) {
4197
+ await ft();
4198
+ return;
4199
+ }
4200
+ ve(), pt(), t.value = !0, await ft(), _.value && (dt(_.value.uid), ge(), Ee(), !m.value && !V && we());
4197
4201
  }
4198
4202
  async function me(e) {
4199
4203
  g.value = null, r.value = !0;
@@ -4202,9 +4206,9 @@ function cc({ environment: e }) {
4202
4206
  let t = qe();
4203
4207
  await H.getLoggedinUser() && t !== e && await H.logout(), Je(e);
4204
4208
  let n = await uc(e);
4205
- _.value = hc(await H.login(n)), dt(_.value.uid), h.value = !0, m.value = typeof navigator < "u" ? !navigator.onLine : !1, ge(), Te(), V || await Ce(), await ke(), qt();
4209
+ _.value = hc(await H.login(n)), dt(_.value.uid), h.value = !0, m.value = typeof navigator < "u" ? !navigator.onLine : !1, ge(), Ee(), V || await we(), await Ae(), Jt();
4206
4210
  } catch (e) {
4207
- throw St(), g.value = Z(e, "Unable to sign in to chat."), e;
4211
+ throw Ct(), g.value = Z(e, "Unable to sign in to chat."), e;
4208
4212
  } finally {
4209
4213
  r.value = !1;
4210
4214
  }
@@ -4214,7 +4218,7 @@ function cc({ environment: e }) {
4214
4218
  try {
4215
4219
  Je(null), Qe(), await H.getLoggedinUser() && await H.logout();
4216
4220
  } finally {
4217
- St();
4221
+ Ct();
4218
4222
  }
4219
4223
  }
4220
4224
  function ge() {
@@ -4247,16 +4251,20 @@ function cc({ environment: e }) {
4247
4251
  function xe() {
4248
4252
  return Date.now() < ae;
4249
4253
  }
4250
- function Se(e = !1) {
4251
- if (ne !== null || B || m.value || !h.value || V) return;
4254
+ function Se() {
4255
+ return !!qe();
4256
+ }
4257
+ function Ce(e = !1) {
4258
+ if (ne !== null || B || m.value || V || !h.value && !Se()) return;
4252
4259
  let t = e ? 0 : Math.min(3e4, 1e3 * 2 ** Math.min(oe, 4));
4253
4260
  ne = setTimeout(() => {
4254
- ne = null, Ce();
4261
+ ne = null, we();
4255
4262
  }, t);
4256
4263
  }
4257
- async function Ce() {
4258
- if (N(), !(m.value || !h.value || V)) return B || (B = (async () => {
4264
+ async function we() {
4265
+ if (N(), !(m.value || V || !h.value && !Se())) return B || (B = (async () => {
4259
4266
  ye();
4267
+ let e = !1;
4260
4268
  try {
4261
4269
  let e = await H.getLoggedinUser();
4262
4270
  if (!e) {
@@ -4267,45 +4275,46 @@ function cc({ environment: e }) {
4267
4275
  }
4268
4276
  _.value = hc(e), h.value = !0, ge();
4269
4277
  let t = H.connect;
4270
- typeof t == "function" && (await t.call(H), p.value = !0), oe = 0, se && await we();
4271
- } catch (e) {
4272
- p.value = !1, oe += 1, Lt(e) || (g.value = Z(e, "Unable to reconnect to chat.")), setTimeout(Se, 1e3);
4278
+ typeof t == "function" && (await t.call(H), p.value = !0), oe = 0, se && await Te();
4279
+ } catch (t) {
4280
+ p.value = !1, oe += 1, Rt(t) || (g.value = Z(t, "Unable to reconnect to chat.")), e = !0;
4273
4281
  } finally {
4274
4282
  B = null;
4275
4283
  }
4284
+ e && Ce();
4276
4285
  })(), B);
4277
4286
  }
4278
- async function we() {
4279
- return re || m.value || !h.value || V || (re = (async () => {
4287
+ async function Te() {
4288
+ return re || m.value || V || !h.value && !Se() || (re = (async () => {
4280
4289
  se = !1, g.value = null;
4281
4290
  try {
4282
- await ke(), qt();
4291
+ await Ae(), Jt();
4283
4292
  } finally {
4284
4293
  re = null;
4285
4294
  }
4286
4295
  })()), re;
4287
4296
  }
4288
- function Te() {
4297
+ function Ee() {
4289
4298
  if (!U || v.value.length > 0) return;
4290
4299
  let e = U.getConversations();
4291
- e.length !== 0 && (v.value = bc(e), !T.value && v.value.length > 0 && Ee(T.value));
4300
+ e.length !== 0 && (v.value = bc(e), !T.value && v.value.length > 0 && De(T.value));
4292
4301
  }
4293
- function Ee(e) {
4302
+ function De(e) {
4294
4303
  if (!U || !e) return y.value = [], !1;
4295
4304
  let t = U.getMessages(e).sort(xc);
4296
4305
  return y.value = t, t.length > 0;
4297
4306
  }
4298
- async function De() {
4299
- V = !1, se = !0, await Ce();
4300
- }
4301
4307
  async function Oe() {
4308
+ V = !1, se = !0, await we();
4309
+ }
4310
+ async function ke() {
4302
4311
  V = !0, se = !1, ye();
4303
4312
  let e = H.disconnect;
4304
4313
  typeof e == "function" && await e.call(H), p.value = !1;
4305
4314
  }
4306
- async function ke() {
4315
+ async function Ae() {
4307
4316
  if (await pe(), N(), i.value = !0, g.value = null, m.value) {
4308
- v.value = bc(U?.getConversations() ?? []), I.value && await rt(), i.value = !1;
4317
+ v.value = bc(U?.getConversations() ?? []), I.value && await it(), i.value = !1;
4309
4318
  return;
4310
4319
  }
4311
4320
  try {
@@ -4318,7 +4327,7 @@ function cc({ environment: e }) {
4318
4327
  let t = r.get(e.id);
4319
4328
  t && (e.subtitle === "No messages yet" && t.subtitle && t.subtitle !== "No messages yet" && (e.subtitle = t.subtitle), !e.lastMessageAt && t.lastMessageAt && (e.lastMessageAt = t.lastMessageAt), !e.lastMessage && t.lastMessage && (e.lastMessage = t.lastMessage));
4320
4329
  }
4321
- v.value = bc(await mt(t)), U?.setConversations(v.value), I.value && await rt();
4330
+ v.value = bc(await ht(t)), U?.setConversations(v.value), I.value && await it();
4322
4331
  } catch (e) {
4323
4332
  let t = U?.getConversations() ?? [];
4324
4333
  if (t.length > 0) {
@@ -4330,39 +4339,39 @@ function cc({ environment: e }) {
4330
4339
  i.value = !1;
4331
4340
  }
4332
4341
  }
4333
- async function Ae(e) {
4334
- T.value = e, E.value = null, b.value = [], de = null, C.value = !1, D.value = null, O.value = null, Ee(e), await rt();
4342
+ async function je(e) {
4343
+ T.value = e, E.value = null, b.value = [], de = null, C.value = !1, D.value = null, O.value = null, De(e), await it();
4335
4344
  }
4336
- function je(e) {
4345
+ function Me(e) {
4337
4346
  e && (O.value = null), D.value = e;
4338
4347
  }
4339
- function Me(e) {
4348
+ function Ne(e) {
4340
4349
  e && (D.value = null), O.value = e;
4341
4350
  }
4342
- async function Ne(e) {
4343
- E.value = e, de = null, C.value = !1, D.value = null, O.value = null, await at(e.id);
4351
+ async function Pe(e) {
4352
+ E.value = e, de = null, C.value = !1, D.value = null, O.value = null, await ot(e.id);
4344
4353
  }
4345
- function Pe() {
4354
+ function Fe() {
4346
4355
  E.value = null, b.value = [], de = null, C.value = !1, D.value = null, O.value = null;
4347
4356
  }
4348
- async function Fe(e, t) {
4357
+ async function Ie(e, t) {
4349
4358
  if (u.value) return;
4350
4359
  let n = I.value;
4351
4360
  if (!n) return;
4352
4361
  let r = Vs(e);
4353
4362
  if (!Hs(r)) return;
4354
4363
  if (O.value) {
4355
- await Ie(O.value, r);
4364
+ await Le(O.value, r);
4356
4365
  return;
4357
4366
  }
4358
- let i = E.value?.id, a = crypto.randomUUID(), o = Dc(Ft(D.value, t), a);
4367
+ let i = E.value?.id, a = crypto.randomUUID(), o = Dc(It(D.value, t), a);
4359
4368
  u.value = !0, g.value = null;
4360
4369
  try {
4361
4370
  if (m.value) {
4362
- Rt(n, r, o, i, a), D.value = null;
4371
+ zt(n, r, o, i, a), D.value = null;
4363
4372
  return;
4364
4373
  }
4365
- Wt(Pt({
4374
+ Gt(Ft({
4366
4375
  conversation: n,
4367
4376
  kind: "text",
4368
4377
  text: r,
@@ -4374,18 +4383,18 @@ function cc({ environment: e }) {
4374
4383
  let e = new H.TextMessage(n.targetId, r, kc(n));
4375
4384
  e.setMuid?.(a), Object.keys(o).length > 0 && e.setMetadata?.(o), i && e.setParentMessageId?.(Number(i));
4376
4385
  let t = await H.sendMessage(e);
4377
- wt(F(t, _.value?.uid)), gt(t), await yt(t), D.value = null;
4386
+ Tt(F(t, _.value?.uid)), _t(t), await bt(t), D.value = null;
4378
4387
  } catch (e) {
4379
- if (Lt(e)) {
4380
- Gt("queued", a), Rt(n, r, o, E.value?.id, a), D.value = null;
4388
+ if (Rt(e)) {
4389
+ Kt("queued", a), zt(n, r, o, E.value?.id, a), D.value = null;
4381
4390
  return;
4382
4391
  }
4383
- throw Gt("failed", a), g.value = Z(e, "Unable to send the message."), e;
4392
+ throw Kt("failed", a), g.value = Z(e, "Unable to send the message."), e;
4384
4393
  } finally {
4385
4394
  u.value = !1;
4386
4395
  }
4387
4396
  }
4388
- async function Ie(e, t) {
4397
+ async function Le(e, t) {
4389
4398
  let n = I.value;
4390
4399
  if (!n || m.value) return;
4391
4400
  let r = Vs(t);
@@ -4395,7 +4404,7 @@ function cc({ environment: e }) {
4395
4404
  let t;
4396
4405
  e.kind === "text" ? t = new H.TextMessage(n.targetId, r, kc(n)) : (t = new H.MediaMessage(n.targetId, e.source?.getAttachment?.()?.getFileUrl?.() ?? e.source?.getAttachment?.()?.getUrl?.() ?? e.attachments[0]?.url ?? "", e.source?.getType?.() ?? e.type ?? e.kind, kc(n)), t.setCaption(r)), t.setId(Number(e.id));
4397
4406
  let i = await H.editMessage(t);
4398
- wt(F(i, _.value?.uid)), gt(i), O.value = null;
4407
+ Tt(F(i, _.value?.uid)), _t(i), O.value = null;
4399
4408
  } catch (e) {
4400
4409
  throw g.value = Z(e, "Unable to edit the message."), e;
4401
4410
  } finally {
@@ -4403,18 +4412,18 @@ function cc({ environment: e }) {
4403
4412
  }
4404
4413
  }
4405
4414
  }
4406
- async function Le(e, t) {
4415
+ async function Re(e, t) {
4407
4416
  if (u.value) return;
4408
4417
  let n = I.value;
4409
4418
  if (!n) return;
4410
- let r = E.value?.id, i = crypto.randomUUID(), a = Dc(Ft(D.value, t), i), o = Nc(e.file);
4419
+ let r = E.value?.id, i = crypto.randomUUID(), a = Dc(It(D.value, t), i), o = Nc(e.file);
4411
4420
  u.value = !0, g.value = null;
4412
4421
  try {
4413
4422
  if (m.value) {
4414
- await Ht(n, e, a, r, i), D.value = null;
4423
+ await Ut(n, e, a, r, i), D.value = null;
4415
4424
  return;
4416
4425
  }
4417
- Wt(Pt({
4426
+ Gt(Ft({
4418
4427
  conversation: n,
4419
4428
  kind: o,
4420
4429
  text: e.caption?.trim() ?? "",
@@ -4432,34 +4441,34 @@ function cc({ environment: e }) {
4432
4441
  let t = new H.MediaMessage(n.targetId, e.file, o, kc(n));
4433
4442
  t.setMuid?.(i), Object.keys(a).length > 0 && t.setMetadata?.(a), r && t.setParentMessageId?.(Number(r)), e.caption?.trim() && t.setCaption?.(e.caption.trim());
4434
4443
  let s = await H.sendMediaMessage(t);
4435
- wt(F(s, _.value?.uid)), gt(s), await yt(s), D.value = null;
4444
+ Tt(F(s, _.value?.uid)), _t(s), await bt(s), D.value = null;
4436
4445
  } catch (t) {
4437
- if (Lt(t)) {
4438
- Gt("queued", i), await Ht(n, e, a, r, i), D.value = null;
4446
+ if (Rt(t)) {
4447
+ Kt("queued", i), await Ut(n, e, a, r, i), D.value = null;
4439
4448
  return;
4440
4449
  }
4441
- throw Gt("failed", i), g.value = Z(t, "Unable to send the attachment."), t;
4450
+ throw Kt("failed", i), g.value = Z(t, "Unable to send the attachment."), t;
4442
4451
  } finally {
4443
4452
  u.value = !1;
4444
4453
  }
4445
4454
  }
4446
- async function Re(e, t) {
4455
+ async function W(e, t) {
4447
4456
  if (u.value) return;
4448
4457
  let n = I.value;
4449
4458
  if (!n) return;
4450
4459
  let r = e.question.trim(), i = e.options.map((e) => e.trim()).filter(Boolean);
4451
4460
  if (!r || i.length < 2) return;
4452
- let a = E.value?.id, o = crypto.randomUUID(), s = Dc(Ft(D.value, t), o);
4461
+ let a = E.value?.id, o = crypto.randomUUID(), s = Dc(It(D.value, t), o);
4453
4462
  u.value = !0, g.value = null;
4454
4463
  try {
4455
4464
  if (m.value) {
4456
- zt(n, {
4465
+ Bt(n, {
4457
4466
  question: r,
4458
4467
  options: i
4459
4468
  }, s, a, o), D.value = null;
4460
4469
  return;
4461
4470
  }
4462
- Wt(Pt({
4471
+ Gt(Ft({
4463
4472
  conversation: n,
4464
4473
  kind: "poll",
4465
4474
  text: `Poll: ${r}`,
@@ -4480,37 +4489,37 @@ function cc({ environment: e }) {
4480
4489
  };
4481
4490
  a && (e.parentMessageId = Number(a)), Object.keys(s).length > 0 && (e.metadata = s);
4482
4491
  let t = await H.callExtension("polls", "POST", "v2/create", e), c = t?.message ?? t?.custom_message ?? t?.data?.message ?? null;
4483
- c ? (Kt(o), wt(F(c, _.value?.uid)), gt(c), await yt(c)) : (Kt(o), await Ct()), D.value = null;
4492
+ c ? (qt(o), Tt(F(c, _.value?.uid)), _t(c), await bt(c)) : (qt(o), await wt()), D.value = null;
4484
4493
  } catch (e) {
4485
- if (Lt(e)) {
4486
- Gt("queued", o), zt(n, {
4494
+ if (Rt(e)) {
4495
+ Kt("queued", o), Bt(n, {
4487
4496
  question: r,
4488
4497
  options: i
4489
4498
  }, s, a, o), D.value = null;
4490
4499
  return;
4491
4500
  }
4492
- throw Gt("failed", o), g.value = Z(e, "Unable to send the poll."), e;
4501
+ throw Kt("failed", o), g.value = Z(e, "Unable to send the poll."), e;
4493
4502
  } finally {
4494
4503
  u.value = !1;
4495
4504
  }
4496
4505
  }
4497
- async function W(e, t) {
4506
+ async function ze(e, t) {
4498
4507
  let n = e.poll?.id ?? e.id, r = _.value?.uid;
4499
4508
  if (!n || !t || m.value) return;
4500
- let i = Et(e.id, e.parentMessageId) ?? e;
4509
+ let i = Dt(e.id, e.parentMessageId) ?? e;
4501
4510
  if (i.poll && !i.poll.options.some((e) => e.id === t && e.voters.includes(r ?? ""))) {
4502
- g.value = null, r && wt(ze(i, t, r));
4511
+ g.value = null, r && Tt(Be(i, t, r));
4503
4512
  try {
4504
4513
  await H.callExtension("polls", "POST", "v2/vote", {
4505
4514
  id: n,
4506
4515
  vote: t
4507
4516
  });
4508
4517
  } catch (e) {
4509
- throw wt(i), g.value = Z(e, "Unable to cast the vote."), e;
4518
+ throw Tt(i), g.value = Z(e, "Unable to cast the vote."), e;
4510
4519
  }
4511
4520
  }
4512
4521
  }
4513
- function ze(e, t, n) {
4522
+ function Be(e, t, n) {
4514
4523
  if (!e.poll) return e;
4515
4524
  let r = e.poll, i = r.allowsMultipleAnswers, a = r.options.filter((e) => e.voters.includes(n)).map((e) => e.id), o = !i && a.length > 0, s = r.options.map((e) => o && e.voters.includes(n) && e.id !== t ? {
4516
4525
  ...e,
@@ -4530,29 +4539,29 @@ function cc({ environment: e }) {
4530
4539
  }
4531
4540
  };
4532
4541
  }
4533
- async function Be(e, t) {
4542
+ async function Ve(e, t) {
4534
4543
  g.value = null;
4535
- let n = Et(e.id, e.parentMessageId) ?? e, r = n.reactions.find((e) => e.emoji === t && e.reactedByMe);
4536
- wt(Dt(n, t));
4544
+ let n = Dt(e.id, e.parentMessageId) ?? e, r = n.reactions.find((e) => e.emoji === t && e.reactedByMe);
4545
+ Tt(Ot(n, t));
4537
4546
  try {
4538
- wt(F(r ? await H.removeReaction(Number(e.id), t) : await H.addReaction(Number(e.id), t), _.value?.uid));
4547
+ Tt(F(r ? await H.removeReaction(Number(e.id), t) : await H.addReaction(Number(e.id), t), _.value?.uid));
4539
4548
  } catch (e) {
4540
- throw wt(n), g.value = Z(e, "Unable to update the reaction."), e;
4549
+ throw Tt(n), g.value = Z(e, "Unable to update the reaction."), e;
4541
4550
  }
4542
4551
  }
4543
- async function Ve(e) {
4552
+ async function Ue(e) {
4544
4553
  if (g.value = null, e.deliveryState === "queued" || e.deliveryState === "failed") {
4545
- At(e);
4554
+ jt(e);
4546
4555
  return;
4547
4556
  }
4548
4557
  if (!m.value) try {
4549
4558
  let t = F(await H.deleteMessage(String(e.id)), _.value?.uid);
4550
- At(t), jt(t);
4559
+ jt(t), Mt(t);
4551
4560
  } catch (e) {
4552
4561
  throw g.value = Z(e, "Unable to delete the message."), e;
4553
4562
  }
4554
4563
  }
4555
- async function Ue(e) {
4564
+ async function We(e) {
4556
4565
  let t = e.source?.getText?.() ?? e.text;
4557
4566
  if (Hs(t)) {
4558
4567
  g.value = null;
@@ -4563,20 +4572,20 @@ function cc({ environment: e }) {
4563
4572
  languages: typeof navigator < "u" ? navigator.languages : ["en"]
4564
4573
  })).translations?.[0]?.message_translated?.trim();
4565
4574
  if (!n) return;
4566
- Tt({
4575
+ Et({
4567
4576
  ...e,
4568
4577
  translatedText: n,
4569
4578
  metadata: {
4570
4579
  ...e.metadata ?? {},
4571
4580
  translated_message: n
4572
4581
  }
4573
- }), kt();
4582
+ }), At();
4574
4583
  } catch (e) {
4575
4584
  throw g.value = Z(e, "Unable to translate the message."), e;
4576
4585
  }
4577
4586
  }
4578
4587
  }
4579
- async function We(e) {
4588
+ async function Ge(e) {
4580
4589
  let t = e ?? I.value?.targetId, n = _.value?.uid, r = ++fe;
4581
4590
  if (!t || !n) {
4582
4591
  r === fe && (x.value = []);
@@ -4600,12 +4609,12 @@ function cc({ environment: e }) {
4600
4609
  }
4601
4610
  }
4602
4611
  }
4603
- async function Ge(e, t) {
4612
+ async function Ke(e, t) {
4604
4613
  let n = I.value;
4605
4614
  if (n) {
4606
4615
  d.value = !0, g.value = null;
4607
4616
  try {
4608
- e.file ? await Mc(n, e, t) : await jc(n, e, t), await We(n.targetId);
4617
+ e.file ? await Mc(n, e, t) : await jc(n, e, t), await Ge(n.targetId);
4609
4618
  } catch (e) {
4610
4619
  throw g.value = Z(e, "Unable to schedule the message."), e;
4611
4620
  } finally {
@@ -4613,16 +4622,16 @@ function cc({ environment: e }) {
4613
4622
  }
4614
4623
  }
4615
4624
  }
4616
- async function Ke(e) {
4625
+ async function Ye(e) {
4617
4626
  if (g.value = null, !e.scheduled) return;
4618
4627
  let t = e.scheduled.originalChatUid;
4619
4628
  try {
4620
- await H.deleteMessage(String(e.id)), x.value = x.value.filter((t) => t.id !== e.id), await We(t);
4629
+ await H.deleteMessage(String(e.id)), x.value = x.value.filter((t) => t.id !== e.id), await Ge(t);
4621
4630
  } catch (e) {
4622
4631
  throw g.value = Z(e, "Unable to remove the scheduled message."), e;
4623
4632
  }
4624
4633
  }
4625
- async function Ye(e, t) {
4634
+ async function Xe(e, t) {
4626
4635
  g.value = null;
4627
4636
  let n = _.value?.uid;
4628
4637
  if (!n || !e.scheduled?.muid || e.kind === "poll") return;
@@ -4637,14 +4646,14 @@ function cc({ environment: e }) {
4637
4646
  let i = e.source?.getAttachment?.()?.getFileUrl?.() ?? e.source?.getAttachment?.()?.getUrl?.() ?? e.attachments[0]?.url ?? "";
4638
4647
  t = new H.MediaMessage(n, i, e.source?.getType?.() ?? e.type ?? e.kind, H.RECEIVER_TYPE.GROUP), t.setCaption(r);
4639
4648
  }
4640
- Object.keys(i).length > 0 && t.setMetadata(i), t.setId(Number(e.id)), await H.editMessage(t), await We(e.scheduled.originalChatUid);
4649
+ Object.keys(i).length > 0 && t.setMetadata(i), t.setId(Number(e.id)), await H.editMessage(t), await Ge(e.scheduled.originalChatUid);
4641
4650
  } catch (e) {
4642
4651
  throw g.value = Z(e, "Unable to edit the scheduled message."), e;
4643
4652
  } finally {
4644
4653
  d.value = !1;
4645
4654
  }
4646
4655
  }
4647
- async function Xe(e) {
4656
+ async function Ze(e) {
4648
4657
  d.value = !0, g.value = null;
4649
4658
  try {
4650
4659
  let t = Ac(), n = await fetch(`${G().chatApiBaseUrl}/chats/rescheduleMessage`, {
@@ -4661,21 +4670,21 @@ function cc({ environment: e }) {
4661
4670
  })
4662
4671
  });
4663
4672
  if (!n.ok) throw Error(`Reschedule failed with status ${n.status}.`);
4664
- await We(e.originalChatUid);
4673
+ await Ge(e.originalChatUid);
4665
4674
  } catch (e) {
4666
4675
  throw g.value = Z(e, "Unable to reschedule the message."), e;
4667
4676
  } finally {
4668
4677
  d.value = !1;
4669
4678
  }
4670
4679
  }
4671
- function Ze(e) {
4680
+ function $e(e) {
4672
4681
  let t = new H.MessagesRequestBuilder().setLimit(50).hideReplies(!0).hideDeletedMessages(!0);
4673
4682
  return e.type === "group" ? t.setGUID(e.targetId) : t.setUID(e.targetId), t.build();
4674
4683
  }
4675
- function $e(e) {
4684
+ function et(e) {
4676
4685
  return new H.MessagesRequestBuilder().setLimit(50).setParentMessageId(Number(e)).hideDeletedMessages(!0).build();
4677
4686
  }
4678
- async function et(e) {
4687
+ async function tt(e) {
4679
4688
  if (!e.isOwn || e.receipts.readAt) return e;
4680
4689
  let t = `bcc-chat:${G().appId}:message_${e.id}_receiptStatus`;
4681
4690
  try {
@@ -4685,7 +4694,7 @@ function cc({ environment: e }) {
4685
4694
  if (!Number.isNaN(r.getTime()) && !Number.isNaN(i.getTime())) return e.receipts.readAt = r, e.receipts.deliveredAt = i, e;
4686
4695
  }
4687
4696
  } catch {}
4688
- let n = await xt(e);
4697
+ let n = await St(e);
4689
4698
  for (let t of n) t.kind === "read" && t.timestamp && (!e.receipts.readAt || t.timestamp > e.receipts.readAt) && (e.receipts.readAt = t.timestamp), t.kind === "delivered" && t.timestamp && (!e.receipts.deliveredAt || t.timestamp > e.receipts.deliveredAt) && (e.receipts.deliveredAt = t.timestamp);
4690
4699
  if (e.receipts.readAt) try {
4691
4700
  localStorage.setItem(t, JSON.stringify({
@@ -4695,7 +4704,7 @@ function cc({ environment: e }) {
4695
4704
  } catch {}
4696
4705
  return e;
4697
4706
  }
4698
- async function tt(e) {
4707
+ async function nt(e) {
4699
4708
  try {
4700
4709
  return await e.fetchPrevious();
4701
4710
  } catch (e) {
@@ -4703,32 +4712,32 @@ function cc({ environment: e }) {
4703
4712
  throw e;
4704
4713
  }
4705
4714
  }
4706
- async function nt(e) {
4715
+ async function rt(e) {
4707
4716
  let t = I.value;
4708
4717
  if (!t || m.value) return y.value = [], S.value = !1, !1;
4709
4718
  if ((e?.reset || ue?.conversationId !== t.id) && (ue = {
4710
4719
  conversationId: t.id,
4711
- request: Ze(t)
4720
+ request: $e(t)
4712
4721
  }, S.value = !0), !ue) return !1;
4713
- let n = await tt(ue.request), r = await Promise.all(n.map((e) => F(e, _.value?.uid)).filter(Tc).sort(xc).map(et));
4722
+ let n = await nt(ue.request), r = await Promise.all(n.map((e) => F(e, _.value?.uid)).filter(Tc).sort(xc).map(tt));
4714
4723
  y.value = e?.reset ? Cc(y.value.filter((e) => e.conversationId === t.id && wc(e)), r) : Cc(y.value, r), S.value = n.length === 50, U?.setMessages(t.id, y.value);
4715
4724
  let i = n[n.length - 1];
4716
- return i && (await bt(i), await yt(i)), n.length > 0;
4725
+ return i && (await xt(i), await bt(i)), n.length > 0;
4717
4726
  }
4718
- async function rt() {
4727
+ async function it() {
4719
4728
  N();
4720
4729
  let e = I.value;
4721
4730
  if (!e) {
4722
4731
  y.value = [], S.value = !1, ue = null;
4723
4732
  return;
4724
4733
  }
4725
- let t = Ee(e.id);
4734
+ let t = De(e.id);
4726
4735
  if (a.value = !0, m.value) {
4727
4736
  S.value = !1, ue = null, a.value = !1;
4728
4737
  return;
4729
4738
  }
4730
4739
  try {
4731
- await nt({ reset: !0 }), v.value = v.value.map((t) => t.id === e.id ? {
4740
+ await rt({ reset: !0 }), v.value = v.value.map((t) => t.id === e.id ? {
4732
4741
  ...t,
4733
4742
  lastMessage: y.value.at(-1) ?? null,
4734
4743
  unreadCount: 0
@@ -4744,25 +4753,25 @@ function cc({ environment: e }) {
4744
4753
  a.value = !1;
4745
4754
  }
4746
4755
  }
4747
- async function it(e) {
4756
+ async function at(e) {
4748
4757
  let t = E.value?.id;
4749
4758
  if (!t) return b.value = [], C.value = !1, !1;
4750
4759
  if ((e?.reset || de?.parentMessageId !== t) && (de = {
4751
4760
  parentMessageId: t,
4752
- request: $e(t)
4761
+ request: et(t)
4753
4762
  }, C.value = !0), !de) return !1;
4754
- let n = await de.request.fetchPrevious(), r = await Promise.all(n.map((e) => F(e, _.value?.uid)).filter(Tc).sort(xc).map(et));
4763
+ let n = await de.request.fetchPrevious(), r = await Promise.all(n.map((e) => F(e, _.value?.uid)).filter(Tc).sort(xc).map(tt));
4755
4764
  b.value = e?.reset ? Cc(b.value.filter((e) => e.parentMessageId === t && wc(e)), r) : Cc(b.value, r), C.value = n.length === 50, U?.setThreadMessages(t, b.value);
4756
4765
  let i = n[n.length - 1];
4757
- return i && (await bt(i), await yt(i)), n.length > 0;
4766
+ return i && (await xt(i), await bt(i)), n.length > 0;
4758
4767
  }
4759
- async function at(e) {
4768
+ async function ot(e) {
4760
4769
  if (o.value = !0, m.value) {
4761
4770
  b.value = (U?.getThreadMessages(e) ?? []).sort(xc), C.value = !1, de = null, o.value = !1;
4762
4771
  return;
4763
4772
  }
4764
4773
  try {
4765
- await it({ reset: !0 });
4774
+ await at({ reset: !0 });
4766
4775
  } catch (t) {
4767
4776
  let n = U?.getThreadMessages(e) ?? [];
4768
4777
  if (n.length > 0) {
@@ -4774,29 +4783,29 @@ function cc({ environment: e }) {
4774
4783
  o.value = !1;
4775
4784
  }
4776
4785
  }
4777
- async function ot() {
4786
+ async function st() {
4778
4787
  if (a.value || s.value || !S.value) return !1;
4779
4788
  s.value = !0, g.value = null;
4780
4789
  try {
4781
- return await nt();
4790
+ return await rt();
4782
4791
  } catch (e) {
4783
4792
  throw g.value = Z(e, "Unable to load messages."), e;
4784
4793
  } finally {
4785
4794
  s.value = !1;
4786
4795
  }
4787
4796
  }
4788
- async function st() {
4797
+ async function ct() {
4789
4798
  if (o.value || c.value || !C.value) return !1;
4790
4799
  c.value = !0, g.value = null;
4791
4800
  try {
4792
- return await it();
4801
+ return await at();
4793
4802
  } catch (e) {
4794
4803
  throw g.value = Z(e, "Unable to load thread."), e;
4795
4804
  } finally {
4796
4805
  c.value = !1;
4797
4806
  }
4798
4807
  }
4799
- async function ct(e) {
4808
+ async function ut(e) {
4800
4809
  let t = e.trim();
4801
4810
  if (!t) return !1;
4802
4811
  let n = () => y.value.some((e) => e.id === t) || b.value.some((e) => e.id === t) || E.value?.id === t;
@@ -4804,92 +4813,92 @@ function cc({ environment: e }) {
4804
4813
  let r = 0;
4805
4814
  for (; C.value && E.value && r < 100;) {
4806
4815
  r += 1;
4807
- let e = await st();
4816
+ let e = await ct();
4808
4817
  if (n()) return !0;
4809
4818
  if (!e) break;
4810
4819
  }
4811
4820
  for (; S.value && I.value && r < 100;) {
4812
4821
  r += 1;
4813
- let e = await ot();
4822
+ let e = await st();
4814
4823
  if (n()) return !0;
4815
4824
  if (!e) break;
4816
4825
  }
4817
4826
  return n();
4818
4827
  }
4819
- async function ut() {
4820
- let e = await H.getLoggedinUser();
4828
+ async function ft() {
4829
+ let e = await H.getLoggedInUser();
4821
4830
  _.value = e ? hc(e) : null, h.value = !!e;
4822
4831
  }
4823
- function ft() {
4832
+ function pt() {
4824
4833
  R ||= (H.addConnectionListener(te, new H.ConnectionListener({
4825
4834
  onConnected: () => {
4826
4835
  if (p.value = !0, oe = 0, ye(), se) {
4827
- we();
4836
+ Te();
4828
4837
  return;
4829
4838
  }
4830
- qt();
4839
+ Jt();
4831
4840
  },
4832
4841
  onDisconnected: () => {
4833
- p.value = !1, !m.value && h.value && !V && (se = !0, Se(!0));
4842
+ p.value = !1, !m.value && !V && (h.value || Se()) && (se = !0, Ce(!0));
4834
4843
  }
4835
4844
  })), H.addMessageListener(L, new H.MessageListener({
4836
4845
  onTextMessageReceived: (e) => {
4837
- pt(e);
4846
+ mt(e);
4838
4847
  },
4839
4848
  onMediaMessageReceived: (e) => {
4840
- pt(e);
4849
+ mt(e);
4841
4850
  },
4842
4851
  onCustomMessageReceived: (e) => {
4843
- pt(e);
4852
+ mt(e);
4844
4853
  },
4845
4854
  onMessagesDelivered: () => {
4846
- xe() || Ct({ includeThread: !1 });
4855
+ xe() || wt({ includeThread: !1 });
4847
4856
  },
4848
4857
  onMessagesRead: () => {
4849
- xe() || Ct({ includeThread: !1 });
4858
+ xe() || wt({ includeThread: !1 });
4850
4859
  },
4851
4860
  onMessageEdited: (e) => {
4852
4861
  let t = F(e, _.value?.uid);
4853
- Tc(t) && (_t(t), gt(e));
4862
+ Tc(t) && (K(t), _t(e));
4854
4863
  },
4855
4864
  onMessageDeleted: (e) => {
4856
4865
  let t = F(e, _.value?.uid);
4857
- t.parentMessageId ? At(t) : (At(t), jt(t)), kt();
4866
+ t.parentMessageId ? jt(t) : (jt(t), Mt(t)), At();
4858
4867
  },
4859
4868
  onMessageReactionAdded: () => {
4860
- Ct();
4869
+ wt();
4861
4870
  },
4862
4871
  onMessageReactionRemoved: () => {
4863
- Ct();
4872
+ wt();
4864
4873
  },
4865
4874
  onMessagesDeliveredToAll: () => {
4866
- xe() || Ct({ includeThread: !1 });
4875
+ xe() || wt({ includeThread: !1 });
4867
4876
  },
4868
4877
  onMessagesReadByAll: () => {
4869
- xe() || Ct({ includeThread: !1 });
4878
+ xe() || wt({ includeThread: !1 });
4870
4879
  }
4871
4880
  })), !0);
4872
4881
  }
4873
- async function pt(e) {
4882
+ async function mt(e) {
4874
4883
  let t = F(e, _.value?.uid);
4875
4884
  if (Tc(t)) {
4876
- if (gt(e), await bt(e), t.parentMessageId) {
4877
- K(t), Ot(t.parentMessageId), kt();
4885
+ if (_t(e), await xt(e), t.parentMessageId) {
4886
+ yt(t), kt(t.parentMessageId), At();
4878
4887
  return;
4879
4888
  }
4880
- t.conversationId === T.value && (_t(t), kt(), await yt(e));
4889
+ t.conversationId === T.value && (K(t), At(), await bt(e));
4881
4890
  }
4882
4891
  }
4883
- async function mt(e) {
4892
+ async function ht(e) {
4884
4893
  return await Promise.all(e.map(async (e) => {
4885
- let t = await ht(e.targetId);
4894
+ let t = await gt(e.targetId);
4886
4895
  return {
4887
4896
  ...e,
4888
4897
  muteSettings: t ? new Date(t) : null
4889
4898
  };
4890
4899
  }));
4891
4900
  }
4892
- async function ht(e) {
4901
+ async function gt(e) {
4893
4902
  let t = U?.getParticipantSettings(e), n = t?.lastUpdated ? Date.now() - t.lastUpdated > 1440 * 60 * 1e3 : !0;
4894
4903
  if (t && (m.value || !n)) return t.mutedUntil;
4895
4904
  if (m.value || !h.value) return t?.mutedUntil ?? null;
@@ -4916,12 +4925,12 @@ function cc({ environment: e }) {
4916
4925
  return t?.mutedUntil ?? null;
4917
4926
  }
4918
4927
  }
4919
- function gt(e) {
4928
+ function _t(e) {
4920
4929
  let t = F(e, _.value?.uid);
4921
4930
  if (!Tc(t) || t.isDeleted) return;
4922
4931
  let n = e.getConversationId(), r = v.value.find((e) => e.id === n);
4923
4932
  if (!r) {
4924
- ke();
4933
+ Ae();
4925
4934
  return;
4926
4935
  }
4927
4936
  let i = {
@@ -4933,33 +4942,33 @@ function cc({ environment: e }) {
4933
4942
  };
4934
4943
  v.value = bc(v.value.map((e) => e.id === n ? i : e)), U?.setConversations(v.value);
4935
4944
  }
4936
- function _t(e) {
4945
+ function K(e) {
4937
4946
  y.value = Sc(y.value, e), T.value && U?.setMessages(T.value, y.value);
4938
4947
  }
4939
- function K(e) {
4948
+ function yt(e) {
4940
4949
  e.parentMessageId === E.value?.id && (b.value = Sc(b.value, e), e.parentMessageId && U?.setThreadMessages(e.parentMessageId, b.value));
4941
4950
  }
4942
- async function yt(e) {
4951
+ async function bt(e) {
4943
4952
  if (m.value) return;
4944
4953
  let t = e.getSender?.()?.getUid?.();
4945
4954
  !t || t === _.value?.uid || e.getReadByMeAt?.() || (be(), await H.markAsRead(e));
4946
4955
  }
4947
- async function bt(e) {
4956
+ async function xt(e) {
4948
4957
  if (m.value) return;
4949
4958
  let t = e.getSender?.()?.getUid?.();
4950
4959
  !t || t === _.value?.uid || e.getDeliveredToMeAt?.() || (be(), await H.markAsDelivered(e));
4951
4960
  }
4952
- async function xt(e) {
4961
+ async function St(e) {
4953
4962
  return m.value ? [] : pc(await H.getMessageReceipts(String(e.id)));
4954
4963
  }
4955
- function St() {
4964
+ function Ct() {
4956
4965
  r.value = !1, i.value = !1, a.value = !1, o.value = !1, s.value = !1, c.value = !1, l.value = !1, u.value = !1, d.value = !1, f.value = !1, p.value = !1, ye(), oe = 0, se = !1, V = !1, h.value = !1, _.value = null, v.value = [], y.value = [], b.value = [], x.value = [], E.value = null, D.value = null, O.value = null, k.value = [], T.value = null, S.value = !1, C.value = !1, ue = null, de = null, le.clear();
4957
4966
  }
4958
- async function Ct(e) {
4967
+ async function wt(e) {
4959
4968
  if (ie) return ie;
4960
4969
  let t = e?.includeThread ?? !0;
4961
4970
  ie = (async () => {
4962
- I.value && await rt(), t && E.value && await at(E.value.id);
4971
+ I.value && await it(), t && E.value && await ot(E.value.id);
4963
4972
  })();
4964
4973
  try {
4965
4974
  await ie;
@@ -4967,20 +4976,20 @@ function cc({ environment: e }) {
4967
4976
  ie = null;
4968
4977
  }
4969
4978
  }
4970
- function wt(e) {
4971
- Tt(e), e.parentMessageId && Ot(e.parentMessageId, e.replyCount), kt();
4972
- }
4973
4979
  function Tt(e) {
4980
+ Et(e), e.parentMessageId && kt(e.parentMessageId, e.replyCount), At();
4981
+ }
4982
+ function Et(e) {
4974
4983
  if (e.parentMessageId) {
4975
4984
  E.value?.id === e.parentMessageId && (b.value = Sc(b.value, e));
4976
4985
  return;
4977
4986
  }
4978
4987
  y.value = Sc(y.value, e), E.value?.id === e.id && (E.value = e);
4979
4988
  }
4980
- function Et(e, t) {
4989
+ function Dt(e, t) {
4981
4990
  return t ? b.value.find((t) => t.id === e) ?? null : E.value?.id === e ? E.value : y.value.find((t) => t.id === e) ?? null;
4982
4991
  }
4983
- function Dt(e, t) {
4992
+ function Ot(e, t) {
4984
4993
  let n = e.reactions.find((e) => e.emoji === t);
4985
4994
  return n ? n.reactedByMe && n.count === 1 ? {
4986
4995
  ...e,
@@ -5001,7 +5010,7 @@ function cc({ environment: e }) {
5001
5010
  }]
5002
5011
  };
5003
5012
  }
5004
- function Ot(e, t) {
5013
+ function kt(e, t) {
5005
5014
  let n = y.value.find((t) => t.id === e);
5006
5015
  if (!n) return;
5007
5016
  let r = {
@@ -5010,18 +5019,18 @@ function cc({ environment: e }) {
5010
5019
  };
5011
5020
  y.value = Sc(y.value, r), E.value?.id === e && (E.value = r);
5012
5021
  }
5013
- function kt() {
5022
+ function At() {
5014
5023
  T.value && U?.setMessages(T.value, y.value), E.value && U?.setThreadMessages(E.value.id, b.value);
5015
5024
  }
5016
- function At(e) {
5025
+ function jt(e) {
5017
5026
  if (e.parentMessageId ? (b.value = b.value.filter((t) => t.id !== e.id), U?.setThreadMessages(e.parentMessageId, b.value)) : (y.value = y.value.filter((t) => t.id !== e.id), T.value && U?.setMessages(T.value, y.value)), e.muid) {
5018
5027
  k.value = k.value.filter((t) => t.muid !== e.muid);
5019
5028
  let t = U?.getQueue().filter((t) => t.muid === e.muid) ?? [];
5020
5029
  for (let e of t) U?.dequeue(e.id), ce.delete(e.id), e.kind === "attachment" && U?.deleteQueuedAttachment(e.id);
5021
5030
  }
5022
- e.parentMessageId || Mt(e.conversationId);
5031
+ e.parentMessageId || Nt(e.conversationId);
5023
5032
  }
5024
- function jt(e) {
5033
+ function Mt(e) {
5025
5034
  if (e.parentMessageId) return;
5026
5035
  let t = e.conversationId, n = v.value.find((e) => e.id === t);
5027
5036
  if (!n) return;
@@ -5046,7 +5055,7 @@ function cc({ environment: e }) {
5046
5055
  lastMessageAt: void 0
5047
5056
  } : e : e)), U?.setConversations(v.value);
5048
5057
  }
5049
- function Mt(e, t) {
5058
+ function Nt(e, t) {
5050
5059
  let n = y.value.length > 0 ? y.value[y.value.length - 1] : null, r = t ?? n;
5051
5060
  v.value = bc(v.value.map((t) => t.id === e ? {
5052
5061
  ...t,
@@ -5055,7 +5064,7 @@ function cc({ environment: e }) {
5055
5064
  lastMessage: r
5056
5065
  } : t)), U?.setConversations(v.value);
5057
5066
  }
5058
- function Nt(e) {
5067
+ function Pt(e) {
5059
5068
  v.value = bc(v.value.map((t) => t.id === e.conversationId ? {
5060
5069
  ...t,
5061
5070
  subtitle: Oc(e),
@@ -5064,8 +5073,8 @@ function cc({ environment: e }) {
5064
5073
  unreadCount: 0
5065
5074
  } : t)), U?.setConversations(v.value);
5066
5075
  }
5067
- function Pt(e) {
5068
- let t = /* @__PURE__ */ new Date(), n = It(e.metadata);
5076
+ function Ft(e) {
5077
+ let t = /* @__PURE__ */ new Date(), n = Lt(e.metadata);
5069
5078
  return {
5070
5079
  id: `local-${e.muid}`,
5071
5080
  muid: e.muid,
@@ -5104,11 +5113,11 @@ function cc({ environment: e }) {
5104
5113
  source: null
5105
5114
  };
5106
5115
  }
5107
- function Ft(e, t) {
5116
+ function It(e, t) {
5108
5117
  let n = {};
5109
5118
  return t?.senderDisplayName?.trim() && (n.senderDisplayName = t.senderDisplayName.trim()), e ? (n.replyToMessageId = e.id, n.replyPreview = Js(e), n) : n;
5110
5119
  }
5111
- function It(e) {
5120
+ function Lt(e) {
5112
5121
  let t = e.replyPreview;
5113
5122
  if (!t || typeof t != "object") return;
5114
5123
  let n = t;
@@ -5119,13 +5128,13 @@ function cc({ environment: e }) {
5119
5128
  kind: n.kind ?? "text"
5120
5129
  };
5121
5130
  }
5122
- function Lt(e) {
5131
+ function Rt(e) {
5123
5132
  if (M() || m.value) return !0;
5124
5133
  let t = Z(e, "").toLowerCase();
5125
5134
  return t.includes("network") || t.includes("failed to fetch") || t.includes("socket") || t.includes("offline");
5126
5135
  }
5127
- function Rt(e, t, n, r, i) {
5128
- let a = Pt({
5136
+ function zt(e, t, n, r, i) {
5137
+ let a = Ft({
5129
5138
  conversation: e,
5130
5139
  kind: "text",
5131
5140
  text: t,
@@ -5134,7 +5143,7 @@ function cc({ environment: e }) {
5134
5143
  muid: i,
5135
5144
  deliveryState: "queued"
5136
5145
  });
5137
- Ut(a, {
5146
+ Wt(a, {
5138
5147
  id: a.id,
5139
5148
  muid: i,
5140
5149
  conversationId: e.id,
@@ -5147,9 +5156,9 @@ function cc({ environment: e }) {
5147
5156
  createdAt: a.sentAt.toISOString()
5148
5157
  });
5149
5158
  }
5150
- function zt(e, t, n, r, i) {
5151
- if (Bt(e, t, r)) return;
5152
- let a = Pt({
5159
+ function Bt(e, t, n, r, i) {
5160
+ if (Ht(e, t, r)) return;
5161
+ let a = Ft({
5153
5162
  conversation: e,
5154
5163
  kind: "poll",
5155
5164
  text: `Poll: ${t.question}`,
@@ -5159,7 +5168,7 @@ function cc({ environment: e }) {
5159
5168
  muid: i,
5160
5169
  deliveryState: "queued"
5161
5170
  });
5162
- Ut(a, {
5171
+ Wt(a, {
5163
5172
  id: a.id,
5164
5173
  muid: i,
5165
5174
  conversationId: e.id,
@@ -5172,7 +5181,7 @@ function cc({ environment: e }) {
5172
5181
  createdAt: a.sentAt.toISOString()
5173
5182
  });
5174
5183
  }
5175
- function Bt(e, t, n) {
5184
+ function Ht(e, t, n) {
5176
5185
  let r = Date.now(), i = (e) => e.trim().toLowerCase(), a = (e) => e.map((e) => i(e)).filter(Boolean).join("\0"), o = i(t.question), s = a(t.options);
5177
5186
  return k.value.some((t) => {
5178
5187
  if (t.kind !== "poll" || !t.poll || t.conversationId !== e.id || t.targetId !== e.targetId || t.parentMessageId !== n) return !1;
@@ -5180,8 +5189,8 @@ function cc({ environment: e }) {
5180
5189
  return Number.isNaN(c) || r - c > 5e3 ? !1 : i(t.poll.question) === o && a(t.poll.options) === s;
5181
5190
  });
5182
5191
  }
5183
- async function Ht(e, t, n, r, i) {
5184
- let a = Nc(t.file), o = Pt({
5192
+ async function Ut(e, t, n, r, i) {
5193
+ let a = Nc(t.file), o = Ft({
5185
5194
  conversation: e,
5186
5195
  kind: a,
5187
5196
  text: t.caption?.trim() ?? "",
@@ -5217,15 +5226,15 @@ function cc({ environment: e }) {
5217
5226
  try {
5218
5227
  await U?.storeQueuedAttachment(s.id, t.file);
5219
5228
  } catch {}
5220
- Ut(o, s);
5229
+ Wt(o, s);
5221
5230
  }
5222
- function Ut(e, t) {
5223
- k.value = [...k.value, t], U?.enqueue(t), Wt(e);
5231
+ function Wt(e, t) {
5232
+ k.value = [...k.value, t], U?.enqueue(t), Gt(e);
5224
5233
  }
5225
- function Wt(e) {
5226
- e.parentMessageId ? (E.value?.id === e.parentMessageId && (b.value = Sc(b.value, e)), Ot(e.parentMessageId)) : y.value = Sc(y.value, e), Nt(e), kt();
5234
+ function Gt(e) {
5235
+ e.parentMessageId ? (E.value?.id === e.parentMessageId && (b.value = Sc(b.value, e)), kt(e.parentMessageId)) : y.value = Sc(y.value, e), Pt(e), At();
5227
5236
  }
5228
- function Gt(e, t) {
5237
+ function Kt(e, t) {
5229
5238
  let n = (n) => n.map((n) => {
5230
5239
  let r = Ec(n);
5231
5240
  return n.muid !== t && r !== t ? n : {
@@ -5233,18 +5242,18 @@ function cc({ environment: e }) {
5233
5242
  deliveryState: e
5234
5243
  };
5235
5244
  });
5236
- y.value = n(y.value), b.value = n(b.value), kt();
5245
+ y.value = n(y.value), b.value = n(b.value), At();
5237
5246
  }
5238
- function Kt(e) {
5247
+ function qt(e) {
5239
5248
  if (!e) return;
5240
5249
  let t = [...y.value, ...b.value].filter((t) => {
5241
5250
  if (!t.id.startsWith("local-")) return !1;
5242
5251
  let n = Ec(t);
5243
5252
  return t.muid === e || n === e;
5244
5253
  });
5245
- for (let e of t) At(e);
5254
+ for (let e of t) jt(e);
5246
5255
  }
5247
- async function qt() {
5256
+ async function Jt() {
5248
5257
  if (!(f.value || k.value.length === 0 || !h.value || m.value)) {
5249
5258
  f.value = !0;
5250
5259
  try {
@@ -5252,20 +5261,20 @@ function cc({ environment: e }) {
5252
5261
  for (let t of e) if (!le.has(t.id)) {
5253
5262
  le.add(t.id);
5254
5263
  try {
5255
- let e = await Jt(t);
5256
- k.value = k.value.filter((e) => e.id !== t.id), U?.dequeue(t.id), ce.delete(t.id), t.kind === "attachment" && await U?.deleteQueuedAttachment(t.id), Kt(t.muid), e ? wt(F(e, _.value?.uid)) : await Ct();
5264
+ let e = await Yt(t);
5265
+ k.value = k.value.filter((e) => e.id !== t.id), U?.dequeue(t.id), ce.delete(t.id), t.kind === "attachment" && await U?.deleteQueuedAttachment(t.id), qt(t.muid), e ? Tt(F(e, _.value?.uid)) : await wt();
5257
5266
  } finally {
5258
5267
  le.delete(t.id);
5259
5268
  }
5260
5269
  }
5261
5270
  } catch (e) {
5262
- Lt(e) || (g.value = Z(e, "Unable to sync queued messages."));
5271
+ Rt(e) || (g.value = Z(e, "Unable to sync queued messages."));
5263
5272
  } finally {
5264
5273
  f.value = !1;
5265
5274
  }
5266
5275
  }
5267
5276
  }
5268
- async function Jt(e) {
5277
+ async function Yt(e) {
5269
5278
  let t = e.receiverType === "group" ? H.RECEIVER_TYPE.GROUP : H.RECEIVER_TYPE.USER;
5270
5279
  if (e.kind === "poll" && e.poll) {
5271
5280
  let n = {
@@ -5317,33 +5326,33 @@ function cc({ environment: e }) {
5317
5326
  replyToMessage: D,
5318
5327
  editingMessage: O,
5319
5328
  init: pe,
5320
- connectRealtime: De,
5321
- disconnectRealtime: Oe,
5329
+ connectRealtime: Oe,
5330
+ disconnectRealtime: ke,
5322
5331
  login: me,
5323
5332
  logout: he,
5324
- fetchConversations: ke,
5325
- selectConversation: Ae,
5326
- sendTextMessage: Fe,
5327
- sendAttachmentMessage: Le,
5328
- sendPollMessage: Re,
5329
- fetchScheduledMessages: We,
5330
- loadOlderMessages: ot,
5331
- loadOlderThreadMessages: st,
5332
- ensureMessageLoaded: ct,
5333
- scheduleMessage: Ge,
5334
- rescheduleMessage: Xe,
5335
- removeScheduledMessage: Ke,
5336
- editScheduledMessage: Ye,
5337
- setReplyToMessage: je,
5338
- setEditingMessage: Me,
5339
- openThread: Ne,
5340
- closeThread: Pe,
5341
- refreshVisibleMessages: Ct,
5342
- fetchMessageReceipts: xt,
5343
- deleteMessage: Ve,
5344
- votePoll: W,
5345
- toggleReaction: Be,
5346
- translateMessage: Ue,
5333
+ fetchConversations: Ae,
5334
+ selectConversation: je,
5335
+ sendTextMessage: Ie,
5336
+ sendAttachmentMessage: Re,
5337
+ sendPollMessage: W,
5338
+ fetchScheduledMessages: Ge,
5339
+ loadOlderMessages: st,
5340
+ loadOlderThreadMessages: ct,
5341
+ ensureMessageLoaded: ut,
5342
+ scheduleMessage: Ke,
5343
+ rescheduleMessage: Ze,
5344
+ removeScheduledMessage: Ye,
5345
+ editScheduledMessage: Xe,
5346
+ setReplyToMessage: Me,
5347
+ setEditingMessage: Ne,
5348
+ openThread: Pe,
5349
+ closeThread: Fe,
5350
+ refreshVisibleMessages: wt,
5351
+ fetchMessageReceipts: St,
5352
+ deleteMessage: Ue,
5353
+ votePoll: ze,
5354
+ toggleReaction: Ve,
5355
+ translateMessage: We,
5347
5356
  mentionDisplayNamesByUid: A,
5348
5357
  rememberMentionDisplayNames: ee
5349
5358
  };