@channelhub/widget 0.1.8 → 0.1.10

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