@traiyani/chatsdk-react 1.0.2 → 1.0.4

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.
@@ -2596,11 +2596,11 @@ function me(c) {
2596
2596
  let e = this || {}, t = c.call ? c(e.p) : c;
2597
2597
  return ut(t.unshift ? t.raw ? mt(t, [].slice.call(arguments, 1), e.p) : t.reduce((a, s) => Object.assign(a, s && s.call ? s(e.p) : s), {}) : t, dt(e.target), e.g, e.o, e.k);
2598
2598
  }
2599
- let Ne, ke, ye;
2599
+ let Ne, ke, ve;
2600
2600
  me.bind({ g: 1 });
2601
2601
  let ee = me.bind({ k: 1 });
2602
2602
  function ft(c, e, t, a) {
2603
- se.p = e, Ne = c, ke = t, ye = a;
2603
+ se.p = e, Ne = c, ke = t, ve = a;
2604
2604
  }
2605
2605
  function ne(c, e) {
2606
2606
  let t = this || {};
@@ -2610,12 +2610,12 @@ function ne(c, e) {
2610
2610
  let r = Object.assign({}, n), i = r.className || s.className;
2611
2611
  t.p = Object.assign({ theme: ke && ke() }, r), t.o = / *go\d+/.test(i), r.className = me.apply(t, a) + (i ? " " + i : "");
2612
2612
  let l = c;
2613
- return c[0] && (l = r.as || c, delete r.as), ye && l[0] && ye(r), Ne(l, r);
2613
+ return c[0] && (l = r.as || c, delete r.as), ve && l[0] && ve(r), Ne(l, r);
2614
2614
  }
2615
2615
  return s;
2616
2616
  };
2617
2617
  }
2618
- var pt = (c) => typeof c == "function", ve = (c, e) => pt(c) ? c(e) : c, wt = /* @__PURE__ */ (() => {
2618
+ var pt = (c) => typeof c == "function", ye = (c, e) => pt(c) ? c(e) : c, wt = /* @__PURE__ */ (() => {
2619
2619
  let c = 0;
2620
2620
  return () => (++c).toString();
2621
2621
  })(), kt = /* @__PURE__ */ (() => {
@@ -2627,10 +2627,10 @@ var pt = (c) => typeof c == "function", ve = (c, e) => pt(c) ? c(e) : c, wt = /*
2627
2627
  }
2628
2628
  return c;
2629
2629
  };
2630
- })(), yt = 20, Te = (c, e) => {
2630
+ })(), vt = 20, Te = (c, e) => {
2631
2631
  switch (e.type) {
2632
2632
  case 0:
2633
- return { ...c, toasts: [e.toast, ...c.toasts].slice(0, yt) };
2633
+ return { ...c, toasts: [e.toast, ...c.toasts].slice(0, vt) };
2634
2634
  case 1:
2635
2635
  return { ...c, toasts: c.toasts.map((n) => n.id === e.toast.id ? { ...n, ...e.toast } : n) };
2636
2636
  case 2:
@@ -2647,8 +2647,8 @@ var pt = (c) => typeof c == "function", ve = (c, e) => pt(c) ? c(e) : c, wt = /*
2647
2647
  let s = e.time - (c.pausedAt || 0);
2648
2648
  return { ...c, pausedAt: void 0, toasts: c.toasts.map((n) => ({ ...n, pauseDuration: n.pauseDuration + s })) };
2649
2649
  }
2650
- }, vt = [], we = { toasts: [], pausedAt: void 0 }, Me = (c) => {
2651
- we = Te(we, c), vt.forEach((e) => {
2650
+ }, yt = [], we = { toasts: [], pausedAt: void 0 }, Me = (c) => {
2651
+ we = Te(we, c), yt.forEach((e) => {
2652
2652
  e(we);
2653
2653
  });
2654
2654
  }, bt = (c, e = "blank", t) => ({ createdAt: Date.now(), visible: !0, dismissed: !1, type: e, ariaProps: { role: "status", "aria-live": "polite" }, message: c, pauseDuration: 0, ...t, id: (t == null ? void 0 : t.id) || wt() }), ue = (c) => (e, t) => {
@@ -2666,10 +2666,10 @@ V.remove = (c) => Me({ type: 4, toastId: c });
2666
2666
  V.promise = (c, e, t) => {
2667
2667
  let a = V.loading(e.loading, { ...t, ...t == null ? void 0 : t.loading });
2668
2668
  return typeof c == "function" && (c = c()), c.then((s) => {
2669
- let n = e.success ? ve(e.success, s) : void 0;
2669
+ let n = e.success ? ye(e.success, s) : void 0;
2670
2670
  return n ? V.success(n, { id: a, ...t, ...t == null ? void 0 : t.success }) : V.dismiss(a), s;
2671
2671
  }).catch((s) => {
2672
- let n = e.error ? ve(e.error, s) : void 0;
2672
+ let n = e.error ? ye(e.error, s) : void 0;
2673
2673
  n ? V.error(n, { id: a, ...t, ...t == null ? void 0 : t.error }) : V.dismiss(a);
2674
2674
  }), c;
2675
2675
  };
@@ -2852,7 +2852,7 @@ to {
2852
2852
  return { animation: e ? `${ee(a)} 0.35s cubic-bezier(.21,1.02,.73,1) forwards` : `${ee(s)} 0.4s forwards cubic-bezier(.06,.71,.55,1)` };
2853
2853
  };
2854
2854
  q.memo(({ toast: c, position: e, style: t, children: a }) => {
2855
- let s = c.height ? Ot(c.position || e || "top-center", c.visible) : { opacity: 0 }, n = q.createElement(Tt, { toast: c }), o = q.createElement(Pt, { ...c.ariaProps }, ve(c.message, c));
2855
+ let s = c.height ? Ot(c.position || e || "top-center", c.visible) : { opacity: 0 }, n = q.createElement(Tt, { toast: c }), o = q.createElement(Pt, { ...c.ariaProps }, ye(c.message, c));
2856
2856
  return q.createElement($t, { className: c.className, style: { ...s, ...t, ...c.style } }, typeof a == "function" ? a({ icon: n, message: o }) : q.createElement(q.Fragment, null, n, o));
2857
2857
  });
2858
2858
  ft(q.createElement);
@@ -3086,7 +3086,7 @@ const jt = {
3086
3086
  let he = "en";
3087
3087
  const Ie = (c) => {
3088
3088
  be[c] ? (he = c, document.documentElement.lang = c, document.documentElement.dir = qt() ? "rtl" : "ltr", localStorage.setItem("chatSDK_language", c)) : (console.warn(`Locale "${c}" not found, falling back to "en".`), he = "en", document.documentElement.lang = "en", document.documentElement.dir = "ltr");
3089
- }, Zt = () => he, qt = () => he === "ar", w = (c, e) => {
3089
+ }, ea = () => he, qt = () => he === "ar", w = (c, e) => {
3090
3090
  let t = be[he][c] || be.en[c] || c;
3091
3091
  if (e)
3092
3092
  for (const a in e)
@@ -3097,15 +3097,15 @@ const Ie = (c) => {
3097
3097
  return t;
3098
3098
  }, Ae = localStorage.getItem("chatSDK_language");
3099
3099
  Ie(Ae || "en");
3100
- const Xt = ({ conversation: c, currentUser: e, onClose: t, onBack: a }) => {
3100
+ const Vt = ({ conversation: c, currentUser: e, onClose: t, onBack: a }) => {
3101
3101
  var Se;
3102
- const [s, n] = T([]), [o, r] = T(""), [i, l] = T(!1), [d, h] = T(!1), [m, p] = T({}), [E, P] = T(!1), [Ce, ge] = T(!0), [y, C] = T(1), [O, G] = T(null), [B, J] = T(!1), [D, F] = T(!1), [N, x] = T(!1), [K, j] = T(null), [te, ae] = T(!1), Q = le(null), ce = le(null), $ = le(null), H = le(null), re = 20, oe = De(() => {
3102
+ const [s, n] = T([]), [o, r] = T(""), [i, l] = T(!1), [d, h] = T(!1), [m, p] = T({}), [E, P] = T(!1), [Ce, ge] = T(!0), [v, C] = T(1), [O, G] = T(null), [B, J] = T(!1), [D, F] = T(!1), [N, x] = T(!1), [K, j] = T(null), [te, ae] = T(!1), Q = le(null), ce = le(null), $ = le(null), H = le(null), re = 20, oe = De(() => {
3103
3103
  if (!c || !e) return null;
3104
3104
  const g = c.participants || [];
3105
3105
  if (g.length === 0) return null;
3106
3106
  const f = e.id || e.userId, b = e.externalUserId || e.external_user_id;
3107
- return g.find((v) => {
3108
- const S = v.id || v.userId, k = v.externalUserId || v.external_user_id;
3107
+ return g.find((y) => {
3108
+ const S = y.id || y.userId, k = y.externalUserId || y.external_user_id;
3109
3109
  return !(f && S && S === f || b && k && k === b) && (S || k);
3110
3110
  }) || null;
3111
3111
  }, [c, e]), U = oe(), W = De(() => {
@@ -3143,7 +3143,7 @@ const Xt = ({ conversation: c, currentUser: e, onClose: t, onBack: a }) => {
3143
3143
  !k.messageId || k.roomId !== (c == null ? void 0 : c.id) || n((_) => _.map(
3144
3144
  (I) => I.id === k.messageId && I.senderId === e.id ? { ...I, isRead: k.isRead } : I
3145
3145
  ));
3146
- }, v = (k) => {
3146
+ }, y = (k) => {
3147
3147
  if (k.roomId !== (c == null ? void 0 : c.id)) return;
3148
3148
  const _ = e == null ? void 0 : e.id;
3149
3149
  if (!k.messageIds || k.messageIds.length === 0) {
@@ -3162,15 +3162,15 @@ const Xt = ({ conversation: c, currentUser: e, onClose: t, onBack: a }) => {
3162
3162
  const A = e.id || e.userId, L = oe(), Z = L ? L.id || L.userId || L.externalUserId || L.external_user_id : null;
3163
3163
  J(I[A] === 1), F(Z ? I[Z] === 1 : !1);
3164
3164
  };
3165
- return g.events.on("message.received", f), g.events.on("message.read.receipt", b), g.events.on("messages.read.receipt", v), g.events.on("conversation.block_status", S), () => {
3166
- g.events.off("message.received", f), g.events.off("message.read.receipt", b), g.events.off("messages.read.receipt", v), g.events.off("conversation.block_status", S);
3165
+ return g.events.on("message.received", f), g.events.on("message.read.receipt", b), g.events.on("messages.read.receipt", y), g.events.on("conversation.block_status", S), () => {
3166
+ g.events.off("message.received", f), g.events.off("message.read.receipt", b), g.events.off("messages.read.receipt", y), g.events.off("conversation.block_status", S);
3167
3167
  };
3168
3168
  }, [c == null ? void 0 : c.id, e == null ? void 0 : e.id]), Y(() => {
3169
3169
  if (!c || !e) {
3170
3170
  J(!1), F(!1), G(null);
3171
3171
  return;
3172
3172
  }
3173
- const f = (c.metadata || {}).blockedUsers || {}, b = e.id || e.userId, v = oe(), S = v ? v.id || v.userId || v.externalUserId || v.external_user_id : null;
3173
+ const f = (c.metadata || {}).blockedUsers || {}, b = e.id || e.userId, y = oe(), S = y ? y.id || y.userId || y.externalUserId || y.external_user_id : null;
3174
3174
  J(f[b] === 1), F(S ? f[S] === 1 : !1), G({
3175
3175
  chatId: c.id,
3176
3176
  currentUserId: b,
@@ -3196,24 +3196,24 @@ const Xt = ({ conversation: c, currentUser: e, onClose: t, onBack: a }) => {
3196
3196
  var g;
3197
3197
  (g = Q.current) == null || g.scrollIntoView({ behavior: "smooth" });
3198
3198
  }, $e = (g) => new Date(g).toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" }), pe = (g) => {
3199
- const f = new Date(g), b = /* @__PURE__ */ new Date(), v = new Date(b.getFullYear(), b.getMonth(), b.getDate()), S = new Date(f.getFullYear(), f.getMonth(), f.getDate()), k = Math.floor((v.getTime() - S.getTime()) / (1e3 * 60 * 60 * 24));
3199
+ const f = new Date(g), b = /* @__PURE__ */ new Date(), y = new Date(b.getFullYear(), b.getMonth(), b.getDate()), S = new Date(f.getFullYear(), f.getMonth(), f.getDate()), k = Math.floor((y.getTime() - S.getTime()) / (1e3 * 60 * 60 * 24));
3200
3200
  if (k === 0) return "Today";
3201
3201
  if (k === 1) return "Yesterday";
3202
3202
  const _ = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], I = f.getDate().toString().padStart(2, "0"), A = (f.getMonth() + 1).toString().padStart(2, "0");
3203
3203
  return k < 7 ? `${_[f.getDay()]}, ${I}/${A}` : `${I}/${A}/${f.getFullYear()}`;
3204
3204
  }, Pe = (g, f) => {
3205
3205
  if (f === 0) return !0;
3206
- const b = s[f - 1], v = new Date(b.timestamp).toDateString(), S = new Date(g.timestamp).toDateString();
3207
- return v !== S;
3206
+ const b = s[f - 1], y = new Date(b.timestamp).toDateString(), S = new Date(g.timestamp).toDateString();
3207
+ return y !== S;
3208
3208
  }, Oe = (g) => g ? g.includes("pdf") ? "📄" : g.includes("word") ? "📝" : g.includes("excel") ? "📊" : g.includes("audio") ? "🎵" : g.includes("video") ? "🎥" : "📎" : "📎", je = () => {
3209
3209
  if (!$.current) return;
3210
3210
  const g = $.current, f = g.querySelectorAll(".date-divider[data-date]");
3211
3211
  if (f.length === 0) return;
3212
3212
  let b = null;
3213
- const v = g.getBoundingClientRect().top;
3213
+ const y = g.getBoundingClientRect().top;
3214
3214
  for (let S = f.length - 1; S >= 0; S--) {
3215
3215
  const k = f[S];
3216
- if (k.getBoundingClientRect().top <= v + 50) {
3216
+ if (k.getBoundingClientRect().top <= y + 50) {
3217
3217
  b = k.getAttribute("data-date");
3218
3218
  break;
3219
3219
  }
@@ -3231,21 +3231,21 @@ const Xt = ({ conversation: c, currentUser: e, onClose: t, onBack: a }) => {
3231
3231
  /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ? window.location.href = `tel:${f}` : navigator.clipboard.writeText(f).then(() => {
3232
3232
  z.success(w("number_copied") || `Phone number copied: ${f}`);
3233
3233
  }).catch(() => {
3234
- const v = document.createElement("textarea");
3235
- v.value = f, document.body.appendChild(v), v.select(), document.execCommand("copy"), document.body.removeChild(v), z.success(w("number_copied") || `Phone number copied: ${f}`);
3234
+ const y = document.createElement("textarea");
3235
+ y.value = f, document.body.appendChild(y), y.select(), document.execCommand("copy"), document.body.removeChild(y), z.success(w("number_copied") || `Phone number copied: ${f}`);
3236
3236
  });
3237
3237
  }, qe = async (g = 1, f = !1) => {
3238
3238
  if (c) {
3239
3239
  g === 1 ? (l(!0), n([]), C(1), ge(!0)) : P(!0);
3240
3240
  try {
3241
- const v = await R.getInstance().messages.getMessages({
3241
+ const y = await R.getInstance().messages.getMessages({
3242
3242
  conversationId: c.id,
3243
3243
  limit: re,
3244
3244
  offset: (g - 1) * re
3245
- }), S = v.sort(
3245
+ }), S = y.sort(
3246
3246
  (k, _) => new Date(k.timestamp).getTime() - new Date(_.timestamp).getTime()
3247
3247
  );
3248
- f && g > 1 ? n((k) => [...S, ...k]) : n(S), ge(v.length === re), C(g);
3248
+ f && g > 1 ? n((k) => [...S, ...k]) : n(S), ge(y.length === re), C(g);
3249
3249
  } catch {
3250
3250
  z.error(w("error_load_messages"));
3251
3251
  } finally {
@@ -3286,10 +3286,10 @@ const Xt = ({ conversation: c, currentUser: e, onClose: t, onBack: a }) => {
3286
3286
  mimeType: g.type
3287
3287
  }
3288
3288
  };
3289
- n((v) => [...v, b]), p((v) => ({ ...v, [f]: 0 }));
3289
+ n((y) => [...y, b]), p((y) => ({ ...y, [f]: 0 }));
3290
3290
  try {
3291
3291
  h(!0);
3292
- const v = R.getInstance(), S = v.media.getFileTypeCategory(g.type), k = await v.media.uploadMedia({
3292
+ const y = R.getInstance(), S = y.media.getFileTypeCategory(g.type), k = await y.media.uploadMedia({
3293
3293
  file: g,
3294
3294
  type: S,
3295
3295
  conversationId: c.id,
@@ -3306,7 +3306,7 @@ const Xt = ({ conversation: c, currentUser: e, onClose: t, onBack: a }) => {
3306
3306
  fileSize: k.fileSize,
3307
3307
  mimeType: k.mimeType || g.type
3308
3308
  };
3309
- await v.messages.sendMessageWithOptions({
3309
+ await y.messages.sendMessageWithOptions({
3310
3310
  conversationId: c.id,
3311
3311
  content: `${g.name}`,
3312
3312
  type: _,
@@ -3317,11 +3317,11 @@ const Xt = ({ conversation: c, currentUser: e, onClose: t, onBack: a }) => {
3317
3317
  return delete L[f], L;
3318
3318
  });
3319
3319
  }, 200), z.success(w("file_sent_successfully"));
3320
- } catch (v) {
3320
+ } catch (y) {
3321
3321
  n((S) => S.filter((k) => k.id !== f)), p((S) => {
3322
3322
  const k = { ...S };
3323
3323
  return delete k[f], k;
3324
- }), z.error(w("error_file_upload") + ": " + (v.message || w("error_unknown")));
3324
+ }), z.error(w("error_file_upload") + ": " + (y.message || w("error_unknown")));
3325
3325
  } finally {
3326
3326
  h(!1);
3327
3327
  }
@@ -3343,8 +3343,8 @@ const Xt = ({ conversation: c, currentUser: e, onClose: t, onBack: a }) => {
3343
3343
  return;
3344
3344
  }
3345
3345
  await g.conversations.blockUserInChat(c.id, b);
3346
- const v = c.metadata || {}, S = v.blockedUsers || {};
3347
- S[b] = 1, c && (c.metadata = { ...v, blockedUsers: S }), F(!0), z.success(w("user_blocked"));
3346
+ const y = c.metadata || {}, S = y.blockedUsers || {};
3347
+ S[b] = 1, c && (c.metadata = { ...y, blockedUsers: S }), F(!0), z.success(w("user_blocked"));
3348
3348
  } catch {
3349
3349
  z.error(w("failed_to_block"));
3350
3350
  }
@@ -3362,8 +3362,8 @@ const Xt = ({ conversation: c, currentUser: e, onClose: t, onBack: a }) => {
3362
3362
  return;
3363
3363
  }
3364
3364
  await g.conversations.unblockUserInChat(c.id, f);
3365
- const b = c.metadata || {}, v = b.blockedUsers || {};
3366
- delete v[f], c && (c.metadata = { ...b, blockedUsers: v }), F(!1), z.success(w("user_unblocked"));
3365
+ const b = c.metadata || {}, y = b.blockedUsers || {};
3366
+ delete y[f], c && (c.metadata = { ...b, blockedUsers: y }), F(!1), z.success(w("user_unblocked"));
3367
3367
  } catch {
3368
3368
  z.error(w("failed_to_unblock"));
3369
3369
  }
@@ -3424,7 +3424,7 @@ const Xt = ({ conversation: c, currentUser: e, onClose: t, onBack: a }) => {
3424
3424
  K && !i && s.length > 0 && /* @__PURE__ */ u("div", { className: `sticky-date-header ${te ? "sticky-date-visible" : ""}`, children: /* @__PURE__ */ u("span", { className: "sticky-date-pill", children: K }) }),
3425
3425
  i ? /* @__PURE__ */ u("div", { className: "loading-messages", children: w("loading_messages") }) : /* @__PURE__ */ M(Je, { children: [
3426
3426
  s.map((g, f) => {
3427
- var b, v, S, k, _, I, A, L, Z, Le;
3427
+ var b, y, S, k, _, I, A, L, Z, Le;
3428
3428
  return /* @__PURE__ */ M(Qe.Fragment, { children: [
3429
3429
  Pe(g, f) && /* @__PURE__ */ M("div", { className: "date-divider", "data-date": pe(g.timestamp), children: [
3430
3430
  /* @__PURE__ */ u("div", { className: "date-divider-line" }),
@@ -3437,7 +3437,7 @@ const Xt = ({ conversation: c, currentUser: e, onClose: t, onBack: a }) => {
3437
3437
  /* @__PURE__ */ u(
3438
3438
  "img",
3439
3439
  {
3440
- src: g.isUploading ? g.localFileUri : (v = g.metadata) == null ? void 0 : v.fileUrl,
3440
+ src: g.isUploading ? g.localFileUri : (y = g.metadata) == null ? void 0 : y.fileUrl,
3441
3441
  alt: ((S = g.metadata) == null ? void 0 : S.fileName) || w("image"),
3442
3442
  className: g.isUploading ? "uploading-image" : "",
3443
3443
  onClick: () => {
@@ -3543,7 +3543,7 @@ const Xt = ({ conversation: c, currentUser: e, onClose: t, onBack: a }) => {
3543
3543
  /* @__PURE__ */ u("button", { type: "submit", disabled: !o.trim() || i || d || B, className: "send-btn", children: w(d ? "uploading" : "send") })
3544
3544
  ] })
3545
3545
  ] });
3546
- }, ea = ({
3546
+ }, ta = (c) => /* @__PURE__ */ u("div", { className: "chatsdk-root", children: /* @__PURE__ */ u(Vt, { ...c }) }), Gt = ({
3547
3547
  currentUser: c,
3548
3548
  onSelectConversation: e,
3549
3549
  selectedConversationId: t
@@ -3559,7 +3559,7 @@ const Xt = ({ conversation: c, currentUser: e, onClose: t, onBack: a }) => {
3559
3559
  c && (s([]), m());
3560
3560
  }, [c.id]), Y(() => {
3561
3561
  var J;
3562
- const y = R.getInstance(), C = (D) => {
3562
+ const v = R.getInstance(), C = (D) => {
3563
3563
  const F = D.message, N = F.roomId || F.conversationId;
3564
3564
  s(
3565
3565
  (x) => x.map((K) => {
@@ -3626,20 +3626,20 @@ const Xt = ({ conversation: c, currentUser: e, onClose: t, onBack: a }) => {
3626
3626
  )
3627
3627
  );
3628
3628
  };
3629
- return y.events.on("message.received", C), y.events.on("conversation.updated", O), y.events.on("conversation.read", G), (J = y.socket) != null && J.isConnected() && (y.socket.on("auto_marked_read", B), y.socket.on("room_marked_read", G)), () => {
3629
+ return v.events.on("message.received", C), v.events.on("conversation.updated", O), v.events.on("conversation.read", G), (J = v.socket) != null && J.isConnected() && (v.socket.on("auto_marked_read", B), v.socket.on("room_marked_read", G)), () => {
3630
3630
  var D;
3631
- y.events.off("message.received", C), y.events.off("conversation.updated", O), y.events.off("conversation.read", G), (D = y.socket) != null && D.isConnected() && (y.socket.off("auto_marked_read", B), y.socket.off("room_marked_read", G));
3631
+ v.events.off("message.received", C), v.events.off("conversation.updated", O), v.events.off("conversation.read", G), (D = v.socket) != null && D.isConnected() && (v.socket.off("auto_marked_read", B), v.socket.off("room_marked_read", G));
3632
3632
  };
3633
3633
  }, []);
3634
- const h = async (y) => {
3634
+ const h = async (v) => {
3635
3635
  try {
3636
- if (y.unreadCount > 0) {
3636
+ if (v.unreadCount > 0) {
3637
3637
  const C = R.getInstance();
3638
- await C.chatUsers.markRoomMessagesRead(y.id), C.chatUsers.startViewingConversation(y.id);
3638
+ await C.chatUsers.markRoomMessagesRead(v.id), C.chatUsers.startViewingConversation(v.id);
3639
3639
  }
3640
- e(y);
3640
+ e(v);
3641
3641
  } catch (C) {
3642
- console.error("Failed to mark conversation as read:", C), e(y);
3642
+ console.error("Failed to mark conversation as read:", C), e(v);
3643
3643
  }
3644
3644
  }, m = async () => {
3645
3645
  o(!0);
@@ -3652,18 +3652,18 @@ const Xt = ({ conversation: c, currentUser: e, onClose: t, onBack: a }) => {
3652
3652
  } finally {
3653
3653
  o(!1);
3654
3654
  }
3655
- }, p = (y) => y.participants.find((C) => C.id !== c.id), E = (y) => {
3656
- const C = p(y);
3655
+ }, p = (v) => v.participants.find((C) => C.id !== c.id), E = (v) => {
3656
+ const C = p(v);
3657
3657
  return (C == null ? void 0 : C.name) || w("unknown_user");
3658
- }, P = (y) => {
3658
+ }, P = (v) => {
3659
3659
  var C;
3660
- return ((C = y.lastMessage) == null ? void 0 : C.content) || w("no_messages_yet");
3661
- }, Ce = (y) => {
3662
- const C = new Date(y), G = ((/* @__PURE__ */ new Date()).getTime() - C.getTime()) / (1e3 * 60 * 60), B = G / 24;
3660
+ return ((C = v.lastMessage) == null ? void 0 : C.content) || w("no_messages_yet");
3661
+ }, Ce = (v) => {
3662
+ const C = new Date(v), G = ((/* @__PURE__ */ new Date()).getTime() - C.getTime()) / (1e3 * 60 * 60), B = G / 24;
3663
3663
  return G < 24 ? C.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" }) : B < 7 ? `${Math.floor(B)}d ago` : `${C.getDate()} ${["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"][C.getMonth()]}`;
3664
- }, ge = r.trim() ? a.filter((y) => {
3664
+ }, ge = r.trim() ? a.filter((v) => {
3665
3665
  var J, D;
3666
- const C = r.toLowerCase().trim(), O = E(y).toLowerCase(), G = ((D = (J = y.productContext) == null ? void 0 : J.productName) == null ? void 0 : D.toLowerCase()) || "", B = P(y).toLowerCase();
3666
+ const C = r.toLowerCase().trim(), O = E(v).toLowerCase(), G = ((D = (J = v.productContext) == null ? void 0 : J.productName) == null ? void 0 : D.toLowerCase()) || "", B = P(v).toLowerCase();
3667
3667
  return O.includes(C) || G.includes(C) || B.includes(C);
3668
3668
  }) : a;
3669
3669
  return n ? /* @__PURE__ */ u("div", { className: "conversation-list loading", children: /* @__PURE__ */ u("div", { className: "loading-spinner", children: w("loading_conversations") }) }) : /* @__PURE__ */ M("div", { className: "conversation-list", children: [
@@ -3677,7 +3677,7 @@ const Xt = ({ conversation: c, currentUser: e, onClose: t, onBack: a }) => {
3677
3677
  "input",
3678
3678
  {
3679
3679
  value: r,
3680
- onChange: (y) => i(y.target.value),
3680
+ onChange: (v) => i(v.target.value),
3681
3681
  type: "text",
3682
3682
  placeholder: w("search") || "Search"
3683
3683
  }
@@ -3686,40 +3686,40 @@ const Xt = ({ conversation: c, currentUser: e, onClose: t, onBack: a }) => {
3686
3686
  /* @__PURE__ */ u("div", { className: "conversations", children: ge.length === 0 ? /* @__PURE__ */ M("div", { className: "empty-conversations", children: [
3687
3687
  /* @__PURE__ */ u("p", { children: r ? w("no_search_results") || "No results found" : w("no_conversations_title") }),
3688
3688
  !r && /* @__PURE__ */ u("p", { children: w("no_conversations_message") })
3689
- ] }) : ge.map((y) => {
3689
+ ] }) : ge.map((v) => {
3690
3690
  var O;
3691
- const C = t === y.id;
3691
+ const C = t === v.id;
3692
3692
  return /* @__PURE__ */ M(
3693
3693
  "div",
3694
3694
  {
3695
- className: `conversation-item ${C ? "selected" : ""} ${y.unreadCount > 0 ? "has-unread" : ""}`,
3696
- onClick: () => h(y),
3695
+ className: `conversation-item ${C ? "selected" : ""} ${v.unreadCount > 0 ? "has-unread" : ""}`,
3696
+ onClick: () => h(v),
3697
3697
  children: [
3698
- /* @__PURE__ */ u("div", { className: "conversation-avatar", children: (O = y.productContext) != null && O.productImage ? /* @__PURE__ */ u(
3698
+ /* @__PURE__ */ u("div", { className: "conversation-avatar", children: (O = v.productContext) != null && O.productImage ? /* @__PURE__ */ u(
3699
3699
  "img",
3700
3700
  {
3701
- src: y.productContext.productImage,
3702
- alt: y.productContext.productName,
3701
+ src: v.productContext.productImage,
3702
+ alt: v.productContext.productName,
3703
3703
  className: "product-image"
3704
3704
  }
3705
- ) : /* @__PURE__ */ u("div", { className: "avatar-placeholder", children: E(y).charAt(0).toUpperCase() }) }),
3705
+ ) : /* @__PURE__ */ u("div", { className: "avatar-placeholder", children: E(v).charAt(0).toUpperCase() }) }),
3706
3706
  /* @__PURE__ */ M("div", { className: "conversation-content", children: [
3707
3707
  /* @__PURE__ */ M("div", { className: "conversation-header", children: [
3708
- /* @__PURE__ */ u("div", { className: "conversation-title-wrapper", children: /* @__PURE__ */ u("h4", { className: "conversation-participant-name", children: E(y) }) }),
3709
- y.lastMessage && /* @__PURE__ */ u("span", { className: "conversation-time", children: Ce(y.lastMessage.timestamp) })
3708
+ /* @__PURE__ */ u("div", { className: "conversation-title-wrapper", children: /* @__PURE__ */ u("h4", { className: "conversation-participant-name", children: E(v) }) }),
3709
+ v.lastMessage && /* @__PURE__ */ u("span", { className: "conversation-time", children: Ce(v.lastMessage.timestamp) })
3710
3710
  ] }),
3711
3711
  /* @__PURE__ */ M("div", { className: "conversation-details", children: [
3712
- /* @__PURE__ */ u("p", { className: "conversation-last-message", children: P(y) }),
3713
- y.unreadCount > 0 && /* @__PURE__ */ u("span", { className: "unread-badge", children: y.unreadCount })
3712
+ /* @__PURE__ */ u("p", { className: "conversation-last-message", children: P(v) }),
3713
+ v.unreadCount > 0 && /* @__PURE__ */ u("span", { className: "unread-badge", children: v.unreadCount })
3714
3714
  ] })
3715
3715
  ] })
3716
3716
  ]
3717
3717
  },
3718
- y.id
3718
+ v.id
3719
3719
  );
3720
3720
  }) })
3721
3721
  ] });
3722
- }, Vt = () => {
3722
+ }, aa = (c) => /* @__PURE__ */ u("div", { className: "chatsdk-root", children: /* @__PURE__ */ u(Gt, { ...c }) }), Ht = () => {
3723
3723
  const [c, e] = T(() => typeof window < "u" && localStorage.getItem("chatSDK-theme") || "auto"), [t, a] = T(() => typeof window < "u" && window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light"), s = c === "auto" ? t : c;
3724
3724
  Y(() => {
3725
3725
  if (typeof window > "u" || !window.matchMedia) return;
@@ -3743,19 +3743,19 @@ const Xt = ({ conversation: c, currentUser: e, onClose: t, onBack: a }) => {
3743
3743
  n(c === "auto" ? t === "light" ? "dark" : "light" : s === "light" ? "dark" : "light");
3744
3744
  }
3745
3745
  };
3746
- }, Ke = Ze(void 0), ta = ({ children: c }) => {
3747
- const e = Vt();
3746
+ }, Ke = Ze(void 0), sa = ({ children: c }) => {
3747
+ const e = Ht();
3748
3748
  return /* @__PURE__ */ u(Ke.Provider, { value: e, children: c });
3749
- }, Gt = () => {
3749
+ }, Yt = () => {
3750
3750
  const c = Xe(Ke);
3751
3751
  if (!c)
3752
3752
  throw new Error("useThemeContext must be used within a ThemeProvider");
3753
3753
  return c;
3754
- }, aa = ({
3754
+ }, na = ({
3755
3755
  className: c = "",
3756
3756
  showLabel: e = !1
3757
3757
  }) => {
3758
- const { theme: t, actualTheme: a, setTheme: s } = Gt(), n = () => {
3758
+ const { theme: t, actualTheme: a, setTheme: s } = Yt(), n = () => {
3759
3759
  switch (t) {
3760
3760
  case "light":
3761
3761
  return /* @__PURE__ */ u("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ u("path", { d: "M12 2.25a.75.75 0 01.75.75v2.25a.75.75 0 01-1.5 0V3a.75.75 0 01.75-.75zM7.5 12a4.5 4.5 0 119 0 4.5 4.5 0 01-9 0zM18.894 6.166a.75.75 0 00-1.06-1.06l-1.591 1.59a.75.75 0 101.06 1.061l1.591-1.59zM21.75 12a.75.75 0 01-.75.75h-2.25a.75.75 0 010-1.5H21a.75.75 0 01.75.75zM17.834 18.894a.75.75 0 001.06-1.06l-1.59-1.591a.75.75 0 10-1.061 1.06l1.59 1.591zM12 18a.75.75 0 01.75.75V21a.75.75 0 01-1.5 0v-2.25A.75.75 0 0112 18zM7.758 17.303a.75.75 0 00-1.061-1.06l-1.591 1.59a.75.75 0 001.06 1.061l1.591-1.59zM6 12a.75.75 0 01-.75.75H3a.75.75 0 010-1.5h2.25A.75.75 0 016 12zM6.697 7.757a.75.75 0 001.06-1.06l-1.59-1.591a.75.75 0 00-1.061 1.06l1.59 1.591z" }) });
@@ -3810,11 +3810,11 @@ const Xt = ({ conversation: c, currentUser: e, onClose: t, onBack: a }) => {
3810
3810
  ]
3811
3811
  }
3812
3812
  );
3813
- }, sa = () => {
3813
+ }, ra = () => {
3814
3814
  var s;
3815
3815
  const c = localStorage.getItem("chatSDK-theme"), e = (s = window.matchMedia) == null ? void 0 : s.call(window, "(prefers-color-scheme: dark)").matches, t = c || "auto", a = t === "auto" ? e ? "dark" : "light" : t;
3816
3816
  document.documentElement.classList.add(`theme-${a}`), document.documentElement.setAttribute("data-theme", a);
3817
- }, na = {
3817
+ }, oa = {
3818
3818
  // Material Design 3 Primary Colors
3819
3819
  primary: {
3820
3820
  main: "#2196F3",
@@ -3898,7 +3898,7 @@ const Xt = ({ conversation: c, currentUser: e, onClose: t, onBack: a }) => {
3898
3898
  black: "#000000",
3899
3899
  transparent: "transparent"
3900
3900
  }
3901
- }, ra = {
3901
+ }, ia = {
3902
3902
  primary: {
3903
3903
  main: "#90CAF9",
3904
3904
  onPrimary: "#0D47A1",
@@ -3946,7 +3946,7 @@ const Xt = ({ conversation: c, currentUser: e, onClose: t, onBack: a }) => {
3946
3946
  timestamp: "#BDBDBD",
3947
3947
  primaryText: "#FFFFFF"
3948
3948
  }
3949
- }, oa = {
3949
+ }, ca = {
3950
3950
  async init(c) {
3951
3951
  const { ChatSDK: e } = await Promise.resolve().then(() => ct);
3952
3952
  return e.getInstance().init(c);
@@ -3964,26 +3964,26 @@ const Xt = ({ conversation: c, currentUser: e, onClose: t, onBack: a }) => {
3964
3964
  export {
3965
3965
  et as AuthManager,
3966
3966
  R as ChatSDK,
3967
- oa as ChatSDKHelpers,
3968
- Xt as ChatWindow,
3969
- ea as ConversationList,
3967
+ ca as ChatSDKHelpers,
3968
+ ta as ChatWindow,
3969
+ aa as ConversationList,
3970
3970
  st as ConversationManager,
3971
3971
  ot as EventManager,
3972
3972
  rt as MediaManager,
3973
3973
  nt as MessageManager,
3974
3974
  Ue as ParseUtils,
3975
3975
  it as SocketManager,
3976
- ta as ThemeProvider,
3977
- aa as ThemeToggle,
3976
+ sa as ThemeProvider,
3977
+ na as ThemeToggle,
3978
3978
  at as UserManager,
3979
3979
  Ie as changeLanguage,
3980
- ra as darkThemeConfig,
3981
- Zt as getCurrentLanguage,
3982
- sa as initializeTheme,
3980
+ ia as darkThemeConfig,
3981
+ ea as getCurrentLanguage,
3982
+ ra as initializeTheme,
3983
3983
  qt as isRTL,
3984
3984
  w as t,
3985
- na as themeConfig,
3986
- Vt as useTheme,
3987
- Gt as useThemeContext
3985
+ oa as themeConfig,
3986
+ Ht as useTheme,
3987
+ Yt as useThemeContext
3988
3988
  };
3989
3989
  //# sourceMappingURL=chatsdk-react.mjs.map