@channelhub/widget 0.1.9 → 0.1.11
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/ChannelHubChannels.d.ts.map +1 -1
- package/dist/LiveChatWidget.d.ts.map +1 -1
- package/dist/index.cjs +6 -6
- package/dist/index.js +414 -341
- package/package.json +1 -1
- package/src/ChannelHubChannels.tsx +106 -24
- package/src/LiveChatWidget.tsx +113 -4
- package/src/api.ts +1 -1
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as e, jsxs as n, Fragment as ie } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef as Pe, createElement as et, createContext as wt, useRef as J, useState as
|
|
2
|
+
import { forwardRef as Pe, createElement as et, createContext as wt, useRef as J, useState as g, useMemo as $e, useEffect as X, useCallback as we, useImperativeHandle as Bt, useContext as tt, Component as Lt } from "react";
|
|
3
3
|
import { createPortal as St } from "react-dom";
|
|
4
4
|
/**
|
|
5
5
|
* @license lucide-react v0.468.0 - ISC
|
|
@@ -39,8 +39,8 @@ const At = Pe(
|
|
|
39
39
|
absoluteStrokeWidth: o,
|
|
40
40
|
className: h = "",
|
|
41
41
|
children: S,
|
|
42
|
-
iconNode:
|
|
43
|
-
|
|
42
|
+
iconNode: b,
|
|
43
|
+
...$
|
|
44
44
|
}, w) => et(
|
|
45
45
|
"svg",
|
|
46
46
|
{
|
|
@@ -51,10 +51,10 @@ const At = Pe(
|
|
|
51
51
|
stroke: t,
|
|
52
52
|
strokeWidth: o ? Number(r) * 24 / Number(i) : r,
|
|
53
53
|
className: Ct("lucide", h),
|
|
54
|
-
|
|
54
|
+
...$
|
|
55
55
|
},
|
|
56
56
|
[
|
|
57
|
-
...
|
|
57
|
+
...b.map(([y, W]) => et(y, W)),
|
|
58
58
|
...Array.isArray(S) ? S : [S]
|
|
59
59
|
]
|
|
60
60
|
)
|
|
@@ -329,16 +329,16 @@ class it {
|
|
|
329
329
|
}, S = await fetch(`${this.apiUrl}${i}`, {
|
|
330
330
|
...r,
|
|
331
331
|
headers: h
|
|
332
|
-
}),
|
|
333
|
-
if (!S.ok) throw new Error((
|
|
334
|
-
return
|
|
332
|
+
}), b = await S.json().catch(() => null);
|
|
333
|
+
if (!S.ok) throw new Error((b == null ? void 0 : b.message) ?? `Request failed (${S.status})`);
|
|
334
|
+
return b;
|
|
335
335
|
}
|
|
336
336
|
getSessionMe() {
|
|
337
337
|
return this.request("/v1/auth/session/me");
|
|
338
338
|
}
|
|
339
339
|
assignConversation(i, r) {
|
|
340
340
|
return this.request(`/v1/conversations/${encodeURIComponent(i)}/assignee`, {
|
|
341
|
-
method: "
|
|
341
|
+
method: "PUT",
|
|
342
342
|
body: JSON.stringify({ agent: r })
|
|
343
343
|
});
|
|
344
344
|
}
|
|
@@ -398,16 +398,16 @@ class it {
|
|
|
398
398
|
connectSSE(i) {
|
|
399
399
|
const r = `${this.apiUrl}/v1/events?token=${encodeURIComponent(this.token)}`;
|
|
400
400
|
let o, h, S = !1;
|
|
401
|
-
const
|
|
402
|
-
o = new EventSource(r), o.addEventListener("message.new", (
|
|
403
|
-
i("message.new", JSON.parse(
|
|
404
|
-
}), o.addEventListener("conversation.updated", (
|
|
405
|
-
i("conversation.updated", JSON.parse(
|
|
401
|
+
const b = () => {
|
|
402
|
+
o = new EventSource(r), o.addEventListener("message.new", ($) => {
|
|
403
|
+
i("message.new", JSON.parse($.data));
|
|
404
|
+
}), o.addEventListener("conversation.updated", ($) => {
|
|
405
|
+
i("conversation.updated", JSON.parse($.data));
|
|
406
406
|
}), o.onerror = () => {
|
|
407
|
-
o.close(), S || (h = setTimeout(
|
|
407
|
+
o.close(), S || (h = setTimeout(b, 5e3));
|
|
408
408
|
};
|
|
409
409
|
};
|
|
410
|
-
return
|
|
410
|
+
return b(), () => {
|
|
411
411
|
S = !0, clearTimeout(h), o == null || o.close();
|
|
412
412
|
};
|
|
413
413
|
}
|
|
@@ -421,7 +421,7 @@ function Xt({ variant: t = "ghost", style: i, ...r }) {
|
|
|
421
421
|
function Yt({ style: t, ...i }) {
|
|
422
422
|
return /* @__PURE__ */ e("input", { ...i, style: { width: "100%", minWidth: 0, border: 0, outline: 0, background: "transparent", font: "inherit", ...t } });
|
|
423
423
|
}
|
|
424
|
-
const
|
|
424
|
+
const Tt = Pe(
|
|
425
425
|
({ children: t, style: i }, r) => /* @__PURE__ */ e("div", { ref: r, style: { minHeight: 0, overflowY: "auto", overscrollBehavior: "contain", ...i }, children: t })
|
|
426
426
|
), Jt = Pe(
|
|
427
427
|
function({ style: i, ...r }, o) {
|
|
@@ -469,7 +469,7 @@ const d = { ink: "#172033", muted: "#718096", line: "#e7ebf2", surface: "#f7f9fc
|
|
|
469
469
|
{ icon: "🍕", emojis: ["🍎", "🍊", "🍋", "🍇", "🍓", "🍒", "🥝", "🥑", "🍔", "🍕", "🌮", "🍜", "🍣", "🍦", "🎂", "🍰", "🧁", "☕", "🧋", "🥤", "🍺", "🥂", "🍾", "🧃", "🧊"] },
|
|
470
470
|
{ icon: "⚽", emojis: ["⚽", "🏀", "🏈", "⚾", "🎾", "🏐", "🏓", "🎮", "🎲", "🎯", "🎳", "🏆", "🥇", "🎖", "🎁", "🎉", "🎊", "🎈", "🎭", "🎨", "🎬", "🎵", "🎸", "🎹", "🎺", "🪗", "🎻"] },
|
|
471
471
|
{ icon: "🌍", emojis: ["🌍", "🌈", "⭐", "🌙", "☀️", "⛅", "🌊", "🔥", "💧", "🌿", "🌸", "🌺", "🌻", "🍀", "🌴", "🏔", "🏖", "🏕", "🌃", "🏙", "🌅", "🌄", "🌠", "🌌", "🌋", "🏝"] }
|
|
472
|
-
], st = wt(""),
|
|
472
|
+
], st = wt(""), Rt = wt("");
|
|
473
473
|
function Qt() {
|
|
474
474
|
try {
|
|
475
475
|
const t = new AudioContext(), i = t.createOscillator(), r = t.createGain();
|
|
@@ -506,33 +506,33 @@ function rt(t) {
|
|
|
506
506
|
const i = t.trim().split(/\s+/).filter(Boolean);
|
|
507
507
|
return i.length <= 2 ? t.trim() : i.slice(-2).join(" ");
|
|
508
508
|
}
|
|
509
|
-
const Wn = Pe(function({ apiUrl: i, token: r, theme: o, height: h, defaultConversationId: S, disableAttachments:
|
|
509
|
+
const Wn = Pe(function({ apiUrl: i, token: r, theme: o, height: h, defaultConversationId: S, disableAttachments: b, disableNotificationSound: $, hideKeyboardHint: w, locale: y = "vi", extensions: W, currentAgent: z, teamAgents: j, onNewMessage: B, onConversationSelect: C }, D) {
|
|
510
510
|
var k, A, K, U, re;
|
|
511
|
-
const I = J(new it(i, r)), [
|
|
511
|
+
const I = J(new it(i, r)), [M, P] = g([]), [q, te] = g([]), [Q, L] = g(), [v, x] = g(), E = J(void 0), [V, ne] = g(""), [de, T] = g("all"), [oe, Z] = g(null), [O, ee] = g({ provider: "all", unreadOnly: !1 }), [se, c] = g(!1), H = J(null), N = J(null), [ae, ce] = g(null), [ye, F] = g(!0), [he, Se] = g(""), [Me, He] = g(() => !!(W != null && W.length)), [Ae, Ce] = g(280), [ve, Ie] = g(!1), [Ne, me] = g(0), _ = (o == null ? void 0 : o.primaryColor) ?? "#2563eb", ue = $e(() => new Map(q.map((l) => [l.id, l])), [q]), ze = J(null), [Fe, je] = g(0), G = z ?? oe ?? null;
|
|
512
512
|
X(() => {
|
|
513
|
-
I.current = new it(i, r),
|
|
513
|
+
I.current = new it(i, r), z || I.current.getSessionMe().then((l) => {
|
|
514
514
|
l != null && l.agent && Z(l.agent);
|
|
515
515
|
}).catch(() => {
|
|
516
516
|
});
|
|
517
|
-
}, [i, r,
|
|
517
|
+
}, [i, r, z]);
|
|
518
518
|
const Ke = $e(() => {
|
|
519
519
|
var p;
|
|
520
520
|
const l = /* @__PURE__ */ new Map();
|
|
521
521
|
G != null && G.id && l.set(G.id, G);
|
|
522
522
|
for (const u of j ?? [])
|
|
523
523
|
u != null && u.id && !l.has(u.id) && l.set(u.id, u);
|
|
524
|
-
for (const u of
|
|
524
|
+
for (const u of M)
|
|
525
525
|
(p = u.assignedAgent) != null && p.id && !l.has(u.assignedAgent.id) && l.set(u.assignedAgent.id, u.assignedAgent);
|
|
526
526
|
return [...l.values()];
|
|
527
|
-
}, [G, j,
|
|
528
|
-
P((u) => u.map((R) => R.id === l.id ? { ...R, assignedAgent: p } : R)),
|
|
527
|
+
}, [G, j, M]), qe = we(async (l, p) => {
|
|
528
|
+
P((u) => u.map((R) => R.id === l.id ? { ...R, assignedAgent: p } : R)), x((u) => u && u.id === l.id ? { ...u, assignedAgent: p } : u), me((u) => u + 1);
|
|
529
529
|
try {
|
|
530
530
|
const u = await I.current.assignConversation(l.id, p);
|
|
531
|
-
P((R) => R.map((le) => le.id === l.id ? { ...le, ...u, assignedAgent: u.assignedAgent ?? p } : le)),
|
|
531
|
+
P((R) => R.map((le) => le.id === l.id ? { ...le, ...u, assignedAgent: u.assignedAgent ?? p } : le)), x((R) => R && R.id === l.id ? { ...R, ...u, assignedAgent: u.assignedAgent ?? p } : R), me((R) => R + 1);
|
|
532
532
|
} catch {
|
|
533
533
|
}
|
|
534
534
|
}, []), ke = we(async (l, p) => {
|
|
535
|
-
l.contactId && await I.current.patchContact(l.contactId, p), P((u) => u.map((R) => R.id === l.id ? { ...R, contactExternalId: p ?? void 0 } : R)),
|
|
535
|
+
l.contactId && await I.current.patchContact(l.contactId, p), P((u) => u.map((R) => R.id === l.id ? { ...R, contactExternalId: p ?? void 0 } : R)), x((u) => u && u.id === l.id ? { ...u, contactExternalId: p ?? void 0 } : u), me((u) => u + 1);
|
|
536
536
|
}, []), fe = we(() => {
|
|
537
537
|
me((l) => l + 1);
|
|
538
538
|
}, []), Ve = $e(() => {
|
|
@@ -541,12 +541,12 @@ const Wn = Pe(function({ apiUrl: i, token: r, theme: o, height: h, defaultConver
|
|
|
541
541
|
}, [q]), Ge = $e(() => {
|
|
542
542
|
var p;
|
|
543
543
|
const l = {};
|
|
544
|
-
for (const u of
|
|
544
|
+
for (const u of M) {
|
|
545
545
|
const R = ((p = ue.get(u.connectionId)) == null ? void 0 : p.provider) ?? "unknown";
|
|
546
546
|
l[R] = (l[R] ?? 0) + 1;
|
|
547
547
|
}
|
|
548
548
|
return l;
|
|
549
|
-
}, [
|
|
549
|
+
}, [M, ue]);
|
|
550
550
|
function Ze(l) {
|
|
551
551
|
const p = l.clientX, u = Ae;
|
|
552
552
|
Ie(!0), document.body.style.cursor = "col-resize", document.body.style.userSelect = "none";
|
|
@@ -562,7 +562,7 @@ const Wn = Pe(function({ apiUrl: i, token: r, theme: o, height: h, defaultConver
|
|
|
562
562
|
const pe = we(async (l) => {
|
|
563
563
|
try {
|
|
564
564
|
const p = await I.current.listConversations(l);
|
|
565
|
-
P((u) => l ? [...u, ...p.items] : p.items),
|
|
565
|
+
P((u) => l ? [...u, ...p.items] : p.items), L(p.nextCursor), !l && p.items.length && x((u) => u ?? (S ? p.items.find((R) => R.id === S) ?? p.items[0] : p.items[0])), Se("");
|
|
566
566
|
} catch (p) {
|
|
567
567
|
Se(p instanceof Error ? p.message : "Không tải được hội thoại");
|
|
568
568
|
} finally {
|
|
@@ -574,22 +574,22 @@ const Wn = Pe(function({ apiUrl: i, token: r, theme: o, height: h, defaultConver
|
|
|
574
574
|
if (p === "message.new" || p === "conversation.updated") {
|
|
575
575
|
if (pe(), p === "message.new") {
|
|
576
576
|
const R = typeof u == "object" && u ? u : {}, le = R.conversationId ? String(R.conversationId) : "", We = R.messageId ? String(R.messageId) : "";
|
|
577
|
-
if ((R.direction ? String(R.direction) : "") === "inbound" &&
|
|
577
|
+
if ((R.direction ? String(R.direction) : "") === "inbound" && !$ && Qt(), le && le === E.current && We && ze.current) {
|
|
578
578
|
const Xe = ze.current;
|
|
579
579
|
I.current.getMessage(We).then((Ye) => {
|
|
580
580
|
Xe(Ye);
|
|
581
581
|
}).catch(() => {
|
|
582
582
|
});
|
|
583
583
|
}
|
|
584
|
-
|
|
584
|
+
B == null || B(le || E.current || "");
|
|
585
585
|
}
|
|
586
586
|
} else p === "message.status_updated" && je((R) => R + 1);
|
|
587
|
-
})), [pe,
|
|
588
|
-
E.current =
|
|
589
|
-
}, [
|
|
590
|
-
|
|
587
|
+
})), [pe, B]), X(() => {
|
|
588
|
+
E.current = v == null ? void 0 : v.id;
|
|
589
|
+
}, [v]), X(() => {
|
|
590
|
+
v != null && v.unreadCount && I.current.markRead(v.id).then(() => pe()).catch(() => {
|
|
591
591
|
});
|
|
592
|
-
}, [
|
|
592
|
+
}, [v == null ? void 0 : v.id]), X(() => {
|
|
593
593
|
if (!se) return;
|
|
594
594
|
function l(p) {
|
|
595
595
|
var u, R;
|
|
@@ -598,14 +598,14 @@ const Wn = Pe(function({ apiUrl: i, token: r, theme: o, height: h, defaultConver
|
|
|
598
598
|
return document.addEventListener("mousedown", l), () => document.removeEventListener("mousedown", l);
|
|
599
599
|
}, [se]);
|
|
600
600
|
const be = $e(() => {
|
|
601
|
-
const l = G ?
|
|
601
|
+
const l = G ? M.filter((u) => {
|
|
602
602
|
var R;
|
|
603
603
|
return ((R = u.assignedAgent) == null ? void 0 : R.id) === G.id;
|
|
604
|
-
}).length : 0, p =
|
|
605
|
-
return { all:
|
|
606
|
-
}, [
|
|
604
|
+
}).length : 0, p = M.filter((u) => !u.assignedAgent).length;
|
|
605
|
+
return { all: M.length, mine: l, unassigned: p };
|
|
606
|
+
}, [M, G]), Te = $e(() => {
|
|
607
607
|
const l = V.toLowerCase().trim();
|
|
608
|
-
return
|
|
608
|
+
return M.filter((p) => {
|
|
609
609
|
var Ee, Xe, Ye;
|
|
610
610
|
if (de === "mine") {
|
|
611
611
|
if (!G || ((Ee = p.assignedAgent) == null ? void 0 : Ee.id) !== G.id) return !1;
|
|
@@ -614,7 +614,7 @@ const Wn = Pe(function({ apiUrl: i, token: r, theme: o, height: h, defaultConver
|
|
|
614
614
|
const u = `${p.contactName ?? ""} ${p.subject ?? ""} ${p.providerConversationKey} ${((Xe = p.assignedAgent) == null ? void 0 : Xe.name) ?? ""}`.toLowerCase(), R = ((Ye = ue.get(p.connectionId)) == null ? void 0 : Ye.provider) ?? "unknown", le = O.provider === "all" || R === O.provider, We = !O.unreadOnly || (p.unreadCount ?? 0) > 0;
|
|
615
615
|
return le && We && (!l || u.includes(l));
|
|
616
616
|
});
|
|
617
|
-
}, [
|
|
617
|
+
}, [M, ue, O, V, de, G]), Re = O.provider !== "all" || O.unreadOnly, a = y === "en" ? {
|
|
618
618
|
today: "TODAY",
|
|
619
619
|
loadOlder: "↑ Load older messages",
|
|
620
620
|
loading: "Loading messages…",
|
|
@@ -637,12 +637,12 @@ const Wn = Pe(function({ apiUrl: i, token: r, theme: o, height: h, defaultConver
|
|
|
637
637
|
};
|
|
638
638
|
Bt(D, () => ({
|
|
639
639
|
openConversation: (l) => {
|
|
640
|
-
const p =
|
|
641
|
-
p &&
|
|
640
|
+
const p = M.find((u) => u.id === l);
|
|
641
|
+
p && x(p);
|
|
642
642
|
},
|
|
643
643
|
refresh: () => void pe()
|
|
644
|
-
}), [
|
|
645
|
-
const
|
|
644
|
+
}), [M, pe]);
|
|
645
|
+
const m = {
|
|
646
646
|
...f.frame,
|
|
647
647
|
height: h ?? 620,
|
|
648
648
|
...h ? { maxHeight: "none" } : {},
|
|
@@ -654,14 +654,14 @@ const Wn = Pe(function({ apiUrl: i, token: r, theme: o, height: h, defaultConver
|
|
|
654
654
|
return ye ? /* @__PURE__ */ n("div", { style: { ...f.state, borderRadius: (o == null ? void 0 : o.borderRadius) ?? "16px" }, children: [
|
|
655
655
|
/* @__PURE__ */ e(ot, {}),
|
|
656
656
|
" Đang tải hộp thư…"
|
|
657
|
-
] }) : he && !
|
|
657
|
+
] }) : he && !M.length ? /* @__PURE__ */ n("div", { style: { ...f.state, color: "#b42318", borderRadius: (o == null ? void 0 : o.borderRadius) ?? "16px" }, children: [
|
|
658
658
|
/* @__PURE__ */ e(Et, { size: 16, strokeWidth: 2 }),
|
|
659
659
|
" ",
|
|
660
660
|
he,
|
|
661
661
|
/* @__PURE__ */ e("button", { style: f.retry, onClick: () => {
|
|
662
662
|
F(!0), pe();
|
|
663
663
|
}, children: "Thử lại" })
|
|
664
|
-
] }) : /* @__PURE__ */ e(st.Provider, { value: i, children: /* @__PURE__ */ e(
|
|
664
|
+
] }) : /* @__PURE__ */ e(st.Provider, { value: i, children: /* @__PURE__ */ e(Rt.Provider, { value: r, children: /* @__PURE__ */ n("div", { style: m, onFocusCapture: () => {
|
|
665
665
|
const l = window.scrollY;
|
|
666
666
|
requestAnimationFrame(() => {
|
|
667
667
|
window.scrollY !== l && window.scrollTo({ top: l, behavior: "instant" });
|
|
@@ -697,9 +697,9 @@ const Wn = Pe(function({ apiUrl: i, token: r, theme: o, height: h, defaultConver
|
|
|
697
697
|
background: d.surface
|
|
698
698
|
},
|
|
699
699
|
children: [
|
|
700
|
-
{ key: "all", label:
|
|
701
|
-
{ key: "mine", label:
|
|
702
|
-
{ key: "unassigned", label:
|
|
700
|
+
{ key: "all", label: y === "en" ? "All" : "Tất cả", count: be.all },
|
|
701
|
+
{ key: "mine", label: y === "en" ? "Mine" : "Của tôi", count: be.mine },
|
|
702
|
+
{ key: "unassigned", label: y === "en" ? "Unassigned" : "Chưa nhận", count: be.unassigned }
|
|
703
703
|
].map((l) => {
|
|
704
704
|
const p = de === l.key;
|
|
705
705
|
return /* @__PURE__ */ n(
|
|
@@ -708,7 +708,7 @@ const Wn = Pe(function({ apiUrl: i, token: r, theme: o, height: h, defaultConver
|
|
|
708
708
|
type: "button",
|
|
709
709
|
role: "tab",
|
|
710
710
|
"aria-selected": p,
|
|
711
|
-
onClick: () =>
|
|
711
|
+
onClick: () => T(l.key),
|
|
712
712
|
style: {
|
|
713
713
|
border: 0,
|
|
714
714
|
borderRadius: 6,
|
|
@@ -739,7 +739,7 @@ const Wn = Pe(function({ apiUrl: i, token: r, theme: o, height: h, defaultConver
|
|
|
739
739
|
})
|
|
740
740
|
}
|
|
741
741
|
),
|
|
742
|
-
|
|
742
|
+
Re && /* @__PURE__ */ n("div", { style: { display: "flex", gap: 4, flexWrap: "wrap", padding: "0 14px 8px" }, children: [
|
|
743
743
|
O.provider !== "all" && /* @__PURE__ */ n("span", { style: { display: "inline-flex", alignItems: "center", gap: 4, background: "#eef2ff", color: _, borderRadius: 6, fontSize: 11, padding: "2px 8px", fontWeight: 500 }, children: [
|
|
744
744
|
/* @__PURE__ */ e(De, { provider: O.provider }),
|
|
745
745
|
yt(O.provider),
|
|
@@ -753,14 +753,14 @@ const Wn = Pe(function({ apiUrl: i, token: r, theme: o, height: h, defaultConver
|
|
|
753
753
|
] }),
|
|
754
754
|
/* @__PURE__ */ n("div", { style: f.listHeader, children: [
|
|
755
755
|
/* @__PURE__ */ n("span", { children: [
|
|
756
|
-
|
|
756
|
+
Te.length,
|
|
757
757
|
" hội thoại"
|
|
758
758
|
] }),
|
|
759
759
|
/* @__PURE__ */ e(
|
|
760
760
|
"button",
|
|
761
761
|
{
|
|
762
762
|
ref: H,
|
|
763
|
-
style: { ...f.iconButton, background:
|
|
763
|
+
style: { ...f.iconButton, background: Re ? `${_}14` : "transparent", color: Re ? _ : d.muted },
|
|
764
764
|
"aria-label": "Bộ lọc",
|
|
765
765
|
onClick: () => {
|
|
766
766
|
var l;
|
|
@@ -787,7 +787,7 @@ const Wn = Pe(function({ apiUrl: i, token: r, theme: o, height: h, defaultConver
|
|
|
787
787
|
l === "all" ? /* @__PURE__ */ n("span", { style: { color: d.ink }, children: [
|
|
788
788
|
a.all,
|
|
789
789
|
" (",
|
|
790
|
-
|
|
790
|
+
M.length,
|
|
791
791
|
")"
|
|
792
792
|
] }) : /* @__PURE__ */ n("span", { style: { display: "flex", alignItems: "center", gap: 5, color: d.ink }, children: [
|
|
793
793
|
/* @__PURE__ */ e(De, { provider: l }),
|
|
@@ -810,15 +810,15 @@ const Wn = Pe(function({ apiUrl: i, token: r, theme: o, height: h, defaultConver
|
|
|
810
810
|
),
|
|
811
811
|
document.body
|
|
812
812
|
),
|
|
813
|
-
/* @__PURE__ */ n(
|
|
814
|
-
|
|
813
|
+
/* @__PURE__ */ n(Tt, { style: f.conversationList, children: [
|
|
814
|
+
Te.map((l) => {
|
|
815
815
|
var p;
|
|
816
|
-
return /* @__PURE__ */ e(nn, { conversation: l, provider: (p = ue.get(l.connectionId)) == null ? void 0 : p.provider, selected: (
|
|
817
|
-
|
|
816
|
+
return /* @__PURE__ */ e(nn, { conversation: l, provider: (p = ue.get(l.connectionId)) == null ? void 0 : p.provider, selected: (v == null ? void 0 : v.id) === l.id, primary: _, currentAgent: G, onSelect: () => {
|
|
817
|
+
x(l), C == null || C(l.id), I.current.markRead(l.id).then(() => pe()).catch(() => {
|
|
818
818
|
});
|
|
819
819
|
} }, l.id);
|
|
820
820
|
}),
|
|
821
|
-
!
|
|
821
|
+
!Te.length && /* @__PURE__ */ n("div", { style: f.emptySmall, children: [
|
|
822
822
|
/* @__PURE__ */ e("div", { style: f.emptyIcon, children: /* @__PURE__ */ e(ut, { size: 16, strokeWidth: 2 }) }),
|
|
823
823
|
/* @__PURE__ */ e("strong", { children: "Không tìm thấy" }),
|
|
824
824
|
/* @__PURE__ */ e("span", { children: "Thử từ khóa hoặc bộ lọc khác." })
|
|
@@ -826,12 +826,12 @@ const Wn = Pe(function({ apiUrl: i, token: r, theme: o, height: h, defaultConver
|
|
|
826
826
|
Q && /* @__PURE__ */ e("button", { style: f.loadMore, onClick: () => void pe(Q), children: "Xem thêm hội thoại" })
|
|
827
827
|
] })
|
|
828
828
|
] }),
|
|
829
|
-
/* @__PURE__ */ e("main", { style: f.main, children:
|
|
829
|
+
/* @__PURE__ */ e("main", { style: f.main, children: v ? /* @__PURE__ */ e(
|
|
830
830
|
rn,
|
|
831
831
|
{
|
|
832
|
-
conversation:
|
|
833
|
-
provider: (re = ue.get(
|
|
834
|
-
connection: ue.get(
|
|
832
|
+
conversation: v,
|
|
833
|
+
provider: (re = ue.get(v.connectionId)) == null ? void 0 : re.provider,
|
|
834
|
+
connection: ue.get(v.connectionId),
|
|
835
835
|
client: I.current,
|
|
836
836
|
primary: _,
|
|
837
837
|
error: he,
|
|
@@ -842,62 +842,62 @@ const Wn = Pe(function({ apiUrl: i, token: r, theme: o, height: h, defaultConver
|
|
|
842
842
|
infoOpen: Me,
|
|
843
843
|
onToggleInfo: () => He((l) => !l),
|
|
844
844
|
t: a,
|
|
845
|
-
disableAttachments:
|
|
845
|
+
disableAttachments: b,
|
|
846
846
|
hideKeyboardHint: w,
|
|
847
847
|
extensions: W,
|
|
848
848
|
currentAgent: G,
|
|
849
849
|
teamAgents: Ke,
|
|
850
|
-
onAssignAgent: (l) => qe(
|
|
851
|
-
onLinkContact: (l) => ke(
|
|
850
|
+
onAssignAgent: (l) => qe(v, l),
|
|
851
|
+
onLinkContact: (l) => ke(v, l),
|
|
852
852
|
onRefreshContactInfo: fe
|
|
853
853
|
},
|
|
854
|
-
|
|
854
|
+
v.id
|
|
855
855
|
) : /* @__PURE__ */ e(dn, {}) }),
|
|
856
|
-
Me &&
|
|
856
|
+
Me && v && /* @__PURE__ */ e(
|
|
857
857
|
an,
|
|
858
858
|
{
|
|
859
|
-
conversation:
|
|
860
|
-
connection: ue.get(
|
|
859
|
+
conversation: v,
|
|
860
|
+
connection: ue.get(v.connectionId),
|
|
861
861
|
primary: _,
|
|
862
862
|
onClose: () => He(!1),
|
|
863
863
|
client: I.current,
|
|
864
864
|
onStartResize: Ze,
|
|
865
865
|
extensions: W,
|
|
866
866
|
extRefreshKey: Ne,
|
|
867
|
-
onLinkContact: (l) => ke(
|
|
867
|
+
onLinkContact: (l) => ke(v, l),
|
|
868
868
|
onRefreshContactInfo: fe
|
|
869
869
|
}
|
|
870
870
|
)
|
|
871
871
|
] }) }) });
|
|
872
872
|
});
|
|
873
873
|
function nn({ conversation: t, provider: i, selected: r, primary: o, currentAgent: h, onSelect: S }) {
|
|
874
|
-
const [
|
|
874
|
+
const [b, $] = g(!1), w = t.contactName ?? t.subject ?? t.providerConversationKey, y = t.unreadCount ?? 0, W = t.lastMessageText ?? "", z = t.lastMessageDirection === "outbound" ? "Bạn: " : "", j = W.length > 60 ? W.slice(0, 60) + "…" : W, B = W ? z + j : "", C = t.assignedAgent ?? null, D = !!(C && h && C.id === h.id);
|
|
875
875
|
let I = "transparent";
|
|
876
|
-
r ? I = "#eef2ff" :
|
|
877
|
-
const
|
|
876
|
+
r ? I = "#eef2ff" : b ? I = "#f7f9fc" : y > 0 && (I = "#f0f4ff");
|
|
877
|
+
const M = {
|
|
878
878
|
...f.row,
|
|
879
879
|
background: I,
|
|
880
|
-
...r ? { boxShadow: `inset 3px 0 0 ${o}` } :
|
|
880
|
+
...r ? { boxShadow: `inset 3px 0 0 ${o}` } : y > 0 && !b ? { boxShadow: `inset 3px 0 0 ${o}` } : {}
|
|
881
881
|
};
|
|
882
882
|
return /* @__PURE__ */ n(
|
|
883
883
|
"button",
|
|
884
884
|
{
|
|
885
885
|
onClick: S,
|
|
886
|
-
style:
|
|
887
|
-
onMouseEnter: () =>
|
|
888
|
-
onMouseLeave: () =>
|
|
886
|
+
style: M,
|
|
887
|
+
onMouseEnter: () => $(!0),
|
|
888
|
+
onMouseLeave: () => $(!1),
|
|
889
889
|
children: [
|
|
890
890
|
/* @__PURE__ */ e($t, { name: w, color: o, image: t.contactPictureUrl, provider: i }),
|
|
891
891
|
/* @__PURE__ */ n("span", { style: f.rowBody, children: [
|
|
892
892
|
/* @__PURE__ */ n("span", { style: f.rowTop, children: [
|
|
893
|
-
/* @__PURE__ */ e("strong", { style: { minWidth: 0, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap", fontWeight:
|
|
893
|
+
/* @__PURE__ */ e("strong", { style: { minWidth: 0, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap", fontWeight: y > 0 ? 700 : 500 }, children: w }),
|
|
894
894
|
/* @__PURE__ */ n("span", { style: { display: "flex", alignItems: "center", gap: 4, flexShrink: 0 }, children: [
|
|
895
895
|
/* @__PURE__ */ e("time", { style: { color: d.muted, fontSize: 11, whiteSpace: "nowrap" }, children: at(t.lastMessageAt) }),
|
|
896
|
-
|
|
896
|
+
y > 0 && /* @__PURE__ */ e("span", { "aria-label": `${y} tin nhắn chưa đọc`, style: f.unreadBadge, children: y > 99 ? "99+" : y })
|
|
897
897
|
] })
|
|
898
898
|
] }),
|
|
899
|
-
/* @__PURE__ */ n("span", { style: { ...f.rowBottom, justifyContent: "space-between", alignItems: "center", gap: 6, color:
|
|
900
|
-
/* @__PURE__ */ e("span", { style: { flex: 1, minWidth: 0, whiteSpace: "nowrap", overflow: "hidden", textOverflow: "ellipsis" }, children:
|
|
899
|
+
/* @__PURE__ */ n("span", { style: { ...f.rowBottom, justifyContent: "space-between", alignItems: "center", gap: 6, color: y > 0 && !r ? "#4a5568" : d.muted }, children: [
|
|
900
|
+
/* @__PURE__ */ e("span", { style: { flex: 1, minWidth: 0, whiteSpace: "nowrap", overflow: "hidden", textOverflow: "ellipsis" }, children: B || /* @__PURE__ */ e("span", { style: { opacity: 0.5 }, children: "Chưa có tin nhắn" }) }),
|
|
901
901
|
C ? /* @__PURE__ */ n(
|
|
902
902
|
"span",
|
|
903
903
|
{
|
|
@@ -938,7 +938,7 @@ function nn({ conversation: t, provider: i, selected: r, primary: o, currentAgen
|
|
|
938
938
|
/* @__PURE__ */ e("span", { style: { maxWidth: 68, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: rt(C.name) })
|
|
939
939
|
]
|
|
940
940
|
}
|
|
941
|
-
) :
|
|
941
|
+
) : y > 0 ? /* @__PURE__ */ e(
|
|
942
942
|
"span",
|
|
943
943
|
{
|
|
944
944
|
style: {
|
|
@@ -961,23 +961,23 @@ function nn({ conversation: t, provider: i, selected: r, primary: o, currentAgen
|
|
|
961
961
|
}
|
|
962
962
|
);
|
|
963
963
|
}
|
|
964
|
-
function rn({ conversation: t, provider: i, connection: r, client: o, primary: h, error: S, onRegisterAppend:
|
|
965
|
-
var
|
|
966
|
-
const [q, te] =
|
|
964
|
+
function rn({ conversation: t, provider: i, connection: r, client: o, primary: h, error: S, onRegisterAppend: b, refreshKey: $, infoOpen: w, onToggleInfo: y, t: W, disableAttachments: z, hideKeyboardHint: j, extensions: B, currentAgent: C, teamAgents: D, onAssignAgent: I, onLinkContact: M, onRefreshContactInfo: P }) {
|
|
965
|
+
var Te, Re;
|
|
966
|
+
const [q, te] = g([]), [Q, L] = g(), [v, x] = g(""), [E, V] = g(!0), [ne, de] = g(!1), [T, oe] = g(""), Z = J(null), O = t.contactName ?? t.subject ?? t.providerConversationKey, ee = J(null), se = J(null), [c, H] = g(null), [N, ae] = g(!1), [ce, ye] = g(!1), [F, he] = g(!1), [Se, Me] = g(0), He = J(null), Ae = J(null), Ce = J(null), [ve, Ie] = g(!1), [Ne, me] = g(""), [_, ue] = g([]), ze = J(null), Fe = J(null), [je, G] = g(!1), Ke = J(null), qe = J(null);
|
|
967
967
|
X(() => {
|
|
968
968
|
if (!je) return;
|
|
969
|
-
function a(
|
|
969
|
+
function a(m) {
|
|
970
970
|
var k, A;
|
|
971
|
-
(k = Ke.current) != null && k.contains(
|
|
971
|
+
(k = Ke.current) != null && k.contains(m.target) || (A = qe.current) != null && A.contains(m.target) || G(!1);
|
|
972
972
|
}
|
|
973
973
|
return document.addEventListener("mousedown", a), () => document.removeEventListener("mousedown", a);
|
|
974
974
|
}, [je]), X(() => () => {
|
|
975
975
|
c != null && c.objectUrl && URL.revokeObjectURL(c.objectUrl);
|
|
976
976
|
}, [c == null ? void 0 : c.objectUrl]), X(() => {
|
|
977
977
|
if (!F) return;
|
|
978
|
-
function a(
|
|
978
|
+
function a(m) {
|
|
979
979
|
var k, A;
|
|
980
|
-
(k = Ae.current) != null && k.contains(
|
|
980
|
+
(k = Ae.current) != null && k.contains(m.target) || (A = He.current) != null && A.contains(m.target) || he(!1);
|
|
981
981
|
}
|
|
982
982
|
return document.addEventListener("mousedown", a), () => document.removeEventListener("mousedown", a);
|
|
983
983
|
}, [F]), X(() => {
|
|
@@ -985,55 +985,55 @@ function rn({ conversation: t, provider: i, connection: r, client: o, primary: h
|
|
|
985
985
|
});
|
|
986
986
|
}, [o]), X(() => {
|
|
987
987
|
if (!ve) return;
|
|
988
|
-
function a(
|
|
988
|
+
function a(m) {
|
|
989
989
|
var k, A;
|
|
990
|
-
(k = Fe.current) != null && k.contains(
|
|
990
|
+
(k = Fe.current) != null && k.contains(m.target) || (A = ze.current) != null && A.contains(m.target) || Ie(!1);
|
|
991
991
|
}
|
|
992
992
|
return document.addEventListener("mousedown", a), () => document.removeEventListener("mousedown", a);
|
|
993
993
|
}, [ve]);
|
|
994
|
-
const ke = J(!0), fe = we(async (a,
|
|
995
|
-
|
|
994
|
+
const ke = J(!0), fe = we(async (a, m) => {
|
|
995
|
+
m || (ke.current = !a);
|
|
996
996
|
try {
|
|
997
997
|
const k = await o.listMessages(t.id, a);
|
|
998
|
-
te((A) => a ? [...k.items, ...A] : k.items),
|
|
998
|
+
te((A) => a ? [...k.items, ...A] : k.items), L(k.nextCursor);
|
|
999
999
|
} catch (k) {
|
|
1000
1000
|
oe(k instanceof Error ? k.message : "Không tải được tin nhắn");
|
|
1001
1001
|
} finally {
|
|
1002
|
-
|
|
1002
|
+
m || V(!1);
|
|
1003
1003
|
}
|
|
1004
1004
|
}, [o, t.id]);
|
|
1005
1005
|
X(() => {
|
|
1006
1006
|
V(!0), fe();
|
|
1007
1007
|
}, [fe]), X(() => {
|
|
1008
|
-
|
|
1009
|
-
}, [
|
|
1008
|
+
$ && fe(void 0, !0);
|
|
1009
|
+
}, [$]), X(() => {
|
|
1010
1010
|
ke.current && requestAnimationFrame(() => {
|
|
1011
1011
|
const a = Z.current;
|
|
1012
1012
|
a && (a.scrollTop = a.scrollHeight);
|
|
1013
1013
|
});
|
|
1014
|
-
}, [q]), X(() => (
|
|
1015
|
-
ke.current = !0, te((
|
|
1014
|
+
}, [q]), X(() => (b == null || b((a) => {
|
|
1015
|
+
ke.current = !0, te((m) => m.some((k) => k.id === a.id) ? m : [...m, a]);
|
|
1016
1016
|
}), () => {
|
|
1017
|
-
|
|
1018
|
-
}), [
|
|
1017
|
+
b == null || b(null);
|
|
1018
|
+
}), [b]);
|
|
1019
1019
|
async function Ve(a) {
|
|
1020
1020
|
var A;
|
|
1021
|
-
const
|
|
1022
|
-
if (!
|
|
1021
|
+
const m = (A = a.target.files) == null ? void 0 : A[0];
|
|
1022
|
+
if (!m) return;
|
|
1023
1023
|
a.target.value = "";
|
|
1024
|
-
const k = URL.createObjectURL(
|
|
1025
|
-
H({ file:
|
|
1024
|
+
const k = URL.createObjectURL(m);
|
|
1025
|
+
H({ file: m, uploading: !0, objectUrl: k });
|
|
1026
1026
|
try {
|
|
1027
|
-
const K = await o.uploadAttachment(
|
|
1028
|
-
H({ file:
|
|
1027
|
+
const K = await o.uploadAttachment(m);
|
|
1028
|
+
H({ file: m, uploading: !1, url: K.url, mimeType: K.mimeType, attachmentType: K.attachmentType, objectUrl: k });
|
|
1029
1029
|
} catch {
|
|
1030
1030
|
URL.revokeObjectURL(k), H(null), oe("Không tải lên được tệp đính kèm");
|
|
1031
1031
|
}
|
|
1032
1032
|
}
|
|
1033
1033
|
async function Ge(a) {
|
|
1034
1034
|
a.preventDefault();
|
|
1035
|
-
const
|
|
1036
|
-
if (!
|
|
1035
|
+
const m = v.trim(), k = c != null && c.url ? [{ url: c.url, mimeType: c.mimeType ?? "application/octet-stream", type: c.attachmentType }] : [];
|
|
1036
|
+
if (!m && !k.length || ne) return;
|
|
1037
1037
|
de(!0), oe(""), !t.assignedAgent && C && I(C);
|
|
1038
1038
|
const A = `optimistic-${Date.now()}`;
|
|
1039
1039
|
C && (ke.current = !0, te((K) => [
|
|
@@ -1042,14 +1042,14 @@ function rn({ conversation: t, provider: i, connection: r, client: o, primary: h
|
|
|
1042
1042
|
id: A,
|
|
1043
1043
|
direction: "outbound",
|
|
1044
1044
|
status: "sending",
|
|
1045
|
-
text:
|
|
1045
|
+
text: m || void 0,
|
|
1046
1046
|
attachments: k.length ? k : void 0,
|
|
1047
1047
|
occurredAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1048
1048
|
senderAgent: C
|
|
1049
1049
|
}
|
|
1050
1050
|
]));
|
|
1051
1051
|
try {
|
|
1052
|
-
await o.sendMessage(t.id,
|
|
1052
|
+
await o.sendMessage(t.id, m || void 0, k.length ? k : void 0), c != null && c.objectUrl && URL.revokeObjectURL(c.objectUrl), x(""), H(null), await fe(), C && te((K) => {
|
|
1053
1053
|
var l, p;
|
|
1054
1054
|
const U = K.filter((u) => u.id !== A), re = U.length - 1;
|
|
1055
1055
|
return re >= 0 && ((l = U[re]) == null ? void 0 : l.direction) === "outbound" && !((p = U[re]) != null && p.senderAgent) ? U.map((u, R) => R === re ? { ...u, senderAgent: C } : u) : U;
|
|
@@ -1061,23 +1061,23 @@ function rn({ conversation: t, provider: i, connection: r, client: o, primary: h
|
|
|
1061
1061
|
}
|
|
1062
1062
|
}
|
|
1063
1063
|
function Ze(a) {
|
|
1064
|
-
const
|
|
1065
|
-
if (!
|
|
1066
|
-
|
|
1064
|
+
const m = Ce.current;
|
|
1065
|
+
if (!m) {
|
|
1066
|
+
x((U) => U + a), he(!1);
|
|
1067
1067
|
return;
|
|
1068
1068
|
}
|
|
1069
|
-
const k =
|
|
1070
|
-
|
|
1071
|
-
|
|
1069
|
+
const k = m.selectionStart ?? v.length, A = m.selectionEnd ?? v.length, K = v.slice(0, k) + a + v.slice(A);
|
|
1070
|
+
x(K), he(!1), requestAnimationFrame(() => {
|
|
1071
|
+
m.focus(), m.selectionStart = m.selectionEnd = k + a.length;
|
|
1072
1072
|
});
|
|
1073
1073
|
}
|
|
1074
1074
|
function pe(a) {
|
|
1075
|
-
|
|
1076
|
-
const
|
|
1077
|
-
|
|
1075
|
+
x(a), Ie(!1), me(""), requestAnimationFrame(() => {
|
|
1076
|
+
const m = Ce.current;
|
|
1077
|
+
m && (m.focus(), m.selectionStart = m.selectionEnd = a.length);
|
|
1078
1078
|
});
|
|
1079
1079
|
}
|
|
1080
|
-
const be = !ne && (
|
|
1080
|
+
const be = !ne && (v.trim().length > 0 || (c == null ? void 0 : c.url) != null && !c.uploading);
|
|
1081
1081
|
return /* @__PURE__ */ n("section", { style: f.chat, children: [
|
|
1082
1082
|
/* @__PURE__ */ n("header", { style: f.chatHeader, children: [
|
|
1083
1083
|
/* @__PURE__ */ e($t, { name: O, color: h, image: t.contactPictureUrl, provider: i }),
|
|
@@ -1200,7 +1200,7 @@ function rn({ conversation: t, provider: i, connection: r, client: o, primary: h
|
|
|
1200
1200
|
},
|
|
1201
1201
|
children: [
|
|
1202
1202
|
/* @__PURE__ */ e("div", { style: { padding: "4px 8px 6px", fontSize: 10, fontWeight: 700, color: d.muted, letterSpacing: 0.8, textTransform: "uppercase" }, children: "Người phụ trách hội thoại" }),
|
|
1203
|
-
C && ((
|
|
1203
|
+
C && ((Te = t.assignedAgent) == null ? void 0 : Te.id) !== C.id && /* @__PURE__ */ n(
|
|
1204
1204
|
"button",
|
|
1205
1205
|
{
|
|
1206
1206
|
type: "button",
|
|
@@ -1235,7 +1235,7 @@ function rn({ conversation: t, provider: i, connection: r, client: o, primary: h
|
|
|
1235
1235
|
),
|
|
1236
1236
|
/* @__PURE__ */ e("div", { style: { maxHeight: 200, overflowY: "auto" }, children: (D ?? []).map((a) => {
|
|
1237
1237
|
var k;
|
|
1238
|
-
const
|
|
1238
|
+
const m = ((k = t.assignedAgent) == null ? void 0 : k.id) === a.id;
|
|
1239
1239
|
return /* @__PURE__ */ n(
|
|
1240
1240
|
"button",
|
|
1241
1241
|
{
|
|
@@ -1251,7 +1251,7 @@ function rn({ conversation: t, provider: i, connection: r, client: o, primary: h
|
|
|
1251
1251
|
width: "100%",
|
|
1252
1252
|
border: 0,
|
|
1253
1253
|
borderRadius: 7,
|
|
1254
|
-
background:
|
|
1254
|
+
background: m ? "#f1f5f9" : "transparent",
|
|
1255
1255
|
color: d.ink,
|
|
1256
1256
|
padding: "6px 8px",
|
|
1257
1257
|
cursor: "pointer",
|
|
@@ -1283,7 +1283,7 @@ function rn({ conversation: t, provider: i, connection: r, client: o, primary: h
|
|
|
1283
1283
|
a.title && /* @__PURE__ */ e("span", { style: { display: "block", fontSize: 10.5, color: d.muted }, children: a.title })
|
|
1284
1284
|
] })
|
|
1285
1285
|
] }),
|
|
1286
|
-
|
|
1286
|
+
m && /* @__PURE__ */ e(lt, { size: 13, color: h, strokeWidth: 2.5 })
|
|
1287
1287
|
]
|
|
1288
1288
|
},
|
|
1289
1289
|
a.id
|
|
@@ -1334,13 +1334,13 @@ function rn({ conversation: t, provider: i, connection: r, client: o, primary: h
|
|
|
1334
1334
|
color: w ? h : d.muted
|
|
1335
1335
|
},
|
|
1336
1336
|
"aria-label": "Thông tin liên hệ",
|
|
1337
|
-
onClick:
|
|
1337
|
+
onClick: y,
|
|
1338
1338
|
children: /* @__PURE__ */ e(Dt, { size: 16, strokeWidth: 2 })
|
|
1339
1339
|
}
|
|
1340
1340
|
)
|
|
1341
1341
|
] })
|
|
1342
1342
|
] }),
|
|
1343
|
-
/* @__PURE__ */ n(
|
|
1343
|
+
/* @__PURE__ */ n(Tt, { ref: Z, style: f.messageArea, children: [
|
|
1344
1344
|
/* @__PURE__ */ e("div", { style: f.day, children: W.today }),
|
|
1345
1345
|
Q && /* @__PURE__ */ e("button", { onClick: () => void fe(Q), style: f.historyButton, children: W.loadOlder }),
|
|
1346
1346
|
E && /* @__PURE__ */ n("div", { style: f.messageHint, children: [
|
|
@@ -1349,11 +1349,11 @@ function rn({ conversation: t, provider: i, connection: r, client: o, primary: h
|
|
|
1349
1349
|
W.loading
|
|
1350
1350
|
] }),
|
|
1351
1351
|
!E && !q.length && /* @__PURE__ */ e("div", { style: f.messageHint, children: W.noMessages }),
|
|
1352
|
-
q.map((a,
|
|
1353
|
-
const k = (
|
|
1352
|
+
q.map((a, m) => {
|
|
1353
|
+
const k = (B == null ? void 0 : B.flatMap((re) => re.messageEnrichments ?? [])) ?? [], A = a.direction === "inbound" && k.length > 0 && m >= q.length - 15, K = A ? Je(t, {
|
|
1354
1354
|
provider: i,
|
|
1355
1355
|
recentMessages: q.slice(-10),
|
|
1356
|
-
linkContact:
|
|
1356
|
+
linkContact: M,
|
|
1357
1357
|
refreshContactInfo: P,
|
|
1358
1358
|
sendMessage: async (re, l) => {
|
|
1359
1359
|
await o.sendMessage(t.id, re, l), await fe(void 0, !0);
|
|
@@ -1373,7 +1373,7 @@ function rn({ conversation: t, provider: i, connection: r, client: o, primary: h
|
|
|
1373
1373
|
"button",
|
|
1374
1374
|
{
|
|
1375
1375
|
type: "button",
|
|
1376
|
-
onClick: () =>
|
|
1376
|
+
onClick: () => x(a),
|
|
1377
1377
|
style: {
|
|
1378
1378
|
fontSize: 11,
|
|
1379
1379
|
padding: "3px 10px",
|
|
@@ -1407,11 +1407,11 @@ function rn({ conversation: t, provider: i, connection: r, client: o, primary: h
|
|
|
1407
1407
|
fontFamily: "inherit"
|
|
1408
1408
|
},
|
|
1409
1409
|
children: [
|
|
1410
|
-
/* @__PURE__ */ e("div", { style: { display: "flex", borderBottom: `1px solid ${d.line}`, background: "#f9fafb" }, children: gt.map((a,
|
|
1410
|
+
/* @__PURE__ */ e("div", { style: { display: "flex", borderBottom: `1px solid ${d.line}`, background: "#f9fafb" }, children: gt.map((a, m) => /* @__PURE__ */ e(
|
|
1411
1411
|
"button",
|
|
1412
1412
|
{
|
|
1413
1413
|
type: "button",
|
|
1414
|
-
onClick: () => Me(
|
|
1414
|
+
onClick: () => Me(m),
|
|
1415
1415
|
style: {
|
|
1416
1416
|
flex: 1,
|
|
1417
1417
|
border: 0,
|
|
@@ -1420,15 +1420,15 @@ function rn({ conversation: t, provider: i, connection: r, client: o, primary: h
|
|
|
1420
1420
|
fontSize: 16,
|
|
1421
1421
|
cursor: "pointer",
|
|
1422
1422
|
lineHeight: 1,
|
|
1423
|
-
borderBottom: Se ===
|
|
1424
|
-
opacity: Se ===
|
|
1423
|
+
borderBottom: Se === m ? `2px solid ${h}` : "2px solid transparent",
|
|
1424
|
+
opacity: Se === m ? 1 : 0.5,
|
|
1425
1425
|
transition: "opacity 100ms ease"
|
|
1426
1426
|
},
|
|
1427
1427
|
children: a.icon
|
|
1428
1428
|
},
|
|
1429
|
-
|
|
1429
|
+
m
|
|
1430
1430
|
)) }),
|
|
1431
|
-
/* @__PURE__ */ e("div", { style: { display: "grid", gridTemplateColumns: "repeat(8, 1fr)", gap: 2, padding: 8, maxHeight: 180, overflowY: "auto" }, children: (
|
|
1431
|
+
/* @__PURE__ */ e("div", { style: { display: "grid", gridTemplateColumns: "repeat(8, 1fr)", gap: 2, padding: 8, maxHeight: 180, overflowY: "auto" }, children: (Re = gt[Se]) == null ? void 0 : Re.emojis.map((a, m) => /* @__PURE__ */ e(
|
|
1432
1432
|
"button",
|
|
1433
1433
|
{
|
|
1434
1434
|
type: "button",
|
|
@@ -1451,7 +1451,7 @@ function rn({ conversation: t, provider: i, connection: r, client: o, primary: h
|
|
|
1451
1451
|
},
|
|
1452
1452
|
children: a
|
|
1453
1453
|
},
|
|
1454
|
-
|
|
1454
|
+
m
|
|
1455
1455
|
)) })
|
|
1456
1456
|
]
|
|
1457
1457
|
}
|
|
@@ -1486,8 +1486,8 @@ function rn({ conversation: t, provider: i, connection: r, client: o, primary: h
|
|
|
1486
1486
|
}
|
|
1487
1487
|
) }),
|
|
1488
1488
|
/* @__PURE__ */ e("div", { style: { maxHeight: 220, overflowY: "auto" }, children: (() => {
|
|
1489
|
-
const a = Ne.trim().toLowerCase(),
|
|
1490
|
-
return
|
|
1489
|
+
const a = Ne.trim().toLowerCase(), m = a ? _.filter((k) => k.title.toLowerCase().includes(a) || k.content.toLowerCase().includes(a) || (k.shortcut ?? "").toLowerCase().includes(a)) : _;
|
|
1490
|
+
return m.length ? m.map((k) => /* @__PURE__ */ n(
|
|
1491
1491
|
"button",
|
|
1492
1492
|
{
|
|
1493
1493
|
type: "button",
|
|
@@ -1541,15 +1541,15 @@ function rn({ conversation: t, provider: i, connection: r, client: o, primary: h
|
|
|
1541
1541
|
children: /* @__PURE__ */ e(qt, { size: 13, strokeWidth: 2 })
|
|
1542
1542
|
}
|
|
1543
1543
|
),
|
|
1544
|
-
!
|
|
1544
|
+
!z && /* @__PURE__ */ e("button", { type: "button", title: "Gửi ảnh / video", "aria-label": "Gửi ảnh hoặc video", style: f.toolbarBtn, onClick: () => {
|
|
1545
1545
|
var a;
|
|
1546
1546
|
return (a = ee.current) == null ? void 0 : a.click();
|
|
1547
1547
|
}, children: /* @__PURE__ */ e(Ot, { size: 13, strokeWidth: 2 }) }),
|
|
1548
|
-
!
|
|
1548
|
+
!z && /* @__PURE__ */ e("button", { type: "button", title: "Gửi tệp đính kèm", "aria-label": "Gửi tệp đính kèm", style: f.toolbarBtn, onClick: () => {
|
|
1549
1549
|
var a;
|
|
1550
1550
|
return (a = se.current) == null ? void 0 : a.click();
|
|
1551
1551
|
}, children: /* @__PURE__ */ e(Pt, { size: 13, strokeWidth: 2 }) }),
|
|
1552
|
-
!
|
|
1552
|
+
!z && /* @__PURE__ */ n(ie, { children: [
|
|
1553
1553
|
/* @__PURE__ */ e("input", { ref: ee, type: "file", style: { display: "none" }, onChange: Ve, accept: "image/*,video/mp4" }),
|
|
1554
1554
|
/* @__PURE__ */ e("input", { ref: se, type: "file", style: { display: "none" }, onChange: Ve, accept: ".pdf,audio/mpeg,audio/ogg,application/octet-stream,application/zip,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document" })
|
|
1555
1555
|
] }),
|
|
@@ -1587,11 +1587,11 @@ function rn({ conversation: t, provider: i, connection: r, client: o, primary: h
|
|
|
1587
1587
|
children: "I"
|
|
1588
1588
|
}
|
|
1589
1589
|
),
|
|
1590
|
-
!!(
|
|
1591
|
-
var
|
|
1592
|
-
return (((
|
|
1590
|
+
!!(B != null && B.some((a) => {
|
|
1591
|
+
var m;
|
|
1592
|
+
return (((m = a.toolbarActions) == null ? void 0 : m.length) ?? 0) > 0;
|
|
1593
1593
|
})) && /* @__PURE__ */ e("span", { style: { width: 1, height: 14, background: "#e5e7eb", margin: "0 4px" } }),
|
|
1594
|
-
|
|
1594
|
+
B == null ? void 0 : B.flatMap((a) => a.toolbarActions ?? []).map((a, m) => /* @__PURE__ */ n(
|
|
1595
1595
|
"button",
|
|
1596
1596
|
{
|
|
1597
1597
|
type: "button",
|
|
@@ -1613,7 +1613,7 @@ function rn({ conversation: t, provider: i, connection: r, client: o, primary: h
|
|
|
1613
1613
|
} : f.toolbarBtn,
|
|
1614
1614
|
onClick: () => {
|
|
1615
1615
|
const k = (K) => {
|
|
1616
|
-
|
|
1616
|
+
x((U) => U && !U.endsWith(" ") && !U.endsWith(`
|
|
1617
1617
|
`) ? `${U} ${K}` : `${U}${K}`), requestAnimationFrame(() => {
|
|
1618
1618
|
var U;
|
|
1619
1619
|
return (U = Ce.current) == null ? void 0 : U.focus();
|
|
@@ -1621,7 +1621,7 @@ function rn({ conversation: t, provider: i, connection: r, client: o, primary: h
|
|
|
1621
1621
|
}, A = Je(t, {
|
|
1622
1622
|
provider: i,
|
|
1623
1623
|
recentMessages: q.slice(-10),
|
|
1624
|
-
linkContact:
|
|
1624
|
+
linkContact: M,
|
|
1625
1625
|
refreshContactInfo: P,
|
|
1626
1626
|
sendMessage: async (K, U) => {
|
|
1627
1627
|
await o.sendMessage(t.id, K, U), await fe(void 0, !0);
|
|
@@ -1634,7 +1634,7 @@ function rn({ conversation: t, provider: i, connection: r, client: o, primary: h
|
|
|
1634
1634
|
a.label && /* @__PURE__ */ e("span", { children: a.label })
|
|
1635
1635
|
]
|
|
1636
1636
|
},
|
|
1637
|
-
|
|
1637
|
+
m
|
|
1638
1638
|
))
|
|
1639
1639
|
] }),
|
|
1640
1640
|
/* @__PURE__ */ e(
|
|
@@ -1643,8 +1643,8 @@ function rn({ conversation: t, provider: i, connection: r, client: o, primary: h
|
|
|
1643
1643
|
ref: Ce,
|
|
1644
1644
|
"aria-label": "Soạn tin nhắn",
|
|
1645
1645
|
rows: 2,
|
|
1646
|
-
value:
|
|
1647
|
-
onChange: (a) =>
|
|
1646
|
+
value: v,
|
|
1647
|
+
onChange: (a) => x(a.target.value),
|
|
1648
1648
|
onKeyDown: (a) => {
|
|
1649
1649
|
a.key === "Enter" && !a.shiftKey && (a.preventDefault(), Ge(a));
|
|
1650
1650
|
},
|
|
@@ -1673,10 +1673,10 @@ function rn({ conversation: t, provider: i, connection: r, client: o, primary: h
|
|
|
1673
1673
|
/* @__PURE__ */ n("div", { style: { display: "flex", alignItems: "center", justifyContent: "space-between", padding: "4px 8px 6px 12px" }, children: [
|
|
1674
1674
|
/* @__PURE__ */ n("span", { style: {
|
|
1675
1675
|
fontSize: 11,
|
|
1676
|
-
color:
|
|
1677
|
-
fontWeight:
|
|
1676
|
+
color: v.length > 1e3 ? "#ef4444" : v.length > 900 ? "#f59e0b" : "#9ca3af",
|
|
1677
|
+
fontWeight: v.length > 1e3 ? 600 : 400
|
|
1678
1678
|
}, children: [
|
|
1679
|
-
|
|
1679
|
+
v.length,
|
|
1680
1680
|
"/1000"
|
|
1681
1681
|
] }),
|
|
1682
1682
|
/* @__PURE__ */ n("div", { style: { display: "flex", alignItems: "center", gap: 6 }, children: [
|
|
@@ -1711,12 +1711,12 @@ function rn({ conversation: t, provider: i, connection: r, client: o, primary: h
|
|
|
1711
1711
|
] })
|
|
1712
1712
|
] })
|
|
1713
1713
|
] }),
|
|
1714
|
-
(
|
|
1714
|
+
(T || S) && /* @__PURE__ */ e("div", { role: "alert", style: f.error, children: T || S })
|
|
1715
1715
|
] });
|
|
1716
1716
|
}
|
|
1717
1717
|
function on({ message: t, primary: i }) {
|
|
1718
|
-
var q, te, Q,
|
|
1719
|
-
const r = tt(st), o = tt(
|
|
1718
|
+
var q, te, Q, L, v;
|
|
1719
|
+
const r = tt(st), o = tt(Rt), h = (x) => x.startsWith("/v1/media/proxy") ? `${r}${x}&tok=${encodeURIComponent(o)}` : x, S = t.direction === "outbound", b = ((q = t.attachments) == null ? void 0 : q.filter((x) => x.type === "image")) ?? [], $ = ((te = t.attachments) == null ? void 0 : te.filter((x) => x.type === "sticker")) ?? [], w = ((Q = t.attachments) == null ? void 0 : Q.filter((x) => x.type === "video")) ?? [], y = ((L = t.attachments) == null ? void 0 : L.filter((x) => x.type === "audio")) ?? [], W = ((v = t.attachments) == null ? void 0 : v.filter((x) => x.type === "file")) ?? [], [z, j] = g(null), B = S ? "flex-end" : "flex-start", C = S ? t.senderAgent ?? null : null, D = /* @__PURE__ */ n("div", { style: { display: "flex", alignItems: "center", justifyContent: S ? "flex-end" : "flex-start", gap: 5, marginTop: 4, fontSize: 10, opacity: 0.78, letterSpacing: 0.2, userSelect: "none" }, children: [
|
|
1720
1720
|
C && /* @__PURE__ */ n(
|
|
1721
1721
|
"span",
|
|
1722
1722
|
{
|
|
@@ -1760,34 +1760,34 @@ function on({ message: t, primary: i }) {
|
|
|
1760
1760
|
" ",
|
|
1761
1761
|
/* @__PURE__ */ e(bt, { status: t.status })
|
|
1762
1762
|
] })
|
|
1763
|
-
] }) }),
|
|
1764
|
-
return /* @__PURE__ */ n("div", { style: { ...f.messageLine, justifyContent:
|
|
1765
|
-
|
|
1766
|
-
/* @__PURE__ */ e("img", { src: h(
|
|
1767
|
-
P &&
|
|
1763
|
+
] }) }), M = S ? { ...f.bubbleOut, background: i, color: "#fff", border: "1px solid transparent" } : f.bubbleIn, P = !t.text && y.length === 0 && W.length === 0;
|
|
1764
|
+
return /* @__PURE__ */ n("div", { style: { ...f.messageLine, justifyContent: B, flexDirection: "column", alignItems: B }, children: [
|
|
1765
|
+
$.map((x, E) => /* @__PURE__ */ n("div", { style: { position: "relative", marginBottom: 2 }, children: [
|
|
1766
|
+
/* @__PURE__ */ e("img", { src: h(x.url), alt: "sticker", style: { display: "block", maxWidth: 128, maxHeight: 128, objectFit: "contain" } }),
|
|
1767
|
+
P && b.length === 0 && w.length === 0 && E === $.length - 1 && I
|
|
1768
1768
|
] }, `s${E}`)),
|
|
1769
|
-
|
|
1770
|
-
/* @__PURE__ */ e("img", { src: h(
|
|
1771
|
-
P && E ===
|
|
1769
|
+
b.map((x, E) => /* @__PURE__ */ n("div", { style: { position: "relative", marginBottom: 2, cursor: "zoom-in" }, onClick: () => j({ url: h(x.url), kind: "image" }), children: [
|
|
1770
|
+
/* @__PURE__ */ e("img", { src: h(x.url), alt: "", style: { display: "block", maxWidth: 260, maxHeight: 260, borderRadius: 12, objectFit: "cover" } }),
|
|
1771
|
+
P && E === b.length - 1 && w.length === 0 && I
|
|
1772
1772
|
] }, E)),
|
|
1773
|
-
w.map((
|
|
1774
|
-
/* @__PURE__ */ e("video", { src: h(
|
|
1773
|
+
w.map((x, E) => /* @__PURE__ */ n("div", { style: { position: "relative", marginBottom: 2, cursor: "pointer" }, onClick: () => j({ url: h(x.url), kind: "video" }), children: [
|
|
1774
|
+
/* @__PURE__ */ e("video", { src: h(x.url), style: { display: "block", maxWidth: 260, maxHeight: 200, borderRadius: 12, objectFit: "cover" } }),
|
|
1775
1775
|
/* @__PURE__ */ e("div", { style: { position: "absolute", inset: 0, display: "flex", alignItems: "center", justifyContent: "center", borderRadius: 12, background: "rgba(0,0,0,.25)" }, children: /* @__PURE__ */ e("div", { style: { width: 40, height: 40, borderRadius: "50%", background: "rgba(255,255,255,.9)", display: "flex", alignItems: "center", justifyContent: "center" }, children: /* @__PURE__ */ e(Nt, { size: 16, fill: "#172033", color: "#172033", style: { marginLeft: 2 } }) }) }),
|
|
1776
1776
|
P && E === w.length - 1 && I
|
|
1777
1777
|
] }, E)),
|
|
1778
|
-
(
|
|
1779
|
-
|
|
1780
|
-
W.map((
|
|
1778
|
+
(y.length > 0 || W.length > 0 || t.text || !b.length && !w.length && !$.length && !t.text) && /* @__PURE__ */ n("div", { style: M, children: [
|
|
1779
|
+
y.map((x, E) => /* @__PURE__ */ e("audio", { src: h(x.url), controls: !0, style: { display: "block", width: "100%", marginBottom: 4 } }, E)),
|
|
1780
|
+
W.map((x, E) => /* @__PURE__ */ n("a", { href: h(x.url), target: "_blank", rel: "noreferrer", style: { display: "block", fontSize: 12, color: S ? "#fff" : "#2563eb", textDecoration: "underline", marginBottom: 4 }, children: [
|
|
1781
1781
|
"📎 ",
|
|
1782
|
-
tn(
|
|
1782
|
+
tn(x.mimeType)
|
|
1783
1783
|
] }, E)),
|
|
1784
1784
|
t.text && /* @__PURE__ */ e("p", { style: { margin: 0, whiteSpace: "pre-wrap", wordBreak: "break-word" }, children: t.text }),
|
|
1785
|
-
!
|
|
1785
|
+
!y.length && !W.length && !t.text && /* @__PURE__ */ e("p", { style: { margin: 0, opacity: 0.5 }, children: "[attachment]" }),
|
|
1786
1786
|
D
|
|
1787
1787
|
] }),
|
|
1788
|
-
|
|
1788
|
+
z && St(
|
|
1789
1789
|
/* @__PURE__ */ n("div", { onClick: () => j(null), style: { position: "fixed", inset: 0, zIndex: 1e4, background: "rgba(0,0,0,.88)", display: "flex", alignItems: "center", justifyContent: "center", cursor: "zoom-out" }, children: [
|
|
1790
|
-
|
|
1790
|
+
z.kind === "image" ? /* @__PURE__ */ e("img", { src: z.url, alt: "", style: { maxWidth: "90vw", maxHeight: "90vh", borderRadius: 8, objectFit: "contain", boxShadow: "0 8px 40px rgba(0,0,0,.5)" }, onClick: (x) => x.stopPropagation() }) : /* @__PURE__ */ e("video", { src: z.url, controls: !0, autoPlay: !0, style: { maxWidth: "90vw", maxHeight: "90vh", borderRadius: 8, boxShadow: "0 8px 40px rgba(0,0,0,.5)" }, onClick: (x) => x.stopPropagation() }),
|
|
1791
1791
|
/* @__PURE__ */ e("button", { onClick: () => j(null), style: { position: "absolute", top: 16, right: 16, background: "rgba(255,255,255,.15)", border: "none", borderRadius: "50%", width: 36, height: 36, cursor: "pointer", display: "flex", alignItems: "center", justifyContent: "center", color: "#fff" }, children: /* @__PURE__ */ e(Ue, { size: 18 }) })
|
|
1792
1792
|
] }),
|
|
1793
1793
|
document.body
|
|
@@ -1801,45 +1801,45 @@ function an({
|
|
|
1801
1801
|
onClose: o,
|
|
1802
1802
|
client: h,
|
|
1803
1803
|
onStartResize: S,
|
|
1804
|
-
extensions:
|
|
1805
|
-
extRefreshKey:
|
|
1804
|
+
extensions: b,
|
|
1805
|
+
extRefreshKey: $,
|
|
1806
1806
|
onLinkContact: w,
|
|
1807
|
-
onRefreshContactInfo:
|
|
1807
|
+
onRefreshContactInfo: y
|
|
1808
1808
|
}) {
|
|
1809
|
-
const W = t.contactName ?? t.subject ?? t.providerConversationKey,
|
|
1809
|
+
const W = t.contactName ?? t.subject ?? t.providerConversationKey, z = i == null ? void 0 : i.provider, j = !!(b != null && b.some((T) => T.contactInfoRows)), [B, C] = g({ channel: !0, stats: !1, extra: !0 }), D = (T) => C((oe) => ({ ...oe, [T]: !oe[T] })), [I, M] = g(""), [P, q] = g(!1), [te, Q] = g(!1), [L, v] = g(""), [x, E] = g([]), [V, ne] = g(!1);
|
|
1810
1810
|
X(() => {
|
|
1811
|
-
|
|
1812
|
-
|
|
1811
|
+
M(""), Q(!1), v(""), h.getNote(t.id).then((T) => {
|
|
1812
|
+
T && M(T.content);
|
|
1813
1813
|
}).catch(() => {
|
|
1814
1814
|
});
|
|
1815
1815
|
}, [t.id, h]), X(() => {
|
|
1816
|
-
if (!j || !
|
|
1817
|
-
let
|
|
1816
|
+
if (!j || !b) return;
|
|
1817
|
+
let T = !1;
|
|
1818
1818
|
const oe = Je(t, {
|
|
1819
|
-
provider:
|
|
1819
|
+
provider: z,
|
|
1820
1820
|
linkContact: w,
|
|
1821
|
-
refreshContactInfo:
|
|
1821
|
+
refreshContactInfo: y,
|
|
1822
1822
|
sendMessage: async (Z, O) => {
|
|
1823
1823
|
await h.sendMessage(t.id, Z, O);
|
|
1824
1824
|
}
|
|
1825
1825
|
});
|
|
1826
1826
|
return ne(!0), Promise.allSettled(
|
|
1827
|
-
|
|
1827
|
+
b.filter((Z) => Z.contactInfoRows).map((Z) => Z.contactInfoRows(oe))
|
|
1828
1828
|
).then((Z) => {
|
|
1829
|
-
if (
|
|
1829
|
+
if (T) return;
|
|
1830
1830
|
const O = Z.filter((ee) => ee.status === "fulfilled").flatMap((ee) => ee.value);
|
|
1831
1831
|
E(O), ne(!1);
|
|
1832
1832
|
}), () => {
|
|
1833
|
-
|
|
1833
|
+
T = !0;
|
|
1834
1834
|
};
|
|
1835
|
-
}, [t.id, t.contactExternalId,
|
|
1835
|
+
}, [t.id, t.contactExternalId, b, $, j, z, w, y, h]);
|
|
1836
1836
|
async function de() {
|
|
1837
1837
|
if (!(!I.trim() || P)) {
|
|
1838
|
-
q(!0),
|
|
1838
|
+
q(!0), v("");
|
|
1839
1839
|
try {
|
|
1840
1840
|
await h.upsertNote(t.id, I.trim()), Q(!0), setTimeout(() => Q(!1), 2e3);
|
|
1841
1841
|
} catch {
|
|
1842
|
-
|
|
1842
|
+
v("Lưu thất bại");
|
|
1843
1843
|
} finally {
|
|
1844
1844
|
q(!1);
|
|
1845
1845
|
}
|
|
@@ -1851,11 +1851,11 @@ function an({
|
|
|
1851
1851
|
{
|
|
1852
1852
|
onMouseDown: S,
|
|
1853
1853
|
style: { position: "absolute", left: 0, top: 0, bottom: 0, width: 4, cursor: "col-resize", zIndex: 1 },
|
|
1854
|
-
onMouseEnter: (
|
|
1855
|
-
|
|
1854
|
+
onMouseEnter: (T) => {
|
|
1855
|
+
T.currentTarget.style.background = "rgba(0,0,0,0.07)";
|
|
1856
1856
|
},
|
|
1857
|
-
onMouseLeave: (
|
|
1858
|
-
|
|
1857
|
+
onMouseLeave: (T) => {
|
|
1858
|
+
T.currentTarget.style.background = "";
|
|
1859
1859
|
}
|
|
1860
1860
|
}
|
|
1861
1861
|
),
|
|
@@ -1874,15 +1874,15 @@ function an({
|
|
|
1874
1874
|
style: { ...f.avatar, width: 48, height: 48, fontSize: 16 }
|
|
1875
1875
|
}
|
|
1876
1876
|
),
|
|
1877
|
-
/* @__PURE__ */ e("span", { style: { ...f.providerBadge, width: 20, height: 20 }, children: /* @__PURE__ */ e(De, { provider:
|
|
1877
|
+
/* @__PURE__ */ e("span", { style: { ...f.providerBadge, width: 20, height: 20 }, children: /* @__PURE__ */ e(De, { provider: z }) })
|
|
1878
1878
|
] }),
|
|
1879
1879
|
/* @__PURE__ */ e("strong", { style: { marginTop: 10, fontSize: 15, color: d.ink, textAlign: "center" }, children: W }),
|
|
1880
1880
|
/* @__PURE__ */ e("span", { style: { fontSize: 11, color: d.muted, fontFamily: "monospace", textAlign: "center" }, children: t.providerConversationKey })
|
|
1881
1881
|
] }),
|
|
1882
|
-
/* @__PURE__ */ n(_e, { label: "KÊNH", sectionKey: "channel", expanded:
|
|
1882
|
+
/* @__PURE__ */ n(_e, { label: "KÊNH", sectionKey: "channel", expanded: B.channel, onToggle: () => D("channel"), children: [
|
|
1883
1883
|
/* @__PURE__ */ e(ge, { label: "Nền tảng", children: /* @__PURE__ */ n("span", { style: { display: "flex", alignItems: "center", gap: 5 }, children: [
|
|
1884
|
-
/* @__PURE__ */ e(De, { provider:
|
|
1885
|
-
/* @__PURE__ */ e("span", { children: Wt(
|
|
1884
|
+
/* @__PURE__ */ e(De, { provider: z }),
|
|
1885
|
+
/* @__PURE__ */ e("span", { children: Wt(z) })
|
|
1886
1886
|
] }) }),
|
|
1887
1887
|
/* @__PURE__ */ n(ge, { label: "ID hội thoại", children: [
|
|
1888
1888
|
/* @__PURE__ */ n("span", { style: { fontFamily: "monospace", fontSize: 11 }, children: [
|
|
@@ -1892,7 +1892,7 @@ function an({
|
|
|
1892
1892
|
/* @__PURE__ */ e(ln, { value: t.id })
|
|
1893
1893
|
] })
|
|
1894
1894
|
] }),
|
|
1895
|
-
/* @__PURE__ */ n(_e, { label: "THỐNG KÊ", sectionKey: "stats", expanded:
|
|
1895
|
+
/* @__PURE__ */ n(_e, { label: "THỐNG KÊ", sectionKey: "stats", expanded: B.stats, onToggle: () => D("stats"), children: [
|
|
1896
1896
|
/* @__PURE__ */ e(ge, { label: "Tin nhắn", value: String(t.messageCount ?? 0) }),
|
|
1897
1897
|
(t.unreadCount ?? 0) > 0 && /* @__PURE__ */ e(ge, { label: "Chưa đọc", value: String(t.unreadCount), valueColor: "#ef4444" }),
|
|
1898
1898
|
/* @__PURE__ */ e(
|
|
@@ -1904,24 +1904,24 @@ function an({
|
|
|
1904
1904
|
),
|
|
1905
1905
|
/* @__PURE__ */ e(ge, { label: "Lần đầu", value: "—" })
|
|
1906
1906
|
] }),
|
|
1907
|
-
/* @__PURE__ */ n(_e, { label: "THÔNG TIN BỔ SUNG", sectionKey: "extra", expanded:
|
|
1907
|
+
/* @__PURE__ */ n(_e, { label: "THÔNG TIN BỔ SUNG", sectionKey: "extra", expanded: B.extra, onToggle: () => D("extra"), children: [
|
|
1908
1908
|
!j && /* @__PURE__ */ n(ie, { children: [
|
|
1909
1909
|
/* @__PURE__ */ e(ge, { label: "Điện thoại", value: "— chưa có", valueMuted: !0 }),
|
|
1910
1910
|
/* @__PURE__ */ e(ge, { label: "Email", value: "— chưa có", valueMuted: !0 }),
|
|
1911
1911
|
/* @__PURE__ */ e(ge, { label: "Nhãn", value: "— chưa có", valueMuted: !0 })
|
|
1912
1912
|
] }),
|
|
1913
|
-
V &&
|
|
1914
|
-
|
|
1915
|
-
|
|
1913
|
+
V && x.length === 0 && /* @__PURE__ */ e("div", { style: { fontSize: 12, color: d.muted, padding: "6px 0" }, children: "Đang tải hồ sơ CRM…" }),
|
|
1914
|
+
x.map((T) => /* @__PURE__ */ e(ge, { label: T.label, children: /* @__PURE__ */ n("span", { style: { display: "inline-flex", alignItems: "center", gap: 6, flexWrap: "wrap", justifyContent: "flex-end" }, children: [
|
|
1915
|
+
T.onClick ? /* @__PURE__ */ e(
|
|
1916
1916
|
"button",
|
|
1917
1917
|
{
|
|
1918
1918
|
type: "button",
|
|
1919
|
-
onClick:
|
|
1919
|
+
onClick: T.onClick,
|
|
1920
1920
|
style: { border: 0, background: "none", padding: 0, color: r, fontSize: 12, fontWeight: 600, cursor: "pointer", textDecoration: "underline" },
|
|
1921
|
-
children:
|
|
1921
|
+
children: T.value
|
|
1922
1922
|
}
|
|
1923
|
-
) :
|
|
1924
|
-
|
|
1923
|
+
) : T.href ? /* @__PURE__ */ e("a", { href: T.href, target: "_blank", rel: "noopener noreferrer", style: { color: r, fontSize: 12, fontWeight: 600 }, children: T.value }) : /* @__PURE__ */ e("span", { style: { fontSize: 12, fontWeight: 500, color: d.ink }, children: T.value }),
|
|
1924
|
+
T.badge && /* @__PURE__ */ e(
|
|
1925
1925
|
"span",
|
|
1926
1926
|
{
|
|
1927
1927
|
style: {
|
|
@@ -1929,18 +1929,18 @@ function an({
|
|
|
1929
1929
|
fontWeight: 700,
|
|
1930
1930
|
padding: "1px 7px",
|
|
1931
1931
|
borderRadius: 999,
|
|
1932
|
-
color:
|
|
1933
|
-
background:
|
|
1932
|
+
color: T.badge.color ?? r,
|
|
1933
|
+
background: T.badge.bg ?? `${r}14`
|
|
1934
1934
|
},
|
|
1935
|
-
children:
|
|
1935
|
+
children: T.badge.text
|
|
1936
1936
|
}
|
|
1937
1937
|
)
|
|
1938
|
-
] }) },
|
|
1938
|
+
] }) }, T.label))
|
|
1939
1939
|
] }),
|
|
1940
1940
|
/* @__PURE__ */ n("div", { style: { padding: "12px 16px", display: "flex", flexDirection: "column", gap: 8 }, children: [
|
|
1941
|
-
!(
|
|
1942
|
-
|
|
1943
|
-
const Z =
|
|
1941
|
+
!(b != null && b.length) && /* @__PURE__ */ e("button", { style: { ...f.ghostButton, color: r, borderColor: `${r}33` }, children: "Xem lịch sử" }),
|
|
1942
|
+
b == null ? void 0 : b.flatMap((T) => T.sidebarActions ?? []).map((T, oe) => {
|
|
1943
|
+
const Z = T.variant === "primary";
|
|
1944
1944
|
return /* @__PURE__ */ n(
|
|
1945
1945
|
"button",
|
|
1946
1946
|
{
|
|
@@ -1957,18 +1957,18 @@ function an({
|
|
|
1957
1957
|
},
|
|
1958
1958
|
onClick: () => {
|
|
1959
1959
|
const O = Je(t, {
|
|
1960
|
-
provider:
|
|
1960
|
+
provider: z,
|
|
1961
1961
|
linkContact: w,
|
|
1962
|
-
refreshContactInfo:
|
|
1962
|
+
refreshContactInfo: y,
|
|
1963
1963
|
sendMessage: async (ee, se) => {
|
|
1964
1964
|
await h.sendMessage(t.id, ee, se);
|
|
1965
1965
|
}
|
|
1966
1966
|
});
|
|
1967
|
-
|
|
1967
|
+
T.onClick(O);
|
|
1968
1968
|
},
|
|
1969
1969
|
children: [
|
|
1970
|
-
|
|
1971
|
-
|
|
1970
|
+
T.icon,
|
|
1971
|
+
T.label
|
|
1972
1972
|
]
|
|
1973
1973
|
},
|
|
1974
1974
|
oe
|
|
@@ -1980,7 +1980,7 @@ function an({
|
|
|
1980
1980
|
"textarea",
|
|
1981
1981
|
{
|
|
1982
1982
|
value: I,
|
|
1983
|
-
onChange: (
|
|
1983
|
+
onChange: (T) => M(T.target.value),
|
|
1984
1984
|
placeholder: "Nhập ghi chú...",
|
|
1985
1985
|
rows: 3,
|
|
1986
1986
|
style: { display: "block", width: "100%", boxSizing: "border-box", border: 0, outline: 0, background: "transparent", resize: "none", padding: "8px 10px", font: "inherit", fontSize: 12, color: d.ink, lineHeight: 1.5 }
|
|
@@ -1990,7 +1990,7 @@ function an({
|
|
|
1990
1990
|
te ? /* @__PURE__ */ n("span", { style: { display: "flex", alignItems: "center", gap: 4, fontSize: 11, color: "#16a34a" }, children: [
|
|
1991
1991
|
/* @__PURE__ */ e(lt, { size: 11, strokeWidth: 2.5 }),
|
|
1992
1992
|
" Đã lưu"
|
|
1993
|
-
] }) :
|
|
1993
|
+
] }) : L ? /* @__PURE__ */ e("span", { style: { fontSize: 11, color: "#ef4444" }, children: L }) : /* @__PURE__ */ e("span", {}),
|
|
1994
1994
|
/* @__PURE__ */ e(
|
|
1995
1995
|
"button",
|
|
1996
1996
|
{
|
|
@@ -2010,7 +2010,7 @@ function an({
|
|
|
2010
2010
|
] });
|
|
2011
2011
|
}
|
|
2012
2012
|
function _e({ label: t, children: i, sectionKey: r, expanded: o, onToggle: h }) {
|
|
2013
|
-
const S = !!h,
|
|
2013
|
+
const S = !!h, b = o ?? !0;
|
|
2014
2014
|
return /* @__PURE__ */ n("div", { style: { borderTop: `1px solid ${d.line}` }, children: [
|
|
2015
2015
|
/* @__PURE__ */ n(
|
|
2016
2016
|
"div",
|
|
@@ -2019,11 +2019,11 @@ function _e({ label: t, children: i, sectionKey: r, expanded: o, onToggle: h })
|
|
|
2019
2019
|
onClick: h,
|
|
2020
2020
|
children: [
|
|
2021
2021
|
/* @__PURE__ */ e("span", { children: t }),
|
|
2022
|
-
S && (
|
|
2022
|
+
S && (b ? /* @__PURE__ */ e(nt, { size: 12, strokeWidth: 2 }) : /* @__PURE__ */ e(jt, { size: 12, strokeWidth: 2 }))
|
|
2023
2023
|
]
|
|
2024
2024
|
}
|
|
2025
2025
|
),
|
|
2026
|
-
|
|
2026
|
+
b && i
|
|
2027
2027
|
] });
|
|
2028
2028
|
}
|
|
2029
2029
|
function ge({ label: t, value: i, children: r, valueColor: o, valueMuted: h }) {
|
|
@@ -2033,7 +2033,7 @@ function ge({ label: t, value: i, children: r, valueColor: o, valueMuted: h }) {
|
|
|
2033
2033
|
] });
|
|
2034
2034
|
}
|
|
2035
2035
|
function ln({ value: t }) {
|
|
2036
|
-
const [i, r] =
|
|
2036
|
+
const [i, r] = g(!1);
|
|
2037
2037
|
return /* @__PURE__ */ e(
|
|
2038
2038
|
"button",
|
|
2039
2039
|
{
|
|
@@ -2194,8 +2194,25 @@ function ct(t) {
|
|
|
2194
2194
|
return String(i.displayName ?? i.pageName ?? i.username ?? i.name ?? t.externalAccountId);
|
|
2195
2195
|
}
|
|
2196
2196
|
function fn(t) {
|
|
2197
|
-
const i =
|
|
2198
|
-
|
|
2197
|
+
const i = t.metadata;
|
|
2198
|
+
switch (t.provider) {
|
|
2199
|
+
case "facebook":
|
|
2200
|
+
return `Fanpage · ID ${t.externalAccountId}`;
|
|
2201
|
+
case "instagram":
|
|
2202
|
+
return `@${String(i.username ?? t.externalAccountId)}`;
|
|
2203
|
+
case "zalo":
|
|
2204
|
+
return `Zalo OA · ID ${t.externalAccountId}`;
|
|
2205
|
+
case "telegram": {
|
|
2206
|
+
const r = String(i.username ?? "");
|
|
2207
|
+
return r ? `@${r}` : `Bot · ${t.externalAccountId}`;
|
|
2208
|
+
}
|
|
2209
|
+
case "livechat":
|
|
2210
|
+
return `Widget ID: ${t.id}`;
|
|
2211
|
+
default: {
|
|
2212
|
+
const r = Oe[t.provider] ?? t.provider, o = String(i.username ?? i.pageName ?? "");
|
|
2213
|
+
return o ? `${r} · ${o}` : r;
|
|
2214
|
+
}
|
|
2215
|
+
}
|
|
2199
2216
|
}
|
|
2200
2217
|
const s = {
|
|
2201
2218
|
root: {
|
|
@@ -2507,7 +2524,7 @@ function bn() {
|
|
|
2507
2524
|
t.textContent = "@keyframes ch-spin{to{transform:rotate(360deg)}}", document.head.appendChild(t);
|
|
2508
2525
|
}
|
|
2509
2526
|
function $n({ apiUrl: t, token: i, onConnectionChange: r }) {
|
|
2510
|
-
const o = t.replace(/\/$/, ""), [h, S] =
|
|
2527
|
+
const o = t.replace(/\/$/, ""), [h, S] = g([]), [b, $] = g(!0), [w, y] = g({ name: "list" }), [W, z] = g(null), [j, B] = g(!1), [C, D] = g(""), [I, M] = g(""), [P, q] = g(""), [te, Q] = g(""), [L, v] = g(!1), [x, E] = g(!1), V = J(null);
|
|
2511
2528
|
bn();
|
|
2512
2529
|
const ne = we(async () => {
|
|
2513
2530
|
try {
|
|
@@ -2518,16 +2535,16 @@ function $n({ apiUrl: t, token: i, onConnectionChange: r }) {
|
|
|
2518
2535
|
const H = await c.json();
|
|
2519
2536
|
S(H), r == null || r(H);
|
|
2520
2537
|
} catch (c) {
|
|
2521
|
-
|
|
2538
|
+
z(c instanceof Error ? c.message : "Lỗi tải dữ liệu");
|
|
2522
2539
|
} finally {
|
|
2523
|
-
|
|
2540
|
+
$(!1);
|
|
2524
2541
|
}
|
|
2525
2542
|
}, [o, i, r]);
|
|
2526
2543
|
X(() => {
|
|
2527
2544
|
ne();
|
|
2528
2545
|
}, [ne]), X(() => {
|
|
2529
2546
|
if (!W) return;
|
|
2530
|
-
const c = setTimeout(() =>
|
|
2547
|
+
const c = setTimeout(() => z(null), 5e3);
|
|
2531
2548
|
return () => clearTimeout(c);
|
|
2532
2549
|
}, [W]), X(() => () => {
|
|
2533
2550
|
V.current && window.removeEventListener("message", V.current);
|
|
@@ -2543,19 +2560,19 @@ Hành động này không thể hoàn tác.`))
|
|
|
2543
2560
|
})).ok) throw new Error("Không thể ngắt kết nối");
|
|
2544
2561
|
await ne();
|
|
2545
2562
|
} catch (N) {
|
|
2546
|
-
|
|
2563
|
+
z(N instanceof Error ? N.message : "Lỗi ngắt kết nối");
|
|
2547
2564
|
}
|
|
2548
2565
|
}
|
|
2549
|
-
async function
|
|
2566
|
+
async function T() {
|
|
2550
2567
|
if (!C.trim()) {
|
|
2551
|
-
|
|
2568
|
+
z("Vui lòng nhập Bot Token");
|
|
2552
2569
|
return;
|
|
2553
2570
|
}
|
|
2554
2571
|
if (!/^\d+:[A-Za-z0-9_-]+$/.test(C.trim())) {
|
|
2555
|
-
|
|
2572
|
+
z("Token không đúng định dạng");
|
|
2556
2573
|
return;
|
|
2557
2574
|
}
|
|
2558
|
-
|
|
2575
|
+
B(!0), z(null);
|
|
2559
2576
|
try {
|
|
2560
2577
|
const c = await fetch(`${o}/v1/connect/telegram/start`, {
|
|
2561
2578
|
method: "POST",
|
|
@@ -2563,19 +2580,19 @@ Hành động này không thể hoàn tác.`))
|
|
|
2563
2580
|
body: JSON.stringify({ botToken: C.trim(), displayName: I.trim() || void 0 })
|
|
2564
2581
|
}), H = await c.json();
|
|
2565
2582
|
if (!c.ok || !H.connectionId) throw new Error(H.message ?? "Không thể kết nối Telegram");
|
|
2566
|
-
D(""),
|
|
2583
|
+
D(""), M(""), await ne(), y({ name: "list" });
|
|
2567
2584
|
} catch (c) {
|
|
2568
|
-
|
|
2585
|
+
z(c instanceof Error ? c.message : "Lỗi kết nối");
|
|
2569
2586
|
} finally {
|
|
2570
|
-
|
|
2587
|
+
B(!1);
|
|
2571
2588
|
}
|
|
2572
2589
|
}
|
|
2573
2590
|
async function oe() {
|
|
2574
2591
|
if (!P.trim()) {
|
|
2575
|
-
|
|
2592
|
+
z("Vui lòng nhập tên widget");
|
|
2576
2593
|
return;
|
|
2577
2594
|
}
|
|
2578
|
-
|
|
2595
|
+
B(!0), z(null);
|
|
2579
2596
|
try {
|
|
2580
2597
|
const c = te.split(/[\n,]+/).map((ae) => ae.trim()).filter(Boolean), H = await fetch(`${o}/v1/connect/livechat/start`, {
|
|
2581
2598
|
method: "POST",
|
|
@@ -2583,7 +2600,7 @@ Hành động này không thể hoàn tác.`))
|
|
|
2583
2600
|
body: JSON.stringify({ displayName: P.trim(), allowedDomains: c.length ? c : void 0 })
|
|
2584
2601
|
}), N = await H.json();
|
|
2585
2602
|
if (!H.ok || !N.connectionId || !N.embedScript) throw new Error(N.message ?? "Không thể tạo widget");
|
|
2586
|
-
q(""), Q(""), await ne(),
|
|
2603
|
+
q(""), Q(""), await ne(), y({
|
|
2587
2604
|
name: "livechat-result",
|
|
2588
2605
|
connectionId: N.connectionId,
|
|
2589
2606
|
embedScript: N.embedScript,
|
|
@@ -2591,13 +2608,13 @@ Hành động này không thể hoàn tác.`))
|
|
|
2591
2608
|
allowedDomains: N.allowedDomains ?? []
|
|
2592
2609
|
});
|
|
2593
2610
|
} catch (c) {
|
|
2594
|
-
|
|
2611
|
+
z(c instanceof Error ? c.message : "Lỗi tạo widget");
|
|
2595
2612
|
} finally {
|
|
2596
|
-
|
|
2613
|
+
B(!1);
|
|
2597
2614
|
}
|
|
2598
2615
|
}
|
|
2599
2616
|
async function Z(c) {
|
|
2600
|
-
|
|
2617
|
+
z(null);
|
|
2601
2618
|
try {
|
|
2602
2619
|
const H = `${o}/static/oauth-popup.html`, N = await fetch(`${o}/v1/connect/${c}/start`, {
|
|
2603
2620
|
method: "POST",
|
|
@@ -2606,11 +2623,11 @@ Hành động này không thể hoàn tác.`))
|
|
|
2606
2623
|
}), ae = await N.json();
|
|
2607
2624
|
if (!N.ok || !ae.authorizationUrl) throw new Error(ae.message ?? "Không thể bắt đầu kết nối");
|
|
2608
2625
|
const ce = window.open(ae.authorizationUrl, "channelhub-oauth", "width=600,height=700,scrollbars=yes,resizable=yes");
|
|
2609
|
-
|
|
2626
|
+
y({ name: "oauth-waiting", provider: c, popup: ce }), V.current && window.removeEventListener("message", V.current);
|
|
2610
2627
|
const ye = (F) => {
|
|
2611
2628
|
if (F.data) {
|
|
2612
2629
|
if (F.data.type === "channelhub:oauth-select") {
|
|
2613
|
-
|
|
2630
|
+
y({
|
|
2614
2631
|
name: "oauth-select",
|
|
2615
2632
|
provider: F.data.provider,
|
|
2616
2633
|
sessionId: String(F.data.sessionId ?? ""),
|
|
@@ -2619,17 +2636,17 @@ Hành động này không thể hoàn tác.`))
|
|
|
2619
2636
|
});
|
|
2620
2637
|
return;
|
|
2621
2638
|
}
|
|
2622
|
-
F.data.type === "channelhub:oauth" && (window.removeEventListener("message", ye), V.current = null, F.data.status === "active" ? (ne(),
|
|
2639
|
+
F.data.type === "channelhub:oauth" && (window.removeEventListener("message", ye), V.current = null, F.data.status === "active" ? (ne(), y({ name: "list" })) : (z("Kết nối thất bại: " + String(F.data.error ?? "Không xác định")), y({ name: "list" })));
|
|
2623
2640
|
}
|
|
2624
2641
|
};
|
|
2625
2642
|
V.current = ye, window.addEventListener("message", ye);
|
|
2626
2643
|
} catch (H) {
|
|
2627
|
-
|
|
2644
|
+
z(H instanceof Error ? H.message : "Lỗi kết nối"), y({ name: "list" });
|
|
2628
2645
|
}
|
|
2629
2646
|
}
|
|
2630
2647
|
function O(c, H) {
|
|
2631
2648
|
navigator.clipboard.writeText(c).then(() => {
|
|
2632
|
-
H === "script" ? (
|
|
2649
|
+
H === "script" ? (v(!0), setTimeout(() => v(!1), 2e3)) : (E(!0), setTimeout(() => E(!1), 2e3));
|
|
2633
2650
|
});
|
|
2634
2651
|
}
|
|
2635
2652
|
function ee() {
|
|
@@ -2639,12 +2656,12 @@ Hành động này không thể hoàn tác.`))
|
|
|
2639
2656
|
c.close();
|
|
2640
2657
|
} catch {
|
|
2641
2658
|
}
|
|
2642
|
-
V.current && (window.removeEventListener("message", V.current), V.current = null),
|
|
2659
|
+
V.current && (window.removeEventListener("message", V.current), V.current = null), y({ name: "add" });
|
|
2643
2660
|
}
|
|
2644
2661
|
async function se(c) {
|
|
2645
2662
|
if (w.name !== "oauth-select") return;
|
|
2646
2663
|
const { provider: H, sessionId: N, popup: ae } = w;
|
|
2647
|
-
|
|
2664
|
+
B(!0), z(null);
|
|
2648
2665
|
const ce = {
|
|
2649
2666
|
facebook: `${o}/v1/connect/facebook/select-page`,
|
|
2650
2667
|
instagram: `${o}/v1/connect/instagram/select-account`,
|
|
@@ -2666,11 +2683,11 @@ Hành động này không thể hoàn tác.`))
|
|
|
2666
2683
|
ae.postMessage({ type: "channelhub:close-popup" }, "*");
|
|
2667
2684
|
} catch {
|
|
2668
2685
|
}
|
|
2669
|
-
V.current && (window.removeEventListener("message", V.current), V.current = null), await ne(),
|
|
2686
|
+
V.current && (window.removeEventListener("message", V.current), V.current = null), await ne(), y({ name: "list" });
|
|
2670
2687
|
} catch (F) {
|
|
2671
|
-
|
|
2688
|
+
z(F instanceof Error ? F.message : "Lỗi kết nối");
|
|
2672
2689
|
} finally {
|
|
2673
|
-
|
|
2690
|
+
B(!1);
|
|
2674
2691
|
}
|
|
2675
2692
|
}
|
|
2676
2693
|
return /* @__PURE__ */ n("div", { style: s.root, children: [
|
|
@@ -2679,19 +2696,19 @@ Hành động này không thể hoàn tác.`))
|
|
|
2679
2696
|
/* @__PURE__ */ n("div", { style: s.header, children: [
|
|
2680
2697
|
/* @__PURE__ */ e("div", { style: s.headerLeft, children: /* @__PURE__ */ n("div", { children: [
|
|
2681
2698
|
/* @__PURE__ */ e("div", { style: s.title, children: "Kênh kết nối" }),
|
|
2682
|
-
/* @__PURE__ */ e("div", { style: s.subtitle, children:
|
|
2699
|
+
/* @__PURE__ */ e("div", { style: s.subtitle, children: b ? "Đang tải…" : `${h.filter((c) => c.status === "active").length} kênh đang hoạt động` })
|
|
2683
2700
|
] }) }),
|
|
2684
|
-
/* @__PURE__ */ n("button", { style: s.addBtn, onClick: () =>
|
|
2701
|
+
/* @__PURE__ */ n("button", { style: s.addBtn, onClick: () => y({ name: "add" }), children: [
|
|
2685
2702
|
/* @__PURE__ */ e(mt, {}),
|
|
2686
2703
|
/* @__PURE__ */ e("span", { children: "Thêm kênh" })
|
|
2687
2704
|
] })
|
|
2688
2705
|
] }),
|
|
2689
2706
|
/* @__PURE__ */ e("div", { style: s.divider }),
|
|
2690
|
-
/* @__PURE__ */ e("div", { style: s.body, children: !
|
|
2707
|
+
/* @__PURE__ */ e("div", { style: s.body, children: !b && h.length === 0 ? /* @__PURE__ */ n("div", { style: s.empty, children: [
|
|
2691
2708
|
/* @__PURE__ */ e("div", { style: { width: 64, height: 64, borderRadius: 16, background: "#f1f5f9", display: "flex", alignItems: "center", justifyContent: "center" }, children: /* @__PURE__ */ e(xe, { provider: "livechat", apiUrl: o, size: 40 }) }),
|
|
2692
2709
|
/* @__PURE__ */ e("div", { style: s.emptyTitle, children: "Chưa có kênh nào được kết nối" }),
|
|
2693
2710
|
/* @__PURE__ */ e("div", { style: s.emptyDesc, children: "Kết nối Facebook, Zalo OA, Telegram hoặc Live Chat để bắt đầu nhận tin nhắn từ khách hàng." }),
|
|
2694
|
-
/* @__PURE__ */ n("button", { style: s.emptyCta, onClick: () =>
|
|
2711
|
+
/* @__PURE__ */ n("button", { style: s.emptyCta, onClick: () => y({ name: "add" }), children: [
|
|
2695
2712
|
/* @__PURE__ */ e(mt, {}),
|
|
2696
2713
|
"Kết nối kênh đầu tiên"
|
|
2697
2714
|
] })
|
|
@@ -2707,7 +2724,7 @@ Hành động này không thể hoàn tác.`))
|
|
|
2707
2724
|
] }),
|
|
2708
2725
|
w.name === "add" && /* @__PURE__ */ n(ie, { children: [
|
|
2709
2726
|
/* @__PURE__ */ e("div", { style: s.header, children: /* @__PURE__ */ n("div", { style: s.headerLeft, children: [
|
|
2710
|
-
/* @__PURE__ */ e("button", { style: s.backBtn, onClick: () =>
|
|
2727
|
+
/* @__PURE__ */ e("button", { style: s.backBtn, onClick: () => y({ name: "list" }), children: /* @__PURE__ */ e(Be, {}) }),
|
|
2711
2728
|
/* @__PURE__ */ n("div", { children: [
|
|
2712
2729
|
/* @__PURE__ */ e("div", { style: s.title, children: "Thêm kênh mới" }),
|
|
2713
2730
|
/* @__PURE__ */ e("div", { style: s.subtitle, children: "Chọn nền tảng bạn muốn kết nối" })
|
|
@@ -2720,7 +2737,7 @@ Hành động này không thể hoàn tác.`))
|
|
|
2720
2737
|
provider: c,
|
|
2721
2738
|
apiUrl: o,
|
|
2722
2739
|
onClick: () => {
|
|
2723
|
-
c.type === "oauth" ? Z(c.id) : c.id === "telegram" ?
|
|
2740
|
+
c.type === "oauth" ? Z(c.id) : c.id === "telegram" ? y({ name: "connect-telegram" }) : y({ name: "connect-livechat" });
|
|
2724
2741
|
}
|
|
2725
2742
|
},
|
|
2726
2743
|
c.id
|
|
@@ -2728,7 +2745,7 @@ Hành động này không thể hoàn tác.`))
|
|
|
2728
2745
|
] }),
|
|
2729
2746
|
w.name === "connect-telegram" && /* @__PURE__ */ n(ie, { children: [
|
|
2730
2747
|
/* @__PURE__ */ n("div", { style: s.connectHeader, children: [
|
|
2731
|
-
/* @__PURE__ */ e("button", { style: s.backBtn, onClick: () =>
|
|
2748
|
+
/* @__PURE__ */ e("button", { style: s.backBtn, onClick: () => y({ name: "add" }), children: /* @__PURE__ */ e(Be, {}) }),
|
|
2732
2749
|
/* @__PURE__ */ e(xe, { provider: "telegram", apiUrl: o, size: 44 }),
|
|
2733
2750
|
/* @__PURE__ */ n("div", { children: [
|
|
2734
2751
|
/* @__PURE__ */ e("div", { style: s.connectTitle, children: "Kết nối Telegram Bot" }),
|
|
@@ -2781,20 +2798,20 @@ Hành động này không thể hoàn tác.`))
|
|
|
2781
2798
|
style: s.input,
|
|
2782
2799
|
type: "text",
|
|
2783
2800
|
value: I,
|
|
2784
|
-
onChange: (c) =>
|
|
2801
|
+
onChange: (c) => M(c.target.value),
|
|
2785
2802
|
placeholder: "VD: Bot hỗ trợ cửa hàng"
|
|
2786
2803
|
}
|
|
2787
2804
|
)
|
|
2788
2805
|
] }),
|
|
2789
2806
|
/* @__PURE__ */ n("div", { style: s.formActions, children: [
|
|
2790
|
-
/* @__PURE__ */ e("button", { style: s.btnSecondary, onClick: () =>
|
|
2791
|
-
/* @__PURE__ */ e("button", { style: s.btnPrimary, disabled: j, onClick: () => void
|
|
2807
|
+
/* @__PURE__ */ e("button", { style: s.btnSecondary, onClick: () => y({ name: "add" }), children: "Hủy" }),
|
|
2808
|
+
/* @__PURE__ */ e("button", { style: s.btnPrimary, disabled: j, onClick: () => void T(), children: j ? "Đang kết nối…" : "Kết nối Telegram" })
|
|
2792
2809
|
] })
|
|
2793
2810
|
] })
|
|
2794
2811
|
] }),
|
|
2795
2812
|
w.name === "connect-livechat" && /* @__PURE__ */ n(ie, { children: [
|
|
2796
2813
|
/* @__PURE__ */ n("div", { style: s.connectHeader, children: [
|
|
2797
|
-
/* @__PURE__ */ e("button", { style: s.backBtn, onClick: () =>
|
|
2814
|
+
/* @__PURE__ */ e("button", { style: s.backBtn, onClick: () => y({ name: "add" }), children: /* @__PURE__ */ e(Be, {}) }),
|
|
2798
2815
|
/* @__PURE__ */ e(xe, { provider: "livechat", apiUrl: o, size: 44 }),
|
|
2799
2816
|
/* @__PURE__ */ n("div", { children: [
|
|
2800
2817
|
/* @__PURE__ */ e("div", { style: s.connectTitle, children: "Tạo Live Chat Widget" }),
|
|
@@ -2837,14 +2854,14 @@ https://www.myshop.com`,
|
|
|
2837
2854
|
/* @__PURE__ */ e("div", { style: s.inputHint, children: "Mỗi domain một dòng. Để trống để cho phép tất cả." })
|
|
2838
2855
|
] }),
|
|
2839
2856
|
/* @__PURE__ */ n("div", { style: s.formActions, children: [
|
|
2840
|
-
/* @__PURE__ */ e("button", { style: s.btnSecondary, onClick: () =>
|
|
2857
|
+
/* @__PURE__ */ e("button", { style: s.btnSecondary, onClick: () => y({ name: "add" }), children: "Hủy" }),
|
|
2841
2858
|
/* @__PURE__ */ e("button", { style: s.btnPrimary, disabled: j, onClick: () => void oe(), children: j ? "Đang tạo…" : "Tạo widget" })
|
|
2842
2859
|
] })
|
|
2843
2860
|
] })
|
|
2844
2861
|
] }),
|
|
2845
2862
|
w.name === "livechat-result" && /* @__PURE__ */ n(ie, { children: [
|
|
2846
2863
|
/* @__PURE__ */ n("div", { style: s.connectHeader, children: [
|
|
2847
|
-
/* @__PURE__ */ e("button", { style: s.backBtn, onClick: () =>
|
|
2864
|
+
/* @__PURE__ */ e("button", { style: s.backBtn, onClick: () => y({ name: "list" }), children: /* @__PURE__ */ e(Be, {}) }),
|
|
2848
2865
|
/* @__PURE__ */ e(xe, { provider: "livechat", apiUrl: o, size: 44 }),
|
|
2849
2866
|
/* @__PURE__ */ n("div", { children: [
|
|
2850
2867
|
/* @__PURE__ */ e("div", { style: s.connectTitle, children: "Widget đã được tạo!" }),
|
|
@@ -2865,7 +2882,7 @@ https://www.myshop.com`,
|
|
|
2865
2882
|
/* @__PURE__ */ e("div", { style: s.codeLabel, children: "Mã nhúng" }),
|
|
2866
2883
|
/* @__PURE__ */ n("div", { style: s.codeBlock, children: [
|
|
2867
2884
|
/* @__PURE__ */ e("pre", { style: s.codePre, children: w.embedScript }),
|
|
2868
|
-
/* @__PURE__ */ e("button", { style: { ...s.copyBtn, ...
|
|
2885
|
+
/* @__PURE__ */ e("button", { style: { ...s.copyBtn, ...L ? { background: "#166534", borderColor: "#166534", color: "#bbf7d0" } : {} }, onClick: () => O(w.embedScript, "script"), children: L ? /* @__PURE__ */ n(ie, { children: [
|
|
2869
2886
|
/* @__PURE__ */ e(vt, {}),
|
|
2870
2887
|
" Đã sao chép"
|
|
2871
2888
|
] }) : /* @__PURE__ */ n(ie, { children: [
|
|
@@ -2887,16 +2904,16 @@ https://www.myshop.com`,
|
|
|
2887
2904
|
"button",
|
|
2888
2905
|
{
|
|
2889
2906
|
onClick: () => O(w.identitySecret, "secret"),
|
|
2890
|
-
style: { border: "none", background: "transparent", cursor: "pointer", color:
|
|
2891
|
-
children:
|
|
2907
|
+
style: { border: "none", background: "transparent", cursor: "pointer", color: x ? "#059669" : "#ca8a04", padding: 2, display: "flex", alignItems: "center" },
|
|
2908
|
+
children: x ? /* @__PURE__ */ e(vt, {}) : /* @__PURE__ */ e(xt, {})
|
|
2892
2909
|
}
|
|
2893
2910
|
)
|
|
2894
2911
|
] }),
|
|
2895
2912
|
/* @__PURE__ */ e("div", { style: { ...s.inputHint, marginTop: 6 }, children: "Dùng secret này để xác thực danh tính người dùng (HMAC). Giữ bí mật — không chia sẻ nơi công khai." })
|
|
2896
2913
|
] }),
|
|
2897
2914
|
/* @__PURE__ */ n("div", { style: s.formActions, children: [
|
|
2898
|
-
/* @__PURE__ */ e("button", { style: s.btnSecondary, onClick: () =>
|
|
2899
|
-
/* @__PURE__ */ e("button", { style: s.btnPrimary, onClick: () =>
|
|
2915
|
+
/* @__PURE__ */ e("button", { style: s.btnSecondary, onClick: () => y({ name: "list" }), children: "Về danh sách" }),
|
|
2916
|
+
/* @__PURE__ */ e("button", { style: s.btnPrimary, onClick: () => y({ name: "add" }), children: "Thêm kênh khác" })
|
|
2900
2917
|
] })
|
|
2901
2918
|
] })
|
|
2902
2919
|
] }),
|
|
@@ -3013,7 +3030,7 @@ function mn(t) {
|
|
|
3013
3030
|
return null;
|
|
3014
3031
|
}
|
|
3015
3032
|
function xn({ conn: t, apiUrl: i, size: r = 40 }) {
|
|
3016
|
-
const [o, h] =
|
|
3033
|
+
const [o, h] = g(!1), S = mn(t), b = Math.round(r * 0.28);
|
|
3017
3034
|
return S && !o ? /* @__PURE__ */ e(
|
|
3018
3035
|
"img",
|
|
3019
3036
|
{
|
|
@@ -3021,33 +3038,89 @@ function xn({ conn: t, apiUrl: i, size: r = 40 }) {
|
|
|
3021
3038
|
alt: ct(t),
|
|
3022
3039
|
referrerPolicy: "no-referrer",
|
|
3023
3040
|
onError: () => h(!0),
|
|
3024
|
-
style: { width: r, height: r, borderRadius:
|
|
3041
|
+
style: { width: r, height: r, borderRadius: b, objectFit: "cover", flexShrink: 0, display: "block" }
|
|
3025
3042
|
}
|
|
3026
3043
|
) : /* @__PURE__ */ e(xe, { provider: t.provider, apiUrl: i, size: r });
|
|
3027
3044
|
}
|
|
3028
3045
|
function vn({ conn: t, apiUrl: i, onDisconnect: r }) {
|
|
3029
|
-
const [o, h] =
|
|
3030
|
-
|
|
3031
|
-
|
|
3032
|
-
|
|
3033
|
-
|
|
3034
|
-
|
|
3046
|
+
const [o, h] = g(!1), [S, b] = g(!1), [$, w] = g(!1), y = t.provider === "livechat", W = i.replace(/\/$/, ""), z = y ? `<script src="${W}/static/livechat.js" data-widget-id="${t.id}" defer><\/script>` : null, j = () => {
|
|
3047
|
+
z && navigator.clipboard.writeText(z).then(() => {
|
|
3048
|
+
w(!0), setTimeout(() => w(!1), 2e3);
|
|
3049
|
+
});
|
|
3050
|
+
};
|
|
3051
|
+
return /* @__PURE__ */ n("div", { style: { ...s.channelItem, flexDirection: "column", alignItems: "stretch", gap: 0 }, children: [
|
|
3052
|
+
/* @__PURE__ */ n("div", { style: { display: "flex", alignItems: "center", gap: 12 }, children: [
|
|
3053
|
+
/* @__PURE__ */ e(xn, { conn: t, apiUrl: i, size: 40 }),
|
|
3054
|
+
/* @__PURE__ */ n("div", { style: s.channelInfo, children: [
|
|
3055
|
+
/* @__PURE__ */ e("div", { style: s.channelName, children: ct(t) }),
|
|
3056
|
+
/* @__PURE__ */ e("div", { style: { ...s.channelMeta, userSelect: "text" }, children: fn(t) })
|
|
3057
|
+
] }),
|
|
3058
|
+
/* @__PURE__ */ n("div", { style: s.channelActions, children: [
|
|
3059
|
+
/* @__PURE__ */ e("span", { style: t.status === "active" ? s.badgeActive : s.badgeInactive, children: t.status === "active" ? "Hoạt động" : t.status }),
|
|
3060
|
+
y && /* @__PURE__ */ e(
|
|
3061
|
+
"button",
|
|
3062
|
+
{
|
|
3063
|
+
style: {
|
|
3064
|
+
...s.disconnectBtn,
|
|
3065
|
+
...S ? { background: "#ede9fe", borderColor: "#c4b5fd", color: "#7c3aed" } : {}
|
|
3066
|
+
},
|
|
3067
|
+
onClick: () => b((B) => !B),
|
|
3068
|
+
children: "Mã nhúng"
|
|
3069
|
+
}
|
|
3070
|
+
),
|
|
3071
|
+
/* @__PURE__ */ e(
|
|
3072
|
+
"button",
|
|
3073
|
+
{
|
|
3074
|
+
style: {
|
|
3075
|
+
...s.disconnectBtn,
|
|
3076
|
+
...o ? { background: "#fef2f2", borderColor: "#fca5a5", color: "#dc2626" } : {}
|
|
3077
|
+
},
|
|
3078
|
+
onMouseEnter: () => h(!0),
|
|
3079
|
+
onMouseLeave: () => h(!1),
|
|
3080
|
+
onClick: r,
|
|
3081
|
+
children: "Ngắt kết nối"
|
|
3082
|
+
}
|
|
3083
|
+
)
|
|
3084
|
+
] })
|
|
3035
3085
|
] }),
|
|
3036
|
-
/* @__PURE__ */ n("div", { style:
|
|
3037
|
-
/* @__PURE__ */ e("
|
|
3038
|
-
/* @__PURE__ */
|
|
3039
|
-
"
|
|
3040
|
-
|
|
3041
|
-
|
|
3042
|
-
|
|
3043
|
-
|
|
3044
|
-
|
|
3045
|
-
|
|
3046
|
-
|
|
3047
|
-
|
|
3048
|
-
|
|
3049
|
-
|
|
3050
|
-
|
|
3086
|
+
y && S && z && /* @__PURE__ */ n("div", { style: { marginTop: 10, borderTop: "1px solid #f1f5f9", paddingTop: 10 }, children: [
|
|
3087
|
+
/* @__PURE__ */ e("div", { style: { fontSize: 11, fontWeight: 600, color: "#7c3aed", marginBottom: 6, textTransform: "uppercase", letterSpacing: "0.05em" }, children: "Mã nhúng — dán vào trước thẻ </body>" }),
|
|
3088
|
+
/* @__PURE__ */ n("div", { style: { position: "relative" }, children: [
|
|
3089
|
+
/* @__PURE__ */ e("pre", { style: {
|
|
3090
|
+
margin: 0,
|
|
3091
|
+
padding: "10px 12px",
|
|
3092
|
+
background: "#f8f7ff",
|
|
3093
|
+
border: "1px solid #e9d5ff",
|
|
3094
|
+
borderRadius: 8,
|
|
3095
|
+
fontSize: 12,
|
|
3096
|
+
color: "#3b0764",
|
|
3097
|
+
overflowX: "auto",
|
|
3098
|
+
fontFamily: "ui-monospace, SFMono-Regular, monospace",
|
|
3099
|
+
lineHeight: 1.5,
|
|
3100
|
+
userSelect: "text"
|
|
3101
|
+
}, children: z }),
|
|
3102
|
+
/* @__PURE__ */ e(
|
|
3103
|
+
"button",
|
|
3104
|
+
{
|
|
3105
|
+
onClick: j,
|
|
3106
|
+
style: {
|
|
3107
|
+
position: "absolute",
|
|
3108
|
+
top: 6,
|
|
3109
|
+
right: 6,
|
|
3110
|
+
fontSize: 11,
|
|
3111
|
+
fontWeight: 600,
|
|
3112
|
+
padding: "3px 10px",
|
|
3113
|
+
borderRadius: 6,
|
|
3114
|
+
border: "1px solid",
|
|
3115
|
+
borderColor: $ ? "#059669" : "#c4b5fd",
|
|
3116
|
+
background: $ ? "#d1fae5" : "#fff",
|
|
3117
|
+
color: $ ? "#059669" : "#7c3aed",
|
|
3118
|
+
cursor: "pointer"
|
|
3119
|
+
},
|
|
3120
|
+
children: $ ? "✓ Đã sao chép" : "Sao chép"
|
|
3121
|
+
}
|
|
3122
|
+
)
|
|
3123
|
+
] })
|
|
3051
3124
|
] })
|
|
3052
3125
|
] });
|
|
3053
3126
|
}
|
|
@@ -3059,7 +3132,7 @@ const kn = [
|
|
|
3059
3132
|
{ id: "livechat", name: "Live Chat", desc: "Website widget", type: "livechat" }
|
|
3060
3133
|
];
|
|
3061
3134
|
function wn({ provider: t, apiUrl: i, onClick: r }) {
|
|
3062
|
-
const [o, h] =
|
|
3135
|
+
const [o, h] = g(!1);
|
|
3063
3136
|
return /* @__PURE__ */ n(
|
|
3064
3137
|
"div",
|
|
3065
3138
|
{
|
|
@@ -3109,28 +3182,28 @@ function Bn({
|
|
|
3109
3182
|
icon: h,
|
|
3110
3183
|
onConversationSelect: S
|
|
3111
3184
|
}) {
|
|
3112
|
-
const
|
|
3185
|
+
const b = (r == null ? void 0 : r.primaryColor) ?? "#2563eb", $ = typeof h == "function" ? h({ size: 20, color: "currentColor" }) : h ?? /* @__PURE__ */ e(pt, { size: 20, strokeWidth: 1.8 }), w = J(new it(t, i)), [y, W] = g(!1), [z, j] = g([]), B = J(null), C = J(null), D = z.filter((L) => (L.unreadCount ?? 0) > 0), I = D.reduce((L, v) => L + (v.unreadCount ?? 0), 0), M = we(async () => {
|
|
3113
3186
|
try {
|
|
3114
|
-
const
|
|
3115
|
-
j(
|
|
3187
|
+
const L = await w.current.listConversations();
|
|
3188
|
+
j(L.items);
|
|
3116
3189
|
} catch {
|
|
3117
3190
|
}
|
|
3118
3191
|
}, []);
|
|
3119
|
-
X(() => (
|
|
3120
|
-
(
|
|
3121
|
-
})), [
|
|
3122
|
-
if (!
|
|
3123
|
-
const
|
|
3124
|
-
var
|
|
3125
|
-
(
|
|
3192
|
+
X(() => (M(), w.current.connectSSE((v) => {
|
|
3193
|
+
(v === "message.new" || v === "conversation.updated") && M();
|
|
3194
|
+
})), [M]), X(() => {
|
|
3195
|
+
if (!y) return;
|
|
3196
|
+
const L = (v) => {
|
|
3197
|
+
var x, E;
|
|
3198
|
+
(x = B.current) != null && x.contains(v.target) || (E = C.current) != null && E.contains(v.target) || W(!1);
|
|
3126
3199
|
};
|
|
3127
|
-
return document.addEventListener("mousedown",
|
|
3128
|
-
}, [
|
|
3129
|
-
const P = async (
|
|
3130
|
-
if (W(!1), S == null || S(
|
|
3200
|
+
return document.addEventListener("mousedown", L), () => document.removeEventListener("mousedown", L);
|
|
3201
|
+
}, [y]);
|
|
3202
|
+
const P = async (L) => {
|
|
3203
|
+
if (W(!1), S == null || S(L.id, L), (L.unreadCount ?? 0) > 0)
|
|
3131
3204
|
try {
|
|
3132
|
-
await w.current.markRead(
|
|
3133
|
-
(
|
|
3205
|
+
await w.current.markRead(L.id), j(
|
|
3206
|
+
(v) => v.map((x) => x.id === L.id ? { ...x, unreadCount: 0 } : x)
|
|
3134
3207
|
);
|
|
3135
3208
|
} catch {
|
|
3136
3209
|
}
|
|
@@ -3139,11 +3212,11 @@ function Bn({
|
|
|
3139
3212
|
/* @__PURE__ */ n(
|
|
3140
3213
|
"button",
|
|
3141
3214
|
{
|
|
3142
|
-
ref:
|
|
3215
|
+
ref: B,
|
|
3143
3216
|
"aria-label": q,
|
|
3144
3217
|
"aria-haspopup": "true",
|
|
3145
|
-
"aria-expanded":
|
|
3146
|
-
onClick: () => W((
|
|
3218
|
+
"aria-expanded": y,
|
|
3219
|
+
onClick: () => W((L) => !L),
|
|
3147
3220
|
style: {
|
|
3148
3221
|
position: "relative",
|
|
3149
3222
|
display: "inline-grid",
|
|
@@ -3152,13 +3225,13 @@ function Bn({
|
|
|
3152
3225
|
height: 40,
|
|
3153
3226
|
border: 0,
|
|
3154
3227
|
borderRadius: "50%",
|
|
3155
|
-
background:
|
|
3156
|
-
color:
|
|
3228
|
+
background: y ? `${b}18` : "transparent",
|
|
3229
|
+
color: y ? b : "#6b7280",
|
|
3157
3230
|
cursor: "pointer",
|
|
3158
3231
|
transition: "background 150ms ease, color 150ms ease"
|
|
3159
3232
|
},
|
|
3160
3233
|
children: [
|
|
3161
|
-
|
|
3234
|
+
$,
|
|
3162
3235
|
I > 0 && /* @__PURE__ */ e(
|
|
3163
3236
|
"span",
|
|
3164
3237
|
{
|
|
@@ -3186,7 +3259,7 @@ function Bn({
|
|
|
3186
3259
|
]
|
|
3187
3260
|
}
|
|
3188
3261
|
),
|
|
3189
|
-
|
|
3262
|
+
y && /* @__PURE__ */ n(
|
|
3190
3263
|
"div",
|
|
3191
3264
|
{
|
|
3192
3265
|
ref: C,
|
|
@@ -3219,8 +3292,8 @@ function Bn({
|
|
|
3219
3292
|
I > 0 && /* @__PURE__ */ n("span", { style: {
|
|
3220
3293
|
fontSize: 11,
|
|
3221
3294
|
fontWeight: 600,
|
|
3222
|
-
background: `${
|
|
3223
|
-
color:
|
|
3295
|
+
background: `${b}14`,
|
|
3296
|
+
color: b,
|
|
3224
3297
|
borderRadius: 999,
|
|
3225
3298
|
padding: "2px 8px"
|
|
3226
3299
|
}, children: [
|
|
@@ -3239,15 +3312,15 @@ function Bn({
|
|
|
3239
3312
|
}, children: [
|
|
3240
3313
|
/* @__PURE__ */ e(pt, { size: 28, strokeWidth: 1.5 }),
|
|
3241
3314
|
/* @__PURE__ */ e("span", { style: { fontSize: 13 }, children: te })
|
|
3242
|
-
] }) : D.map((
|
|
3315
|
+
] }) : D.map((L) => /* @__PURE__ */ e(
|
|
3243
3316
|
In,
|
|
3244
3317
|
{
|
|
3245
|
-
conversation:
|
|
3246
|
-
primary:
|
|
3318
|
+
conversation: L,
|
|
3319
|
+
primary: b,
|
|
3247
3320
|
apiUrl: t,
|
|
3248
3321
|
onSelect: P
|
|
3249
3322
|
},
|
|
3250
|
-
|
|
3323
|
+
L.id
|
|
3251
3324
|
)) })
|
|
3252
3325
|
]
|
|
3253
3326
|
}
|
|
@@ -3260,7 +3333,7 @@ function In({
|
|
|
3260
3333
|
apiUrl: r,
|
|
3261
3334
|
onSelect: o
|
|
3262
3335
|
}) {
|
|
3263
|
-
const [h, S] =
|
|
3336
|
+
const [h, S] = g(!1), b = t.contactName ?? t.providerConversationKey, $ = t.unreadCount ?? 0;
|
|
3264
3337
|
return /* @__PURE__ */ n(
|
|
3265
3338
|
"button",
|
|
3266
3339
|
{
|
|
@@ -3274,7 +3347,7 @@ function In({
|
|
|
3274
3347
|
padding: "10px 16px",
|
|
3275
3348
|
border: 0,
|
|
3276
3349
|
borderBottom: "1px solid #f1f5f9",
|
|
3277
|
-
background: h ? "#f7f9fc" :
|
|
3350
|
+
background: h ? "#f7f9fc" : $ > 0 ? "#f0f4ff" : "#fff",
|
|
3278
3351
|
textAlign: "left",
|
|
3279
3352
|
cursor: "pointer",
|
|
3280
3353
|
transition: "background 100ms ease",
|
|
@@ -3286,7 +3359,7 @@ function In({
|
|
|
3286
3359
|
dt,
|
|
3287
3360
|
{
|
|
3288
3361
|
src: t.contactPictureUrl,
|
|
3289
|
-
fallback: Sn(
|
|
3362
|
+
fallback: Sn(b),
|
|
3290
3363
|
style: {
|
|
3291
3364
|
width: 42,
|
|
3292
3365
|
height: 42,
|
|
@@ -3307,15 +3380,15 @@ function In({
|
|
|
3307
3380
|
/* @__PURE__ */ n("span", { style: { display: "flex", justifyContent: "space-between", alignItems: "center", gap: 6 }, children: [
|
|
3308
3381
|
/* @__PURE__ */ e("span", { style: {
|
|
3309
3382
|
fontSize: 13,
|
|
3310
|
-
fontWeight:
|
|
3383
|
+
fontWeight: $ > 0 ? 700 : 500,
|
|
3311
3384
|
color: "#172033",
|
|
3312
3385
|
overflow: "hidden",
|
|
3313
3386
|
textOverflow: "ellipsis",
|
|
3314
3387
|
whiteSpace: "nowrap"
|
|
3315
|
-
}, children:
|
|
3388
|
+
}, children: b }),
|
|
3316
3389
|
/* @__PURE__ */ n("span", { style: { display: "flex", alignItems: "center", gap: 5, flexShrink: 0 }, children: [
|
|
3317
3390
|
/* @__PURE__ */ e("time", { style: { fontSize: 11, color: "#9aa5b5", whiteSpace: "nowrap" }, children: Cn(t.lastMessageAt) }),
|
|
3318
|
-
|
|
3391
|
+
$ > 0 && /* @__PURE__ */ e("span", { style: {
|
|
3319
3392
|
display: "inline-grid",
|
|
3320
3393
|
placeItems: "center",
|
|
3321
3394
|
minWidth: 18,
|
|
@@ -3326,15 +3399,15 @@ function In({
|
|
|
3326
3399
|
fontSize: 10,
|
|
3327
3400
|
fontWeight: 800,
|
|
3328
3401
|
padding: "0 4px"
|
|
3329
|
-
}, children:
|
|
3402
|
+
}, children: $ > 99 ? "99+" : $ })
|
|
3330
3403
|
] })
|
|
3331
3404
|
] }),
|
|
3332
3405
|
/* @__PURE__ */ n("span", { style: {
|
|
3333
3406
|
display: "block",
|
|
3334
3407
|
marginTop: 2,
|
|
3335
3408
|
fontSize: 12,
|
|
3336
|
-
color:
|
|
3337
|
-
fontWeight:
|
|
3409
|
+
color: $ > 0 ? "#374151" : "#9aa5b5",
|
|
3410
|
+
fontWeight: $ > 0 ? 500 : 400,
|
|
3338
3411
|
overflow: "hidden",
|
|
3339
3412
|
textOverflow: "ellipsis",
|
|
3340
3413
|
whiteSpace: "nowrap"
|
|
@@ -3347,7 +3420,7 @@ function In({
|
|
|
3347
3420
|
}
|
|
3348
3421
|
);
|
|
3349
3422
|
}
|
|
3350
|
-
console.log("[ChannelHub] widget v0.1.
|
|
3423
|
+
console.log("[ChannelHub] widget v0.1.11 loaded");
|
|
3351
3424
|
export {
|
|
3352
3425
|
$n as ChannelHubChannels,
|
|
3353
3426
|
it as ChannelHubClient,
|