@channelhub/widget 0.1.11 → 0.1.12
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/ChannelHubInbox.d.ts.map +1 -1
- package/dist/index.cjs +34 -29
- package/dist/index.js +1318 -1186
- package/package.json +1 -1
- package/src/ChannelHubInbox.tsx +220 -56
package/dist/index.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { jsx as e, jsxs as n, Fragment as
|
|
2
|
-
import { forwardRef as
|
|
3
|
-
import { createPortal as
|
|
1
|
+
import { jsx as e, jsxs as n, Fragment as ne } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as Xe, createElement as dt, createContext as Ht, useRef as X, useState as u, useMemo as We, useEffect as K, useCallback as Te, useImperativeHandle as Ft, useContext as st, Component as Kt } from "react";
|
|
3
|
+
import { createPortal as At } from "react-dom";
|
|
4
4
|
/**
|
|
5
5
|
* @license lucide-react v0.468.0 - ISC
|
|
6
6
|
*
|
|
7
7
|
* This source code is licensed under the ISC license.
|
|
8
8
|
* See the LICENSE file in the root directory of this source tree.
|
|
9
9
|
*/
|
|
10
|
-
const
|
|
10
|
+
const qt = (t) => t.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase(), jt = (...t) => t.filter((i, o, r) => !!i && i.trim() !== "" && r.indexOf(i) === o).join(" ").trim();
|
|
11
11
|
/**
|
|
12
12
|
* @license lucide-react v0.468.0 - ISC
|
|
13
13
|
*
|
|
14
14
|
* This source code is licensed under the ISC license.
|
|
15
15
|
* See the LICENSE file in the root directory of this source tree.
|
|
16
16
|
*/
|
|
17
|
-
var
|
|
17
|
+
var Vt = {
|
|
18
18
|
xmlns: "http://www.w3.org/2000/svg",
|
|
19
19
|
width: 24,
|
|
20
20
|
height: 24,
|
|
@@ -31,31 +31,31 @@ var Ht = {
|
|
|
31
31
|
* This source code is licensed under the ISC license.
|
|
32
32
|
* See the LICENSE file in the root directory of this source tree.
|
|
33
33
|
*/
|
|
34
|
-
const
|
|
34
|
+
const Gt = Xe(
|
|
35
35
|
({
|
|
36
36
|
color: t = "currentColor",
|
|
37
37
|
size: i = 24,
|
|
38
|
-
strokeWidth:
|
|
39
|
-
absoluteStrokeWidth:
|
|
40
|
-
className:
|
|
41
|
-
children:
|
|
42
|
-
iconNode:
|
|
43
|
-
|
|
44
|
-
}, w) =>
|
|
38
|
+
strokeWidth: o = 2,
|
|
39
|
+
absoluteStrokeWidth: r,
|
|
40
|
+
className: c = "",
|
|
41
|
+
children: C,
|
|
42
|
+
iconNode: y,
|
|
43
|
+
...L
|
|
44
|
+
}, w) => dt(
|
|
45
45
|
"svg",
|
|
46
46
|
{
|
|
47
47
|
ref: w,
|
|
48
|
-
...
|
|
48
|
+
...Vt,
|
|
49
49
|
width: i,
|
|
50
50
|
height: i,
|
|
51
51
|
stroke: t,
|
|
52
|
-
strokeWidth:
|
|
53
|
-
className:
|
|
54
|
-
|
|
52
|
+
strokeWidth: r ? Number(o) * 24 / Number(i) : o,
|
|
53
|
+
className: jt("lucide", c),
|
|
54
|
+
...L
|
|
55
55
|
},
|
|
56
56
|
[
|
|
57
|
-
...
|
|
58
|
-
...Array.isArray(
|
|
57
|
+
...y.map(([g, $]) => dt(g, $)),
|
|
58
|
+
...Array.isArray(C) ? C : [C]
|
|
59
59
|
]
|
|
60
60
|
)
|
|
61
61
|
);
|
|
@@ -66,15 +66,15 @@ const At = Pe(
|
|
|
66
66
|
* See the LICENSE file in the root directory of this source tree.
|
|
67
67
|
*/
|
|
68
68
|
const Y = (t, i) => {
|
|
69
|
-
const
|
|
70
|
-
({ className:
|
|
71
|
-
ref:
|
|
69
|
+
const o = Xe(
|
|
70
|
+
({ className: r, ...c }, C) => dt(Gt, {
|
|
71
|
+
ref: C,
|
|
72
72
|
iconNode: i,
|
|
73
|
-
className:
|
|
74
|
-
...
|
|
73
|
+
className: jt(`lucide-${qt(t)}`, r),
|
|
74
|
+
...c
|
|
75
75
|
})
|
|
76
76
|
);
|
|
77
|
-
return
|
|
77
|
+
return o.displayName = `${t}`, o;
|
|
78
78
|
};
|
|
79
79
|
/**
|
|
80
80
|
* @license lucide-react v0.468.0 - ISC
|
|
@@ -82,7 +82,17 @@ const Y = (t, i) => {
|
|
|
82
82
|
* This source code is licensed under the ISC license.
|
|
83
83
|
* See the LICENSE file in the root directory of this source tree.
|
|
84
84
|
*/
|
|
85
|
-
const
|
|
85
|
+
const Xt = Y("ArrowLeft", [
|
|
86
|
+
["path", { d: "m12 19-7-7 7-7", key: "1l729n" }],
|
|
87
|
+
["path", { d: "M19 12H5", key: "x3x0zl" }]
|
|
88
|
+
]);
|
|
89
|
+
/**
|
|
90
|
+
* @license lucide-react v0.468.0 - ISC
|
|
91
|
+
*
|
|
92
|
+
* This source code is licensed under the ISC license.
|
|
93
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
94
|
+
*/
|
|
95
|
+
const wt = Y("CheckCheck", [
|
|
86
96
|
["path", { d: "M18 6 7 17l-5-5", key: "116fxf" }],
|
|
87
97
|
["path", { d: "m22 10-7.5 7.5L13 16", key: "ke71qq" }]
|
|
88
98
|
]);
|
|
@@ -92,14 +102,14 @@ const ht = Y("CheckCheck", [
|
|
|
92
102
|
* This source code is licensed under the ISC license.
|
|
93
103
|
* See the LICENSE file in the root directory of this source tree.
|
|
94
104
|
*/
|
|
95
|
-
const
|
|
105
|
+
const gt = Y("Check", [["path", { d: "M20 6 9 17l-5-5", key: "1gmf2c" }]]);
|
|
96
106
|
/**
|
|
97
107
|
* @license lucide-react v0.468.0 - ISC
|
|
98
108
|
*
|
|
99
109
|
* This source code is licensed under the ISC license.
|
|
100
110
|
* See the LICENSE file in the root directory of this source tree.
|
|
101
111
|
*/
|
|
102
|
-
const
|
|
112
|
+
const ct = Y("ChevronDown", [
|
|
103
113
|
["path", { d: "m6 9 6 6 6-6", key: "qrunsl" }]
|
|
104
114
|
]);
|
|
105
115
|
/**
|
|
@@ -108,7 +118,7 @@ const nt = Y("ChevronDown", [
|
|
|
108
118
|
* This source code is licensed under the ISC license.
|
|
109
119
|
* See the LICENSE file in the root directory of this source tree.
|
|
110
120
|
*/
|
|
111
|
-
const
|
|
121
|
+
const Yt = Y("ChevronRight", [
|
|
112
122
|
["path", { d: "m9 18 6-6-6-6", key: "mthhwq" }]
|
|
113
123
|
]);
|
|
114
124
|
/**
|
|
@@ -117,7 +127,7 @@ const jt = Y("ChevronRight", [
|
|
|
117
127
|
* This source code is licensed under the ISC license.
|
|
118
128
|
* See the LICENSE file in the root directory of this source tree.
|
|
119
129
|
*/
|
|
120
|
-
const
|
|
130
|
+
const Jt = Y("CircleAlert", [
|
|
121
131
|
["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
|
|
122
132
|
["line", { x1: "12", x2: "12", y1: "8", y2: "12", key: "1pkeuh" }],
|
|
123
133
|
["line", { x1: "12", x2: "12.01", y1: "16", y2: "16", key: "4dfq90" }]
|
|
@@ -128,7 +138,7 @@ const Et = Y("CircleAlert", [
|
|
|
128
138
|
* This source code is licensed under the ISC license.
|
|
129
139
|
* See the LICENSE file in the root directory of this source tree.
|
|
130
140
|
*/
|
|
131
|
-
const
|
|
141
|
+
const Et = Y("Ellipsis", [
|
|
132
142
|
["circle", { cx: "12", cy: "12", r: "1", key: "41hilf" }],
|
|
133
143
|
["circle", { cx: "19", cy: "12", r: "1", key: "1wjl8i" }],
|
|
134
144
|
["circle", { cx: "5", cy: "12", r: "1", key: "1pcz8c" }]
|
|
@@ -139,7 +149,7 @@ const It = Y("Ellipsis", [
|
|
|
139
149
|
* This source code is licensed under the ISC license.
|
|
140
150
|
* See the LICENSE file in the root directory of this source tree.
|
|
141
151
|
*/
|
|
142
|
-
const
|
|
152
|
+
const Zt = Y("Image", [
|
|
143
153
|
["rect", { width: "18", height: "18", x: "3", y: "3", rx: "2", ry: "2", key: "1m3agn" }],
|
|
144
154
|
["circle", { cx: "9", cy: "9", r: "2", key: "af1f0g" }],
|
|
145
155
|
["path", { d: "m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21", key: "1xmnt7" }]
|
|
@@ -150,7 +160,7 @@ const Ot = Y("Image", [
|
|
|
150
160
|
* This source code is licensed under the ISC license.
|
|
151
161
|
* See the LICENSE file in the root directory of this source tree.
|
|
152
162
|
*/
|
|
153
|
-
const
|
|
163
|
+
const _t = Y("Inbox", [
|
|
154
164
|
["polyline", { points: "22 12 16 12 14 15 10 15 8 12 2 12", key: "o97t9d" }],
|
|
155
165
|
[
|
|
156
166
|
"path",
|
|
@@ -166,7 +176,7 @@ const Ut = Y("Inbox", [
|
|
|
166
176
|
* This source code is licensed under the ISC license.
|
|
167
177
|
* See the LICENSE file in the root directory of this source tree.
|
|
168
178
|
*/
|
|
169
|
-
const
|
|
179
|
+
const Qt = Y("Info", [
|
|
170
180
|
["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
|
|
171
181
|
["path", { d: "M12 16v-4", key: "1dtifu" }],
|
|
172
182
|
["path", { d: "M12 8h.01", key: "e9boi3" }]
|
|
@@ -177,7 +187,7 @@ const Dt = Y("Info", [
|
|
|
177
187
|
* This source code is licensed under the ISC license.
|
|
178
188
|
* See the LICENSE file in the root directory of this source tree.
|
|
179
189
|
*/
|
|
180
|
-
const
|
|
190
|
+
const Ot = Y("LoaderCircle", [
|
|
181
191
|
["path", { d: "M21 12a9 9 0 1 1-6.219-8.56", key: "13zald" }]
|
|
182
192
|
]);
|
|
183
193
|
/**
|
|
@@ -186,7 +196,7 @@ const zt = Y("LoaderCircle", [
|
|
|
186
196
|
* This source code is licensed under the ISC license.
|
|
187
197
|
* See the LICENSE file in the root directory of this source tree.
|
|
188
198
|
*/
|
|
189
|
-
const
|
|
199
|
+
const St = Y("MessageCircle", [
|
|
190
200
|
["path", { d: "M7.9 20A9 9 0 1 0 4 16.1L2 22Z", key: "vv11sd" }]
|
|
191
201
|
]);
|
|
192
202
|
/**
|
|
@@ -195,7 +205,7 @@ const pt = Y("MessageCircle", [
|
|
|
195
205
|
* This source code is licensed under the ISC license.
|
|
196
206
|
* See the LICENSE file in the root directory of this source tree.
|
|
197
207
|
*/
|
|
198
|
-
const
|
|
208
|
+
const en = Y("Paperclip", [
|
|
199
209
|
["path", { d: "M13.234 20.252 21 12.3", key: "1cbrk9" }],
|
|
200
210
|
[
|
|
201
211
|
"path",
|
|
@@ -211,7 +221,7 @@ const Pt = Y("Paperclip", [
|
|
|
211
221
|
* This source code is licensed under the ISC license.
|
|
212
222
|
* See the LICENSE file in the root directory of this source tree.
|
|
213
223
|
*/
|
|
214
|
-
const
|
|
224
|
+
const tn = Y("Play", [
|
|
215
225
|
["polygon", { points: "6 3 20 12 6 21 6 3", key: "1oa8hb" }]
|
|
216
226
|
]);
|
|
217
227
|
/**
|
|
@@ -220,7 +230,7 @@ const Nt = Y("Play", [
|
|
|
220
230
|
* This source code is licensed under the ISC license.
|
|
221
231
|
* See the LICENSE file in the root directory of this source tree.
|
|
222
232
|
*/
|
|
223
|
-
const
|
|
233
|
+
const Ct = Y("Search", [
|
|
224
234
|
["circle", { cx: "11", cy: "11", r: "8", key: "4ej97u" }],
|
|
225
235
|
["path", { d: "m21 21-4.3-4.3", key: "1qie3q" }]
|
|
226
236
|
]);
|
|
@@ -230,7 +240,7 @@ const ut = Y("Search", [
|
|
|
230
240
|
* This source code is licensed under the ISC license.
|
|
231
241
|
* See the LICENSE file in the root directory of this source tree.
|
|
232
242
|
*/
|
|
233
|
-
const
|
|
243
|
+
const nn = Y("Send", [
|
|
234
244
|
[
|
|
235
245
|
"path",
|
|
236
246
|
{
|
|
@@ -246,7 +256,7 @@ const Ft = Y("Send", [
|
|
|
246
256
|
* This source code is licensed under the ISC license.
|
|
247
257
|
* See the LICENSE file in the root directory of this source tree.
|
|
248
258
|
*/
|
|
249
|
-
const
|
|
259
|
+
const on = Y("SlidersHorizontal", [
|
|
250
260
|
["line", { x1: "21", x2: "14", y1: "4", y2: "4", key: "obuewd" }],
|
|
251
261
|
["line", { x1: "10", x2: "3", y1: "4", y2: "4", key: "1q6298" }],
|
|
252
262
|
["line", { x1: "21", x2: "12", y1: "12", y2: "12", key: "1iu8h1" }],
|
|
@@ -263,7 +273,7 @@ const Kt = Y("SlidersHorizontal", [
|
|
|
263
273
|
* This source code is licensed under the ISC license.
|
|
264
274
|
* See the LICENSE file in the root directory of this source tree.
|
|
265
275
|
*/
|
|
266
|
-
const
|
|
276
|
+
const rn = Y("Smile", [
|
|
267
277
|
["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
|
|
268
278
|
["path", { d: "M8 14s1.5 2 4 2 4-2 4-2", key: "1y1vjs" }],
|
|
269
279
|
["line", { x1: "9", x2: "9.01", y1: "9", y2: "9", key: "yxxnd0" }],
|
|
@@ -275,7 +285,7 @@ const qt = Y("Smile", [
|
|
|
275
285
|
* This source code is licensed under the ISC license.
|
|
276
286
|
* See the LICENSE file in the root directory of this source tree.
|
|
277
287
|
*/
|
|
278
|
-
const
|
|
288
|
+
const an = Y("UserCheck", [
|
|
279
289
|
["path", { d: "M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2", key: "1yyitq" }],
|
|
280
290
|
["circle", { cx: "9", cy: "7", r: "4", key: "nufk8" }],
|
|
281
291
|
["polyline", { points: "16 11 18 13 22 9", key: "1pwet4" }]
|
|
@@ -286,7 +296,7 @@ const Vt = Y("UserCheck", [
|
|
|
286
296
|
* This source code is licensed under the ISC license.
|
|
287
297
|
* See the LICENSE file in the root directory of this source tree.
|
|
288
298
|
*/
|
|
289
|
-
const
|
|
299
|
+
const It = Y("UserPlus", [
|
|
290
300
|
["path", { d: "M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2", key: "1yyitq" }],
|
|
291
301
|
["circle", { cx: "9", cy: "7", r: "4", key: "nufk8" }],
|
|
292
302
|
["line", { x1: "19", x2: "19", y1: "8", y2: "14", key: "1bvyxn" }],
|
|
@@ -298,7 +308,7 @@ const ft = Y("UserPlus", [
|
|
|
298
308
|
* This source code is licensed under the ISC license.
|
|
299
309
|
* See the LICENSE file in the root directory of this source tree.
|
|
300
310
|
*/
|
|
301
|
-
const
|
|
311
|
+
const Ve = Y("X", [
|
|
302
312
|
["path", { d: "M18 6 6 18", key: "1bl5f8" }],
|
|
303
313
|
["path", { d: "m6 6 12 12", key: "d8bk6v" }]
|
|
304
314
|
]);
|
|
@@ -308,7 +318,7 @@ const Ue = Y("X", [
|
|
|
308
318
|
* This source code is licensed under the ISC license.
|
|
309
319
|
* See the LICENSE file in the root directory of this source tree.
|
|
310
320
|
*/
|
|
311
|
-
const
|
|
321
|
+
const ln = Y("Zap", [
|
|
312
322
|
[
|
|
313
323
|
"path",
|
|
314
324
|
{
|
|
@@ -317,29 +327,29 @@ const Gt = Y("Zap", [
|
|
|
317
327
|
}
|
|
318
328
|
]
|
|
319
329
|
]);
|
|
320
|
-
class
|
|
321
|
-
constructor(i,
|
|
322
|
-
this.apiUrl = i, this.token =
|
|
330
|
+
class ht {
|
|
331
|
+
constructor(i, o) {
|
|
332
|
+
this.apiUrl = i, this.token = o;
|
|
323
333
|
}
|
|
324
|
-
async request(i,
|
|
325
|
-
const
|
|
334
|
+
async request(i, o, r) {
|
|
335
|
+
const c = {
|
|
326
336
|
authorization: `Bearer ${this.token}`,
|
|
327
|
-
...
|
|
328
|
-
...
|
|
329
|
-
},
|
|
330
|
-
...
|
|
331
|
-
headers:
|
|
332
|
-
}),
|
|
333
|
-
if (!
|
|
334
|
-
return
|
|
337
|
+
...r ? {} : { "content-type": "application/json" },
|
|
338
|
+
...o == null ? void 0 : o.headers
|
|
339
|
+
}, C = await fetch(`${this.apiUrl}${i}`, {
|
|
340
|
+
...o,
|
|
341
|
+
headers: c
|
|
342
|
+
}), y = await C.json().catch(() => null);
|
|
343
|
+
if (!C.ok) throw new Error((y == null ? void 0 : y.message) ?? `Request failed (${C.status})`);
|
|
344
|
+
return y;
|
|
335
345
|
}
|
|
336
346
|
getSessionMe() {
|
|
337
347
|
return this.request("/v1/auth/session/me");
|
|
338
348
|
}
|
|
339
|
-
assignConversation(i,
|
|
349
|
+
assignConversation(i, o) {
|
|
340
350
|
return this.request(`/v1/conversations/${encodeURIComponent(i)}/assignee`, {
|
|
341
351
|
method: "PUT",
|
|
342
|
-
body: JSON.stringify({ agent:
|
|
352
|
+
body: JSON.stringify({ agent: o })
|
|
343
353
|
});
|
|
344
354
|
}
|
|
345
355
|
listConnections() {
|
|
@@ -348,87 +358,87 @@ class it {
|
|
|
348
358
|
listConversations(i) {
|
|
349
359
|
return this.request(`/v1/conversations${i ? `?cursor=${encodeURIComponent(i)}` : ""}`);
|
|
350
360
|
}
|
|
351
|
-
listMessages(i,
|
|
352
|
-
return this.request(`/v1/conversations/${encodeURIComponent(i)}/messages${
|
|
361
|
+
listMessages(i, o) {
|
|
362
|
+
return this.request(`/v1/conversations/${encodeURIComponent(i)}/messages${o ? `?cursor=${encodeURIComponent(o)}` : ""}`);
|
|
353
363
|
}
|
|
354
364
|
getMessage(i) {
|
|
355
365
|
return this.request(`/v1/messages/${encodeURIComponent(i)}`);
|
|
356
366
|
}
|
|
357
|
-
sendMessage(i,
|
|
367
|
+
sendMessage(i, o, r) {
|
|
358
368
|
return this.request(`/v1/conversations/${encodeURIComponent(i)}/messages`, {
|
|
359
369
|
method: "POST",
|
|
360
370
|
headers: { "idempotency-key": crypto.randomUUID() },
|
|
361
|
-
body: JSON.stringify({ text:
|
|
371
|
+
body: JSON.stringify({ text: o, attachments: r })
|
|
362
372
|
});
|
|
363
373
|
}
|
|
364
374
|
async markRead(i) {
|
|
365
|
-
const
|
|
375
|
+
const o = await fetch(`${this.apiUrl}/v1/conversations/${encodeURIComponent(i)}/mark-read`, {
|
|
366
376
|
method: "POST",
|
|
367
377
|
headers: { authorization: `Bearer ${this.token}` }
|
|
368
378
|
});
|
|
369
|
-
if (!
|
|
379
|
+
if (!o.ok && o.status !== 204) throw new Error(`markRead failed (${o.status})`);
|
|
370
380
|
}
|
|
371
381
|
listCannedResponses(i) {
|
|
372
|
-
const
|
|
373
|
-
return this.request(`/v1/canned-responses${
|
|
382
|
+
const o = i != null && i.trim() ? `?search=${encodeURIComponent(i)}` : "";
|
|
383
|
+
return this.request(`/v1/canned-responses${o}`);
|
|
374
384
|
}
|
|
375
385
|
getNote(i) {
|
|
376
386
|
return this.request(`/v1/conversations/${encodeURIComponent(i)}/note`);
|
|
377
387
|
}
|
|
378
|
-
patchContact(i,
|
|
388
|
+
patchContact(i, o) {
|
|
379
389
|
return this.request(`/v1/contacts/${encodeURIComponent(i)}`, {
|
|
380
390
|
method: "PATCH",
|
|
381
|
-
body: JSON.stringify({ externalId:
|
|
391
|
+
body: JSON.stringify({ externalId: o })
|
|
382
392
|
});
|
|
383
393
|
}
|
|
384
|
-
upsertNote(i,
|
|
394
|
+
upsertNote(i, o) {
|
|
385
395
|
return this.request(`/v1/conversations/${encodeURIComponent(i)}/note`, {
|
|
386
396
|
method: "PUT",
|
|
387
|
-
body: JSON.stringify({ content:
|
|
397
|
+
body: JSON.stringify({ content: o })
|
|
388
398
|
});
|
|
389
399
|
}
|
|
390
400
|
async uploadAttachment(i) {
|
|
391
|
-
const
|
|
392
|
-
return
|
|
401
|
+
const o = new FormData();
|
|
402
|
+
return o.append("file", i), this.request(
|
|
393
403
|
"/v1/attachments",
|
|
394
|
-
{ method: "POST", body:
|
|
404
|
+
{ method: "POST", body: o },
|
|
395
405
|
!0
|
|
396
406
|
);
|
|
397
407
|
}
|
|
398
408
|
connectSSE(i) {
|
|
399
|
-
const
|
|
400
|
-
let
|
|
401
|
-
const
|
|
402
|
-
|
|
403
|
-
i("message.new", JSON.parse(
|
|
404
|
-
}),
|
|
405
|
-
i("conversation.updated", JSON.parse(
|
|
406
|
-
}),
|
|
407
|
-
|
|
409
|
+
const o = `${this.apiUrl}/v1/events?token=${encodeURIComponent(this.token)}`;
|
|
410
|
+
let r, c, C = !1;
|
|
411
|
+
const y = () => {
|
|
412
|
+
r = new EventSource(o), r.addEventListener("message.new", (L) => {
|
|
413
|
+
i("message.new", JSON.parse(L.data));
|
|
414
|
+
}), r.addEventListener("conversation.updated", (L) => {
|
|
415
|
+
i("conversation.updated", JSON.parse(L.data));
|
|
416
|
+
}), r.onerror = () => {
|
|
417
|
+
r.close(), C || (c = setTimeout(y, 5e3));
|
|
408
418
|
};
|
|
409
419
|
};
|
|
410
|
-
return
|
|
411
|
-
|
|
420
|
+
return y(), () => {
|
|
421
|
+
C = !0, clearTimeout(c), r == null || r.close();
|
|
412
422
|
};
|
|
413
423
|
}
|
|
414
424
|
}
|
|
415
|
-
function
|
|
416
|
-
return t ? /* @__PURE__ */ e("img", { src: t, alt: i, style: { width: 38, height: 38, borderRadius: "50%", objectFit: "cover", ...
|
|
425
|
+
function bt({ src: t, alt: i = "", fallback: o, style: r }) {
|
|
426
|
+
return t ? /* @__PURE__ */ e("img", { src: t, alt: i, style: { width: 38, height: 38, borderRadius: "50%", objectFit: "cover", ...r } }) : /* @__PURE__ */ e("span", { style: { display: "grid", placeItems: "center", width: 38, height: 38, borderRadius: "50%", ...r }, children: o });
|
|
417
427
|
}
|
|
418
|
-
function
|
|
419
|
-
return /* @__PURE__ */ e("button", { ...
|
|
428
|
+
function dn({ variant: t = "ghost", style: i, ...o }) {
|
|
429
|
+
return /* @__PURE__ */ e("button", { ...o, style: { display: "inline-flex", alignItems: "center", justifyContent: "center", border: t === "outline" ? "1px solid #e7ebf2" : 0, borderRadius: 8, cursor: "pointer", font: "inherit", background: t === "default" ? "#2563eb" : "transparent", ...i } });
|
|
420
430
|
}
|
|
421
|
-
function
|
|
431
|
+
function sn({ style: t, ...i }) {
|
|
422
432
|
return /* @__PURE__ */ e("input", { ...i, style: { width: "100%", minWidth: 0, border: 0, outline: 0, background: "transparent", font: "inherit", ...t } });
|
|
423
433
|
}
|
|
424
|
-
const
|
|
425
|
-
({ children: t, style: i },
|
|
426
|
-
),
|
|
427
|
-
function({ style: i, ...
|
|
428
|
-
return /* @__PURE__ */ e("textarea", { ref:
|
|
434
|
+
const Ut = Xe(
|
|
435
|
+
({ children: t, style: i }, o) => /* @__PURE__ */ e("div", { ref: o, style: { minHeight: 0, overflowY: "auto", overscrollBehavior: "contain", ...i }, children: t })
|
|
436
|
+
), cn = Xe(
|
|
437
|
+
function({ style: i, ...o }, r) {
|
|
438
|
+
return /* @__PURE__ */ e("textarea", { ref: r, ...o, style: { display: "block", width: "100%", minWidth: 0, boxSizing: "border-box", resize: "vertical", border: 0, outline: 0, background: "transparent", font: "inherit", ...i } });
|
|
429
439
|
}
|
|
430
440
|
);
|
|
431
|
-
function
|
|
441
|
+
function hn(t) {
|
|
432
442
|
return {
|
|
433
443
|
id: t.contactId ?? t.providerConversationKey,
|
|
434
444
|
name: t.contactName,
|
|
@@ -437,10 +447,10 @@ function Zt(t) {
|
|
|
437
447
|
...t.contactExternalId ? { externalId: t.contactExternalId } : {}
|
|
438
448
|
};
|
|
439
449
|
}
|
|
440
|
-
function
|
|
450
|
+
function ot(t, i) {
|
|
441
451
|
return {
|
|
442
452
|
conversation: t,
|
|
443
|
-
contact:
|
|
453
|
+
contact: hn(t),
|
|
444
454
|
provider: i == null ? void 0 : i.provider,
|
|
445
455
|
recentMessages: i == null ? void 0 : i.recentMessages,
|
|
446
456
|
linkContact: (i == null ? void 0 : i.linkContact) ?? (async () => {
|
|
@@ -451,7 +461,7 @@ function Je(t, i) {
|
|
|
451
461
|
})
|
|
452
462
|
};
|
|
453
463
|
}
|
|
454
|
-
class
|
|
464
|
+
class pn extends Kt {
|
|
455
465
|
constructor() {
|
|
456
466
|
super(...arguments), this.state = { caught: !1 };
|
|
457
467
|
}
|
|
@@ -462,34 +472,34 @@ class _t extends Lt {
|
|
|
462
472
|
return this.state.caught ? null : this.props.children;
|
|
463
473
|
}
|
|
464
474
|
}
|
|
465
|
-
const
|
|
475
|
+
const a = { ink: "#172033", muted: "#718096", line: "#e7ebf2", surface: "#f7f9fc", white: "#fff" }, zt = [
|
|
466
476
|
{ icon: "😊", emojis: ["😀", "😁", "😂", "🤣", "😊", "😇", "🙂", "😉", "😍", "🥰", "😘", "😋", "😎", "🤩", "😏", "😒", "😔", "😢", "😭", "😤", "😠", "🤯", "😱", "🥳", "😴", "🤔", "🤗", "🫡", "😮", "🤧", "🥺", "😶", "🫠", "🤭", "🤫"] },
|
|
467
477
|
{ icon: "👋", emojis: ["👍", "👎", "👏", "🙏", "🤝", "✌️", "🤞", "🫡", "💪", "🤜", "👊", "✊", "🖐", "👌", "🤌", "🤏", "☝️", "👆", "👇", "👉", "👈", "🤙", "💅", "🫶", "❤️", "🧡", "💛", "💚", "💙", "💜", "🖤", "💔", "❣️", "💕", "💯"] },
|
|
468
478
|
{ icon: "🐱", emojis: ["🐶", "🐱", "🐭", "🐹", "🐰", "🦊", "🐻", "🐼", "🐨", "🐯", "🦁", "🐮", "🐷", "🐸", "🐵", "🙈", "🐔", "🐧", "🐦", "🦆", "🦅", "🦉", "🦋", "🐝", "🐛", "🐢", "🦎", "🐬", "🦈", "🐳", "🐙", "🦑"] },
|
|
469
479
|
{ icon: "🍕", emojis: ["🍎", "🍊", "🍋", "🍇", "🍓", "🍒", "🥝", "🥑", "🍔", "🍕", "🌮", "🍜", "🍣", "🍦", "🎂", "🍰", "🧁", "☕", "🧋", "🥤", "🍺", "🥂", "🍾", "🧃", "🧊"] },
|
|
470
480
|
{ icon: "⚽", emojis: ["⚽", "🏀", "🏈", "⚾", "🎾", "🏐", "🏓", "🎮", "🎲", "🎯", "🎳", "🏆", "🥇", "🎖", "🎁", "🎉", "🎊", "🎈", "🎭", "🎨", "🎬", "🎵", "🎸", "🎹", "🎺", "🪗", "🎻"] },
|
|
471
481
|
{ icon: "🌍", emojis: ["🌍", "🌈", "⭐", "🌙", "☀️", "⛅", "🌊", "🔥", "💧", "🌿", "🌸", "🌺", "🌻", "🍀", "🌴", "🏔", "🏖", "🏕", "🌃", "🏙", "🌅", "🌄", "🌠", "🌌", "🌋", "🏝"] }
|
|
472
|
-
],
|
|
473
|
-
function
|
|
482
|
+
], yt = Ht(""), Dt = Ht("");
|
|
483
|
+
function un() {
|
|
474
484
|
try {
|
|
475
|
-
const t = new AudioContext(), i = t.createOscillator(),
|
|
476
|
-
i.connect(
|
|
485
|
+
const t = new AudioContext(), i = t.createOscillator(), o = t.createGain();
|
|
486
|
+
i.connect(o), o.connect(t.destination), i.type = "sine", i.frequency.setValueAtTime(880, t.currentTime), i.frequency.exponentialRampToValueAtTime(660, t.currentTime + 0.12), o.gain.setValueAtTime(0.25, t.currentTime), o.gain.exponentialRampToValueAtTime(1e-3, t.currentTime + 0.35), i.start(t.currentTime), i.stop(t.currentTime + 0.35);
|
|
477
487
|
} catch {
|
|
478
488
|
}
|
|
479
489
|
}
|
|
480
|
-
function
|
|
490
|
+
function fn(t) {
|
|
481
491
|
if (!(t != null && t.metadata)) return;
|
|
482
|
-
const i = t.metadata,
|
|
483
|
-
return typeof
|
|
492
|
+
const i = t.metadata, o = i.pageName ?? i.displayName ?? i.username ?? i.name;
|
|
493
|
+
return typeof o == "string" && o ? o : void 0;
|
|
484
494
|
}
|
|
485
|
-
function
|
|
495
|
+
function Nt(t) {
|
|
486
496
|
return t === "facebook" ? "Facebook Messenger" : t === "instagram" ? "Instagram" : t === "telegram" ? "Telegram" : t === "zalo" ? "Zalo OA" : t === "livechat" ? "Live Chat" : "Channel";
|
|
487
497
|
}
|
|
488
|
-
function
|
|
498
|
+
function Rt(t) {
|
|
489
499
|
return t === "facebook" ? "Facebook" : t === "instagram" ? "Instagram" : t === "telegram" ? "Telegram" : t === "zalo" ? "Zalo" : t === "livechat" ? "Live Chat" : String(t ?? "");
|
|
490
500
|
}
|
|
491
|
-
const
|
|
492
|
-
var
|
|
501
|
+
const gn = (t) => {
|
|
502
|
+
var o;
|
|
493
503
|
const i = {
|
|
494
504
|
"application/pdf": "PDF",
|
|
495
505
|
"video/mp4": "Video MP4",
|
|
@@ -497,124 +507,138 @@ const tn = (t) => {
|
|
|
497
507
|
"audio/ogg": "Audio OGG",
|
|
498
508
|
"application/octet-stream": "Tệp đính kèm"
|
|
499
509
|
};
|
|
500
|
-
return t ? i[t] ?? ((
|
|
510
|
+
return t ? i[t] ?? ((o = t.split("/")[1]) == null ? void 0 : o.toUpperCase()) ?? "Tệp" : "Tệp đính kèm";
|
|
501
511
|
};
|
|
502
|
-
function
|
|
503
|
-
return t === "read" ? /* @__PURE__ */ e(
|
|
512
|
+
function Wt({ status: t }) {
|
|
513
|
+
return t === "read" ? /* @__PURE__ */ e(wt, { size: 11, strokeWidth: 2, style: { display: "inline", verticalAlign: "middle" } }) : t === "delivered" ? /* @__PURE__ */ e(wt, { size: 11, strokeWidth: 2, style: { display: "inline", verticalAlign: "middle", opacity: 0.5 } }) : t === "sent" ? /* @__PURE__ */ e(gt, { size: 11, strokeWidth: 2, style: { display: "inline", verticalAlign: "middle" } }) : null;
|
|
504
514
|
}
|
|
505
|
-
function
|
|
515
|
+
function pt(t) {
|
|
506
516
|
const i = t.trim().split(/\s+/).filter(Boolean);
|
|
507
517
|
return i.length <= 2 ? t.trim() : i.slice(-2).join(" ");
|
|
508
518
|
}
|
|
509
|
-
const
|
|
510
|
-
var
|
|
511
|
-
const
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
519
|
+
const Nn = Xe(function({ apiUrl: i, token: o, theme: r, height: c, defaultConversationId: C, disableAttachments: y, disableNotificationSound: L, hideKeyboardHint: w, locale: g = "vi", extensions: $, currentAgent: T, teamAgents: E, onNewMessage: M, onConversationSelect: I }, q) {
|
|
520
|
+
var ge, tt, xt, vt, kt;
|
|
521
|
+
const R = X(new ht(i, o)), [H, J] = u([]), [F, re] = u([]), [V, B] = u(), [b, S] = u(), D = X(void 0), [j, Z] = u(""), [pe, ve] = u("all"), [fe, se] = u(null), [G, k] = u({ provider: "all", unreadOnly: !1 }), [ie, h] = u(!1), A = X(null), U = X(null), [z, ce] = u(null), [de, Q] = u(!0), [he, Ye] = u(""), ke = X(null), [Ie, Ee] = u(() => typeof window < "u" ? window.innerWidth : 1200), ee = Ie < 640 ? "mobile" : Ie < 1024 ? "tablet" : "desktop", [Oe, $e] = u(() => C ? "chat" : "list"), [we, ue] = u(() => typeof window < "u" && window.innerWidth < 1024 ? !1 : !!($ != null && $.length)), Be = X(ee), [Ue, De] = u(280), [Ne, Je] = u(!1), [Pe, ze] = u(0), _ = (r == null ? void 0 : r.primaryColor) ?? "#2563eb", oe = We(() => new Map(F.map((d) => [d.id, d])), [F]), Le = X(null), [Ze, Me] = u(0);
|
|
522
|
+
K(() => {
|
|
523
|
+
const d = ke.current;
|
|
524
|
+
if (!d || typeof ResizeObserver > "u") return;
|
|
525
|
+
const p = new ResizeObserver((m) => {
|
|
526
|
+
for (const W of m) {
|
|
527
|
+
const le = W.contentRect.width;
|
|
528
|
+
le > 0 && Ee(le);
|
|
529
|
+
}
|
|
530
|
+
});
|
|
531
|
+
return p.observe(d), () => p.disconnect();
|
|
532
|
+
}, [de, he]), K(() => {
|
|
533
|
+
Be.current === "desktop" && ee !== "desktop" && ue(!1), Be.current = ee;
|
|
534
|
+
}, [ee]);
|
|
535
|
+
const ye = We(() => H.filter((d) => d.id !== (b == null ? void 0 : b.id) && (d.unreadCount ?? 0) > 0).length, [H, b == null ? void 0 : b.id]), te = T ?? fe ?? null;
|
|
536
|
+
K(() => {
|
|
537
|
+
R.current = new ht(i, o), T || R.current.getSessionMe().then((d) => {
|
|
538
|
+
d != null && d.agent && se(d.agent);
|
|
515
539
|
}).catch(() => {
|
|
516
540
|
});
|
|
517
|
-
}, [i,
|
|
518
|
-
const
|
|
541
|
+
}, [i, o, T]);
|
|
542
|
+
const _e = We(() => {
|
|
519
543
|
var p;
|
|
520
|
-
const
|
|
521
|
-
|
|
522
|
-
for (const
|
|
523
|
-
|
|
524
|
-
for (const
|
|
525
|
-
(p =
|
|
526
|
-
return [...
|
|
527
|
-
}, [
|
|
528
|
-
|
|
544
|
+
const d = /* @__PURE__ */ new Map();
|
|
545
|
+
te != null && te.id && d.set(te.id, te);
|
|
546
|
+
for (const m of E ?? [])
|
|
547
|
+
m != null && m.id && !d.has(m.id) && d.set(m.id, m);
|
|
548
|
+
for (const m of H)
|
|
549
|
+
(p = m.assignedAgent) != null && p.id && !d.has(m.assignedAgent.id) && d.set(m.assignedAgent.id, m.assignedAgent);
|
|
550
|
+
return [...d.values()];
|
|
551
|
+
}, [te, E, H]), rt = Te(async (d, p) => {
|
|
552
|
+
J((m) => m.map((W) => W.id === d.id ? { ...W, assignedAgent: p } : W)), S((m) => m && m.id === d.id ? { ...m, assignedAgent: p } : m), ze((m) => m + 1);
|
|
529
553
|
try {
|
|
530
|
-
const
|
|
531
|
-
|
|
554
|
+
const m = await R.current.assignConversation(d.id, p);
|
|
555
|
+
J((W) => W.map((le) => le.id === d.id ? { ...le, ...m, assignedAgent: m.assignedAgent ?? p } : le)), S((W) => W && W.id === d.id ? { ...W, ...m, assignedAgent: m.assignedAgent ?? p } : W), ze((W) => W + 1);
|
|
532
556
|
} catch {
|
|
533
557
|
}
|
|
534
|
-
}, []),
|
|
535
|
-
|
|
536
|
-
}, []),
|
|
537
|
-
|
|
538
|
-
}, []),
|
|
539
|
-
const
|
|
540
|
-
return ["facebook", "instagram", "telegram", "zalo", "livechat"].filter((p) =>
|
|
541
|
-
}, [
|
|
558
|
+
}, []), Fe = Te(async (d, p) => {
|
|
559
|
+
d.contactId && await R.current.patchContact(d.contactId, p), J((m) => m.map((W) => W.id === d.id ? { ...W, contactExternalId: p ?? void 0 } : W)), S((m) => m && m.id === d.id ? { ...m, contactExternalId: p ?? void 0 } : m), ze((m) => m + 1);
|
|
560
|
+
}, []), me = Te(() => {
|
|
561
|
+
ze((d) => d + 1);
|
|
562
|
+
}, []), xe = We(() => {
|
|
563
|
+
const d = new Set(F.map((p) => p.provider));
|
|
564
|
+
return ["facebook", "instagram", "telegram", "zalo", "livechat"].filter((p) => d.has(p));
|
|
565
|
+
}, [F]), Qe = We(() => {
|
|
542
566
|
var p;
|
|
543
|
-
const
|
|
544
|
-
for (const
|
|
545
|
-
const
|
|
546
|
-
|
|
567
|
+
const d = {};
|
|
568
|
+
for (const m of H) {
|
|
569
|
+
const W = ((p = oe.get(m.connectionId)) == null ? void 0 : p.provider) ?? "unknown";
|
|
570
|
+
d[W] = (d[W] ?? 0) + 1;
|
|
547
571
|
}
|
|
548
|
-
return
|
|
549
|
-
}, [
|
|
550
|
-
function
|
|
551
|
-
const p =
|
|
552
|
-
|
|
553
|
-
function
|
|
554
|
-
const
|
|
555
|
-
|
|
572
|
+
return d;
|
|
573
|
+
}, [H, oe]);
|
|
574
|
+
function et(d) {
|
|
575
|
+
const p = d.clientX, m = Ue;
|
|
576
|
+
Je(!0), document.body.style.cursor = "col-resize", document.body.style.userSelect = "none";
|
|
577
|
+
function W(He) {
|
|
578
|
+
const Ke = Math.max(200, Math.min(480, m + (p - He.clientX)));
|
|
579
|
+
De(Ke);
|
|
556
580
|
}
|
|
557
581
|
function le() {
|
|
558
|
-
|
|
582
|
+
Je(!1), document.body.style.cursor = "", document.body.style.userSelect = "", document.removeEventListener("mousemove", W), document.removeEventListener("mouseup", le);
|
|
559
583
|
}
|
|
560
|
-
document.addEventListener("mousemove",
|
|
584
|
+
document.addEventListener("mousemove", W), document.addEventListener("mouseup", le);
|
|
561
585
|
}
|
|
562
|
-
const
|
|
586
|
+
const l = Te(async (d) => {
|
|
563
587
|
try {
|
|
564
|
-
const p = await
|
|
565
|
-
|
|
588
|
+
const p = await R.current.listConversations(d);
|
|
589
|
+
J((m) => d ? [...m, ...p.items] : p.items), B(p.nextCursor), !d && p.items.length && S((m) => m ?? (C ? p.items.find((W) => W.id === C) ?? p.items[0] : p.items[0])), Ye("");
|
|
566
590
|
} catch (p) {
|
|
567
|
-
|
|
591
|
+
Ye(p instanceof Error ? p.message : "Không tải được hội thoại");
|
|
568
592
|
} finally {
|
|
569
|
-
|
|
593
|
+
Q(!1);
|
|
570
594
|
}
|
|
571
|
-
}, [
|
|
572
|
-
|
|
573
|
-
}),
|
|
595
|
+
}, [C]);
|
|
596
|
+
K(() => (R.current.listConnections().then(re).catch(() => {
|
|
597
|
+
}), l(), R.current.connectSSE((p, m) => {
|
|
574
598
|
if (p === "message.new" || p === "conversation.updated") {
|
|
575
|
-
if (
|
|
576
|
-
const
|
|
577
|
-
if ((
|
|
578
|
-
const
|
|
579
|
-
|
|
580
|
-
|
|
599
|
+
if (l(), p === "message.new") {
|
|
600
|
+
const W = typeof m == "object" && m ? m : {}, le = W.conversationId ? String(W.conversationId) : "", He = W.messageId ? String(W.messageId) : "";
|
|
601
|
+
if ((W.direction ? String(W.direction) : "") === "inbound" && !L && un(), le && le === D.current && He && Le.current) {
|
|
602
|
+
const nt = Le.current;
|
|
603
|
+
R.current.getMessage(He).then((it) => {
|
|
604
|
+
nt(it);
|
|
581
605
|
}).catch(() => {
|
|
582
606
|
});
|
|
583
607
|
}
|
|
584
|
-
|
|
608
|
+
M == null || M(le || D.current || "");
|
|
585
609
|
}
|
|
586
|
-
} else p === "message.status_updated" &&
|
|
587
|
-
})), [
|
|
588
|
-
|
|
589
|
-
}, [
|
|
590
|
-
|
|
610
|
+
} else p === "message.status_updated" && Me((W) => W + 1);
|
|
611
|
+
})), [l, M]), K(() => {
|
|
612
|
+
D.current = b == null ? void 0 : b.id;
|
|
613
|
+
}, [b]), K(() => {
|
|
614
|
+
b != null && b.unreadCount && R.current.markRead(b.id).then(() => l()).catch(() => {
|
|
591
615
|
});
|
|
592
|
-
}, [
|
|
593
|
-
if (!
|
|
594
|
-
function
|
|
595
|
-
var
|
|
596
|
-
(
|
|
616
|
+
}, [b == null ? void 0 : b.id]), K(() => {
|
|
617
|
+
if (!ie) return;
|
|
618
|
+
function d(p) {
|
|
619
|
+
var m, W;
|
|
620
|
+
(m = A.current) != null && m.contains(p.target) || (W = U.current) != null && W.contains(p.target) || h(!1);
|
|
597
621
|
}
|
|
598
|
-
return document.addEventListener("mousedown",
|
|
599
|
-
}, [
|
|
600
|
-
const
|
|
601
|
-
const
|
|
602
|
-
var
|
|
603
|
-
return ((
|
|
604
|
-
}).length : 0, p =
|
|
605
|
-
return { all:
|
|
606
|
-
}, [
|
|
607
|
-
const
|
|
608
|
-
return
|
|
609
|
-
var
|
|
610
|
-
if (
|
|
611
|
-
if (!
|
|
612
|
-
} else if (
|
|
622
|
+
return document.addEventListener("mousedown", d), () => document.removeEventListener("mousedown", d);
|
|
623
|
+
}, [ie]);
|
|
624
|
+
const f = We(() => {
|
|
625
|
+
const d = te ? H.filter((m) => {
|
|
626
|
+
var W;
|
|
627
|
+
return ((W = m.assignedAgent) == null ? void 0 : W.id) === te.id;
|
|
628
|
+
}).length : 0, p = H.filter((m) => !m.assignedAgent).length;
|
|
629
|
+
return { all: H.length, mine: d, unassigned: p };
|
|
630
|
+
}, [H, te]), v = We(() => {
|
|
631
|
+
const d = j.toLowerCase().trim();
|
|
632
|
+
return H.filter((p) => {
|
|
633
|
+
var Ke, nt, it;
|
|
634
|
+
if (pe === "mine") {
|
|
635
|
+
if (!te || ((Ke = p.assignedAgent) == null ? void 0 : Ke.id) !== te.id) return !1;
|
|
636
|
+
} else if (pe === "unassigned" && p.assignedAgent)
|
|
613
637
|
return !1;
|
|
614
|
-
const
|
|
615
|
-
return le &&
|
|
638
|
+
const m = `${p.contactName ?? ""} ${p.subject ?? ""} ${p.providerConversationKey} ${((nt = p.assignedAgent) == null ? void 0 : nt.name) ?? ""}`.toLowerCase(), W = ((it = oe.get(p.connectionId)) == null ? void 0 : it.provider) ?? "unknown", le = G.provider === "all" || W === G.provider, He = !G.unreadOnly || (p.unreadCount ?? 0) > 0;
|
|
639
|
+
return le && He && (!d || m.includes(d));
|
|
616
640
|
});
|
|
617
|
-
}, [
|
|
641
|
+
}, [H, oe, G, j, pe, te]), O = G.provider !== "all" || G.unreadOnly, N = g === "en" ? {
|
|
618
642
|
today: "TODAY",
|
|
619
643
|
loadOlder: "↑ Load older messages",
|
|
620
644
|
loading: "Loading messages…",
|
|
@@ -635,51 +659,55 @@ const Wn = Pe(function({ apiUrl: i, token: r, theme: o, height: h, defaultConver
|
|
|
635
659
|
send: "Gửi",
|
|
636
660
|
all: "Tất cả"
|
|
637
661
|
};
|
|
638
|
-
|
|
639
|
-
openConversation: (
|
|
640
|
-
const p =
|
|
641
|
-
p &&
|
|
662
|
+
Ft(q, () => ({
|
|
663
|
+
openConversation: (d) => {
|
|
664
|
+
const p = H.find((m) => m.id === d);
|
|
665
|
+
p && (S(p), $e("chat"));
|
|
642
666
|
},
|
|
643
|
-
refresh: () => void
|
|
644
|
-
}), [
|
|
645
|
-
const
|
|
646
|
-
...
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
667
|
+
refresh: () => void l()
|
|
668
|
+
}), [H, l]);
|
|
669
|
+
const P = ee === "mobile" ? "minmax(0, 1fr)" : ee === "tablet" ? "minmax(240px, 270px) minmax(0, 1fr)" : we ? `minmax(260px, 300px) minmax(0, 1fr) ${Ue}px` : "minmax(260px, 300px) minmax(0, 1fr)", ae = {
|
|
670
|
+
...x.frame,
|
|
671
|
+
position: "relative",
|
|
672
|
+
height: c ?? 620,
|
|
673
|
+
...c ? { maxHeight: "none" } : {},
|
|
674
|
+
fontFamily: (r == null ? void 0 : r.fontFamily) ?? "Inter, ui-sans-serif, system-ui, sans-serif",
|
|
675
|
+
borderRadius: (r == null ? void 0 : r.borderRadius) ?? "16px",
|
|
676
|
+
gridTemplateColumns: P,
|
|
677
|
+
transition: Ne ? "none" : "grid-template-columns 220ms ease"
|
|
653
678
|
};
|
|
654
|
-
|
|
655
|
-
/* @__PURE__ */ e(
|
|
679
|
+
if (de) return /* @__PURE__ */ n("div", { style: { ...x.state, borderRadius: (r == null ? void 0 : r.borderRadius) ?? "16px" }, children: [
|
|
680
|
+
/* @__PURE__ */ e(ut, {}),
|
|
656
681
|
" Đang tải hộp thư…"
|
|
657
|
-
] })
|
|
658
|
-
|
|
682
|
+
] });
|
|
683
|
+
if (he && !H.length) return /* @__PURE__ */ n("div", { style: { ...x.state, color: "#b42318", borderRadius: (r == null ? void 0 : r.borderRadius) ?? "16px" }, children: [
|
|
684
|
+
/* @__PURE__ */ e(Jt, { size: 16, strokeWidth: 2 }),
|
|
659
685
|
" ",
|
|
660
686
|
he,
|
|
661
|
-
/* @__PURE__ */ e("button", { style:
|
|
662
|
-
|
|
687
|
+
/* @__PURE__ */ e("button", { style: x.retry, onClick: () => {
|
|
688
|
+
Q(!0), l();
|
|
663
689
|
}, children: "Thử lại" })
|
|
664
|
-
] })
|
|
665
|
-
|
|
690
|
+
] });
|
|
691
|
+
const Se = ee !== "mobile" || Oe === "list" || !b, Re = ee !== "mobile" || Oe === "chat" && !!b;
|
|
692
|
+
return /* @__PURE__ */ e(yt.Provider, { value: i, children: /* @__PURE__ */ e(Dt.Provider, { value: o, children: /* @__PURE__ */ n("div", { ref: ke, style: ae, onFocusCapture: () => {
|
|
693
|
+
const d = window.scrollY;
|
|
666
694
|
requestAnimationFrame(() => {
|
|
667
|
-
window.scrollY !==
|
|
695
|
+
window.scrollY !== d && window.scrollTo({ top: d, behavior: "instant" });
|
|
668
696
|
});
|
|
669
697
|
}, children: [
|
|
670
|
-
/* @__PURE__ */ n("aside", { style:
|
|
671
|
-
/* @__PURE__ */ n("div", { style:
|
|
672
|
-
/* @__PURE__ */ e("div", { style: { ...
|
|
698
|
+
Se && /* @__PURE__ */ n("aside", { style: { ...x.sidebar, ...ee === "mobile" ? { borderRight: 0 } : {} }, children: [
|
|
699
|
+
/* @__PURE__ */ n("div", { style: x.brand, children: [
|
|
700
|
+
/* @__PURE__ */ e("div", { style: { ...x.brandMark, background: _, overflow: "hidden", padding: 0 }, children: (ge = r == null ? void 0 : r.branding) != null && ge.logoUrl ? /* @__PURE__ */ e("img", { src: r.branding.logoUrl, alt: "", style: { width: "100%", height: "100%", objectFit: "cover" } }) : ((tt = r == null ? void 0 : r.branding) == null ? void 0 : tt.mark) ?? "C" }),
|
|
673
701
|
/* @__PURE__ */ n("div", { children: [
|
|
674
|
-
/* @__PURE__ */ e("strong", { children: ((
|
|
675
|
-
!((
|
|
702
|
+
/* @__PURE__ */ e("strong", { children: ((xt = r == null ? void 0 : r.branding) == null ? void 0 : xt.name) ?? "Hộp thư" }),
|
|
703
|
+
!((vt = r == null ? void 0 : r.branding) != null && vt.name) && /* @__PURE__ */ e("span", { style: x.eyebrow, children: "CHANNELHUB" })
|
|
676
704
|
] }),
|
|
677
|
-
/* @__PURE__ */ e(
|
|
705
|
+
/* @__PURE__ */ e(dn, { "aria-label": "Tùy chọn", style: x.iconButton, children: /* @__PURE__ */ e(Et, { size: 16, strokeWidth: 2 }) })
|
|
678
706
|
] }),
|
|
679
|
-
/* @__PURE__ */ n("div", { style:
|
|
680
|
-
/* @__PURE__ */ e(
|
|
681
|
-
/* @__PURE__ */ e(
|
|
682
|
-
|
|
707
|
+
/* @__PURE__ */ n("div", { style: x.search, children: [
|
|
708
|
+
/* @__PURE__ */ e(Ct, { size: 16, strokeWidth: 2 }),
|
|
709
|
+
/* @__PURE__ */ e(sn, { "aria-label": N.searchPlaceholder, value: j, onChange: (d) => Z(d.target.value), placeholder: N.searchPlaceholder, style: { fontSize: ee === "mobile" ? 16 : 12 } }),
|
|
710
|
+
j && /* @__PURE__ */ e("button", { style: x.clear, onClick: () => Z(""), "aria-label": "Xóa tìm kiếm", children: "×" })
|
|
683
711
|
] }),
|
|
684
712
|
/* @__PURE__ */ e(
|
|
685
713
|
"div",
|
|
@@ -693,30 +721,30 @@ const Wn = Pe(function({ apiUrl: i, token: r, theme: o, height: h, defaultConver
|
|
|
693
721
|
margin: "0 14px 10px",
|
|
694
722
|
padding: 3,
|
|
695
723
|
borderRadius: 9,
|
|
696
|
-
border: `1px solid ${
|
|
697
|
-
background:
|
|
724
|
+
border: `1px solid ${a.line}`,
|
|
725
|
+
background: a.surface
|
|
698
726
|
},
|
|
699
727
|
children: [
|
|
700
|
-
{ key: "all", label:
|
|
701
|
-
{ key: "mine", label:
|
|
702
|
-
{ key: "unassigned", label:
|
|
703
|
-
].map((
|
|
704
|
-
const p =
|
|
728
|
+
{ key: "all", label: g === "en" ? "All" : "Tất cả", count: f.all },
|
|
729
|
+
{ key: "mine", label: g === "en" ? "Mine" : "Của tôi", count: f.mine },
|
|
730
|
+
{ key: "unassigned", label: g === "en" ? "Unassigned" : "Chưa nhận", count: f.unassigned }
|
|
731
|
+
].map((d) => {
|
|
732
|
+
const p = pe === d.key;
|
|
705
733
|
return /* @__PURE__ */ n(
|
|
706
734
|
"button",
|
|
707
735
|
{
|
|
708
736
|
type: "button",
|
|
709
737
|
role: "tab",
|
|
710
738
|
"aria-selected": p,
|
|
711
|
-
onClick: () =>
|
|
739
|
+
onClick: () => ve(d.key),
|
|
712
740
|
style: {
|
|
713
741
|
border: 0,
|
|
714
742
|
borderRadius: 6,
|
|
715
743
|
padding: "5px 4px",
|
|
716
744
|
fontSize: 11,
|
|
717
745
|
fontWeight: p ? 700 : 500,
|
|
718
|
-
background: p ?
|
|
719
|
-
color: p ? _ :
|
|
746
|
+
background: p ? a.white : "transparent",
|
|
747
|
+
color: p ? _ : a.muted,
|
|
720
748
|
boxShadow: p ? "0 1px 3px rgba(23,32,51,.08)" : "none",
|
|
721
749
|
cursor: "pointer",
|
|
722
750
|
whiteSpace: "nowrap",
|
|
@@ -725,183 +753,230 @@ const Wn = Pe(function({ apiUrl: i, token: r, theme: o, height: h, defaultConver
|
|
|
725
753
|
transition: "all 120ms ease"
|
|
726
754
|
},
|
|
727
755
|
children: [
|
|
728
|
-
|
|
756
|
+
d.label,
|
|
729
757
|
" ",
|
|
730
758
|
/* @__PURE__ */ n("span", { style: { opacity: 0.75 }, children: [
|
|
731
759
|
"(",
|
|
732
|
-
|
|
760
|
+
d.count,
|
|
733
761
|
")"
|
|
734
762
|
] })
|
|
735
763
|
]
|
|
736
764
|
},
|
|
737
|
-
|
|
765
|
+
d.key
|
|
738
766
|
);
|
|
739
767
|
})
|
|
740
768
|
}
|
|
741
769
|
),
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
/* @__PURE__ */ e(
|
|
745
|
-
|
|
746
|
-
/* @__PURE__ */ e("button", { style: { border: 0, background: "none", cursor: "pointer", color: _, padding: 0, lineHeight: 1, display: "flex" }, onClick: () =>
|
|
770
|
+
O && /* @__PURE__ */ n("div", { style: { display: "flex", gap: 4, flexWrap: "wrap", padding: "0 14px 8px" }, children: [
|
|
771
|
+
G.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: [
|
|
772
|
+
/* @__PURE__ */ e(Ge, { provider: G.provider }),
|
|
773
|
+
Rt(G.provider),
|
|
774
|
+
/* @__PURE__ */ e("button", { style: { border: 0, background: "none", cursor: "pointer", color: _, padding: 0, lineHeight: 1, display: "flex" }, onClick: () => k((d) => ({ ...d, provider: "all" })), "aria-label": "Xóa filter kênh", children: /* @__PURE__ */ e(Ve, { size: 10 }) })
|
|
747
775
|
] }),
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
/* @__PURE__ */ e("button", { style: { border: 0, background: "none", cursor: "pointer", color: _, padding: 0, lineHeight: 1, display: "flex" }, onClick: () =>
|
|
776
|
+
G.unreadOnly && /* @__PURE__ */ n("span", { style: { display: "inline-flex", alignItems: "center", gap: 4, background: "#eef2ff", color: _, borderRadius: 6, fontSize: 11, padding: "2px 8px", fontWeight: 500 }, children: [
|
|
777
|
+
N.unreadOnly,
|
|
778
|
+
/* @__PURE__ */ e("button", { style: { border: 0, background: "none", cursor: "pointer", color: _, padding: 0, lineHeight: 1, display: "flex" }, onClick: () => k((d) => ({ ...d, unreadOnly: !1 })), "aria-label": "Xóa filter chưa đọc", children: /* @__PURE__ */ e(Ve, { size: 10 }) })
|
|
751
779
|
] }),
|
|
752
|
-
/* @__PURE__ */ e("button", { style: { border: 0, background: "none", cursor: "pointer", color:
|
|
780
|
+
/* @__PURE__ */ e("button", { style: { border: 0, background: "none", cursor: "pointer", color: a.muted, fontSize: 11, padding: "2px 4px" }, onClick: () => k({ provider: "all", unreadOnly: !1 }), children: "Xóa tất cả" })
|
|
753
781
|
] }),
|
|
754
|
-
/* @__PURE__ */ n("div", { style:
|
|
782
|
+
/* @__PURE__ */ n("div", { style: x.listHeader, children: [
|
|
755
783
|
/* @__PURE__ */ n("span", { children: [
|
|
756
|
-
|
|
784
|
+
v.length,
|
|
757
785
|
" hội thoại"
|
|
758
786
|
] }),
|
|
759
787
|
/* @__PURE__ */ e(
|
|
760
788
|
"button",
|
|
761
789
|
{
|
|
762
|
-
ref:
|
|
763
|
-
style: { ...
|
|
790
|
+
ref: A,
|
|
791
|
+
style: { ...x.iconButton, background: O ? `${_}14` : "transparent", color: O ? _ : a.muted },
|
|
764
792
|
"aria-label": "Bộ lọc",
|
|
765
793
|
onClick: () => {
|
|
766
|
-
var
|
|
767
|
-
if (!
|
|
768
|
-
const p = (
|
|
794
|
+
var d;
|
|
795
|
+
if (!ie) {
|
|
796
|
+
const p = (d = A.current) == null ? void 0 : d.getBoundingClientRect();
|
|
769
797
|
p && ce({ top: p.bottom + 6, left: p.left });
|
|
770
798
|
}
|
|
771
|
-
|
|
799
|
+
h((p) => !p);
|
|
772
800
|
},
|
|
773
|
-
children: /* @__PURE__ */ e(
|
|
801
|
+
children: /* @__PURE__ */ e(on, { size: 15, strokeWidth: 2 })
|
|
774
802
|
}
|
|
775
803
|
)
|
|
776
804
|
] }),
|
|
777
|
-
|
|
805
|
+
ie && z && At(
|
|
778
806
|
/* @__PURE__ */ n(
|
|
779
807
|
"div",
|
|
780
808
|
{
|
|
781
|
-
ref:
|
|
782
|
-
style: { position: "fixed", top:
|
|
809
|
+
ref: U,
|
|
810
|
+
style: { position: "fixed", top: z.top, left: Math.min(z.left, (typeof window < "u" ? window.innerWidth : 1200) - 230), zIndex: 9999, background: a.white, border: `1px solid ${a.line}`, borderRadius: 10, padding: "12px 14px", boxShadow: "0 8px 24px rgba(23,32,51,.14)", minWidth: 210, fontFamily: (r == null ? void 0 : r.fontFamily) ?? "Inter, ui-sans-serif, system-ui, sans-serif", fontSize: 13 },
|
|
783
811
|
children: [
|
|
784
|
-
/* @__PURE__ */ e("div", { style: { fontSize: 10, fontWeight: 700, color:
|
|
785
|
-
["all", ...
|
|
786
|
-
/* @__PURE__ */ e("input", { type: "radio", name: "provider-filter", checked:
|
|
787
|
-
|
|
788
|
-
|
|
812
|
+
/* @__PURE__ */ e("div", { style: { fontSize: 10, fontWeight: 700, color: a.muted, letterSpacing: 1, textTransform: "uppercase", marginBottom: 8 }, children: "Kênh" }),
|
|
813
|
+
["all", ...xe].map((d) => /* @__PURE__ */ n("label", { style: { display: "flex", alignItems: "center", gap: 8, padding: "5px 6px", cursor: "pointer", borderRadius: 6, background: G.provider === d ? `${_}0f` : "transparent" }, children: [
|
|
814
|
+
/* @__PURE__ */ e("input", { type: "radio", name: "provider-filter", checked: G.provider === d, onChange: () => k((p) => ({ ...p, provider: d })), style: { accentColor: _ } }),
|
|
815
|
+
d === "all" ? /* @__PURE__ */ n("span", { style: { color: a.ink }, children: [
|
|
816
|
+
N.all,
|
|
789
817
|
" (",
|
|
790
|
-
|
|
818
|
+
H.length,
|
|
791
819
|
")"
|
|
792
|
-
] }) : /* @__PURE__ */ n("span", { style: { display: "flex", alignItems: "center", gap: 5, color:
|
|
793
|
-
/* @__PURE__ */ e(
|
|
794
|
-
|
|
820
|
+
] }) : /* @__PURE__ */ n("span", { style: { display: "flex", alignItems: "center", gap: 5, color: a.ink }, children: [
|
|
821
|
+
/* @__PURE__ */ e(Ge, { provider: d }),
|
|
822
|
+
Rt(d),
|
|
795
823
|
" ",
|
|
796
|
-
/* @__PURE__ */ n("span", { style: { color:
|
|
824
|
+
/* @__PURE__ */ n("span", { style: { color: a.muted }, children: [
|
|
797
825
|
"(",
|
|
798
|
-
|
|
826
|
+
Qe[d] ?? 0,
|
|
799
827
|
")"
|
|
800
828
|
] })
|
|
801
829
|
] })
|
|
802
|
-
] },
|
|
803
|
-
/* @__PURE__ */ e("div", { style: { borderTop: `1px solid ${
|
|
804
|
-
/* @__PURE__ */ n("label", { style: { display: "flex", alignItems: "center", gap: 8, padding: "5px 6px", cursor: "pointer", borderRadius: 6, background:
|
|
805
|
-
/* @__PURE__ */ e("input", { type: "checkbox", checked:
|
|
806
|
-
/* @__PURE__ */ e("span", { style: { color:
|
|
830
|
+
] }, d)),
|
|
831
|
+
/* @__PURE__ */ e("div", { style: { borderTop: `1px solid ${a.line}`, margin: "8px 0 6px" } }),
|
|
832
|
+
/* @__PURE__ */ n("label", { style: { display: "flex", alignItems: "center", gap: 8, padding: "5px 6px", cursor: "pointer", borderRadius: 6, background: G.unreadOnly ? `${_}0f` : "transparent" }, children: [
|
|
833
|
+
/* @__PURE__ */ e("input", { type: "checkbox", checked: G.unreadOnly, onChange: (d) => k((p) => ({ ...p, unreadOnly: d.target.checked })), style: { accentColor: _ } }),
|
|
834
|
+
/* @__PURE__ */ e("span", { style: { color: a.ink }, children: N.unreadOnly })
|
|
807
835
|
] })
|
|
808
836
|
]
|
|
809
837
|
}
|
|
810
838
|
),
|
|
811
839
|
document.body
|
|
812
840
|
),
|
|
813
|
-
/* @__PURE__ */ n(
|
|
814
|
-
|
|
841
|
+
/* @__PURE__ */ n(Ut, { style: x.conversationList, children: [
|
|
842
|
+
v.map((d) => {
|
|
815
843
|
var p;
|
|
816
|
-
return /* @__PURE__ */ e(
|
|
817
|
-
|
|
844
|
+
return /* @__PURE__ */ e(bn, { conversation: d, provider: (p = oe.get(d.connectionId)) == null ? void 0 : p.provider, selected: (b == null ? void 0 : b.id) === d.id, primary: _, currentAgent: te, onSelect: () => {
|
|
845
|
+
S(d), $e("chat"), I == null || I(d.id), R.current.markRead(d.id).then(() => l()).catch(() => {
|
|
818
846
|
});
|
|
819
|
-
} },
|
|
847
|
+
} }, d.id);
|
|
820
848
|
}),
|
|
821
|
-
!
|
|
822
|
-
/* @__PURE__ */ e("div", { style:
|
|
849
|
+
!v.length && /* @__PURE__ */ n("div", { style: x.emptySmall, children: [
|
|
850
|
+
/* @__PURE__ */ e("div", { style: x.emptyIcon, children: /* @__PURE__ */ e(Ct, { size: 16, strokeWidth: 2 }) }),
|
|
823
851
|
/* @__PURE__ */ e("strong", { children: "Không tìm thấy" }),
|
|
824
852
|
/* @__PURE__ */ e("span", { children: "Thử từ khóa hoặc bộ lọc khác." })
|
|
825
853
|
] }),
|
|
826
|
-
|
|
854
|
+
V && /* @__PURE__ */ e("button", { style: x.loadMore, onClick: () => void l(V), children: "Xem thêm hội thoại" })
|
|
827
855
|
] })
|
|
828
856
|
] }),
|
|
829
|
-
/* @__PURE__ */ e("main", { style:
|
|
830
|
-
|
|
857
|
+
Re && /* @__PURE__ */ e("main", { style: x.main, children: b ? /* @__PURE__ */ e(
|
|
858
|
+
yn,
|
|
831
859
|
{
|
|
832
|
-
conversation:
|
|
833
|
-
provider: (
|
|
834
|
-
connection:
|
|
835
|
-
client:
|
|
860
|
+
conversation: b,
|
|
861
|
+
provider: (kt = oe.get(b.connectionId)) == null ? void 0 : kt.provider,
|
|
862
|
+
connection: oe.get(b.connectionId),
|
|
863
|
+
client: R.current,
|
|
836
864
|
primary: _,
|
|
837
865
|
error: he,
|
|
838
|
-
onRegisterAppend: (
|
|
839
|
-
|
|
866
|
+
onRegisterAppend: (d) => {
|
|
867
|
+
Le.current = d;
|
|
840
868
|
},
|
|
841
|
-
refreshKey:
|
|
842
|
-
infoOpen:
|
|
843
|
-
onToggleInfo: () =>
|
|
844
|
-
t:
|
|
845
|
-
disableAttachments:
|
|
869
|
+
refreshKey: Ze,
|
|
870
|
+
infoOpen: we,
|
|
871
|
+
onToggleInfo: () => ue((d) => !d),
|
|
872
|
+
t: N,
|
|
873
|
+
disableAttachments: y,
|
|
846
874
|
hideKeyboardHint: w,
|
|
847
|
-
extensions:
|
|
848
|
-
currentAgent:
|
|
849
|
-
teamAgents:
|
|
850
|
-
onAssignAgent: (
|
|
851
|
-
onLinkContact: (
|
|
852
|
-
onRefreshContactInfo:
|
|
875
|
+
extensions: $,
|
|
876
|
+
currentAgent: te,
|
|
877
|
+
teamAgents: _e,
|
|
878
|
+
onAssignAgent: (d) => rt(b, d),
|
|
879
|
+
onLinkContact: (d) => Fe(b, d),
|
|
880
|
+
onRefreshContactInfo: me,
|
|
881
|
+
layoutMode: ee,
|
|
882
|
+
onBackToList: () => $e("list"),
|
|
883
|
+
totalUnreadCount: ye
|
|
853
884
|
},
|
|
854
|
-
|
|
855
|
-
) : /* @__PURE__ */ e(
|
|
856
|
-
|
|
857
|
-
|
|
885
|
+
b.id
|
|
886
|
+
) : /* @__PURE__ */ e(vn, {}) }),
|
|
887
|
+
we && b && (ee === "desktop" ? /* @__PURE__ */ e(
|
|
888
|
+
Tt,
|
|
858
889
|
{
|
|
859
|
-
conversation:
|
|
860
|
-
connection:
|
|
890
|
+
conversation: b,
|
|
891
|
+
connection: oe.get(b.connectionId),
|
|
861
892
|
primary: _,
|
|
862
|
-
onClose: () =>
|
|
863
|
-
client:
|
|
864
|
-
onStartResize:
|
|
865
|
-
extensions:
|
|
866
|
-
extRefreshKey:
|
|
867
|
-
onLinkContact: (
|
|
868
|
-
onRefreshContactInfo:
|
|
893
|
+
onClose: () => ue(!1),
|
|
894
|
+
client: R.current,
|
|
895
|
+
onStartResize: et,
|
|
896
|
+
extensions: $,
|
|
897
|
+
extRefreshKey: Pe,
|
|
898
|
+
onLinkContact: (d) => Fe(b, d),
|
|
899
|
+
onRefreshContactInfo: me,
|
|
900
|
+
layoutMode: ee
|
|
869
901
|
}
|
|
870
|
-
)
|
|
902
|
+
) : /* @__PURE__ */ e(
|
|
903
|
+
"div",
|
|
904
|
+
{
|
|
905
|
+
onClick: () => ue(!1),
|
|
906
|
+
style: {
|
|
907
|
+
position: "absolute",
|
|
908
|
+
inset: 0,
|
|
909
|
+
zIndex: 50,
|
|
910
|
+
background: "rgba(15, 23, 42, 0.32)",
|
|
911
|
+
display: "flex",
|
|
912
|
+
justifyContent: "flex-end"
|
|
913
|
+
},
|
|
914
|
+
children: /* @__PURE__ */ e(
|
|
915
|
+
"div",
|
|
916
|
+
{
|
|
917
|
+
onClick: (d) => d.stopPropagation(),
|
|
918
|
+
style: {
|
|
919
|
+
width: ee === "mobile" ? "100%" : "min(320px, 85%)",
|
|
920
|
+
height: "100%",
|
|
921
|
+
background: a.white,
|
|
922
|
+
boxShadow: "-8px 0 24px rgba(15, 23, 42, 0.14)",
|
|
923
|
+
display: "flex",
|
|
924
|
+
flexDirection: "column"
|
|
925
|
+
},
|
|
926
|
+
children: /* @__PURE__ */ e(
|
|
927
|
+
Tt,
|
|
928
|
+
{
|
|
929
|
+
conversation: b,
|
|
930
|
+
connection: oe.get(b.connectionId),
|
|
931
|
+
primary: _,
|
|
932
|
+
onClose: () => ue(!1),
|
|
933
|
+
client: R.current,
|
|
934
|
+
onStartResize: void 0,
|
|
935
|
+
extensions: $,
|
|
936
|
+
extRefreshKey: Pe,
|
|
937
|
+
onLinkContact: (d) => Fe(b, d),
|
|
938
|
+
onRefreshContactInfo: me,
|
|
939
|
+
layoutMode: ee
|
|
940
|
+
}
|
|
941
|
+
)
|
|
942
|
+
}
|
|
943
|
+
)
|
|
944
|
+
}
|
|
945
|
+
))
|
|
871
946
|
] }) }) });
|
|
872
947
|
});
|
|
873
|
-
function
|
|
874
|
-
const [
|
|
875
|
-
let
|
|
876
|
-
|
|
877
|
-
const
|
|
878
|
-
...
|
|
879
|
-
background:
|
|
880
|
-
...
|
|
948
|
+
function bn({ conversation: t, provider: i, selected: o, primary: r, currentAgent: c, onSelect: C }) {
|
|
949
|
+
const [y, L] = u(!1), w = t.contactName ?? t.subject ?? t.providerConversationKey, g = t.unreadCount ?? 0, $ = t.lastMessageText ?? "", T = t.lastMessageDirection === "outbound" ? "Bạn: " : "", E = $.length > 60 ? $.slice(0, 60) + "…" : $, M = $ ? T + E : "", I = t.assignedAgent ?? null, q = !!(I && c && I.id === c.id);
|
|
950
|
+
let R = "transparent";
|
|
951
|
+
o ? R = "#eef2ff" : y ? R = "#f7f9fc" : g > 0 && (R = "#f0f4ff");
|
|
952
|
+
const H = {
|
|
953
|
+
...x.row,
|
|
954
|
+
background: R,
|
|
955
|
+
...o ? { boxShadow: `inset 3px 0 0 ${r}` } : g > 0 && !y ? { boxShadow: `inset 3px 0 0 ${r}` } : {}
|
|
881
956
|
};
|
|
882
957
|
return /* @__PURE__ */ n(
|
|
883
958
|
"button",
|
|
884
959
|
{
|
|
885
|
-
onClick:
|
|
886
|
-
style:
|
|
887
|
-
onMouseEnter: () =>
|
|
888
|
-
onMouseLeave: () =>
|
|
960
|
+
onClick: C,
|
|
961
|
+
style: H,
|
|
962
|
+
onMouseEnter: () => L(!0),
|
|
963
|
+
onMouseLeave: () => L(!1),
|
|
889
964
|
children: [
|
|
890
|
-
/* @__PURE__ */ e(
|
|
891
|
-
/* @__PURE__ */ n("span", { style:
|
|
892
|
-
/* @__PURE__ */ n("span", { style:
|
|
893
|
-
/* @__PURE__ */ e("strong", { style: { minWidth: 0, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap", fontWeight:
|
|
965
|
+
/* @__PURE__ */ e(Pt, { name: w, color: r, image: t.contactPictureUrl, provider: i }),
|
|
966
|
+
/* @__PURE__ */ n("span", { style: x.rowBody, children: [
|
|
967
|
+
/* @__PURE__ */ n("span", { style: x.rowTop, children: [
|
|
968
|
+
/* @__PURE__ */ e("strong", { style: { minWidth: 0, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap", fontWeight: g > 0 ? 700 : 500 }, children: w }),
|
|
894
969
|
/* @__PURE__ */ n("span", { style: { display: "flex", alignItems: "center", gap: 4, flexShrink: 0 }, children: [
|
|
895
|
-
/* @__PURE__ */ e("time", { style: { color:
|
|
896
|
-
|
|
970
|
+
/* @__PURE__ */ e("time", { style: { color: a.muted, fontSize: 11, whiteSpace: "nowrap" }, children: ft(t.lastMessageAt) }),
|
|
971
|
+
g > 0 && /* @__PURE__ */ e("span", { "aria-label": `${g} tin nhắn chưa đọc`, style: x.unreadBadge, children: g > 99 ? "99+" : g })
|
|
897
972
|
] })
|
|
898
973
|
] }),
|
|
899
|
-
/* @__PURE__ */ n("span", { style: { ...
|
|
900
|
-
/* @__PURE__ */ e("span", { style: { flex: 1, minWidth: 0, whiteSpace: "nowrap", overflow: "hidden", textOverflow: "ellipsis" }, children:
|
|
901
|
-
|
|
974
|
+
/* @__PURE__ */ n("span", { style: { ...x.rowBottom, justifyContent: "space-between", alignItems: "center", gap: 6, color: g > 0 && !o ? "#4a5568" : a.muted }, children: [
|
|
975
|
+
/* @__PURE__ */ e("span", { style: { flex: 1, minWidth: 0, whiteSpace: "nowrap", overflow: "hidden", textOverflow: "ellipsis" }, children: M || /* @__PURE__ */ e("span", { style: { opacity: 0.5 }, children: "Chưa có tin nhắn" }) }),
|
|
976
|
+
I ? /* @__PURE__ */ n(
|
|
902
977
|
"span",
|
|
903
978
|
{
|
|
904
|
-
title: `Phụ trách: ${
|
|
979
|
+
title: `Phụ trách: ${I.name}${I.title ? ` (${I.title})` : ""}`,
|
|
905
980
|
style: {
|
|
906
981
|
display: "inline-flex",
|
|
907
982
|
alignItems: "center",
|
|
@@ -911,9 +986,9 @@ function nn({ conversation: t, provider: i, selected: r, primary: o, currentAgen
|
|
|
911
986
|
fontSize: 10,
|
|
912
987
|
fontWeight: 600,
|
|
913
988
|
flexShrink: 0,
|
|
914
|
-
background:
|
|
915
|
-
color:
|
|
916
|
-
border:
|
|
989
|
+
background: q ? `${r}18` : "#f1f5f9",
|
|
990
|
+
color: q ? r : "#475569",
|
|
991
|
+
border: q ? `1px solid ${r}33` : "1px solid #e2e8f0"
|
|
917
992
|
},
|
|
918
993
|
children: [
|
|
919
994
|
/* @__PURE__ */ e(
|
|
@@ -923,7 +998,7 @@ function nn({ conversation: t, provider: i, selected: r, primary: o, currentAgen
|
|
|
923
998
|
width: 14,
|
|
924
999
|
height: 14,
|
|
925
1000
|
borderRadius: "50%",
|
|
926
|
-
background:
|
|
1001
|
+
background: q ? r : "#64748b",
|
|
927
1002
|
color: "#fff",
|
|
928
1003
|
fontSize: 8,
|
|
929
1004
|
fontWeight: 700,
|
|
@@ -932,13 +1007,13 @@ function nn({ conversation: t, provider: i, selected: r, primary: o, currentAgen
|
|
|
932
1007
|
overflow: "hidden",
|
|
933
1008
|
flexShrink: 0
|
|
934
1009
|
},
|
|
935
|
-
children:
|
|
1010
|
+
children: I.avatarUrl ? /* @__PURE__ */ e("img", { src: I.avatarUrl, alt: "", style: { width: "100%", height: "100%", objectFit: "cover" } }) : je(I.name)
|
|
936
1011
|
}
|
|
937
1012
|
),
|
|
938
|
-
/* @__PURE__ */ e("span", { style: { maxWidth: 68, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children:
|
|
1013
|
+
/* @__PURE__ */ e("span", { style: { maxWidth: 68, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: pt(I.name) })
|
|
939
1014
|
]
|
|
940
1015
|
}
|
|
941
|
-
) :
|
|
1016
|
+
) : g > 0 ? /* @__PURE__ */ e(
|
|
942
1017
|
"span",
|
|
943
1018
|
{
|
|
944
1019
|
style: {
|
|
@@ -961,142 +1036,184 @@ function nn({ conversation: t, provider: i, selected: r, primary: o, currentAgen
|
|
|
961
1036
|
}
|
|
962
1037
|
);
|
|
963
1038
|
}
|
|
964
|
-
function
|
|
965
|
-
var
|
|
966
|
-
const [
|
|
967
|
-
|
|
968
|
-
if (!
|
|
969
|
-
function
|
|
970
|
-
var
|
|
971
|
-
(
|
|
1039
|
+
function yn({ conversation: t, provider: i, connection: o, client: r, primary: c, error: C, onRegisterAppend: y, refreshKey: L, infoOpen: w, onToggleInfo: g, t: $, disableAttachments: T, hideKeyboardHint: E, extensions: M, currentAgent: I, teamAgents: q, onAssignAgent: R, onLinkContact: H, onRefreshContactInfo: J, layoutMode: F = "desktop", onBackToList: re, totalUnreadCount: V = 0 }) {
|
|
1040
|
+
var Qe, et;
|
|
1041
|
+
const [B, b] = u([]), [S, D] = u(), [j, Z] = u(""), [pe, ve] = u(!0), [fe, se] = u(!1), [G, k] = u(""), ie = X(null), h = t.contactName ?? t.subject ?? t.providerConversationKey, A = X(null), U = X(null), [z, ce] = u(null), [de, Q] = u(!1), [he, Ye] = u(!1), [ke, Ie] = u(!1), [Ee, ee] = u(0), Oe = X(null), $e = X(null), we = X(null), [ue, Be] = u(!1), [Ue, De] = u(""), [Ne, Je] = u([]), Pe = X(null), ze = X(null), [_, oe] = u(!1), Le = X(null), Ze = X(null);
|
|
1042
|
+
K(() => {
|
|
1043
|
+
if (!_) return;
|
|
1044
|
+
function l(f) {
|
|
1045
|
+
var v, O;
|
|
1046
|
+
(v = Le.current) != null && v.contains(f.target) || (O = Ze.current) != null && O.contains(f.target) || oe(!1);
|
|
972
1047
|
}
|
|
973
|
-
return document.addEventListener("mousedown",
|
|
974
|
-
}, [
|
|
975
|
-
|
|
976
|
-
}, [
|
|
977
|
-
if (!
|
|
978
|
-
function
|
|
979
|
-
var
|
|
980
|
-
(
|
|
1048
|
+
return document.addEventListener("mousedown", l), () => document.removeEventListener("mousedown", l);
|
|
1049
|
+
}, [_]), K(() => () => {
|
|
1050
|
+
z != null && z.objectUrl && URL.revokeObjectURL(z.objectUrl);
|
|
1051
|
+
}, [z == null ? void 0 : z.objectUrl]), K(() => {
|
|
1052
|
+
if (!ke) return;
|
|
1053
|
+
function l(f) {
|
|
1054
|
+
var v, O;
|
|
1055
|
+
(v = $e.current) != null && v.contains(f.target) || (O = Oe.current) != null && O.contains(f.target) || Ie(!1);
|
|
981
1056
|
}
|
|
982
|
-
return document.addEventListener("mousedown",
|
|
983
|
-
}, [
|
|
984
|
-
|
|
1057
|
+
return document.addEventListener("mousedown", l), () => document.removeEventListener("mousedown", l);
|
|
1058
|
+
}, [ke]), K(() => {
|
|
1059
|
+
r.listCannedResponses().then(Je).catch(() => {
|
|
985
1060
|
});
|
|
986
|
-
}, [
|
|
987
|
-
if (!
|
|
988
|
-
function
|
|
989
|
-
var
|
|
990
|
-
(
|
|
1061
|
+
}, [r]), K(() => {
|
|
1062
|
+
if (!ue) return;
|
|
1063
|
+
function l(f) {
|
|
1064
|
+
var v, O;
|
|
1065
|
+
(v = ze.current) != null && v.contains(f.target) || (O = Pe.current) != null && O.contains(f.target) || Be(!1);
|
|
991
1066
|
}
|
|
992
|
-
return document.addEventListener("mousedown",
|
|
993
|
-
}, [
|
|
994
|
-
const
|
|
995
|
-
|
|
1067
|
+
return document.addEventListener("mousedown", l), () => document.removeEventListener("mousedown", l);
|
|
1068
|
+
}, [ue]);
|
|
1069
|
+
const Me = X(!0), ye = Te(async (l, f) => {
|
|
1070
|
+
f || (Me.current = !l);
|
|
996
1071
|
try {
|
|
997
|
-
const
|
|
998
|
-
|
|
999
|
-
} catch (
|
|
1000
|
-
|
|
1072
|
+
const v = await r.listMessages(t.id, l);
|
|
1073
|
+
b((O) => l ? [...v.items, ...O] : v.items), D(v.nextCursor);
|
|
1074
|
+
} catch (v) {
|
|
1075
|
+
k(v instanceof Error ? v.message : "Không tải được tin nhắn");
|
|
1001
1076
|
} finally {
|
|
1002
|
-
|
|
1077
|
+
f || ve(!1);
|
|
1003
1078
|
}
|
|
1004
|
-
}, [
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
}, [
|
|
1008
|
-
|
|
1009
|
-
}, [
|
|
1010
|
-
|
|
1011
|
-
const
|
|
1012
|
-
|
|
1079
|
+
}, [r, t.id]);
|
|
1080
|
+
K(() => {
|
|
1081
|
+
ve(!0), ye();
|
|
1082
|
+
}, [ye]), K(() => {
|
|
1083
|
+
L && ye(void 0, !0);
|
|
1084
|
+
}, [L]), K(() => {
|
|
1085
|
+
Me.current && requestAnimationFrame(() => {
|
|
1086
|
+
const l = ie.current;
|
|
1087
|
+
l && (l.scrollTop = l.scrollHeight);
|
|
1013
1088
|
});
|
|
1014
|
-
}, [
|
|
1015
|
-
|
|
1089
|
+
}, [B]), K(() => (y == null || y((l) => {
|
|
1090
|
+
Me.current = !0, b((f) => f.some((v) => v.id === l.id) ? f : [...f, l]);
|
|
1016
1091
|
}), () => {
|
|
1017
|
-
|
|
1018
|
-
}), [
|
|
1019
|
-
async function
|
|
1020
|
-
var
|
|
1021
|
-
const
|
|
1022
|
-
if (!
|
|
1023
|
-
|
|
1024
|
-
const
|
|
1025
|
-
|
|
1092
|
+
y == null || y(null);
|
|
1093
|
+
}), [y]);
|
|
1094
|
+
async function te(l) {
|
|
1095
|
+
var O;
|
|
1096
|
+
const f = (O = l.target.files) == null ? void 0 : O[0];
|
|
1097
|
+
if (!f) return;
|
|
1098
|
+
l.target.value = "";
|
|
1099
|
+
const v = URL.createObjectURL(f);
|
|
1100
|
+
ce({ file: f, uploading: !0, objectUrl: v });
|
|
1026
1101
|
try {
|
|
1027
|
-
const
|
|
1028
|
-
|
|
1102
|
+
const N = await r.uploadAttachment(f);
|
|
1103
|
+
ce({ file: f, uploading: !1, url: N.url, mimeType: N.mimeType, attachmentType: N.attachmentType, objectUrl: v });
|
|
1029
1104
|
} catch {
|
|
1030
|
-
URL.revokeObjectURL(
|
|
1105
|
+
URL.revokeObjectURL(v), ce(null), k("Không tải lên được tệp đính kèm");
|
|
1031
1106
|
}
|
|
1032
1107
|
}
|
|
1033
|
-
async function
|
|
1034
|
-
|
|
1035
|
-
const
|
|
1036
|
-
if (!
|
|
1037
|
-
|
|
1038
|
-
const
|
|
1039
|
-
|
|
1040
|
-
...
|
|
1108
|
+
async function _e(l) {
|
|
1109
|
+
l.preventDefault();
|
|
1110
|
+
const f = j.trim(), v = z != null && z.url ? [{ url: z.url, mimeType: z.mimeType ?? "application/octet-stream", type: z.attachmentType }] : [];
|
|
1111
|
+
if (!f && !v.length || fe) return;
|
|
1112
|
+
se(!0), k(""), !t.assignedAgent && I && R(I);
|
|
1113
|
+
const O = `optimistic-${Date.now()}`;
|
|
1114
|
+
I && (Me.current = !0, b((N) => [
|
|
1115
|
+
...N,
|
|
1041
1116
|
{
|
|
1042
|
-
id:
|
|
1117
|
+
id: O,
|
|
1043
1118
|
direction: "outbound",
|
|
1044
1119
|
status: "sending",
|
|
1045
|
-
text:
|
|
1046
|
-
attachments:
|
|
1120
|
+
text: f || void 0,
|
|
1121
|
+
attachments: v.length ? v : void 0,
|
|
1047
1122
|
occurredAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1048
|
-
senderAgent:
|
|
1123
|
+
senderAgent: I
|
|
1049
1124
|
}
|
|
1050
1125
|
]));
|
|
1051
1126
|
try {
|
|
1052
|
-
await
|
|
1053
|
-
var
|
|
1054
|
-
const
|
|
1055
|
-
return
|
|
1127
|
+
await r.sendMessage(t.id, f || void 0, v.length ? v : void 0), z != null && z.objectUrl && URL.revokeObjectURL(z.objectUrl), Z(""), ce(null), await ye(), I && b((N) => {
|
|
1128
|
+
var Se, Re;
|
|
1129
|
+
const P = N.filter((ge) => ge.id !== O), ae = P.length - 1;
|
|
1130
|
+
return ae >= 0 && ((Se = P[ae]) == null ? void 0 : Se.direction) === "outbound" && !((Re = P[ae]) != null && Re.senderAgent) ? P.map((ge, tt) => tt === ae ? { ...ge, senderAgent: I } : ge) : P;
|
|
1056
1131
|
});
|
|
1057
|
-
} catch (
|
|
1058
|
-
|
|
1132
|
+
} catch (N) {
|
|
1133
|
+
b((P) => P.filter((ae) => ae.id !== O)), k(N instanceof Error ? N.message : "Không gửi được tin nhắn");
|
|
1059
1134
|
} finally {
|
|
1060
|
-
|
|
1135
|
+
se(!1);
|
|
1061
1136
|
}
|
|
1062
1137
|
}
|
|
1063
|
-
function
|
|
1064
|
-
const
|
|
1065
|
-
if (!
|
|
1066
|
-
|
|
1138
|
+
function rt(l) {
|
|
1139
|
+
const f = we.current;
|
|
1140
|
+
if (!f) {
|
|
1141
|
+
Z((P) => P + l), Ie(!1);
|
|
1067
1142
|
return;
|
|
1068
1143
|
}
|
|
1069
|
-
const
|
|
1070
|
-
|
|
1071
|
-
|
|
1144
|
+
const v = f.selectionStart ?? j.length, O = f.selectionEnd ?? j.length, N = j.slice(0, v) + l + j.slice(O);
|
|
1145
|
+
Z(N), Ie(!1), requestAnimationFrame(() => {
|
|
1146
|
+
f.focus(), f.selectionStart = f.selectionEnd = v + l.length;
|
|
1072
1147
|
});
|
|
1073
1148
|
}
|
|
1074
|
-
function
|
|
1075
|
-
|
|
1076
|
-
const
|
|
1077
|
-
|
|
1149
|
+
function Fe(l) {
|
|
1150
|
+
Z(l), Be(!1), De(""), requestAnimationFrame(() => {
|
|
1151
|
+
const f = we.current;
|
|
1152
|
+
f && (f.focus(), f.selectionStart = f.selectionEnd = l.length);
|
|
1078
1153
|
});
|
|
1079
1154
|
}
|
|
1080
|
-
const
|
|
1081
|
-
return /* @__PURE__ */ n("section", { style:
|
|
1082
|
-
/* @__PURE__ */ n("header", { style:
|
|
1083
|
-
/* @__PURE__ */
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1155
|
+
const me = !fe && (j.trim().length > 0 || (z == null ? void 0 : z.url) != null && !z.uploading), xe = F === "desktop" ? x.toolbarBtn : { ...x.toolbarBtn, width: 32, height: 32 };
|
|
1156
|
+
return /* @__PURE__ */ n("section", { style: x.chat, children: [
|
|
1157
|
+
/* @__PURE__ */ n("header", { style: { ...x.chatHeader, ...F === "mobile" ? { padding: "0 10px 0 8px", gap: 8 } : {} }, children: [
|
|
1158
|
+
F === "mobile" && /* @__PURE__ */ n(
|
|
1159
|
+
"button",
|
|
1160
|
+
{
|
|
1161
|
+
type: "button",
|
|
1162
|
+
onClick: re,
|
|
1163
|
+
"aria-label": "Quay lại danh sách",
|
|
1164
|
+
style: {
|
|
1165
|
+
...x.iconButton,
|
|
1166
|
+
width: 36,
|
|
1167
|
+
height: 36,
|
|
1168
|
+
marginLeft: 0,
|
|
1169
|
+
position: "relative",
|
|
1170
|
+
flexShrink: 0,
|
|
1171
|
+
color: a.ink
|
|
1172
|
+
},
|
|
1173
|
+
children: [
|
|
1174
|
+
/* @__PURE__ */ e(Xt, { size: 18, strokeWidth: 2.2 }),
|
|
1175
|
+
V > 0 && /* @__PURE__ */ e(
|
|
1176
|
+
"span",
|
|
1177
|
+
{
|
|
1178
|
+
style: {
|
|
1179
|
+
position: "absolute",
|
|
1180
|
+
top: 3,
|
|
1181
|
+
right: 3,
|
|
1182
|
+
minWidth: 15,
|
|
1183
|
+
height: 15,
|
|
1184
|
+
borderRadius: 999,
|
|
1185
|
+
background: "#ef4444",
|
|
1186
|
+
color: "#fff",
|
|
1187
|
+
fontSize: 9,
|
|
1188
|
+
fontWeight: 800,
|
|
1189
|
+
display: "inline-grid",
|
|
1190
|
+
placeItems: "center",
|
|
1191
|
+
padding: "0 3px",
|
|
1192
|
+
border: `1.5px solid ${a.white}`
|
|
1193
|
+
},
|
|
1194
|
+
children: V > 99 ? "99+" : V
|
|
1195
|
+
}
|
|
1196
|
+
)
|
|
1197
|
+
]
|
|
1198
|
+
}
|
|
1199
|
+
),
|
|
1200
|
+
/* @__PURE__ */ e(Pt, { name: h, color: c, image: t.contactPictureUrl, provider: i }),
|
|
1201
|
+
/* @__PURE__ */ n("div", { style: x.contact, children: [
|
|
1202
|
+
/* @__PURE__ */ e("strong", { style: x.contactName, children: h }),
|
|
1203
|
+
/* @__PURE__ */ e("span", { style: x.contactMeta, children: fn(o) ?? Nt(i) })
|
|
1087
1204
|
] }),
|
|
1088
|
-
/* @__PURE__ */ n("div", { style: { ...
|
|
1089
|
-
/* @__PURE__ */ n("div", { ref:
|
|
1090
|
-
!t.assignedAgent &&
|
|
1205
|
+
/* @__PURE__ */ n("div", { style: { ...x.headerActions, alignItems: "center", gap: 6 }, children: [
|
|
1206
|
+
/* @__PURE__ */ n("div", { ref: Le, style: { position: "relative", display: "inline-flex", alignItems: "center", gap: 4 }, children: [
|
|
1207
|
+
!t.assignedAgent && I ? /* @__PURE__ */ n("div", { style: { display: "inline-flex", alignItems: "center", borderRadius: 999, border: `1px solid ${c}40`, background: `${c}0d`, overflow: "hidden" }, children: [
|
|
1091
1208
|
/* @__PURE__ */ n(
|
|
1092
1209
|
"button",
|
|
1093
1210
|
{
|
|
1094
1211
|
type: "button",
|
|
1095
|
-
onClick: () => void I
|
|
1212
|
+
onClick: () => void R(I),
|
|
1096
1213
|
style: {
|
|
1097
1214
|
border: 0,
|
|
1098
1215
|
background: "transparent",
|
|
1099
|
-
color:
|
|
1216
|
+
color: c,
|
|
1100
1217
|
padding: "4px 9px",
|
|
1101
1218
|
fontSize: 11.5,
|
|
1102
1219
|
fontWeight: 600,
|
|
@@ -1107,51 +1224,51 @@ function rn({ conversation: t, provider: i, connection: r, client: o, primary: h
|
|
|
1107
1224
|
whiteSpace: "nowrap"
|
|
1108
1225
|
},
|
|
1109
1226
|
children: [
|
|
1110
|
-
/* @__PURE__ */ e(
|
|
1111
|
-
/* @__PURE__ */ e("span", { children: "+ Nhận phụ trách" })
|
|
1227
|
+
/* @__PURE__ */ e(It, { size: 12, strokeWidth: 2.2 }),
|
|
1228
|
+
/* @__PURE__ */ e("span", { children: F === "mobile" ? "+ Nhận" : "+ Nhận phụ trách" })
|
|
1112
1229
|
]
|
|
1113
1230
|
}
|
|
1114
1231
|
),
|
|
1115
|
-
((
|
|
1232
|
+
((q == null ? void 0 : q.length) ?? 0) > 1 && /* @__PURE__ */ e(
|
|
1116
1233
|
"button",
|
|
1117
1234
|
{
|
|
1118
1235
|
type: "button",
|
|
1119
1236
|
"aria-label": "Chọn nhân viên phụ trách",
|
|
1120
|
-
onClick: () =>
|
|
1237
|
+
onClick: () => oe((l) => !l),
|
|
1121
1238
|
style: {
|
|
1122
1239
|
border: 0,
|
|
1123
|
-
borderLeft: `1px solid ${
|
|
1240
|
+
borderLeft: `1px solid ${c}30`,
|
|
1124
1241
|
background: "transparent",
|
|
1125
|
-
color:
|
|
1242
|
+
color: c,
|
|
1126
1243
|
padding: "4px 6px",
|
|
1127
1244
|
cursor: "pointer",
|
|
1128
1245
|
display: "inline-flex",
|
|
1129
1246
|
alignItems: "center"
|
|
1130
1247
|
},
|
|
1131
|
-
children: /* @__PURE__ */ e(
|
|
1248
|
+
children: /* @__PURE__ */ e(ct, { size: 12, strokeWidth: 2.2 })
|
|
1132
1249
|
}
|
|
1133
1250
|
)
|
|
1134
1251
|
] }) : /* @__PURE__ */ n(
|
|
1135
1252
|
"button",
|
|
1136
1253
|
{
|
|
1137
1254
|
type: "button",
|
|
1138
|
-
onClick: () =>
|
|
1255
|
+
onClick: () => oe((l) => !l),
|
|
1139
1256
|
style: {
|
|
1140
1257
|
display: "inline-flex",
|
|
1141
1258
|
alignItems: "center",
|
|
1142
1259
|
gap: 6,
|
|
1143
1260
|
padding: "3px 9px 3px 4px",
|
|
1144
1261
|
borderRadius: 999,
|
|
1145
|
-
border: `1px solid ${
|
|
1146
|
-
background:
|
|
1147
|
-
color:
|
|
1262
|
+
border: `1px solid ${a.line}`,
|
|
1263
|
+
background: a.surface,
|
|
1264
|
+
color: a.ink,
|
|
1148
1265
|
fontSize: 11.5,
|
|
1149
1266
|
fontWeight: 600,
|
|
1150
1267
|
cursor: "pointer",
|
|
1151
1268
|
whiteSpace: "nowrap"
|
|
1152
1269
|
},
|
|
1153
1270
|
children: [
|
|
1154
|
-
t.assignedAgent ? /* @__PURE__ */ n(
|
|
1271
|
+
t.assignedAgent ? /* @__PURE__ */ n(ne, { children: [
|
|
1155
1272
|
/* @__PURE__ */ e(
|
|
1156
1273
|
"span",
|
|
1157
1274
|
{
|
|
@@ -1159,7 +1276,7 @@ function rn({ conversation: t, provider: i, connection: r, client: o, primary: h
|
|
|
1159
1276
|
width: 18,
|
|
1160
1277
|
height: 18,
|
|
1161
1278
|
borderRadius: "50%",
|
|
1162
|
-
background:
|
|
1279
|
+
background: c,
|
|
1163
1280
|
color: "#fff",
|
|
1164
1281
|
fontSize: 9,
|
|
1165
1282
|
fontWeight: 700,
|
|
@@ -1168,44 +1285,44 @@ function rn({ conversation: t, provider: i, connection: r, client: o, primary: h
|
|
|
1168
1285
|
overflow: "hidden",
|
|
1169
1286
|
flexShrink: 0
|
|
1170
1287
|
},
|
|
1171
|
-
children: t.assignedAgent.avatarUrl ? /* @__PURE__ */ e("img", { src: t.assignedAgent.avatarUrl, alt: "", style: { width: "100%", height: "100%", objectFit: "cover" } }) :
|
|
1288
|
+
children: t.assignedAgent.avatarUrl ? /* @__PURE__ */ e("img", { src: t.assignedAgent.avatarUrl, alt: "", style: { width: "100%", height: "100%", objectFit: "cover" } }) : je(t.assignedAgent.name)
|
|
1172
1289
|
}
|
|
1173
1290
|
),
|
|
1174
|
-
/* @__PURE__ */ e("span", { style: { color:
|
|
1175
|
-
/* @__PURE__ */ e("span", { style: { maxWidth: 110, overflow: "hidden", textOverflow: "ellipsis" }, children:
|
|
1176
|
-
] }) : /* @__PURE__ */ n(
|
|
1177
|
-
/* @__PURE__ */ e(
|
|
1178
|
-
/* @__PURE__ */ e("span", { style: { color:
|
|
1291
|
+
F !== "mobile" && /* @__PURE__ */ e("span", { style: { color: a.muted, fontWeight: 500 }, children: "Phụ trách:" }),
|
|
1292
|
+
/* @__PURE__ */ e("span", { style: { maxWidth: F === "mobile" ? 76 : 110, overflow: "hidden", textOverflow: "ellipsis" }, children: pt(t.assignedAgent.name) })
|
|
1293
|
+
] }) : /* @__PURE__ */ n(ne, { children: [
|
|
1294
|
+
/* @__PURE__ */ e(an, { size: 13, color: a.muted }),
|
|
1295
|
+
/* @__PURE__ */ e("span", { style: { color: a.muted }, children: "Chưa phân công" })
|
|
1179
1296
|
] }),
|
|
1180
|
-
/* @__PURE__ */ e(
|
|
1297
|
+
/* @__PURE__ */ e(ct, { size: 12, color: a.muted })
|
|
1181
1298
|
]
|
|
1182
1299
|
}
|
|
1183
1300
|
),
|
|
1184
|
-
|
|
1301
|
+
_ && /* @__PURE__ */ n(
|
|
1185
1302
|
"div",
|
|
1186
1303
|
{
|
|
1187
|
-
ref:
|
|
1304
|
+
ref: Ze,
|
|
1188
1305
|
style: {
|
|
1189
1306
|
position: "absolute",
|
|
1190
1307
|
top: "calc(100% + 6px)",
|
|
1191
1308
|
right: 0,
|
|
1192
1309
|
zIndex: 200,
|
|
1193
1310
|
minWidth: 230,
|
|
1194
|
-
background:
|
|
1195
|
-
border: `1px solid ${
|
|
1311
|
+
background: a.white,
|
|
1312
|
+
border: `1px solid ${a.line}`,
|
|
1196
1313
|
borderRadius: 11,
|
|
1197
1314
|
boxShadow: "0 10px 28px rgba(23,32,51,.15)",
|
|
1198
1315
|
padding: 6,
|
|
1199
1316
|
fontSize: 12
|
|
1200
1317
|
},
|
|
1201
1318
|
children: [
|
|
1202
|
-
/* @__PURE__ */ e("div", { style: { padding: "4px 8px 6px", fontSize: 10, fontWeight: 700, color:
|
|
1203
|
-
|
|
1319
|
+
/* @__PURE__ */ e("div", { style: { padding: "4px 8px 6px", fontSize: 10, fontWeight: 700, color: a.muted, letterSpacing: 0.8, textTransform: "uppercase" }, children: "Người phụ trách hội thoại" }),
|
|
1320
|
+
I && ((Qe = t.assignedAgent) == null ? void 0 : Qe.id) !== I.id && /* @__PURE__ */ n(
|
|
1204
1321
|
"button",
|
|
1205
1322
|
{
|
|
1206
1323
|
type: "button",
|
|
1207
1324
|
onClick: () => {
|
|
1208
|
-
|
|
1325
|
+
oe(!1), R(I);
|
|
1209
1326
|
},
|
|
1210
1327
|
style: {
|
|
1211
1328
|
display: "flex",
|
|
@@ -1214,8 +1331,8 @@ function rn({ conversation: t, provider: i, connection: r, client: o, primary: h
|
|
|
1214
1331
|
width: "100%",
|
|
1215
1332
|
border: 0,
|
|
1216
1333
|
borderRadius: 7,
|
|
1217
|
-
background: `${
|
|
1218
|
-
color:
|
|
1334
|
+
background: `${c}10`,
|
|
1335
|
+
color: c,
|
|
1219
1336
|
padding: "6px 8px",
|
|
1220
1337
|
marginBottom: 4,
|
|
1221
1338
|
fontWeight: 600,
|
|
@@ -1224,24 +1341,24 @@ function rn({ conversation: t, provider: i, connection: r, client: o, primary: h
|
|
|
1224
1341
|
textAlign: "left"
|
|
1225
1342
|
},
|
|
1226
1343
|
children: [
|
|
1227
|
-
/* @__PURE__ */ e(
|
|
1344
|
+
/* @__PURE__ */ e(It, { size: 13 }),
|
|
1228
1345
|
/* @__PURE__ */ n("span", { children: [
|
|
1229
1346
|
"Nhận phụ trách cho tôi (",
|
|
1230
|
-
|
|
1347
|
+
pt(I.name),
|
|
1231
1348
|
")"
|
|
1232
1349
|
] })
|
|
1233
1350
|
]
|
|
1234
1351
|
}
|
|
1235
1352
|
),
|
|
1236
|
-
/* @__PURE__ */ e("div", { style: { maxHeight: 200, overflowY: "auto" }, children: (
|
|
1237
|
-
var
|
|
1238
|
-
const
|
|
1353
|
+
/* @__PURE__ */ e("div", { style: { maxHeight: 200, overflowY: "auto" }, children: (q ?? []).map((l) => {
|
|
1354
|
+
var v;
|
|
1355
|
+
const f = ((v = t.assignedAgent) == null ? void 0 : v.id) === l.id;
|
|
1239
1356
|
return /* @__PURE__ */ n(
|
|
1240
1357
|
"button",
|
|
1241
1358
|
{
|
|
1242
1359
|
type: "button",
|
|
1243
1360
|
onClick: () => {
|
|
1244
|
-
|
|
1361
|
+
oe(!1), R(l);
|
|
1245
1362
|
},
|
|
1246
1363
|
style: {
|
|
1247
1364
|
display: "flex",
|
|
@@ -1251,8 +1368,8 @@ function rn({ conversation: t, provider: i, connection: r, client: o, primary: h
|
|
|
1251
1368
|
width: "100%",
|
|
1252
1369
|
border: 0,
|
|
1253
1370
|
borderRadius: 7,
|
|
1254
|
-
background:
|
|
1255
|
-
color:
|
|
1371
|
+
background: f ? "#f1f5f9" : "transparent",
|
|
1372
|
+
color: a.ink,
|
|
1256
1373
|
padding: "6px 8px",
|
|
1257
1374
|
cursor: "pointer",
|
|
1258
1375
|
textAlign: "left"
|
|
@@ -1266,8 +1383,8 @@ function rn({ conversation: t, provider: i, connection: r, client: o, primary: h
|
|
|
1266
1383
|
width: 22,
|
|
1267
1384
|
height: 22,
|
|
1268
1385
|
borderRadius: "50%",
|
|
1269
|
-
background: `${
|
|
1270
|
-
color:
|
|
1386
|
+
background: `${c}18`,
|
|
1387
|
+
color: c,
|
|
1271
1388
|
fontSize: 10,
|
|
1272
1389
|
fontWeight: 700,
|
|
1273
1390
|
display: "inline-grid",
|
|
@@ -1275,28 +1392,28 @@ function rn({ conversation: t, provider: i, connection: r, client: o, primary: h
|
|
|
1275
1392
|
overflow: "hidden",
|
|
1276
1393
|
flexShrink: 0
|
|
1277
1394
|
},
|
|
1278
|
-
children:
|
|
1395
|
+
children: l.avatarUrl ? /* @__PURE__ */ e("img", { src: l.avatarUrl, alt: "", style: { width: "100%", height: "100%", objectFit: "cover" } }) : je(l.name)
|
|
1279
1396
|
}
|
|
1280
1397
|
),
|
|
1281
1398
|
/* @__PURE__ */ n("span", { style: { minWidth: 0 }, children: [
|
|
1282
|
-
/* @__PURE__ */ e("span", { style: { display: "block", fontWeight: 600, whiteSpace: "nowrap", overflow: "hidden", textOverflow: "ellipsis" }, children:
|
|
1283
|
-
|
|
1399
|
+
/* @__PURE__ */ e("span", { style: { display: "block", fontWeight: 600, whiteSpace: "nowrap", overflow: "hidden", textOverflow: "ellipsis" }, children: l.name }),
|
|
1400
|
+
l.title && /* @__PURE__ */ e("span", { style: { display: "block", fontSize: 10.5, color: a.muted }, children: l.title })
|
|
1284
1401
|
] })
|
|
1285
1402
|
] }),
|
|
1286
|
-
|
|
1403
|
+
f && /* @__PURE__ */ e(gt, { size: 13, color: c, strokeWidth: 2.5 })
|
|
1287
1404
|
]
|
|
1288
1405
|
},
|
|
1289
|
-
|
|
1406
|
+
l.id
|
|
1290
1407
|
);
|
|
1291
1408
|
}) }),
|
|
1292
|
-
t.assignedAgent && /* @__PURE__ */ n(
|
|
1293
|
-
/* @__PURE__ */ e("div", { style: { borderTop: `1px solid ${
|
|
1409
|
+
t.assignedAgent && /* @__PURE__ */ n(ne, { children: [
|
|
1410
|
+
/* @__PURE__ */ e("div", { style: { borderTop: `1px solid ${a.line}`, margin: "5px 0" } }),
|
|
1294
1411
|
/* @__PURE__ */ n(
|
|
1295
1412
|
"button",
|
|
1296
1413
|
{
|
|
1297
1414
|
type: "button",
|
|
1298
1415
|
onClick: () => {
|
|
1299
|
-
|
|
1416
|
+
oe(!1), R(null);
|
|
1300
1417
|
},
|
|
1301
1418
|
style: {
|
|
1302
1419
|
display: "flex",
|
|
@@ -1314,7 +1431,7 @@ function rn({ conversation: t, provider: i, connection: r, client: o, primary: h
|
|
|
1314
1431
|
textAlign: "left"
|
|
1315
1432
|
},
|
|
1316
1433
|
children: [
|
|
1317
|
-
/* @__PURE__ */ e(
|
|
1434
|
+
/* @__PURE__ */ e(Ve, { size: 13 }),
|
|
1318
1435
|
/* @__PURE__ */ e("span", { children: "Bỏ phân công (Chưa có người nhận)" })
|
|
1319
1436
|
]
|
|
1320
1437
|
}
|
|
@@ -1324,94 +1441,96 @@ function rn({ conversation: t, provider: i, connection: r, client: o, primary: h
|
|
|
1324
1441
|
}
|
|
1325
1442
|
)
|
|
1326
1443
|
] }),
|
|
1327
|
-
/* @__PURE__ */ e("button", { style:
|
|
1444
|
+
F !== "mobile" && /* @__PURE__ */ e("button", { style: x.iconButton, "aria-label": "Thêm tùy chọn", children: /* @__PURE__ */ e(Et, { size: 16, strokeWidth: 2 }) }),
|
|
1328
1445
|
/* @__PURE__ */ e(
|
|
1329
1446
|
"button",
|
|
1330
1447
|
{
|
|
1331
1448
|
style: {
|
|
1332
|
-
...
|
|
1333
|
-
background: w ? `${
|
|
1334
|
-
color: w ?
|
|
1449
|
+
...x.iconButton,
|
|
1450
|
+
background: w ? `${c}14` : "transparent",
|
|
1451
|
+
color: w ? c : a.muted
|
|
1335
1452
|
},
|
|
1336
1453
|
"aria-label": "Thông tin liên hệ",
|
|
1337
|
-
onClick:
|
|
1338
|
-
children: /* @__PURE__ */ e(
|
|
1454
|
+
onClick: g,
|
|
1455
|
+
children: /* @__PURE__ */ e(Qt, { size: 16, strokeWidth: 2 })
|
|
1339
1456
|
}
|
|
1340
1457
|
)
|
|
1341
1458
|
] })
|
|
1342
1459
|
] }),
|
|
1343
|
-
/* @__PURE__ */ n(
|
|
1344
|
-
/* @__PURE__ */ e("div", { style:
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
/* @__PURE__ */ e(
|
|
1460
|
+
/* @__PURE__ */ n(Ut, { ref: ie, style: x.messageArea, children: [
|
|
1461
|
+
/* @__PURE__ */ e("div", { style: x.day, children: $.today }),
|
|
1462
|
+
S && /* @__PURE__ */ e("button", { onClick: () => void ye(S), style: x.historyButton, children: $.loadOlder }),
|
|
1463
|
+
pe && /* @__PURE__ */ n("div", { style: x.messageHint, children: [
|
|
1464
|
+
/* @__PURE__ */ e(ut, {}),
|
|
1348
1465
|
" ",
|
|
1349
|
-
|
|
1466
|
+
$.loading
|
|
1350
1467
|
] }),
|
|
1351
|
-
!
|
|
1352
|
-
|
|
1353
|
-
const
|
|
1468
|
+
!pe && !B.length && /* @__PURE__ */ e("div", { style: x.messageHint, children: $.noMessages }),
|
|
1469
|
+
B.map((l, f) => {
|
|
1470
|
+
const v = (M == null ? void 0 : M.flatMap((ae) => ae.messageEnrichments ?? [])) ?? [], O = l.direction === "inbound" && v.length > 0 && f >= B.length - 15, N = O ? ot(t, {
|
|
1354
1471
|
provider: i,
|
|
1355
|
-
recentMessages:
|
|
1356
|
-
linkContact:
|
|
1357
|
-
refreshContactInfo:
|
|
1358
|
-
sendMessage: async (
|
|
1359
|
-
await
|
|
1472
|
+
recentMessages: B.slice(-10),
|
|
1473
|
+
linkContact: H,
|
|
1474
|
+
refreshContactInfo: J,
|
|
1475
|
+
sendMessage: async (ae, Se) => {
|
|
1476
|
+
await r.sendMessage(t.id, ae, Se), await ye(void 0, !0);
|
|
1360
1477
|
}
|
|
1361
|
-
}) : null,
|
|
1362
|
-
var
|
|
1363
|
-
const
|
|
1364
|
-
return
|
|
1478
|
+
}) : null, P = O && N ? v.map((ae, Se) => {
|
|
1479
|
+
var ge;
|
|
1480
|
+
const Re = (ge = l.text) == null ? void 0 : ge.match(ae.pattern);
|
|
1481
|
+
return Re ? /* @__PURE__ */ e(pn, { children: ae.render(Re, N, l) }, `${l.id}-${Se}`) : null;
|
|
1365
1482
|
}).filter(Boolean) : [];
|
|
1366
1483
|
return /* @__PURE__ */ n("div", { children: [
|
|
1367
|
-
/* @__PURE__ */ e(
|
|
1368
|
-
|
|
1369
|
-
] },
|
|
1484
|
+
/* @__PURE__ */ e(mn, { message: l, primary: c }),
|
|
1485
|
+
P.length > 0 && /* @__PURE__ */ e("div", { style: { maxWidth: "min(70%, 480px)", marginTop: -4, marginBottom: 10, display: "flex", flexDirection: "column", gap: 6 }, children: P })
|
|
1486
|
+
] }, l.id);
|
|
1370
1487
|
})
|
|
1371
1488
|
] }),
|
|
1372
|
-
/* @__PURE__ */ e("div", { style: { display: "flex", gap: 6, flexWrap: "
|
|
1489
|
+
/* @__PURE__ */ e("div", { style: { display: "flex", gap: 6, flexWrap: "nowrap", overflowX: "auto", WebkitOverflowScrolling: "touch", scrollbarWidth: "none", padding: "6px 14px 2px", borderTop: `1px solid ${a.line}` }, children: ["Cảm ơn bạn đã liên hệ 🙏", "Mình sẽ kiểm tra ngay", "Vui lòng chờ 1-2 phút"].map((l) => /* @__PURE__ */ e(
|
|
1373
1490
|
"button",
|
|
1374
1491
|
{
|
|
1375
1492
|
type: "button",
|
|
1376
|
-
onClick: () =>
|
|
1493
|
+
onClick: () => Z(l),
|
|
1377
1494
|
style: {
|
|
1378
1495
|
fontSize: 11,
|
|
1379
1496
|
padding: "3px 10px",
|
|
1380
1497
|
borderRadius: 999,
|
|
1381
|
-
background: `${
|
|
1382
|
-
color:
|
|
1383
|
-
border: `1px solid ${
|
|
1498
|
+
background: `${c}0f`,
|
|
1499
|
+
color: c,
|
|
1500
|
+
border: `1px solid ${c}33`,
|
|
1384
1501
|
cursor: "pointer",
|
|
1385
|
-
whiteSpace: "nowrap"
|
|
1502
|
+
whiteSpace: "nowrap",
|
|
1503
|
+
flexShrink: 0
|
|
1386
1504
|
},
|
|
1387
|
-
children:
|
|
1505
|
+
children: l
|
|
1388
1506
|
},
|
|
1389
|
-
|
|
1507
|
+
l
|
|
1390
1508
|
)) }),
|
|
1391
|
-
/* @__PURE__ */ n("form", { onSubmit:
|
|
1392
|
-
|
|
1509
|
+
/* @__PURE__ */ n("form", { onSubmit: _e, style: { flex: "0 0 auto", padding: "8px 14px 12px", borderTop: `1px solid ${a.line}`, background: a.white, position: "relative" }, children: [
|
|
1510
|
+
ke && /* @__PURE__ */ n(
|
|
1393
1511
|
"div",
|
|
1394
1512
|
{
|
|
1395
|
-
ref:
|
|
1513
|
+
ref: Oe,
|
|
1396
1514
|
style: {
|
|
1397
1515
|
position: "absolute",
|
|
1398
1516
|
bottom: "calc(100% + 6px)",
|
|
1399
1517
|
left: 0,
|
|
1400
1518
|
zIndex: 100,
|
|
1401
|
-
background:
|
|
1402
|
-
border: `1px solid ${
|
|
1519
|
+
background: a.white,
|
|
1520
|
+
border: `1px solid ${a.line}`,
|
|
1403
1521
|
borderRadius: 12,
|
|
1404
1522
|
boxShadow: "0 8px 24px rgba(23,32,51,.14)",
|
|
1405
1523
|
width: 280,
|
|
1524
|
+
maxWidth: "calc(100vw - 28px)",
|
|
1406
1525
|
overflow: "hidden",
|
|
1407
1526
|
fontFamily: "inherit"
|
|
1408
1527
|
},
|
|
1409
1528
|
children: [
|
|
1410
|
-
/* @__PURE__ */ e("div", { style: { display: "flex", borderBottom: `1px solid ${
|
|
1529
|
+
/* @__PURE__ */ e("div", { style: { display: "flex", borderBottom: `1px solid ${a.line}`, background: "#f9fafb" }, children: zt.map((l, f) => /* @__PURE__ */ e(
|
|
1411
1530
|
"button",
|
|
1412
1531
|
{
|
|
1413
1532
|
type: "button",
|
|
1414
|
-
onClick: () =>
|
|
1533
|
+
onClick: () => ee(f),
|
|
1415
1534
|
style: {
|
|
1416
1535
|
flex: 1,
|
|
1417
1536
|
border: 0,
|
|
@@ -1420,19 +1539,19 @@ function rn({ conversation: t, provider: i, connection: r, client: o, primary: h
|
|
|
1420
1539
|
fontSize: 16,
|
|
1421
1540
|
cursor: "pointer",
|
|
1422
1541
|
lineHeight: 1,
|
|
1423
|
-
borderBottom:
|
|
1424
|
-
opacity:
|
|
1542
|
+
borderBottom: Ee === f ? `2px solid ${c}` : "2px solid transparent",
|
|
1543
|
+
opacity: Ee === f ? 1 : 0.5,
|
|
1425
1544
|
transition: "opacity 100ms ease"
|
|
1426
1545
|
},
|
|
1427
|
-
children:
|
|
1546
|
+
children: l.icon
|
|
1428
1547
|
},
|
|
1429
|
-
|
|
1548
|
+
f
|
|
1430
1549
|
)) }),
|
|
1431
|
-
/* @__PURE__ */ e("div", { style: { display: "grid", gridTemplateColumns: "repeat(8, 1fr)", gap: 2, padding: 8, maxHeight: 180, overflowY: "auto" }, children: (
|
|
1550
|
+
/* @__PURE__ */ e("div", { style: { display: "grid", gridTemplateColumns: "repeat(8, 1fr)", gap: 2, padding: 8, maxHeight: 180, overflowY: "auto" }, children: (et = zt[Ee]) == null ? void 0 : et.emojis.map((l, f) => /* @__PURE__ */ e(
|
|
1432
1551
|
"button",
|
|
1433
1552
|
{
|
|
1434
1553
|
type: "button",
|
|
1435
|
-
onClick: () =>
|
|
1554
|
+
onClick: () => rt(l),
|
|
1436
1555
|
style: {
|
|
1437
1556
|
border: 0,
|
|
1438
1557
|
background: "transparent",
|
|
@@ -1443,127 +1562,128 @@ function rn({ conversation: t, provider: i, connection: r, client: o, primary: h
|
|
|
1443
1562
|
lineHeight: 1,
|
|
1444
1563
|
transition: "background 80ms ease"
|
|
1445
1564
|
},
|
|
1446
|
-
onMouseEnter: (
|
|
1447
|
-
|
|
1565
|
+
onMouseEnter: (v) => {
|
|
1566
|
+
v.target.style.background = "#f3f4f6";
|
|
1448
1567
|
},
|
|
1449
|
-
onMouseLeave: (
|
|
1450
|
-
|
|
1568
|
+
onMouseLeave: (v) => {
|
|
1569
|
+
v.target.style.background = "transparent";
|
|
1451
1570
|
},
|
|
1452
|
-
children:
|
|
1571
|
+
children: l
|
|
1453
1572
|
},
|
|
1454
|
-
|
|
1573
|
+
f
|
|
1455
1574
|
)) })
|
|
1456
1575
|
]
|
|
1457
1576
|
}
|
|
1458
1577
|
),
|
|
1459
|
-
|
|
1578
|
+
ue && /* @__PURE__ */ n(
|
|
1460
1579
|
"div",
|
|
1461
1580
|
{
|
|
1462
|
-
ref:
|
|
1581
|
+
ref: Pe,
|
|
1463
1582
|
style: {
|
|
1464
1583
|
position: "absolute",
|
|
1465
1584
|
bottom: "calc(100% + 6px)",
|
|
1466
1585
|
left: 0,
|
|
1467
1586
|
zIndex: 100,
|
|
1468
|
-
background:
|
|
1469
|
-
border: `1px solid ${
|
|
1587
|
+
background: a.white,
|
|
1588
|
+
border: `1px solid ${a.line}`,
|
|
1470
1589
|
borderRadius: 12,
|
|
1471
1590
|
boxShadow: "0 8px 24px rgba(23,32,51,.14)",
|
|
1472
1591
|
width: 300,
|
|
1592
|
+
maxWidth: "calc(100vw - 28px)",
|
|
1473
1593
|
overflow: "hidden",
|
|
1474
1594
|
fontFamily: "inherit"
|
|
1475
1595
|
},
|
|
1476
1596
|
children: [
|
|
1477
|
-
/* @__PURE__ */ e("div", { style: { padding: "8px 10px", borderBottom: `1px solid ${
|
|
1597
|
+
/* @__PURE__ */ e("div", { style: { padding: "8px 10px", borderBottom: `1px solid ${a.line}` }, children: /* @__PURE__ */ e(
|
|
1478
1598
|
"input",
|
|
1479
1599
|
{
|
|
1480
1600
|
autoFocus: !0,
|
|
1481
1601
|
type: "text",
|
|
1482
1602
|
placeholder: "Tìm template…",
|
|
1483
|
-
value:
|
|
1484
|
-
onChange: (
|
|
1485
|
-
style: { width: "100%", boxSizing: "border-box", border: `1px solid ${
|
|
1603
|
+
value: Ue,
|
|
1604
|
+
onChange: (l) => De(l.target.value),
|
|
1605
|
+
style: { width: "100%", boxSizing: "border-box", border: `1px solid ${a.line}`, borderRadius: 7, padding: "5px 8px", fontSize: 12, outline: "none", fontFamily: "inherit", color: a.ink }
|
|
1486
1606
|
}
|
|
1487
1607
|
) }),
|
|
1488
1608
|
/* @__PURE__ */ e("div", { style: { maxHeight: 220, overflowY: "auto" }, children: (() => {
|
|
1489
|
-
const
|
|
1490
|
-
return
|
|
1609
|
+
const l = Ue.trim().toLowerCase(), f = l ? Ne.filter((v) => v.title.toLowerCase().includes(l) || v.content.toLowerCase().includes(l) || (v.shortcut ?? "").toLowerCase().includes(l)) : Ne;
|
|
1610
|
+
return f.length ? f.map((v) => /* @__PURE__ */ n(
|
|
1491
1611
|
"button",
|
|
1492
1612
|
{
|
|
1493
1613
|
type: "button",
|
|
1494
|
-
onClick: () =>
|
|
1495
|
-
style: { display: "block", width: "100%", textAlign: "left", border: 0, borderBottom: `1px solid ${
|
|
1496
|
-
onMouseEnter: (
|
|
1497
|
-
|
|
1614
|
+
onClick: () => Fe(v.content),
|
|
1615
|
+
style: { display: "block", width: "100%", textAlign: "left", border: 0, borderBottom: `1px solid ${a.line}`, background: "transparent", padding: "9px 12px", cursor: "pointer", fontFamily: "inherit" },
|
|
1616
|
+
onMouseEnter: (O) => {
|
|
1617
|
+
O.currentTarget.style.background = "#f7f9fc";
|
|
1498
1618
|
},
|
|
1499
|
-
onMouseLeave: (
|
|
1500
|
-
|
|
1619
|
+
onMouseLeave: (O) => {
|
|
1620
|
+
O.currentTarget.style.background = "transparent";
|
|
1501
1621
|
},
|
|
1502
1622
|
children: [
|
|
1503
1623
|
/* @__PURE__ */ n("div", { style: { display: "flex", alignItems: "center", gap: 6, marginBottom: 2 }, children: [
|
|
1504
|
-
/* @__PURE__ */ e("span", { style: { fontSize: 12, fontWeight: 600, color:
|
|
1505
|
-
|
|
1624
|
+
/* @__PURE__ */ e("span", { style: { fontSize: 12, fontWeight: 600, color: a.ink }, children: v.title }),
|
|
1625
|
+
v.shortcut && /* @__PURE__ */ e("span", { style: { fontSize: 10, color: c, background: `${c}18`, borderRadius: 4, padding: "1px 5px" }, children: v.shortcut })
|
|
1506
1626
|
] }),
|
|
1507
|
-
/* @__PURE__ */ e("div", { style: { fontSize: 11, color:
|
|
1627
|
+
/* @__PURE__ */ e("div", { style: { fontSize: 11, color: a.muted, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: v.content })
|
|
1508
1628
|
]
|
|
1509
1629
|
},
|
|
1510
|
-
|
|
1511
|
-
)) : /* @__PURE__ */ e("div", { style: { padding: "24px 16px", textAlign: "center", color:
|
|
1630
|
+
v.id
|
|
1631
|
+
)) : /* @__PURE__ */ e("div", { style: { padding: "24px 16px", textAlign: "center", color: a.muted, fontSize: 12 }, children: Ne.length === 0 ? "Chưa có template nào" : "Không tìm thấy" });
|
|
1512
1632
|
})() })
|
|
1513
1633
|
]
|
|
1514
1634
|
}
|
|
1515
1635
|
),
|
|
1516
|
-
/* @__PURE__ */ n("div", { style: { border: `1.5px solid ${
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
/* @__PURE__ */ e(
|
|
1520
|
-
/* @__PURE__ */ e("span", { style: { color:
|
|
1521
|
-
] }) :
|
|
1636
|
+
/* @__PURE__ */ n("div", { style: { border: `1.5px solid ${a.line}`, borderRadius: 12, background: a.white, overflow: "hidden" }, children: [
|
|
1637
|
+
z && /* @__PURE__ */ n("div", { style: { display: "flex", alignItems: "center", gap: 8, padding: "8px 12px", borderBottom: `1px solid ${a.line}`, fontSize: 12 }, children: [
|
|
1638
|
+
z.uploading ? /* @__PURE__ */ n(ne, { children: [
|
|
1639
|
+
/* @__PURE__ */ e(ut, {}),
|
|
1640
|
+
/* @__PURE__ */ e("span", { style: { color: a.muted }, children: "Đang tải lên…" })
|
|
1641
|
+
] }) : z.attachmentType === "image" && z.objectUrl ? /* @__PURE__ */ e("img", { src: z.objectUrl, alt: "", style: { height: 48, width: 48, objectFit: "cover", borderRadius: 6 } }) : /* @__PURE__ */ n("span", { style: { color: a.muted }, children: [
|
|
1522
1642
|
"📎 ",
|
|
1523
|
-
|
|
1643
|
+
z.file.name,
|
|
1524
1644
|
" (",
|
|
1525
|
-
Math.round(
|
|
1645
|
+
Math.round(z.file.size / 1024),
|
|
1526
1646
|
" KB)"
|
|
1527
1647
|
] }),
|
|
1528
|
-
!
|
|
1529
|
-
|
|
1530
|
-
}, style: { marginLeft: "auto", border: 0, background: "none", color:
|
|
1648
|
+
!z.uploading && /* @__PURE__ */ e("button", { type: "button", onClick: () => {
|
|
1649
|
+
z != null && z.objectUrl && URL.revokeObjectURL(z.objectUrl), ce(null);
|
|
1650
|
+
}, style: { marginLeft: "auto", border: 0, background: "none", color: a.muted, cursor: "pointer", fontSize: 16 }, "aria-label": "Xóa tệp đính kèm", children: "✕" })
|
|
1531
1651
|
] }),
|
|
1532
1652
|
/* @__PURE__ */ n("div", { style: { display: "flex", alignItems: "center", gap: 2, padding: "4px 8px", borderBottom: "1px solid #f3f4f6" }, children: [
|
|
1533
1653
|
/* @__PURE__ */ e(
|
|
1534
1654
|
"button",
|
|
1535
1655
|
{
|
|
1536
|
-
ref:
|
|
1656
|
+
ref: $e,
|
|
1537
1657
|
type: "button",
|
|
1538
1658
|
title: "Chèn emoji",
|
|
1539
|
-
onClick: () =>
|
|
1540
|
-
style: { ...
|
|
1541
|
-
children: /* @__PURE__ */ e(
|
|
1659
|
+
onClick: () => Ie((l) => !l),
|
|
1660
|
+
style: { ...xe, background: ke ? `${c}18` : "transparent", color: ke ? c : "#9ca3af" },
|
|
1661
|
+
children: /* @__PURE__ */ e(rn, { size: 13, strokeWidth: 2 })
|
|
1542
1662
|
}
|
|
1543
1663
|
),
|
|
1544
|
-
!
|
|
1545
|
-
var
|
|
1546
|
-
return (
|
|
1547
|
-
}, children: /* @__PURE__ */ e(
|
|
1548
|
-
!
|
|
1549
|
-
var
|
|
1550
|
-
return (
|
|
1551
|
-
}, children: /* @__PURE__ */ e(
|
|
1552
|
-
!
|
|
1553
|
-
/* @__PURE__ */ e("input", { ref:
|
|
1554
|
-
/* @__PURE__ */ e("input", { ref:
|
|
1664
|
+
!T && /* @__PURE__ */ e("button", { type: "button", title: "Gửi ảnh / video", "aria-label": "Gửi ảnh hoặc video", style: xe, onClick: () => {
|
|
1665
|
+
var l;
|
|
1666
|
+
return (l = A.current) == null ? void 0 : l.click();
|
|
1667
|
+
}, children: /* @__PURE__ */ e(Zt, { size: 13, strokeWidth: 2 }) }),
|
|
1668
|
+
!T && /* @__PURE__ */ e("button", { type: "button", title: "Gửi tệp đính kèm", "aria-label": "Gửi tệp đính kèm", style: xe, onClick: () => {
|
|
1669
|
+
var l;
|
|
1670
|
+
return (l = U.current) == null ? void 0 : l.click();
|
|
1671
|
+
}, children: /* @__PURE__ */ e(en, { size: 13, strokeWidth: 2 }) }),
|
|
1672
|
+
!T && /* @__PURE__ */ n(ne, { children: [
|
|
1673
|
+
/* @__PURE__ */ e("input", { ref: A, type: "file", style: { display: "none" }, onChange: te, accept: "image/*,video/mp4" }),
|
|
1674
|
+
/* @__PURE__ */ e("input", { ref: U, type: "file", style: { display: "none" }, onChange: te, accept: ".pdf,audio/mpeg,audio/ogg,application/octet-stream,application/zip,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document" })
|
|
1555
1675
|
] }),
|
|
1556
1676
|
/* @__PURE__ */ e(
|
|
1557
1677
|
"button",
|
|
1558
1678
|
{
|
|
1559
|
-
ref:
|
|
1679
|
+
ref: ze,
|
|
1560
1680
|
type: "button",
|
|
1561
1681
|
title: "Template nhanh",
|
|
1562
1682
|
onClick: () => {
|
|
1563
|
-
|
|
1683
|
+
Be((l) => !l), De("");
|
|
1564
1684
|
},
|
|
1565
|
-
style: { ...
|
|
1566
|
-
children: /* @__PURE__ */ e(
|
|
1685
|
+
style: { ...xe, background: ue ? `${c}18` : "transparent", color: ue ? c : "#9ca3af" },
|
|
1686
|
+
children: /* @__PURE__ */ e(ln, { size: 13, strokeWidth: 2 })
|
|
1567
1687
|
}
|
|
1568
1688
|
),
|
|
1569
1689
|
/* @__PURE__ */ e("span", { style: { width: 1, height: 14, background: "#e5e7eb", margin: "0 2px" } }),
|
|
@@ -1572,8 +1692,8 @@ function rn({ conversation: t, provider: i, connection: r, client: o, primary: h
|
|
|
1572
1692
|
{
|
|
1573
1693
|
type: "button",
|
|
1574
1694
|
title: "In đậm",
|
|
1575
|
-
onClick: () =>
|
|
1576
|
-
style: { ...
|
|
1695
|
+
onClick: () => Q((l) => !l),
|
|
1696
|
+
style: { ...xe, fontWeight: 700, fontSize: 12, background: de ? `${c}18` : "transparent", color: de ? c : "#9ca3af", border: de ? `1px solid ${c}33` : "1px solid transparent" },
|
|
1577
1697
|
children: "B"
|
|
1578
1698
|
}
|
|
1579
1699
|
),
|
|
@@ -1582,73 +1702,73 @@ function rn({ conversation: t, provider: i, connection: r, client: o, primary: h
|
|
|
1582
1702
|
{
|
|
1583
1703
|
type: "button",
|
|
1584
1704
|
title: "Nghiêng",
|
|
1585
|
-
onClick: () =>
|
|
1586
|
-
style: { ...
|
|
1705
|
+
onClick: () => Ye((l) => !l),
|
|
1706
|
+
style: { ...xe, fontStyle: "italic", fontSize: 12, background: he ? `${c}18` : "transparent", color: he ? c : "#9ca3af", border: he ? `1px solid ${c}33` : "1px solid transparent" },
|
|
1587
1707
|
children: "I"
|
|
1588
1708
|
}
|
|
1589
1709
|
),
|
|
1590
|
-
!!(
|
|
1591
|
-
var
|
|
1592
|
-
return (((
|
|
1710
|
+
!!(M != null && M.some((l) => {
|
|
1711
|
+
var f;
|
|
1712
|
+
return (((f = l.toolbarActions) == null ? void 0 : f.length) ?? 0) > 0;
|
|
1593
1713
|
})) && /* @__PURE__ */ e("span", { style: { width: 1, height: 14, background: "#e5e7eb", margin: "0 4px" } }),
|
|
1594
|
-
|
|
1714
|
+
M == null ? void 0 : M.flatMap((l) => l.toolbarActions ?? []).map((l, f) => /* @__PURE__ */ n(
|
|
1595
1715
|
"button",
|
|
1596
1716
|
{
|
|
1597
1717
|
type: "button",
|
|
1598
|
-
title:
|
|
1599
|
-
style:
|
|
1718
|
+
title: l.tooltip,
|
|
1719
|
+
style: l.label ? {
|
|
1600
1720
|
display: "inline-flex",
|
|
1601
1721
|
alignItems: "center",
|
|
1602
1722
|
gap: 5,
|
|
1603
1723
|
padding: "3px 9px",
|
|
1604
1724
|
borderRadius: 999,
|
|
1605
|
-
border: `1px solid ${
|
|
1606
|
-
background: `${
|
|
1607
|
-
color:
|
|
1725
|
+
border: `1px solid ${c}33`,
|
|
1726
|
+
background: `${c}0f`,
|
|
1727
|
+
color: c,
|
|
1608
1728
|
fontSize: 11.5,
|
|
1609
1729
|
fontWeight: 600,
|
|
1610
1730
|
cursor: "pointer",
|
|
1611
1731
|
lineHeight: 1.2,
|
|
1612
1732
|
whiteSpace: "nowrap"
|
|
1613
|
-
} :
|
|
1733
|
+
} : xe,
|
|
1614
1734
|
onClick: () => {
|
|
1615
|
-
const
|
|
1616
|
-
|
|
1617
|
-
`) ? `${
|
|
1618
|
-
var
|
|
1619
|
-
return (
|
|
1735
|
+
const v = (N) => {
|
|
1736
|
+
Z((P) => P && !P.endsWith(" ") && !P.endsWith(`
|
|
1737
|
+
`) ? `${P} ${N}` : `${P}${N}`), requestAnimationFrame(() => {
|
|
1738
|
+
var P;
|
|
1739
|
+
return (P = we.current) == null ? void 0 : P.focus();
|
|
1620
1740
|
});
|
|
1621
|
-
},
|
|
1741
|
+
}, O = ot(t, {
|
|
1622
1742
|
provider: i,
|
|
1623
|
-
recentMessages:
|
|
1624
|
-
linkContact:
|
|
1625
|
-
refreshContactInfo:
|
|
1626
|
-
sendMessage: async (
|
|
1627
|
-
await
|
|
1743
|
+
recentMessages: B.slice(-10),
|
|
1744
|
+
linkContact: H,
|
|
1745
|
+
refreshContactInfo: J,
|
|
1746
|
+
sendMessage: async (N, P) => {
|
|
1747
|
+
await r.sendMessage(t.id, N, P), await ye(void 0, !0);
|
|
1628
1748
|
}
|
|
1629
1749
|
});
|
|
1630
|
-
|
|
1750
|
+
l.onClick({ ...O, insertText: v });
|
|
1631
1751
|
},
|
|
1632
1752
|
children: [
|
|
1633
|
-
|
|
1634
|
-
|
|
1753
|
+
l.icon,
|
|
1754
|
+
l.label && /* @__PURE__ */ e("span", { children: l.label })
|
|
1635
1755
|
]
|
|
1636
1756
|
},
|
|
1637
|
-
|
|
1757
|
+
f
|
|
1638
1758
|
))
|
|
1639
1759
|
] }),
|
|
1640
1760
|
/* @__PURE__ */ e(
|
|
1641
|
-
|
|
1761
|
+
cn,
|
|
1642
1762
|
{
|
|
1643
|
-
ref:
|
|
1763
|
+
ref: we,
|
|
1644
1764
|
"aria-label": "Soạn tin nhắn",
|
|
1645
1765
|
rows: 2,
|
|
1646
|
-
value:
|
|
1647
|
-
onChange: (
|
|
1648
|
-
onKeyDown: (
|
|
1649
|
-
|
|
1766
|
+
value: j,
|
|
1767
|
+
onChange: (l) => Z(l.target.value),
|
|
1768
|
+
onKeyDown: (l) => {
|
|
1769
|
+
l.key === "Enter" && !l.shiftKey && (l.preventDefault(), _e(l));
|
|
1650
1770
|
},
|
|
1651
|
-
placeholder:
|
|
1771
|
+
placeholder: $.sendPlaceholder,
|
|
1652
1772
|
style: {
|
|
1653
1773
|
display: "block",
|
|
1654
1774
|
width: "100%",
|
|
@@ -1660,31 +1780,31 @@ function rn({ conversation: t, provider: i, connection: r, client: o, primary: h
|
|
|
1660
1780
|
border: 0,
|
|
1661
1781
|
outline: 0,
|
|
1662
1782
|
background: "transparent",
|
|
1663
|
-
color:
|
|
1783
|
+
color: a.ink,
|
|
1664
1784
|
padding: "8px 12px 4px",
|
|
1665
1785
|
font: "inherit",
|
|
1666
|
-
fontSize: 13,
|
|
1786
|
+
fontSize: F === "mobile" ? 16 : 13,
|
|
1667
1787
|
lineHeight: 1.45,
|
|
1668
|
-
fontStyle:
|
|
1669
|
-
fontWeight:
|
|
1788
|
+
fontStyle: he ? "italic" : "normal",
|
|
1789
|
+
fontWeight: de ? 700 : 400
|
|
1670
1790
|
}
|
|
1671
1791
|
}
|
|
1672
1792
|
),
|
|
1673
1793
|
/* @__PURE__ */ n("div", { style: { display: "flex", alignItems: "center", justifyContent: "space-between", padding: "4px 8px 6px 12px" }, children: [
|
|
1674
1794
|
/* @__PURE__ */ n("span", { style: {
|
|
1675
1795
|
fontSize: 11,
|
|
1676
|
-
color:
|
|
1677
|
-
fontWeight:
|
|
1796
|
+
color: j.length > 1e3 ? "#ef4444" : j.length > 900 ? "#f59e0b" : "#9ca3af",
|
|
1797
|
+
fontWeight: j.length > 1e3 ? 600 : 400
|
|
1678
1798
|
}, children: [
|
|
1679
|
-
|
|
1799
|
+
j.length,
|
|
1680
1800
|
"/1000"
|
|
1681
1801
|
] }),
|
|
1682
1802
|
/* @__PURE__ */ n("div", { style: { display: "flex", alignItems: "center", gap: 6 }, children: [
|
|
1683
|
-
!
|
|
1803
|
+
!E && F === "desktop" && /* @__PURE__ */ e("span", { style: { fontSize: 10, color: "#9ca3af" }, children: "↵ Gửi · ⇧↵ Xuống dòng" }),
|
|
1684
1804
|
/* @__PURE__ */ n(
|
|
1685
1805
|
"button",
|
|
1686
1806
|
{
|
|
1687
|
-
disabled: !
|
|
1807
|
+
disabled: !me,
|
|
1688
1808
|
"aria-label": "Gửi tin nhắn",
|
|
1689
1809
|
style: {
|
|
1690
1810
|
display: "flex",
|
|
@@ -1695,15 +1815,15 @@ function rn({ conversation: t, provider: i, connection: r, client: o, primary: h
|
|
|
1695
1815
|
borderRadius: 999,
|
|
1696
1816
|
fontSize: 12,
|
|
1697
1817
|
fontWeight: 600,
|
|
1698
|
-
background:
|
|
1699
|
-
color:
|
|
1700
|
-
cursor:
|
|
1701
|
-
boxShadow:
|
|
1818
|
+
background: me ? `linear-gradient(135deg,${c},#0ea5e9)` : "#e5e7eb",
|
|
1819
|
+
color: me ? "#fff" : "#9ca3af",
|
|
1820
|
+
cursor: me ? "pointer" : "not-allowed",
|
|
1821
|
+
boxShadow: me ? "0 2px 8px rgba(37,99,235,0.25)" : "none",
|
|
1702
1822
|
transition: "all 150ms ease"
|
|
1703
1823
|
},
|
|
1704
1824
|
children: [
|
|
1705
|
-
|
|
1706
|
-
|
|
1825
|
+
fe ? /* @__PURE__ */ e(Ot, { size: 12, style: { animation: "channelhub-spin .7s linear infinite" } }) : /* @__PURE__ */ e(nn, { size: 12, strokeWidth: 2 }),
|
|
1826
|
+
$.send
|
|
1707
1827
|
]
|
|
1708
1828
|
}
|
|
1709
1829
|
)
|
|
@@ -1711,16 +1831,16 @@ function rn({ conversation: t, provider: i, connection: r, client: o, primary: h
|
|
|
1711
1831
|
] })
|
|
1712
1832
|
] })
|
|
1713
1833
|
] }),
|
|
1714
|
-
(
|
|
1834
|
+
(G || C) && /* @__PURE__ */ e("div", { role: "alert", style: x.error, children: G || C })
|
|
1715
1835
|
] });
|
|
1716
1836
|
}
|
|
1717
|
-
function
|
|
1718
|
-
var
|
|
1719
|
-
const
|
|
1720
|
-
|
|
1837
|
+
function mn({ message: t, primary: i }) {
|
|
1838
|
+
var F, re, V, B, b;
|
|
1839
|
+
const o = st(yt), r = st(Dt), c = (S) => S.startsWith("/v1/media/proxy") ? `${o}${S}&tok=${encodeURIComponent(r)}` : S, C = t.direction === "outbound", y = ((F = t.attachments) == null ? void 0 : F.filter((S) => S.type === "image")) ?? [], L = ((re = t.attachments) == null ? void 0 : re.filter((S) => S.type === "sticker")) ?? [], w = ((V = t.attachments) == null ? void 0 : V.filter((S) => S.type === "video")) ?? [], g = ((B = t.attachments) == null ? void 0 : B.filter((S) => S.type === "audio")) ?? [], $ = ((b = t.attachments) == null ? void 0 : b.filter((S) => S.type === "file")) ?? [], [T, E] = u(null), M = C ? "flex-end" : "flex-start", I = C ? t.senderAgent ?? null : null, q = /* @__PURE__ */ n("div", { style: { display: "flex", alignItems: "center", justifyContent: C ? "flex-end" : "flex-start", gap: 5, marginTop: 4, fontSize: 10, opacity: 0.78, letterSpacing: 0.2, userSelect: "none" }, children: [
|
|
1840
|
+
I && /* @__PURE__ */ n(
|
|
1721
1841
|
"span",
|
|
1722
1842
|
{
|
|
1723
|
-
title:
|
|
1843
|
+
title: I.title ? `${I.name} (${I.title})` : I.name,
|
|
1724
1844
|
style: { display: "inline-flex", alignItems: "center", gap: 3.5, fontWeight: 600 },
|
|
1725
1845
|
children: [
|
|
1726
1846
|
/* @__PURE__ */ e(
|
|
@@ -1739,189 +1859,192 @@ function on({ message: t, primary: i }) {
|
|
|
1739
1859
|
overflow: "hidden",
|
|
1740
1860
|
flexShrink: 0
|
|
1741
1861
|
},
|
|
1742
|
-
children:
|
|
1862
|
+
children: I.avatarUrl ? /* @__PURE__ */ e("img", { src: I.avatarUrl, alt: "", style: { width: "100%", height: "100%", objectFit: "cover" } }) : je(I.name)
|
|
1743
1863
|
}
|
|
1744
1864
|
),
|
|
1745
|
-
/* @__PURE__ */ e("span", { children:
|
|
1865
|
+
/* @__PURE__ */ e("span", { children: I.name }),
|
|
1746
1866
|
/* @__PURE__ */ e("span", { style: { opacity: 0.6 }, children: "•" })
|
|
1747
1867
|
]
|
|
1748
1868
|
}
|
|
1749
1869
|
),
|
|
1750
1870
|
/* @__PURE__ */ n("time", { children: [
|
|
1751
|
-
|
|
1752
|
-
|
|
1871
|
+
ft(t.occurredAt, !0),
|
|
1872
|
+
C && /* @__PURE__ */ n(ne, { children: [
|
|
1753
1873
|
" ",
|
|
1754
|
-
/* @__PURE__ */ e(
|
|
1874
|
+
/* @__PURE__ */ e(Wt, { status: t.status })
|
|
1755
1875
|
] })
|
|
1756
1876
|
] })
|
|
1757
|
-
] }),
|
|
1758
|
-
|
|
1759
|
-
|
|
1877
|
+
] }), R = /* @__PURE__ */ e("div", { style: { position: "absolute", bottom: 6, right: 8 }, children: /* @__PURE__ */ n("time", { style: { fontSize: 10, color: "#fff", textShadow: "0 1px 3px rgba(0,0,0,.5)", letterSpacing: 0.2, userSelect: "none" }, children: [
|
|
1878
|
+
ft(t.occurredAt, !0),
|
|
1879
|
+
C && /* @__PURE__ */ n(ne, { children: [
|
|
1760
1880
|
" ",
|
|
1761
|
-
/* @__PURE__ */ e(
|
|
1881
|
+
/* @__PURE__ */ e(Wt, { status: t.status })
|
|
1762
1882
|
] })
|
|
1763
|
-
] }) }),
|
|
1764
|
-
return /* @__PURE__ */ n("div", { style: { ...
|
|
1765
|
-
|
|
1766
|
-
/* @__PURE__ */ e("img", { src:
|
|
1767
|
-
|
|
1768
|
-
] }, `s${
|
|
1769
|
-
|
|
1770
|
-
/* @__PURE__ */ e("img", { src:
|
|
1771
|
-
|
|
1772
|
-
] },
|
|
1773
|
-
w.map((
|
|
1774
|
-
/* @__PURE__ */ e("video", { src:
|
|
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(
|
|
1776
|
-
|
|
1777
|
-
] },
|
|
1778
|
-
(
|
|
1779
|
-
|
|
1780
|
-
|
|
1883
|
+
] }) }), H = C ? { ...x.bubbleOut, background: i, color: "#fff", border: "1px solid transparent" } : x.bubbleIn, J = !t.text && g.length === 0 && $.length === 0;
|
|
1884
|
+
return /* @__PURE__ */ n("div", { style: { ...x.messageLine, justifyContent: M, flexDirection: "column", alignItems: M }, children: [
|
|
1885
|
+
L.map((S, D) => /* @__PURE__ */ n("div", { style: { position: "relative", marginBottom: 2 }, children: [
|
|
1886
|
+
/* @__PURE__ */ e("img", { src: c(S.url), alt: "sticker", style: { display: "block", maxWidth: 128, maxHeight: 128, objectFit: "contain" } }),
|
|
1887
|
+
J && y.length === 0 && w.length === 0 && D === L.length - 1 && R
|
|
1888
|
+
] }, `s${D}`)),
|
|
1889
|
+
y.map((S, D) => /* @__PURE__ */ n("div", { style: { position: "relative", marginBottom: 2, cursor: "zoom-in" }, onClick: () => E({ url: c(S.url), kind: "image" }), children: [
|
|
1890
|
+
/* @__PURE__ */ e("img", { src: c(S.url), alt: "", style: { display: "block", maxWidth: 260, maxHeight: 260, borderRadius: 12, objectFit: "cover" } }),
|
|
1891
|
+
J && D === y.length - 1 && w.length === 0 && R
|
|
1892
|
+
] }, D)),
|
|
1893
|
+
w.map((S, D) => /* @__PURE__ */ n("div", { style: { position: "relative", marginBottom: 2, cursor: "pointer" }, onClick: () => E({ url: c(S.url), kind: "video" }), children: [
|
|
1894
|
+
/* @__PURE__ */ e("video", { src: c(S.url), style: { display: "block", maxWidth: 260, maxHeight: 200, borderRadius: 12, objectFit: "cover" } }),
|
|
1895
|
+
/* @__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(tn, { size: 16, fill: "#172033", color: "#172033", style: { marginLeft: 2 } }) }) }),
|
|
1896
|
+
J && D === w.length - 1 && R
|
|
1897
|
+
] }, D)),
|
|
1898
|
+
(g.length > 0 || $.length > 0 || t.text || !y.length && !w.length && !L.length && !t.text) && /* @__PURE__ */ n("div", { style: H, children: [
|
|
1899
|
+
g.map((S, D) => /* @__PURE__ */ e("audio", { src: c(S.url), controls: !0, style: { display: "block", width: "100%", marginBottom: 4 } }, D)),
|
|
1900
|
+
$.map((S, D) => /* @__PURE__ */ n("a", { href: c(S.url), target: "_blank", rel: "noreferrer", style: { display: "block", fontSize: 12, color: C ? "#fff" : "#2563eb", textDecoration: "underline", marginBottom: 4 }, children: [
|
|
1781
1901
|
"📎 ",
|
|
1782
|
-
|
|
1783
|
-
] },
|
|
1902
|
+
gn(S.mimeType)
|
|
1903
|
+
] }, D)),
|
|
1784
1904
|
t.text && /* @__PURE__ */ e("p", { style: { margin: 0, whiteSpace: "pre-wrap", wordBreak: "break-word" }, children: t.text }),
|
|
1785
|
-
!
|
|
1786
|
-
|
|
1905
|
+
!g.length && !$.length && !t.text && /* @__PURE__ */ e("p", { style: { margin: 0, opacity: 0.5 }, children: "[attachment]" }),
|
|
1906
|
+
q
|
|
1787
1907
|
] }),
|
|
1788
|
-
|
|
1789
|
-
/* @__PURE__ */ n("div", { onClick: () =>
|
|
1790
|
-
|
|
1791
|
-
/* @__PURE__ */ e("button", { onClick: () =>
|
|
1908
|
+
T && At(
|
|
1909
|
+
/* @__PURE__ */ n("div", { onClick: () => E(null), style: { position: "fixed", inset: 0, zIndex: 1e4, background: "rgba(0,0,0,.88)", display: "flex", alignItems: "center", justifyContent: "center", cursor: "zoom-out" }, children: [
|
|
1910
|
+
T.kind === "image" ? /* @__PURE__ */ e("img", { src: T.url, alt: "", style: { maxWidth: "90vw", maxHeight: "90vh", borderRadius: 8, objectFit: "contain", boxShadow: "0 8px 40px rgba(0,0,0,.5)" }, onClick: (S) => S.stopPropagation() }) : /* @__PURE__ */ e("video", { src: T.url, controls: !0, autoPlay: !0, style: { maxWidth: "90vw", maxHeight: "90vh", borderRadius: 8, boxShadow: "0 8px 40px rgba(0,0,0,.5)" }, onClick: (S) => S.stopPropagation() }),
|
|
1911
|
+
/* @__PURE__ */ e("button", { onClick: () => E(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(Ve, { size: 18 }) })
|
|
1792
1912
|
] }),
|
|
1793
1913
|
document.body
|
|
1794
1914
|
)
|
|
1795
1915
|
] });
|
|
1796
1916
|
}
|
|
1797
|
-
function
|
|
1917
|
+
function Tt({
|
|
1798
1918
|
conversation: t,
|
|
1799
1919
|
connection: i,
|
|
1800
|
-
primary:
|
|
1801
|
-
onClose:
|
|
1802
|
-
client:
|
|
1803
|
-
onStartResize:
|
|
1804
|
-
extensions:
|
|
1805
|
-
extRefreshKey:
|
|
1920
|
+
primary: o,
|
|
1921
|
+
onClose: r,
|
|
1922
|
+
client: c,
|
|
1923
|
+
onStartResize: C,
|
|
1924
|
+
extensions: y,
|
|
1925
|
+
extRefreshKey: L,
|
|
1806
1926
|
onLinkContact: w,
|
|
1807
|
-
onRefreshContactInfo:
|
|
1927
|
+
onRefreshContactInfo: g,
|
|
1928
|
+
layoutMode: $ = "desktop"
|
|
1808
1929
|
}) {
|
|
1809
|
-
const
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1930
|
+
const T = t.contactName ?? t.subject ?? t.providerConversationKey, E = i == null ? void 0 : i.provider, M = !!(y != null && y.some((k) => k.contactInfoRows)), [I, q] = u({ channel: !0, stats: !1, extra: !0 }), R = (k) => q((ie) => ({ ...ie, [k]: !ie[k] })), [H, J] = u(""), [F, re] = u(""), [V, B] = u(!1), [b, S] = u(!1), [D, j] = u(""), [Z, pe] = u([]), [ve, fe] = u(!1);
|
|
1931
|
+
K(() => {
|
|
1932
|
+
J(""), re(""), S(!1), j(""), c.getNote(t.id).then((k) => {
|
|
1933
|
+
k && (J(k.content), re(k.content));
|
|
1813
1934
|
}).catch(() => {
|
|
1814
1935
|
});
|
|
1815
|
-
}, [t.id,
|
|
1816
|
-
if (!
|
|
1817
|
-
let
|
|
1818
|
-
const
|
|
1819
|
-
provider:
|
|
1936
|
+
}, [t.id, c]), K(() => {
|
|
1937
|
+
if (!M || !y) return;
|
|
1938
|
+
let k = !1;
|
|
1939
|
+
const ie = ot(t, {
|
|
1940
|
+
provider: E,
|
|
1820
1941
|
linkContact: w,
|
|
1821
|
-
refreshContactInfo:
|
|
1822
|
-
sendMessage: async (
|
|
1823
|
-
await
|
|
1942
|
+
refreshContactInfo: g,
|
|
1943
|
+
sendMessage: async (h, A) => {
|
|
1944
|
+
await c.sendMessage(t.id, h, A);
|
|
1824
1945
|
}
|
|
1825
1946
|
});
|
|
1826
|
-
return
|
|
1827
|
-
|
|
1828
|
-
).then((
|
|
1829
|
-
if (
|
|
1830
|
-
const
|
|
1831
|
-
|
|
1947
|
+
return fe(!0), Promise.allSettled(
|
|
1948
|
+
y.filter((h) => h.contactInfoRows).map((h) => h.contactInfoRows(ie))
|
|
1949
|
+
).then((h) => {
|
|
1950
|
+
if (k) return;
|
|
1951
|
+
const A = h.filter((U) => U.status === "fulfilled").flatMap((U) => U.value);
|
|
1952
|
+
pe(A), fe(!1);
|
|
1832
1953
|
}), () => {
|
|
1833
|
-
|
|
1954
|
+
k = !0;
|
|
1834
1955
|
};
|
|
1835
|
-
}, [t.id, t.contactExternalId,
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1956
|
+
}, [t.id, t.contactExternalId, y, L, M, E, w, g, c]);
|
|
1957
|
+
const se = H.trim() !== F.trim() && H.trim().length > 0;
|
|
1958
|
+
async function G() {
|
|
1959
|
+
if (!(!se || V)) {
|
|
1960
|
+
B(!0), j("");
|
|
1839
1961
|
try {
|
|
1840
|
-
|
|
1962
|
+
const k = H.trim();
|
|
1963
|
+
await c.upsertNote(t.id, k), re(k), S(!0), setTimeout(() => S(!1), 2e3);
|
|
1841
1964
|
} catch {
|
|
1842
|
-
|
|
1965
|
+
j("Lưu thất bại");
|
|
1843
1966
|
} finally {
|
|
1844
|
-
|
|
1967
|
+
B(!1);
|
|
1845
1968
|
}
|
|
1846
1969
|
}
|
|
1847
1970
|
}
|
|
1848
|
-
return /* @__PURE__ */ n("aside", { style: { ...
|
|
1849
|
-
/* @__PURE__ */ e(
|
|
1971
|
+
return /* @__PURE__ */ n("aside", { style: { ...x.infoPanel, position: "relative", ...$ !== "desktop" ? { flex: 1, borderLeft: 0 } : {} }, children: [
|
|
1972
|
+
C && /* @__PURE__ */ e(
|
|
1850
1973
|
"div",
|
|
1851
1974
|
{
|
|
1852
|
-
onMouseDown:
|
|
1975
|
+
onMouseDown: C,
|
|
1853
1976
|
style: { position: "absolute", left: 0, top: 0, bottom: 0, width: 4, cursor: "col-resize", zIndex: 1 },
|
|
1854
|
-
onMouseEnter: (
|
|
1855
|
-
|
|
1977
|
+
onMouseEnter: (k) => {
|
|
1978
|
+
k.currentTarget.style.background = "rgba(0,0,0,0.07)";
|
|
1856
1979
|
},
|
|
1857
|
-
onMouseLeave: (
|
|
1858
|
-
|
|
1980
|
+
onMouseLeave: (k) => {
|
|
1981
|
+
k.currentTarget.style.background = "";
|
|
1859
1982
|
}
|
|
1860
1983
|
}
|
|
1861
1984
|
),
|
|
1862
|
-
/* @__PURE__ */ n("div", { style:
|
|
1863
|
-
/* @__PURE__ */ e("span", { style: { fontWeight: 600, fontSize: 13, color:
|
|
1864
|
-
/* @__PURE__ */ e("button", { style:
|
|
1985
|
+
/* @__PURE__ */ n("div", { style: x.infoPanelHeader, children: [
|
|
1986
|
+
/* @__PURE__ */ e("span", { style: { fontWeight: 600, fontSize: 13, color: a.ink }, children: "Thông tin liên hệ" }),
|
|
1987
|
+
/* @__PURE__ */ e("button", { style: x.iconButton, onClick: r, "aria-label": "Đóng", children: /* @__PURE__ */ e(Ve, { size: 16, strokeWidth: 2 }) })
|
|
1865
1988
|
] }),
|
|
1866
1989
|
/* @__PURE__ */ n("div", { style: { overflowY: "auto", flex: 1 }, children: [
|
|
1867
|
-
/* @__PURE__ */ n("div", { style:
|
|
1868
|
-
/* @__PURE__ */ n("span", { style: { ...
|
|
1990
|
+
/* @__PURE__ */ n("div", { style: x.infoPanelIdentity, children: [
|
|
1991
|
+
/* @__PURE__ */ n("span", { style: { ...x.avatarWrap, width: 48, height: 48 }, children: [
|
|
1869
1992
|
/* @__PURE__ */ e(
|
|
1870
|
-
|
|
1993
|
+
bt,
|
|
1871
1994
|
{
|
|
1872
1995
|
src: t.contactPictureUrl,
|
|
1873
|
-
fallback:
|
|
1874
|
-
style: { ...
|
|
1996
|
+
fallback: je(T),
|
|
1997
|
+
style: { ...x.avatar, width: 48, height: 48, fontSize: 16 }
|
|
1875
1998
|
}
|
|
1876
1999
|
),
|
|
1877
|
-
/* @__PURE__ */ e("span", { style: { ...
|
|
2000
|
+
/* @__PURE__ */ e("span", { style: { ...x.providerBadge, width: 20, height: 20 }, children: /* @__PURE__ */ e(Ge, { provider: E }) })
|
|
1878
2001
|
] }),
|
|
1879
|
-
/* @__PURE__ */ e("strong", { style: { marginTop: 10, fontSize: 15, color:
|
|
1880
|
-
/* @__PURE__ */ e("span", { style: { fontSize: 11, color:
|
|
2002
|
+
/* @__PURE__ */ e("strong", { style: { marginTop: 10, fontSize: 15, color: a.ink, textAlign: "center" }, children: T }),
|
|
2003
|
+
/* @__PURE__ */ e("span", { style: { fontSize: 11, color: a.muted, fontFamily: "monospace", textAlign: "center" }, children: t.providerConversationKey })
|
|
1881
2004
|
] }),
|
|
1882
|
-
/* @__PURE__ */ n(
|
|
1883
|
-
/* @__PURE__ */ e(
|
|
1884
|
-
/* @__PURE__ */ e(
|
|
1885
|
-
/* @__PURE__ */ e("span", { children:
|
|
2005
|
+
/* @__PURE__ */ n(at, { label: "KÊNH", sectionKey: "channel", expanded: I.channel, onToggle: () => R("channel"), children: [
|
|
2006
|
+
/* @__PURE__ */ e(be, { label: "Nền tảng", children: /* @__PURE__ */ n("span", { style: { display: "flex", alignItems: "center", gap: 5 }, children: [
|
|
2007
|
+
/* @__PURE__ */ e(Ge, { provider: E }),
|
|
2008
|
+
/* @__PURE__ */ e("span", { children: Nt(E) })
|
|
1886
2009
|
] }) }),
|
|
1887
|
-
/* @__PURE__ */ n(
|
|
2010
|
+
/* @__PURE__ */ n(be, { label: "ID hội thoại", children: [
|
|
1888
2011
|
/* @__PURE__ */ n("span", { style: { fontFamily: "monospace", fontSize: 11 }, children: [
|
|
1889
2012
|
t.id.slice(0, 8),
|
|
1890
2013
|
"…"
|
|
1891
2014
|
] }),
|
|
1892
|
-
/* @__PURE__ */ e(
|
|
2015
|
+
/* @__PURE__ */ e(xn, { value: t.id })
|
|
1893
2016
|
] })
|
|
1894
2017
|
] }),
|
|
1895
|
-
/* @__PURE__ */ n(
|
|
1896
|
-
/* @__PURE__ */ e(
|
|
1897
|
-
(t.unreadCount ?? 0) > 0 && /* @__PURE__ */ e(
|
|
2018
|
+
/* @__PURE__ */ n(at, { label: "THỐNG KÊ", sectionKey: "stats", expanded: I.stats, onToggle: () => R("stats"), children: [
|
|
2019
|
+
/* @__PURE__ */ e(be, { label: "Tin nhắn", value: String(t.messageCount ?? 0) }),
|
|
2020
|
+
(t.unreadCount ?? 0) > 0 && /* @__PURE__ */ e(be, { label: "Chưa đọc", value: String(t.unreadCount), valueColor: "#ef4444" }),
|
|
1898
2021
|
/* @__PURE__ */ e(
|
|
1899
|
-
|
|
2022
|
+
be,
|
|
1900
2023
|
{
|
|
1901
2024
|
label: "Gần nhất",
|
|
1902
2025
|
value: t.lastMessageAt ? new Date(t.lastMessageAt).toLocaleDateString("vi-VN", { day: "2-digit", month: "2-digit", year: "numeric" }) : "—"
|
|
1903
2026
|
}
|
|
1904
2027
|
),
|
|
1905
|
-
/* @__PURE__ */ e(
|
|
2028
|
+
/* @__PURE__ */ e(be, { label: "Lần đầu", value: "—" })
|
|
1906
2029
|
] }),
|
|
1907
|
-
/* @__PURE__ */ n(
|
|
1908
|
-
!
|
|
1909
|
-
/* @__PURE__ */ e(
|
|
1910
|
-
/* @__PURE__ */ e(
|
|
1911
|
-
/* @__PURE__ */ e(
|
|
2030
|
+
/* @__PURE__ */ n(at, { label: "THÔNG TIN BỔ SUNG", sectionKey: "extra", expanded: I.extra, onToggle: () => R("extra"), children: [
|
|
2031
|
+
!M && /* @__PURE__ */ n(ne, { children: [
|
|
2032
|
+
/* @__PURE__ */ e(be, { label: "Điện thoại", value: "— chưa có", valueMuted: !0 }),
|
|
2033
|
+
/* @__PURE__ */ e(be, { label: "Email", value: "— chưa có", valueMuted: !0 }),
|
|
2034
|
+
/* @__PURE__ */ e(be, { label: "Nhãn", value: "— chưa có", valueMuted: !0 })
|
|
1912
2035
|
] }),
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
2036
|
+
ve && Z.length === 0 && /* @__PURE__ */ e("div", { style: { fontSize: 12, color: a.muted, padding: "6px 0" }, children: "Đang tải hồ sơ CRM…" }),
|
|
2037
|
+
Z.map((k) => /* @__PURE__ */ e(be, { label: k.label, children: /* @__PURE__ */ n("span", { style: { display: "inline-flex", alignItems: "center", gap: 6, flexWrap: "wrap", justifyContent: "flex-end" }, children: [
|
|
2038
|
+
k.onClick ? /* @__PURE__ */ e(
|
|
1916
2039
|
"button",
|
|
1917
2040
|
{
|
|
1918
2041
|
type: "button",
|
|
1919
|
-
onClick:
|
|
1920
|
-
style: { border: 0, background: "none", padding: 0, color:
|
|
1921
|
-
children:
|
|
2042
|
+
onClick: k.onClick,
|
|
2043
|
+
style: { border: 0, background: "none", padding: 0, color: o, fontSize: 12, fontWeight: 600, cursor: "pointer", textDecoration: "underline" },
|
|
2044
|
+
children: k.value
|
|
1922
2045
|
}
|
|
1923
|
-
) :
|
|
1924
|
-
|
|
2046
|
+
) : k.href ? /* @__PURE__ */ e("a", { href: k.href, target: "_blank", rel: "noopener noreferrer", style: { color: o, fontSize: 12, fontWeight: 600 }, children: k.value }) : /* @__PURE__ */ e("span", { style: { fontSize: 12, fontWeight: 500, color: a.ink }, children: k.value }),
|
|
2047
|
+
k.badge && /* @__PURE__ */ e(
|
|
1925
2048
|
"span",
|
|
1926
2049
|
{
|
|
1927
2050
|
style: {
|
|
@@ -1929,78 +2052,87 @@ function an({
|
|
|
1929
2052
|
fontWeight: 700,
|
|
1930
2053
|
padding: "1px 7px",
|
|
1931
2054
|
borderRadius: 999,
|
|
1932
|
-
color:
|
|
1933
|
-
background:
|
|
2055
|
+
color: k.badge.color ?? o,
|
|
2056
|
+
background: k.badge.bg ?? `${o}14`
|
|
1934
2057
|
},
|
|
1935
|
-
children:
|
|
2058
|
+
children: k.badge.text
|
|
1936
2059
|
}
|
|
1937
2060
|
)
|
|
1938
|
-
] }) },
|
|
2061
|
+
] }) }, k.label))
|
|
1939
2062
|
] }),
|
|
1940
2063
|
/* @__PURE__ */ n("div", { style: { padding: "12px 16px", display: "flex", flexDirection: "column", gap: 8 }, children: [
|
|
1941
|
-
!(
|
|
1942
|
-
|
|
1943
|
-
const
|
|
2064
|
+
!(y != null && y.length) && /* @__PURE__ */ e("button", { style: { ...x.ghostButton, color: o, borderColor: `${o}33` }, children: "Xem lịch sử" }),
|
|
2065
|
+
y == null ? void 0 : y.flatMap((k) => k.sidebarActions ?? []).map((k, ie) => {
|
|
2066
|
+
const h = k.variant === "primary";
|
|
1944
2067
|
return /* @__PURE__ */ n(
|
|
1945
2068
|
"button",
|
|
1946
2069
|
{
|
|
1947
2070
|
style: {
|
|
1948
|
-
...
|
|
1949
|
-
background:
|
|
1950
|
-
color:
|
|
1951
|
-
borderColor:
|
|
1952
|
-
fontWeight:
|
|
2071
|
+
...x.ghostButton,
|
|
2072
|
+
background: h ? o : "#fff",
|
|
2073
|
+
color: h ? "#fff" : a.ink,
|
|
2074
|
+
borderColor: h ? o : a.line,
|
|
2075
|
+
fontWeight: h ? 700 : 600,
|
|
1953
2076
|
display: "flex",
|
|
1954
2077
|
alignItems: "center",
|
|
1955
2078
|
justifyContent: "center",
|
|
1956
2079
|
gap: 6
|
|
1957
2080
|
},
|
|
1958
2081
|
onClick: () => {
|
|
1959
|
-
const
|
|
1960
|
-
provider:
|
|
2082
|
+
const A = ot(t, {
|
|
2083
|
+
provider: E,
|
|
1961
2084
|
linkContact: w,
|
|
1962
|
-
refreshContactInfo:
|
|
1963
|
-
sendMessage: async (
|
|
1964
|
-
await
|
|
2085
|
+
refreshContactInfo: g,
|
|
2086
|
+
sendMessage: async (U, z) => {
|
|
2087
|
+
await c.sendMessage(t.id, U, z);
|
|
1965
2088
|
}
|
|
1966
2089
|
});
|
|
1967
|
-
|
|
2090
|
+
k.onClick(A);
|
|
1968
2091
|
},
|
|
1969
2092
|
children: [
|
|
1970
|
-
|
|
1971
|
-
|
|
2093
|
+
k.icon,
|
|
2094
|
+
k.label
|
|
1972
2095
|
]
|
|
1973
2096
|
},
|
|
1974
|
-
|
|
2097
|
+
ie
|
|
1975
2098
|
);
|
|
1976
2099
|
}),
|
|
1977
|
-
/* @__PURE__ */ n("div", { style: { border: `1px solid ${
|
|
1978
|
-
/* @__PURE__ */ e("div", { style: { display: "flex", alignItems: "center", gap: 6, padding: "7px 10px", borderBottom:
|
|
2100
|
+
/* @__PURE__ */ n("div", { style: { border: `1px solid ${a.line}`, borderRadius: 10, background: a.white, overflow: "hidden" }, children: [
|
|
2101
|
+
/* @__PURE__ */ e("div", { style: { display: "flex", alignItems: "center", gap: 6, padding: "7px 10px", borderBottom: `1px solid ${a.line}`, background: a.surface, fontSize: 11, fontWeight: 600, color: a.muted }, children: "Ghi chú nội bộ" }),
|
|
1979
2102
|
/* @__PURE__ */ e(
|
|
1980
2103
|
"textarea",
|
|
1981
2104
|
{
|
|
1982
|
-
value:
|
|
1983
|
-
onChange: (
|
|
2105
|
+
value: H,
|
|
2106
|
+
onChange: (k) => J(k.target.value),
|
|
1984
2107
|
placeholder: "Nhập ghi chú...",
|
|
1985
2108
|
rows: 3,
|
|
1986
|
-
style: { display: "block", width: "100%", boxSizing: "border-box", border: 0, outline: 0, background:
|
|
2109
|
+
style: { display: "block", width: "100%", boxSizing: "border-box", border: 0, outline: 0, background: a.white, resize: "none", padding: "8px 10px", font: "inherit", fontSize: $ === "mobile" ? 16 : 12, color: a.ink, lineHeight: 1.5 }
|
|
1987
2110
|
}
|
|
1988
2111
|
),
|
|
1989
2112
|
/* @__PURE__ */ n("div", { style: { display: "flex", alignItems: "center", justifyContent: "space-between", padding: "4px 10px 6px" }, children: [
|
|
1990
|
-
|
|
1991
|
-
/* @__PURE__ */ e(
|
|
2113
|
+
b ? /* @__PURE__ */ n("span", { style: { display: "flex", alignItems: "center", gap: 4, fontSize: 11, color: "#16a34a" }, children: [
|
|
2114
|
+
/* @__PURE__ */ e(gt, { size: 11, strokeWidth: 2.5 }),
|
|
1992
2115
|
" Đã lưu"
|
|
1993
|
-
] }) :
|
|
2116
|
+
] }) : D ? /* @__PURE__ */ e("span", { style: { fontSize: 11, color: "#ef4444" }, children: D }) : /* @__PURE__ */ e("span", {}),
|
|
1994
2117
|
/* @__PURE__ */ e(
|
|
1995
2118
|
"button",
|
|
1996
2119
|
{
|
|
1997
2120
|
type: "button",
|
|
1998
2121
|
onClick: () => {
|
|
1999
|
-
|
|
2122
|
+
G();
|
|
2123
|
+
},
|
|
2124
|
+
disabled: !se || V,
|
|
2125
|
+
style: {
|
|
2126
|
+
padding: "4px 12px",
|
|
2127
|
+
border: 0,
|
|
2128
|
+
borderRadius: 7,
|
|
2129
|
+
fontSize: 12,
|
|
2130
|
+
fontWeight: 600,
|
|
2131
|
+
background: se && !V ? o : "#f1f5f9",
|
|
2132
|
+
color: se && !V ? "#fff" : "#94a3b8",
|
|
2133
|
+
cursor: se && !V ? "pointer" : "not-allowed"
|
|
2000
2134
|
},
|
|
2001
|
-
|
|
2002
|
-
style: { padding: "4px 12px", border: 0, borderRadius: 7, fontSize: 12, fontWeight: 600, background: I.trim() && !P ? "linear-gradient(135deg,#f59e0b,#fbbf24)" : "#e5e7eb", color: I.trim() && !P ? "#fff" : "#9ca3af", cursor: I.trim() && !P ? "pointer" : "not-allowed" },
|
|
2003
|
-
children: P ? "Đang lưu…" : "Lưu ghi chú"
|
|
2135
|
+
children: V ? "Đang lưu…" : "Lưu ghi chú"
|
|
2004
2136
|
}
|
|
2005
2137
|
)
|
|
2006
2138
|
] })
|
|
@@ -2009,39 +2141,39 @@ function an({
|
|
|
2009
2141
|
] })
|
|
2010
2142
|
] });
|
|
2011
2143
|
}
|
|
2012
|
-
function
|
|
2013
|
-
const
|
|
2014
|
-
return /* @__PURE__ */ n("div", { style: { borderTop: `1px solid ${
|
|
2144
|
+
function at({ label: t, children: i, sectionKey: o, expanded: r, onToggle: c }) {
|
|
2145
|
+
const C = !!c, y = r ?? !0;
|
|
2146
|
+
return /* @__PURE__ */ n("div", { style: { borderTop: `1px solid ${a.line}` }, children: [
|
|
2015
2147
|
/* @__PURE__ */ n(
|
|
2016
2148
|
"div",
|
|
2017
2149
|
{
|
|
2018
|
-
style: { display: "flex", alignItems: "center", justifyContent: "space-between", padding: "10px 16px 6px", fontSize: 10, fontWeight: 700, letterSpacing: 1, color:
|
|
2019
|
-
onClick:
|
|
2150
|
+
style: { display: "flex", alignItems: "center", justifyContent: "space-between", padding: "10px 16px 6px", fontSize: 10, fontWeight: 700, letterSpacing: 1, color: a.muted, textTransform: "uppercase", cursor: C ? "pointer" : "default" },
|
|
2151
|
+
onClick: c,
|
|
2020
2152
|
children: [
|
|
2021
2153
|
/* @__PURE__ */ e("span", { children: t }),
|
|
2022
|
-
|
|
2154
|
+
C && (y ? /* @__PURE__ */ e(ct, { size: 12, strokeWidth: 2 }) : /* @__PURE__ */ e(Yt, { size: 12, strokeWidth: 2 }))
|
|
2023
2155
|
]
|
|
2024
2156
|
}
|
|
2025
2157
|
),
|
|
2026
|
-
|
|
2158
|
+
y && i
|
|
2027
2159
|
] });
|
|
2028
2160
|
}
|
|
2029
|
-
function
|
|
2161
|
+
function be({ label: t, value: i, children: o, valueColor: r, valueMuted: c }) {
|
|
2030
2162
|
return /* @__PURE__ */ n("div", { style: { display: "flex", justifyContent: "space-between", alignItems: "flex-start", padding: "5px 16px", fontSize: 12, gap: 10 }, children: [
|
|
2031
|
-
/* @__PURE__ */ e("span", { style: { color:
|
|
2032
|
-
/* @__PURE__ */ e("span", { style: { color:
|
|
2163
|
+
/* @__PURE__ */ e("span", { style: { color: a.muted, flexShrink: 0, lineHeight: 1.4 }, children: t }),
|
|
2164
|
+
/* @__PURE__ */ e("span", { style: { color: r ?? (c ? a.muted : a.ink), textAlign: "right", minWidth: 0, display: "flex", alignItems: "center", justifyContent: "flex-end", flexWrap: "wrap", gap: 4, lineHeight: 1.4 }, children: o ?? i })
|
|
2033
2165
|
] });
|
|
2034
2166
|
}
|
|
2035
|
-
function
|
|
2036
|
-
const [i,
|
|
2167
|
+
function xn({ value: t }) {
|
|
2168
|
+
const [i, o] = u(!1);
|
|
2037
2169
|
return /* @__PURE__ */ e(
|
|
2038
2170
|
"button",
|
|
2039
2171
|
{
|
|
2040
|
-
style: { border: 0, background: "none", cursor: "pointer", color:
|
|
2172
|
+
style: { border: 0, background: "none", cursor: "pointer", color: a.muted, padding: 2, lineHeight: 1 },
|
|
2041
2173
|
title: "Sao chép",
|
|
2042
2174
|
onClick: () => {
|
|
2043
2175
|
navigator.clipboard.writeText(t).then(() => {
|
|
2044
|
-
|
|
2176
|
+
o(!0), setTimeout(() => o(!1), 1500);
|
|
2045
2177
|
});
|
|
2046
2178
|
},
|
|
2047
2179
|
"aria-label": "Sao chép ID",
|
|
@@ -2049,52 +2181,52 @@ function ln({ value: t }) {
|
|
|
2049
2181
|
}
|
|
2050
2182
|
);
|
|
2051
2183
|
}
|
|
2052
|
-
function
|
|
2053
|
-
return /* @__PURE__ */ n("div", { style:
|
|
2054
|
-
/* @__PURE__ */ e("div", { style:
|
|
2184
|
+
function vn() {
|
|
2185
|
+
return /* @__PURE__ */ n("div", { style: x.empty, children: [
|
|
2186
|
+
/* @__PURE__ */ e("div", { style: x.emptyHero, children: /* @__PURE__ */ e(_t, { size: 16, strokeWidth: 2 }) }),
|
|
2055
2187
|
/* @__PURE__ */ e("h2", { children: "Chọn một hội thoại" }),
|
|
2056
2188
|
/* @__PURE__ */ e("p", { children: "Chọn hội thoại bên trái để xem và trả lời tin nhắn." })
|
|
2057
2189
|
] });
|
|
2058
2190
|
}
|
|
2059
|
-
function
|
|
2060
|
-
return /* @__PURE__ */ n("span", { style:
|
|
2061
|
-
/* @__PURE__ */ e(
|
|
2062
|
-
|
|
2191
|
+
function Pt({ name: t, color: i, image: o, provider: r }) {
|
|
2192
|
+
return /* @__PURE__ */ n("span", { style: x.avatarWrap, children: [
|
|
2193
|
+
/* @__PURE__ */ e(kn, { name: t, color: i, image: o }),
|
|
2194
|
+
r && /* @__PURE__ */ e("span", { style: x.providerBadge, children: /* @__PURE__ */ e(Ge, { provider: r }) })
|
|
2063
2195
|
] });
|
|
2064
2196
|
}
|
|
2065
|
-
function
|
|
2066
|
-
return /* @__PURE__ */ e(
|
|
2197
|
+
function kn({ name: t, color: i, image: o }) {
|
|
2198
|
+
return /* @__PURE__ */ e(bt, { src: o, fallback: je(t), style: { ...x.avatar, background: `${i}18`, color: i } });
|
|
2067
2199
|
}
|
|
2068
|
-
function
|
|
2069
|
-
return /* @__PURE__ */ e(
|
|
2200
|
+
function ut() {
|
|
2201
|
+
return /* @__PURE__ */ e(Ot, { size: 14, style: x.spinner, "aria-hidden": "true" });
|
|
2070
2202
|
}
|
|
2071
|
-
function
|
|
2203
|
+
function je(t) {
|
|
2072
2204
|
return t.split(/\s+/).filter(Boolean).slice(-2).map((i) => i[0]).join("").toUpperCase() || "?";
|
|
2073
2205
|
}
|
|
2074
|
-
const
|
|
2075
|
-
function
|
|
2076
|
-
const i =
|
|
2206
|
+
const wn = { livechat: "web" };
|
|
2207
|
+
function Ge({ provider: t }) {
|
|
2208
|
+
const i = st(yt), o = 14;
|
|
2077
2209
|
if (!t) return null;
|
|
2078
|
-
const
|
|
2079
|
-
return /* @__PURE__ */ e("img", { src: `${i}/static/logos/${
|
|
2210
|
+
const r = wn[t] ?? t;
|
|
2211
|
+
return /* @__PURE__ */ e("img", { src: `${i}/static/logos/${r}.avif`, alt: t, width: o, height: o, style: { borderRadius: "50%", objectFit: "cover", display: "block" } });
|
|
2080
2212
|
}
|
|
2081
|
-
function
|
|
2213
|
+
function ft(t, i = !1) {
|
|
2082
2214
|
if (!t) return "";
|
|
2083
|
-
const
|
|
2084
|
-
return
|
|
2215
|
+
const o = new Date(t);
|
|
2216
|
+
return o.toDateString() === (/* @__PURE__ */ new Date()).toDateString() ? o.toLocaleTimeString("vi-VN", { hour: "2-digit", minute: "2-digit" }) : o.toLocaleDateString("vi-VN", { day: "2-digit", month: "2-digit" });
|
|
2085
2217
|
}
|
|
2086
|
-
const
|
|
2087
|
-
frame: { display: "grid", gridTemplateRows: "minmax(0, 1fr)", height: 620, maxHeight: "calc(100dvh - 220px)", minHeight: 0, overflow: "hidden", border: `1px solid ${
|
|
2088
|
-
sidebar: { display: "flex", flexDirection: "column", minWidth: 0, minHeight: 0, borderRight: `1px solid ${
|
|
2218
|
+
const x = {
|
|
2219
|
+
frame: { display: "grid", gridTemplateRows: "minmax(0, 1fr)", height: 620, maxHeight: "calc(100dvh - 220px)", minHeight: 0, overflow: "hidden", border: `1px solid ${a.line}`, background: a.white, color: a.ink, boxShadow: "0 18px 50px rgba(31,45,72,.10)" },
|
|
2220
|
+
sidebar: { display: "flex", flexDirection: "column", minWidth: 0, minHeight: 0, borderRight: `1px solid ${a.line}`, background: a.white },
|
|
2089
2221
|
brand: { display: "flex", alignItems: "center", gap: 10, padding: "20px 18px 16px" },
|
|
2090
2222
|
brandMark: { display: "grid", placeItems: "center", width: 32, height: 32, borderRadius: 10, color: "#fff", fontWeight: 800 },
|
|
2091
|
-
eyebrow: { display: "block", marginTop: 2, fontSize: 9, letterSpacing: 1.3, color:
|
|
2092
|
-
iconButton: { display: "inline-grid", placeItems: "center", width: 32, height: 32, marginLeft: "auto", border: 0, borderRadius: 8, background: "transparent", color:
|
|
2093
|
-
search: { display: "flex", alignItems: "center", gap: 8, margin: "0 14px 12px", padding: "9px 10px", border: `1px solid ${
|
|
2094
|
-
clear: { border: 0, background: "none", color:
|
|
2095
|
-
listHeader: { display: "flex", alignItems: "center", padding: "10px 18px", borderTop: `1px solid ${
|
|
2223
|
+
eyebrow: { display: "block", marginTop: 2, fontSize: 9, letterSpacing: 1.3, color: a.muted },
|
|
2224
|
+
iconButton: { display: "inline-grid", placeItems: "center", width: 32, height: 32, marginLeft: "auto", border: 0, borderRadius: 8, background: "transparent", color: a.muted, cursor: "pointer" },
|
|
2225
|
+
search: { display: "flex", alignItems: "center", gap: 8, margin: "0 14px 12px", padding: "9px 10px", border: `1px solid ${a.line}`, borderRadius: 9, color: a.muted, background: a.surface },
|
|
2226
|
+
clear: { border: 0, background: "none", color: a.muted, cursor: "pointer", fontSize: 18 },
|
|
2227
|
+
listHeader: { display: "flex", alignItems: "center", padding: "10px 18px", borderTop: `1px solid ${a.line}`, borderBottom: `1px solid ${a.line}`, color: a.muted, fontSize: 11, fontWeight: 700, letterSpacing: 0.4, textTransform: "uppercase" },
|
|
2096
2228
|
conversationList: { overflowY: "auto", flex: 1, minHeight: 0 },
|
|
2097
|
-
row: { display: "flex", width: "100%", gap: 11, padding: "16px 14px", border: 0, borderBottom: `1px solid ${
|
|
2229
|
+
row: { display: "flex", width: "100%", gap: 11, padding: "16px 14px", border: 0, borderBottom: `1px solid ${a.line}`, background: "transparent", textAlign: "left", cursor: "pointer", transition: "background 120ms ease" },
|
|
2098
2230
|
avatarWrap: { position: "relative", flex: "0 0 auto", width: 44, height: 44 },
|
|
2099
2231
|
avatar: { flex: "0 0 auto", width: 44, height: 44, display: "grid", placeItems: "center", borderRadius: "50%", objectFit: "cover", fontSize: 14, fontWeight: 800 },
|
|
2100
2232
|
providerBadge: { position: "absolute", left: -3, bottom: -3, display: "grid", placeItems: "center", width: 17, height: 17, border: "2px solid #fff", borderRadius: "50%", background: "#fff", color: "#64748b" },
|
|
@@ -2103,41 +2235,41 @@ const f = {
|
|
|
2103
2235
|
rowBottom: { display: "flex", marginTop: 4, fontSize: 12, minWidth: 0, overflow: "hidden", lineHeight: 1.4 },
|
|
2104
2236
|
unreadBadge: { display: "inline-grid", placeItems: "center", minWidth: 18, height: 18, borderRadius: 999, background: "#ef4444", color: "#fff", fontSize: 10, fontWeight: 800, padding: "0 5px" },
|
|
2105
2237
|
loadMore: { width: "100%", border: 0, background: "transparent", color: "#4c72ca", padding: 14, cursor: "pointer", fontSize: 12 },
|
|
2106
|
-
emptySmall: { display: "grid", justifyItems: "center", gap: 7, padding: "56px 24px", color:
|
|
2107
|
-
emptyIcon: { display: "grid", placeItems: "center", width: 40, height: 40, borderRadius: 12, background:
|
|
2108
|
-
main: { minWidth: 0, minHeight: 0, overflow: "hidden", background:
|
|
2238
|
+
emptySmall: { display: "grid", justifyItems: "center", gap: 7, padding: "56px 24px", color: a.muted, fontSize: 12, textAlign: "center" },
|
|
2239
|
+
emptyIcon: { display: "grid", placeItems: "center", width: 40, height: 40, borderRadius: 12, background: a.surface },
|
|
2240
|
+
main: { minWidth: 0, minHeight: 0, overflow: "hidden", background: a.surface },
|
|
2109
2241
|
chat: { display: "flex", flexDirection: "column", height: "100%", minWidth: 0, minHeight: 0 },
|
|
2110
|
-
chatHeader: { flex: "0 0 auto", display: "flex", alignItems: "center", gap: 10, padding: "0 16px 0 18px", height: 56, borderBottom: `1px solid ${
|
|
2242
|
+
chatHeader: { flex: "0 0 auto", display: "flex", alignItems: "center", gap: 10, padding: "0 16px 0 18px", height: 56, borderBottom: `1px solid ${a.line}`, background: a.white },
|
|
2111
2243
|
contact: { display: "grid", gap: 3, minWidth: 0, flex: 1 },
|
|
2112
|
-
contactName: { fontSize: 14, fontWeight: 600, color:
|
|
2113
|
-
contactMeta: { display: "flex", alignItems: "center", gap: 5, fontSize: 11, color:
|
|
2244
|
+
contactName: { fontSize: 14, fontWeight: 600, color: a.ink, whiteSpace: "nowrap", overflow: "hidden", textOverflow: "ellipsis" },
|
|
2245
|
+
contactMeta: { display: "flex", alignItems: "center", gap: 5, fontSize: 11, color: a.muted },
|
|
2114
2246
|
headerActions: { display: "flex", gap: 2, marginLeft: "auto" },
|
|
2115
2247
|
messageArea: { flex: 1, minHeight: 0, overflowY: "auto", overscrollBehavior: "contain", padding: "20px clamp(16px,5vw,56px)", background: "linear-gradient(180deg,#f9fbfe 0%,#f4f7fb 100%)" },
|
|
2116
2248
|
day: { margin: "0 auto 18px", color: "#a1acbb", fontSize: 10, letterSpacing: 1.2, fontWeight: 700, textAlign: "center" },
|
|
2117
|
-
historyButton: { display: "block", margin: "0 auto 18px", border: `1px solid ${
|
|
2118
|
-
messageHint: { display: "flex", justifyContent: "center", alignItems: "center", gap: 8, padding: 40, color:
|
|
2249
|
+
historyButton: { display: "block", margin: "0 auto 18px", border: `1px solid ${a.line}`, borderRadius: 20, padding: "6px 12px", background: a.white, color: a.muted, cursor: "pointer", fontSize: 11 },
|
|
2250
|
+
messageHint: { display: "flex", justifyContent: "center", alignItems: "center", gap: 8, padding: 40, color: a.muted, fontSize: 12 },
|
|
2119
2251
|
messageLine: { display: "flex", marginBottom: 10 },
|
|
2120
2252
|
bubbleOut: { maxWidth: "min(70%,480px)", padding: "9px 13px", borderRadius: "14px 14px 3px 14px", boxShadow: "0 2px 5px rgba(30,43,65,.03)", fontSize: 14, lineHeight: 1.55 },
|
|
2121
|
-
bubbleIn: { maxWidth: "min(70%,480px)", padding: "9px 13px", borderRadius: "14px 14px 14px 3px", border: `1px solid ${
|
|
2253
|
+
bubbleIn: { maxWidth: "min(70%,480px)", padding: "9px 13px", borderRadius: "14px 14px 14px 3px", border: `1px solid ${a.line}`, background: a.surface, boxShadow: "0 2px 5px rgba(30,43,65,.03)", fontSize: 14, lineHeight: 1.55 },
|
|
2122
2254
|
error: { padding: "8px 18px", background: "#fff2f0", color: "#b42318", fontSize: 12 },
|
|
2123
|
-
empty: { display: "grid", placeItems: "center", alignContent: "center", height: "100%", padding: 30, textAlign: "center", color:
|
|
2255
|
+
empty: { display: "grid", placeItems: "center", alignContent: "center", height: "100%", padding: 30, textAlign: "center", color: a.muted },
|
|
2124
2256
|
emptyHero: { display: "grid", placeItems: "center", width: 64, height: 64, marginBottom: 16, borderRadius: 20, background: "#eaf0ff", color: "#5277d7" },
|
|
2125
|
-
state: { display: "flex", alignItems: "center", justifyContent: "center", gap: 10, minHeight: 180, border: `1px solid ${
|
|
2257
|
+
state: { display: "flex", alignItems: "center", justifyContent: "center", gap: 10, minHeight: 180, border: `1px solid ${a.line}`, background: a.white, color: a.muted, fontSize: 13 },
|
|
2126
2258
|
retry: { border: 0, borderRadius: 7, padding: "7px 10px", background: "#eff4ff", color: "#315dbb", cursor: "pointer" },
|
|
2127
2259
|
spinner: { display: "inline-block", width: 14, height: 14, border: "2px solid #dbe3f3", borderTopColor: "#5277d7", borderRadius: "50%", animation: "channelhub-spin .7s linear infinite" },
|
|
2128
2260
|
toolbarBtn: { display: "inline-grid", placeItems: "center", width: 26, height: 26, border: "1px solid transparent", borderRadius: 6, background: "transparent", color: "#9ca3af", cursor: "pointer", padding: 0, lineHeight: 1 },
|
|
2129
|
-
infoPanel: { display: "flex", flexDirection: "column", borderLeft: `1px solid ${
|
|
2130
|
-
infoPanelHeader: { display: "flex", alignItems: "center", justifyContent: "space-between", padding: "16px 16px 12px", borderBottom: `1px solid ${
|
|
2261
|
+
infoPanel: { display: "flex", flexDirection: "column", borderLeft: `1px solid ${a.line}`, background: a.white, minHeight: 0, overflow: "hidden" },
|
|
2262
|
+
infoPanelHeader: { display: "flex", alignItems: "center", justifyContent: "space-between", padding: "16px 16px 12px", borderBottom: `1px solid ${a.line}`, flex: "0 0 auto" },
|
|
2131
2263
|
infoPanelIdentity: { display: "flex", flexDirection: "column", alignItems: "center", padding: "20px 16px 16px", gap: 4 },
|
|
2132
|
-
ghostButton: { width: "100%", padding: "8px 12px", border: `1px solid ${
|
|
2133
|
-
},
|
|
2264
|
+
ghostButton: { width: "100%", padding: "8px 12px", border: `1px solid ${a.line}`, borderRadius: 8, background: "transparent", fontSize: 12, cursor: "pointer", textAlign: "center" }
|
|
2265
|
+
}, Sn = {
|
|
2134
2266
|
facebook: "#dbeafe",
|
|
2135
2267
|
zalo: "#e0f2fe",
|
|
2136
2268
|
instagram: "#fce7f3",
|
|
2137
2269
|
telegram: "#cffafe",
|
|
2138
2270
|
livechat: "#ede9fe",
|
|
2139
2271
|
whatsapp: "#dcfce7"
|
|
2140
|
-
},
|
|
2272
|
+
}, Cn = {
|
|
2141
2273
|
facebook: "facebook",
|
|
2142
2274
|
instagram: "instagram",
|
|
2143
2275
|
telegram: "telegram",
|
|
@@ -2145,43 +2277,43 @@ const f = {
|
|
|
2145
2277
|
livechat: "web",
|
|
2146
2278
|
whatsapp: "web"
|
|
2147
2279
|
};
|
|
2148
|
-
function
|
|
2149
|
-
const
|
|
2280
|
+
function Ce({ provider: t, apiUrl: i, size: o = 40 }) {
|
|
2281
|
+
const r = Sn[t] ?? "#f1f5f9", c = Cn[t], C = i.replace(/\/$/, "");
|
|
2150
2282
|
return /* @__PURE__ */ e(
|
|
2151
2283
|
"div",
|
|
2152
2284
|
{
|
|
2153
2285
|
style: {
|
|
2154
|
-
width:
|
|
2155
|
-
height:
|
|
2156
|
-
borderRadius: Math.round(
|
|
2157
|
-
background:
|
|
2286
|
+
width: o,
|
|
2287
|
+
height: o,
|
|
2288
|
+
borderRadius: Math.round(o * 0.28),
|
|
2289
|
+
background: r,
|
|
2158
2290
|
display: "flex",
|
|
2159
2291
|
alignItems: "center",
|
|
2160
2292
|
justifyContent: "center",
|
|
2161
2293
|
flexShrink: 0,
|
|
2162
2294
|
overflow: "hidden"
|
|
2163
2295
|
},
|
|
2164
|
-
children:
|
|
2296
|
+
children: c ? /* @__PURE__ */ e(
|
|
2165
2297
|
"img",
|
|
2166
2298
|
{
|
|
2167
|
-
src: `${
|
|
2299
|
+
src: `${C}/static/logos/${c}.avif`,
|
|
2168
2300
|
alt: t,
|
|
2169
|
-
width: Math.round(
|
|
2170
|
-
height: Math.round(
|
|
2301
|
+
width: Math.round(o * 0.65),
|
|
2302
|
+
height: Math.round(o * 0.65),
|
|
2171
2303
|
style: { objectFit: "contain", display: "block" }
|
|
2172
2304
|
}
|
|
2173
|
-
) : /* @__PURE__ */ e("span", { style: { fontSize: Math.round(
|
|
2305
|
+
) : /* @__PURE__ */ e("span", { style: { fontSize: Math.round(o * 0.45), fontWeight: 700, color: "#64748b", textTransform: "uppercase" }, children: t.slice(0, 1) })
|
|
2174
2306
|
}
|
|
2175
2307
|
);
|
|
2176
2308
|
}
|
|
2177
|
-
const
|
|
2309
|
+
const qe = {
|
|
2178
2310
|
facebook: "Facebook",
|
|
2179
2311
|
zalo: "Zalo OA",
|
|
2180
2312
|
instagram: "Instagram",
|
|
2181
2313
|
telegram: "Telegram",
|
|
2182
2314
|
livechat: "Live Chat",
|
|
2183
2315
|
whatsapp: "WhatsApp"
|
|
2184
|
-
},
|
|
2316
|
+
}, In = {
|
|
2185
2317
|
facebook: "#dbeafe",
|
|
2186
2318
|
zalo: "#e0f2fe",
|
|
2187
2319
|
instagram: "#fce7f3",
|
|
@@ -2189,11 +2321,11 @@ const Oe = {
|
|
|
2189
2321
|
livechat: "#ede9fe",
|
|
2190
2322
|
whatsapp: "#dcfce7"
|
|
2191
2323
|
};
|
|
2192
|
-
function
|
|
2324
|
+
function mt(t) {
|
|
2193
2325
|
const i = t.metadata;
|
|
2194
2326
|
return String(i.displayName ?? i.pageName ?? i.username ?? i.name ?? t.externalAccountId);
|
|
2195
2327
|
}
|
|
2196
|
-
function
|
|
2328
|
+
function zn(t) {
|
|
2197
2329
|
const i = t.metadata;
|
|
2198
2330
|
switch (t.provider) {
|
|
2199
2331
|
case "facebook":
|
|
@@ -2203,14 +2335,14 @@ function fn(t) {
|
|
|
2203
2335
|
case "zalo":
|
|
2204
2336
|
return `Zalo OA · ID ${t.externalAccountId}`;
|
|
2205
2337
|
case "telegram": {
|
|
2206
|
-
const
|
|
2207
|
-
return
|
|
2338
|
+
const o = String(i.username ?? "");
|
|
2339
|
+
return o ? `@${o}` : `Bot · ${t.externalAccountId}`;
|
|
2208
2340
|
}
|
|
2209
2341
|
case "livechat":
|
|
2210
2342
|
return `Widget ID: ${t.id}`;
|
|
2211
2343
|
default: {
|
|
2212
|
-
const
|
|
2213
|
-
return
|
|
2344
|
+
const o = qe[t.provider] ?? t.provider, r = String(i.username ?? i.pageName ?? "");
|
|
2345
|
+
return r ? `${o} · ${r}` : o;
|
|
2214
2346
|
}
|
|
2215
2347
|
}
|
|
2216
2348
|
}
|
|
@@ -2489,264 +2621,264 @@ const s = {
|
|
|
2489
2621
|
fontFamily: "inherit"
|
|
2490
2622
|
}
|
|
2491
2623
|
};
|
|
2492
|
-
function
|
|
2624
|
+
function $t() {
|
|
2493
2625
|
return /* @__PURE__ */ e("svg", { width: "14", height: "14", viewBox: "0 0 14 14", fill: "none", children: /* @__PURE__ */ e("path", { d: "M7 1v12M1 7h12", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round" }) });
|
|
2494
2626
|
}
|
|
2495
|
-
function
|
|
2627
|
+
function Ae() {
|
|
2496
2628
|
return /* @__PURE__ */ e("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", children: /* @__PURE__ */ e("path", { d: "M10 3L5 8l5 5", stroke: "currentColor", strokeWidth: "1.75", strokeLinecap: "round", strokeLinejoin: "round" }) });
|
|
2497
2629
|
}
|
|
2498
|
-
function
|
|
2630
|
+
function Bt() {
|
|
2499
2631
|
return /* @__PURE__ */ n("svg", { width: "12", height: "12", viewBox: "0 0 12 12", fill: "none", children: [
|
|
2500
2632
|
/* @__PURE__ */ e("rect", { x: "4", y: "4", width: "7", height: "7", rx: "1.5", stroke: "currentColor", strokeWidth: "1.3" }),
|
|
2501
2633
|
/* @__PURE__ */ e("path", { d: "M2.5 8H2a1 1 0 01-1-1V2a1 1 0 011-1h5a1 1 0 011 1v.5", stroke: "currentColor", strokeWidth: "1.3", strokeLinecap: "round" })
|
|
2502
2634
|
] });
|
|
2503
2635
|
}
|
|
2504
|
-
function
|
|
2636
|
+
function Lt() {
|
|
2505
2637
|
return /* @__PURE__ */ e("svg", { width: "12", height: "12", viewBox: "0 0 12 12", fill: "none", children: /* @__PURE__ */ e("path", { d: "M2 6l3 3 5-5", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }) });
|
|
2506
2638
|
}
|
|
2507
|
-
function
|
|
2639
|
+
function Rn() {
|
|
2508
2640
|
return /* @__PURE__ */ n("svg", { width: "14", height: "14", viewBox: "0 0 14 14", fill: "none", style: { flexShrink: 0 }, children: [
|
|
2509
2641
|
/* @__PURE__ */ e("circle", { cx: "5", cy: "6", r: "3.5", stroke: "#ca8a04", strokeWidth: "1.4" }),
|
|
2510
2642
|
/* @__PURE__ */ e("path", { d: "M8 7.5l4.5 4.5M10.5 10l1.5 1.5", stroke: "#ca8a04", strokeWidth: "1.4", strokeLinecap: "round" })
|
|
2511
2643
|
] });
|
|
2512
2644
|
}
|
|
2513
|
-
function
|
|
2645
|
+
function Wn() {
|
|
2514
2646
|
return /* @__PURE__ */ n("svg", { width: "14", height: "14", viewBox: "0 0 14 14", fill: "none", style: { flexShrink: 0, marginTop: 1 }, children: [
|
|
2515
2647
|
/* @__PURE__ */ e("circle", { cx: "7", cy: "7", r: "6", stroke: "currentColor", strokeWidth: "1.5" }),
|
|
2516
2648
|
/* @__PURE__ */ e("path", { d: "M7 6v5M7 4.5v.01", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round" })
|
|
2517
2649
|
] });
|
|
2518
2650
|
}
|
|
2519
|
-
let
|
|
2520
|
-
function
|
|
2521
|
-
if (
|
|
2522
|
-
|
|
2651
|
+
let Mt = !1;
|
|
2652
|
+
function Tn() {
|
|
2653
|
+
if (Mt || typeof document > "u") return;
|
|
2654
|
+
Mt = !0;
|
|
2523
2655
|
const t = document.createElement("style");
|
|
2524
2656
|
t.textContent = "@keyframes ch-spin{to{transform:rotate(360deg)}}", document.head.appendChild(t);
|
|
2525
2657
|
}
|
|
2526
|
-
function
|
|
2527
|
-
const
|
|
2528
|
-
|
|
2529
|
-
const
|
|
2658
|
+
function Pn({ apiUrl: t, token: i, onConnectionChange: o }) {
|
|
2659
|
+
const r = t.replace(/\/$/, ""), [c, C] = u([]), [y, L] = u(!0), [w, g] = u({ name: "list" }), [$, T] = u(null), [E, M] = u(!1), [I, q] = u(""), [R, H] = u(""), [J, F] = u(""), [re, V] = u(""), [B, b] = u(!1), [S, D] = u(!1), j = X(null);
|
|
2660
|
+
Tn();
|
|
2661
|
+
const Z = Te(async () => {
|
|
2530
2662
|
try {
|
|
2531
|
-
const
|
|
2663
|
+
const h = await fetch(`${r}/v1/connections`, {
|
|
2532
2664
|
headers: { authorization: `Bearer ${i}` }
|
|
2533
2665
|
});
|
|
2534
|
-
if (!
|
|
2535
|
-
const
|
|
2536
|
-
|
|
2537
|
-
} catch (
|
|
2538
|
-
|
|
2666
|
+
if (!h.ok) throw new Error("Không tải được kênh");
|
|
2667
|
+
const A = await h.json();
|
|
2668
|
+
C(A), o == null || o(A);
|
|
2669
|
+
} catch (h) {
|
|
2670
|
+
T(h instanceof Error ? h.message : "Lỗi tải dữ liệu");
|
|
2539
2671
|
} finally {
|
|
2540
|
-
|
|
2672
|
+
L(!1);
|
|
2541
2673
|
}
|
|
2542
|
-
}, [
|
|
2543
|
-
|
|
2544
|
-
|
|
2545
|
-
}, [
|
|
2546
|
-
if (
|
|
2547
|
-
const
|
|
2548
|
-
return () => clearTimeout(
|
|
2549
|
-
}, [
|
|
2550
|
-
|
|
2674
|
+
}, [r, i, o]);
|
|
2675
|
+
K(() => {
|
|
2676
|
+
Z();
|
|
2677
|
+
}, [Z]), K(() => {
|
|
2678
|
+
if (!$) return;
|
|
2679
|
+
const h = setTimeout(() => T(null), 5e3);
|
|
2680
|
+
return () => clearTimeout(h);
|
|
2681
|
+
}, [$]), K(() => () => {
|
|
2682
|
+
j.current && window.removeEventListener("message", j.current);
|
|
2551
2683
|
}, []);
|
|
2552
|
-
async function
|
|
2553
|
-
if (confirm(`Bạn chắc chắn muốn ngắt kết nối "${
|
|
2684
|
+
async function pe(h, A) {
|
|
2685
|
+
if (confirm(`Bạn chắc chắn muốn ngắt kết nối "${A}"?
|
|
2554
2686
|
|
|
2555
2687
|
Hành động này không thể hoàn tác.`))
|
|
2556
2688
|
try {
|
|
2557
|
-
if (!(await fetch(`${
|
|
2689
|
+
if (!(await fetch(`${r}/v1/connections/${h}`, {
|
|
2558
2690
|
method: "DELETE",
|
|
2559
2691
|
headers: { authorization: `Bearer ${i}` }
|
|
2560
2692
|
})).ok) throw new Error("Không thể ngắt kết nối");
|
|
2561
|
-
await
|
|
2562
|
-
} catch (
|
|
2563
|
-
|
|
2693
|
+
await Z();
|
|
2694
|
+
} catch (U) {
|
|
2695
|
+
T(U instanceof Error ? U.message : "Lỗi ngắt kết nối");
|
|
2564
2696
|
}
|
|
2565
2697
|
}
|
|
2566
|
-
async function
|
|
2567
|
-
if (!
|
|
2568
|
-
|
|
2698
|
+
async function ve() {
|
|
2699
|
+
if (!I.trim()) {
|
|
2700
|
+
T("Vui lòng nhập Bot Token");
|
|
2569
2701
|
return;
|
|
2570
2702
|
}
|
|
2571
|
-
if (!/^\d+:[A-Za-z0-9_-]+$/.test(
|
|
2572
|
-
|
|
2703
|
+
if (!/^\d+:[A-Za-z0-9_-]+$/.test(I.trim())) {
|
|
2704
|
+
T("Token không đúng định dạng");
|
|
2573
2705
|
return;
|
|
2574
2706
|
}
|
|
2575
|
-
|
|
2707
|
+
M(!0), T(null);
|
|
2576
2708
|
try {
|
|
2577
|
-
const
|
|
2709
|
+
const h = await fetch(`${r}/v1/connect/telegram/start`, {
|
|
2578
2710
|
method: "POST",
|
|
2579
2711
|
headers: { authorization: `Bearer ${i}`, "content-type": "application/json" },
|
|
2580
|
-
body: JSON.stringify({ botToken:
|
|
2581
|
-
}),
|
|
2582
|
-
if (!
|
|
2583
|
-
|
|
2584
|
-
} catch (
|
|
2585
|
-
|
|
2712
|
+
body: JSON.stringify({ botToken: I.trim(), displayName: R.trim() || void 0 })
|
|
2713
|
+
}), A = await h.json();
|
|
2714
|
+
if (!h.ok || !A.connectionId) throw new Error(A.message ?? "Không thể kết nối Telegram");
|
|
2715
|
+
q(""), H(""), await Z(), g({ name: "list" });
|
|
2716
|
+
} catch (h) {
|
|
2717
|
+
T(h instanceof Error ? h.message : "Lỗi kết nối");
|
|
2586
2718
|
} finally {
|
|
2587
|
-
|
|
2719
|
+
M(!1);
|
|
2588
2720
|
}
|
|
2589
2721
|
}
|
|
2590
|
-
async function
|
|
2591
|
-
if (!
|
|
2592
|
-
|
|
2722
|
+
async function fe() {
|
|
2723
|
+
if (!J.trim()) {
|
|
2724
|
+
T("Vui lòng nhập tên widget");
|
|
2593
2725
|
return;
|
|
2594
2726
|
}
|
|
2595
|
-
|
|
2727
|
+
M(!0), T(null);
|
|
2596
2728
|
try {
|
|
2597
|
-
const
|
|
2729
|
+
const h = re.split(/[\n,]+/).map((z) => z.trim()).filter(Boolean), A = await fetch(`${r}/v1/connect/livechat/start`, {
|
|
2598
2730
|
method: "POST",
|
|
2599
2731
|
headers: { authorization: `Bearer ${i}`, "content-type": "application/json" },
|
|
2600
|
-
body: JSON.stringify({ displayName:
|
|
2601
|
-
}),
|
|
2602
|
-
if (!
|
|
2603
|
-
|
|
2732
|
+
body: JSON.stringify({ displayName: J.trim(), allowedDomains: h.length ? h : void 0 })
|
|
2733
|
+
}), U = await A.json();
|
|
2734
|
+
if (!A.ok || !U.connectionId || !U.embedScript) throw new Error(U.message ?? "Không thể tạo widget");
|
|
2735
|
+
F(""), V(""), await Z(), g({
|
|
2604
2736
|
name: "livechat-result",
|
|
2605
|
-
connectionId:
|
|
2606
|
-
embedScript:
|
|
2607
|
-
identitySecret:
|
|
2608
|
-
allowedDomains:
|
|
2737
|
+
connectionId: U.connectionId,
|
|
2738
|
+
embedScript: U.embedScript,
|
|
2739
|
+
identitySecret: U.identitySecret ?? "",
|
|
2740
|
+
allowedDomains: U.allowedDomains ?? []
|
|
2609
2741
|
});
|
|
2610
|
-
} catch (
|
|
2611
|
-
|
|
2742
|
+
} catch (h) {
|
|
2743
|
+
T(h instanceof Error ? h.message : "Lỗi tạo widget");
|
|
2612
2744
|
} finally {
|
|
2613
|
-
|
|
2745
|
+
M(!1);
|
|
2614
2746
|
}
|
|
2615
2747
|
}
|
|
2616
|
-
async function
|
|
2617
|
-
|
|
2748
|
+
async function se(h) {
|
|
2749
|
+
T(null);
|
|
2618
2750
|
try {
|
|
2619
|
-
const
|
|
2751
|
+
const A = `${r}/static/oauth-popup.html`, U = await fetch(`${r}/v1/connect/${h}/start`, {
|
|
2620
2752
|
method: "POST",
|
|
2621
2753
|
headers: { authorization: `Bearer ${i}`, "content-type": "application/json" },
|
|
2622
|
-
body: JSON.stringify({ callbackUrl:
|
|
2623
|
-
}),
|
|
2624
|
-
if (!
|
|
2625
|
-
const ce = window.open(
|
|
2626
|
-
|
|
2627
|
-
const
|
|
2628
|
-
if (
|
|
2629
|
-
if (
|
|
2630
|
-
|
|
2754
|
+
body: JSON.stringify({ callbackUrl: A })
|
|
2755
|
+
}), z = await U.json();
|
|
2756
|
+
if (!U.ok || !z.authorizationUrl) throw new Error(z.message ?? "Không thể bắt đầu kết nối");
|
|
2757
|
+
const ce = window.open(z.authorizationUrl, "channelhub-oauth", "width=600,height=700,scrollbars=yes,resizable=yes");
|
|
2758
|
+
g({ name: "oauth-waiting", provider: h, popup: ce }), j.current && window.removeEventListener("message", j.current);
|
|
2759
|
+
const de = (Q) => {
|
|
2760
|
+
if (Q.data) {
|
|
2761
|
+
if (Q.data.type === "channelhub:oauth-select") {
|
|
2762
|
+
g({
|
|
2631
2763
|
name: "oauth-select",
|
|
2632
|
-
provider:
|
|
2633
|
-
sessionId: String(
|
|
2634
|
-
pages:
|
|
2764
|
+
provider: Q.data.provider,
|
|
2765
|
+
sessionId: String(Q.data.sessionId ?? ""),
|
|
2766
|
+
pages: Q.data.pages ?? [],
|
|
2635
2767
|
popup: ce
|
|
2636
2768
|
});
|
|
2637
2769
|
return;
|
|
2638
2770
|
}
|
|
2639
|
-
|
|
2771
|
+
Q.data.type === "channelhub:oauth" && (window.removeEventListener("message", de), j.current = null, Q.data.status === "active" ? (Z(), g({ name: "list" })) : (T("Kết nối thất bại: " + String(Q.data.error ?? "Không xác định")), g({ name: "list" })));
|
|
2640
2772
|
}
|
|
2641
2773
|
};
|
|
2642
|
-
|
|
2643
|
-
} catch (
|
|
2644
|
-
|
|
2774
|
+
j.current = de, window.addEventListener("message", de);
|
|
2775
|
+
} catch (A) {
|
|
2776
|
+
T(A instanceof Error ? A.message : "Lỗi kết nối"), g({ name: "list" });
|
|
2645
2777
|
}
|
|
2646
2778
|
}
|
|
2647
|
-
function
|
|
2648
|
-
navigator.clipboard.writeText(
|
|
2649
|
-
|
|
2779
|
+
function G(h, A) {
|
|
2780
|
+
navigator.clipboard.writeText(h).then(() => {
|
|
2781
|
+
A === "script" ? (b(!0), setTimeout(() => b(!1), 2e3)) : (D(!0), setTimeout(() => D(!1), 2e3));
|
|
2650
2782
|
});
|
|
2651
2783
|
}
|
|
2652
|
-
function
|
|
2653
|
-
const
|
|
2654
|
-
if (
|
|
2784
|
+
function k() {
|
|
2785
|
+
const h = w.name === "oauth-waiting" || w.name === "oauth-select" ? w.popup : null;
|
|
2786
|
+
if (h)
|
|
2655
2787
|
try {
|
|
2656
|
-
|
|
2788
|
+
h.close();
|
|
2657
2789
|
} catch {
|
|
2658
2790
|
}
|
|
2659
|
-
|
|
2791
|
+
j.current && (window.removeEventListener("message", j.current), j.current = null), g({ name: "add" });
|
|
2660
2792
|
}
|
|
2661
|
-
async function
|
|
2793
|
+
async function ie(h) {
|
|
2662
2794
|
if (w.name !== "oauth-select") return;
|
|
2663
|
-
const { provider:
|
|
2664
|
-
|
|
2795
|
+
const { provider: A, sessionId: U, popup: z } = w;
|
|
2796
|
+
M(!0), T(null);
|
|
2665
2797
|
const ce = {
|
|
2666
|
-
facebook: `${
|
|
2667
|
-
instagram: `${
|
|
2668
|
-
zalo: `${
|
|
2669
|
-
},
|
|
2798
|
+
facebook: `${r}/v1/connect/facebook/select-page`,
|
|
2799
|
+
instagram: `${r}/v1/connect/instagram/select-account`,
|
|
2800
|
+
zalo: `${r}/v1/connect/zalo/select-oa`
|
|
2801
|
+
}, de = {
|
|
2670
2802
|
facebook: "pageId",
|
|
2671
2803
|
instagram: "accountId",
|
|
2672
2804
|
zalo: "oaId"
|
|
2673
2805
|
};
|
|
2674
2806
|
try {
|
|
2675
|
-
const
|
|
2807
|
+
const Q = await fetch(ce[A] ?? `${r}/v1/connect/${A}/select-page`, {
|
|
2676
2808
|
method: "POST",
|
|
2677
2809
|
headers: { authorization: `Bearer ${i}`, "content-type": "application/json" },
|
|
2678
|
-
body: JSON.stringify({ sessionId:
|
|
2679
|
-
}), he = await
|
|
2680
|
-
if (!
|
|
2681
|
-
if (
|
|
2810
|
+
body: JSON.stringify({ sessionId: U, [de[A] ?? "pageId"]: h })
|
|
2811
|
+
}), he = await Q.json();
|
|
2812
|
+
if (!Q.ok || !he.connectionId) throw new Error(he.message ?? "Không thể kết nối");
|
|
2813
|
+
if (z)
|
|
2682
2814
|
try {
|
|
2683
|
-
|
|
2815
|
+
z.postMessage({ type: "channelhub:close-popup" }, "*");
|
|
2684
2816
|
} catch {
|
|
2685
2817
|
}
|
|
2686
|
-
|
|
2687
|
-
} catch (
|
|
2688
|
-
|
|
2818
|
+
j.current && (window.removeEventListener("message", j.current), j.current = null), await Z(), g({ name: "list" });
|
|
2819
|
+
} catch (Q) {
|
|
2820
|
+
T(Q instanceof Error ? Q.message : "Lỗi kết nối");
|
|
2689
2821
|
} finally {
|
|
2690
|
-
|
|
2822
|
+
M(!1);
|
|
2691
2823
|
}
|
|
2692
2824
|
}
|
|
2693
2825
|
return /* @__PURE__ */ n("div", { style: s.root, children: [
|
|
2694
|
-
|
|
2695
|
-
w.name === "list" && /* @__PURE__ */ n(
|
|
2826
|
+
$ && /* @__PURE__ */ e("div", { style: s.errorBanner, children: $ }),
|
|
2827
|
+
w.name === "list" && /* @__PURE__ */ n(ne, { children: [
|
|
2696
2828
|
/* @__PURE__ */ n("div", { style: s.header, children: [
|
|
2697
2829
|
/* @__PURE__ */ e("div", { style: s.headerLeft, children: /* @__PURE__ */ n("div", { children: [
|
|
2698
2830
|
/* @__PURE__ */ e("div", { style: s.title, children: "Kênh kết nối" }),
|
|
2699
|
-
/* @__PURE__ */ e("div", { style: s.subtitle, children:
|
|
2831
|
+
/* @__PURE__ */ e("div", { style: s.subtitle, children: y ? "Đang tải…" : `${c.filter((h) => h.status === "active").length} kênh đang hoạt động` })
|
|
2700
2832
|
] }) }),
|
|
2701
|
-
/* @__PURE__ */ n("button", { style: s.addBtn, onClick: () =>
|
|
2702
|
-
/* @__PURE__ */ e(
|
|
2833
|
+
/* @__PURE__ */ n("button", { style: s.addBtn, onClick: () => g({ name: "add" }), children: [
|
|
2834
|
+
/* @__PURE__ */ e($t, {}),
|
|
2703
2835
|
/* @__PURE__ */ e("span", { children: "Thêm kênh" })
|
|
2704
2836
|
] })
|
|
2705
2837
|
] }),
|
|
2706
2838
|
/* @__PURE__ */ e("div", { style: s.divider }),
|
|
2707
|
-
/* @__PURE__ */ e("div", { style: s.body, children: !
|
|
2708
|
-
/* @__PURE__ */ e("div", { style: { width: 64, height: 64, borderRadius: 16, background: "#f1f5f9", display: "flex", alignItems: "center", justifyContent: "center" }, children: /* @__PURE__ */ e(
|
|
2839
|
+
/* @__PURE__ */ e("div", { style: s.body, children: !y && c.length === 0 ? /* @__PURE__ */ n("div", { style: s.empty, children: [
|
|
2840
|
+
/* @__PURE__ */ e("div", { style: { width: 64, height: 64, borderRadius: 16, background: "#f1f5f9", display: "flex", alignItems: "center", justifyContent: "center" }, children: /* @__PURE__ */ e(Ce, { provider: "livechat", apiUrl: r, size: 40 }) }),
|
|
2709
2841
|
/* @__PURE__ */ e("div", { style: s.emptyTitle, children: "Chưa có kênh nào được kết nối" }),
|
|
2710
2842
|
/* @__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." }),
|
|
2711
|
-
/* @__PURE__ */ n("button", { style: s.emptyCta, onClick: () =>
|
|
2712
|
-
/* @__PURE__ */ e(
|
|
2843
|
+
/* @__PURE__ */ n("button", { style: s.emptyCta, onClick: () => g({ name: "add" }), children: [
|
|
2844
|
+
/* @__PURE__ */ e($t, {}),
|
|
2713
2845
|
"Kết nối kênh đầu tiên"
|
|
2714
2846
|
] })
|
|
2715
|
-
] }) : /* @__PURE__ */ e("div", { children:
|
|
2716
|
-
|
|
2847
|
+
] }) : /* @__PURE__ */ e("div", { children: c.map((h) => /* @__PURE__ */ e(
|
|
2848
|
+
Ln,
|
|
2717
2849
|
{
|
|
2718
|
-
conn:
|
|
2719
|
-
apiUrl:
|
|
2720
|
-
onDisconnect: () => void
|
|
2850
|
+
conn: h,
|
|
2851
|
+
apiUrl: r,
|
|
2852
|
+
onDisconnect: () => void pe(h.id, mt(h))
|
|
2721
2853
|
},
|
|
2722
|
-
|
|
2854
|
+
h.id
|
|
2723
2855
|
)) }) })
|
|
2724
2856
|
] }),
|
|
2725
|
-
w.name === "add" && /* @__PURE__ */ n(
|
|
2857
|
+
w.name === "add" && /* @__PURE__ */ n(ne, { children: [
|
|
2726
2858
|
/* @__PURE__ */ e("div", { style: s.header, children: /* @__PURE__ */ n("div", { style: s.headerLeft, children: [
|
|
2727
|
-
/* @__PURE__ */ e("button", { style: s.backBtn, onClick: () =>
|
|
2859
|
+
/* @__PURE__ */ e("button", { style: s.backBtn, onClick: () => g({ name: "list" }), children: /* @__PURE__ */ e(Ae, {}) }),
|
|
2728
2860
|
/* @__PURE__ */ n("div", { children: [
|
|
2729
2861
|
/* @__PURE__ */ e("div", { style: s.title, children: "Thêm kênh mới" }),
|
|
2730
2862
|
/* @__PURE__ */ e("div", { style: s.subtitle, children: "Chọn nền tảng bạn muốn kết nối" })
|
|
2731
2863
|
] })
|
|
2732
2864
|
] }) }),
|
|
2733
2865
|
/* @__PURE__ */ e("div", { style: s.divider }),
|
|
2734
|
-
/* @__PURE__ */ e("div", { style: s.body, children: /* @__PURE__ */ e("div", { style: s.providerGrid, children:
|
|
2735
|
-
|
|
2866
|
+
/* @__PURE__ */ e("div", { style: s.body, children: /* @__PURE__ */ e("div", { style: s.providerGrid, children: Mn.map((h) => /* @__PURE__ */ e(
|
|
2867
|
+
Hn,
|
|
2736
2868
|
{
|
|
2737
|
-
provider:
|
|
2738
|
-
apiUrl:
|
|
2869
|
+
provider: h,
|
|
2870
|
+
apiUrl: r,
|
|
2739
2871
|
onClick: () => {
|
|
2740
|
-
|
|
2872
|
+
h.type === "oauth" ? se(h.id) : h.id === "telegram" ? g({ name: "connect-telegram" }) : g({ name: "connect-livechat" });
|
|
2741
2873
|
}
|
|
2742
2874
|
},
|
|
2743
|
-
|
|
2875
|
+
h.id
|
|
2744
2876
|
)) }) })
|
|
2745
2877
|
] }),
|
|
2746
|
-
w.name === "connect-telegram" && /* @__PURE__ */ n(
|
|
2878
|
+
w.name === "connect-telegram" && /* @__PURE__ */ n(ne, { children: [
|
|
2747
2879
|
/* @__PURE__ */ n("div", { style: s.connectHeader, children: [
|
|
2748
|
-
/* @__PURE__ */ e("button", { style: s.backBtn, onClick: () =>
|
|
2749
|
-
/* @__PURE__ */ e(
|
|
2880
|
+
/* @__PURE__ */ e("button", { style: s.backBtn, onClick: () => g({ name: "add" }), children: /* @__PURE__ */ e(Ae, {}) }),
|
|
2881
|
+
/* @__PURE__ */ e(Ce, { provider: "telegram", apiUrl: r, size: 44 }),
|
|
2750
2882
|
/* @__PURE__ */ n("div", { children: [
|
|
2751
2883
|
/* @__PURE__ */ e("div", { style: s.connectTitle, children: "Kết nối Telegram Bot" }),
|
|
2752
2884
|
/* @__PURE__ */ e("div", { style: s.connectDesc, children: "Nhập Bot Token để bắt đầu nhận tin nhắn" })
|
|
@@ -2754,7 +2886,7 @@ Hành động này không thể hoàn tác.`))
|
|
|
2754
2886
|
] }),
|
|
2755
2887
|
/* @__PURE__ */ n("div", { style: s.form, children: [
|
|
2756
2888
|
/* @__PURE__ */ n("div", { style: s.infoBox, children: [
|
|
2757
|
-
/* @__PURE__ */ e(
|
|
2889
|
+
/* @__PURE__ */ e(Wn, {}),
|
|
2758
2890
|
/* @__PURE__ */ n("div", { children: [
|
|
2759
2891
|
"Tạo bot mới bằng cách nhắn tin cho ",
|
|
2760
2892
|
/* @__PURE__ */ e("strong", { children: "@BotFather" }),
|
|
@@ -2773,8 +2905,8 @@ Hành động này không thể hoàn tác.`))
|
|
|
2773
2905
|
{
|
|
2774
2906
|
style: s.input,
|
|
2775
2907
|
type: "text",
|
|
2776
|
-
value:
|
|
2777
|
-
onChange: (
|
|
2908
|
+
value: I,
|
|
2909
|
+
onChange: (h) => q(h.target.value),
|
|
2778
2910
|
placeholder: "1234567890:AAExxxxxxxxxxxxxxxxxxxxxxxx",
|
|
2779
2911
|
autoComplete: "off",
|
|
2780
2912
|
spellCheck: !1
|
|
@@ -2797,22 +2929,22 @@ Hành động này không thể hoàn tác.`))
|
|
|
2797
2929
|
{
|
|
2798
2930
|
style: s.input,
|
|
2799
2931
|
type: "text",
|
|
2800
|
-
value:
|
|
2801
|
-
onChange: (
|
|
2932
|
+
value: R,
|
|
2933
|
+
onChange: (h) => H(h.target.value),
|
|
2802
2934
|
placeholder: "VD: Bot hỗ trợ cửa hàng"
|
|
2803
2935
|
}
|
|
2804
2936
|
)
|
|
2805
2937
|
] }),
|
|
2806
2938
|
/* @__PURE__ */ n("div", { style: s.formActions, children: [
|
|
2807
|
-
/* @__PURE__ */ e("button", { style: s.btnSecondary, onClick: () =>
|
|
2808
|
-
/* @__PURE__ */ e("button", { style: s.btnPrimary, disabled:
|
|
2939
|
+
/* @__PURE__ */ e("button", { style: s.btnSecondary, onClick: () => g({ name: "add" }), children: "Hủy" }),
|
|
2940
|
+
/* @__PURE__ */ e("button", { style: s.btnPrimary, disabled: E, onClick: () => void ve(), children: E ? "Đang kết nối…" : "Kết nối Telegram" })
|
|
2809
2941
|
] })
|
|
2810
2942
|
] })
|
|
2811
2943
|
] }),
|
|
2812
|
-
w.name === "connect-livechat" && /* @__PURE__ */ n(
|
|
2944
|
+
w.name === "connect-livechat" && /* @__PURE__ */ n(ne, { children: [
|
|
2813
2945
|
/* @__PURE__ */ n("div", { style: s.connectHeader, children: [
|
|
2814
|
-
/* @__PURE__ */ e("button", { style: s.backBtn, onClick: () =>
|
|
2815
|
-
/* @__PURE__ */ e(
|
|
2946
|
+
/* @__PURE__ */ e("button", { style: s.backBtn, onClick: () => g({ name: "add" }), children: /* @__PURE__ */ e(Ae, {}) }),
|
|
2947
|
+
/* @__PURE__ */ e(Ce, { provider: "livechat", apiUrl: r, size: 44 }),
|
|
2816
2948
|
/* @__PURE__ */ n("div", { children: [
|
|
2817
2949
|
/* @__PURE__ */ e("div", { style: s.connectTitle, children: "Tạo Live Chat Widget" }),
|
|
2818
2950
|
/* @__PURE__ */ e("div", { style: s.connectDesc, children: "Nhúng vào website để nhận tin nhắn từ khách hàng" })
|
|
@@ -2829,8 +2961,8 @@ Hành động này không thể hoàn tác.`))
|
|
|
2829
2961
|
{
|
|
2830
2962
|
style: s.input,
|
|
2831
2963
|
type: "text",
|
|
2832
|
-
value:
|
|
2833
|
-
onChange: (
|
|
2964
|
+
value: J,
|
|
2965
|
+
onChange: (h) => F(h.target.value),
|
|
2834
2966
|
placeholder: "VD: Hỗ trợ website hanashop.vn"
|
|
2835
2967
|
}
|
|
2836
2968
|
)
|
|
@@ -2844,8 +2976,8 @@ Hành động này không thể hoàn tác.`))
|
|
|
2844
2976
|
"textarea",
|
|
2845
2977
|
{
|
|
2846
2978
|
style: { ...s.input, resize: "vertical", minHeight: 80, lineHeight: 1.5 },
|
|
2847
|
-
value:
|
|
2848
|
-
onChange: (
|
|
2979
|
+
value: re,
|
|
2980
|
+
onChange: (h) => V(h.target.value),
|
|
2849
2981
|
placeholder: `https://myshop.com
|
|
2850
2982
|
https://www.myshop.com`,
|
|
2851
2983
|
spellCheck: !1
|
|
@@ -2854,15 +2986,15 @@ https://www.myshop.com`,
|
|
|
2854
2986
|
/* @__PURE__ */ e("div", { style: s.inputHint, children: "Mỗi domain một dòng. Để trống để cho phép tất cả." })
|
|
2855
2987
|
] }),
|
|
2856
2988
|
/* @__PURE__ */ n("div", { style: s.formActions, children: [
|
|
2857
|
-
/* @__PURE__ */ e("button", { style: s.btnSecondary, onClick: () =>
|
|
2858
|
-
/* @__PURE__ */ e("button", { style: s.btnPrimary, disabled:
|
|
2989
|
+
/* @__PURE__ */ e("button", { style: s.btnSecondary, onClick: () => g({ name: "add" }), children: "Hủy" }),
|
|
2990
|
+
/* @__PURE__ */ e("button", { style: s.btnPrimary, disabled: E, onClick: () => void fe(), children: E ? "Đang tạo…" : "Tạo widget" })
|
|
2859
2991
|
] })
|
|
2860
2992
|
] })
|
|
2861
2993
|
] }),
|
|
2862
|
-
w.name === "livechat-result" && /* @__PURE__ */ n(
|
|
2994
|
+
w.name === "livechat-result" && /* @__PURE__ */ n(ne, { children: [
|
|
2863
2995
|
/* @__PURE__ */ n("div", { style: s.connectHeader, children: [
|
|
2864
|
-
/* @__PURE__ */ e("button", { style: s.backBtn, onClick: () =>
|
|
2865
|
-
/* @__PURE__ */ e(
|
|
2996
|
+
/* @__PURE__ */ e("button", { style: s.backBtn, onClick: () => g({ name: "list" }), children: /* @__PURE__ */ e(Ae, {}) }),
|
|
2997
|
+
/* @__PURE__ */ e(Ce, { provider: "livechat", apiUrl: r, size: 44 }),
|
|
2866
2998
|
/* @__PURE__ */ n("div", { children: [
|
|
2867
2999
|
/* @__PURE__ */ e("div", { style: s.connectTitle, children: "Widget đã được tạo!" }),
|
|
2868
3000
|
/* @__PURE__ */ e("div", { style: s.connectDesc, children: "Sao chép mã nhúng và dán vào website của bạn" })
|
|
@@ -2882,11 +3014,11 @@ https://www.myshop.com`,
|
|
|
2882
3014
|
/* @__PURE__ */ e("div", { style: s.codeLabel, children: "Mã nhúng" }),
|
|
2883
3015
|
/* @__PURE__ */ n("div", { style: s.codeBlock, children: [
|
|
2884
3016
|
/* @__PURE__ */ e("pre", { style: s.codePre, children: w.embedScript }),
|
|
2885
|
-
/* @__PURE__ */ e("button", { style: { ...s.copyBtn, ...
|
|
2886
|
-
/* @__PURE__ */ e(
|
|
3017
|
+
/* @__PURE__ */ e("button", { style: { ...s.copyBtn, ...B ? { background: "#166534", borderColor: "#166534", color: "#bbf7d0" } : {} }, onClick: () => G(w.embedScript, "script"), children: B ? /* @__PURE__ */ n(ne, { children: [
|
|
3018
|
+
/* @__PURE__ */ e(Lt, {}),
|
|
2887
3019
|
" Đã sao chép"
|
|
2888
|
-
] }) : /* @__PURE__ */ n(
|
|
2889
|
-
/* @__PURE__ */ e(
|
|
3020
|
+
] }) : /* @__PURE__ */ n(ne, { children: [
|
|
3021
|
+
/* @__PURE__ */ e(Bt, {}),
|
|
2890
3022
|
" Sao chép"
|
|
2891
3023
|
] }) })
|
|
2892
3024
|
] })
|
|
@@ -2897,40 +3029,40 @@ https://www.myshop.com`,
|
|
|
2897
3029
|
/* @__PURE__ */ e("span", { style: { ...s.labelHint, color: "#dc2626", fontWeight: 600 }, children: "Lưu ngay — chỉ hiển thị một lần" })
|
|
2898
3030
|
] }),
|
|
2899
3031
|
/* @__PURE__ */ n("div", { style: s.secretRow, children: [
|
|
2900
|
-
/* @__PURE__ */ e(
|
|
3032
|
+
/* @__PURE__ */ e(Rn, {}),
|
|
2901
3033
|
/* @__PURE__ */ e("span", { style: s.secretLabel, children: "Secret:" }),
|
|
2902
3034
|
/* @__PURE__ */ e("span", { style: s.secretValue, children: w.identitySecret }),
|
|
2903
3035
|
/* @__PURE__ */ e(
|
|
2904
3036
|
"button",
|
|
2905
3037
|
{
|
|
2906
|
-
onClick: () =>
|
|
2907
|
-
style: { border: "none", background: "transparent", cursor: "pointer", color:
|
|
2908
|
-
children:
|
|
3038
|
+
onClick: () => G(w.identitySecret, "secret"),
|
|
3039
|
+
style: { border: "none", background: "transparent", cursor: "pointer", color: S ? "#059669" : "#ca8a04", padding: 2, display: "flex", alignItems: "center" },
|
|
3040
|
+
children: S ? /* @__PURE__ */ e(Lt, {}) : /* @__PURE__ */ e(Bt, {})
|
|
2909
3041
|
}
|
|
2910
3042
|
)
|
|
2911
3043
|
] }),
|
|
2912
3044
|
/* @__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." })
|
|
2913
3045
|
] }),
|
|
2914
3046
|
/* @__PURE__ */ n("div", { style: s.formActions, children: [
|
|
2915
|
-
/* @__PURE__ */ e("button", { style: s.btnSecondary, onClick: () =>
|
|
2916
|
-
/* @__PURE__ */ e("button", { style: s.btnPrimary, onClick: () =>
|
|
3047
|
+
/* @__PURE__ */ e("button", { style: s.btnSecondary, onClick: () => g({ name: "list" }), children: "Về danh sách" }),
|
|
3048
|
+
/* @__PURE__ */ e("button", { style: s.btnPrimary, onClick: () => g({ name: "add" }), children: "Thêm kênh khác" })
|
|
2917
3049
|
] })
|
|
2918
3050
|
] })
|
|
2919
3051
|
] }),
|
|
2920
|
-
w.name === "oauth-waiting" && /* @__PURE__ */ n(
|
|
3052
|
+
w.name === "oauth-waiting" && /* @__PURE__ */ n(ne, { children: [
|
|
2921
3053
|
/* @__PURE__ */ e("div", { style: s.header, children: /* @__PURE__ */ n("div", { style: s.headerLeft, children: [
|
|
2922
|
-
/* @__PURE__ */ e("button", { style: s.backBtn, onClick:
|
|
3054
|
+
/* @__PURE__ */ e("button", { style: s.backBtn, onClick: k, children: /* @__PURE__ */ e(Ae, {}) }),
|
|
2923
3055
|
/* @__PURE__ */ n("div", { children: [
|
|
2924
3056
|
/* @__PURE__ */ n("div", { style: s.title, children: [
|
|
2925
3057
|
"Đang xác thực ",
|
|
2926
|
-
|
|
3058
|
+
qe[w.provider]
|
|
2927
3059
|
] }),
|
|
2928
3060
|
/* @__PURE__ */ e("div", { style: s.subtitle, children: "Vui lòng hoàn thành trong cửa sổ bật lên" })
|
|
2929
3061
|
] })
|
|
2930
3062
|
] }) }),
|
|
2931
3063
|
/* @__PURE__ */ n("div", { style: s.oauthWaiting, children: [
|
|
2932
3064
|
/* @__PURE__ */ n("div", { style: { position: "relative", width: 72, height: 72 }, children: [
|
|
2933
|
-
/* @__PURE__ */ e("div", { style: { width: 72, height: 72, borderRadius: 20, background:
|
|
3065
|
+
/* @__PURE__ */ e("div", { style: { width: 72, height: 72, borderRadius: 20, background: In[w.provider] ?? "#f1f5f9", display: "flex", alignItems: "center", justifyContent: "center" }, children: /* @__PURE__ */ e(Ce, { provider: w.provider, apiUrl: r, size: 48 }) }),
|
|
2934
3066
|
/* @__PURE__ */ n(
|
|
2935
3067
|
"svg",
|
|
2936
3068
|
{
|
|
@@ -2959,21 +3091,21 @@ https://www.myshop.com`,
|
|
|
2959
3091
|
] }),
|
|
2960
3092
|
/* @__PURE__ */ n("div", { style: s.oauthTitle, children: [
|
|
2961
3093
|
"Đang chờ xác thực với ",
|
|
2962
|
-
|
|
3094
|
+
qe[w.provider]
|
|
2963
3095
|
] }),
|
|
2964
3096
|
/* @__PURE__ */ e("div", { style: s.oauthDesc, children: "Một cửa sổ đăng nhập đã được mở. Vui lòng đăng nhập và cấp quyền truy cập để hoàn tất kết nối." }),
|
|
2965
3097
|
/* @__PURE__ */ n("div", { style: { display: "flex", flexDirection: "column", gap: 8, alignItems: "flex-start", width: "100%", maxWidth: 280 }, children: [
|
|
2966
|
-
/* @__PURE__ */ e(
|
|
2967
|
-
/* @__PURE__ */ e(
|
|
2968
|
-
/* @__PURE__ */ e(
|
|
3098
|
+
/* @__PURE__ */ e(lt, { done: !0, label: `Đã mở cửa sổ ${qe[w.provider]}` }),
|
|
3099
|
+
/* @__PURE__ */ e(lt, { active: !0, label: "Đang chờ bạn đăng nhập & cấp quyền" }),
|
|
3100
|
+
/* @__PURE__ */ e(lt, { label: "Lưu kết nối & quay về" })
|
|
2969
3101
|
] }),
|
|
2970
|
-
/* @__PURE__ */ e("button", { style: s.oauthCancel, onClick:
|
|
3102
|
+
/* @__PURE__ */ e("button", { style: s.oauthCancel, onClick: k, children: "Hủy và quay lại" })
|
|
2971
3103
|
] })
|
|
2972
3104
|
] }),
|
|
2973
|
-
w.name === "oauth-select" && /* @__PURE__ */ n(
|
|
3105
|
+
w.name === "oauth-select" && /* @__PURE__ */ n(ne, { children: [
|
|
2974
3106
|
/* @__PURE__ */ n("div", { style: s.connectHeader, children: [
|
|
2975
|
-
/* @__PURE__ */ e("button", { style: s.backBtn, onClick:
|
|
2976
|
-
/* @__PURE__ */ e(
|
|
3107
|
+
/* @__PURE__ */ e("button", { style: s.backBtn, onClick: k, children: /* @__PURE__ */ e(Ae, {}) }),
|
|
3108
|
+
/* @__PURE__ */ e(Ce, { provider: w.provider, apiUrl: r, size: 44 }),
|
|
2977
3109
|
/* @__PURE__ */ n("div", { children: [
|
|
2978
3110
|
/* @__PURE__ */ n("div", { style: s.connectTitle, children: [
|
|
2979
3111
|
"Chọn ",
|
|
@@ -2981,16 +3113,16 @@ https://www.myshop.com`,
|
|
|
2981
3113
|
] }),
|
|
2982
3114
|
/* @__PURE__ */ n("div", { style: s.connectDesc, children: [
|
|
2983
3115
|
"Chọn ",
|
|
2984
|
-
|
|
3116
|
+
qe[w.provider],
|
|
2985
3117
|
" bạn muốn kết nối với ChannelHub"
|
|
2986
3118
|
] })
|
|
2987
3119
|
] })
|
|
2988
3120
|
] }),
|
|
2989
|
-
/* @__PURE__ */ e("div", { style: s.body, children: w.pages.length === 0 ? /* @__PURE__ */ e("div", { style: { textAlign: "center", color: "#94a3b8", fontSize: 13, padding: "24px 0" }, children: "Không tìm thấy trang/tài khoản nào. Hãy thử lại." }) : /* @__PURE__ */ e("div", { style: { display: "flex", flexDirection: "column", gap: 8 }, children: w.pages.map((
|
|
3121
|
+
/* @__PURE__ */ e("div", { style: s.body, children: w.pages.length === 0 ? /* @__PURE__ */ e("div", { style: { textAlign: "center", color: "#94a3b8", fontSize: 13, padding: "24px 0" }, children: "Không tìm thấy trang/tài khoản nào. Hãy thử lại." }) : /* @__PURE__ */ e("div", { style: { display: "flex", flexDirection: "column", gap: 8 }, children: w.pages.map((h) => /* @__PURE__ */ n(
|
|
2990
3122
|
"button",
|
|
2991
3123
|
{
|
|
2992
|
-
disabled:
|
|
2993
|
-
onClick: () => void
|
|
3124
|
+
disabled: E,
|
|
3125
|
+
onClick: () => void ie(h.id),
|
|
2994
3126
|
style: {
|
|
2995
3127
|
display: "flex",
|
|
2996
3128
|
alignItems: "center",
|
|
@@ -2999,72 +3131,72 @@ https://www.myshop.com`,
|
|
|
2999
3131
|
borderRadius: 12,
|
|
3000
3132
|
border: "1.5px solid #e2e8f0",
|
|
3001
3133
|
background: "#fff",
|
|
3002
|
-
cursor:
|
|
3003
|
-
opacity:
|
|
3134
|
+
cursor: E ? "not-allowed" : "pointer",
|
|
3135
|
+
opacity: E ? 0.6 : 1,
|
|
3004
3136
|
textAlign: "left",
|
|
3005
3137
|
fontFamily: "inherit",
|
|
3006
3138
|
transition: "border-color .15s, background .15s"
|
|
3007
3139
|
},
|
|
3008
3140
|
children: [
|
|
3009
3141
|
/* @__PURE__ */ n("div", { children: [
|
|
3010
|
-
/* @__PURE__ */ e("div", { style: { fontSize: 14, fontWeight: 600, color: "#0f172a" }, children:
|
|
3011
|
-
/* @__PURE__ */ e("div", { style: { fontSize: 11, color: "#94a3b8", fontFamily: "monospace", marginTop: 2 }, children:
|
|
3142
|
+
/* @__PURE__ */ e("div", { style: { fontSize: 14, fontWeight: 600, color: "#0f172a" }, children: h.name }),
|
|
3143
|
+
/* @__PURE__ */ e("div", { style: { fontSize: 11, color: "#94a3b8", fontFamily: "monospace", marginTop: 2 }, children: h.id })
|
|
3012
3144
|
] }),
|
|
3013
|
-
/* @__PURE__ */ e("span", { style: { fontSize: 13, color: "#2563eb", fontWeight: 500 }, children:
|
|
3145
|
+
/* @__PURE__ */ e("span", { style: { fontSize: 13, color: "#2563eb", fontWeight: 500 }, children: E ? "Đang kết nối…" : "Chọn →" })
|
|
3014
3146
|
]
|
|
3015
3147
|
},
|
|
3016
|
-
|
|
3148
|
+
h.id
|
|
3017
3149
|
)) }) })
|
|
3018
3150
|
] })
|
|
3019
3151
|
] });
|
|
3020
3152
|
}
|
|
3021
|
-
function
|
|
3153
|
+
function $n(t) {
|
|
3022
3154
|
const i = t.metadata;
|
|
3023
3155
|
if (typeof i.pictureUrl == "string") return i.pictureUrl;
|
|
3024
3156
|
if (t.provider === "facebook")
|
|
3025
3157
|
return `https://graph.facebook.com/${t.externalAccountId}/picture?type=square`;
|
|
3026
3158
|
if (t.provider === "instagram") {
|
|
3027
|
-
const
|
|
3028
|
-
if (
|
|
3159
|
+
const o = typeof i.pageId == "string" ? i.pageId : null;
|
|
3160
|
+
if (o) return `https://graph.facebook.com/${o}/picture?type=square`;
|
|
3029
3161
|
}
|
|
3030
3162
|
return null;
|
|
3031
3163
|
}
|
|
3032
|
-
function
|
|
3033
|
-
const [
|
|
3034
|
-
return
|
|
3164
|
+
function Bn({ conn: t, apiUrl: i, size: o = 40 }) {
|
|
3165
|
+
const [r, c] = u(!1), C = $n(t), y = Math.round(o * 0.28);
|
|
3166
|
+
return C && !r ? /* @__PURE__ */ e(
|
|
3035
3167
|
"img",
|
|
3036
3168
|
{
|
|
3037
|
-
src:
|
|
3038
|
-
alt:
|
|
3169
|
+
src: C,
|
|
3170
|
+
alt: mt(t),
|
|
3039
3171
|
referrerPolicy: "no-referrer",
|
|
3040
|
-
onError: () =>
|
|
3041
|
-
style: { width:
|
|
3172
|
+
onError: () => c(!0),
|
|
3173
|
+
style: { width: o, height: o, borderRadius: y, objectFit: "cover", flexShrink: 0, display: "block" }
|
|
3042
3174
|
}
|
|
3043
|
-
) : /* @__PURE__ */ e(
|
|
3175
|
+
) : /* @__PURE__ */ e(Ce, { provider: t.provider, apiUrl: i, size: o });
|
|
3044
3176
|
}
|
|
3045
|
-
function
|
|
3046
|
-
const [
|
|
3047
|
-
|
|
3177
|
+
function Ln({ conn: t, apiUrl: i, onDisconnect: o }) {
|
|
3178
|
+
const [r, c] = u(!1), [C, y] = u(!1), [L, w] = u(!1), g = t.provider === "livechat", $ = i.replace(/\/$/, ""), T = g ? `<script src="${$}/static/livechat.js" data-widget-id="${t.id}" defer><\/script>` : null, E = () => {
|
|
3179
|
+
T && navigator.clipboard.writeText(T).then(() => {
|
|
3048
3180
|
w(!0), setTimeout(() => w(!1), 2e3);
|
|
3049
3181
|
});
|
|
3050
3182
|
};
|
|
3051
3183
|
return /* @__PURE__ */ n("div", { style: { ...s.channelItem, flexDirection: "column", alignItems: "stretch", gap: 0 }, children: [
|
|
3052
3184
|
/* @__PURE__ */ n("div", { style: { display: "flex", alignItems: "center", gap: 12 }, children: [
|
|
3053
|
-
/* @__PURE__ */ e(
|
|
3185
|
+
/* @__PURE__ */ e(Bn, { conn: t, apiUrl: i, size: 40 }),
|
|
3054
3186
|
/* @__PURE__ */ n("div", { style: s.channelInfo, children: [
|
|
3055
|
-
/* @__PURE__ */ e("div", { style: s.channelName, children:
|
|
3056
|
-
/* @__PURE__ */ e("div", { style: { ...s.channelMeta, userSelect: "text" }, children:
|
|
3187
|
+
/* @__PURE__ */ e("div", { style: s.channelName, children: mt(t) }),
|
|
3188
|
+
/* @__PURE__ */ e("div", { style: { ...s.channelMeta, userSelect: "text" }, children: zn(t) })
|
|
3057
3189
|
] }),
|
|
3058
3190
|
/* @__PURE__ */ n("div", { style: s.channelActions, children: [
|
|
3059
3191
|
/* @__PURE__ */ e("span", { style: t.status === "active" ? s.badgeActive : s.badgeInactive, children: t.status === "active" ? "Hoạt động" : t.status }),
|
|
3060
|
-
|
|
3192
|
+
g && /* @__PURE__ */ e(
|
|
3061
3193
|
"button",
|
|
3062
3194
|
{
|
|
3063
3195
|
style: {
|
|
3064
3196
|
...s.disconnectBtn,
|
|
3065
|
-
...
|
|
3197
|
+
...C ? { background: "#ede9fe", borderColor: "#c4b5fd", color: "#7c3aed" } : {}
|
|
3066
3198
|
},
|
|
3067
|
-
onClick: () =>
|
|
3199
|
+
onClick: () => y((M) => !M),
|
|
3068
3200
|
children: "Mã nhúng"
|
|
3069
3201
|
}
|
|
3070
3202
|
),
|
|
@@ -3073,17 +3205,17 @@ function vn({ conn: t, apiUrl: i, onDisconnect: r }) {
|
|
|
3073
3205
|
{
|
|
3074
3206
|
style: {
|
|
3075
3207
|
...s.disconnectBtn,
|
|
3076
|
-
...
|
|
3208
|
+
...r ? { background: "#fef2f2", borderColor: "#fca5a5", color: "#dc2626" } : {}
|
|
3077
3209
|
},
|
|
3078
|
-
onMouseEnter: () =>
|
|
3079
|
-
onMouseLeave: () =>
|
|
3080
|
-
onClick:
|
|
3210
|
+
onMouseEnter: () => c(!0),
|
|
3211
|
+
onMouseLeave: () => c(!1),
|
|
3212
|
+
onClick: o,
|
|
3081
3213
|
children: "Ngắt kết nối"
|
|
3082
3214
|
}
|
|
3083
3215
|
)
|
|
3084
3216
|
] })
|
|
3085
3217
|
] }),
|
|
3086
|
-
|
|
3218
|
+
g && C && T && /* @__PURE__ */ n("div", { style: { marginTop: 10, borderTop: "1px solid #f1f5f9", paddingTop: 10 }, children: [
|
|
3087
3219
|
/* @__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
3220
|
/* @__PURE__ */ n("div", { style: { position: "relative" }, children: [
|
|
3089
3221
|
/* @__PURE__ */ e("pre", { style: {
|
|
@@ -3098,11 +3230,11 @@ function vn({ conn: t, apiUrl: i, onDisconnect: r }) {
|
|
|
3098
3230
|
fontFamily: "ui-monospace, SFMono-Regular, monospace",
|
|
3099
3231
|
lineHeight: 1.5,
|
|
3100
3232
|
userSelect: "text"
|
|
3101
|
-
}, children:
|
|
3233
|
+
}, children: T }),
|
|
3102
3234
|
/* @__PURE__ */ e(
|
|
3103
3235
|
"button",
|
|
3104
3236
|
{
|
|
3105
|
-
onClick:
|
|
3237
|
+
onClick: E,
|
|
3106
3238
|
style: {
|
|
3107
3239
|
position: "absolute",
|
|
3108
3240
|
top: 6,
|
|
@@ -3112,39 +3244,39 @@ function vn({ conn: t, apiUrl: i, onDisconnect: r }) {
|
|
|
3112
3244
|
padding: "3px 10px",
|
|
3113
3245
|
borderRadius: 6,
|
|
3114
3246
|
border: "1px solid",
|
|
3115
|
-
borderColor:
|
|
3116
|
-
background:
|
|
3117
|
-
color:
|
|
3247
|
+
borderColor: L ? "#059669" : "#c4b5fd",
|
|
3248
|
+
background: L ? "#d1fae5" : "#fff",
|
|
3249
|
+
color: L ? "#059669" : "#7c3aed",
|
|
3118
3250
|
cursor: "pointer"
|
|
3119
3251
|
},
|
|
3120
|
-
children:
|
|
3252
|
+
children: L ? "✓ Đã sao chép" : "Sao chép"
|
|
3121
3253
|
}
|
|
3122
3254
|
)
|
|
3123
3255
|
] })
|
|
3124
3256
|
] })
|
|
3125
3257
|
] });
|
|
3126
3258
|
}
|
|
3127
|
-
const
|
|
3259
|
+
const Mn = [
|
|
3128
3260
|
{ id: "facebook", name: "Facebook", desc: "Fanpage & Messenger", type: "oauth" },
|
|
3129
3261
|
{ id: "zalo", name: "Zalo OA", desc: "Official Account", type: "oauth" },
|
|
3130
3262
|
{ id: "instagram", name: "Instagram", desc: "DM & Comments", type: "oauth" },
|
|
3131
3263
|
{ id: "telegram", name: "Telegram", desc: "Bot token", type: "token" },
|
|
3132
3264
|
{ id: "livechat", name: "Live Chat", desc: "Website widget", type: "livechat" }
|
|
3133
3265
|
];
|
|
3134
|
-
function
|
|
3135
|
-
const [
|
|
3266
|
+
function Hn({ provider: t, apiUrl: i, onClick: o }) {
|
|
3267
|
+
const [r, c] = u(!1);
|
|
3136
3268
|
return /* @__PURE__ */ n(
|
|
3137
3269
|
"div",
|
|
3138
3270
|
{
|
|
3139
3271
|
style: {
|
|
3140
3272
|
...s.providerCard,
|
|
3141
|
-
...
|
|
3273
|
+
...r ? { background: "#fff", borderColor: "#e2e8f0", boxShadow: "0 2px 8px rgba(0,0,0,.07)", transform: "translateY(-1px)" } : {}
|
|
3142
3274
|
},
|
|
3143
|
-
onClick:
|
|
3144
|
-
onMouseEnter: () =>
|
|
3145
|
-
onMouseLeave: () =>
|
|
3275
|
+
onClick: o,
|
|
3276
|
+
onMouseEnter: () => c(!0),
|
|
3277
|
+
onMouseLeave: () => c(!1),
|
|
3146
3278
|
children: [
|
|
3147
|
-
/* @__PURE__ */ e(
|
|
3279
|
+
/* @__PURE__ */ e(Ce, { provider: t.id, apiUrl: i, size: 44 }),
|
|
3148
3280
|
/* @__PURE__ */ n("div", { children: [
|
|
3149
3281
|
/* @__PURE__ */ e("div", { style: s.providerName, children: t.name }),
|
|
3150
3282
|
/* @__PURE__ */ e("div", { style: s.providerDesc, children: t.desc })
|
|
@@ -3153,7 +3285,7 @@ function wn({ provider: t, apiUrl: i, onClick: r }) {
|
|
|
3153
3285
|
}
|
|
3154
3286
|
);
|
|
3155
3287
|
}
|
|
3156
|
-
function
|
|
3288
|
+
function lt({ done: t, active: i, label: o }) {
|
|
3157
3289
|
return /* @__PURE__ */ n("div", { style: { display: "flex", alignItems: "center", gap: 10, fontSize: 13, color: t ? "#059669" : i ? "#0f172a" : "#94a3b8" }, children: [
|
|
3158
3290
|
/* @__PURE__ */ e("div", { style: {
|
|
3159
3291
|
width: 10,
|
|
@@ -3163,60 +3295,60 @@ function Qe({ done: t, active: i, label: r }) {
|
|
|
3163
3295
|
flexShrink: 0,
|
|
3164
3296
|
...i ? { boxShadow: "0 0 0 3px rgba(37,99,235,.2)" } : {}
|
|
3165
3297
|
} }),
|
|
3166
|
-
|
|
3298
|
+
o
|
|
3167
3299
|
] });
|
|
3168
3300
|
}
|
|
3169
|
-
function
|
|
3301
|
+
function An(t) {
|
|
3170
3302
|
return t.split(/\s+/).filter(Boolean).slice(-2).map((i) => i[0]).join("").toUpperCase() || "?";
|
|
3171
3303
|
}
|
|
3172
|
-
function
|
|
3304
|
+
function jn(t) {
|
|
3173
3305
|
if (!t) return "";
|
|
3174
3306
|
const i = new Date(t);
|
|
3175
3307
|
return i.toDateString() === (/* @__PURE__ */ new Date()).toDateString() ? i.toLocaleTimeString("vi-VN", { hour: "2-digit", minute: "2-digit" }) : i.toLocaleDateString("vi-VN", { day: "2-digit", month: "2-digit" });
|
|
3176
3308
|
}
|
|
3177
|
-
function
|
|
3309
|
+
function Fn({
|
|
3178
3310
|
apiUrl: t,
|
|
3179
3311
|
token: i,
|
|
3180
|
-
theme:
|
|
3181
|
-
locale:
|
|
3182
|
-
icon:
|
|
3183
|
-
onConversationSelect:
|
|
3312
|
+
theme: o,
|
|
3313
|
+
locale: r = "vi",
|
|
3314
|
+
icon: c,
|
|
3315
|
+
onConversationSelect: C
|
|
3184
3316
|
}) {
|
|
3185
|
-
const
|
|
3317
|
+
const y = (o == null ? void 0 : o.primaryColor) ?? "#2563eb", L = typeof c == "function" ? c({ size: 20, color: "currentColor" }) : c ?? /* @__PURE__ */ e(St, { size: 20, strokeWidth: 1.8 }), w = X(new ht(t, i)), [g, $] = u(!1), [T, E] = u([]), M = X(null), I = X(null), q = T.filter((B) => (B.unreadCount ?? 0) > 0), R = q.reduce((B, b) => B + (b.unreadCount ?? 0), 0), H = Te(async () => {
|
|
3186
3318
|
try {
|
|
3187
|
-
const
|
|
3188
|
-
|
|
3319
|
+
const B = await w.current.listConversations();
|
|
3320
|
+
E(B.items);
|
|
3189
3321
|
} catch {
|
|
3190
3322
|
}
|
|
3191
3323
|
}, []);
|
|
3192
|
-
|
|
3193
|
-
(
|
|
3194
|
-
})), [
|
|
3195
|
-
if (!
|
|
3196
|
-
const
|
|
3197
|
-
var
|
|
3198
|
-
(
|
|
3324
|
+
K(() => (H(), w.current.connectSSE((b) => {
|
|
3325
|
+
(b === "message.new" || b === "conversation.updated") && H();
|
|
3326
|
+
})), [H]), K(() => {
|
|
3327
|
+
if (!g) return;
|
|
3328
|
+
const B = (b) => {
|
|
3329
|
+
var S, D;
|
|
3330
|
+
(S = M.current) != null && S.contains(b.target) || (D = I.current) != null && D.contains(b.target) || $(!1);
|
|
3199
3331
|
};
|
|
3200
|
-
return document.addEventListener("mousedown",
|
|
3201
|
-
}, [
|
|
3202
|
-
const
|
|
3203
|
-
if (
|
|
3332
|
+
return document.addEventListener("mousedown", B), () => document.removeEventListener("mousedown", B);
|
|
3333
|
+
}, [g]);
|
|
3334
|
+
const J = async (B) => {
|
|
3335
|
+
if ($(!1), C == null || C(B.id, B), (B.unreadCount ?? 0) > 0)
|
|
3204
3336
|
try {
|
|
3205
|
-
await w.current.markRead(
|
|
3206
|
-
(
|
|
3337
|
+
await w.current.markRead(B.id), E(
|
|
3338
|
+
(b) => b.map((S) => S.id === B.id ? { ...S, unreadCount: 0 } : S)
|
|
3207
3339
|
);
|
|
3208
3340
|
} catch {
|
|
3209
3341
|
}
|
|
3210
|
-
},
|
|
3211
|
-
return /* @__PURE__ */ n("div", { style: { position: "relative", display: "inline-block", fontFamily: (
|
|
3342
|
+
}, F = r === "en" ? `${R} unread message${R !== 1 ? "s" : ""}` : `${R} tin nhắn chưa đọc`, re = r === "en" ? "No unread messages" : "Không có tin nhắn mới", V = r === "en" ? "Messages" : "Tin nhắn";
|
|
3343
|
+
return /* @__PURE__ */ n("div", { style: { position: "relative", display: "inline-block", fontFamily: (o == null ? void 0 : o.fontFamily) ?? "Inter, ui-sans-serif, system-ui, sans-serif" }, children: [
|
|
3212
3344
|
/* @__PURE__ */ n(
|
|
3213
3345
|
"button",
|
|
3214
3346
|
{
|
|
3215
|
-
ref:
|
|
3216
|
-
"aria-label":
|
|
3347
|
+
ref: M,
|
|
3348
|
+
"aria-label": F,
|
|
3217
3349
|
"aria-haspopup": "true",
|
|
3218
|
-
"aria-expanded":
|
|
3219
|
-
onClick: () =>
|
|
3350
|
+
"aria-expanded": g,
|
|
3351
|
+
onClick: () => $((B) => !B),
|
|
3220
3352
|
style: {
|
|
3221
3353
|
position: "relative",
|
|
3222
3354
|
display: "inline-grid",
|
|
@@ -3225,14 +3357,14 @@ function Bn({
|
|
|
3225
3357
|
height: 40,
|
|
3226
3358
|
border: 0,
|
|
3227
3359
|
borderRadius: "50%",
|
|
3228
|
-
background:
|
|
3229
|
-
color:
|
|
3360
|
+
background: g ? `${y}18` : "transparent",
|
|
3361
|
+
color: g ? y : "#6b7280",
|
|
3230
3362
|
cursor: "pointer",
|
|
3231
3363
|
transition: "background 150ms ease, color 150ms ease"
|
|
3232
3364
|
},
|
|
3233
3365
|
children: [
|
|
3234
|
-
|
|
3235
|
-
|
|
3366
|
+
L,
|
|
3367
|
+
R > 0 && /* @__PURE__ */ e(
|
|
3236
3368
|
"span",
|
|
3237
3369
|
{
|
|
3238
3370
|
"aria-hidden": "true",
|
|
@@ -3253,18 +3385,18 @@ function Bn({
|
|
|
3253
3385
|
border: "2px solid #fff",
|
|
3254
3386
|
boxSizing: "border-box"
|
|
3255
3387
|
},
|
|
3256
|
-
children:
|
|
3388
|
+
children: R > 99 ? "99+" : R
|
|
3257
3389
|
}
|
|
3258
3390
|
)
|
|
3259
3391
|
]
|
|
3260
3392
|
}
|
|
3261
3393
|
),
|
|
3262
|
-
|
|
3394
|
+
g && /* @__PURE__ */ n(
|
|
3263
3395
|
"div",
|
|
3264
3396
|
{
|
|
3265
|
-
ref:
|
|
3397
|
+
ref: I,
|
|
3266
3398
|
role: "dialog",
|
|
3267
|
-
"aria-label":
|
|
3399
|
+
"aria-label": V,
|
|
3268
3400
|
style: {
|
|
3269
3401
|
position: "absolute",
|
|
3270
3402
|
top: "calc(100% + 8px)",
|
|
@@ -3288,21 +3420,21 @@ function Bn({
|
|
|
3288
3420
|
padding: "14px 16px 10px",
|
|
3289
3421
|
borderBottom: "1px solid #e7ebf2"
|
|
3290
3422
|
}, children: [
|
|
3291
|
-
/* @__PURE__ */ e("span", { style: { fontSize: 16, fontWeight: 700, color: "#172033" }, children:
|
|
3292
|
-
|
|
3423
|
+
/* @__PURE__ */ e("span", { style: { fontSize: 16, fontWeight: 700, color: "#172033" }, children: V }),
|
|
3424
|
+
R > 0 && /* @__PURE__ */ n("span", { style: {
|
|
3293
3425
|
fontSize: 11,
|
|
3294
3426
|
fontWeight: 600,
|
|
3295
|
-
background: `${
|
|
3296
|
-
color:
|
|
3427
|
+
background: `${y}14`,
|
|
3428
|
+
color: y,
|
|
3297
3429
|
borderRadius: 999,
|
|
3298
3430
|
padding: "2px 8px"
|
|
3299
3431
|
}, children: [
|
|
3300
|
-
|
|
3432
|
+
R,
|
|
3301
3433
|
" ",
|
|
3302
|
-
|
|
3434
|
+
r === "en" ? "unread" : "chưa đọc"
|
|
3303
3435
|
] })
|
|
3304
3436
|
] }),
|
|
3305
|
-
/* @__PURE__ */ e("div", { style: { overflowY: "auto", flex: 1 }, children:
|
|
3437
|
+
/* @__PURE__ */ e("div", { style: { overflowY: "auto", flex: 1 }, children: q.length === 0 ? /* @__PURE__ */ n("div", { style: {
|
|
3306
3438
|
display: "flex",
|
|
3307
3439
|
flexDirection: "column",
|
|
3308
3440
|
alignItems: "center",
|
|
@@ -3310,36 +3442,36 @@ function Bn({
|
|
|
3310
3442
|
padding: "40px 24px",
|
|
3311
3443
|
color: "#9aa5b5"
|
|
3312
3444
|
}, children: [
|
|
3313
|
-
/* @__PURE__ */ e(
|
|
3314
|
-
/* @__PURE__ */ e("span", { style: { fontSize: 13 }, children:
|
|
3315
|
-
] }) :
|
|
3316
|
-
|
|
3445
|
+
/* @__PURE__ */ e(St, { size: 28, strokeWidth: 1.5 }),
|
|
3446
|
+
/* @__PURE__ */ e("span", { style: { fontSize: 13 }, children: re })
|
|
3447
|
+
] }) : q.map((B) => /* @__PURE__ */ e(
|
|
3448
|
+
En,
|
|
3317
3449
|
{
|
|
3318
|
-
conversation:
|
|
3319
|
-
primary:
|
|
3450
|
+
conversation: B,
|
|
3451
|
+
primary: y,
|
|
3320
3452
|
apiUrl: t,
|
|
3321
|
-
onSelect:
|
|
3453
|
+
onSelect: J
|
|
3322
3454
|
},
|
|
3323
|
-
|
|
3455
|
+
B.id
|
|
3324
3456
|
)) })
|
|
3325
3457
|
]
|
|
3326
3458
|
}
|
|
3327
3459
|
)
|
|
3328
3460
|
] });
|
|
3329
3461
|
}
|
|
3330
|
-
function
|
|
3462
|
+
function En({
|
|
3331
3463
|
conversation: t,
|
|
3332
3464
|
primary: i,
|
|
3333
|
-
apiUrl:
|
|
3334
|
-
onSelect:
|
|
3465
|
+
apiUrl: o,
|
|
3466
|
+
onSelect: r
|
|
3335
3467
|
}) {
|
|
3336
|
-
const [
|
|
3468
|
+
const [c, C] = u(!1), y = t.contactName ?? t.providerConversationKey, L = t.unreadCount ?? 0;
|
|
3337
3469
|
return /* @__PURE__ */ n(
|
|
3338
3470
|
"button",
|
|
3339
3471
|
{
|
|
3340
|
-
onClick: () =>
|
|
3341
|
-
onMouseEnter: () =>
|
|
3342
|
-
onMouseLeave: () =>
|
|
3472
|
+
onClick: () => r(t),
|
|
3473
|
+
onMouseEnter: () => C(!0),
|
|
3474
|
+
onMouseLeave: () => C(!1),
|
|
3343
3475
|
style: {
|
|
3344
3476
|
display: "flex",
|
|
3345
3477
|
width: "100%",
|
|
@@ -3347,7 +3479,7 @@ function In({
|
|
|
3347
3479
|
padding: "10px 16px",
|
|
3348
3480
|
border: 0,
|
|
3349
3481
|
borderBottom: "1px solid #f1f5f9",
|
|
3350
|
-
background:
|
|
3482
|
+
background: c ? "#f7f9fc" : L > 0 ? "#f0f4ff" : "#fff",
|
|
3351
3483
|
textAlign: "left",
|
|
3352
3484
|
cursor: "pointer",
|
|
3353
3485
|
transition: "background 100ms ease",
|
|
@@ -3356,10 +3488,10 @@ function In({
|
|
|
3356
3488
|
children: [
|
|
3357
3489
|
/* @__PURE__ */ n("span", { style: { position: "relative", flex: "0 0 auto", width: 42, height: 42 }, children: [
|
|
3358
3490
|
/* @__PURE__ */ e(
|
|
3359
|
-
|
|
3491
|
+
bt,
|
|
3360
3492
|
{
|
|
3361
3493
|
src: t.contactPictureUrl,
|
|
3362
|
-
fallback:
|
|
3494
|
+
fallback: An(y),
|
|
3363
3495
|
style: {
|
|
3364
3496
|
width: 42,
|
|
3365
3497
|
height: 42,
|
|
@@ -3380,15 +3512,15 @@ function In({
|
|
|
3380
3512
|
/* @__PURE__ */ n("span", { style: { display: "flex", justifyContent: "space-between", alignItems: "center", gap: 6 }, children: [
|
|
3381
3513
|
/* @__PURE__ */ e("span", { style: {
|
|
3382
3514
|
fontSize: 13,
|
|
3383
|
-
fontWeight:
|
|
3515
|
+
fontWeight: L > 0 ? 700 : 500,
|
|
3384
3516
|
color: "#172033",
|
|
3385
3517
|
overflow: "hidden",
|
|
3386
3518
|
textOverflow: "ellipsis",
|
|
3387
3519
|
whiteSpace: "nowrap"
|
|
3388
|
-
}, children:
|
|
3520
|
+
}, children: y }),
|
|
3389
3521
|
/* @__PURE__ */ n("span", { style: { display: "flex", alignItems: "center", gap: 5, flexShrink: 0 }, children: [
|
|
3390
|
-
/* @__PURE__ */ e("time", { style: { fontSize: 11, color: "#9aa5b5", whiteSpace: "nowrap" }, children:
|
|
3391
|
-
|
|
3522
|
+
/* @__PURE__ */ e("time", { style: { fontSize: 11, color: "#9aa5b5", whiteSpace: "nowrap" }, children: jn(t.lastMessageAt) }),
|
|
3523
|
+
L > 0 && /* @__PURE__ */ e("span", { style: {
|
|
3392
3524
|
display: "inline-grid",
|
|
3393
3525
|
placeItems: "center",
|
|
3394
3526
|
minWidth: 18,
|
|
@@ -3399,15 +3531,15 @@ function In({
|
|
|
3399
3531
|
fontSize: 10,
|
|
3400
3532
|
fontWeight: 800,
|
|
3401
3533
|
padding: "0 4px"
|
|
3402
|
-
}, children:
|
|
3534
|
+
}, children: L > 99 ? "99+" : L })
|
|
3403
3535
|
] })
|
|
3404
3536
|
] }),
|
|
3405
3537
|
/* @__PURE__ */ n("span", { style: {
|
|
3406
3538
|
display: "block",
|
|
3407
3539
|
marginTop: 2,
|
|
3408
3540
|
fontSize: 12,
|
|
3409
|
-
color:
|
|
3410
|
-
fontWeight:
|
|
3541
|
+
color: L > 0 ? "#374151" : "#9aa5b5",
|
|
3542
|
+
fontWeight: L > 0 ? 500 : 400,
|
|
3411
3543
|
overflow: "hidden",
|
|
3412
3544
|
textOverflow: "ellipsis",
|
|
3413
3545
|
whiteSpace: "nowrap"
|
|
@@ -3420,10 +3552,10 @@ function In({
|
|
|
3420
3552
|
}
|
|
3421
3553
|
);
|
|
3422
3554
|
}
|
|
3423
|
-
console.log("[ChannelHub] widget v0.1.
|
|
3555
|
+
console.log("[ChannelHub] widget v0.1.12 loaded");
|
|
3424
3556
|
export {
|
|
3425
|
-
|
|
3426
|
-
|
|
3427
|
-
|
|
3428
|
-
|
|
3557
|
+
Pn as ChannelHubChannels,
|
|
3558
|
+
ht as ChannelHubClient,
|
|
3559
|
+
Nn as ChannelHubInbox,
|
|
3560
|
+
Fn as ChannelHubNotificationBell
|
|
3429
3561
|
};
|