@traiyani/chatsdk-react 1.0.4 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chatsdk-react.cjs +27 -27
- package/dist/chatsdk-react.cjs.map +1 -1
- package/dist/chatsdk-react.mjs +357 -326
- package/dist/chatsdk-react.mjs.map +1 -1
- package/dist/chatsdk.css +1 -1
- package/package.json +1 -1
package/dist/chatsdk-react.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { io as
|
|
3
|
-
import {
|
|
4
|
-
import * as
|
|
5
|
-
import
|
|
6
|
-
class
|
|
1
|
+
import ge from "axios";
|
|
2
|
+
import { io as Xe } from "socket.io-client";
|
|
3
|
+
import { jsx as u, jsxs as M, Fragment as et } from "react/jsx-runtime";
|
|
4
|
+
import * as V from "react";
|
|
5
|
+
import tt, { useState as T, useRef as de, useEffect as P, useCallback as Ie, 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 =
|
|
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
|
|
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 =
|
|
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),
|
|
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:
|
|
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(
|
|
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
|
|
611
|
-
return (r = this.config) != null && r.enableLogging && console.log("✅ ChatUserManager: Room messages marked as read via API", { conversationId: e, markedCount:
|
|
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
|
|
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 =
|
|
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
|
|
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 =
|
|
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
|
|
930
|
-
console.log("📡 Server response:",
|
|
931
|
-
const
|
|
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:
|
|
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(
|
|
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
|
|
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 =
|
|
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
|
|
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 =
|
|
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
|
|
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
|
|
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
|
|
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 =
|
|
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,
|
|
2217
|
-
clearTimeout(m), (p = this.config) != null && p.enableLogging && console.log("✅ SocketManager: Connected to WebSocket server successfully!"), this.socket.emit("authenticate", { userId: e, appId: (
|
|
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
|
|
2220
|
-
clearTimeout(m), (
|
|
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
|
|
2223
|
-
(
|
|
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 =
|
|
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 =
|
|
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 });
|
|
@@ -2420,7 +2420,7 @@ class it {
|
|
|
2420
2420
|
}
|
|
2421
2421
|
const ie = class ie {
|
|
2422
2422
|
constructor() {
|
|
2423
|
-
this.config = null, this.isInitialized = !1, this.currentUser = null, this.auth = new
|
|
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
|
|
@@ -2548,26 +2548,26 @@ const ie = class ie {
|
|
|
2548
2548
|
ie.instance = null;
|
|
2549
2549
|
let R = ie;
|
|
2550
2550
|
R.getInstance();
|
|
2551
|
-
const
|
|
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
|
|
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 = {},
|
|
2562
|
+
}, X = {}, Te = (c) => {
|
|
2563
2563
|
if (typeof c == "object") {
|
|
2564
2564
|
let e = "";
|
|
2565
|
-
for (let t in c) e += t +
|
|
2565
|
+
for (let t in c) e += t + Te(c[t]);
|
|
2566
2566
|
return e;
|
|
2567
2567
|
}
|
|
2568
2568
|
return c;
|
|
2569
|
-
},
|
|
2570
|
-
let n =
|
|
2569
|
+
}, wt = (c, e, t, a, s) => {
|
|
2570
|
+
let n = Te(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 =
|
|
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
|
-
},
|
|
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,15 +2592,15 @@ let lt = { data: "" }, dt = (c) => typeof window == "object" ? ((c ? c.querySele
|
|
|
2592
2592
|
}
|
|
2593
2593
|
return a + s + (o ?? "");
|
|
2594
2594
|
}, "");
|
|
2595
|
-
function
|
|
2595
|
+
function pe(c) {
|
|
2596
2596
|
let e = this || {}, t = c.call ? c(e.p) : c;
|
|
2597
|
-
return
|
|
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
|
|
2600
|
-
|
|
2601
|
-
let ee =
|
|
2602
|
-
function
|
|
2603
|
-
se.p = e,
|
|
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
2605
|
function ne(c, e) {
|
|
2606
2606
|
let t = this || {};
|
|
@@ -2608,17 +2608,17 @@ function ne(c, e) {
|
|
|
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:
|
|
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),
|
|
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
|
|
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
|
-
})(),
|
|
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
|
-
})(),
|
|
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,
|
|
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
|
|
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
|
-
},
|
|
2651
|
-
|
|
2652
|
-
e(
|
|
2650
|
+
}, _t = [], ve = { toasts: [], pausedAt: void 0 }, _e = (c) => {
|
|
2651
|
+
ve = ze(ve, c), _t.forEach((e) => {
|
|
2652
|
+
e(ve);
|
|
2653
2653
|
});
|
|
2654
|
-
},
|
|
2655
|
-
let a =
|
|
2656
|
-
return
|
|
2657
|
-
},
|
|
2658
|
-
|
|
2659
|
-
|
|
2660
|
-
|
|
2661
|
-
|
|
2662
|
-
|
|
2663
|
-
|
|
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
|
-
|
|
2666
|
-
|
|
2667
|
-
let a =
|
|
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 ?
|
|
2670
|
-
return n ?
|
|
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 ?
|
|
2673
|
-
n ?
|
|
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
|
|
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
|
-
}`,
|
|
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
|
-
}`,
|
|
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
|
-
}`,
|
|
2700
|
+
}`, Ut = ne("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: ${
|
|
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: ${
|
|
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: ${
|
|
2729
|
+
animation: ${Et} 0.15s ease-out forwards;
|
|
2730
2730
|
animation-delay: 180ms;
|
|
2731
2731
|
transform: rotate(90deg);
|
|
2732
2732
|
}
|
|
2733
|
-
`,
|
|
2733
|
+
`, Ft = ee`
|
|
2734
2734
|
from {
|
|
2735
2735
|
transform: rotate(0deg);
|
|
2736
2736
|
}
|
|
2737
2737
|
to {
|
|
2738
2738
|
transform: rotate(360deg);
|
|
2739
2739
|
}
|
|
2740
|
-
`,
|
|
2740
|
+
`, It = ne("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: ${
|
|
2749
|
-
`,
|
|
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
|
-
}`,
|
|
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
|
-
}`,
|
|
2771
|
+
}`, Nt = ne("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: ${
|
|
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: ${
|
|
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
|
-
`,
|
|
2798
|
+
`, Tt = ne("div")`
|
|
2799
2799
|
position: absolute;
|
|
2800
|
-
`,
|
|
2800
|
+
`, Kt = ne("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
|
-
`,
|
|
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
|
-
}`,
|
|
2815
|
+
}`, Rt = ne("div")`
|
|
2816
2816
|
position: relative;
|
|
2817
2817
|
transform: scale(0.6);
|
|
2818
2818
|
opacity: 0.4;
|
|
2819
2819
|
min-width: 20px;
|
|
2820
|
-
animation: ${
|
|
2820
|
+
animation: ${zt} 0.3s 0.12s cubic-bezier(0.175, 0.885, 0.32, 1.275)
|
|
2821
2821
|
forwards;
|
|
2822
|
-
`,
|
|
2822
|
+
`, Bt = ({ toast: c }) => {
|
|
2823
2823
|
let { icon: e, type: t, iconTheme: a } = c;
|
|
2824
|
-
return e !== void 0 ? typeof e == "string" ?
|
|
2825
|
-
},
|
|
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(Tt, null, t === "error" ? V.createElement(Ut, { ...a }) : V.createElement(Nt, { ...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
|
-
`,
|
|
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
|
-
`,
|
|
2831
|
+
`, Ot = "0%{opacity:0;} 100%{opacity:1;}", jt = "0%{opacity:1;} 100%{opacity:0;}", Wt = ne("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
|
-
`,
|
|
2843
|
+
`, qt = ne("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
|
-
`,
|
|
2851
|
-
let t = c.includes("top") ? 1 : -1, [a, s] =
|
|
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
|
-
|
|
2855
|
-
let s = c.height ?
|
|
2856
|
-
return
|
|
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
|
-
|
|
2859
|
-
|
|
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 =
|
|
2866
|
-
const
|
|
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
|
-
},
|
|
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
|
-
},
|
|
3083
|
-
|
|
3084
|
-
|
|
3082
|
+
}, Re = "chatsdk-root";
|
|
3083
|
+
let ue = null;
|
|
3084
|
+
const aa = (c) => {
|
|
3085
|
+
ue = c;
|
|
3086
|
+
}, sa = () => {
|
|
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
|
|
3087
|
-
const
|
|
3088
|
-
|
|
3089
|
-
|
|
3090
|
-
|
|
3097
|
+
let ce = "en", Ne = !1;
|
|
3098
|
+
const we = () => {
|
|
3099
|
+
const c = ce, e = Yt() ? "rtl" : "ltr";
|
|
3100
|
+
Se((t) => {
|
|
3101
|
+
t.setAttribute("lang", c), t.setAttribute("dir", e);
|
|
3102
|
+
});
|
|
3103
|
+
}, na = (c) => {
|
|
3104
|
+
fe[c] ? (ce = c, localStorage.setItem("chatSDK_language", c)) : (console.warn(`Locale "${c}" not found, falling back to "en".`), ce = "en"), we();
|
|
3105
|
+
}, ra = () => ce, Yt = () => ce === "ar", w = (c, e) => {
|
|
3106
|
+
let t = fe[ce][c] || fe.en[c] || c;
|
|
3091
3107
|
if (e)
|
|
3092
3108
|
for (const a in e)
|
|
3093
3109
|
t = t.replace(
|
|
@@ -3095,20 +3111,27 @@ const Ie = (c) => {
|
|
|
3095
3111
|
String(e[a])
|
|
3096
3112
|
);
|
|
3097
3113
|
return t;
|
|
3098
|
-
},
|
|
3099
|
-
|
|
3100
|
-
|
|
3101
|
-
|
|
3102
|
-
|
|
3114
|
+
}, Be = () => {
|
|
3115
|
+
if (Ne) return;
|
|
3116
|
+
Ne = !0;
|
|
3117
|
+
const c = localStorage.getItem("chatSDK_language");
|
|
3118
|
+
c && fe[c] && (ce = c), we();
|
|
3119
|
+
}, oa = ({ conversation: c, currentUser: e, onClose: t, onBack: a }) => {
|
|
3120
|
+
var Ee;
|
|
3121
|
+
const [s, n] = T([]), [o, r] = T(""), [i, l] = T(!1), [d, h] = T(!1), [m, p] = T({}), [D, O] = T(!1), [Le, he] = T(!0), [y, C] = T(1), [j, H] = T(null), [B, J] = T(!1), [E, F] = T(!1), [N, x] = T(!1), [K, W] = T(null), [te, ae] = T(!1), Q = de(null), le = de(null), $ = de(null), Y = de(null), re = 20;
|
|
3122
|
+
P(() => {
|
|
3123
|
+
Be(), we();
|
|
3124
|
+
}, []);
|
|
3125
|
+
const oe = Ie(() => {
|
|
3103
3126
|
if (!c || !e) return null;
|
|
3104
3127
|
const g = c.participants || [];
|
|
3105
3128
|
if (g.length === 0) return null;
|
|
3106
3129
|
const f = e.id || e.userId, b = e.externalUserId || e.external_user_id;
|
|
3107
|
-
return g.find((
|
|
3108
|
-
const S =
|
|
3130
|
+
return g.find((v) => {
|
|
3131
|
+
const S = v.id || v.userId, k = v.externalUserId || v.external_user_id;
|
|
3109
3132
|
return !(f && S && S === f || b && k && k === b) && (S || k);
|
|
3110
3133
|
}) || null;
|
|
3111
|
-
}, [c, e]), U = oe(),
|
|
3134
|
+
}, [c, e]), U = oe(), q = Ie(() => {
|
|
3112
3135
|
if (!c) return { userName: w("conversations_title"), productName: null, productImage: null, productMetadata: null };
|
|
3113
3136
|
const g = U && (U.name || U.userName || U.displayName || U.externalUserId) || w("unknown_user"), f = c.productContext || c.product_context;
|
|
3114
3137
|
return f ? {
|
|
@@ -3119,9 +3142,9 @@ const Vt = ({ conversation: c, currentUser: e, onClose: t, onBack: a }) => {
|
|
|
3119
3142
|
productMetadata: f.productMetadata || f.product_metadata
|
|
3120
3143
|
} : { userName: g, productName: null, productImage: null, productMetadata: null };
|
|
3121
3144
|
}, [c, U])();
|
|
3122
|
-
|
|
3123
|
-
c && (
|
|
3124
|
-
}), [c]),
|
|
3145
|
+
P(() => (c && (x(!1), Ye(1, !1), Pe(), R.getInstance().chatUsers.startViewingConversation(c.id)), () => {
|
|
3146
|
+
c && (Oe(), R.getInstance().chatUsers.stopViewingConversation(c.id));
|
|
3147
|
+
}), [c]), P(() => {
|
|
3125
3148
|
const g = R.getInstance(), f = (k) => {
|
|
3126
3149
|
const _ = k.message;
|
|
3127
3150
|
_.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 +3166,7 @@ const Vt = ({ conversation: c, currentUser: e, onClose: t, onBack: a }) => {
|
|
|
3143
3166
|
!k.messageId || k.roomId !== (c == null ? void 0 : c.id) || n((_) => _.map(
|
|
3144
3167
|
(I) => I.id === k.messageId && I.senderId === e.id ? { ...I, isRead: k.isRead } : I
|
|
3145
3168
|
));
|
|
3146
|
-
},
|
|
3169
|
+
}, v = (k) => {
|
|
3147
3170
|
if (k.roomId !== (c == null ? void 0 : c.id)) return;
|
|
3148
3171
|
const _ = e == null ? void 0 : e.id;
|
|
3149
3172
|
if (!k.messageIds || k.messageIds.length === 0) {
|
|
@@ -3162,66 +3185,66 @@ const Vt = ({ conversation: c, currentUser: e, onClose: t, onBack: a }) => {
|
|
|
3162
3185
|
const A = e.id || e.userId, L = oe(), Z = L ? L.id || L.userId || L.externalUserId || L.external_user_id : null;
|
|
3163
3186
|
J(I[A] === 1), F(Z ? I[Z] === 1 : !1);
|
|
3164
3187
|
};
|
|
3165
|
-
return g.events.on("message.received", f), g.events.on("message.read.receipt", b), g.events.on("messages.read.receipt",
|
|
3166
|
-
g.events.off("message.received", f), g.events.off("message.read.receipt", b), g.events.off("messages.read.receipt",
|
|
3188
|
+
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), () => {
|
|
3189
|
+
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
3190
|
};
|
|
3168
|
-
}, [c == null ? void 0 : c.id, e == null ? void 0 : e.id]),
|
|
3191
|
+
}, [c == null ? void 0 : c.id, e == null ? void 0 : e.id]), P(() => {
|
|
3169
3192
|
if (!c || !e) {
|
|
3170
|
-
J(!1), F(!1),
|
|
3193
|
+
J(!1), F(!1), H(null);
|
|
3171
3194
|
return;
|
|
3172
3195
|
}
|
|
3173
|
-
const f = (c.metadata || {}).blockedUsers || {}, b = e.id || e.userId,
|
|
3174
|
-
J(f[b] === 1), F(S ? f[S] === 1 : !1),
|
|
3196
|
+
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;
|
|
3197
|
+
J(f[b] === 1), F(S ? f[S] === 1 : !1), H({
|
|
3175
3198
|
chatId: c.id,
|
|
3176
3199
|
currentUserId: b,
|
|
3177
3200
|
isBlockedByOther: f[b] === 1,
|
|
3178
3201
|
usersBlockedByMe: Object.keys(f).filter((k) => f[k] === 1),
|
|
3179
3202
|
blockedUsers: f
|
|
3180
3203
|
});
|
|
3181
|
-
}, [c == null ? void 0 : c.id, JSON.stringify(c == null ? void 0 : c.metadata), e == null ? void 0 : e.id]),
|
|
3182
|
-
|
|
3183
|
-
}, [s]),
|
|
3204
|
+
}, [c == null ? void 0 : c.id, JSON.stringify(c == null ? void 0 : c.metadata), e == null ? void 0 : e.id]), P(() => {
|
|
3205
|
+
je();
|
|
3206
|
+
}, [s]), P(() => {
|
|
3184
3207
|
const g = (f) => {
|
|
3185
3208
|
f.target.closest(".chat-options-wrapper") || x(!1);
|
|
3186
3209
|
};
|
|
3187
3210
|
return document.addEventListener("click", g), () => {
|
|
3188
|
-
document.removeEventListener("click", g),
|
|
3211
|
+
document.removeEventListener("click", g), Y.current && clearTimeout(Y.current);
|
|
3189
3212
|
};
|
|
3190
3213
|
}, []);
|
|
3191
|
-
const
|
|
3214
|
+
const Pe = () => {
|
|
3192
3215
|
c && R.getInstance().socket.joinRoom(c.id);
|
|
3193
|
-
},
|
|
3216
|
+
}, Oe = () => {
|
|
3194
3217
|
c && R.getInstance().socket.leaveRoom(c.id);
|
|
3195
|
-
},
|
|
3218
|
+
}, je = () => {
|
|
3196
3219
|
var g;
|
|
3197
3220
|
(g = Q.current) == null || g.scrollIntoView({ behavior: "smooth" });
|
|
3198
|
-
},
|
|
3199
|
-
const f = new Date(g), b = /* @__PURE__ */ new Date(),
|
|
3221
|
+
}, We = (g) => new Date(g).toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" }), ye = (g) => {
|
|
3222
|
+
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
3223
|
if (k === 0) return "Today";
|
|
3201
3224
|
if (k === 1) return "Yesterday";
|
|
3202
3225
|
const _ = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], I = f.getDate().toString().padStart(2, "0"), A = (f.getMonth() + 1).toString().padStart(2, "0");
|
|
3203
3226
|
return k < 7 ? `${_[f.getDay()]}, ${I}/${A}` : `${I}/${A}/${f.getFullYear()}`;
|
|
3204
|
-
},
|
|
3227
|
+
}, qe = (g, f) => {
|
|
3205
3228
|
if (f === 0) return !0;
|
|
3206
|
-
const b = s[f - 1],
|
|
3207
|
-
return
|
|
3208
|
-
},
|
|
3229
|
+
const b = s[f - 1], v = new Date(b.timestamp).toDateString(), S = new Date(g.timestamp).toDateString();
|
|
3230
|
+
return v !== S;
|
|
3231
|
+
}, Ve = (g) => g ? g.includes("pdf") ? "📄" : g.includes("word") ? "📝" : g.includes("excel") ? "📊" : g.includes("audio") ? "🎵" : g.includes("video") ? "🎥" : "📎" : "📎", Ge = () => {
|
|
3209
3232
|
if (!$.current) return;
|
|
3210
3233
|
const g = $.current, f = g.querySelectorAll(".date-divider[data-date]");
|
|
3211
3234
|
if (f.length === 0) return;
|
|
3212
3235
|
let b = null;
|
|
3213
|
-
const
|
|
3236
|
+
const v = g.getBoundingClientRect().top;
|
|
3214
3237
|
for (let S = f.length - 1; S >= 0; S--) {
|
|
3215
3238
|
const k = f[S];
|
|
3216
|
-
if (k.getBoundingClientRect().top <=
|
|
3239
|
+
if (k.getBoundingClientRect().top <= v + 50) {
|
|
3217
3240
|
b = k.getAttribute("data-date");
|
|
3218
3241
|
break;
|
|
3219
3242
|
}
|
|
3220
3243
|
}
|
|
3221
|
-
!b && s.length > 0 && (b =
|
|
3244
|
+
!b && s.length > 0 && (b = ye(s[0].timestamp)), b && (W(b), ae(!0), Y.current && clearTimeout(Y.current), Y.current = setTimeout(() => {
|
|
3222
3245
|
ae(!1);
|
|
3223
3246
|
}, 2e3));
|
|
3224
|
-
},
|
|
3247
|
+
}, He = () => {
|
|
3225
3248
|
if (!U) return;
|
|
3226
3249
|
const g = U, f = g.phone || g.phoneNumber || g.mobile || g.externalUserId || "";
|
|
3227
3250
|
if (!f) {
|
|
@@ -3231,28 +3254,28 @@ const Vt = ({ conversation: c, currentUser: e, onClose: t, onBack: a }) => {
|
|
|
3231
3254
|
/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ? window.location.href = `tel:${f}` : navigator.clipboard.writeText(f).then(() => {
|
|
3232
3255
|
z.success(w("number_copied") || `Phone number copied: ${f}`);
|
|
3233
3256
|
}).catch(() => {
|
|
3234
|
-
const
|
|
3235
|
-
|
|
3257
|
+
const v = document.createElement("textarea");
|
|
3258
|
+
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
3259
|
});
|
|
3237
|
-
},
|
|
3260
|
+
}, Ye = async (g = 1, f = !1) => {
|
|
3238
3261
|
if (c) {
|
|
3239
|
-
g === 1 ? (l(!0), n([]), C(1),
|
|
3262
|
+
g === 1 ? (l(!0), n([]), C(1), he(!0)) : O(!0);
|
|
3240
3263
|
try {
|
|
3241
|
-
const
|
|
3264
|
+
const v = await R.getInstance().messages.getMessages({
|
|
3242
3265
|
conversationId: c.id,
|
|
3243
3266
|
limit: re,
|
|
3244
3267
|
offset: (g - 1) * re
|
|
3245
|
-
}), S =
|
|
3268
|
+
}), S = v.sort(
|
|
3246
3269
|
(k, _) => new Date(k.timestamp).getTime() - new Date(_.timestamp).getTime()
|
|
3247
3270
|
);
|
|
3248
|
-
f && g > 1 ? n((k) => [...S, ...k]) : n(S),
|
|
3271
|
+
f && g > 1 ? n((k) => [...S, ...k]) : n(S), he(v.length === re), C(g);
|
|
3249
3272
|
} catch {
|
|
3250
3273
|
z.error(w("error_load_messages"));
|
|
3251
3274
|
} finally {
|
|
3252
|
-
l(!1),
|
|
3275
|
+
l(!1), O(!1);
|
|
3253
3276
|
}
|
|
3254
3277
|
}
|
|
3255
|
-
},
|
|
3278
|
+
}, Je = async (g) => {
|
|
3256
3279
|
if (g.preventDefault(), !c || !o.trim() || B) {
|
|
3257
3280
|
B && z.error(w("you_are_blocked"));
|
|
3258
3281
|
return;
|
|
@@ -3264,7 +3287,7 @@ const Vt = ({ conversation: c, currentUser: e, onClose: t, onBack: a }) => {
|
|
|
3264
3287
|
} catch {
|
|
3265
3288
|
r(f), z.error(w("error_send_message"));
|
|
3266
3289
|
}
|
|
3267
|
-
},
|
|
3290
|
+
}, Qe = async (g) => {
|
|
3268
3291
|
if (!c) return;
|
|
3269
3292
|
const f = `temp_${Date.now()}`, b = {
|
|
3270
3293
|
id: f,
|
|
@@ -3286,10 +3309,10 @@ const Vt = ({ conversation: c, currentUser: e, onClose: t, onBack: a }) => {
|
|
|
3286
3309
|
mimeType: g.type
|
|
3287
3310
|
}
|
|
3288
3311
|
};
|
|
3289
|
-
n((
|
|
3312
|
+
n((v) => [...v, b]), p((v) => ({ ...v, [f]: 0 }));
|
|
3290
3313
|
try {
|
|
3291
3314
|
h(!0);
|
|
3292
|
-
const
|
|
3315
|
+
const v = R.getInstance(), S = v.media.getFileTypeCategory(g.type), k = await v.media.uploadMedia({
|
|
3293
3316
|
file: g,
|
|
3294
3317
|
type: S,
|
|
3295
3318
|
conversationId: c.id,
|
|
@@ -3306,7 +3329,7 @@ const Vt = ({ conversation: c, currentUser: e, onClose: t, onBack: a }) => {
|
|
|
3306
3329
|
fileSize: k.fileSize,
|
|
3307
3330
|
mimeType: k.mimeType || g.type
|
|
3308
3331
|
};
|
|
3309
|
-
await
|
|
3332
|
+
await v.messages.sendMessageWithOptions({
|
|
3310
3333
|
conversationId: c.id,
|
|
3311
3334
|
content: `${g.name}`,
|
|
3312
3335
|
type: _,
|
|
@@ -3317,15 +3340,15 @@ const Vt = ({ conversation: c, currentUser: e, onClose: t, onBack: a }) => {
|
|
|
3317
3340
|
return delete L[f], L;
|
|
3318
3341
|
});
|
|
3319
3342
|
}, 200), z.success(w("file_sent_successfully"));
|
|
3320
|
-
} catch (
|
|
3343
|
+
} catch (v) {
|
|
3321
3344
|
n((S) => S.filter((k) => k.id !== f)), p((S) => {
|
|
3322
3345
|
const k = { ...S };
|
|
3323
3346
|
return delete k[f], k;
|
|
3324
|
-
}), z.error(w("error_file_upload") + ": " + (
|
|
3347
|
+
}), z.error(w("error_file_upload") + ": " + (v.message || w("error_unknown")));
|
|
3325
3348
|
} finally {
|
|
3326
3349
|
h(!1);
|
|
3327
3350
|
}
|
|
3328
|
-
},
|
|
3351
|
+
}, Ze = async () => {
|
|
3329
3352
|
if (x(!1), !(!c || !e) && window.confirm(w("block_user_confirm")))
|
|
3330
3353
|
try {
|
|
3331
3354
|
const g = R.getInstance();
|
|
@@ -3343,12 +3366,12 @@ const Vt = ({ conversation: c, currentUser: e, onClose: t, onBack: a }) => {
|
|
|
3343
3366
|
return;
|
|
3344
3367
|
}
|
|
3345
3368
|
await g.conversations.blockUserInChat(c.id, b);
|
|
3346
|
-
const
|
|
3347
|
-
S[b] = 1, c && (c.metadata = { ...
|
|
3369
|
+
const v = c.metadata || {}, S = v.blockedUsers || {};
|
|
3370
|
+
S[b] = 1, c && (c.metadata = { ...v, blockedUsers: S }), F(!0), z.success(w("user_blocked"));
|
|
3348
3371
|
} catch {
|
|
3349
3372
|
z.error(w("failed_to_block"));
|
|
3350
3373
|
}
|
|
3351
|
-
},
|
|
3374
|
+
}, De = async () => {
|
|
3352
3375
|
if (x(!1), !(!c || !e) && window.confirm(w("unblock_user_confirm")))
|
|
3353
3376
|
try {
|
|
3354
3377
|
const g = R.getInstance();
|
|
@@ -3362,27 +3385,27 @@ const Vt = ({ conversation: c, currentUser: e, onClose: t, onBack: a }) => {
|
|
|
3362
3385
|
return;
|
|
3363
3386
|
}
|
|
3364
3387
|
await g.conversations.unblockUserInChat(c.id, f);
|
|
3365
|
-
const b = c.metadata || {},
|
|
3366
|
-
delete
|
|
3388
|
+
const b = c.metadata || {}, v = b.blockedUsers || {};
|
|
3389
|
+
delete v[f], c && (c.metadata = { ...b, blockedUsers: v }), F(!1), z.success(w("user_unblocked"));
|
|
3367
3390
|
} catch {
|
|
3368
3391
|
z.error(w("failed_to_unblock"));
|
|
3369
3392
|
}
|
|
3370
3393
|
};
|
|
3371
|
-
return i && s.length === 0 ? /* @__PURE__ */ M("div", { className: "chat-window", children: [
|
|
3394
|
+
return i && s.length === 0 ? /* @__PURE__ */ u("div", { className: "chatsdk-root", children: /* @__PURE__ */ M("div", { className: "chat-window", children: [
|
|
3372
3395
|
/* @__PURE__ */ M("div", { className: "chat-header", children: [
|
|
3373
3396
|
/* @__PURE__ */ u("div", { className: "chat-header-left", children: /* @__PURE__ */ u("h3", { style: { margin: 0 }, children: w("loading") }) }),
|
|
3374
3397
|
/* @__PURE__ */ u("div", { className: "chat-header-actions", children: t && /* @__PURE__ */ u("button", { onClick: t, className: "close-button", children: "×" }) })
|
|
3375
3398
|
] }),
|
|
3376
3399
|
/* @__PURE__ */ u("div", { className: "loading-messages", children: w("loading_messages") })
|
|
3377
|
-
] }) : /* @__PURE__ */ M("div", { className: "chat-window", children: [
|
|
3400
|
+
] }) }) : /* @__PURE__ */ u("div", { className: "chatsdk-root", children: /* @__PURE__ */ M("div", { className: "chat-window", children: [
|
|
3378
3401
|
/* @__PURE__ */ M("div", { className: "chat-header", children: [
|
|
3379
3402
|
/* @__PURE__ */ M("div", { className: "chat-header-left", children: [
|
|
3380
3403
|
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:
|
|
3382
|
-
/* @__PURE__ */ u("div", { className: "chat-header-info", children: /* @__PURE__ */ u("h3", { className: "chat-participant-name", children:
|
|
3404
|
+
/* @__PURE__ */ u("div", { className: "chat-header-avatar", children: /* @__PURE__ */ u("div", { className: "avatar-placeholder", children: q.userName ? q.userName.charAt(0).toUpperCase() : "?" }) }),
|
|
3405
|
+
/* @__PURE__ */ u("div", { className: "chat-header-info", children: /* @__PURE__ */ u("h3", { className: "chat-participant-name", children: q.userName }) })
|
|
3383
3406
|
] }),
|
|
3384
3407
|
/* @__PURE__ */ M("div", { className: "chat-header-actions", children: [
|
|
3385
|
-
U && /* @__PURE__ */ u("button", { onClick:
|
|
3408
|
+
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
3409
|
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
3410
|
c && U && /* @__PURE__ */ M("div", { className: "chat-options-wrapper", children: [
|
|
3388
3411
|
/* @__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: [
|
|
@@ -3391,14 +3414,14 @@ const Vt = ({ conversation: c, currentUser: e, onClose: t, onBack: a }) => {
|
|
|
3391
3414
|
/* @__PURE__ */ u("circle", { cx: "12", cy: "19", r: "2" })
|
|
3392
3415
|
] }) }),
|
|
3393
3416
|
N && /* @__PURE__ */ M("div", { className: "chat-options-menu", children: [
|
|
3394
|
-
!B && !
|
|
3417
|
+
!B && !E && /* @__PURE__ */ M("button", { onClick: Ze, className: "danger", children: [
|
|
3395
3418
|
/* @__PURE__ */ M("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
|
|
3396
3419
|
/* @__PURE__ */ u("circle", { cx: "12", cy: "12", r: "10" }),
|
|
3397
3420
|
/* @__PURE__ */ u("line", { x1: "4.93", y1: "4.93", x2: "19.07", y2: "19.07" })
|
|
3398
3421
|
] }),
|
|
3399
3422
|
w("block_user")
|
|
3400
3423
|
] }),
|
|
3401
|
-
|
|
3424
|
+
E && /* @__PURE__ */ M("button", { onClick: De, children: [
|
|
3402
3425
|
/* @__PURE__ */ M("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
|
|
3403
3426
|
/* @__PURE__ */ u("circle", { cx: "12", cy: "12", r: "10" }),
|
|
3404
3427
|
/* @__PURE__ */ u("path", { d: "M2 12h20" })
|
|
@@ -3409,26 +3432,26 @@ const Vt = ({ conversation: c, currentUser: e, onClose: t, onBack: a }) => {
|
|
|
3409
3432
|
] })
|
|
3410
3433
|
] })
|
|
3411
3434
|
] }),
|
|
3412
|
-
|
|
3413
|
-
|
|
3435
|
+
q.productName && /* @__PURE__ */ M("div", { className: "chat-product-bar", children: [
|
|
3436
|
+
q.productImage && /* @__PURE__ */ u("img", { src: q.productImage, alt: q.productName }),
|
|
3414
3437
|
/* @__PURE__ */ M("div", { className: "chat-product-bar-info", children: [
|
|
3415
|
-
/* @__PURE__ */ u("p", { className: "chat-product-bar-name", children:
|
|
3416
|
-
((
|
|
3417
|
-
|
|
3438
|
+
/* @__PURE__ */ u("p", { className: "chat-product-bar-name", children: q.productName }),
|
|
3439
|
+
((Ee = q.productMetadata) == null ? void 0 : Ee.price) && /* @__PURE__ */ M("p", { className: "chat-product-bar-price", children: [
|
|
3440
|
+
q.productMetadata.price,
|
|
3418
3441
|
" ",
|
|
3419
|
-
|
|
3442
|
+
q.productMetadata.currency || "QAR"
|
|
3420
3443
|
] })
|
|
3421
3444
|
] })
|
|
3422
3445
|
] }),
|
|
3423
|
-
/* @__PURE__ */ M("div", { className: "chat-messages", ref: $, onScroll:
|
|
3446
|
+
/* @__PURE__ */ M("div", { className: "chat-messages", ref: $, onScroll: Ge, onClick: () => x(!1), children: [
|
|
3424
3447
|
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(
|
|
3448
|
+
i ? /* @__PURE__ */ u("div", { className: "loading-messages", children: w("loading_messages") }) : /* @__PURE__ */ M(et, { children: [
|
|
3426
3449
|
s.map((g, f) => {
|
|
3427
|
-
var b,
|
|
3428
|
-
return /* @__PURE__ */ M(
|
|
3429
|
-
|
|
3450
|
+
var b, v, S, k, _, I, A, L, Z, Ue;
|
|
3451
|
+
return /* @__PURE__ */ M(tt.Fragment, { children: [
|
|
3452
|
+
qe(g, f) && /* @__PURE__ */ M("div", { className: "date-divider", "data-date": ye(g.timestamp), children: [
|
|
3430
3453
|
/* @__PURE__ */ u("div", { className: "date-divider-line" }),
|
|
3431
|
-
/* @__PURE__ */ u("span", { className: "date-divider-text", children:
|
|
3454
|
+
/* @__PURE__ */ u("span", { className: "date-divider-text", children: ye(g.timestamp) }),
|
|
3432
3455
|
/* @__PURE__ */ u("div", { className: "date-divider-line" })
|
|
3433
3456
|
] }),
|
|
3434
3457
|
/* @__PURE__ */ u("div", { className: `message ${g.senderId === e.id ? "sent" : "received"}`, children: /* @__PURE__ */ M("div", { className: "message-content", children: [
|
|
@@ -3437,12 +3460,12 @@ const Vt = ({ conversation: c, currentUser: e, onClose: t, onBack: a }) => {
|
|
|
3437
3460
|
/* @__PURE__ */ u(
|
|
3438
3461
|
"img",
|
|
3439
3462
|
{
|
|
3440
|
-
src: g.isUploading ? g.localFileUri : (
|
|
3463
|
+
src: g.isUploading ? g.localFileUri : (v = g.metadata) == null ? void 0 : v.fileUrl,
|
|
3441
3464
|
alt: ((S = g.metadata) == null ? void 0 : S.fileName) || w("image"),
|
|
3442
3465
|
className: g.isUploading ? "uploading-image" : "",
|
|
3443
3466
|
onClick: () => {
|
|
3444
|
-
var
|
|
3445
|
-
return !g.isUploading && ((
|
|
3467
|
+
var Fe;
|
|
3468
|
+
return !g.isUploading && ((Fe = g.metadata) == null ? void 0 : Fe.fileUrl) && window.open(g.metadata.fileUrl, "_blank");
|
|
3446
3469
|
}
|
|
3447
3470
|
}
|
|
3448
3471
|
),
|
|
@@ -3458,7 +3481,7 @@ const Vt = ({ conversation: c, currentUser: e, onClose: t, onBack: a }) => {
|
|
|
3458
3481
|
/* File Message */
|
|
3459
3482
|
/* @__PURE__ */ M("div", { className: "message-attachment file-attachment", children: [
|
|
3460
3483
|
/* @__PURE__ */ M("div", { className: "file-info", children: [
|
|
3461
|
-
/* @__PURE__ */ u("div", { className: "file-icon", children:
|
|
3484
|
+
/* @__PURE__ */ u("div", { className: "file-icon", children: Ve((A = g.metadata) == null ? void 0 : A.mimeType) }),
|
|
3462
3485
|
/* @__PURE__ */ M("div", { className: "file-details", children: [
|
|
3463
3486
|
/* @__PURE__ */ u("div", { className: "file-name", children: ((L = g.metadata) == null ? void 0 : L.fileName) || w("file") }),
|
|
3464
3487
|
/* @__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 +3490,7 @@ const Vt = ({ conversation: c, currentUser: e, onClose: t, onBack: a }) => {
|
|
|
3467
3490
|
/* @__PURE__ */ u(
|
|
3468
3491
|
"a",
|
|
3469
3492
|
{
|
|
3470
|
-
href: ((
|
|
3493
|
+
href: ((Ue = g.metadata) == null ? void 0 : Ue.fileUrl) || "#",
|
|
3471
3494
|
target: "_blank",
|
|
3472
3495
|
rel: "noopener noreferrer",
|
|
3473
3496
|
className: "download-btn",
|
|
@@ -3480,7 +3503,7 @@ const Vt = ({ conversation: c, currentUser: e, onClose: t, onBack: a }) => {
|
|
|
3480
3503
|
g.content
|
|
3481
3504
|
),
|
|
3482
3505
|
/* @__PURE__ */ M("div", { className: "message-footer", children: [
|
|
3483
|
-
/* @__PURE__ */ u("span", { className: "message-time", children:
|
|
3506
|
+
/* @__PURE__ */ u("span", { className: "message-time", children: We(g.timestamp) }),
|
|
3484
3507
|
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
3508
|
/* @__PURE__ */ u("polyline", { points: "1 13 5 17 11 9" }),
|
|
3486
3509
|
/* @__PURE__ */ u("polyline", { points: "7 13 11 17 17 9" })
|
|
@@ -3492,23 +3515,23 @@ const Vt = ({ conversation: c, currentUser: e, onClose: t, onBack: a }) => {
|
|
|
3492
3515
|
/* @__PURE__ */ u("div", { ref: Q })
|
|
3493
3516
|
] })
|
|
3494
3517
|
] }),
|
|
3495
|
-
|
|
3496
|
-
/* @__PURE__ */ u("div", { className: "blocked-title", children: w("you_have_blocked", { userName:
|
|
3518
|
+
E && /* @__PURE__ */ M("div", { className: "blocked-ui blocked-by-me", children: [
|
|
3519
|
+
/* @__PURE__ */ u("div", { className: "blocked-title", children: w("you_have_blocked", { userName: q.userName || w("unknown_user") }) }),
|
|
3497
3520
|
/* @__PURE__ */ u("div", { className: "blocked-message", children: w("you_have_blocked_submessage") }),
|
|
3498
|
-
/* @__PURE__ */ u("button", { onClick:
|
|
3521
|
+
/* @__PURE__ */ u("button", { onClick: De, className: "unblock-btn", children: w("unblock_user") })
|
|
3499
3522
|
] }),
|
|
3500
|
-
B && !
|
|
3501
|
-
/* @__PURE__ */ u("div", { className: "blocked-title", children: w("blocked_by_user", { userName:
|
|
3523
|
+
B && !E && /* @__PURE__ */ M("div", { className: "blocked-ui blocked-by-other", children: [
|
|
3524
|
+
/* @__PURE__ */ u("div", { className: "blocked-title", children: w("blocked_by_user", { userName: q.userName || w("unknown_user") }) }),
|
|
3502
3525
|
/* @__PURE__ */ u("div", { className: "blocked-message", children: w("blocked_by_user_submessage") })
|
|
3503
3526
|
] }),
|
|
3504
|
-
!
|
|
3527
|
+
!E && !B && /* @__PURE__ */ M("form", { onSubmit: Je, className: "chat-input", children: [
|
|
3505
3528
|
/* @__PURE__ */ u(
|
|
3506
3529
|
"button",
|
|
3507
3530
|
{
|
|
3508
3531
|
type: "button",
|
|
3509
3532
|
onClick: () => {
|
|
3510
3533
|
var g;
|
|
3511
|
-
return (g =
|
|
3534
|
+
return (g = le.current) == null ? void 0 : g.click();
|
|
3512
3535
|
},
|
|
3513
3536
|
disabled: i || d || B,
|
|
3514
3537
|
className: "attachment-btn",
|
|
@@ -3519,14 +3542,14 @@ const Vt = ({ conversation: c, currentUser: e, onClose: t, onBack: a }) => {
|
|
|
3519
3542
|
/* @__PURE__ */ u(
|
|
3520
3543
|
"input",
|
|
3521
3544
|
{
|
|
3522
|
-
ref:
|
|
3545
|
+
ref: le,
|
|
3523
3546
|
type: "file",
|
|
3524
3547
|
style: { display: "none" },
|
|
3525
3548
|
accept: "image/*,video/*,audio/*,.pdf,.doc,.docx,.txt",
|
|
3526
3549
|
onChange: (g) => {
|
|
3527
3550
|
var b;
|
|
3528
3551
|
const f = (b = g.target.files) == null ? void 0 : b[0];
|
|
3529
|
-
f && (
|
|
3552
|
+
f && (Qe(f), g.target.value = "");
|
|
3530
3553
|
}
|
|
3531
3554
|
}
|
|
3532
3555
|
),
|
|
@@ -3542,131 +3565,133 @@ const Vt = ({ conversation: c, currentUser: e, onClose: t, onBack: a }) => {
|
|
|
3542
3565
|
),
|
|
3543
3566
|
/* @__PURE__ */ u("button", { type: "submit", disabled: !o.trim() || i || d || B, className: "send-btn", children: w(d ? "uploading" : "send") })
|
|
3544
3567
|
] })
|
|
3545
|
-
] });
|
|
3546
|
-
},
|
|
3568
|
+
] }) });
|
|
3569
|
+
}, ia = ({
|
|
3547
3570
|
currentUser: c,
|
|
3548
3571
|
onSelectConversation: e,
|
|
3549
3572
|
selectedConversationId: t
|
|
3550
3573
|
}) => {
|
|
3551
|
-
const [a, s] = T([]), [n, o] = T(!1), [r, i] = T(""), l =
|
|
3552
|
-
|
|
3574
|
+
const [a, s] = T([]), [n, o] = T(!1), [r, i] = T(""), l = de(t), d = de(c.id);
|
|
3575
|
+
P(() => {
|
|
3576
|
+
Be(), we();
|
|
3577
|
+
}, []), P(() => {
|
|
3553
3578
|
l.current = t;
|
|
3554
|
-
}, [t]),
|
|
3579
|
+
}, [t]), P(() => {
|
|
3555
3580
|
d.current = c.id;
|
|
3556
|
-
}, [c.id]),
|
|
3581
|
+
}, [c.id]), P(() => {
|
|
3557
3582
|
m();
|
|
3558
|
-
}, []),
|
|
3583
|
+
}, []), P(() => {
|
|
3559
3584
|
c && (s([]), m());
|
|
3560
|
-
}, [c.id]),
|
|
3585
|
+
}, [c.id]), P(() => {
|
|
3561
3586
|
var J;
|
|
3562
|
-
const
|
|
3563
|
-
const F =
|
|
3587
|
+
const y = R.getInstance(), C = (E) => {
|
|
3588
|
+
const F = E.message, N = F.roomId || F.conversationId;
|
|
3564
3589
|
s(
|
|
3565
3590
|
(x) => x.map((K) => {
|
|
3566
3591
|
if (K.id === N) {
|
|
3567
|
-
const
|
|
3592
|
+
const W = F.senderId !== d.current, te = l.current !== N;
|
|
3568
3593
|
return {
|
|
3569
3594
|
...K,
|
|
3570
3595
|
lastMessage: F,
|
|
3571
|
-
unreadCount:
|
|
3596
|
+
unreadCount: W && te ? K.unreadCount + 1 : K.unreadCount
|
|
3572
3597
|
};
|
|
3573
3598
|
}
|
|
3574
3599
|
return K;
|
|
3575
|
-
}).sort((K,
|
|
3576
|
-
var Q,
|
|
3577
|
-
const te = ((Q = K.lastMessage) == null ? void 0 : Q.timestamp) || K.createdAt, ae = ((
|
|
3600
|
+
}).sort((K, W) => {
|
|
3601
|
+
var Q, le;
|
|
3602
|
+
const te = ((Q = K.lastMessage) == null ? void 0 : Q.timestamp) || K.createdAt, ae = ((le = W.lastMessage) == null ? void 0 : le.timestamp) || W.createdAt;
|
|
3578
3603
|
return new Date(ae).getTime() - new Date(te).getTime();
|
|
3579
3604
|
})
|
|
3580
3605
|
), F.senderId !== d.current && l.current === N && R.getInstance().chatUsers.markMessageRead(F.id).then(() => {
|
|
3581
3606
|
s(
|
|
3582
3607
|
(K) => K.map(
|
|
3583
|
-
(
|
|
3608
|
+
(W) => W.id === N ? { ...W, unreadCount: 0 } : W
|
|
3584
3609
|
)
|
|
3585
3610
|
);
|
|
3586
3611
|
}).catch((K) => {
|
|
3587
3612
|
console.warn("Failed to auto-mark message as read:", K);
|
|
3588
3613
|
});
|
|
3589
|
-
},
|
|
3590
|
-
var K,
|
|
3591
|
-
const F =
|
|
3614
|
+
}, j = (E) => {
|
|
3615
|
+
var K, W, te, ae;
|
|
3616
|
+
const F = E.conversationId || ((K = E.conversation) == null ? void 0 : K.id) || ((W = E.conversation) == null ? void 0 : W.conversationId);
|
|
3592
3617
|
if (!F) return;
|
|
3593
|
-
const N =
|
|
3618
|
+
const N = E.lastMessage || ((te = E.conversation) == null ? void 0 : te.lastMessage), x = (ae = E.conversation) == null ? void 0 : ae.unreadCount;
|
|
3594
3619
|
s((Q) => Q.some(($) => $.id === F) ? Q.map(($) => {
|
|
3595
3620
|
if ($.id !== F) return $;
|
|
3596
|
-
const
|
|
3621
|
+
const Y = l.current === F, re = d.current;
|
|
3597
3622
|
if (typeof x == "number")
|
|
3598
3623
|
return {
|
|
3599
3624
|
...$,
|
|
3600
3625
|
lastMessage: N || $.lastMessage,
|
|
3601
|
-
unreadCount:
|
|
3626
|
+
unreadCount: Y ? 0 : x
|
|
3602
3627
|
};
|
|
3603
|
-
const oe = (N == null ? void 0 : N.senderId) && N.senderId !== re, U = !!N && oe && !
|
|
3628
|
+
const oe = (N == null ? void 0 : N.senderId) && N.senderId !== re, U = !!N && oe && !Y;
|
|
3604
3629
|
return {
|
|
3605
3630
|
...$,
|
|
3606
3631
|
lastMessage: N || $.lastMessage,
|
|
3607
|
-
unreadCount:
|
|
3632
|
+
unreadCount: Y ? 0 : U ? $.unreadCount + 1 : $.unreadCount
|
|
3608
3633
|
};
|
|
3609
|
-
}).sort(($,
|
|
3610
|
-
var U,
|
|
3611
|
-
const re = ((U = $.lastMessage) == null ? void 0 : U.timestamp) || $.createdAt, oe = ((
|
|
3634
|
+
}).sort(($, Y) => {
|
|
3635
|
+
var U, ke;
|
|
3636
|
+
const re = ((U = $.lastMessage) == null ? void 0 : U.timestamp) || $.createdAt, oe = ((ke = Y.lastMessage) == null ? void 0 : ke.timestamp) || Y.createdAt;
|
|
3612
3637
|
return new Date(oe).getTime() - new Date(re).getTime();
|
|
3613
3638
|
}) : (m(), Q));
|
|
3614
|
-
},
|
|
3615
|
-
const F =
|
|
3639
|
+
}, H = (E) => {
|
|
3640
|
+
const F = E.conversationId || E.roomId;
|
|
3616
3641
|
F && s(
|
|
3617
3642
|
(N) => N.map(
|
|
3618
3643
|
(x) => x.id === F ? { ...x, unreadCount: 0 } : x
|
|
3619
3644
|
)
|
|
3620
3645
|
);
|
|
3621
|
-
}, B = (
|
|
3622
|
-
const F =
|
|
3646
|
+
}, B = (E) => {
|
|
3647
|
+
const F = E.roomId || E.conversationId;
|
|
3623
3648
|
F && s(
|
|
3624
3649
|
(N) => N.map(
|
|
3625
3650
|
(x) => x.id === F ? { ...x, unreadCount: 0 } : x
|
|
3626
3651
|
)
|
|
3627
3652
|
);
|
|
3628
3653
|
};
|
|
3629
|
-
return
|
|
3630
|
-
var
|
|
3631
|
-
|
|
3654
|
+
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)), () => {
|
|
3655
|
+
var E;
|
|
3656
|
+
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
3657
|
};
|
|
3633
3658
|
}, []);
|
|
3634
|
-
const h = async (
|
|
3659
|
+
const h = async (y) => {
|
|
3635
3660
|
try {
|
|
3636
|
-
if (
|
|
3661
|
+
if (y.unreadCount > 0) {
|
|
3637
3662
|
const C = R.getInstance();
|
|
3638
|
-
await C.chatUsers.markRoomMessagesRead(
|
|
3663
|
+
await C.chatUsers.markRoomMessagesRead(y.id), C.chatUsers.startViewingConversation(y.id);
|
|
3639
3664
|
}
|
|
3640
|
-
e(
|
|
3665
|
+
e(y);
|
|
3641
3666
|
} catch (C) {
|
|
3642
|
-
console.error("Failed to mark conversation as read:", C), e(
|
|
3667
|
+
console.error("Failed to mark conversation as read:", C), e(y);
|
|
3643
3668
|
}
|
|
3644
3669
|
}, m = async () => {
|
|
3645
3670
|
o(!0);
|
|
3646
3671
|
try {
|
|
3647
3672
|
const C = await R.getInstance().chatUsers.getConversations();
|
|
3648
|
-
let
|
|
3649
|
-
C && typeof C == "object" && !Array.isArray(C) && (
|
|
3673
|
+
let j = C;
|
|
3674
|
+
C && typeof C == "object" && !Array.isArray(C) && (j = C.conversations || C.data || []), s(Array.isArray(j) ? j : []);
|
|
3650
3675
|
} catch {
|
|
3651
3676
|
z.error(w("error_load_conversations"));
|
|
3652
3677
|
} finally {
|
|
3653
3678
|
o(!1);
|
|
3654
3679
|
}
|
|
3655
|
-
}, p = (
|
|
3656
|
-
const C = p(
|
|
3680
|
+
}, p = (y) => y.participants.find((C) => C.id !== c.id), D = (y) => {
|
|
3681
|
+
const C = p(y);
|
|
3657
3682
|
return (C == null ? void 0 : C.name) || w("unknown_user");
|
|
3658
|
-
},
|
|
3683
|
+
}, O = (y) => {
|
|
3659
3684
|
var C;
|
|
3660
|
-
return ((C =
|
|
3661
|
-
},
|
|
3662
|
-
const C = new Date(
|
|
3663
|
-
return
|
|
3664
|
-
},
|
|
3665
|
-
var J,
|
|
3666
|
-
const C = r.toLowerCase().trim(),
|
|
3667
|
-
return
|
|
3685
|
+
return ((C = y.lastMessage) == null ? void 0 : C.content) || w("no_messages_yet");
|
|
3686
|
+
}, Le = (y) => {
|
|
3687
|
+
const C = new Date(y), H = ((/* @__PURE__ */ new Date()).getTime() - C.getTime()) / (1e3 * 60 * 60), B = H / 24;
|
|
3688
|
+
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()]}`;
|
|
3689
|
+
}, he = r.trim() ? a.filter((y) => {
|
|
3690
|
+
var J, E;
|
|
3691
|
+
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();
|
|
3692
|
+
return j.includes(C) || H.includes(C) || B.includes(C);
|
|
3668
3693
|
}) : a;
|
|
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: [
|
|
3694
|
+
return n ? /* @__PURE__ */ u("div", { className: "chatsdk-root", children: /* @__PURE__ */ u("div", { className: "conversation-list loading", children: /* @__PURE__ */ u("div", { className: "loading-spinner", children: w("loading_conversations") }) }) }) : /* @__PURE__ */ u("div", { className: "chatsdk-root", children: /* @__PURE__ */ M("div", { className: "conversation-list", children: [
|
|
3670
3695
|
/* @__PURE__ */ u("div", { className: "conversation-list-header", children: /* @__PURE__ */ u("h3", { children: w("conversations_title") }) }),
|
|
3671
3696
|
/* @__PURE__ */ u("div", { className: "conversation-search", children: /* @__PURE__ */ M("div", { className: "conversation-search-input", children: [
|
|
3672
3697
|
/* @__PURE__ */ u("span", { className: "search-icon", children: /* @__PURE__ */ M("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
@@ -3677,60 +3702,60 @@ const Vt = ({ conversation: c, currentUser: e, onClose: t, onBack: a }) => {
|
|
|
3677
3702
|
"input",
|
|
3678
3703
|
{
|
|
3679
3704
|
value: r,
|
|
3680
|
-
onChange: (
|
|
3705
|
+
onChange: (y) => i(y.target.value),
|
|
3681
3706
|
type: "text",
|
|
3682
3707
|
placeholder: w("search") || "Search"
|
|
3683
3708
|
}
|
|
3684
3709
|
)
|
|
3685
3710
|
] }) }),
|
|
3686
|
-
/* @__PURE__ */ u("div", { className: "conversations", children:
|
|
3711
|
+
/* @__PURE__ */ u("div", { className: "conversations", children: he.length === 0 ? /* @__PURE__ */ M("div", { className: "empty-conversations", children: [
|
|
3687
3712
|
/* @__PURE__ */ u("p", { children: r ? w("no_search_results") || "No results found" : w("no_conversations_title") }),
|
|
3688
3713
|
!r && /* @__PURE__ */ u("p", { children: w("no_conversations_message") })
|
|
3689
|
-
] }) :
|
|
3690
|
-
var
|
|
3691
|
-
const C = t ===
|
|
3714
|
+
] }) : he.map((y) => {
|
|
3715
|
+
var j;
|
|
3716
|
+
const C = t === y.id;
|
|
3692
3717
|
return /* @__PURE__ */ M(
|
|
3693
3718
|
"div",
|
|
3694
3719
|
{
|
|
3695
|
-
className: `conversation-item ${C ? "selected" : ""} ${
|
|
3696
|
-
onClick: () => h(
|
|
3720
|
+
className: `conversation-item ${C ? "selected" : ""} ${y.unreadCount > 0 ? "has-unread" : ""}`,
|
|
3721
|
+
onClick: () => h(y),
|
|
3697
3722
|
children: [
|
|
3698
|
-
/* @__PURE__ */ u("div", { className: "conversation-avatar", children: (
|
|
3723
|
+
/* @__PURE__ */ u("div", { className: "conversation-avatar", children: (j = y.productContext) != null && j.productImage ? /* @__PURE__ */ u(
|
|
3699
3724
|
"img",
|
|
3700
3725
|
{
|
|
3701
|
-
src:
|
|
3702
|
-
alt:
|
|
3726
|
+
src: y.productContext.productImage,
|
|
3727
|
+
alt: y.productContext.productName,
|
|
3703
3728
|
className: "product-image"
|
|
3704
3729
|
}
|
|
3705
|
-
) : /* @__PURE__ */ u("div", { className: "avatar-placeholder", children:
|
|
3730
|
+
) : /* @__PURE__ */ u("div", { className: "avatar-placeholder", children: D(y).charAt(0).toUpperCase() }) }),
|
|
3706
3731
|
/* @__PURE__ */ M("div", { className: "conversation-content", children: [
|
|
3707
3732
|
/* @__PURE__ */ M("div", { className: "conversation-header", children: [
|
|
3708
|
-
/* @__PURE__ */ u("div", { className: "conversation-title-wrapper", children: /* @__PURE__ */ u("h4", { className: "conversation-participant-name", children:
|
|
3709
|
-
|
|
3733
|
+
/* @__PURE__ */ u("div", { className: "conversation-title-wrapper", children: /* @__PURE__ */ u("h4", { className: "conversation-participant-name", children: D(y) }) }),
|
|
3734
|
+
y.lastMessage && /* @__PURE__ */ u("span", { className: "conversation-time", children: Le(y.lastMessage.timestamp) })
|
|
3710
3735
|
] }),
|
|
3711
3736
|
/* @__PURE__ */ M("div", { className: "conversation-details", children: [
|
|
3712
|
-
/* @__PURE__ */ u("p", { className: "conversation-last-message", children:
|
|
3713
|
-
|
|
3737
|
+
/* @__PURE__ */ u("p", { className: "conversation-last-message", children: O(y) }),
|
|
3738
|
+
y.unreadCount > 0 && /* @__PURE__ */ u("span", { className: "unread-badge", children: y.unreadCount })
|
|
3714
3739
|
] })
|
|
3715
3740
|
] })
|
|
3716
3741
|
]
|
|
3717
3742
|
},
|
|
3718
|
-
|
|
3743
|
+
y.id
|
|
3719
3744
|
);
|
|
3720
3745
|
}) })
|
|
3721
|
-
] });
|
|
3722
|
-
},
|
|
3746
|
+
] }) });
|
|
3747
|
+
}, Jt = () => {
|
|
3723
3748
|
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
|
-
|
|
3749
|
+
P(() => {
|
|
3725
3750
|
if (typeof window > "u" || !window.matchMedia) return;
|
|
3726
3751
|
const r = window.matchMedia("(prefers-color-scheme: dark)"), i = (l) => {
|
|
3727
3752
|
a(l.matches ? "dark" : "light");
|
|
3728
3753
|
};
|
|
3729
3754
|
return r.addEventListener("change", i), () => r.removeEventListener("change", i);
|
|
3730
|
-
}, []),
|
|
3731
|
-
|
|
3732
|
-
|
|
3733
|
-
|
|
3755
|
+
}, []), P(() => {
|
|
3756
|
+
typeof window > "u" || Se((r) => {
|
|
3757
|
+
r.classList.remove("theme-light", "theme-dark"), r.removeAttribute("data-theme"), r.classList.add(`theme-${s}`), r.setAttribute("data-theme", s);
|
|
3758
|
+
});
|
|
3734
3759
|
}, [s]);
|
|
3735
3760
|
const n = (r) => {
|
|
3736
3761
|
e(r), typeof window < "u" && localStorage.setItem("chatSDK-theme", r);
|
|
@@ -3743,19 +3768,19 @@ const Vt = ({ conversation: c, currentUser: e, onClose: t, onBack: a }) => {
|
|
|
3743
3768
|
n(c === "auto" ? t === "light" ? "dark" : "light" : s === "light" ? "dark" : "light");
|
|
3744
3769
|
}
|
|
3745
3770
|
};
|
|
3746
|
-
},
|
|
3747
|
-
const e =
|
|
3748
|
-
return /* @__PURE__ */ u(
|
|
3749
|
-
},
|
|
3750
|
-
const c =
|
|
3771
|
+
}, $e = at(void 0), ca = ({ children: c }) => {
|
|
3772
|
+
const e = Jt();
|
|
3773
|
+
return /* @__PURE__ */ u($e.Provider, { value: e, children: c });
|
|
3774
|
+
}, Qt = () => {
|
|
3775
|
+
const c = st($e);
|
|
3751
3776
|
if (!c)
|
|
3752
3777
|
throw new Error("useThemeContext must be used within a ThemeProvider");
|
|
3753
3778
|
return c;
|
|
3754
|
-
},
|
|
3779
|
+
}, la = ({
|
|
3755
3780
|
className: c = "",
|
|
3756
3781
|
showLabel: e = !1
|
|
3757
3782
|
}) => {
|
|
3758
|
-
const { theme: t, actualTheme: a, setTheme: s } =
|
|
3783
|
+
const { theme: t, actualTheme: a, setTheme: s } = Qt(), n = () => {
|
|
3759
3784
|
switch (t) {
|
|
3760
3785
|
case "light":
|
|
3761
3786
|
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 +3835,13 @@ const Vt = ({ conversation: c, currentUser: e, onClose: t, onBack: a }) => {
|
|
|
3810
3835
|
]
|
|
3811
3836
|
}
|
|
3812
3837
|
);
|
|
3813
|
-
},
|
|
3838
|
+
}, da = () => {
|
|
3814
3839
|
var s;
|
|
3815
3840
|
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
|
-
|
|
3817
|
-
},
|
|
3841
|
+
Se((n) => {
|
|
3842
|
+
n.classList.add(`theme-${a}`), n.setAttribute("data-theme", a);
|
|
3843
|
+
});
|
|
3844
|
+
}, ga = {
|
|
3818
3845
|
// Material Design 3 Primary Colors
|
|
3819
3846
|
primary: {
|
|
3820
3847
|
main: "#2196F3",
|
|
@@ -3898,7 +3925,7 @@ const Vt = ({ conversation: c, currentUser: e, onClose: t, onBack: a }) => {
|
|
|
3898
3925
|
black: "#000000",
|
|
3899
3926
|
transparent: "transparent"
|
|
3900
3927
|
}
|
|
3901
|
-
},
|
|
3928
|
+
}, ha = {
|
|
3902
3929
|
primary: {
|
|
3903
3930
|
main: "#90CAF9",
|
|
3904
3931
|
onPrimary: "#0D47A1",
|
|
@@ -3946,9 +3973,9 @@ const Vt = ({ conversation: c, currentUser: e, onClose: t, onBack: a }) => {
|
|
|
3946
3973
|
timestamp: "#BDBDBD",
|
|
3947
3974
|
primaryText: "#FFFFFF"
|
|
3948
3975
|
}
|
|
3949
|
-
},
|
|
3976
|
+
}, ua = {
|
|
3950
3977
|
async init(c) {
|
|
3951
|
-
const { ChatSDK: e } = await Promise.resolve().then(() =>
|
|
3978
|
+
const { ChatSDK: e } = await Promise.resolve().then(() => ht);
|
|
3952
3979
|
return e.getInstance().init(c);
|
|
3953
3980
|
},
|
|
3954
3981
|
formatFileSize(c) {
|
|
@@ -3962,28 +3989,32 @@ const Vt = ({ conversation: c, currentUser: e, onClose: t, onBack: a }) => {
|
|
|
3962
3989
|
}
|
|
3963
3990
|
};
|
|
3964
3991
|
export {
|
|
3965
|
-
|
|
3992
|
+
nt as AuthManager,
|
|
3966
3993
|
R as ChatSDK,
|
|
3967
|
-
|
|
3968
|
-
|
|
3969
|
-
|
|
3970
|
-
|
|
3971
|
-
|
|
3972
|
-
|
|
3973
|
-
|
|
3974
|
-
|
|
3975
|
-
|
|
3976
|
-
|
|
3977
|
-
|
|
3978
|
-
|
|
3979
|
-
|
|
3980
|
-
|
|
3981
|
-
|
|
3982
|
-
ra as
|
|
3983
|
-
|
|
3994
|
+
ua as ChatSDKHelpers,
|
|
3995
|
+
oa as ChatWindow,
|
|
3996
|
+
ia as ConversationList,
|
|
3997
|
+
it as ConversationManager,
|
|
3998
|
+
dt as EventManager,
|
|
3999
|
+
lt as MediaManager,
|
|
4000
|
+
ct as MessageManager,
|
|
4001
|
+
Ae as ParseUtils,
|
|
4002
|
+
gt as SocketManager,
|
|
4003
|
+
ca as ThemeProvider,
|
|
4004
|
+
la as ThemeToggle,
|
|
4005
|
+
ot as UserManager,
|
|
4006
|
+
we as applyLanguageToDOM,
|
|
4007
|
+
na as changeLanguage,
|
|
4008
|
+
ha as darkThemeConfig,
|
|
4009
|
+
ra as getCurrentLanguage,
|
|
4010
|
+
sa as getSDKRoot,
|
|
4011
|
+
Be as initializeI18n,
|
|
4012
|
+
da as initializeTheme,
|
|
4013
|
+
Yt as isRTL,
|
|
4014
|
+
aa as setSDKRoot,
|
|
3984
4015
|
w as t,
|
|
3985
|
-
|
|
3986
|
-
|
|
3987
|
-
|
|
4016
|
+
ga as themeConfig,
|
|
4017
|
+
Jt as useTheme,
|
|
4018
|
+
Qt as useThemeContext
|
|
3988
4019
|
};
|
|
3989
4020
|
//# sourceMappingURL=chatsdk-react.mjs.map
|