@traiyani/chatsdk-react 1.0.4 → 1.0.5

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.
@@ -1,9 +1,9 @@
1
- import de from "axios";
2
- import { io as Ye } from "socket.io-client";
3
- import { jsxs as M, jsx as u, Fragment as Je } from "react/jsx-runtime";
4
- import * as q from "react";
5
- import Qe, { useState as T, useRef as le, useCallback as De, useEffect as Y, createContext as Ze, useContext as Xe } from "react";
6
- class et {
1
+ import ge from "axios";
2
+ import { io as Xe } from "socket.io-client";
3
+ import { jsxs as M, jsx as u, Fragment as et } from "react/jsx-runtime";
4
+ import * as V from "react";
5
+ import tt, { useState as N, useRef as ne, useCallback as Ie, useEffect as P, createContext as at, useContext as st } from "react";
6
+ class nt {
7
7
  constructor(e) {
8
8
  this.api = null, this.config = null, this.chatSDK = e;
9
9
  }
@@ -11,7 +11,7 @@ class et {
11
11
  * Initialize AuthManager with configuration
12
12
  */
13
13
  async init(e) {
14
- this.config = e, this.api = de.create({
14
+ this.config = e, this.api = ge.create({
15
15
  baseURL: e.apiBaseUrl,
16
16
  headers: {
17
17
  "Content-Type": "application/json"
@@ -281,7 +281,7 @@ class et {
281
281
  localStorage.removeItem("chatSDKToken");
282
282
  }
283
283
  }
284
- class tt {
284
+ class rt {
285
285
  constructor(e) {
286
286
  this.api = null, this.config = null, this.chatSDK = e;
287
287
  }
@@ -289,7 +289,7 @@ class tt {
289
289
  * Initialize ChatUserManager with configuration
290
290
  */
291
291
  async init(e) {
292
- this.config = e, this.api = de.create({
292
+ this.config = e, this.api = ge.create({
293
293
  baseURL: e.apiBaseUrl,
294
294
  headers: {
295
295
  "Content-Type": "application/json"
@@ -535,13 +535,13 @@ class tt {
535
535
  }
536
536
  };
537
537
  s && Object.keys(s).length > 0 && (m.chatMetadata = s);
538
- const p = await this.api.post("/api/chat-users/chats", m), E = p.data.data || p.data.conversation || p.data;
538
+ const p = await this.api.post("/api/chat-users/chats", m), D = p.data.data || p.data.conversation || p.data;
539
539
  return (n = this.config) != null && n.enableLogging && console.log("💬 ChatUserManager: Product chat started successfully", {
540
- conversationId: E.id,
540
+ conversationId: D.id,
541
541
  userId: t,
542
542
  productId: a.productId,
543
543
  productName: a.productName
544
- }), (o = this.chatSDK.socket) != null && o.isConnected() && this.chatSDK.socket.joinRoom(E.id), (r = this.chatSDK.events) == null || r.emit("conversation.created", { conversation: E }), E;
544
+ }), (o = this.chatSDK.socket) != null && o.isConnected() && this.chatSDK.socket.joinRoom(D.id), (r = this.chatSDK.events) == null || r.emit("conversation.created", { conversation: D }), D;
545
545
  } catch (m) {
546
546
  throw (i = this.config) != null && i.enableLogging && console.error("❌ ChatUserManager: Start product chat failed", ((l = m.response) == null ? void 0 : l.data) || m.message), new Error(((h = (d = m.response) == null ? void 0 : d.data) == null ? void 0 : h.message) || "Failed to start product chat");
547
547
  }
@@ -607,8 +607,8 @@ class tt {
607
607
  if ((t = this.config) != null && t.enableLogging && console.log("📖 ChatUserManager: Marking room as read", { conversationId: e }), (a = this.chatSDK.socket) != null && a.isConnected())
608
608
  return this.chatSDK.socket.emit("mark_room_read", { roomId: e }), (s = this.config) != null && s.enableLogging && console.log("📡 ChatUserManager: mark_room_read sent via socket", { roomId: e }), (n = this.chatSDK.events) == null || n.emit("conversation.read", { conversationId: e, markedCount: 0 }), 0;
609
609
  (o = this.config) != null && o.enableLogging && console.log("📡 ChatUserManager: Socket not connected, falling back to API");
610
- const E = (await this.api.post(`/api/chat-users/chats/${e}/mark-read`)).data.data.markedAsReadCount || 0;
611
- return (r = this.config) != null && r.enableLogging && console.log("✅ ChatUserManager: Room messages marked as read via API", { conversationId: e, markedCount: E }), (i = this.chatSDK.events) == null || i.emit("conversation.read", { conversationId: e, markedCount: E }), E;
610
+ const D = (await this.api.post(`/api/chat-users/chats/${e}/mark-read`)).data.data.markedAsReadCount || 0;
611
+ return (r = this.config) != null && r.enableLogging && console.log("✅ ChatUserManager: Room messages marked as read via API", { conversationId: e, markedCount: D }), (i = this.chatSDK.events) == null || i.emit("conversation.read", { conversationId: e, markedCount: D }), D;
612
612
  } catch (p) {
613
613
  throw console.error("❌ ChatUserManager: Mark room messages as read failed", {
614
614
  conversationId: e,
@@ -663,7 +663,7 @@ class tt {
663
663
  }), (a = this.config) != null && a.enableLogging && console.log("👁️ ChatUserManager: Stopped viewing conversation", { conversationId: e }));
664
664
  }
665
665
  }
666
- class at {
666
+ class ot {
667
667
  constructor(e) {
668
668
  this.api = null, this.config = null, this.chatSDK = e;
669
669
  }
@@ -671,7 +671,7 @@ class at {
671
671
  * Initialize UserManager with configuration
672
672
  */
673
673
  async init(e) {
674
- this.config = e, this.api = de.create({
674
+ this.config = e, this.api = ge.create({
675
675
  baseURL: e.apiBaseUrl,
676
676
  headers: {
677
677
  "Content-Type": "application/json"
@@ -846,7 +846,7 @@ class at {
846
846
  }
847
847
  }
848
848
  }
849
- class st {
849
+ class it {
850
850
  constructor(e) {
851
851
  this.api = null, this.config = null, this.chatSDK = e;
852
852
  }
@@ -854,7 +854,7 @@ class st {
854
854
  * Initialize ConversationManager with configuration
855
855
  */
856
856
  async init(e) {
857
- this.config = e, this.api = de.create({
857
+ this.config = e, this.api = ge.create({
858
858
  baseURL: e.apiBaseUrl,
859
859
  headers: {
860
860
  "Content-Type": "application/json"
@@ -926,15 +926,15 @@ class st {
926
926
  }
927
927
  };
928
928
  s && Object.keys(s).length > 0 && (p.chatMetadata = s), (n = this.config) != null && n.enableLogging && console.log("⚡ Using externalGroupId:", e);
929
- const E = await this.api.post("/api/chat-users/chats", p);
930
- console.log("📡 Server response:", E.data);
931
- const P = E.data.data || E.data.conversation || E.data;
929
+ const D = await this.api.post("/api/chat-users/chats", p);
930
+ console.log("📡 Server response:", D.data);
931
+ const O = D.data.data || D.data.conversation || D.data;
932
932
  return (o = this.config) != null && o.enableLogging && console.log("💬 ConversationManager: Product chat started successfully", {
933
- conversationId: P.id,
933
+ conversationId: O.id,
934
934
  userId: t,
935
935
  productId: a.productId,
936
936
  productName: a.productName
937
- }), (r = this.chatSDK.socket) != null && r.isConnected() && this.chatSDK.socket.joinRoom(P.id), (i = this.chatSDK.events) == null || i.emit("conversation.created", { conversation: P }), P;
937
+ }), (r = this.chatSDK.socket) != null && r.isConnected() && this.chatSDK.socket.joinRoom(O.id), (i = this.chatSDK.events) == null || i.emit("conversation.created", { conversation: O }), O;
938
938
  } catch (p) {
939
939
  throw (l = this.config) != null && l.enableLogging && console.error("❌ ConversationManager: Start product chat failed", ((d = p.response) == null ? void 0 : d.data) || p.message), new Error(((m = (h = p.response) == null ? void 0 : h.data) == null ? void 0 : m.message) || "Failed to start product chat");
940
940
  }
@@ -1265,7 +1265,7 @@ class st {
1265
1265
  }
1266
1266
  }
1267
1267
  }
1268
- class nt {
1268
+ class ct {
1269
1269
  constructor(e) {
1270
1270
  this.api = null, this.config = null, this.chatSDK = e;
1271
1271
  }
@@ -1273,7 +1273,7 @@ class nt {
1273
1273
  * Initialize MessageManager with configuration
1274
1274
  */
1275
1275
  async init(e) {
1276
- this.config = e, this.api = de.create({
1276
+ this.config = e, this.api = ge.create({
1277
1277
  baseURL: e.apiBaseUrl,
1278
1278
  headers: {
1279
1279
  "Content-Type": "application/json"
@@ -1557,7 +1557,7 @@ class nt {
1557
1557
  }
1558
1558
  }
1559
1559
  }
1560
- class rt {
1560
+ class lt {
1561
1561
  constructor(e) {
1562
1562
  this.api = null, this.config = null, this.maxFileSize = 50 * 1024 * 1024, this.allowedTypes = [
1563
1563
  "image/jpeg",
@@ -1582,7 +1582,7 @@ class rt {
1582
1582
  * Initialize MediaManager with configuration
1583
1583
  */
1584
1584
  async init(e) {
1585
- this.config = e, this.api = de.create({
1585
+ this.config = e, this.api = ge.create({
1586
1586
  baseURL: e.apiBaseUrl,
1587
1587
  headers: {
1588
1588
  "Content-Type": "application/json"
@@ -1809,7 +1809,7 @@ class rt {
1809
1809
  return parseFloat((e / Math.pow(t, s)).toFixed(2)) + " " + a[s];
1810
1810
  }
1811
1811
  }
1812
- class ot {
1812
+ class dt {
1813
1813
  constructor(e) {
1814
1814
  this.config = null, this.socket = null, this.eventListeners = /* @__PURE__ */ new Map(), this.isConnected = !1, this.reconnectAttempts = 0, this.maxReconnectAttempts = 5, this.reconnectDelay = 1e3, this.heartbeatInterval = null, this.connectionTimeout = null, this.chatSDK = e;
1815
1815
  }
@@ -2007,7 +2007,7 @@ class ot {
2007
2007
  return Array.from(this.eventListeners.keys());
2008
2008
  }
2009
2009
  }
2010
- class Ue {
2010
+ class Ae {
2011
2011
  /**
2012
2012
  * Parse user data - handles standard server format only
2013
2013
  * @param data User data from server
@@ -2146,7 +2146,7 @@ class Ue {
2146
2146
  return Array.isArray(e) ? e : [];
2147
2147
  }
2148
2148
  }
2149
- class it {
2149
+ class gt {
2150
2150
  constructor(e) {
2151
2151
  this.socket = null, this.config = null, this.currentUserId = null, this.joinedRooms = /* @__PURE__ */ new Set(), this.chatSDK = e;
2152
2152
  }
@@ -2165,7 +2165,7 @@ class it {
2165
2165
  wsUrl: e.wsUrl,
2166
2166
  apiBaseUrl: e.apiBaseUrl,
2167
2167
  environment: e.environment
2168
- }), this.socket = Ye(o, {
2168
+ }), this.socket = Xe(o, {
2169
2169
  transports: ["websocket", "polling"],
2170
2170
  // Try websocket first, fallback to polling
2171
2171
  autoConnect: !1,
@@ -2213,14 +2213,14 @@ class it {
2213
2213
  (p = this.config) != null && p.enableLogging && console.error("❌ SocketManager: Connection timeout after 10 seconds"), h(new Error("Connection timeout"));
2214
2214
  }, 1e4);
2215
2215
  this.socket.connect(), this.socket.on("connect", () => {
2216
- var p, E, P;
2217
- clearTimeout(m), (p = this.config) != null && p.enableLogging && console.log("✅ SocketManager: Connected to WebSocket server successfully!"), this.socket.emit("authenticate", { userId: e, appId: (E = this.config) == null ? void 0 : E.appId }), (P = this.config) != null && P.enableLogging && console.log("🔐 SocketManager: Sent authentication for user:", e), d();
2216
+ var p, D, O;
2217
+ clearTimeout(m), (p = this.config) != null && p.enableLogging && console.log("✅ SocketManager: Connected to WebSocket server successfully!"), this.socket.emit("authenticate", { userId: e, appId: (D = this.config) == null ? void 0 : D.appId }), (O = this.config) != null && O.enableLogging && console.log("🔐 SocketManager: Sent authentication for user:", e), d();
2218
2218
  }), this.socket.on("connect_error", (p) => {
2219
- var E;
2220
- clearTimeout(m), (E = this.config) != null && E.enableLogging && console.error("❌ SocketManager: Connection failed with error:", p), h(p);
2219
+ var D;
2220
+ clearTimeout(m), (D = this.config) != null && D.enableLogging && console.error("❌ SocketManager: Connection failed with error:", p), h(p);
2221
2221
  }), this.socket.on("disconnect", (p) => {
2222
- var E;
2223
- (E = this.config) != null && E.enableLogging && console.log("🔌 SocketManager: Disconnected from server, reason:", p);
2222
+ var D;
2223
+ (D = this.config) != null && D.enableLogging && console.log("🔌 SocketManager: Disconnected from server, reason:", p);
2224
2224
  });
2225
2225
  });
2226
2226
  }
@@ -2290,7 +2290,7 @@ class it {
2290
2290
  this.socket && (this.socket.on("message_received", (e) => {
2291
2291
  var t, a, s;
2292
2292
  try {
2293
- const n = Ue.parseMessage(e);
2293
+ const n = Ae.parseMessage(e);
2294
2294
  (t = this.chatSDK.events) == null || t.emit("message.received", { message: n });
2295
2295
  } catch (n) {
2296
2296
  (a = this.config) != null && a.enableLogging && console.error("❌ SocketManager: Failed to parse received message", n), (s = this.chatSDK.events) == null || s.emit("message.received", { message: e });
@@ -2342,7 +2342,7 @@ class it {
2342
2342
  }), this.socket.on("online-users", (e) => {
2343
2343
  var t, a, s, n;
2344
2344
  try {
2345
- const o = Ue.parseUsers(e);
2345
+ const o = Ae.parseUsers(e);
2346
2346
  (t = this.config) != null && t.enableLogging && console.log("🌐 SocketManager: Online users update", { count: o.length }), (a = this.chatSDK.events) == null || a.emit("users.online", { users: o });
2347
2347
  } catch (o) {
2348
2348
  (s = this.config) != null && s.enableLogging && console.error("❌ SocketManager: Failed to parse online users", o), (n = this.chatSDK.events) == null || n.emit("users.online", { users: e });
@@ -2418,15 +2418,15 @@ class it {
2418
2418
  this.socket && (this.socket.off(e, t), (a = this.config) != null && a.enableLogging && console.log("🔇 SocketManager: Stopped listening to event:", e));
2419
2419
  }
2420
2420
  }
2421
- const ie = class ie {
2421
+ const ce = class ce {
2422
2422
  constructor() {
2423
- this.config = null, this.isInitialized = !1, this.currentUser = null, this.auth = new et(this), this.chatUsers = new tt(this), this.users = new at(this), this.conversations = new st(this), this.messages = new nt(this), this.media = new rt(this), this.events = new ot(this), this.socket = new it(this);
2423
+ this.config = null, this.isInitialized = !1, this.currentUser = null, this.auth = new nt(this), this.chatUsers = new rt(this), this.users = new ot(this), this.conversations = new it(this), this.messages = new ct(this), this.media = new lt(this), this.events = new dt(this), this.socket = new gt(this);
2424
2424
  }
2425
2425
  /**
2426
2426
  * Get singleton instance of ChatSDK
2427
2427
  */
2428
2428
  static getInstance() {
2429
- return ie.instance || (ie.instance = new ie()), ie.instance;
2429
+ return ce.instance || (ce.instance = new ce()), ce.instance;
2430
2430
  }
2431
2431
  /**
2432
2432
  * Initialize ChatSDK with configuration
@@ -2545,29 +2545,29 @@ const ie = class ie {
2545
2545
  throw new Error("ChatSDK not initialized. Call ChatSDK.init() first.");
2546
2546
  }
2547
2547
  };
2548
- ie.instance = null;
2549
- let R = ie;
2548
+ ce.instance = null;
2549
+ let R = ce;
2550
2550
  R.getInstance();
2551
- const ct = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2551
+ const ht = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2552
2552
  __proto__: null,
2553
2553
  ChatSDK: R
2554
2554
  }, Symbol.toStringTag, { value: "Module" }));
2555
- let lt = { data: "" }, dt = (c) => typeof window == "object" ? ((c ? c.querySelector("#_goober") : window._goober) || Object.assign((c || document.head).appendChild(document.createElement("style")), { innerHTML: " ", id: "_goober" })).firstChild : c || lt, gt = /(?:([\u0080-\uFFFF\w-%@]+) *:? *([^{;]+?);|([^;}{]*?) *{)|(}\s*)/g, ht = /\/\*[^]*?\*\/| +/g, Fe = /\n+/g, se = (c, e) => {
2555
+ let ut = { data: "" }, mt = (c) => typeof window == "object" ? ((c ? c.querySelector("#_goober") : window._goober) || Object.assign((c || document.head).appendChild(document.createElement("style")), { innerHTML: " ", id: "_goober" })).firstChild : c || ut, ft = /(?:([\u0080-\uFFFF\w-%@]+) *:? *([^{;]+?);|([^;}{]*?) *{)|(}\s*)/g, pt = /\/\*[^]*?\*\/| +/g, xe = /\n+/g, se = (c, e) => {
2556
2556
  let t = "", a = "", s = "";
2557
2557
  for (let n in c) {
2558
2558
  let o = c[n];
2559
2559
  n[0] == "@" ? n[1] == "i" ? t = n + " " + o + ";" : a += n[1] == "f" ? se(o, n) : n + "{" + se(o, n[1] == "k" ? "" : e) + "}" : typeof o == "object" ? a += se(o, e ? e.replace(/([^,])+/g, (r) => n.replace(/([^,]*:\S+\([^)]*\))|([^,])+/g, (i) => /&/.test(i) ? i.replace(/&/g, r) : r ? r + " " + i : i)) : n) : o != null && (n = /^--/.test(n) ? n : n.replace(/[A-Z]/g, "-$&").toLowerCase(), s += se.p ? se.p(n, o) : n + ":" + o + ";");
2560
2560
  }
2561
2561
  return t + (e && s ? e + "{" + s + "}" : s) + a;
2562
- }, X = {}, xe = (c) => {
2562
+ }, X = {}, Ne = (c) => {
2563
2563
  if (typeof c == "object") {
2564
2564
  let e = "";
2565
- for (let t in c) e += t + xe(c[t]);
2565
+ for (let t in c) e += t + Ne(c[t]);
2566
2566
  return e;
2567
2567
  }
2568
2568
  return c;
2569
- }, ut = (c, e, t, a, s) => {
2570
- let n = xe(c), o = X[n] || (X[n] = ((i) => {
2569
+ }, wt = (c, e, t, a, s) => {
2570
+ let n = Ne(c), o = X[n] || (X[n] = ((i) => {
2571
2571
  let l = 0, d = 11;
2572
2572
  for (; l < i.length; ) d = 101 * d + i.charCodeAt(l++) >>> 0;
2573
2573
  return "go" + d;
@@ -2575,7 +2575,7 @@ let lt = { data: "" }, dt = (c) => typeof window == "object" ? ((c ? c.querySele
2575
2575
  if (!X[o]) {
2576
2576
  let i = n !== c ? c : ((l) => {
2577
2577
  let d, h, m = [{}];
2578
- for (; d = gt.exec(l.replace(ht, "")); ) d[4] ? m.shift() : d[3] ? (h = d[3].replace(Fe, " ").trim(), m.unshift(m[0][h] = m[0][h] || {})) : m[0][d[1]] = d[2].replace(Fe, " ").trim();
2578
+ for (; d = ft.exec(l.replace(pt, "")); ) d[4] ? m.shift() : d[3] ? (h = d[3].replace(xe, " ").trim(), m.unshift(m[0][h] = m[0][h] || {})) : m[0][d[1]] = d[2].replace(xe, " ").trim();
2579
2579
  return m[0];
2580
2580
  })(c);
2581
2581
  X[o] = se(s ? { ["@keyframes " + o]: i } : i, t ? "" : "." + o);
@@ -2584,7 +2584,7 @@ let lt = { data: "" }, dt = (c) => typeof window == "object" ? ((c ? c.querySele
2584
2584
  return t && (X.g = X[o]), ((i, l, d, h) => {
2585
2585
  h ? l.data = l.data.replace(h, i) : l.data.indexOf(i) === -1 && (l.data = d ? i + l.data : l.data + i);
2586
2586
  })(X[o], e, a, r), o;
2587
- }, mt = (c, e, t) => c.reduce((a, s, n) => {
2587
+ }, kt = (c, e, t) => c.reduce((a, s, n) => {
2588
2588
  let o = e[n];
2589
2589
  if (o && o.call) {
2590
2590
  let r = o(t), i = r && r.props && r.props.className || /^go/.test(r) && r;
@@ -2592,33 +2592,33 @@ let lt = { data: "" }, dt = (c) => typeof window == "object" ? ((c ? c.querySele
2592
2592
  }
2593
2593
  return a + s + (o ?? "");
2594
2594
  }, "");
2595
- function me(c) {
2595
+ function pe(c) {
2596
2596
  let e = this || {}, t = c.call ? c(e.p) : c;
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);
2597
+ return wt(t.unshift ? t.raw ? kt(t, [].slice.call(arguments, 1), e.p) : t.reduce((a, s) => Object.assign(a, s && s.call ? s(e.p) : s), {}) : t, mt(e.target), e.g, e.o, e.k);
2598
2598
  }
2599
- let Ne, ke, ve;
2600
- me.bind({ g: 1 });
2601
- let ee = me.bind({ k: 1 });
2602
- function ft(c, e, t, a) {
2603
- se.p = e, Ne = c, ke = t, ve = a;
2599
+ let Ke, be, Me;
2600
+ pe.bind({ g: 1 });
2601
+ let ee = pe.bind({ k: 1 });
2602
+ function yt(c, e, t, a) {
2603
+ se.p = e, Ke = c, be = t, Me = a;
2604
2604
  }
2605
- function ne(c, e) {
2605
+ function re(c, e) {
2606
2606
  let t = this || {};
2607
2607
  return function() {
2608
2608
  let a = arguments;
2609
2609
  function s(n, o) {
2610
2610
  let r = Object.assign({}, n), i = r.className || s.className;
2611
- t.p = Object.assign({ theme: ke && ke() }, r), t.o = / *go\d+/.test(i), r.className = me.apply(t, a) + (i ? " " + i : "");
2611
+ t.p = Object.assign({ theme: be && be() }, r), t.o = / *go\d+/.test(i), r.className = pe.apply(t, a) + (i ? " " + i : "");
2612
2612
  let l = c;
2613
- return c[0] && (l = r.as || c, delete r.as), ve && l[0] && ve(r), Ne(l, r);
2613
+ return c[0] && (l = r.as || c, delete r.as), Me && l[0] && Me(r), Ke(l, r);
2614
2614
  }
2615
2615
  return s;
2616
2616
  };
2617
2617
  }
2618
- var pt = (c) => typeof c == "function", ye = (c, e) => pt(c) ? c(e) : c, wt = /* @__PURE__ */ (() => {
2618
+ var vt = (c) => typeof c == "function", Ce = (c, e) => vt(c) ? c(e) : c, bt = /* @__PURE__ */ (() => {
2619
2619
  let c = 0;
2620
2620
  return () => (++c).toString();
2621
- })(), kt = /* @__PURE__ */ (() => {
2621
+ })(), Mt = /* @__PURE__ */ (() => {
2622
2622
  let c;
2623
2623
  return () => {
2624
2624
  if (c === void 0 && typeof window < "u") {
@@ -2627,15 +2627,15 @@ var pt = (c) => typeof c == "function", ye = (c, e) => pt(c) ? c(e) : c, wt = /*
2627
2627
  }
2628
2628
  return c;
2629
2629
  };
2630
- })(), vt = 20, Te = (c, e) => {
2630
+ })(), Ct = 20, ze = (c, e) => {
2631
2631
  switch (e.type) {
2632
2632
  case 0:
2633
- return { ...c, toasts: [e.toast, ...c.toasts].slice(0, vt) };
2633
+ return { ...c, toasts: [e.toast, ...c.toasts].slice(0, Ct) };
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:
2637
2637
  let { toast: t } = e;
2638
- return Te(c, { type: c.toasts.find((n) => n.id === t.id) ? 1 : 0, toast: t });
2638
+ return ze(c, { type: c.toasts.find((n) => n.id === t.id) ? 1 : 0, toast: t });
2639
2639
  case 3:
2640
2640
  let { toastId: a } = e;
2641
2641
  return { ...c, toasts: c.toasts.map((n) => n.id === a || a === void 0 ? { ...n, dismissed: !0, visible: !1 } : n) };
@@ -2647,33 +2647,33 @@ var pt = (c) => typeof c == "function", ye = (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
- }, yt = [], we = { toasts: [], pausedAt: void 0 }, Me = (c) => {
2651
- we = Te(we, c), yt.forEach((e) => {
2652
- e(we);
2650
+ }, _t = [], ve = { toasts: [], pausedAt: void 0 }, _e = (c) => {
2651
+ ve = ze(ve, c), _t.forEach((e) => {
2652
+ e(ve);
2653
2653
  });
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) => {
2655
- let a = bt(e, c, t);
2656
- return Me({ type: 2, toast: a }), a.id;
2657
- }, V = (c, e) => ue("blank")(c, e);
2658
- V.error = ue("error");
2659
- V.success = ue("success");
2660
- V.loading = ue("loading");
2661
- V.custom = ue("custom");
2662
- V.dismiss = (c) => {
2663
- Me({ type: 3, toastId: c });
2654
+ }, St = (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) || bt() }), me = (c) => (e, t) => {
2655
+ let a = St(e, c, t);
2656
+ return _e({ type: 2, toast: a }), a.id;
2657
+ }, G = (c, e) => me("blank")(c, e);
2658
+ G.error = me("error");
2659
+ G.success = me("success");
2660
+ G.loading = me("loading");
2661
+ G.custom = me("custom");
2662
+ G.dismiss = (c) => {
2663
+ _e({ type: 3, toastId: c });
2664
2664
  };
2665
- V.remove = (c) => Me({ type: 4, toastId: c });
2666
- V.promise = (c, e, t) => {
2667
- let a = V.loading(e.loading, { ...t, ...t == null ? void 0 : t.loading });
2665
+ G.remove = (c) => _e({ type: 4, toastId: c });
2666
+ G.promise = (c, e, t) => {
2667
+ let a = G.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 ? ye(e.success, s) : void 0;
2670
- return n ? V.success(n, { id: a, ...t, ...t == null ? void 0 : t.success }) : V.dismiss(a), s;
2669
+ let n = e.success ? Ce(e.success, s) : void 0;
2670
+ return n ? G.success(n, { id: a, ...t, ...t == null ? void 0 : t.success }) : G.dismiss(a), s;
2671
2671
  }).catch((s) => {
2672
- let n = e.error ? ye(e.error, s) : void 0;
2673
- n ? V.error(n, { id: a, ...t, ...t == null ? void 0 : t.error }) : V.dismiss(a);
2672
+ let n = e.error ? Ce(e.error, s) : void 0;
2673
+ n ? G.error(n, { id: a, ...t, ...t == null ? void 0 : t.error }) : G.dismiss(a);
2674
2674
  }), c;
2675
2675
  };
2676
- var Mt = ee`
2676
+ var Lt = ee`
2677
2677
  from {
2678
2678
  transform: scale(0) rotate(45deg);
2679
2679
  opacity: 0;
@@ -2681,7 +2681,7 @@ from {
2681
2681
  to {
2682
2682
  transform: scale(1) rotate(45deg);
2683
2683
  opacity: 1;
2684
- }`, Ct = ee`
2684
+ }`, Dt = ee`
2685
2685
  from {
2686
2686
  transform: scale(0);
2687
2687
  opacity: 0;
@@ -2689,7 +2689,7 @@ from {
2689
2689
  to {
2690
2690
  transform: scale(1);
2691
2691
  opacity: 1;
2692
- }`, _t = ee`
2692
+ }`, Et = ee`
2693
2693
  from {
2694
2694
  transform: scale(0) rotate(90deg);
2695
2695
  opacity: 0;
@@ -2697,7 +2697,7 @@ from {
2697
2697
  to {
2698
2698
  transform: scale(1) rotate(90deg);
2699
2699
  opacity: 1;
2700
- }`, St = ne("div")`
2700
+ }`, Ut = re("div")`
2701
2701
  width: 20px;
2702
2702
  opacity: 0;
2703
2703
  height: 20px;
@@ -2706,14 +2706,14 @@ to {
2706
2706
  position: relative;
2707
2707
  transform: rotate(45deg);
2708
2708
 
2709
- animation: ${Mt} 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275)
2709
+ animation: ${Lt} 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275)
2710
2710
  forwards;
2711
2711
  animation-delay: 100ms;
2712
2712
 
2713
2713
  &:after,
2714
2714
  &:before {
2715
2715
  content: '';
2716
- animation: ${Ct} 0.15s ease-out forwards;
2716
+ animation: ${Dt} 0.15s ease-out forwards;
2717
2717
  animation-delay: 150ms;
2718
2718
  position: absolute;
2719
2719
  border-radius: 3px;
@@ -2726,18 +2726,18 @@ to {
2726
2726
  }
2727
2727
 
2728
2728
  &:before {
2729
- animation: ${_t} 0.15s ease-out forwards;
2729
+ animation: ${Et} 0.15s ease-out forwards;
2730
2730
  animation-delay: 180ms;
2731
2731
  transform: rotate(90deg);
2732
2732
  }
2733
- `, Lt = ee`
2733
+ `, Ft = ee`
2734
2734
  from {
2735
2735
  transform: rotate(0deg);
2736
2736
  }
2737
2737
  to {
2738
2738
  transform: rotate(360deg);
2739
2739
  }
2740
- `, Et = ne("div")`
2740
+ `, It = re("div")`
2741
2741
  width: 12px;
2742
2742
  height: 12px;
2743
2743
  box-sizing: border-box;
@@ -2745,8 +2745,8 @@ to {
2745
2745
  border-radius: 100%;
2746
2746
  border-color: ${(c) => c.secondary || "#e0e0e0"};
2747
2747
  border-right-color: ${(c) => c.primary || "#616161"};
2748
- animation: ${Lt} 1s linear infinite;
2749
- `, Dt = ee`
2748
+ animation: ${Ft} 1s linear infinite;
2749
+ `, At = ee`
2750
2750
  from {
2751
2751
  transform: scale(0) rotate(45deg);
2752
2752
  opacity: 0;
@@ -2754,7 +2754,7 @@ from {
2754
2754
  to {
2755
2755
  transform: scale(1) rotate(45deg);
2756
2756
  opacity: 1;
2757
- }`, Ut = ee`
2757
+ }`, xt = ee`
2758
2758
  0% {
2759
2759
  height: 0;
2760
2760
  width: 0;
@@ -2768,7 +2768,7 @@ to {
2768
2768
  100% {
2769
2769
  opacity: 1;
2770
2770
  height: 10px;
2771
- }`, Ft = ne("div")`
2771
+ }`, Tt = re("div")`
2772
2772
  width: 20px;
2773
2773
  opacity: 0;
2774
2774
  height: 20px;
@@ -2777,13 +2777,13 @@ to {
2777
2777
  position: relative;
2778
2778
  transform: rotate(45deg);
2779
2779
 
2780
- animation: ${Dt} 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275)
2780
+ animation: ${At} 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275)
2781
2781
  forwards;
2782
2782
  animation-delay: 100ms;
2783
2783
  &:after {
2784
2784
  content: '';
2785
2785
  box-sizing: border-box;
2786
- animation: ${Ut} 0.2s ease-out forwards;
2786
+ animation: ${xt} 0.2s ease-out forwards;
2787
2787
  opacity: 0;
2788
2788
  animation-delay: 200ms;
2789
2789
  position: absolute;
@@ -2795,16 +2795,16 @@ to {
2795
2795
  height: 10px;
2796
2796
  width: 6px;
2797
2797
  }
2798
- `, It = ne("div")`
2798
+ `, Nt = re("div")`
2799
2799
  position: absolute;
2800
- `, At = ne("div")`
2800
+ `, Kt = re("div")`
2801
2801
  position: relative;
2802
2802
  display: flex;
2803
2803
  justify-content: center;
2804
2804
  align-items: center;
2805
2805
  min-width: 20px;
2806
2806
  min-height: 20px;
2807
- `, xt = ee`
2807
+ `, zt = ee`
2808
2808
  from {
2809
2809
  transform: scale(0.6);
2810
2810
  opacity: 0.4;
@@ -2812,23 +2812,23 @@ from {
2812
2812
  to {
2813
2813
  transform: scale(1);
2814
2814
  opacity: 1;
2815
- }`, Nt = ne("div")`
2815
+ }`, Rt = re("div")`
2816
2816
  position: relative;
2817
2817
  transform: scale(0.6);
2818
2818
  opacity: 0.4;
2819
2819
  min-width: 20px;
2820
- animation: ${xt} 0.3s 0.12s cubic-bezier(0.175, 0.885, 0.32, 1.275)
2820
+ animation: ${zt} 0.3s 0.12s cubic-bezier(0.175, 0.885, 0.32, 1.275)
2821
2821
  forwards;
2822
- `, Tt = ({ toast: c }) => {
2822
+ `, Bt = ({ toast: c }) => {
2823
2823
  let { icon: e, type: t, iconTheme: a } = c;
2824
- return e !== void 0 ? typeof e == "string" ? q.createElement(Nt, null, e) : e : t === "blank" ? null : q.createElement(At, null, q.createElement(Et, { ...a }), t !== "loading" && q.createElement(It, null, t === "error" ? q.createElement(St, { ...a }) : q.createElement(Ft, { ...a })));
2825
- }, Kt = (c) => `
2824
+ return e !== void 0 ? typeof e == "string" ? V.createElement(Rt, null, e) : e : t === "blank" ? null : V.createElement(Kt, null, V.createElement(It, { ...a }), t !== "loading" && V.createElement(Nt, null, t === "error" ? V.createElement(Ut, { ...a }) : V.createElement(Tt, { ...a })));
2825
+ }, $t = (c) => `
2826
2826
  0% {transform: translate3d(0,${c * -200}%,0) scale(.6); opacity:.5;}
2827
2827
  100% {transform: translate3d(0,0,0) scale(1); opacity:1;}
2828
- `, zt = (c) => `
2828
+ `, Pt = (c) => `
2829
2829
  0% {transform: translate3d(0,0,-1px) scale(1); opacity:1;}
2830
2830
  100% {transform: translate3d(0,${c * -150}%,-1px) scale(.6); opacity:0;}
2831
- `, Rt = "0%{opacity:0;} 100%{opacity:1;}", Bt = "0%{opacity:1;} 100%{opacity:0;}", $t = ne("div")`
2831
+ `, Ot = "0%{opacity:0;} 100%{opacity:1;}", jt = "0%{opacity:1;} 100%{opacity:0;}", Wt = re("div")`
2832
2832
  display: flex;
2833
2833
  align-items: center;
2834
2834
  background: #fff;
@@ -2840,30 +2840,30 @@ to {
2840
2840
  pointer-events: auto;
2841
2841
  padding: 8px 10px;
2842
2842
  border-radius: 8px;
2843
- `, Pt = ne("div")`
2843
+ `, qt = re("div")`
2844
2844
  display: flex;
2845
2845
  justify-content: center;
2846
2846
  margin: 4px 10px;
2847
2847
  color: inherit;
2848
2848
  flex: 1 1 auto;
2849
2849
  white-space: pre-line;
2850
- `, Ot = (c, e) => {
2851
- let t = c.includes("top") ? 1 : -1, [a, s] = kt() ? [Rt, Bt] : [Kt(t), zt(t)];
2850
+ `, Vt = (c, e) => {
2851
+ let t = c.includes("top") ? 1 : -1, [a, s] = Mt() ? [Ot, jt] : [$t(t), Pt(t)];
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
- 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 }, ye(c.message, c));
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));
2854
+ V.memo(({ toast: c, position: e, style: t, children: a }) => {
2855
+ let s = c.height ? Vt(c.position || e || "top-center", c.visible) : { opacity: 0 }, n = V.createElement(Bt, { toast: c }), o = V.createElement(qt, { ...c.ariaProps }, Ce(c.message, c));
2856
+ return V.createElement(Wt, { className: c.className, style: { ...s, ...t, ...c.style } }, typeof a == "function" ? a({ icon: n, message: o }) : V.createElement(V.Fragment, null, n, o));
2857
2857
  });
2858
- ft(q.createElement);
2859
- me`
2858
+ yt(V.createElement);
2859
+ pe`
2860
2860
  z-index: 9999;
2861
2861
  > * {
2862
2862
  pointer-events: auto;
2863
2863
  }
2864
2864
  `;
2865
- var z = V;
2866
- const jt = {
2865
+ var z = G;
2866
+ const Gt = {
2867
2867
  // General
2868
2868
  send: "Send",
2869
2869
  // Conversations
@@ -2971,7 +2971,7 @@ const jt = {
2971
2971
  chat_with_owner: "Chat with Owner",
2972
2972
  your_product: "Your Product",
2973
2973
  owner_label: "Owner:"
2974
- }, Wt = {
2974
+ }, Ht = {
2975
2975
  // General
2976
2976
  send: "إرسال",
2977
2977
  // Conversations
@@ -3079,15 +3079,31 @@ const jt = {
3079
3079
  chat_with_owner: "الدردشة مع المالك",
3080
3080
  your_product: "منتجك",
3081
3081
  owner_label: "المالك:"
3082
- }, be = {
3083
- en: jt,
3084
- ar: Wt
3082
+ }, Re = "chatsdk-root";
3083
+ let ue = null;
3084
+ const na = (c) => {
3085
+ ue = c;
3086
+ }, ra = () => {
3087
+ if (ue && ue.isConnected)
3088
+ return ue;
3089
+ const c = document.querySelector(`.${Re}`);
3090
+ return c ? (ue = c, c) : null;
3091
+ }, Se = (c) => {
3092
+ document.querySelectorAll(`.${Re}`).forEach(c);
3093
+ }, fe = {
3094
+ en: Gt,
3095
+ ar: Ht
3085
3096
  };
3086
- let he = "en";
3087
- const Ie = (c) => {
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
- }, ea = () => he, qt = () => he === "ar", w = (c, e) => {
3090
- let t = be[he][c] || be.en[c] || c;
3097
+ let le = "en", Te = !1;
3098
+ const we = () => {
3099
+ const c = le, e = Yt() ? "rtl" : "ltr";
3100
+ Se((t) => {
3101
+ t.setAttribute("lang", c), t.setAttribute("dir", e);
3102
+ });
3103
+ }, oa = (c) => {
3104
+ fe[c] ? (le = c, localStorage.setItem("chatSDK_language", c)) : (console.warn(`Locale "${c}" not found, falling back to "en".`), le = "en"), we();
3105
+ }, ia = () => le, Yt = () => le === "ar", w = (c, e) => {
3106
+ let t = fe[le][c] || fe.en[c] || c;
3091
3107
  if (e)
3092
3108
  for (const a in e)
3093
3109
  t = t.replace(
@@ -3095,20 +3111,23 @@ const Ie = (c) => {
3095
3111
  String(e[a])
3096
3112
  );
3097
3113
  return t;
3098
- }, Ae = localStorage.getItem("chatSDK_language");
3099
- Ie(Ae || "en");
3100
- const Vt = ({ conversation: c, currentUser: e, onClose: t, onBack: a }) => {
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), [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(() => {
3114
+ }, Be = () => {
3115
+ if (Te) return;
3116
+ Te = !0;
3117
+ const c = localStorage.getItem("chatSDK_language");
3118
+ c && fe[c] && (le = c), we();
3119
+ }, Jt = ({ conversation: c, currentUser: e, onClose: t, onBack: a }) => {
3120
+ var Ee;
3121
+ const [s, n] = N([]), [o, r] = N(""), [i, l] = N(!1), [d, h] = N(!1), [m, p] = N({}), [D, O] = N(!1), [Le, he] = N(!0), [y, C] = N(1), [j, H] = N(null), [B, J] = N(!1), [E, F] = N(!1), [T, x] = N(!1), [K, W] = N(null), [te, ae] = N(!1), Q = ne(null), de = ne(null), $ = ne(null), Y = ne(null), oe = 20, ie = Ie(() => {
3103
3122
  if (!c || !e) return null;
3104
3123
  const g = c.participants || [];
3105
3124
  if (g.length === 0) return null;
3106
3125
  const f = e.id || e.userId, b = e.externalUserId || e.external_user_id;
3107
- return g.find((y) => {
3108
- const S = y.id || y.userId, k = y.externalUserId || y.external_user_id;
3126
+ return g.find((v) => {
3127
+ const S = v.id || v.userId, k = v.externalUserId || v.external_user_id;
3109
3128
  return !(f && S && S === f || b && k && k === b) && (S || k);
3110
3129
  }) || null;
3111
- }, [c, e]), U = oe(), W = De(() => {
3130
+ }, [c, e]), U = ie(), q = Ie(() => {
3112
3131
  if (!c) return { userName: w("conversations_title"), productName: null, productImage: null, productMetadata: null };
3113
3132
  const g = U && (U.name || U.userName || U.displayName || U.externalUserId) || w("unknown_user"), f = c.productContext || c.product_context;
3114
3133
  return f ? {
@@ -3119,9 +3138,9 @@ const Vt = ({ conversation: c, currentUser: e, onClose: t, onBack: a }) => {
3119
3138
  productMetadata: f.productMetadata || f.product_metadata
3120
3139
  } : { userName: g, productName: null, productImage: null, productMetadata: null };
3121
3140
  }, [c, U])();
3122
- Y(() => (c && (x(!1), qe(1, !1), ze(), R.getInstance().chatUsers.startViewingConversation(c.id)), () => {
3123
- c && (Re(), R.getInstance().chatUsers.stopViewingConversation(c.id));
3124
- }), [c]), Y(() => {
3141
+ P(() => (c && (x(!1), Ye(1, !1), Pe(), R.getInstance().chatUsers.startViewingConversation(c.id)), () => {
3142
+ c && (Oe(), R.getInstance().chatUsers.stopViewingConversation(c.id));
3143
+ }), [c]), P(() => {
3125
3144
  const g = R.getInstance(), f = (k) => {
3126
3145
  const _ = k.message;
3127
3146
  _.roomId === (c == null ? void 0 : c.id) && n((I) => I.some((L) => L.id === _.id) ? I : (_.senderId !== e.id && g.chatUsers.markMessageRead(_.id).catch((L) => {
@@ -3143,7 +3162,7 @@ const Vt = ({ conversation: c, currentUser: e, onClose: t, onBack: a }) => {
3143
3162
  !k.messageId || k.roomId !== (c == null ? void 0 : c.id) || n((_) => _.map(
3144
3163
  (I) => I.id === k.messageId && I.senderId === e.id ? { ...I, isRead: k.isRead } : I
3145
3164
  ));
3146
- }, y = (k) => {
3165
+ }, v = (k) => {
3147
3166
  if (k.roomId !== (c == null ? void 0 : c.id)) return;
3148
3167
  const _ = e == null ? void 0 : e.id;
3149
3168
  if (!k.messageIds || k.messageIds.length === 0) {
@@ -3159,69 +3178,69 @@ const Vt = ({ conversation: c, currentUser: e, onClose: t, onBack: a }) => {
3159
3178
  ...c.metadata || {},
3160
3179
  blockedUsers: I
3161
3180
  };
3162
- const A = e.id || e.userId, L = oe(), Z = L ? L.id || L.userId || L.externalUserId || L.external_user_id : null;
3181
+ const A = e.id || e.userId, L = ie(), Z = L ? L.id || L.userId || L.externalUserId || L.external_user_id : null;
3163
3182
  J(I[A] === 1), F(Z ? I[Z] === 1 : !1);
3164
3183
  };
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);
3184
+ 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), () => {
3185
+ 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);
3167
3186
  };
3168
- }, [c == null ? void 0 : c.id, e == null ? void 0 : e.id]), Y(() => {
3187
+ }, [c == null ? void 0 : c.id, e == null ? void 0 : e.id]), P(() => {
3169
3188
  if (!c || !e) {
3170
- J(!1), F(!1), G(null);
3189
+ J(!1), F(!1), H(null);
3171
3190
  return;
3172
3191
  }
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
- J(f[b] === 1), F(S ? f[S] === 1 : !1), G({
3192
+ const f = (c.metadata || {}).blockedUsers || {}, b = e.id || e.userId, v = ie(), S = v ? v.id || v.userId || v.externalUserId || v.external_user_id : null;
3193
+ J(f[b] === 1), F(S ? f[S] === 1 : !1), H({
3175
3194
  chatId: c.id,
3176
3195
  currentUserId: b,
3177
3196
  isBlockedByOther: f[b] === 1,
3178
3197
  usersBlockedByMe: Object.keys(f).filter((k) => f[k] === 1),
3179
3198
  blockedUsers: f
3180
3199
  });
3181
- }, [c == null ? void 0 : c.id, JSON.stringify(c == null ? void 0 : c.metadata), e == null ? void 0 : e.id]), Y(() => {
3182
- Be();
3183
- }, [s]), Y(() => {
3200
+ }, [c == null ? void 0 : c.id, JSON.stringify(c == null ? void 0 : c.metadata), e == null ? void 0 : e.id]), P(() => {
3201
+ je();
3202
+ }, [s]), P(() => {
3184
3203
  const g = (f) => {
3185
3204
  f.target.closest(".chat-options-wrapper") || x(!1);
3186
3205
  };
3187
3206
  return document.addEventListener("click", g), () => {
3188
- document.removeEventListener("click", g), H.current && clearTimeout(H.current);
3207
+ document.removeEventListener("click", g), Y.current && clearTimeout(Y.current);
3189
3208
  };
3190
3209
  }, []);
3191
- const ze = () => {
3210
+ const Pe = () => {
3192
3211
  c && R.getInstance().socket.joinRoom(c.id);
3193
- }, Re = () => {
3212
+ }, Oe = () => {
3194
3213
  c && R.getInstance().socket.leaveRoom(c.id);
3195
- }, Be = () => {
3214
+ }, je = () => {
3196
3215
  var g;
3197
3216
  (g = Q.current) == null || g.scrollIntoView({ behavior: "smooth" });
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(), 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));
3217
+ }, We = (g) => new Date(g).toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" }), ye = (g) => {
3218
+ 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));
3200
3219
  if (k === 0) return "Today";
3201
3220
  if (k === 1) return "Yesterday";
3202
3221
  const _ = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], I = f.getDate().toString().padStart(2, "0"), A = (f.getMonth() + 1).toString().padStart(2, "0");
3203
3222
  return k < 7 ? `${_[f.getDay()]}, ${I}/${A}` : `${I}/${A}/${f.getFullYear()}`;
3204
- }, Pe = (g, f) => {
3223
+ }, qe = (g, f) => {
3205
3224
  if (f === 0) return !0;
3206
- const b = s[f - 1], y = new Date(b.timestamp).toDateString(), S = new Date(g.timestamp).toDateString();
3207
- return y !== S;
3208
- }, Oe = (g) => g ? g.includes("pdf") ? "📄" : g.includes("word") ? "📝" : g.includes("excel") ? "📊" : g.includes("audio") ? "🎵" : g.includes("video") ? "🎥" : "📎" : "📎", je = () => {
3225
+ const b = s[f - 1], v = new Date(b.timestamp).toDateString(), S = new Date(g.timestamp).toDateString();
3226
+ return v !== S;
3227
+ }, Ve = (g) => g ? g.includes("pdf") ? "📄" : g.includes("word") ? "📝" : g.includes("excel") ? "📊" : g.includes("audio") ? "🎵" : g.includes("video") ? "🎥" : "📎" : "📎", Ge = () => {
3209
3228
  if (!$.current) return;
3210
3229
  const g = $.current, f = g.querySelectorAll(".date-divider[data-date]");
3211
3230
  if (f.length === 0) return;
3212
3231
  let b = null;
3213
- const y = g.getBoundingClientRect().top;
3232
+ const v = g.getBoundingClientRect().top;
3214
3233
  for (let S = f.length - 1; S >= 0; S--) {
3215
3234
  const k = f[S];
3216
- if (k.getBoundingClientRect().top <= y + 50) {
3235
+ if (k.getBoundingClientRect().top <= v + 50) {
3217
3236
  b = k.getAttribute("data-date");
3218
3237
  break;
3219
3238
  }
3220
3239
  }
3221
- !b && s.length > 0 && (b = pe(s[0].timestamp)), b && (j(b), ae(!0), H.current && clearTimeout(H.current), H.current = setTimeout(() => {
3240
+ !b && s.length > 0 && (b = ye(s[0].timestamp)), b && (W(b), ae(!0), Y.current && clearTimeout(Y.current), Y.current = setTimeout(() => {
3222
3241
  ae(!1);
3223
3242
  }, 2e3));
3224
- }, We = () => {
3243
+ }, He = () => {
3225
3244
  if (!U) return;
3226
3245
  const g = U, f = g.phone || g.phoneNumber || g.mobile || g.externalUserId || "";
3227
3246
  if (!f) {
@@ -3231,28 +3250,28 @@ const Vt = ({ conversation: c, currentUser: e, onClose: t, onBack: a }) => {
3231
3250
  /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ? window.location.href = `tel:${f}` : navigator.clipboard.writeText(f).then(() => {
3232
3251
  z.success(w("number_copied") || `Phone number copied: ${f}`);
3233
3252
  }).catch(() => {
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}`);
3253
+ const v = document.createElement("textarea");
3254
+ 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}`);
3236
3255
  });
3237
- }, qe = async (g = 1, f = !1) => {
3256
+ }, Ye = async (g = 1, f = !1) => {
3238
3257
  if (c) {
3239
- g === 1 ? (l(!0), n([]), C(1), ge(!0)) : P(!0);
3258
+ g === 1 ? (l(!0), n([]), C(1), he(!0)) : O(!0);
3240
3259
  try {
3241
- const y = await R.getInstance().messages.getMessages({
3260
+ const v = await R.getInstance().messages.getMessages({
3242
3261
  conversationId: c.id,
3243
- limit: re,
3244
- offset: (g - 1) * re
3245
- }), S = y.sort(
3262
+ limit: oe,
3263
+ offset: (g - 1) * oe
3264
+ }), S = v.sort(
3246
3265
  (k, _) => new Date(k.timestamp).getTime() - new Date(_.timestamp).getTime()
3247
3266
  );
3248
- f && g > 1 ? n((k) => [...S, ...k]) : n(S), ge(y.length === re), C(g);
3267
+ f && g > 1 ? n((k) => [...S, ...k]) : n(S), he(v.length === oe), C(g);
3249
3268
  } catch {
3250
3269
  z.error(w("error_load_messages"));
3251
3270
  } finally {
3252
- l(!1), P(!1);
3271
+ l(!1), O(!1);
3253
3272
  }
3254
3273
  }
3255
- }, Ve = async (g) => {
3274
+ }, Je = async (g) => {
3256
3275
  if (g.preventDefault(), !c || !o.trim() || B) {
3257
3276
  B && z.error(w("you_are_blocked"));
3258
3277
  return;
@@ -3264,7 +3283,7 @@ const Vt = ({ conversation: c, currentUser: e, onClose: t, onBack: a }) => {
3264
3283
  } catch {
3265
3284
  r(f), z.error(w("error_send_message"));
3266
3285
  }
3267
- }, Ge = async (g) => {
3286
+ }, Qe = async (g) => {
3268
3287
  if (!c) return;
3269
3288
  const f = `temp_${Date.now()}`, b = {
3270
3289
  id: f,
@@ -3286,10 +3305,10 @@ const Vt = ({ conversation: c, currentUser: e, onClose: t, onBack: a }) => {
3286
3305
  mimeType: g.type
3287
3306
  }
3288
3307
  };
3289
- n((y) => [...y, b]), p((y) => ({ ...y, [f]: 0 }));
3308
+ n((v) => [...v, b]), p((v) => ({ ...v, [f]: 0 }));
3290
3309
  try {
3291
3310
  h(!0);
3292
- const y = R.getInstance(), S = y.media.getFileTypeCategory(g.type), k = await y.media.uploadMedia({
3311
+ const v = R.getInstance(), S = v.media.getFileTypeCategory(g.type), k = await v.media.uploadMedia({
3293
3312
  file: g,
3294
3313
  type: S,
3295
3314
  conversationId: c.id,
@@ -3306,7 +3325,7 @@ const Vt = ({ conversation: c, currentUser: e, onClose: t, onBack: a }) => {
3306
3325
  fileSize: k.fileSize,
3307
3326
  mimeType: k.mimeType || g.type
3308
3327
  };
3309
- await y.messages.sendMessageWithOptions({
3328
+ await v.messages.sendMessageWithOptions({
3310
3329
  conversationId: c.id,
3311
3330
  content: `${g.name}`,
3312
3331
  type: _,
@@ -3317,15 +3336,15 @@ const Vt = ({ conversation: c, currentUser: e, onClose: t, onBack: a }) => {
3317
3336
  return delete L[f], L;
3318
3337
  });
3319
3338
  }, 200), z.success(w("file_sent_successfully"));
3320
- } catch (y) {
3339
+ } catch (v) {
3321
3340
  n((S) => S.filter((k) => k.id !== f)), p((S) => {
3322
3341
  const k = { ...S };
3323
3342
  return delete k[f], k;
3324
- }), z.error(w("error_file_upload") + ": " + (y.message || w("error_unknown")));
3343
+ }), z.error(w("error_file_upload") + ": " + (v.message || w("error_unknown")));
3325
3344
  } finally {
3326
3345
  h(!1);
3327
3346
  }
3328
- }, He = async () => {
3347
+ }, Ze = async () => {
3329
3348
  if (x(!1), !(!c || !e) && window.confirm(w("block_user_confirm")))
3330
3349
  try {
3331
3350
  const g = R.getInstance();
@@ -3343,12 +3362,12 @@ const Vt = ({ conversation: c, currentUser: e, onClose: t, onBack: a }) => {
3343
3362
  return;
3344
3363
  }
3345
3364
  await g.conversations.blockUserInChat(c.id, b);
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"));
3365
+ const v = c.metadata || {}, S = v.blockedUsers || {};
3366
+ S[b] = 1, c && (c.metadata = { ...v, blockedUsers: S }), F(!0), z.success(w("user_blocked"));
3348
3367
  } catch {
3349
3368
  z.error(w("failed_to_block"));
3350
3369
  }
3351
- }, _e = async () => {
3370
+ }, De = async () => {
3352
3371
  if (x(!1), !(!c || !e) && window.confirm(w("unblock_user_confirm")))
3353
3372
  try {
3354
3373
  const g = R.getInstance();
@@ -3362,8 +3381,8 @@ const Vt = ({ conversation: c, currentUser: e, onClose: t, onBack: a }) => {
3362
3381
  return;
3363
3382
  }
3364
3383
  await g.conversations.unblockUserInChat(c.id, f);
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"));
3384
+ const b = c.metadata || {}, v = b.blockedUsers || {};
3385
+ delete v[f], c && (c.metadata = { ...b, blockedUsers: v }), F(!1), z.success(w("user_unblocked"));
3367
3386
  } catch {
3368
3387
  z.error(w("failed_to_unblock"));
3369
3388
  }
@@ -3378,27 +3397,27 @@ const Vt = ({ conversation: c, currentUser: e, onClose: t, onBack: a }) => {
3378
3397
  /* @__PURE__ */ M("div", { className: "chat-header", children: [
3379
3398
  /* @__PURE__ */ M("div", { className: "chat-header-left", children: [
3380
3399
  a && /* @__PURE__ */ u("button", { className: "chat-back-btn", onClick: a, title: w("back") || "Back", children: /* @__PURE__ */ u("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ u("polyline", { points: "15 18 9 12 15 6" }) }) }),
3381
- /* @__PURE__ */ u("div", { className: "chat-header-avatar", children: /* @__PURE__ */ u("div", { className: "avatar-placeholder", children: W.userName ? W.userName.charAt(0).toUpperCase() : "?" }) }),
3382
- /* @__PURE__ */ u("div", { className: "chat-header-info", children: /* @__PURE__ */ u("h3", { className: "chat-participant-name", children: W.userName }) })
3400
+ /* @__PURE__ */ u("div", { className: "chat-header-avatar", children: /* @__PURE__ */ u("div", { className: "avatar-placeholder", children: q.userName ? q.userName.charAt(0).toUpperCase() : "?" }) }),
3401
+ /* @__PURE__ */ u("div", { className: "chat-header-info", children: /* @__PURE__ */ u("h3", { className: "chat-participant-name", children: q.userName }) })
3383
3402
  ] }),
3384
3403
  /* @__PURE__ */ M("div", { className: "chat-header-actions", children: [
3385
- U && /* @__PURE__ */ u("button", { onClick: We, className: "chat-action-btn", title: w("call") || "Call", children: /* @__PURE__ */ u("svg", { viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ u("path", { d: "M6.62 10.79c1.44 2.83 3.76 5.14 6.59 6.59l2.2-2.2c.27-.27.67-.36 1.02-.24 1.12.37 2.33.57 3.57.57.55 0 1 .45 1 1V20c0 .55-.45 1-1 1-9.39 0-17-7.61-17-17 0-.55.45-1 1-1h3.5c.55 0 1 .45 1 1 0 1.25.2 2.45.57 3.57.11.35.03.74-.25 1.02l-2.2 2.2z" }) }) }),
3404
+ U && /* @__PURE__ */ u("button", { onClick: He, className: "chat-action-btn", title: w("call") || "Call", children: /* @__PURE__ */ u("svg", { viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ u("path", { d: "M6.62 10.79c1.44 2.83 3.76 5.14 6.59 6.59l2.2-2.2c.27-.27.67-.36 1.02-.24 1.12.37 2.33.57 3.57.57.55 0 1 .45 1 1V20c0 .55-.45 1-1 1-9.39 0-17-7.61-17-17 0-.55.45-1 1-1h3.5c.55 0 1 .45 1 1 0 1.25.2 2.45.57 3.57.11.35.03.74-.25 1.02l-2.2 2.2z" }) }) }),
3386
3405
  t && /* @__PURE__ */ u("button", { onClick: t, className: "chat-action-btn", title: w("close") || "Close", children: /* @__PURE__ */ u("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: /* @__PURE__ */ u("path", { d: "M4 14h6v6M20 10h-6V4M14 10l7-7M3 21l7-7" }) }) }),
3387
3406
  c && U && /* @__PURE__ */ M("div", { className: "chat-options-wrapper", children: [
3388
- /* @__PURE__ */ u("button", { onClick: () => x(!N), className: "chat-action-btn", title: w("options") || "Options", children: /* @__PURE__ */ M("svg", { viewBox: "0 0 24 24", fill: "currentColor", children: [
3407
+ /* @__PURE__ */ u("button", { onClick: () => x(!T), className: "chat-action-btn", title: w("options") || "Options", children: /* @__PURE__ */ M("svg", { viewBox: "0 0 24 24", fill: "currentColor", children: [
3389
3408
  /* @__PURE__ */ u("circle", { cx: "12", cy: "5", r: "2" }),
3390
3409
  /* @__PURE__ */ u("circle", { cx: "12", cy: "12", r: "2" }),
3391
3410
  /* @__PURE__ */ u("circle", { cx: "12", cy: "19", r: "2" })
3392
3411
  ] }) }),
3393
- N && /* @__PURE__ */ M("div", { className: "chat-options-menu", children: [
3394
- !B && !D && /* @__PURE__ */ M("button", { onClick: He, className: "danger", children: [
3412
+ T && /* @__PURE__ */ M("div", { className: "chat-options-menu", children: [
3413
+ !B && !E && /* @__PURE__ */ M("button", { onClick: Ze, className: "danger", children: [
3395
3414
  /* @__PURE__ */ M("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
3396
3415
  /* @__PURE__ */ u("circle", { cx: "12", cy: "12", r: "10" }),
3397
3416
  /* @__PURE__ */ u("line", { x1: "4.93", y1: "4.93", x2: "19.07", y2: "19.07" })
3398
3417
  ] }),
3399
3418
  w("block_user")
3400
3419
  ] }),
3401
- D && /* @__PURE__ */ M("button", { onClick: _e, children: [
3420
+ E && /* @__PURE__ */ M("button", { onClick: De, children: [
3402
3421
  /* @__PURE__ */ M("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
3403
3422
  /* @__PURE__ */ u("circle", { cx: "12", cy: "12", r: "10" }),
3404
3423
  /* @__PURE__ */ u("path", { d: "M2 12h20" })
@@ -3409,26 +3428,26 @@ const Vt = ({ conversation: c, currentUser: e, onClose: t, onBack: a }) => {
3409
3428
  ] })
3410
3429
  ] })
3411
3430
  ] }),
3412
- W.productName && /* @__PURE__ */ M("div", { className: "chat-product-bar", children: [
3413
- W.productImage && /* @__PURE__ */ u("img", { src: W.productImage, alt: W.productName }),
3431
+ q.productName && /* @__PURE__ */ M("div", { className: "chat-product-bar", children: [
3432
+ q.productImage && /* @__PURE__ */ u("img", { src: q.productImage, alt: q.productName }),
3414
3433
  /* @__PURE__ */ M("div", { className: "chat-product-bar-info", children: [
3415
- /* @__PURE__ */ u("p", { className: "chat-product-bar-name", children: W.productName }),
3416
- ((Se = W.productMetadata) == null ? void 0 : Se.price) && /* @__PURE__ */ M("p", { className: "chat-product-bar-price", children: [
3417
- W.productMetadata.price,
3434
+ /* @__PURE__ */ u("p", { className: "chat-product-bar-name", children: q.productName }),
3435
+ ((Ee = q.productMetadata) == null ? void 0 : Ee.price) && /* @__PURE__ */ M("p", { className: "chat-product-bar-price", children: [
3436
+ q.productMetadata.price,
3418
3437
  " ",
3419
- W.productMetadata.currency || "QAR"
3438
+ q.productMetadata.currency || "QAR"
3420
3439
  ] })
3421
3440
  ] })
3422
3441
  ] }),
3423
- /* @__PURE__ */ M("div", { className: "chat-messages", ref: $, onScroll: je, onClick: () => x(!1), children: [
3442
+ /* @__PURE__ */ M("div", { className: "chat-messages", ref: $, onScroll: Ge, onClick: () => x(!1), children: [
3424
3443
  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
- i ? /* @__PURE__ */ u("div", { className: "loading-messages", children: w("loading_messages") }) : /* @__PURE__ */ M(Je, { children: [
3444
+ i ? /* @__PURE__ */ u("div", { className: "loading-messages", children: w("loading_messages") }) : /* @__PURE__ */ M(et, { children: [
3426
3445
  s.map((g, f) => {
3427
- var b, y, S, k, _, I, A, L, Z, Le;
3428
- return /* @__PURE__ */ M(Qe.Fragment, { children: [
3429
- Pe(g, f) && /* @__PURE__ */ M("div", { className: "date-divider", "data-date": pe(g.timestamp), children: [
3446
+ var b, v, S, k, _, I, A, L, Z, Ue;
3447
+ return /* @__PURE__ */ M(tt.Fragment, { children: [
3448
+ qe(g, f) && /* @__PURE__ */ M("div", { className: "date-divider", "data-date": ye(g.timestamp), children: [
3430
3449
  /* @__PURE__ */ u("div", { className: "date-divider-line" }),
3431
- /* @__PURE__ */ u("span", { className: "date-divider-text", children: pe(g.timestamp) }),
3450
+ /* @__PURE__ */ u("span", { className: "date-divider-text", children: ye(g.timestamp) }),
3432
3451
  /* @__PURE__ */ u("div", { className: "date-divider-line" })
3433
3452
  ] }),
3434
3453
  /* @__PURE__ */ u("div", { className: `message ${g.senderId === e.id ? "sent" : "received"}`, children: /* @__PURE__ */ M("div", { className: "message-content", children: [
@@ -3437,12 +3456,12 @@ const Vt = ({ conversation: c, currentUser: e, onClose: t, onBack: a }) => {
3437
3456
  /* @__PURE__ */ u(
3438
3457
  "img",
3439
3458
  {
3440
- src: g.isUploading ? g.localFileUri : (y = g.metadata) == null ? void 0 : y.fileUrl,
3459
+ src: g.isUploading ? g.localFileUri : (v = g.metadata) == null ? void 0 : v.fileUrl,
3441
3460
  alt: ((S = g.metadata) == null ? void 0 : S.fileName) || w("image"),
3442
3461
  className: g.isUploading ? "uploading-image" : "",
3443
3462
  onClick: () => {
3444
- var Ee;
3445
- return !g.isUploading && ((Ee = g.metadata) == null ? void 0 : Ee.fileUrl) && window.open(g.metadata.fileUrl, "_blank");
3463
+ var Fe;
3464
+ return !g.isUploading && ((Fe = g.metadata) == null ? void 0 : Fe.fileUrl) && window.open(g.metadata.fileUrl, "_blank");
3446
3465
  }
3447
3466
  }
3448
3467
  ),
@@ -3458,7 +3477,7 @@ const Vt = ({ conversation: c, currentUser: e, onClose: t, onBack: a }) => {
3458
3477
  /* File Message */
3459
3478
  /* @__PURE__ */ M("div", { className: "message-attachment file-attachment", children: [
3460
3479
  /* @__PURE__ */ M("div", { className: "file-info", children: [
3461
- /* @__PURE__ */ u("div", { className: "file-icon", children: Oe((A = g.metadata) == null ? void 0 : A.mimeType) }),
3480
+ /* @__PURE__ */ u("div", { className: "file-icon", children: Ve((A = g.metadata) == null ? void 0 : A.mimeType) }),
3462
3481
  /* @__PURE__ */ M("div", { className: "file-details", children: [
3463
3482
  /* @__PURE__ */ u("div", { className: "file-name", children: ((L = g.metadata) == null ? void 0 : L.fileName) || w("file") }),
3464
3483
  /* @__PURE__ */ u("div", { className: "file-size", children: (Z = g.metadata) != null && Z.fileSize ? `${Math.round(g.metadata.fileSize / 1024)} KB` : w("unknown_size") })
@@ -3467,7 +3486,7 @@ const Vt = ({ conversation: c, currentUser: e, onClose: t, onBack: a }) => {
3467
3486
  /* @__PURE__ */ u(
3468
3487
  "a",
3469
3488
  {
3470
- href: ((Le = g.metadata) == null ? void 0 : Le.fileUrl) || "#",
3489
+ href: ((Ue = g.metadata) == null ? void 0 : Ue.fileUrl) || "#",
3471
3490
  target: "_blank",
3472
3491
  rel: "noopener noreferrer",
3473
3492
  className: "download-btn",
@@ -3480,7 +3499,7 @@ const Vt = ({ conversation: c, currentUser: e, onClose: t, onBack: a }) => {
3480
3499
  g.content
3481
3500
  ),
3482
3501
  /* @__PURE__ */ M("div", { className: "message-footer", children: [
3483
- /* @__PURE__ */ u("span", { className: "message-time", children: $e(g.timestamp) }),
3502
+ /* @__PURE__ */ u("span", { className: "message-time", children: We(g.timestamp) }),
3484
3503
  g.senderId === e.id && /* @__PURE__ */ u("span", { className: "message-status", children: /* @__PURE__ */ u("span", { className: "read-status", children: g.isRead ? /* @__PURE__ */ M("svg", { className: "read-check is-read", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", strokeLinecap: "round", strokeLinejoin: "round", width: "20", height: "20", children: [
3485
3504
  /* @__PURE__ */ u("polyline", { points: "1 13 5 17 11 9" }),
3486
3505
  /* @__PURE__ */ u("polyline", { points: "7 13 11 17 17 9" })
@@ -3492,23 +3511,23 @@ const Vt = ({ conversation: c, currentUser: e, onClose: t, onBack: a }) => {
3492
3511
  /* @__PURE__ */ u("div", { ref: Q })
3493
3512
  ] })
3494
3513
  ] }),
3495
- D && /* @__PURE__ */ M("div", { className: "blocked-ui blocked-by-me", children: [
3496
- /* @__PURE__ */ u("div", { className: "blocked-title", children: w("you_have_blocked", { userName: W.userName || w("unknown_user") }) }),
3514
+ E && /* @__PURE__ */ M("div", { className: "blocked-ui blocked-by-me", children: [
3515
+ /* @__PURE__ */ u("div", { className: "blocked-title", children: w("you_have_blocked", { userName: q.userName || w("unknown_user") }) }),
3497
3516
  /* @__PURE__ */ u("div", { className: "blocked-message", children: w("you_have_blocked_submessage") }),
3498
- /* @__PURE__ */ u("button", { onClick: _e, className: "unblock-btn", children: w("unblock_user") })
3517
+ /* @__PURE__ */ u("button", { onClick: De, className: "unblock-btn", children: w("unblock_user") })
3499
3518
  ] }),
3500
- B && !D && /* @__PURE__ */ M("div", { className: "blocked-ui blocked-by-other", children: [
3501
- /* @__PURE__ */ u("div", { className: "blocked-title", children: w("blocked_by_user", { userName: W.userName || w("unknown_user") }) }),
3519
+ B && !E && /* @__PURE__ */ M("div", { className: "blocked-ui blocked-by-other", children: [
3520
+ /* @__PURE__ */ u("div", { className: "blocked-title", children: w("blocked_by_user", { userName: q.userName || w("unknown_user") }) }),
3502
3521
  /* @__PURE__ */ u("div", { className: "blocked-message", children: w("blocked_by_user_submessage") })
3503
3522
  ] }),
3504
- !D && !B && /* @__PURE__ */ M("form", { onSubmit: Ve, className: "chat-input", children: [
3523
+ !E && !B && /* @__PURE__ */ M("form", { onSubmit: Je, className: "chat-input", children: [
3505
3524
  /* @__PURE__ */ u(
3506
3525
  "button",
3507
3526
  {
3508
3527
  type: "button",
3509
3528
  onClick: () => {
3510
3529
  var g;
3511
- return (g = ce.current) == null ? void 0 : g.click();
3530
+ return (g = de.current) == null ? void 0 : g.click();
3512
3531
  },
3513
3532
  disabled: i || d || B,
3514
3533
  className: "attachment-btn",
@@ -3519,14 +3538,14 @@ const Vt = ({ conversation: c, currentUser: e, onClose: t, onBack: a }) => {
3519
3538
  /* @__PURE__ */ u(
3520
3539
  "input",
3521
3540
  {
3522
- ref: ce,
3541
+ ref: de,
3523
3542
  type: "file",
3524
3543
  style: { display: "none" },
3525
3544
  accept: "image/*,video/*,audio/*,.pdf,.doc,.docx,.txt",
3526
3545
  onChange: (g) => {
3527
3546
  var b;
3528
3547
  const f = (b = g.target.files) == null ? void 0 : b[0];
3529
- f && (Ge(f), g.target.value = "");
3548
+ f && (Qe(f), g.target.value = "");
3530
3549
  }
3531
3550
  }
3532
3551
  ),
@@ -3543,128 +3562,133 @@ const Vt = ({ conversation: c, currentUser: e, onClose: t, onBack: a }) => {
3543
3562
  /* @__PURE__ */ u("button", { type: "submit", disabled: !o.trim() || i || d || B, className: "send-btn", children: w(d ? "uploading" : "send") })
3544
3563
  ] })
3545
3564
  ] });
3546
- }, ta = (c) => /* @__PURE__ */ u("div", { className: "chatsdk-root", children: /* @__PURE__ */ u(Vt, { ...c }) }), Gt = ({
3565
+ }, ca = (c) => {
3566
+ const e = ne(null);
3567
+ return P(() => {
3568
+ Be(), we();
3569
+ }, []), /* @__PURE__ */ u("div", { ref: e, className: "chatsdk-root", children: /* @__PURE__ */ u(Jt, { ...c }) });
3570
+ }, Qt = ({
3547
3571
  currentUser: c,
3548
3572
  onSelectConversation: e,
3549
3573
  selectedConversationId: t
3550
3574
  }) => {
3551
- const [a, s] = T([]), [n, o] = T(!1), [r, i] = T(""), l = le(t), d = le(c.id);
3552
- Y(() => {
3575
+ const [a, s] = N([]), [n, o] = N(!1), [r, i] = N(""), l = ne(t), d = ne(c.id);
3576
+ P(() => {
3553
3577
  l.current = t;
3554
- }, [t]), Y(() => {
3578
+ }, [t]), P(() => {
3555
3579
  d.current = c.id;
3556
- }, [c.id]), Y(() => {
3580
+ }, [c.id]), P(() => {
3557
3581
  m();
3558
- }, []), Y(() => {
3582
+ }, []), P(() => {
3559
3583
  c && (s([]), m());
3560
- }, [c.id]), Y(() => {
3584
+ }, [c.id]), P(() => {
3561
3585
  var J;
3562
- const v = R.getInstance(), C = (D) => {
3563
- const F = D.message, N = F.roomId || F.conversationId;
3586
+ const y = R.getInstance(), C = (E) => {
3587
+ const F = E.message, T = F.roomId || F.conversationId;
3564
3588
  s(
3565
3589
  (x) => x.map((K) => {
3566
- if (K.id === N) {
3567
- const j = F.senderId !== d.current, te = l.current !== N;
3590
+ if (K.id === T) {
3591
+ const W = F.senderId !== d.current, te = l.current !== T;
3568
3592
  return {
3569
3593
  ...K,
3570
3594
  lastMessage: F,
3571
- unreadCount: j && te ? K.unreadCount + 1 : K.unreadCount
3595
+ unreadCount: W && te ? K.unreadCount + 1 : K.unreadCount
3572
3596
  };
3573
3597
  }
3574
3598
  return K;
3575
- }).sort((K, j) => {
3576
- var Q, ce;
3577
- const te = ((Q = K.lastMessage) == null ? void 0 : Q.timestamp) || K.createdAt, ae = ((ce = j.lastMessage) == null ? void 0 : ce.timestamp) || j.createdAt;
3599
+ }).sort((K, W) => {
3600
+ var Q, de;
3601
+ const te = ((Q = K.lastMessage) == null ? void 0 : Q.timestamp) || K.createdAt, ae = ((de = W.lastMessage) == null ? void 0 : de.timestamp) || W.createdAt;
3578
3602
  return new Date(ae).getTime() - new Date(te).getTime();
3579
3603
  })
3580
- ), F.senderId !== d.current && l.current === N && R.getInstance().chatUsers.markMessageRead(F.id).then(() => {
3604
+ ), F.senderId !== d.current && l.current === T && R.getInstance().chatUsers.markMessageRead(F.id).then(() => {
3581
3605
  s(
3582
3606
  (K) => K.map(
3583
- (j) => j.id === N ? { ...j, unreadCount: 0 } : j
3607
+ (W) => W.id === T ? { ...W, unreadCount: 0 } : W
3584
3608
  )
3585
3609
  );
3586
3610
  }).catch((K) => {
3587
3611
  console.warn("Failed to auto-mark message as read:", K);
3588
3612
  });
3589
- }, O = (D) => {
3590
- var K, j, te, ae;
3591
- const F = D.conversationId || ((K = D.conversation) == null ? void 0 : K.id) || ((j = D.conversation) == null ? void 0 : j.conversationId);
3613
+ }, j = (E) => {
3614
+ var K, W, te, ae;
3615
+ const F = E.conversationId || ((K = E.conversation) == null ? void 0 : K.id) || ((W = E.conversation) == null ? void 0 : W.conversationId);
3592
3616
  if (!F) return;
3593
- const N = D.lastMessage || ((te = D.conversation) == null ? void 0 : te.lastMessage), x = (ae = D.conversation) == null ? void 0 : ae.unreadCount;
3617
+ const T = E.lastMessage || ((te = E.conversation) == null ? void 0 : te.lastMessage), x = (ae = E.conversation) == null ? void 0 : ae.unreadCount;
3594
3618
  s((Q) => Q.some(($) => $.id === F) ? Q.map(($) => {
3595
3619
  if ($.id !== F) return $;
3596
- const H = l.current === F, re = d.current;
3620
+ const Y = l.current === F, oe = d.current;
3597
3621
  if (typeof x == "number")
3598
3622
  return {
3599
3623
  ...$,
3600
- lastMessage: N || $.lastMessage,
3601
- unreadCount: H ? 0 : x
3624
+ lastMessage: T || $.lastMessage,
3625
+ unreadCount: Y ? 0 : x
3602
3626
  };
3603
- const oe = (N == null ? void 0 : N.senderId) && N.senderId !== re, U = !!N && oe && !H;
3627
+ const ie = (T == null ? void 0 : T.senderId) && T.senderId !== oe, U = !!T && ie && !Y;
3604
3628
  return {
3605
3629
  ...$,
3606
- lastMessage: N || $.lastMessage,
3607
- unreadCount: H ? 0 : U ? $.unreadCount + 1 : $.unreadCount
3630
+ lastMessage: T || $.lastMessage,
3631
+ unreadCount: Y ? 0 : U ? $.unreadCount + 1 : $.unreadCount
3608
3632
  };
3609
- }).sort(($, H) => {
3610
- var U, fe;
3611
- const re = ((U = $.lastMessage) == null ? void 0 : U.timestamp) || $.createdAt, oe = ((fe = H.lastMessage) == null ? void 0 : fe.timestamp) || H.createdAt;
3612
- return new Date(oe).getTime() - new Date(re).getTime();
3633
+ }).sort(($, Y) => {
3634
+ var U, ke;
3635
+ const oe = ((U = $.lastMessage) == null ? void 0 : U.timestamp) || $.createdAt, ie = ((ke = Y.lastMessage) == null ? void 0 : ke.timestamp) || Y.createdAt;
3636
+ return new Date(ie).getTime() - new Date(oe).getTime();
3613
3637
  }) : (m(), Q));
3614
- }, G = (D) => {
3615
- const F = D.conversationId || D.roomId;
3638
+ }, H = (E) => {
3639
+ const F = E.conversationId || E.roomId;
3616
3640
  F && s(
3617
- (N) => N.map(
3641
+ (T) => T.map(
3618
3642
  (x) => x.id === F ? { ...x, unreadCount: 0 } : x
3619
3643
  )
3620
3644
  );
3621
- }, B = (D) => {
3622
- const F = D.roomId || D.conversationId;
3645
+ }, B = (E) => {
3646
+ const F = E.roomId || E.conversationId;
3623
3647
  F && s(
3624
- (N) => N.map(
3648
+ (T) => T.map(
3625
3649
  (x) => x.id === F ? { ...x, unreadCount: 0 } : x
3626
3650
  )
3627
3651
  );
3628
3652
  };
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
- var D;
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));
3653
+ return y.events.on("message.received", C), y.events.on("conversation.updated", j), y.events.on("conversation.read", H), (J = y.socket) != null && J.isConnected() && (y.socket.on("auto_marked_read", B), y.socket.on("room_marked_read", H)), () => {
3654
+ var E;
3655
+ y.events.off("message.received", C), y.events.off("conversation.updated", j), y.events.off("conversation.read", H), (E = y.socket) != null && E.isConnected() && (y.socket.off("auto_marked_read", B), y.socket.off("room_marked_read", H));
3632
3656
  };
3633
3657
  }, []);
3634
- const h = async (v) => {
3658
+ const h = async (y) => {
3635
3659
  try {
3636
- if (v.unreadCount > 0) {
3660
+ if (y.unreadCount > 0) {
3637
3661
  const C = R.getInstance();
3638
- await C.chatUsers.markRoomMessagesRead(v.id), C.chatUsers.startViewingConversation(v.id);
3662
+ await C.chatUsers.markRoomMessagesRead(y.id), C.chatUsers.startViewingConversation(y.id);
3639
3663
  }
3640
- e(v);
3664
+ e(y);
3641
3665
  } catch (C) {
3642
- console.error("Failed to mark conversation as read:", C), e(v);
3666
+ console.error("Failed to mark conversation as read:", C), e(y);
3643
3667
  }
3644
3668
  }, m = async () => {
3645
3669
  o(!0);
3646
3670
  try {
3647
3671
  const C = await R.getInstance().chatUsers.getConversations();
3648
- let O = C;
3649
- C && typeof C == "object" && !Array.isArray(C) && (O = C.conversations || C.data || []), s(Array.isArray(O) ? O : []);
3672
+ let j = C;
3673
+ C && typeof C == "object" && !Array.isArray(C) && (j = C.conversations || C.data || []), s(Array.isArray(j) ? j : []);
3650
3674
  } catch {
3651
3675
  z.error(w("error_load_conversations"));
3652
3676
  } finally {
3653
3677
  o(!1);
3654
3678
  }
3655
- }, p = (v) => v.participants.find((C) => C.id !== c.id), E = (v) => {
3656
- const C = p(v);
3679
+ }, p = (y) => y.participants.find((C) => C.id !== c.id), D = (y) => {
3680
+ const C = p(y);
3657
3681
  return (C == null ? void 0 : C.name) || w("unknown_user");
3658
- }, P = (v) => {
3682
+ }, O = (y) => {
3659
3683
  var C;
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
- 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((v) => {
3665
- var J, D;
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
- return O.includes(C) || G.includes(C) || B.includes(C);
3684
+ return ((C = y.lastMessage) == null ? void 0 : C.content) || w("no_messages_yet");
3685
+ }, Le = (y) => {
3686
+ const C = new Date(y), H = ((/* @__PURE__ */ new Date()).getTime() - C.getTime()) / (1e3 * 60 * 60), B = H / 24;
3687
+ return H < 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()]}`;
3688
+ }, he = r.trim() ? a.filter((y) => {
3689
+ var J, E;
3690
+ const C = r.toLowerCase().trim(), j = D(y).toLowerCase(), H = ((E = (J = y.productContext) == null ? void 0 : J.productName) == null ? void 0 : E.toLowerCase()) || "", B = O(y).toLowerCase();
3691
+ return j.includes(C) || H.includes(C) || B.includes(C);
3668
3692
  }) : a;
3669
3693
  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: [
3670
3694
  /* @__PURE__ */ u("div", { className: "conversation-list-header", children: /* @__PURE__ */ u("h3", { children: w("conversations_title") }) }),
@@ -3677,60 +3701,65 @@ const Vt = ({ conversation: c, currentUser: e, onClose: t, onBack: a }) => {
3677
3701
  "input",
3678
3702
  {
3679
3703
  value: r,
3680
- onChange: (v) => i(v.target.value),
3704
+ onChange: (y) => i(y.target.value),
3681
3705
  type: "text",
3682
3706
  placeholder: w("search") || "Search"
3683
3707
  }
3684
3708
  )
3685
3709
  ] }) }),
3686
- /* @__PURE__ */ u("div", { className: "conversations", children: ge.length === 0 ? /* @__PURE__ */ M("div", { className: "empty-conversations", children: [
3710
+ /* @__PURE__ */ u("div", { className: "conversations", children: he.length === 0 ? /* @__PURE__ */ M("div", { className: "empty-conversations", children: [
3687
3711
  /* @__PURE__ */ u("p", { children: r ? w("no_search_results") || "No results found" : w("no_conversations_title") }),
3688
3712
  !r && /* @__PURE__ */ u("p", { children: w("no_conversations_message") })
3689
- ] }) : ge.map((v) => {
3690
- var O;
3691
- const C = t === v.id;
3713
+ ] }) : he.map((y) => {
3714
+ var j;
3715
+ const C = t === y.id;
3692
3716
  return /* @__PURE__ */ M(
3693
3717
  "div",
3694
3718
  {
3695
- className: `conversation-item ${C ? "selected" : ""} ${v.unreadCount > 0 ? "has-unread" : ""}`,
3696
- onClick: () => h(v),
3719
+ className: `conversation-item ${C ? "selected" : ""} ${y.unreadCount > 0 ? "has-unread" : ""}`,
3720
+ onClick: () => h(y),
3697
3721
  children: [
3698
- /* @__PURE__ */ u("div", { className: "conversation-avatar", children: (O = v.productContext) != null && O.productImage ? /* @__PURE__ */ u(
3722
+ /* @__PURE__ */ u("div", { className: "conversation-avatar", children: (j = y.productContext) != null && j.productImage ? /* @__PURE__ */ u(
3699
3723
  "img",
3700
3724
  {
3701
- src: v.productContext.productImage,
3702
- alt: v.productContext.productName,
3725
+ src: y.productContext.productImage,
3726
+ alt: y.productContext.productName,
3703
3727
  className: "product-image"
3704
3728
  }
3705
- ) : /* @__PURE__ */ u("div", { className: "avatar-placeholder", children: E(v).charAt(0).toUpperCase() }) }),
3729
+ ) : /* @__PURE__ */ u("div", { className: "avatar-placeholder", children: D(y).charAt(0).toUpperCase() }) }),
3706
3730
  /* @__PURE__ */ M("div", { className: "conversation-content", children: [
3707
3731
  /* @__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(v) }) }),
3709
- v.lastMessage && /* @__PURE__ */ u("span", { className: "conversation-time", children: Ce(v.lastMessage.timestamp) })
3732
+ /* @__PURE__ */ u("div", { className: "conversation-title-wrapper", children: /* @__PURE__ */ u("h4", { className: "conversation-participant-name", children: D(y) }) }),
3733
+ y.lastMessage && /* @__PURE__ */ u("span", { className: "conversation-time", children: Le(y.lastMessage.timestamp) })
3710
3734
  ] }),
3711
3735
  /* @__PURE__ */ M("div", { className: "conversation-details", children: [
3712
- /* @__PURE__ */ u("p", { className: "conversation-last-message", children: P(v) }),
3713
- v.unreadCount > 0 && /* @__PURE__ */ u("span", { className: "unread-badge", children: v.unreadCount })
3736
+ /* @__PURE__ */ u("p", { className: "conversation-last-message", children: O(y) }),
3737
+ y.unreadCount > 0 && /* @__PURE__ */ u("span", { className: "unread-badge", children: y.unreadCount })
3714
3738
  ] })
3715
3739
  ] })
3716
3740
  ]
3717
3741
  },
3718
- v.id
3742
+ y.id
3719
3743
  );
3720
3744
  }) })
3721
3745
  ] });
3722
- }, aa = (c) => /* @__PURE__ */ u("div", { className: "chatsdk-root", children: /* @__PURE__ */ u(Gt, { ...c }) }), Ht = () => {
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
- Y(() => {
3746
+ }, la = (c) => {
3747
+ const e = ne(null);
3748
+ return P(() => {
3749
+ Be(), we();
3750
+ }, []), /* @__PURE__ */ u("div", { ref: e, className: "chatsdk-root", children: /* @__PURE__ */ u(Qt, { ...c }) });
3751
+ }, Zt = () => {
3752
+ const [c, e] = N(() => typeof window < "u" && localStorage.getItem("chatSDK-theme") || "auto"), [t, a] = N(() => typeof window < "u" && window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light"), s = c === "auto" ? t : c;
3753
+ P(() => {
3725
3754
  if (typeof window > "u" || !window.matchMedia) return;
3726
3755
  const r = window.matchMedia("(prefers-color-scheme: dark)"), i = (l) => {
3727
3756
  a(l.matches ? "dark" : "light");
3728
3757
  };
3729
3758
  return r.addEventListener("change", i), () => r.removeEventListener("change", i);
3730
- }, []), Y(() => {
3731
- if (typeof window > "u") return;
3732
- const r = document.documentElement;
3733
- r.classList.remove("theme-light", "theme-dark"), r.removeAttribute("data-theme"), r.classList.add(`theme-${s}`), r.setAttribute("data-theme", s);
3759
+ }, []), P(() => {
3760
+ typeof window > "u" || Se((r) => {
3761
+ r.classList.remove("theme-light", "theme-dark"), r.removeAttribute("data-theme"), r.classList.add(`theme-${s}`), r.setAttribute("data-theme", s);
3762
+ });
3734
3763
  }, [s]);
3735
3764
  const n = (r) => {
3736
3765
  e(r), typeof window < "u" && localStorage.setItem("chatSDK-theme", r);
@@ -3743,19 +3772,19 @@ const Vt = ({ conversation: c, currentUser: e, onClose: t, onBack: a }) => {
3743
3772
  n(c === "auto" ? t === "light" ? "dark" : "light" : s === "light" ? "dark" : "light");
3744
3773
  }
3745
3774
  };
3746
- }, Ke = Ze(void 0), sa = ({ children: c }) => {
3747
- const e = Ht();
3748
- return /* @__PURE__ */ u(Ke.Provider, { value: e, children: c });
3749
- }, Yt = () => {
3750
- const c = Xe(Ke);
3775
+ }, $e = at(void 0), da = ({ children: c }) => {
3776
+ const e = Zt();
3777
+ return /* @__PURE__ */ u($e.Provider, { value: e, children: c });
3778
+ }, Xt = () => {
3779
+ const c = st($e);
3751
3780
  if (!c)
3752
3781
  throw new Error("useThemeContext must be used within a ThemeProvider");
3753
3782
  return c;
3754
- }, na = ({
3783
+ }, ga = ({
3755
3784
  className: c = "",
3756
3785
  showLabel: e = !1
3757
3786
  }) => {
3758
- const { theme: t, actualTheme: a, setTheme: s } = Yt(), n = () => {
3787
+ const { theme: t, actualTheme: a, setTheme: s } = Xt(), n = () => {
3759
3788
  switch (t) {
3760
3789
  case "light":
3761
3790
  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 +3839,13 @@ const Vt = ({ conversation: c, currentUser: e, onClose: t, onBack: a }) => {
3810
3839
  ]
3811
3840
  }
3812
3841
  );
3813
- }, ra = () => {
3842
+ }, ha = () => {
3814
3843
  var s;
3815
3844
  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
- document.documentElement.classList.add(`theme-${a}`), document.documentElement.setAttribute("data-theme", a);
3817
- }, oa = {
3845
+ Se((n) => {
3846
+ n.classList.add(`theme-${a}`), n.setAttribute("data-theme", a);
3847
+ });
3848
+ }, ua = {
3818
3849
  // Material Design 3 Primary Colors
3819
3850
  primary: {
3820
3851
  main: "#2196F3",
@@ -3898,7 +3929,7 @@ const Vt = ({ conversation: c, currentUser: e, onClose: t, onBack: a }) => {
3898
3929
  black: "#000000",
3899
3930
  transparent: "transparent"
3900
3931
  }
3901
- }, ia = {
3932
+ }, ma = {
3902
3933
  primary: {
3903
3934
  main: "#90CAF9",
3904
3935
  onPrimary: "#0D47A1",
@@ -3946,9 +3977,9 @@ const Vt = ({ conversation: c, currentUser: e, onClose: t, onBack: a }) => {
3946
3977
  timestamp: "#BDBDBD",
3947
3978
  primaryText: "#FFFFFF"
3948
3979
  }
3949
- }, ca = {
3980
+ }, fa = {
3950
3981
  async init(c) {
3951
- const { ChatSDK: e } = await Promise.resolve().then(() => ct);
3982
+ const { ChatSDK: e } = await Promise.resolve().then(() => ht);
3952
3983
  return e.getInstance().init(c);
3953
3984
  },
3954
3985
  formatFileSize(c) {
@@ -3962,28 +3993,32 @@ const Vt = ({ conversation: c, currentUser: e, onClose: t, onBack: a }) => {
3962
3993
  }
3963
3994
  };
3964
3995
  export {
3965
- et as AuthManager,
3996
+ nt as AuthManager,
3966
3997
  R as ChatSDK,
3967
- ca as ChatSDKHelpers,
3968
- ta as ChatWindow,
3969
- aa as ConversationList,
3970
- st as ConversationManager,
3971
- ot as EventManager,
3972
- rt as MediaManager,
3973
- nt as MessageManager,
3974
- Ue as ParseUtils,
3975
- it as SocketManager,
3976
- sa as ThemeProvider,
3977
- na as ThemeToggle,
3978
- at as UserManager,
3979
- Ie as changeLanguage,
3980
- ia as darkThemeConfig,
3981
- ea as getCurrentLanguage,
3982
- ra as initializeTheme,
3983
- qt as isRTL,
3998
+ fa as ChatSDKHelpers,
3999
+ ca as ChatWindow,
4000
+ la as ConversationList,
4001
+ it as ConversationManager,
4002
+ dt as EventManager,
4003
+ lt as MediaManager,
4004
+ ct as MessageManager,
4005
+ Ae as ParseUtils,
4006
+ gt as SocketManager,
4007
+ da as ThemeProvider,
4008
+ ga as ThemeToggle,
4009
+ ot as UserManager,
4010
+ we as applyLanguageToDOM,
4011
+ oa as changeLanguage,
4012
+ ma as darkThemeConfig,
4013
+ ia as getCurrentLanguage,
4014
+ ra as getSDKRoot,
4015
+ Be as initializeI18n,
4016
+ ha as initializeTheme,
4017
+ Yt as isRTL,
4018
+ na as setSDKRoot,
3984
4019
  w as t,
3985
- oa as themeConfig,
3986
- Ht as useTheme,
3987
- Yt as useThemeContext
4020
+ ua as themeConfig,
4021
+ Zt as useTheme,
4022
+ Xt as useThemeContext
3988
4023
  };
3989
4024
  //# sourceMappingURL=chatsdk-react.mjs.map