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