@veploy/ploychat 0.1.0

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 ADDED
@@ -0,0 +1,2158 @@
1
+ "use client";
2
+
3
+ // src/components/App.jsx
4
+ import { useMemo as useMemo2, useRef as useRef3, useState as useState4, useEffect as useEffect4 } from "react";
5
+
6
+ // src/lib/useInbox.js
7
+ import { useCallback, useEffect, useRef, useState } from "react";
8
+
9
+ // src/lib/context.jsx
10
+ import { createContext, useContext, useMemo } from "react";
11
+
12
+ // src/lib/client.js
13
+ import { createClient } from "@supabase/supabase-js";
14
+ function createPloyClient(config = {}) {
15
+ const apiBase = (config.apiBase || "").replace(/\/+$/, "");
16
+ async function apiFetch(path, { method = "GET", body } = {}) {
17
+ const headers = {};
18
+ if (body) headers["Content-Type"] = "application/json";
19
+ const token = config.getToken ? await config.getToken() : null;
20
+ if (token) headers["Authorization"] = `Bearer ${token}`;
21
+ if (config.workspaceId) headers["X-Workspace"] = config.workspaceId;
22
+ const res = await fetch(`${apiBase}${path}`, {
23
+ method,
24
+ headers,
25
+ body: body ? JSON.stringify(body) : void 0
26
+ });
27
+ const txt = await res.text();
28
+ let json;
29
+ try {
30
+ json = txt ? JSON.parse(txt) : null;
31
+ } catch {
32
+ json = txt;
33
+ }
34
+ if (!res.ok) {
35
+ const err = new Error((json == null ? void 0 : json.message) || (json == null ? void 0 : json.error) || `HTTP ${res.status}`);
36
+ err.status = res.status;
37
+ err.body = json;
38
+ throw err;
39
+ }
40
+ return json;
41
+ }
42
+ let supabase = config.supabase || null;
43
+ if (!supabase && config.supabaseUrl && config.supabaseAnonKey) {
44
+ supabase = createClient(config.supabaseUrl, config.supabaseAnonKey, {
45
+ auth: { persistSession: false, autoRefreshToken: false }
46
+ });
47
+ }
48
+ const live = !!(config.apiBase && config.workspaceId && config.getToken);
49
+ return { apiFetch, supabase, live };
50
+ }
51
+
52
+ // src/lib/context.jsx
53
+ import { jsx } from "react/jsx-runtime";
54
+ var PloyContext = createContext(null);
55
+ function PloyConfigProvider({ config, children }) {
56
+ const value = useMemo(() => {
57
+ const client = createPloyClient(config);
58
+ return { config, client };
59
+ }, [config.apiBase, config.workspaceId, config.getToken, config.supabase, config.supabaseUrl, config.supabaseAnonKey]);
60
+ return /* @__PURE__ */ jsx(PloyContext.Provider, { value, children });
61
+ }
62
+ function usePloy() {
63
+ const ctx = useContext(PloyContext);
64
+ if (!ctx) throw new Error("PloyChat components must be used within <PloyChat>");
65
+ return ctx;
66
+ }
67
+
68
+ // src/lib/mappers.js
69
+ var PALETTE = ["bg-violet-500", "bg-rose-500", "bg-sky-500", "bg-amber-500", "bg-emerald-600", "bg-slate-700"];
70
+ function hash(s = "") {
71
+ let h = 0;
72
+ for (let i = 0; i < s.length; i++) h = h * 31 + s.charCodeAt(i) >>> 0;
73
+ return h;
74
+ }
75
+ function colorFor(id = "") {
76
+ return PALETTE[hash(id) % PALETTE.length];
77
+ }
78
+ var pad = (n) => String(n).padStart(2, "0");
79
+ function timeOf(iso) {
80
+ if (!iso) return "";
81
+ const d = new Date(iso);
82
+ return `${pad(d.getHours())}:${pad(d.getMinutes())}`;
83
+ }
84
+ function dayOf(iso) {
85
+ if (!iso) return "";
86
+ const d = new Date(iso);
87
+ const now = /* @__PURE__ */ new Date();
88
+ if (d.toDateString() === now.toDateString()) return "Hoje";
89
+ const y = new Date(now);
90
+ y.setDate(now.getDate() - 1);
91
+ if (d.toDateString() === y.toDateString()) return "Ontem";
92
+ return d.toLocaleDateString("pt-BR");
93
+ }
94
+ function relTime(iso) {
95
+ if (!iso) return "";
96
+ const m = Math.floor((Date.now() - new Date(iso).getTime()) / 6e4);
97
+ if (m < 1) return "agora";
98
+ if (m < 60) return `${m}m`;
99
+ const h = Math.floor(m / 60);
100
+ if (h < 24) return `${h}h`;
101
+ return `${Math.floor(h / 24)}d`;
102
+ }
103
+ function nowHHMM() {
104
+ const d = /* @__PURE__ */ new Date();
105
+ return `${pad(d.getHours())}:${pad(d.getMinutes())}`;
106
+ }
107
+ var STATUS_MAP = { open: "open", pending: "in_progress", resolved: "resolved", snoozed: "waiting" };
108
+ function mapConversation(c) {
109
+ const contact = c.contact || {};
110
+ const name = contact.name || contact.push_name || contact.phone_e164 || contact.external_id || "Contato";
111
+ return {
112
+ id: c.id,
113
+ name,
114
+ phone: contact.phone_e164 || "",
115
+ avatarColor: colorFor(c.id),
116
+ preview: c.last_message_preview || "",
117
+ waitFor: relTime(c.last_message_at),
118
+ unread: c.unread_count || 0,
119
+ sla: "ok",
120
+ priority: c.priority || "normal",
121
+ status: STATUS_MAP[c.status] || "open",
122
+ ticket: c.property_ref ? `REF ${c.property_ref}` : `#${String(c.id).slice(0, 4)}`,
123
+ starred: false,
124
+ _raw: c
125
+ };
126
+ }
127
+ function mapMessage(m) {
128
+ const ts = m.sent_at || m.created_at;
129
+ if (m.kind === "note") {
130
+ return { id: m.id, side: "note", kind: "text", text: m.text || "", time: timeOf(ts), day: dayOf(ts), author: m.author_name, _raw: m };
131
+ }
132
+ if (m.kind === "system") {
133
+ return { id: m.id, side: "system", kind: "text", text: m.text || "", time: timeOf(ts), day: dayOf(ts), _raw: m };
134
+ }
135
+ let kind = m.kind || "text";
136
+ let text = m.text || "";
137
+ if (!["text", "image", "audio", "video", "document"].includes(kind)) {
138
+ text = m.text || m.caption || `[${kind}]`;
139
+ kind = "text";
140
+ }
141
+ return {
142
+ id: m.id,
143
+ side: m.direction,
144
+ // 'in' | 'out'
145
+ kind,
146
+ text,
147
+ caption: m.caption || "",
148
+ meta: m.media_mime || "",
149
+ mediaUrl: m.media_url || "",
150
+ time: timeOf(ts),
151
+ day: dayOf(ts),
152
+ status: m.status,
153
+ _raw: m
154
+ };
155
+ }
156
+
157
+ // src/lib/useInbox.js
158
+ function useInbox() {
159
+ const { client } = usePloy();
160
+ const live = client.live;
161
+ const [conversations2, setConversations] = useState([]);
162
+ const [activeId, setActiveId] = useState(null);
163
+ const [messages, setMessages] = useState([]);
164
+ const [channels, setChannels] = useState([]);
165
+ const [agents, setAgents] = useState([]);
166
+ const [me, setMe] = useState(null);
167
+ const [tenantId, setTenantId] = useState(null);
168
+ const [loading, setLoading] = useState(live);
169
+ const [error, setError] = useState(null);
170
+ const activeIdRef = useRef(null);
171
+ activeIdRef.current = activeId;
172
+ const api = client.apiFetch;
173
+ useEffect(() => {
174
+ if (!live) return;
175
+ api("/v1/me").then((m) => {
176
+ var _a;
177
+ if ((_a = m == null ? void 0 : m.user) == null ? void 0 : _a.id) setMe(m.user.id);
178
+ if (m == null ? void 0 : m.tenant_id) setTenantId(m.tenant_id);
179
+ }).catch(() => {
180
+ });
181
+ }, [live, api]);
182
+ const loadConversations = useCallback(async () => {
183
+ if (!live) return;
184
+ try {
185
+ const data = await api("/v1/conversations?limit=50");
186
+ const mapped = (data || []).map(mapConversation);
187
+ setConversations(mapped);
188
+ setActiveId((a) => {
189
+ var _a;
190
+ return a || ((_a = mapped[0]) == null ? void 0 : _a.id) || null;
191
+ });
192
+ } catch (e) {
193
+ setError(e.message);
194
+ } finally {
195
+ setLoading(false);
196
+ }
197
+ }, [live, api]);
198
+ const loadMessages = useCallback(async (convId) => {
199
+ if (!live || !convId) return;
200
+ try {
201
+ const res = await api(`/v1/conversations/${convId}/messages?limit=50`);
202
+ setMessages(((res == null ? void 0 : res.messages) || []).slice().reverse().map(mapMessage));
203
+ } catch (e) {
204
+ setError(e.message);
205
+ }
206
+ }, [live, api]);
207
+ const loadChannels = useCallback(async () => {
208
+ if (!live) return [];
209
+ try {
210
+ const l = await api("/v1/channels") || [];
211
+ setChannels(l);
212
+ return l;
213
+ } catch {
214
+ return [];
215
+ }
216
+ }, [live, api]);
217
+ const loadAgents = useCallback(async () => {
218
+ if (!live) return [];
219
+ try {
220
+ const l = await api("/v1/agents") || [];
221
+ setAgents(l);
222
+ return l;
223
+ } catch {
224
+ return [];
225
+ }
226
+ }, [live, api]);
227
+ useEffect(() => {
228
+ loadConversations();
229
+ loadChannels();
230
+ loadAgents();
231
+ }, [loadConversations, loadChannels, loadAgents]);
232
+ useEffect(() => {
233
+ loadMessages(activeId);
234
+ }, [activeId, loadMessages]);
235
+ const markRead = useCallback(async (convId) => {
236
+ if (!live || !convId) return;
237
+ setConversations((cs) => cs.map((c) => c.id === convId ? { ...c, unread: 0 } : c));
238
+ try {
239
+ await api(`/v1/conversations/${convId}/read`, { method: "POST" });
240
+ } catch {
241
+ }
242
+ }, [live, api]);
243
+ const assign = useCallback(async (convId, userId) => {
244
+ if (!live || !convId) return;
245
+ setConversations((cs) => cs.map((c) => c.id === convId ? { ...c, _raw: { ...c._raw, assignee_user_id: userId } } : c));
246
+ try {
247
+ await api(`/v1/conversations/${convId}/assign`, { method: "POST", body: { assignee_user_id: userId } });
248
+ } catch (e) {
249
+ setError(e.message);
250
+ }
251
+ }, [live, api]);
252
+ const send = useCallback(async (text, isNote = false) => {
253
+ const t = (text || "").trim();
254
+ if (!t || !live || !activeIdRef.current) return;
255
+ const tmpId = `tmp${Date.now()}`;
256
+ setMessages((ms) => [...ms, isNote ? { id: tmpId, side: "note", kind: "text", text: t, time: nowHHMM() } : { id: tmpId, side: "out", kind: "text", text: t, time: nowHHMM(), status: "pending" }]);
257
+ try {
258
+ const saved = await api(`/v1/conversations/${activeIdRef.current}/messages`, {
259
+ method: "POST",
260
+ body: isNote ? { text: t, note: true } : { text: t }
261
+ });
262
+ setMessages((ms) => ms.map((m) => m.id === tmpId ? mapMessage(saved) : m));
263
+ } catch {
264
+ setMessages((ms) => ms.map((m) => m.id === tmpId ? { ...m, status: "failed" } : m));
265
+ }
266
+ }, [live, api]);
267
+ const sendMedia = useCallback(async ({ data, mime, kind, filename, previewUrl, caption }) => {
268
+ if (!live || !activeIdRef.current || !data) return;
269
+ const tmpId = `tmp${Date.now()}`;
270
+ setMessages((ms) => [...ms, { id: tmpId, side: "out", kind, mediaUrl: previewUrl || "", caption: caption || "", meta: filename || mime || "", time: nowHHMM(), status: "pending" }]);
271
+ try {
272
+ const saved = await api(`/v1/conversations/${activeIdRef.current}/messages`, {
273
+ method: "POST",
274
+ body: { media: { data, mime, kind, filename }, caption }
275
+ });
276
+ const mapped = mapMessage(saved);
277
+ setMessages((ms) => ms.map((m) => m.id === tmpId ? { ...mapped, mediaUrl: mapped.mediaUrl || previewUrl || "" } : m));
278
+ } catch {
279
+ setMessages((ms) => ms.map((m) => m.id === tmpId ? { ...m, status: "failed" } : m));
280
+ }
281
+ }, [live, api]);
282
+ const createChannel = useCallback((displayName) => api("/v1/channels", { method: "POST", body: { display_name: displayName } }), [api]);
283
+ const connect = useCallback((id) => api(`/v1/channels/${id}/connect`, { method: "POST" }), [api]);
284
+ const channelStatus = useCallback((id) => api(`/v1/channels/${id}/status`), [api]);
285
+ useEffect(() => {
286
+ if (!live || !tenantId) return;
287
+ const sb = client.supabase;
288
+ if (!sb) return;
289
+ const ch = sb.channel(`inbox:${tenantId}`).on("broadcast", { event: "message.created" }, ({ payload }) => {
290
+ if ((payload == null ? void 0 : payload.conversation_id) === activeIdRef.current) {
291
+ setMessages((ms) => ms.some((m) => m.id === payload.id) ? ms : [...ms, mapMessage(payload)]);
292
+ }
293
+ loadConversations();
294
+ }).on("broadcast", { event: "message.updated" }, ({ payload }) => {
295
+ setMessages((ms) => ms.map((m) => m.id === (payload == null ? void 0 : payload.id) ? { ...m, status: payload.status || m.status } : m));
296
+ }).on("broadcast", { event: "conversation.updated" }, () => loadConversations()).on("broadcast", { event: "channel.updated" }, () => loadChannels()).subscribe();
297
+ return () => {
298
+ sb.removeChannel(ch);
299
+ };
300
+ }, [live, tenantId, client, loadConversations, loadChannels]);
301
+ return {
302
+ live,
303
+ loading,
304
+ error,
305
+ conversations: conversations2,
306
+ activeId,
307
+ setActiveId,
308
+ messages,
309
+ send,
310
+ sendMedia,
311
+ markRead,
312
+ assign,
313
+ me,
314
+ agents,
315
+ loadAgents,
316
+ channels,
317
+ loadChannels,
318
+ createChannel,
319
+ connect,
320
+ channelStatus
321
+ };
322
+ }
323
+
324
+ // src/components/ConnectChannel.jsx
325
+ import { useEffect as useEffect2, useRef as useRef2, useState as useState2 } from "react";
326
+ import { jsx as jsx2, jsxs } from "react/jsx-runtime";
327
+ function ConnectChannel({ inbox, onClose }) {
328
+ const [channel, setChannel] = useState2(null);
329
+ const [qr, setQr] = useState2(null);
330
+ const [status, setStatus] = useState2("idle");
331
+ const [error, setError] = useState2(null);
332
+ const [busy, setBusy] = useState2(false);
333
+ const pollRef = useRef2(null);
334
+ const asDataUrl = (q) => !q ? null : q.startsWith("data:") ? q : `data:image/png;base64,${q}`;
335
+ useEffect2(() => {
336
+ (async () => {
337
+ try {
338
+ const list = await inbox.loadChannels();
339
+ const c = (list || [])[0] || null;
340
+ setChannel(c);
341
+ if (c) setStatus(c.status);
342
+ } catch (e) {
343
+ setError(e.message);
344
+ }
345
+ })();
346
+ return () => clearInterval(pollRef.current);
347
+ }, [inbox]);
348
+ const poll = (id) => {
349
+ clearInterval(pollRef.current);
350
+ pollRef.current = setInterval(async () => {
351
+ try {
352
+ const s = await inbox.channelStatus(id);
353
+ setStatus(s.status);
354
+ if (s.status === "connected") {
355
+ clearInterval(pollRef.current);
356
+ inbox.loadChannels();
357
+ } else {
358
+ const res = await inbox.connect(id);
359
+ if (res == null ? void 0 : res.qr) setQr(asDataUrl(res.qr));
360
+ }
361
+ } catch {
362
+ }
363
+ }, 3e3);
364
+ };
365
+ const startConnect = async (ch) => {
366
+ setError(null);
367
+ setBusy(true);
368
+ setStatus("connecting");
369
+ try {
370
+ const res = await inbox.connect(ch.id);
371
+ setQr(asDataUrl(res == null ? void 0 : res.qr));
372
+ setStatus((res == null ? void 0 : res.status) || "qr");
373
+ poll(ch.id);
374
+ } catch (e) {
375
+ setError(e.message);
376
+ setStatus("error");
377
+ } finally {
378
+ setBusy(false);
379
+ }
380
+ };
381
+ const handleCreate = async () => {
382
+ setError(null);
383
+ setBusy(true);
384
+ try {
385
+ const ch = await inbox.createChannel("WhatsApp");
386
+ setChannel(ch);
387
+ await startConnect(ch);
388
+ } catch (e) {
389
+ setError(e.message);
390
+ } finally {
391
+ setBusy(false);
392
+ }
393
+ };
394
+ return /* @__PURE__ */ jsx2("div", { className: "fixed inset-0 z-50 bg-black/40 flex items-center justify-center", onClick: onClose, children: /* @__PURE__ */ jsxs("div", { className: "bg-white rounded-2xl shadow-xl w-[380px] p-5", onClick: (e) => e.stopPropagation(), children: [
395
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between mb-3", children: [
396
+ /* @__PURE__ */ jsx2("h3", { className: "font-semibold text-[15px]", children: "Conectar WhatsApp" }),
397
+ /* @__PURE__ */ jsx2("button", { onClick: onClose, className: "text-slate-400 hover:text-slate-700 text-lg leading-none", children: "\xD7" })
398
+ ] }),
399
+ error && /* @__PURE__ */ jsx2("div", { className: "text-[12px] text-rose-600 mb-2 break-words", children: error }),
400
+ status === "connected" ? /* @__PURE__ */ jsx2("div", { className: "text-center py-8 text-emerald-600 font-medium", children: "\u2713 N\xFAmero conectado" }) : qr ? /* @__PURE__ */ jsxs("div", { className: "text-center", children: [
401
+ /* @__PURE__ */ jsx2("img", { src: qr, alt: "QR Code", className: "w-56 h-56 mx-auto rounded-lg border border-slate-200" }),
402
+ /* @__PURE__ */ jsxs("p", { className: "text-[12px] text-slate-500 mt-3", children: [
403
+ "WhatsApp \u203A Aparelhos conectados \u203A Conectar um aparelho, e escaneie. (",
404
+ status,
405
+ ")"
406
+ ] })
407
+ ] }) : channel ? /* @__PURE__ */ jsxs("div", { className: "text-center py-4", children: [
408
+ /* @__PURE__ */ jsxs("p", { className: "text-[13px] text-slate-600 mb-3", children: [
409
+ "Canal: ",
410
+ channel.display_name,
411
+ " \xB7 ",
412
+ channel.status
413
+ ] }),
414
+ /* @__PURE__ */ jsx2(
415
+ "button",
416
+ {
417
+ disabled: busy,
418
+ onClick: () => startConnect(channel),
419
+ className: "bg-emerald-600 hover:bg-emerald-700 disabled:opacity-50 text-white px-4 py-2 rounded-lg text-[13px] font-medium",
420
+ children: busy ? "Gerando\u2026" : "Gerar QR Code"
421
+ }
422
+ )
423
+ ] }) : /* @__PURE__ */ jsxs("div", { className: "text-center py-4", children: [
424
+ /* @__PURE__ */ jsx2("p", { className: "text-[13px] text-slate-600 mb-3", children: "Nenhum canal ainda. Crie um para conectar um n\xFAmero." }),
425
+ /* @__PURE__ */ jsx2(
426
+ "button",
427
+ {
428
+ disabled: busy,
429
+ onClick: handleCreate,
430
+ className: "bg-emerald-600 hover:bg-emerald-700 disabled:opacity-50 text-white px-4 py-2 rounded-lg text-[13px] font-medium",
431
+ children: busy ? "Criando\u2026" : "Criar canal"
432
+ }
433
+ )
434
+ ] })
435
+ ] }) });
436
+ }
437
+
438
+ // src/components/EmojiPicker.jsx
439
+ import { lazy, Suspense } from "react";
440
+ import { jsx as jsx3 } from "react/jsx-runtime";
441
+ var Picker = lazy(() => import("emoji-picker-react"));
442
+ var CATEGORIES_PT = [
443
+ { category: "suggested", name: "Recentes" },
444
+ { category: "smileys_people", name: "Rostos e pessoas" },
445
+ { category: "animals_nature", name: "Animais e natureza" },
446
+ { category: "food_drink", name: "Comidas e bebidas" },
447
+ { category: "travel_places", name: "Viagens e lugares" },
448
+ { category: "activities", name: "Atividades" },
449
+ { category: "objects", name: "Objetos" },
450
+ { category: "symbols", name: "S\xEDmbolos" },
451
+ { category: "flags", name: "Bandeiras" }
452
+ ];
453
+ function EmojiPicker({ onPick }) {
454
+ return /* @__PURE__ */ jsx3("div", { className: "absolute bottom-[calc(100%+6px)] left-0 z-30 shadow-xl rounded-xl overflow-hidden", children: /* @__PURE__ */ jsx3(Suspense, { fallback: /* @__PURE__ */ jsx3("div", { className: "w-[340px] h-[420px] bg-white" }), children: /* @__PURE__ */ jsx3(
455
+ Picker,
456
+ {
457
+ onEmojiClick: (e) => onPick(e.emoji),
458
+ lazyLoadEmojis: true,
459
+ width: 340,
460
+ height: 420,
461
+ categories: CATEGORIES_PT,
462
+ searchPlaceholder: "Buscar emoji\u2026",
463
+ previewConfig: { showPreview: false }
464
+ }
465
+ ) }) });
466
+ }
467
+
468
+ // src/components/TransferModal.jsx
469
+ import { useEffect as useEffect3, useState as useState3 } from "react";
470
+ import { jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
471
+ function TransferModal({ inbox, conversationId, currentAssignee, onClose }) {
472
+ const [agents, setAgents] = useState3(inbox.agents || []);
473
+ const [q, setQ] = useState3("");
474
+ useEffect3(() => {
475
+ inbox.loadAgents().then((a) => a && setAgents(a));
476
+ }, [inbox]);
477
+ const filtered = agents.filter((a) => {
478
+ const s = q.trim().toLowerCase();
479
+ if (!s) return true;
480
+ return (a.name || "").toLowerCase().includes(s) || (a.email || "").toLowerCase().includes(s);
481
+ });
482
+ const pick = (userId) => {
483
+ inbox.assign(conversationId, userId);
484
+ onClose();
485
+ };
486
+ const initials = (n) => (n || "?").split(" ").map((p) => p[0]).slice(0, 2).join("").toUpperCase();
487
+ return /* @__PURE__ */ jsx4("div", { className: "fixed inset-0 z-50 bg-black/40 flex items-center justify-center", onClick: onClose, children: /* @__PURE__ */ jsxs2("div", { className: "bg-white rounded-2xl shadow-xl w-[380px] max-h-[72vh] flex flex-col", onClick: (e) => e.stopPropagation(), children: [
488
+ /* @__PURE__ */ jsxs2("div", { className: "px-4 py-3 border-b border-slate-200 flex items-center justify-between", children: [
489
+ /* @__PURE__ */ jsx4("h3", { className: "font-semibold text-[15px]", children: "Transferir conversa" }),
490
+ /* @__PURE__ */ jsx4("button", { onClick: onClose, className: "text-slate-400 hover:text-slate-700 text-lg leading-none", children: "\xD7" })
491
+ ] }),
492
+ /* @__PURE__ */ jsx4("div", { className: "p-3 border-b border-slate-100", children: /* @__PURE__ */ jsx4(
493
+ "input",
494
+ {
495
+ value: q,
496
+ onChange: (e) => setQ(e.target.value),
497
+ placeholder: "Buscar agente\u2026",
498
+ className: "w-full px-3 py-1.5 text-[13px] rounded-lg bg-slate-50 border border-slate-200 outline-none focus:bg-white focus:border-slate-300"
499
+ }
500
+ ) }),
501
+ /* @__PURE__ */ jsxs2("div", { className: "flex-1 overflow-y-auto p-2", children: [
502
+ /* @__PURE__ */ jsx4(
503
+ "button",
504
+ {
505
+ onClick: () => pick(null),
506
+ className: "w-full text-left px-3 py-2 rounded-lg hover:bg-slate-50 text-[13px] text-slate-500",
507
+ children: "Sem atribui\xE7\xE3o"
508
+ }
509
+ ),
510
+ filtered.map((a) => /* @__PURE__ */ jsxs2(
511
+ "button",
512
+ {
513
+ onClick: () => pick(a.user_id),
514
+ className: `w-full text-left px-3 py-2 rounded-lg hover:bg-slate-50 flex items-center gap-2.5 ${currentAssignee === a.user_id ? "bg-emerald-50" : ""}`,
515
+ children: [
516
+ /* @__PURE__ */ jsx4("span", { className: "w-8 h-8 rounded-full bg-slate-200 text-slate-600 text-[11px] font-semibold flex items-center justify-center shrink-0", children: initials(a.name) }),
517
+ /* @__PURE__ */ jsxs2("span", { className: "flex-1 min-w-0", children: [
518
+ /* @__PURE__ */ jsx4("span", { className: "block text-[13px] truncate", children: a.name }),
519
+ /* @__PURE__ */ jsx4("span", { className: "block text-[11px] text-slate-400 truncate", children: [a.email, a.role].filter(Boolean).join(" \xB7 ") })
520
+ ] }),
521
+ currentAssignee === a.user_id && /* @__PURE__ */ jsx4("span", { className: "text-emerald-600 text-[11px] font-medium shrink-0", children: "atual" })
522
+ ]
523
+ },
524
+ a.user_id
525
+ )),
526
+ filtered.length === 0 && /* @__PURE__ */ jsx4("p", { className: "text-center text-[12px] text-slate-400 py-6", children: "Nenhum agente encontrado" })
527
+ ] })
528
+ ] }) });
529
+ }
530
+
531
+ // src/components/App.jsx
532
+ import { Fragment, jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
533
+ var Icon = ({ d, className = "w-4 h-4", stroke = 1.8, fill = "none" }) => /* @__PURE__ */ jsx5("svg", { viewBox: "0 0 24 24", className, fill, stroke: "currentColor", strokeWidth: stroke, strokeLinecap: "round", strokeLinejoin: "round", children: d });
534
+ var I = {
535
+ inbox: /* @__PURE__ */ jsx5(Icon, { d: /* @__PURE__ */ jsxs3(Fragment, { children: [
536
+ /* @__PURE__ */ jsx5("path", { d: "M22 12h-6l-2 3h-4l-2-3H2" }),
537
+ /* @__PURE__ */ jsx5("path", { d: "M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11Z" })
538
+ ] }) }),
539
+ chat: /* @__PURE__ */ jsx5(Icon, { d: /* @__PURE__ */ jsx5("path", { d: "M21 11.5a8.38 8.38 0 0 1-.9 3.8 8.5 8.5 0 0 1-7.6 4.7 8.38 8.38 0 0 1-3.8-.9L3 21l1.9-5.7a8.38 8.38 0 0 1-.9-3.8 8.5 8.5 0 0 1 4.7-7.6 8.38 8.38 0 0 1 3.8-.9h.5a8.48 8.48 0 0 1 8 8v.5Z" }) }),
540
+ contacts: /* @__PURE__ */ jsx5(Icon, { d: /* @__PURE__ */ jsxs3(Fragment, { children: [
541
+ /* @__PURE__ */ jsx5("path", { d: "M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2" }),
542
+ /* @__PURE__ */ jsx5("circle", { cx: "9", cy: "7", r: "4" }),
543
+ /* @__PURE__ */ jsx5("path", { d: "M22 21v-2a4 4 0 0 0-3-3.87M16 3.13a4 4 0 0 1 0 7.75" })
544
+ ] }) }),
545
+ send: /* @__PURE__ */ jsx5(Icon, { d: /* @__PURE__ */ jsxs3(Fragment, { children: [
546
+ /* @__PURE__ */ jsx5("line", { x1: "22", y1: "2", x2: "11", y2: "13" }),
547
+ /* @__PURE__ */ jsx5("polygon", { points: "22 2 15 22 11 13 2 9 22 2" })
548
+ ] }) }),
549
+ bolt: /* @__PURE__ */ jsx5(Icon, { d: /* @__PURE__ */ jsx5("polygon", { points: "13 2 3 14 12 14 11 22 21 10 12 10 13 2" }) }),
550
+ bulb: /* @__PURE__ */ jsx5(Icon, { d: /* @__PURE__ */ jsxs3(Fragment, { children: [
551
+ /* @__PURE__ */ jsx5("path", { d: "M9 18h6" }),
552
+ /* @__PURE__ */ jsx5("path", { d: "M10 22h4" }),
553
+ /* @__PURE__ */ jsx5("path", { d: "M12 2a7 7 0 0 0-4 12.7c.6.5 1 1.3 1 2.1V18h6v-1.2c0-.8.4-1.6 1-2.1A7 7 0 0 0 12 2Z" })
554
+ ] }) }),
555
+ book: /* @__PURE__ */ jsx5(Icon, { d: /* @__PURE__ */ jsxs3(Fragment, { children: [
556
+ /* @__PURE__ */ jsx5("path", { d: "M4 19.5A2.5 2.5 0 0 1 6.5 17H20" }),
557
+ /* @__PURE__ */ jsx5("path", { d: "M6.5 2H20v20H6.5A2.5 2.5 0 0 1 4 19.5v-15A2.5 2.5 0 0 1 6.5 2Z" })
558
+ ] }) }),
559
+ chart: /* @__PURE__ */ jsx5(Icon, { d: /* @__PURE__ */ jsxs3(Fragment, { children: [
560
+ /* @__PURE__ */ jsx5("line", { x1: "18", y1: "20", x2: "18", y2: "10" }),
561
+ /* @__PURE__ */ jsx5("line", { x1: "12", y1: "20", x2: "12", y2: "4" }),
562
+ /* @__PURE__ */ jsx5("line", { x1: "6", y1: "20", x2: "6", y2: "14" })
563
+ ] }) }),
564
+ users: /* @__PURE__ */ jsx5(Icon, { d: /* @__PURE__ */ jsxs3(Fragment, { children: [
565
+ /* @__PURE__ */ jsx5("path", { d: "M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2" }),
566
+ /* @__PURE__ */ jsx5("circle", { cx: "9", cy: "7", r: "4" }),
567
+ /* @__PURE__ */ jsx5("path", { d: "M23 21v-2a4 4 0 0 0-3-3.87M16 3.13a4 4 0 0 1 0 7.75" })
568
+ ] }) }),
569
+ grid: /* @__PURE__ */ jsx5(Icon, { d: /* @__PURE__ */ jsxs3(Fragment, { children: [
570
+ /* @__PURE__ */ jsx5("rect", { x: "3", y: "3", width: "7", height: "7" }),
571
+ /* @__PURE__ */ jsx5("rect", { x: "14", y: "3", width: "7", height: "7" }),
572
+ /* @__PURE__ */ jsx5("rect", { x: "14", y: "14", width: "7", height: "7" }),
573
+ /* @__PURE__ */ jsx5("rect", { x: "3", y: "14", width: "7", height: "7" })
574
+ ] }) }),
575
+ briefcase: /* @__PURE__ */ jsx5(Icon, { d: /* @__PURE__ */ jsxs3(Fragment, { children: [
576
+ /* @__PURE__ */ jsx5("rect", { x: "2", y: "7", width: "20", height: "14", rx: "2" }),
577
+ /* @__PURE__ */ jsx5("path", { d: "M16 21V5a2 2 0 0 0-2-2h-4a2 2 0 0 0-2 2v16" })
578
+ ] }) }),
579
+ search: /* @__PURE__ */ jsx5(Icon, { d: /* @__PURE__ */ jsxs3(Fragment, { children: [
580
+ /* @__PURE__ */ jsx5("circle", { cx: "11", cy: "11", r: "8" }),
581
+ /* @__PURE__ */ jsx5("line", { x1: "21", y1: "21", x2: "16.65", y2: "16.65" })
582
+ ] }) }),
583
+ filter: /* @__PURE__ */ jsx5(Icon, { d: /* @__PURE__ */ jsx5("polygon", { points: "22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3" }) }),
584
+ sort: /* @__PURE__ */ jsx5(Icon, { d: /* @__PURE__ */ jsxs3(Fragment, { children: [
585
+ /* @__PURE__ */ jsx5("path", { d: "m3 16 4 4 4-4" }),
586
+ /* @__PURE__ */ jsx5("path", { d: "M7 20V4" }),
587
+ /* @__PURE__ */ jsx5("path", { d: "m21 8-4-4-4 4" }),
588
+ /* @__PURE__ */ jsx5("path", { d: "M17 4v16" })
589
+ ] }) }),
590
+ chevDown: /* @__PURE__ */ jsx5(Icon, { d: /* @__PURE__ */ jsx5("polyline", { points: "6 9 12 15 18 9" }) }),
591
+ chevRight: /* @__PURE__ */ jsx5(Icon, { d: /* @__PURE__ */ jsx5("polyline", { points: "9 18 15 12 9 6" }) }),
592
+ panel: /* @__PURE__ */ jsx5(Icon, { d: /* @__PURE__ */ jsxs3(Fragment, { children: [
593
+ /* @__PURE__ */ jsx5("rect", { x: "3", y: "3", width: "18", height: "18", rx: "2" }),
594
+ /* @__PURE__ */ jsx5("line", { x1: "9", y1: "3", x2: "9", y2: "21" })
595
+ ] }) }),
596
+ more: /* @__PURE__ */ jsx5(Icon, { d: /* @__PURE__ */ jsxs3(Fragment, { children: [
597
+ /* @__PURE__ */ jsx5("circle", { cx: "12", cy: "12", r: "1" }),
598
+ /* @__PURE__ */ jsx5("circle", { cx: "19", cy: "12", r: "1" }),
599
+ /* @__PURE__ */ jsx5("circle", { cx: "5", cy: "12", r: "1" })
600
+ ] }) }),
601
+ star: /* @__PURE__ */ jsx5(Icon, { d: /* @__PURE__ */ jsx5("polygon", { points: "12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2" }) }),
602
+ phone: /* @__PURE__ */ jsx5(Icon, { d: /* @__PURE__ */ jsx5("path", { d: "M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92Z" }) }),
603
+ moon: /* @__PURE__ */ jsx5(Icon, { d: /* @__PURE__ */ jsx5("path", { d: "M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79Z" }) }),
604
+ check: /* @__PURE__ */ jsx5(Icon, { d: /* @__PURE__ */ jsx5("polyline", { points: "20 6 9 17 4 12" }) }),
605
+ paperclip: /* @__PURE__ */ jsx5(Icon, { d: /* @__PURE__ */ jsx5("path", { d: "m21.44 11.05-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48" }) }),
606
+ emoji: /* @__PURE__ */ jsx5(Icon, { d: /* @__PURE__ */ jsxs3(Fragment, { children: [
607
+ /* @__PURE__ */ jsx5("circle", { cx: "12", cy: "12", r: "10" }),
608
+ /* @__PURE__ */ jsx5("path", { d: "M8 14s1.5 2 4 2 4-2 4-2" }),
609
+ /* @__PURE__ */ jsx5("line", { x1: "9", y1: "9", x2: "9.01", y2: "9" }),
610
+ /* @__PURE__ */ jsx5("line", { x1: "15", y1: "9", x2: "15.01", y2: "9" })
611
+ ] }) }),
612
+ mic: /* @__PURE__ */ jsx5(Icon, { d: /* @__PURE__ */ jsxs3(Fragment, { children: [
613
+ /* @__PURE__ */ jsx5("path", { d: "M12 1a3 3 0 0 0-3 3v8a3 3 0 0 0 6 0V4a3 3 0 0 0-3-3Z" }),
614
+ /* @__PURE__ */ jsx5("path", { d: "M19 10v2a7 7 0 0 1-14 0v-2" }),
615
+ /* @__PURE__ */ jsx5("line", { x1: "12", y1: "19", x2: "12", y2: "23" }),
616
+ /* @__PURE__ */ jsx5("line", { x1: "8", y1: "23", x2: "16", y2: "23" })
617
+ ] }) }),
618
+ image: /* @__PURE__ */ jsx5(Icon, { d: /* @__PURE__ */ jsxs3(Fragment, { children: [
619
+ /* @__PURE__ */ jsx5("rect", { x: "3", y: "3", width: "18", height: "18", rx: "2", ry: "2" }),
620
+ /* @__PURE__ */ jsx5("circle", { cx: "8.5", cy: "8.5", r: "1.5" }),
621
+ /* @__PURE__ */ jsx5("polyline", { points: "21 15 16 10 5 21" })
622
+ ] }) }),
623
+ file: /* @__PURE__ */ jsx5(Icon, { d: /* @__PURE__ */ jsxs3(Fragment, { children: [
624
+ /* @__PURE__ */ jsx5("path", { d: "M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z" }),
625
+ /* @__PURE__ */ jsx5("polyline", { points: "14 2 14 8 20 8" })
626
+ ] }) }),
627
+ pin: /* @__PURE__ */ jsx5(Icon, { d: /* @__PURE__ */ jsxs3(Fragment, { children: [
628
+ /* @__PURE__ */ jsx5("path", { d: "M21 10c0 7-9 13-9 13s-9-6-9-13a9 9 0 0 1 18 0z" }),
629
+ /* @__PURE__ */ jsx5("circle", { cx: "12", cy: "10", r: "3" })
630
+ ] }) }),
631
+ tag: /* @__PURE__ */ jsx5(Icon, { d: /* @__PURE__ */ jsxs3(Fragment, { children: [
632
+ /* @__PURE__ */ jsx5("path", { d: "M20.59 13.41 13.42 20.58a2 2 0 0 1-2.83 0L2 12V2h10l8.59 8.59a2 2 0 0 1 0 2.82Z" }),
633
+ /* @__PURE__ */ jsx5("line", { x1: "7", y1: "7", x2: "7.01", y2: "7" })
634
+ ] }) }),
635
+ link: /* @__PURE__ */ jsx5(Icon, { d: /* @__PURE__ */ jsxs3(Fragment, { children: [
636
+ /* @__PURE__ */ jsx5("path", { d: "M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71" }),
637
+ /* @__PURE__ */ jsx5("path", { d: "M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71" })
638
+ ] }) }),
639
+ clock: /* @__PURE__ */ jsx5(Icon, { d: /* @__PURE__ */ jsxs3(Fragment, { children: [
640
+ /* @__PURE__ */ jsx5("circle", { cx: "12", cy: "12", r: "10" }),
641
+ /* @__PURE__ */ jsx5("polyline", { points: "12 6 12 12 16 14" })
642
+ ] }) }),
643
+ forward: /* @__PURE__ */ jsx5(Icon, { d: /* @__PURE__ */ jsxs3(Fragment, { children: [
644
+ /* @__PURE__ */ jsx5("polyline", { points: "15 17 20 12 15 7" }),
645
+ /* @__PURE__ */ jsx5("path", { d: "M4 18v-2a4 4 0 0 1 4-4h12" })
646
+ ] }) }),
647
+ x: /* @__PURE__ */ jsx5(Icon, { d: /* @__PURE__ */ jsxs3(Fragment, { children: [
648
+ /* @__PURE__ */ jsx5("line", { x1: "18", y1: "6", x2: "6", y2: "18" }),
649
+ /* @__PURE__ */ jsx5("line", { x1: "6", y1: "6", x2: "18", y2: "18" })
650
+ ] }) }),
651
+ external: /* @__PURE__ */ jsx5(Icon, { d: /* @__PURE__ */ jsxs3(Fragment, { children: [
652
+ /* @__PURE__ */ jsx5("path", { d: "M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6" }),
653
+ /* @__PURE__ */ jsx5("polyline", { points: "15 3 21 3 21 9" }),
654
+ /* @__PURE__ */ jsx5("line", { x1: "10", y1: "14", x2: "21", y2: "3" })
655
+ ] }) }),
656
+ plus: /* @__PURE__ */ jsx5(Icon, { d: /* @__PURE__ */ jsxs3(Fragment, { children: [
657
+ /* @__PURE__ */ jsx5("line", { x1: "12", y1: "5", x2: "12", y2: "19" }),
658
+ /* @__PURE__ */ jsx5("line", { x1: "5", y1: "12", x2: "19", y2: "12" })
659
+ ] }) }),
660
+ template: /* @__PURE__ */ jsx5(Icon, { d: /* @__PURE__ */ jsxs3(Fragment, { children: [
661
+ /* @__PURE__ */ jsx5("rect", { x: "3", y: "3", width: "18", height: "18", rx: "2" }),
662
+ /* @__PURE__ */ jsx5("line", { x1: "3", y1: "9", x2: "21", y2: "9" }),
663
+ /* @__PURE__ */ jsx5("line", { x1: "9", y1: "21", x2: "9", y2: "9" })
664
+ ] }) }),
665
+ reply: /* @__PURE__ */ jsx5(Icon, { d: /* @__PURE__ */ jsxs3(Fragment, { children: [
666
+ /* @__PURE__ */ jsx5("polyline", { points: "9 17 4 12 9 7" }),
667
+ /* @__PURE__ */ jsx5("path", { d: "M20 18v-2a4 4 0 0 0-4-4H4" })
668
+ ] }) }),
669
+ whatsapp: /* @__PURE__ */ jsx5(Icon, { d: /* @__PURE__ */ jsxs3(Fragment, { children: [
670
+ /* @__PURE__ */ jsx5("path", { d: "M20.52 3.48A11.93 11.93 0 0 0 12.02 0C5.4 0 .03 5.37.03 11.99c0 2.11.55 4.18 1.6 6L0 24l6.18-1.62a12 12 0 0 0 5.84 1.49h.01c6.62 0 11.99-5.37 11.99-11.99 0-3.2-1.25-6.21-3.5-8.4Z" }),
671
+ /* @__PURE__ */ jsx5("path", { d: "M9.3 7.4c-.2-.5-.4-.5-.6-.5h-.5c-.2 0-.5.07-.7.34-.27.27-.93.91-.93 2.22 0 1.31.95 2.58 1.08 2.76.13.18 1.86 2.96 4.58 4.04 2.27.89 2.73.71 3.22.67.49-.05 1.58-.65 1.8-1.27.22-.62.22-1.16.15-1.27-.07-.11-.25-.18-.52-.31-.27-.13-1.58-.78-1.83-.87-.24-.09-.42-.13-.6.13-.18.27-.69.87-.84 1.05-.16.18-.31.2-.58.07-.27-.13-1.14-.42-2.17-1.34-.8-.71-1.34-1.59-1.5-1.86-.16-.27-.02-.41.12-.55.12-.12.27-.31.4-.47.13-.16.18-.27.27-.45.09-.18.04-.34-.02-.47-.07-.13-.6-1.43-.82-1.96Z" })
672
+ ] }), fill: "currentColor", stroke: "none" }),
673
+ home: /* @__PURE__ */ jsx5(Icon, { d: /* @__PURE__ */ jsx5(Fragment, { children: /* @__PURE__ */ jsx5("path", { d: "M3 9.5 12 3l9 6.5V20a1 1 0 0 1-1 1h-5v-7h-6v7H4a1 1 0 0 1-1-1V9.5Z" }) }) }),
674
+ calendar: /* @__PURE__ */ jsx5(Icon, { d: /* @__PURE__ */ jsxs3(Fragment, { children: [
675
+ /* @__PURE__ */ jsx5("rect", { x: "3", y: "4.5", width: "18", height: "16.5", rx: "2" }),
676
+ /* @__PURE__ */ jsx5("line", { x1: "3", y1: "10", x2: "21", y2: "10" }),
677
+ /* @__PURE__ */ jsx5("line", { x1: "8", y1: "2.5", x2: "8", y2: "6" }),
678
+ /* @__PURE__ */ jsx5("line", { x1: "16", y1: "2.5", x2: "16", y2: "6" })
679
+ ] }) }),
680
+ building: /* @__PURE__ */ jsx5(Icon, { d: /* @__PURE__ */ jsxs3(Fragment, { children: [
681
+ /* @__PURE__ */ jsx5("rect", { x: "4", y: "2.5", width: "16", height: "19", rx: "1.5" }),
682
+ /* @__PURE__ */ jsx5("path", { d: "M9 21.5v-4h6v4" }),
683
+ /* @__PURE__ */ jsx5("path", { d: "M8.5 7h.01M12 7h.01M15.5 7h.01M8.5 11h.01M12 11h.01M15.5 11h.01M8.5 15h.01M15.5 15h.01" })
684
+ ] }) }),
685
+ target: /* @__PURE__ */ jsx5(Icon, { d: /* @__PURE__ */ jsxs3(Fragment, { children: [
686
+ /* @__PURE__ */ jsx5("circle", { cx: "12", cy: "12", r: "9" }),
687
+ /* @__PURE__ */ jsx5("circle", { cx: "12", cy: "12", r: "5" }),
688
+ /* @__PURE__ */ jsx5("circle", { cx: "12", cy: "12", r: "1.5", fill: "currentColor" })
689
+ ] }) }),
690
+ kanban: /* @__PURE__ */ jsx5(Icon, { d: /* @__PURE__ */ jsxs3(Fragment, { children: [
691
+ /* @__PURE__ */ jsx5("rect", { x: "3", y: "3", width: "18", height: "18", rx: "2" }),
692
+ /* @__PURE__ */ jsx5("line", { x1: "9", y1: "3", x2: "9", y2: "14" }),
693
+ /* @__PURE__ */ jsx5("line", { x1: "15", y1: "3", x2: "15", y2: "10" })
694
+ ] }) }),
695
+ dollar: /* @__PURE__ */ jsx5(Icon, { d: /* @__PURE__ */ jsxs3(Fragment, { children: [
696
+ /* @__PURE__ */ jsx5("circle", { cx: "12", cy: "12", r: "9.5" }),
697
+ /* @__PURE__ */ jsx5("path", { d: "M15 9c-.6-1.3-1.7-2-3-2-1.7 0-3 1-3 2.3 0 2.7 6 1.3 6 4 0 1.3-1.3 2.3-3 2.3-1.3 0-2.4-.7-3-2" }),
698
+ /* @__PURE__ */ jsx5("line", { x1: "12", y1: "5.5", x2: "12", y2: "18.5" })
699
+ ] }) }),
700
+ checkCircle: /* @__PURE__ */ jsx5(Icon, { d: /* @__PURE__ */ jsxs3(Fragment, { children: [
701
+ /* @__PURE__ */ jsx5("circle", { cx: "12", cy: "12", r: "9.5" }),
702
+ /* @__PURE__ */ jsx5("polyline", { points: "8.5 12 11 14.5 15.5 9.5" })
703
+ ] }) }),
704
+ globe: /* @__PURE__ */ jsx5(Icon, { d: /* @__PURE__ */ jsxs3(Fragment, { children: [
705
+ /* @__PURE__ */ jsx5("circle", { cx: "12", cy: "12", r: "9.5" }),
706
+ /* @__PURE__ */ jsx5("line", { x1: "2.5", y1: "12", x2: "21.5", y2: "12" }),
707
+ /* @__PURE__ */ jsx5("path", { d: "M12 2.5c2.5 2.7 4 6.1 4 9.5s-1.5 6.8-4 9.5C9.5 18.8 8 15.4 8 12s1.5-6.8 4-9.5z" })
708
+ ] }) }),
709
+ rocket: /* @__PURE__ */ jsx5(Icon, { d: /* @__PURE__ */ jsxs3(Fragment, { children: [
710
+ /* @__PURE__ */ jsx5("path", { d: "M4.5 16.5c-1.5 1.3-2 5-2 5s3.7-.5 5-2c.7-.8.7-2.1-.1-2.9-.8-.8-2.1-.8-2.9-.1z" }),
711
+ /* @__PURE__ */ jsx5("path", { d: "M12 15l-3-3a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22 22 0 0 1-4 2z" }),
712
+ /* @__PURE__ */ jsx5("path", { d: "M9 12H4s.55-3 2-4c1.6-1 5 0 5 0" }),
713
+ /* @__PURE__ */ jsx5("path", { d: "M12 15v5s3-.5 4-2c1-1.6 0-5 0-5" })
714
+ ] }) }),
715
+ wand: /* @__PURE__ */ jsx5(Icon, { d: /* @__PURE__ */ jsxs3(Fragment, { children: [
716
+ /* @__PURE__ */ jsx5("path", { d: "m3 21 9-9" }),
717
+ /* @__PURE__ */ jsx5("path", { d: "M15 3v3" }),
718
+ /* @__PURE__ */ jsx5("path", { d: "M19 7l-2 2" }),
719
+ /* @__PURE__ */ jsx5("path", { d: "M21 11h-3" }),
720
+ /* @__PURE__ */ jsx5("path", { d: "M19 15l-2-2" }),
721
+ /* @__PURE__ */ jsx5("path", { d: "M15 17v-3" })
722
+ ] }) }),
723
+ doc: /* @__PURE__ */ jsx5(Icon, { d: /* @__PURE__ */ jsxs3(Fragment, { children: [
724
+ /* @__PURE__ */ jsx5("path", { d: "M14 2.5H6.5A2 2 0 0 0 4.5 4.5v15a2 2 0 0 0 2 2h11a2 2 0 0 0 2-2V8.5z" }),
725
+ /* @__PURE__ */ jsx5("polyline", { points: "14 2.5 14 8.5 20 8.5" }),
726
+ /* @__PURE__ */ jsx5("line", { x1: "8", y1: "13", x2: "16", y2: "13" }),
727
+ /* @__PURE__ */ jsx5("line", { x1: "8", y1: "17", x2: "14", y2: "17" })
728
+ ] }) }),
729
+ gear: /* @__PURE__ */ jsx5(Icon, { d: /* @__PURE__ */ jsxs3(Fragment, { children: [
730
+ /* @__PURE__ */ jsx5("circle", { cx: "12", cy: "12", r: "3" }),
731
+ /* @__PURE__ */ jsx5("path", { d: "M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 1 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 1 1-2.83-2.83l.06-.06A1.65 1.65 0 0 0 4.6 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 1 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 1 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 1 1 2.83 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 1 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z" })
732
+ ] }) }),
733
+ card: /* @__PURE__ */ jsx5(Icon, { d: /* @__PURE__ */ jsxs3(Fragment, { children: [
734
+ /* @__PURE__ */ jsx5("rect", { x: "2", y: "5.5", width: "20", height: "13", rx: "2" }),
735
+ /* @__PURE__ */ jsx5("line", { x1: "2", y1: "10", x2: "22", y2: "10" })
736
+ ] }) }),
737
+ chevDblL: /* @__PURE__ */ jsx5(Icon, { d: /* @__PURE__ */ jsxs3(Fragment, { children: [
738
+ /* @__PURE__ */ jsx5("path", { d: "m11 17-5-5 5-5" }),
739
+ /* @__PURE__ */ jsx5("path", { d: "m18 17-5-5 5-5" })
740
+ ] }) }),
741
+ chevDblR: /* @__PURE__ */ jsx5(Icon, { d: /* @__PURE__ */ jsxs3(Fragment, { children: [
742
+ /* @__PURE__ */ jsx5("path", { d: "m13 17 5-5-5-5" }),
743
+ /* @__PURE__ */ jsx5("path", { d: "m6 17 5-5-5-5" })
744
+ ] }) }),
745
+ chevUp: /* @__PURE__ */ jsx5(Icon, { d: /* @__PURE__ */ jsx5("polyline", { points: "18 15 12 9 6 15" }) }),
746
+ userPlus: /* @__PURE__ */ jsx5(Icon, { d: /* @__PURE__ */ jsxs3(Fragment, { children: [
747
+ /* @__PURE__ */ jsx5("path", { d: "M16 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2" }),
748
+ /* @__PURE__ */ jsx5("circle", { cx: "8.5", cy: "7", r: "4" }),
749
+ /* @__PURE__ */ jsx5("line", { x1: "20", y1: "8", x2: "20", y2: "14" }),
750
+ /* @__PURE__ */ jsx5("line", { x1: "23", y1: "11", x2: "17", y2: "11" })
751
+ ] }) }),
752
+ qrcode: /* @__PURE__ */ jsx5(Icon, { d: /* @__PURE__ */ jsxs3(Fragment, { children: [
753
+ /* @__PURE__ */ jsx5("rect", { x: "3", y: "3", width: "7", height: "7", rx: "1" }),
754
+ /* @__PURE__ */ jsx5("rect", { x: "14", y: "3", width: "7", height: "7", rx: "1" }),
755
+ /* @__PURE__ */ jsx5("rect", { x: "3", y: "14", width: "7", height: "7", rx: "1" }),
756
+ /* @__PURE__ */ jsx5("path", { d: "M14 14h3v3" }),
757
+ /* @__PURE__ */ jsx5("path", { d: "M21 14v.01" }),
758
+ /* @__PURE__ */ jsx5("path", { d: "M14 21h.01" }),
759
+ /* @__PURE__ */ jsx5("path", { d: "M21 21v-3.5" }),
760
+ /* @__PURE__ */ jsx5("path", { d: "M17.5 21h.01" })
761
+ ] }) })
762
+ };
763
+ var Avatar = ({ name, size = "md", color = "bg-violet-500", online }) => {
764
+ const sizes = { sm: "w-7 h-7 text-[11px]", md: "w-9 h-9 text-xs", lg: "w-11 h-11 text-sm", xl: "w-14 h-14 text-base" };
765
+ const initials = name.split(" ").map((p) => p[0]).slice(0, 2).join("").toUpperCase();
766
+ return /* @__PURE__ */ jsxs3("div", { className: "relative inline-flex", children: [
767
+ /* @__PURE__ */ jsx5("div", { className: `${sizes[size]} ${color} rounded-full text-white font-semibold inline-flex items-center justify-center select-none shrink-0`, children: initials }),
768
+ online && /* @__PURE__ */ jsx5("span", { className: "absolute bottom-0 right-0 w-2.5 h-2.5 rounded-full bg-emerald-500 ring-2 ring-white" })
769
+ ] });
770
+ };
771
+ var Pill = ({ children, tone = "slate" }) => {
772
+ const tones = {
773
+ slate: "bg-slate-100 text-slate-700 ring-slate-200",
774
+ amber: "bg-amber-50 text-amber-700 ring-amber-200",
775
+ emerald: "bg-emerald-50 text-emerald-700 ring-emerald-200",
776
+ rose: "bg-rose-50 text-rose-700 ring-rose-200",
777
+ violet: "bg-violet-50 text-violet-700 ring-violet-200",
778
+ sky: "bg-sky-50 text-sky-700 ring-sky-200",
779
+ yellow: "bg-yellow-100 text-yellow-800 ring-yellow-200"
780
+ };
781
+ return /* @__PURE__ */ jsx5("span", { className: `inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-[11px] font-medium ring-1 ring-inset ${tones[tone]}`, children });
782
+ };
783
+ var conversations = [
784
+ {
785
+ id: "c1",
786
+ name: "Samir Patel",
787
+ phone: "+55 11 98452-1023",
788
+ avatarColor: "bg-violet-500",
789
+ preview: "Ol\xE1! Vi o apto de 2 dorm em Vila Mariana, ainda est\xE1\u2026",
790
+ waitFor: "4m",
791
+ unread: 0,
792
+ sla: "risk",
793
+ priority: "high",
794
+ status: "in_progress",
795
+ ticket: "#8743",
796
+ tier: "Gold",
797
+ assignee: "Voc\xEA"
798
+ },
799
+ {
800
+ id: "c2",
801
+ name: "Jenifer Souza",
802
+ phone: "+55 21 99201-7811",
803
+ avatarColor: "bg-rose-500",
804
+ preview: "Oi, tenho uma d\xFAvida sobre a fatura desse m\xEAs \u{1F914}",
805
+ waitFor: "8m",
806
+ unread: 2,
807
+ sla: "breach",
808
+ priority: "urgent",
809
+ status: "open",
810
+ ticket: "#8744",
811
+ tier: "Platinum",
812
+ assignee: "Voc\xEA",
813
+ starred: true
814
+ },
815
+ {
816
+ id: "c3",
817
+ name: "Ingrid Bahia",
818
+ phone: "+55 71 98800-4421",
819
+ avatarColor: "bg-sky-500",
820
+ preview: "Boa tarde, vamos prosseguir com a troca do plano\u2026",
821
+ waitFor: "17m",
822
+ unread: 0,
823
+ sla: "ok",
824
+ priority: "normal",
825
+ status: "waiting",
826
+ ticket: "#8746",
827
+ tier: "Silver",
828
+ assignee: "Voc\xEA"
829
+ },
830
+ {
831
+ id: "c4",
832
+ name: "Sven Ribeiro",
833
+ phone: "+55 47 98112-7755",
834
+ avatarColor: "bg-slate-700",
835
+ preview: "Sim, ser\xE1 processado em at\xE9 24h corridas.",
836
+ waitFor: "23m",
837
+ unread: 0,
838
+ sla: "ok",
839
+ priority: "low",
840
+ status: "in_progress",
841
+ ticket: "#8749",
842
+ tier: "Bronze",
843
+ assignee: "Voc\xEA"
844
+ },
845
+ {
846
+ id: "c5",
847
+ name: "Marcelo Tavares",
848
+ phone: "+55 11 95542-3398",
849
+ avatarColor: "bg-amber-500",
850
+ preview: "\xC1udio \xB7 0:42",
851
+ waitFor: "34m",
852
+ unread: 1,
853
+ sla: "risk",
854
+ priority: "high",
855
+ status: "open",
856
+ ticket: "#8751",
857
+ tier: "Gold",
858
+ assignee: "Fila \u2014 Vendas"
859
+ },
860
+ {
861
+ id: "c6",
862
+ name: "Helena Prado",
863
+ phone: "+55 31 99776-2210",
864
+ avatarColor: "bg-emerald-600",
865
+ preview: "Documento \xB7 contrato_v3.pdf",
866
+ waitFor: "52m",
867
+ unread: 0,
868
+ sla: "ok",
869
+ priority: "normal",
870
+ status: "waiting",
871
+ ticket: "#8755",
872
+ tier: "Silver",
873
+ assignee: "Voc\xEA"
874
+ }
875
+ ];
876
+ var INITIAL_MESSAGES = [
877
+ { id: "m1", side: "in", kind: "text", text: "Ol\xE1! Vi no site de voc\xEAs o apartamento de 2 dormit\xF3rios em Vila Mariana. Ainda est\xE1 dispon\xEDvel? Tenho interesse em visitar essa semana.", time: "10:02", day: "Hoje" },
878
+ { id: "m2", side: "out", kind: "text", text: "Ol\xE1 Samir! Tudo bem? Aqui \xE9 a Maria, corretora respons\xE1vel. Sim, o im\xF3vel est\xE1 dispon\xEDvel! Pra eu te ajudar melhor, posso te perguntar uma coisa r\xE1pida \u2014 \xE9 pra moradia ou investimento? E voc\xEA j\xE1 tem uma faixa de valor em mente?", time: "10:04", status: "read" },
879
+ { id: "m3", side: "in", kind: "text", text: "Pra morar mesmo. Sou casado, sem filhos, e t\xF4 olhando algo na Zona Sul at\xE9 R$ 900 mil. Preciso de vaga de garagem e, se poss\xEDvel, varanda.", time: "10:05" },
880
+ { id: "m4", side: "in", kind: "image", caption: "Esse \xE9 o estilo de planta que eu gostei", meta: "1.4 MB \xB7 referencia.jpg", time: "10:06" },
881
+ { id: "m5", side: "note", text: "@Alissa esse cliente tem o perfil ideal pro 65m\xB2 da Vila Mariana (c\xF3d. 856301) e pro 95m\xB2 em Moema (c\xF3d. 858033). Os dois ainda est\xE3o liberados pra visita amanh\xE3? Quero confirmar antes de oferecer.", author: "Maria Eduarda", time: "10:09" },
882
+ { id: "m6", side: "system", text: "Alissa Mendes foi adicionada \xE0 conversa", time: "10:10" },
883
+ { id: "m7", side: "out", kind: "text", text: "Samir, tenho duas \xF3timas op\xE7\xF5es pra voc\xEA dentro do or\xE7amento e com vaga + varanda: um 2 dorm em Vila Mariana e um 3 dorm em Moema. Os dois est\xE3o liberados pra visita amanh\xE3. Te mando agora os detalhes e fotos?", time: "10:18", status: "read", author: "Alissa Mendes" },
884
+ { id: "m8", side: "in", kind: "text", text: "Perfeito, manda sim! \u{1F64F}", time: "10:20" },
885
+ { id: "m9", side: "in", kind: "audio", duration: "0:18", time: "10:21" },
886
+ { id: "m10", side: "out", kind: "text", text: "Maravilha! Qual per\xEDodo da semana funciona melhor pra voc\xEA visitar \u2014 manh\xE3 ou final do dia? J\xE1 adianto o agendamento com os propriet\xE1rios. \u{1F60A}", time: "10:24", status: "delivered" }
887
+ ];
888
+ var quickReplies = [
889
+ { id: "q1", label: "Sauda\xE7\xE3o", text: "Ol\xE1! Aqui \xE9 da imobili\xE1ria, tudo bem? Como posso te ajudar a encontrar o im\xF3vel ideal?" },
890
+ { id: "q2", label: "Perfil", text: "Pra eu te enviar as melhores op\xE7\xF5es, me conta: \xE9 pra moradia ou investimento? Qual regi\xE3o e faixa de valor?" },
891
+ { id: "q3", label: "Agendar visita", text: "Posso j\xE1 agendar a visita pra voc\xEA. Qual o melhor dia e hor\xE1rio essa semana?" },
892
+ { id: "q4", label: "Documentos", text: "Pra avan\xE7ar com a proposta, vou precisar de RG, CPF, comprovante de renda e resid\xEAncia. Pode me enviar por aqui mesmo." }
893
+ ];
894
+ var statusInfo = {
895
+ open: { tone: "sky", label: "Aberto" },
896
+ in_progress: { tone: "amber", label: "Em atendimento" },
897
+ waiting: { tone: "violet", label: "Aguardando cliente" },
898
+ resolved: { tone: "emerald", label: "Resolvido" }
899
+ };
900
+ function App() {
901
+ var _a;
902
+ const inbox = useInbox();
903
+ const live = inbox.live;
904
+ const [mockActiveId, setMockActiveId] = useState4("c1");
905
+ const activeId = live ? inbox.activeId : mockActiveId;
906
+ const setActiveId = live ? inbox.setActiveId : setMockActiveId;
907
+ const [connectOpen, setConnectOpen] = useState4(false);
908
+ const [transferOpen, setTransferOpen] = useState4(false);
909
+ const [emojiOpen, setEmojiOpen] = useState4(false);
910
+ const [filterOpen, setFilterOpen] = useState4(false);
911
+ const [unreadOnly, setUnreadOnly] = useState4(false);
912
+ const [mineOnly, setMineOnly] = useState4(false);
913
+ const [recording, setRecording] = useState4(false);
914
+ const [recSecs, setRecSecs] = useState4(0);
915
+ const [composeMode, setComposeMode] = useState4("reply");
916
+ const [text, setText] = useState4("");
917
+ const [filter, setFilter] = useState4("all");
918
+ const [detailsOpen, setDetailsOpen] = useState4(true);
919
+ const [quickOpen, setQuickOpen] = useState4(false);
920
+ const [searchOpen, setSearchOpen] = useState4(false);
921
+ const [searchQuery, setSearchQuery] = useState4("");
922
+ const [searchIndex, setSearchIndex] = useState4(0);
923
+ const [messages, setMessages] = useState4(INITIAL_MESSAGES);
924
+ const threadMessages = live ? inbox.messages : messages;
925
+ const convList = live ? inbox.conversations : conversations;
926
+ const scrollRef = useRef3(null);
927
+ const textareaRef = useRef3(null);
928
+ const imageInputRef = useRef3(null);
929
+ const fileInputRef = useRef3(null);
930
+ const mediaRecorderRef = useRef3(null);
931
+ const audioChunksRef = useRef3([]);
932
+ const cancelAudioRef = useRef3(false);
933
+ const audioCtxRef = useRef3(null);
934
+ const analyserRef = useRef3(null);
935
+ const recTimerRef = useRef3(null);
936
+ const [listWidth, setListWidth] = useState4(() => {
937
+ if (typeof window !== "undefined") {
938
+ const v = parseInt(window.localStorage.getItem("veploy_chat_list_width") || "", 10);
939
+ if (v >= 300 && v <= 600) return v;
940
+ }
941
+ return 380;
942
+ });
943
+ const resizingRef = useRef3(false);
944
+ const listWidthRef = useRef3(listWidth);
945
+ listWidthRef.current = listWidth;
946
+ useEffect4(() => {
947
+ const onMove = (e) => {
948
+ if (!resizingRef.current) return;
949
+ setListWidth(Math.min(600, Math.max(300, e.clientX)));
950
+ };
951
+ const onUp = () => {
952
+ if (!resizingRef.current) return;
953
+ resizingRef.current = false;
954
+ document.body.style.cursor = "";
955
+ document.body.style.userSelect = "";
956
+ try {
957
+ window.localStorage.setItem("veploy_chat_list_width", String(listWidthRef.current));
958
+ } catch {
959
+ }
960
+ };
961
+ window.addEventListener("mousemove", onMove);
962
+ window.addEventListener("mouseup", onUp);
963
+ return () => {
964
+ window.removeEventListener("mousemove", onMove);
965
+ window.removeEventListener("mouseup", onUp);
966
+ };
967
+ }, []);
968
+ const startResize = (e) => {
969
+ resizingRef.current = true;
970
+ document.body.style.cursor = "col-resize";
971
+ document.body.style.userSelect = "none";
972
+ e.preventDefault();
973
+ };
974
+ const formatNow = () => {
975
+ const d = /* @__PURE__ */ new Date();
976
+ return `${String(d.getHours()).padStart(2, "0")}:${String(d.getMinutes()).padStart(2, "0")}`;
977
+ };
978
+ const fileToDataUrl = (file) => new Promise((res, rej) => {
979
+ const r = new FileReader();
980
+ r.onload = () => res(r.result);
981
+ r.onerror = rej;
982
+ r.readAsDataURL(file);
983
+ });
984
+ const insertEmoji = (e) => {
985
+ var _a2;
986
+ setText((t) => t + e);
987
+ setEmojiOpen(false);
988
+ (_a2 = textareaRef.current) == null ? void 0 : _a2.focus();
989
+ };
990
+ const sendMediaFile = async (file, kind) => {
991
+ if (!file) return;
992
+ const previewUrl = URL.createObjectURL(file);
993
+ const data = await fileToDataUrl(file);
994
+ if (live) {
995
+ inbox.sendMedia({ data, mime: file.type, kind, filename: file.name, previewUrl });
996
+ } else {
997
+ setMessages((ms) => [...ms, { id: `m${Date.now()}`, side: "out", kind, mediaUrl: previewUrl, meta: file.name, time: formatNow(), status: "sent" }]);
998
+ }
999
+ };
1000
+ const onPickImage = async (e) => {
1001
+ var _a2;
1002
+ const f = (_a2 = e.target.files) == null ? void 0 : _a2[0];
1003
+ e.target.value = "";
1004
+ await sendMediaFile(f, "image");
1005
+ };
1006
+ const onPickFile = async (e) => {
1007
+ var _a2;
1008
+ const f = (_a2 = e.target.files) == null ? void 0 : _a2[0];
1009
+ e.target.value = "";
1010
+ await sendMediaFile(f, "document");
1011
+ };
1012
+ const startRecording = async () => {
1013
+ try {
1014
+ const stream = await navigator.mediaDevices.getUserMedia({ audio: true });
1015
+ const mr = new MediaRecorder(stream);
1016
+ audioChunksRef.current = [];
1017
+ cancelAudioRef.current = false;
1018
+ const Ctx = window.AudioContext || window.webkitAudioContext;
1019
+ const audioCtx = new Ctx();
1020
+ const source = audioCtx.createMediaStreamSource(stream);
1021
+ const analyser = audioCtx.createAnalyser();
1022
+ analyser.fftSize = 64;
1023
+ source.connect(analyser);
1024
+ audioCtxRef.current = audioCtx;
1025
+ analyserRef.current = analyser;
1026
+ setRecSecs(0);
1027
+ clearInterval(recTimerRef.current);
1028
+ recTimerRef.current = setInterval(() => setRecSecs((s) => s + 1), 1e3);
1029
+ mr.ondataavailable = (ev) => {
1030
+ if (ev.data.size > 0) audioChunksRef.current.push(ev.data);
1031
+ };
1032
+ mr.onstop = async () => {
1033
+ var _a2;
1034
+ stream.getTracks().forEach((t) => t.stop());
1035
+ clearInterval(recTimerRef.current);
1036
+ try {
1037
+ (_a2 = audioCtxRef.current) == null ? void 0 : _a2.close();
1038
+ } catch {
1039
+ }
1040
+ analyserRef.current = null;
1041
+ if (cancelAudioRef.current) return;
1042
+ const blob = new Blob(audioChunksRef.current, { type: mr.mimeType || "audio/webm" });
1043
+ const previewUrl = URL.createObjectURL(blob);
1044
+ const data = await fileToDataUrl(blob);
1045
+ if (live) inbox.sendMedia({ data, mime: blob.type, kind: "audio", filename: "audio", previewUrl });
1046
+ else setMessages((ms) => [...ms, { id: `m${Date.now()}`, side: "out", kind: "audio", mediaUrl: previewUrl, time: formatNow(), status: "sent" }]);
1047
+ };
1048
+ mediaRecorderRef.current = mr;
1049
+ mr.start();
1050
+ setRecording(true);
1051
+ } catch {
1052
+ alert("N\xE3o foi poss\xEDvel acessar o microfone");
1053
+ }
1054
+ };
1055
+ const stopRecording = (cancel = false) => {
1056
+ var _a2;
1057
+ cancelAudioRef.current = cancel;
1058
+ setRecording(false);
1059
+ try {
1060
+ (_a2 = mediaRecorderRef.current) == null ? void 0 : _a2.stop();
1061
+ } catch {
1062
+ }
1063
+ };
1064
+ useEffect4(() => {
1065
+ if (!recording) return;
1066
+ const onKey = (e) => {
1067
+ if (e.key === "Escape") stopRecording(true);
1068
+ };
1069
+ window.addEventListener("keydown", onKey);
1070
+ return () => window.removeEventListener("keydown", onKey);
1071
+ }, [recording]);
1072
+ const handleSend = () => {
1073
+ const t = text.trim();
1074
+ if (!t) return;
1075
+ if (live) {
1076
+ inbox.send(t, composeMode === "note");
1077
+ setText("");
1078
+ return;
1079
+ }
1080
+ const id = `m${Date.now()}`;
1081
+ const time = formatNow();
1082
+ const msg = composeMode === "note" ? { id, side: "note", text: t, author: "Maria Eduarda", time } : { id, side: "out", kind: "text", text: t, time, status: "sent", author: "Maria Eduarda" };
1083
+ setMessages((ms) => [...ms, msg]);
1084
+ setText("");
1085
+ };
1086
+ const searchMatches = useMemo2(() => {
1087
+ const q = searchQuery.trim().toLowerCase();
1088
+ if (!q) return [];
1089
+ return threadMessages.filter((m) => {
1090
+ const t = (m.text || m.caption || "").toLowerCase();
1091
+ return t.includes(q);
1092
+ }).map((m) => m.id);
1093
+ }, [searchQuery, threadMessages]);
1094
+ useEffect4(() => {
1095
+ setSearchIndex(0);
1096
+ }, [searchQuery]);
1097
+ useEffect4(() => {
1098
+ if (typeof window === "undefined" || window.parent === window) return;
1099
+ const envOrigins = typeof process !== "undefined" && process.env && process.env.NEXT_PUBLIC_EMBED_ORIGINS || "";
1100
+ const allowed = envOrigins.split(",").map((s) => s.trim()).filter(Boolean);
1101
+ const onMsg = (e) => {
1102
+ if (allowed.length && !allowed.includes(e.origin)) return;
1103
+ const d = e.data || {};
1104
+ if (d.type === "veploy-chat-auth" && d.token && d.workspace) {
1105
+ const wasLive = !!localStorage.getItem("veploy_chat_token") && !!localStorage.getItem("veploy_chat_workspace");
1106
+ localStorage.setItem("veploy_chat_token", d.token);
1107
+ localStorage.setItem("veploy_chat_workspace", String(d.workspace));
1108
+ if (!wasLive) location.reload();
1109
+ }
1110
+ };
1111
+ window.addEventListener("message", onMsg);
1112
+ try {
1113
+ window.parent.postMessage({ type: "veploy-chat-ready" }, "*");
1114
+ } catch {
1115
+ }
1116
+ return () => window.removeEventListener("message", onMsg);
1117
+ }, []);
1118
+ const currentMatchId = searchMatches[searchIndex];
1119
+ const openSearch = () => {
1120
+ setSearchOpen(true);
1121
+ setSearchQuery("");
1122
+ };
1123
+ const closeSearch = () => {
1124
+ setSearchOpen(false);
1125
+ setSearchQuery("");
1126
+ };
1127
+ const nextMatch = () => searchMatches.length && setSearchIndex((i) => (i + 1) % searchMatches.length);
1128
+ const prevMatch = () => searchMatches.length && setSearchIndex((i) => (i - 1 + searchMatches.length) % searchMatches.length);
1129
+ const active = convList.find((c) => c.id === activeId);
1130
+ useEffect4(() => {
1131
+ if (scrollRef.current) scrollRef.current.scrollTop = scrollRef.current.scrollHeight;
1132
+ }, [activeId, threadMessages.length]);
1133
+ const counts = useMemo2(() => ({
1134
+ open: convList.filter((c) => c.status !== "resolved" && c.status !== "waiting").length,
1135
+ pending: convList.filter((c) => c.status === "waiting").length,
1136
+ all: convList.length
1137
+ }), [convList]);
1138
+ const filtered = useMemo2(() => {
1139
+ let list = convList;
1140
+ if (filter === "pending") list = list.filter((c) => c.status === "waiting");
1141
+ else if (filter !== "all") list = list.filter((c) => c.status !== "resolved" && c.status !== "waiting");
1142
+ if (unreadOnly) list = list.filter((c) => c.unread > 0);
1143
+ if (mineOnly) list = list.filter((c) => {
1144
+ var _a2;
1145
+ return ((_a2 = c._raw) == null ? void 0 : _a2.assignee_user_id) && c._raw.assignee_user_id === inbox.me;
1146
+ });
1147
+ return list;
1148
+ }, [filter, convList, unreadOnly, mineOnly, inbox.me]);
1149
+ return /* @__PURE__ */ jsxs3("div", { className: "h-full w-full bg-slate-100 flex text-slate-900", children: [
1150
+ /* @__PURE__ */ jsxs3("main", { className: "flex-1 flex overflow-hidden", children: [
1151
+ /* @__PURE__ */ jsxs3("section", { style: { width: listWidth }, className: "relative bg-white border-r border-slate-200 flex flex-col shrink-0", children: [
1152
+ /* @__PURE__ */ jsxs3("header", { className: "px-4 pt-4 pb-3 border-b border-slate-100", children: [
1153
+ /* @__PURE__ */ jsxs3("div", { className: "flex items-center justify-between mb-3", children: [
1154
+ /* @__PURE__ */ jsx5("h1", { className: "font-semibold text-[15px]", children: "Caixa de entrada" }),
1155
+ /* @__PURE__ */ jsxs3("div", { className: "flex items-center gap-1", children: [
1156
+ live && /* @__PURE__ */ jsx5(
1157
+ "button",
1158
+ {
1159
+ onClick: () => setConnectOpen(true),
1160
+ title: "Conectar WhatsApp",
1161
+ className: "p-1.5 rounded-md hover:bg-emerald-50 text-emerald-600",
1162
+ children: I.qrcode
1163
+ }
1164
+ ),
1165
+ /* @__PURE__ */ jsxs3("div", { className: "relative", children: [
1166
+ /* @__PURE__ */ jsx5(
1167
+ "button",
1168
+ {
1169
+ onClick: () => setFilterOpen((v) => !v),
1170
+ title: "Filtros",
1171
+ className: `p-1.5 rounded-md ${unreadOnly || mineOnly ? "bg-slate-900 text-white" : "hover:bg-slate-100 text-slate-500"}`,
1172
+ children: I.filter
1173
+ }
1174
+ ),
1175
+ filterOpen && /* @__PURE__ */ jsxs3("div", { className: "absolute right-0 top-[calc(100%+6px)] z-20 w-52 bg-white border border-slate-200 rounded-xl shadow-lg py-1.5 text-[13px]", children: [
1176
+ /* @__PURE__ */ jsxs3("label", { className: "flex items-center gap-2 px-3 py-1.5 hover:bg-slate-50 cursor-pointer", children: [
1177
+ /* @__PURE__ */ jsx5("input", { type: "checkbox", checked: unreadOnly, onChange: (e) => setUnreadOnly(e.target.checked) }),
1178
+ " S\xF3 n\xE3o lidas"
1179
+ ] }),
1180
+ live && /* @__PURE__ */ jsxs3("label", { className: "flex items-center gap-2 px-3 py-1.5 hover:bg-slate-50 cursor-pointer", children: [
1181
+ /* @__PURE__ */ jsx5("input", { type: "checkbox", checked: mineOnly, onChange: (e) => setMineOnly(e.target.checked) }),
1182
+ " Atribu\xEDdas a mim"
1183
+ ] }),
1184
+ (unreadOnly || mineOnly) && /* @__PURE__ */ jsx5(
1185
+ "button",
1186
+ {
1187
+ onClick: () => {
1188
+ setUnreadOnly(false);
1189
+ setMineOnly(false);
1190
+ },
1191
+ className: "w-full text-left px-3 py-1.5 text-slate-500 hover:bg-slate-50 border-t border-slate-100 mt-1",
1192
+ children: "Limpar filtros"
1193
+ }
1194
+ )
1195
+ ] })
1196
+ ] }),
1197
+ /* @__PURE__ */ jsx5("button", { className: "p-1.5 rounded-md text-slate-300 cursor-not-allowed", title: "Ordenar (em breve)", children: I.sort })
1198
+ ] })
1199
+ ] }),
1200
+ /* @__PURE__ */ jsxs3("div", { className: "relative", children: [
1201
+ /* @__PURE__ */ jsx5("span", { className: "absolute left-2.5 top-1/2 -translate-y-1/2 text-slate-400", children: I.search }),
1202
+ /* @__PURE__ */ jsx5("input", { placeholder: "Buscar conversas, n\xBA ou ticket\u2026", className: "w-full pl-8 pr-3 py-1.5 text-[13px] rounded-lg bg-slate-50 border border-slate-200 focus:bg-white focus:border-slate-300 outline-none" })
1203
+ ] }),
1204
+ /* @__PURE__ */ jsx5("div", { className: "flex items-center gap-2 mt-3 text-[12px]", children: [
1205
+ ["all", "Todas", counts.all],
1206
+ ["pending", "Pendentes", counts.pending],
1207
+ ["open", "Abertas", counts.open]
1208
+ ].map(([k, l, n]) => /* @__PURE__ */ jsxs3(
1209
+ "button",
1210
+ {
1211
+ onClick: () => setFilter(k),
1212
+ className: `relative px-3 py-1.5 rounded-full font-medium transition-colors
1213
+ ${filter === k ? "bg-slate-900 text-white" : "text-slate-600 hover:bg-slate-100"}`,
1214
+ children: [
1215
+ l,
1216
+ n > 0 && /* @__PURE__ */ jsx5("span", { className: "absolute -top-1.5 -right-1.5 min-w-[18px] h-[18px] px-1 rounded-full bg-slate-500 text-white text-[10px] font-bold inline-flex items-center justify-center ring-2 ring-white tabular-nums", children: n > 99 ? "99+" : n })
1217
+ ]
1218
+ },
1219
+ k
1220
+ )) })
1221
+ ] }),
1222
+ /* @__PURE__ */ jsx5("div", { className: "flex-1 overflow-y-auto", children: filtered.map((c) => /* @__PURE__ */ jsx5(ConversationItem, { c, active: c.id === activeId, onClick: () => {
1223
+ setActiveId(c.id);
1224
+ if (live) inbox.markRead(c.id);
1225
+ } }, c.id)) }),
1226
+ /* @__PURE__ */ jsxs3("footer", { className: "border-t border-slate-100 px-3 py-2 flex items-center justify-between text-[11px] text-slate-500", children: [
1227
+ /* @__PURE__ */ jsxs3("div", { className: "flex items-center gap-1.5", children: [
1228
+ /* @__PURE__ */ jsx5("span", { className: "w-1.5 h-1.5 rounded-full bg-emerald-500 animate-pulse" }),
1229
+ "Dispon\xEDvel para atender"
1230
+ ] }),
1231
+ /* @__PURE__ */ jsx5("button", { className: "hover:text-slate-700", children: "Pausar" })
1232
+ ] }),
1233
+ /* @__PURE__ */ jsx5(
1234
+ "div",
1235
+ {
1236
+ onMouseDown: startResize,
1237
+ title: "Arraste para redimensionar",
1238
+ className: "absolute top-0 right-0 h-full w-1.5 cursor-col-resize hover:bg-emerald-400/40 active:bg-emerald-500/50 z-10"
1239
+ }
1240
+ )
1241
+ ] }),
1242
+ /* @__PURE__ */ jsxs3("section", { className: "flex-1 flex flex-col bg-slate-50 min-w-0", children: [
1243
+ active && /* @__PURE__ */ jsx5(ChatHeader, { c: active, onToggleDetails: () => setDetailsOpen((v) => !v), detailsOpen, onOpenSearch: openSearch, onTransfer: () => setTransferOpen(true) }),
1244
+ searchOpen && /* @__PURE__ */ jsx5(
1245
+ SearchBar,
1246
+ {
1247
+ query: searchQuery,
1248
+ onChange: setSearchQuery,
1249
+ matches: searchMatches,
1250
+ currentIndex: searchIndex,
1251
+ onPrev: prevMatch,
1252
+ onNext: nextMatch,
1253
+ onClose: closeSearch
1254
+ }
1255
+ ),
1256
+ /* @__PURE__ */ jsxs3("div", { ref: scrollRef, className: "flex-1 overflow-y-auto px-6 py-5 space-y-1", children: [
1257
+ /* @__PURE__ */ jsx5(DayDivider, { label: "Hoje" }),
1258
+ threadMessages.map((m, i) => /* @__PURE__ */ jsx5(
1259
+ Message,
1260
+ {
1261
+ m,
1262
+ prev: threadMessages[i - 1],
1263
+ searchQuery: searchOpen ? searchQuery : "",
1264
+ isCurrentMatch: m.id === currentMatchId
1265
+ },
1266
+ m.id
1267
+ )),
1268
+ /* @__PURE__ */ jsx5("div", { className: "text-center mt-4", children: /* @__PURE__ */ jsxs3("span", { className: "text-[11px] text-slate-400 inline-flex items-center gap-1", children: [
1269
+ /* @__PURE__ */ jsx5(Avatar, { name: (active == null ? void 0 : active.name) || "", size: "sm", color: active == null ? void 0 : active.avatarColor }),
1270
+ " Conversa criada por voc\xEA \xB7 agora"
1271
+ ] }) })
1272
+ ] }),
1273
+ /* @__PURE__ */ jsx5("div", { className: "px-6 pb-5", children: /* @__PURE__ */ jsxs3("div", { className: "bg-white border border-slate-200 rounded-2xl shadow-soft", children: [
1274
+ /* @__PURE__ */ jsxs3("div", { className: "flex items-center gap-1 px-3 pt-2 text-[12px]", children: [
1275
+ [
1276
+ ["reply", "Mensagem"],
1277
+ ["note", "Nota interna"]
1278
+ ].map(([k, l]) => /* @__PURE__ */ jsx5(
1279
+ "button",
1280
+ {
1281
+ onClick: () => setComposeMode(k),
1282
+ className: `px-2.5 py-1 rounded-md font-medium ${composeMode === k ? k === "note" ? "bg-yellow-100 text-yellow-800" : "bg-slate-900 text-white" : "text-slate-600 hover:bg-slate-100"}`,
1283
+ children: l
1284
+ },
1285
+ k
1286
+ )),
1287
+ /* @__PURE__ */ jsx5("div", { className: "flex-1" }),
1288
+ /* @__PURE__ */ jsxs3("button", { onClick: () => setQuickOpen((v) => !v), className: "px-2.5 py-1 text-slate-600 hover:bg-slate-100 rounded-md inline-flex items-center gap-1 font-medium", children: [
1289
+ "\u2318K ",
1290
+ /* @__PURE__ */ jsx5("span", { className: "text-slate-400", children: "para respostas r\xE1pidas" })
1291
+ ] })
1292
+ ] }),
1293
+ quickOpen && /* @__PURE__ */ jsx5("div", { className: "px-3 py-2 border-t border-slate-100 bg-slate-50/60 flex flex-wrap gap-1.5", children: quickReplies.map((q) => /* @__PURE__ */ jsxs3(
1294
+ "button",
1295
+ {
1296
+ onClick: () => {
1297
+ setText(q.text);
1298
+ setQuickOpen(false);
1299
+ },
1300
+ className: "text-[12px] bg-white border border-slate-200 hover:border-slate-300 px-2.5 py-1 rounded-md text-slate-700",
1301
+ children: [
1302
+ /* @__PURE__ */ jsx5("span", { className: "text-slate-400 mr-1", children: "/" }),
1303
+ q.label
1304
+ ]
1305
+ },
1306
+ q.id
1307
+ )) }),
1308
+ /* @__PURE__ */ jsx5("div", { className: `px-4 py-3 ${composeMode === "note" ? "bg-yellow-50" : ""}`, children: /* @__PURE__ */ jsx5(
1309
+ "textarea",
1310
+ {
1311
+ ref: textareaRef,
1312
+ rows: 3,
1313
+ value: text,
1314
+ onChange: (e) => setText(e.target.value),
1315
+ onKeyDown: (e) => {
1316
+ if (e.key === "Enter" && !e.shiftKey) {
1317
+ e.preventDefault();
1318
+ handleSend();
1319
+ }
1320
+ },
1321
+ placeholder: composeMode === "note" ? "Adicione uma nota interna \u2014 vis\xEDvel s\xF3 para o time\u2026" : "Digite uma mensagem para Samir\u2026",
1322
+ className: `w-full text-[14px] resize-none bg-transparent outline-none placeholder:text-slate-400 ${composeMode === "note" ? "text-yellow-900 placeholder:text-yellow-600" : ""}`
1323
+ }
1324
+ ) }),
1325
+ /* @__PURE__ */ jsxs3("div", { className: "flex items-center gap-1 px-3 py-2 border-t border-slate-100", children: [
1326
+ recording ? /* @__PURE__ */ jsxs3("div", { className: "flex items-center gap-3 flex-1", children: [
1327
+ /* @__PURE__ */ jsx5("span", { className: "w-2 h-2 rounded-full bg-rose-500 animate-pulse shrink-0" }),
1328
+ /* @__PURE__ */ jsx5("span", { className: "text-[12.5px] text-rose-600 font-medium tabular-nums shrink-0", children: fmtSecs(recSecs) }),
1329
+ /* @__PURE__ */ jsx5(AudioWave, { analyserRef }),
1330
+ /* @__PURE__ */ jsx5("span", { className: "text-[11px] text-slate-400 shrink-0 hidden sm:inline", children: "Esc cancela" }),
1331
+ /* @__PURE__ */ jsx5("button", { onClick: () => stopRecording(true), className: "text-[12.5px] text-slate-500 px-2.5 py-1.5 rounded-lg hover:bg-slate-100 shrink-0", children: "Cancelar" }),
1332
+ /* @__PURE__ */ jsxs3("button", { onClick: () => stopRecording(false), className: "text-[13px] font-medium bg-emerald-600 hover:bg-emerald-700 text-white px-3 py-1.5 rounded-lg inline-flex items-center gap-1.5 shrink-0", children: [
1333
+ "Enviar ",
1334
+ /* @__PURE__ */ jsx5("span", { className: "opacity-90", children: I.send })
1335
+ ] })
1336
+ ] }) : /* @__PURE__ */ jsxs3(Fragment, { children: [
1337
+ /* @__PURE__ */ jsxs3("div", { className: "relative", children: [
1338
+ /* @__PURE__ */ jsx5(
1339
+ "button",
1340
+ {
1341
+ onClick: () => setEmojiOpen((v) => !v),
1342
+ title: "Emoji",
1343
+ className: `px-1.5 py-1.5 rounded-md inline-flex items-center ${emojiOpen ? "bg-slate-100 text-slate-900" : "text-slate-500 hover:bg-slate-100"}`,
1344
+ children: I.emoji
1345
+ }
1346
+ ),
1347
+ emojiOpen && /* @__PURE__ */ jsx5(EmojiPicker, { onPick: insertEmoji })
1348
+ ] }),
1349
+ /* @__PURE__ */ jsx5(AttachMenu, { onImage: () => {
1350
+ var _a2;
1351
+ return (_a2 = imageInputRef.current) == null ? void 0 : _a2.click();
1352
+ }, onFile: () => {
1353
+ var _a2;
1354
+ return (_a2 = fileInputRef.current) == null ? void 0 : _a2.click();
1355
+ } }),
1356
+ /* @__PURE__ */ jsx5(
1357
+ "button",
1358
+ {
1359
+ onClick: startRecording,
1360
+ title: "Gravar \xE1udio",
1361
+ className: "text-slate-500 hover:bg-slate-100 px-1.5 py-1.5 rounded-md inline-flex items-center",
1362
+ children: I.mic
1363
+ }
1364
+ ),
1365
+ /* @__PURE__ */ jsx5("div", { className: "flex-1" }),
1366
+ /* @__PURE__ */ jsxs3(
1367
+ "button",
1368
+ {
1369
+ onClick: handleSend,
1370
+ disabled: !text.trim(),
1371
+ className: `text-[13px] font-medium px-3.5 py-1.5 rounded-lg inline-flex items-center gap-1.5 disabled:opacity-50 disabled:cursor-not-allowed ${composeMode === "note" ? "bg-yellow-500 hover:bg-yellow-600 text-white" : "bg-emerald-600 hover:bg-emerald-700 text-white"}`,
1372
+ children: [
1373
+ composeMode === "note" ? "Salvar nota" : "Enviar",
1374
+ /* @__PURE__ */ jsx5("span", { className: "opacity-90", children: I.send })
1375
+ ]
1376
+ }
1377
+ )
1378
+ ] }),
1379
+ /* @__PURE__ */ jsx5("input", { ref: imageInputRef, type: "file", accept: "image/*", className: "hidden", onChange: onPickImage }),
1380
+ /* @__PURE__ */ jsx5("input", { ref: fileInputRef, type: "file", className: "hidden", onChange: onPickFile })
1381
+ ] })
1382
+ ] }) })
1383
+ ] }),
1384
+ detailsOpen && active && /* @__PURE__ */ jsx5(DetailsPanel, { c: active, onClose: () => setDetailsOpen(false) })
1385
+ ] }),
1386
+ connectOpen && /* @__PURE__ */ jsx5(ConnectChannel, { inbox, onClose: () => setConnectOpen(false) }),
1387
+ transferOpen && active && /* @__PURE__ */ jsx5(TransferModal, { inbox, conversationId: active.id, currentAssignee: (_a = active._raw) == null ? void 0 : _a.assignee_user_id, onClose: () => setTransferOpen(false) })
1388
+ ] });
1389
+ }
1390
+ function ConversationItem({ c, active, onClick }) {
1391
+ return /* @__PURE__ */ jsxs3(
1392
+ "button",
1393
+ {
1394
+ onClick,
1395
+ className: `w-full text-left px-3 py-3 border-l-2 transition-colors flex gap-3 ${active ? "bg-slate-50 border-emerald-500" : "border-transparent hover:bg-slate-50"}`,
1396
+ children: [
1397
+ /* @__PURE__ */ jsx5(Avatar, { name: c.name, color: c.avatarColor }),
1398
+ /* @__PURE__ */ jsxs3("div", { className: "flex-1 min-w-0", children: [
1399
+ /* @__PURE__ */ jsxs3("div", { className: "flex items-center justify-between gap-2", children: [
1400
+ /* @__PURE__ */ jsxs3("div", { className: "flex items-center gap-1.5 min-w-0", children: [
1401
+ /* @__PURE__ */ jsx5("span", { className: `text-[13.5px] truncate ${c.unread ? "font-semibold" : "font-medium text-slate-800"}`, children: c.name }),
1402
+ c.starred && /* @__PURE__ */ jsx5("span", { className: "text-amber-400", children: I.star })
1403
+ ] }),
1404
+ /* @__PURE__ */ jsx5("span", { className: `text-[11px] shrink-0 ${c.unread ? "text-emerald-600 font-semibold" : "text-slate-400"}`, children: c.waitFor })
1405
+ ] }),
1406
+ /* @__PURE__ */ jsxs3("div", { className: "flex items-center justify-between gap-2 mt-0.5", children: [
1407
+ /* @__PURE__ */ jsx5("p", { className: `text-[12.5px] truncate ${c.unread ? "text-slate-700" : "text-slate-500"}`, children: c.preview }),
1408
+ c.unread > 0 && /* @__PURE__ */ jsx5("span", { className: "shrink-0 min-w-[18px] h-[18px] px-1.5 rounded-full bg-emerald-500 text-white text-[10px] font-bold inline-flex items-center justify-center", children: c.unread })
1409
+ ] }),
1410
+ /* @__PURE__ */ jsx5("div", { className: "flex items-center gap-1.5 mt-1.5", children: /* @__PURE__ */ jsx5(Pill, { tone: "slate", children: c.ticket }) })
1411
+ ] })
1412
+ ]
1413
+ }
1414
+ );
1415
+ }
1416
+ function ChatHeader({ c, onToggleDetails, detailsOpen, onOpenSearch, onTransfer }) {
1417
+ const [menuOpen, setMenuOpen] = useState4(false);
1418
+ const menuRef = useRef3(null);
1419
+ useEffect4(() => {
1420
+ if (!menuOpen) return;
1421
+ const onDoc = (e) => {
1422
+ if (menuRef.current && !menuRef.current.contains(e.target)) setMenuOpen(false);
1423
+ };
1424
+ document.addEventListener("mousedown", onDoc);
1425
+ return () => document.removeEventListener("mousedown", onDoc);
1426
+ }, [menuOpen]);
1427
+ return /* @__PURE__ */ jsxs3("header", { className: "bg-white border-b border-slate-200 px-5 py-3 flex items-center gap-3 min-w-0", children: [
1428
+ /* @__PURE__ */ jsx5(Avatar, { name: c.name, color: c.avatarColor, size: "lg", online: true }),
1429
+ /* @__PURE__ */ jsxs3("div", { className: "flex-1 min-w-0", children: [
1430
+ /* @__PURE__ */ jsx5("div", { className: "flex items-center gap-2 min-w-0", children: /* @__PURE__ */ jsx5("h2", { className: "font-semibold text-[15px] truncate", children: c.name }) }),
1431
+ /* @__PURE__ */ jsxs3("div", { className: "flex items-center gap-2 text-[12px] text-slate-500 mt-0.5 min-w-0", children: [
1432
+ /* @__PURE__ */ jsxs3("span", { className: "inline-flex items-center gap-1 shrink-0", children: [
1433
+ I.phone,
1434
+ " ",
1435
+ c.phone
1436
+ ] }),
1437
+ /* @__PURE__ */ jsx5("span", { className: "hidden lg:inline text-slate-300 shrink-0", children: "\xB7" }),
1438
+ /* @__PURE__ */ jsxs3("span", { className: "hidden lg:inline-flex items-center gap-1 shrink-0", children: [
1439
+ I.tag,
1440
+ " ",
1441
+ c.ticket
1442
+ ] })
1443
+ ] })
1444
+ ] }),
1445
+ /* @__PURE__ */ jsxs3("div", { className: "hidden 2xl:flex items-center gap-4 text-[12px] pr-3 border-r border-slate-200 shrink-0", children: [
1446
+ /* @__PURE__ */ jsxs3("div", { className: "flex flex-col items-end leading-tight", children: [
1447
+ /* @__PURE__ */ jsx5("span", { className: "text-[9.5px] uppercase tracking-wide text-slate-400", children: "SLA" }),
1448
+ /* @__PURE__ */ jsx5("span", { className: "font-semibold text-amber-600 tabular-nums", children: "02:14" })
1449
+ ] }),
1450
+ /* @__PURE__ */ jsxs3("div", { className: "flex flex-col items-end leading-tight", children: [
1451
+ /* @__PURE__ */ jsx5("span", { className: "text-[9.5px] uppercase tracking-wide text-slate-400", children: "1\xAA resposta" }),
1452
+ /* @__PURE__ */ jsx5("span", { className: "font-semibold text-emerald-600 tabular-nums", children: "00:48" })
1453
+ ] })
1454
+ ] }),
1455
+ /* @__PURE__ */ jsxs3("button", { className: "shrink-0 text-[12.5px] font-medium bg-emerald-600 hover:bg-emerald-700 text-white px-3 py-1.5 rounded-lg inline-flex items-center gap-1.5", children: [
1456
+ I.check,
1457
+ " ",
1458
+ /* @__PURE__ */ jsx5("span", { className: "hidden lg:inline", children: "Resolver" })
1459
+ ] }),
1460
+ /* @__PURE__ */ jsx5("div", { className: "w-px h-6 bg-slate-200 shrink-0" }),
1461
+ /* @__PURE__ */ jsxs3("div", { className: "flex items-center gap-0.5 shrink-0", children: [
1462
+ /* @__PURE__ */ jsx5(
1463
+ "button",
1464
+ {
1465
+ onClick: onToggleDetails,
1466
+ title: "Detalhes",
1467
+ className: `p-1.5 rounded-md ${detailsOpen ? "bg-slate-900 text-white" : "text-slate-500 hover:bg-slate-100"}`,
1468
+ children: I.panel
1469
+ }
1470
+ ),
1471
+ /* @__PURE__ */ jsxs3("div", { ref: menuRef, className: "relative", children: [
1472
+ /* @__PURE__ */ jsx5(
1473
+ "button",
1474
+ {
1475
+ onClick: () => setMenuOpen((v) => !v),
1476
+ title: "Mais op\xE7\xF5es",
1477
+ className: `p-1.5 rounded-md ${menuOpen ? "bg-slate-100 text-slate-900" : "text-slate-500 hover:bg-slate-100"}`,
1478
+ children: I.more
1479
+ }
1480
+ ),
1481
+ menuOpen && /* @__PURE__ */ jsxs3("div", { className: "absolute right-0 top-[calc(100%+6px)] z-20 w-56 bg-white border border-slate-200 rounded-xl shadow-lg py-1.5 text-[13px]", children: [
1482
+ /* @__PURE__ */ jsx5(MenuItem, { icon: I.phone, label: "Ligar", onClick: () => setMenuOpen(false) }),
1483
+ /* @__PURE__ */ jsx5(MenuItem, { icon: I.forward, label: "Transferir", onClick: () => {
1484
+ setMenuOpen(false);
1485
+ onTransfer == null ? void 0 : onTransfer();
1486
+ } }),
1487
+ /* @__PURE__ */ jsx5(MenuItem, { icon: I.userPlus, label: "Adicionar participantes", onClick: () => setMenuOpen(false) }),
1488
+ /* @__PURE__ */ jsx5("div", { className: "my-1 h-px bg-slate-100" }),
1489
+ /* @__PURE__ */ jsx5(MenuItem, { icon: I.search, label: "Procurar na conversa", onClick: () => {
1490
+ setMenuOpen(false);
1491
+ onOpenSearch == null ? void 0 : onOpenSearch();
1492
+ } }),
1493
+ /* @__PURE__ */ jsx5(MenuItem, { icon: I.star, label: "Marcar com estrela", onClick: () => setMenuOpen(false) }),
1494
+ /* @__PURE__ */ jsx5(MenuItem, { icon: I.tag, label: "Editar tags", onClick: () => setMenuOpen(false) }),
1495
+ /* @__PURE__ */ jsx5(MenuItem, { icon: I.link, label: "Copiar link da conversa", onClick: () => setMenuOpen(false) }),
1496
+ /* @__PURE__ */ jsx5("div", { className: "my-1 h-px bg-slate-100" }),
1497
+ /* @__PURE__ */ jsx5(MenuItem, { icon: I.x, label: "Encerrar sem resolver", tone: "danger", onClick: () => setMenuOpen(false) })
1498
+ ] })
1499
+ ] })
1500
+ ] })
1501
+ ] });
1502
+ }
1503
+ function MenuItem({ icon, label, onClick, tone }) {
1504
+ const color = tone === "danger" ? "text-rose-600 hover:bg-rose-50" : "text-slate-700 hover:bg-slate-50";
1505
+ return /* @__PURE__ */ jsxs3(
1506
+ "button",
1507
+ {
1508
+ onClick,
1509
+ className: `w-full flex items-center gap-2.5 px-3 py-1.5 ${color}`,
1510
+ children: [
1511
+ /* @__PURE__ */ jsx5("span", { className: tone === "danger" ? "text-rose-500" : "text-slate-500", children: icon }),
1512
+ /* @__PURE__ */ jsx5("span", { className: "flex-1 text-left", children: label })
1513
+ ]
1514
+ }
1515
+ );
1516
+ }
1517
+ function SearchBar({ query, onChange, matches, currentIndex, onPrev, onNext, onClose }) {
1518
+ const inputRef = useRef3(null);
1519
+ useEffect4(() => {
1520
+ var _a;
1521
+ (_a = inputRef.current) == null ? void 0 : _a.focus();
1522
+ }, []);
1523
+ useEffect4(() => {
1524
+ const onKey = (e) => {
1525
+ if (e.key === "Escape") onClose();
1526
+ if (e.key === "Enter") {
1527
+ e.preventDefault();
1528
+ e.shiftKey ? onPrev() : onNext();
1529
+ }
1530
+ };
1531
+ window.addEventListener("keydown", onKey);
1532
+ return () => window.removeEventListener("keydown", onKey);
1533
+ }, [onClose, onPrev, onNext]);
1534
+ return /* @__PURE__ */ jsxs3("div", { className: "bg-white border-b border-slate-200 px-5 py-2 flex items-center gap-3", children: [
1535
+ /* @__PURE__ */ jsx5("span", { className: "text-slate-400 shrink-0", children: I.search }),
1536
+ /* @__PURE__ */ jsx5(
1537
+ "input",
1538
+ {
1539
+ ref: inputRef,
1540
+ value: query,
1541
+ onChange: (e) => onChange(e.target.value),
1542
+ placeholder: "Procurar na conversa\u2026",
1543
+ className: "flex-1 bg-transparent outline-none text-[13.5px] placeholder:text-slate-400 min-w-0"
1544
+ }
1545
+ ),
1546
+ query && /* @__PURE__ */ jsx5("span", { className: "text-[12px] text-slate-500 tabular-nums shrink-0", children: matches.length === 0 ? "sem resultados" : `${currentIndex + 1} de ${matches.length}` }),
1547
+ /* @__PURE__ */ jsxs3("div", { className: "flex items-center gap-0.5 shrink-0", children: [
1548
+ /* @__PURE__ */ jsx5(
1549
+ "button",
1550
+ {
1551
+ onClick: onPrev,
1552
+ disabled: matches.length === 0,
1553
+ title: "Anterior (Shift+Enter)",
1554
+ className: "p-1 rounded-md text-slate-500 hover:bg-slate-100 disabled:opacity-30 disabled:hover:bg-transparent",
1555
+ children: I.chevUp
1556
+ }
1557
+ ),
1558
+ /* @__PURE__ */ jsx5(
1559
+ "button",
1560
+ {
1561
+ onClick: onNext,
1562
+ disabled: matches.length === 0,
1563
+ title: "Pr\xF3ximo (Enter)",
1564
+ className: "p-1 rounded-md text-slate-500 hover:bg-slate-100 disabled:opacity-30 disabled:hover:bg-transparent",
1565
+ children: I.chevDown
1566
+ }
1567
+ ),
1568
+ /* @__PURE__ */ jsx5(
1569
+ "button",
1570
+ {
1571
+ onClick: onClose,
1572
+ title: "Fechar (Esc)",
1573
+ className: "p-1 rounded-md text-slate-500 hover:bg-slate-100 ml-1",
1574
+ children: I.x
1575
+ }
1576
+ )
1577
+ ] })
1578
+ ] });
1579
+ }
1580
+ function highlightText(text, query, isCurrent) {
1581
+ if (!query) return text;
1582
+ const q = query.trim();
1583
+ if (!q) return text;
1584
+ const lower = text.toLowerCase();
1585
+ const ql = q.toLowerCase();
1586
+ if (!lower.includes(ql)) return text;
1587
+ const parts = [];
1588
+ let last = 0;
1589
+ let idx = lower.indexOf(ql);
1590
+ let key = 0;
1591
+ while (idx !== -1) {
1592
+ if (idx > last) parts.push(text.slice(last, idx));
1593
+ parts.push(
1594
+ /* @__PURE__ */ jsx5("mark", { className: `rounded px-0.5 ${isCurrent ? "bg-amber-400 text-slate-900" : "bg-yellow-200 text-slate-900"}`, children: text.slice(idx, idx + ql.length) }, key++)
1595
+ );
1596
+ last = idx + ql.length;
1597
+ idx = lower.indexOf(ql, last);
1598
+ }
1599
+ if (last < text.length) parts.push(text.slice(last));
1600
+ return parts;
1601
+ }
1602
+ function DayDivider({ label }) {
1603
+ return /* @__PURE__ */ jsx5("div", { className: "flex items-center justify-center my-3", children: /* @__PURE__ */ jsx5("span", { className: "text-[11px] font-medium text-slate-600 bg-white border border-slate-200 rounded-full px-2.5 py-0.5 shadow-soft", children: label }) });
1604
+ }
1605
+ function Ticks({ status }) {
1606
+ if (status === "sent") return /* @__PURE__ */ jsx5("span", { className: "text-slate-400", children: "\u2713" });
1607
+ if (status === "delivered") return /* @__PURE__ */ jsx5("span", { className: "text-slate-400", children: "\u2713\u2713" });
1608
+ if (status === "read") return /* @__PURE__ */ jsx5("span", { className: "text-sky-500", children: "\u2713\u2713" });
1609
+ return null;
1610
+ }
1611
+ function Message({ m, searchQuery = "", isCurrentMatch = false }) {
1612
+ if (m.side === "system") {
1613
+ return /* @__PURE__ */ jsx5("div", { className: "flex justify-center my-2", children: /* @__PURE__ */ jsxs3("span", { className: "text-[11px] text-slate-500 bg-slate-100 rounded-full px-2.5 py-0.5", children: [
1614
+ m.text,
1615
+ " \xB7 ",
1616
+ m.time
1617
+ ] }) });
1618
+ }
1619
+ if (m.side === "note") {
1620
+ return /* @__PURE__ */ jsx5("div", { className: "flex justify-end my-2", children: /* @__PURE__ */ jsxs3("div", { className: `max-w-[70%] bg-yellow-50 border rounded-2xl rounded-tr-sm px-3.5 py-2.5 shadow-soft ${isCurrentMatch ? "border-amber-500 ring-2 ring-amber-300" : "border-yellow-200"}`, children: [
1621
+ /* @__PURE__ */ jsxs3("div", { className: "flex items-center justify-between gap-3 mb-1", children: [
1622
+ /* @__PURE__ */ jsxs3("span", { className: "text-[11px] font-semibold text-yellow-800 inline-flex items-center gap-1", children: [
1623
+ I.pin,
1624
+ " Nota interna \xB7 ",
1625
+ m.author
1626
+ ] }),
1627
+ /* @__PURE__ */ jsx5("span", { className: "text-[11px] text-yellow-700", children: m.time })
1628
+ ] }),
1629
+ /* @__PURE__ */ jsx5("p", { className: "text-[13.5px] text-yellow-900 leading-relaxed", children: highlightText(m.text, searchQuery, isCurrentMatch) })
1630
+ ] }) });
1631
+ }
1632
+ const isOut = m.side === "out";
1633
+ return /* @__PURE__ */ jsxs3("div", { className: `flex ${isOut ? "justify-end" : "justify-start"} group`, children: [
1634
+ !isOut && /* @__PURE__ */ jsx5(Avatar, { name: "Samir Patel", color: "bg-violet-500", size: "sm" }),
1635
+ /* @__PURE__ */ jsxs3("div", { className: `mx-2 max-w-[68%] ${isOut ? "order-first" : ""}`, children: [
1636
+ /* @__PURE__ */ jsxs3("div", { className: `relative px-3.5 py-2.5 rounded-2xl shadow-soft ${isOut ? "bg-emerald-600 text-white rounded-tr-sm" : "bg-white border border-slate-200 text-slate-800 rounded-tl-sm"} ${isCurrentMatch ? "ring-2 ring-amber-400" : ""}`, children: [
1637
+ m.kind === "text" && /* @__PURE__ */ jsx5("p", { className: "text-[13.5px] leading-relaxed whitespace-pre-wrap", children: highlightText(m.text, searchQuery, isCurrentMatch) }),
1638
+ m.kind === "image" && /* @__PURE__ */ jsxs3("div", { className: "-mx-1 -mt-1", children: [
1639
+ m.mediaUrl ? /* @__PURE__ */ jsx5("a", { href: m.mediaUrl, target: "_blank", rel: "noreferrer", children: /* @__PURE__ */ jsx5("img", { src: m.mediaUrl, alt: m.caption || "imagem", className: "w-64 max-h-72 object-cover rounded-lg" }) }) : /* @__PURE__ */ jsx5("div", { className: "w-64 h-40 rounded-lg bg-gradient-to-br from-slate-200 to-slate-300 flex items-center justify-center text-slate-500", children: I.image }),
1640
+ m.caption && /* @__PURE__ */ jsx5("p", { className: "text-[13px] mt-2", children: highlightText(m.caption, searchQuery, isCurrentMatch) })
1641
+ ] }),
1642
+ m.kind === "video" && /* @__PURE__ */ jsxs3("div", { className: "-mx-1 -mt-1", children: [
1643
+ m.mediaUrl ? /* @__PURE__ */ jsx5("video", { src: m.mediaUrl, controls: true, className: "w-64 rounded-lg" }) : /* @__PURE__ */ jsx5("div", { className: "w-64 h-40 rounded-lg bg-slate-200 flex items-center justify-center text-slate-500", children: "\u{1F3A5}" }),
1644
+ m.caption && /* @__PURE__ */ jsx5("p", { className: "text-[13px] mt-2", children: highlightText(m.caption, searchQuery, isCurrentMatch) })
1645
+ ] }),
1646
+ m.kind === "document" && /* @__PURE__ */ jsxs3(
1647
+ "a",
1648
+ {
1649
+ href: m.mediaUrl || "#",
1650
+ target: "_blank",
1651
+ rel: "noreferrer",
1652
+ className: `flex items-center gap-2.5 min-w-[200px] rounded-lg px-2 py-1.5 ${isOut ? "bg-emerald-700/40" : "bg-slate-100"}`,
1653
+ children: [
1654
+ /* @__PURE__ */ jsx5("span", { className: isOut ? "text-emerald-100" : "text-slate-500", children: I.file }),
1655
+ /* @__PURE__ */ jsx5("span", { className: "text-[13px] truncate flex-1", children: m.meta || m.caption || "arquivo" })
1656
+ ]
1657
+ }
1658
+ ),
1659
+ m.kind === "audio" && /* @__PURE__ */ jsxs3("div", { className: "flex items-center gap-3 min-w-[220px]", children: [
1660
+ /* @__PURE__ */ jsx5("button", { className: `w-9 h-9 rounded-full inline-flex items-center justify-center ${isOut ? "bg-emerald-700" : "bg-slate-100 text-slate-700"}`, children: "\u25B6" }),
1661
+ /* @__PURE__ */ jsxs3("div", { className: "flex-1", children: [
1662
+ /* @__PURE__ */ jsx5("div", { className: `h-1 rounded-full ${isOut ? "bg-emerald-700" : "bg-slate-200"} relative overflow-hidden`, children: /* @__PURE__ */ jsx5("div", { className: `h-full w-2/5 ${isOut ? "bg-white" : "bg-emerald-500"}` }) }),
1663
+ /* @__PURE__ */ jsx5("div", { className: `text-[11px] mt-1 ${isOut ? "text-emerald-100" : "text-slate-500"}`, children: m.duration })
1664
+ ] }),
1665
+ /* @__PURE__ */ jsx5("span", { className: isOut ? "text-emerald-100" : "text-slate-400", children: I.mic })
1666
+ ] }),
1667
+ /* @__PURE__ */ jsxs3("div", { className: `flex items-center gap-1 justify-end mt-1 text-[10.5px] ${isOut ? "text-emerald-100" : "text-slate-400"}`, children: [
1668
+ m.author && !isOut === false && /* @__PURE__ */ jsx5("span", { className: "mr-1", children: m.author }),
1669
+ /* @__PURE__ */ jsx5("span", { children: m.time }),
1670
+ isOut && /* @__PURE__ */ jsx5(Ticks, { status: m.status })
1671
+ ] })
1672
+ ] }),
1673
+ /* @__PURE__ */ jsxs3("div", { className: `flex gap-1 mt-1 opacity-0 group-hover:opacity-100 transition-opacity ${isOut ? "justify-end" : "justify-start"}`, children: [
1674
+ /* @__PURE__ */ jsx5(HoverBtn, { icon: I.reply }),
1675
+ /* @__PURE__ */ jsx5(HoverBtn, { icon: I.forward }),
1676
+ /* @__PURE__ */ jsx5(HoverBtn, { icon: I.emoji }),
1677
+ /* @__PURE__ */ jsx5(HoverBtn, { icon: I.more })
1678
+ ] })
1679
+ ] }),
1680
+ isOut && /* @__PURE__ */ jsx5(Avatar, { name: m.author || "Maria Eduarda", color: m.author === "Alissa Mendes" ? "bg-sky-500" : "bg-amber-500", size: "sm" })
1681
+ ] });
1682
+ }
1683
+ function HoverBtn({ icon }) {
1684
+ return /* @__PURE__ */ jsx5("button", { className: "p-1 rounded-md text-slate-400 bg-white border border-slate-200 hover:text-slate-700 shadow-soft", children: icon });
1685
+ }
1686
+ function fmtSecs(s) {
1687
+ const m = Math.floor(s / 60);
1688
+ return `${m}:${String(s % 60).padStart(2, "0")}`;
1689
+ }
1690
+ function AudioWave({ analyserRef }) {
1691
+ const MAX = 56;
1692
+ const [samples, setSamples] = useState4([]);
1693
+ useEffect4(() => {
1694
+ let raf;
1695
+ let last = 0;
1696
+ const buf = [];
1697
+ const loop = (ts) => {
1698
+ const an = analyserRef == null ? void 0 : analyserRef.current;
1699
+ if (an && ts - last > 70) {
1700
+ last = ts;
1701
+ const data = new Uint8Array(an.fftSize);
1702
+ an.getByteTimeDomainData(data);
1703
+ let sum = 0;
1704
+ for (let i = 0; i < data.length; i++) {
1705
+ const v = (data[i] - 128) / 128;
1706
+ sum += v * v;
1707
+ }
1708
+ const rms = Math.sqrt(sum / data.length);
1709
+ buf.push(Math.min(1, rms * 2.4));
1710
+ if (buf.length > MAX) buf.shift();
1711
+ setSamples([...buf]);
1712
+ }
1713
+ raf = requestAnimationFrame(loop);
1714
+ };
1715
+ raf = requestAnimationFrame(loop);
1716
+ return () => cancelAnimationFrame(raf);
1717
+ }, [analyserRef]);
1718
+ return /* @__PURE__ */ jsx5("div", { className: "flex items-center justify-start gap-[2px] h-7 flex-1 min-w-0 overflow-hidden", children: samples.map((v, i) => /* @__PURE__ */ jsx5(
1719
+ "span",
1720
+ {
1721
+ style: { height: `${Math.max(2, v * 26)}px` },
1722
+ className: "w-[2px] bg-rose-400 rounded-full shrink-0"
1723
+ },
1724
+ i
1725
+ )) });
1726
+ }
1727
+ function AttachMenu({ onImage, onFile }) {
1728
+ const [open, setOpen] = useState4(false);
1729
+ const ref = useRef3(null);
1730
+ useEffect4(() => {
1731
+ if (!open) return;
1732
+ const onDoc = (e) => {
1733
+ if (ref.current && !ref.current.contains(e.target)) setOpen(false);
1734
+ };
1735
+ document.addEventListener("mousedown", onDoc);
1736
+ return () => document.removeEventListener("mousedown", onDoc);
1737
+ }, [open]);
1738
+ return /* @__PURE__ */ jsxs3("div", { ref, className: "relative", children: [
1739
+ /* @__PURE__ */ jsx5(
1740
+ "button",
1741
+ {
1742
+ onClick: () => setOpen((v) => !v),
1743
+ title: "Anexar",
1744
+ className: `px-1.5 py-1.5 rounded-md inline-flex items-center ${open ? "bg-slate-100 text-slate-900" : "text-slate-500 hover:bg-slate-100"}`,
1745
+ children: I.paperclip
1746
+ }
1747
+ ),
1748
+ open && /* @__PURE__ */ jsxs3("div", { className: "absolute bottom-[calc(100%+6px)] left-0 z-20 w-44 bg-white border border-slate-200 rounded-xl shadow-lg py-1.5 text-[13px]", children: [
1749
+ /* @__PURE__ */ jsx5(MenuItem, { icon: I.image, label: "Imagem", onClick: () => {
1750
+ setOpen(false);
1751
+ onImage == null ? void 0 : onImage();
1752
+ } }),
1753
+ /* @__PURE__ */ jsx5(MenuItem, { icon: I.file, label: "Documento", onClick: () => {
1754
+ setOpen(false);
1755
+ onFile == null ? void 0 : onFile();
1756
+ } })
1757
+ ] })
1758
+ ] });
1759
+ }
1760
+ function DetailsPanel({ c, onClose }) {
1761
+ const [tab, setTab] = useState4("details");
1762
+ return /* @__PURE__ */ jsxs3("aside", { className: "w-[340px] bg-white border-l border-slate-200 flex flex-col", children: [
1763
+ /* @__PURE__ */ jsxs3("header", { className: "px-4 py-3 border-b border-slate-200 flex items-center justify-between", children: [
1764
+ /* @__PURE__ */ jsx5("div", { className: "flex gap-3 text-[12.5px]", children: [
1765
+ ["details", "Detalhes"],
1766
+ ["notes", "Notas"],
1767
+ ["history", "Hist\xF3rico"]
1768
+ ].map(([k, l]) => /* @__PURE__ */ jsx5(
1769
+ "button",
1770
+ {
1771
+ onClick: () => setTab(k),
1772
+ className: `pb-2 -mb-3 font-medium border-b-2 ${tab === k ? "border-slate-900 text-slate-900" : "border-transparent text-slate-500 hover:text-slate-800"}`,
1773
+ children: l
1774
+ },
1775
+ k
1776
+ )) }),
1777
+ /* @__PURE__ */ jsxs3("div", { className: "flex items-center gap-1", children: [
1778
+ /* @__PURE__ */ jsx5("button", { className: "p-1.5 rounded-md text-slate-500 hover:bg-slate-100", children: I.external }),
1779
+ /* @__PURE__ */ jsx5("button", { onClick: onClose, className: "p-1.5 rounded-md text-slate-500 hover:bg-slate-100", children: I.x })
1780
+ ] })
1781
+ ] }),
1782
+ /* @__PURE__ */ jsxs3("div", { className: "flex-1 overflow-y-auto", children: [
1783
+ tab === "details" && /* @__PURE__ */ jsx5(DetailsTab, { c }),
1784
+ tab === "notes" && /* @__PURE__ */ jsx5(NotesTab, {}),
1785
+ tab === "history" && /* @__PURE__ */ jsx5(HistoryTab, {})
1786
+ ] })
1787
+ ] });
1788
+ }
1789
+ function Section({ title, action, children, defaultOpen = true }) {
1790
+ const [open, setOpen] = useState4(defaultOpen);
1791
+ return /* @__PURE__ */ jsxs3("div", { className: "border-b border-slate-100", children: [
1792
+ /* @__PURE__ */ jsxs3("button", { onClick: () => setOpen((v) => !v), className: "w-full px-4 pt-4 pb-2 flex items-center justify-between", children: [
1793
+ /* @__PURE__ */ jsx5("span", { className: "text-[11px] font-semibold uppercase tracking-wider text-slate-500", children: title }),
1794
+ /* @__PURE__ */ jsx5("span", { className: `text-slate-400 transition-transform ${open ? "" : "-rotate-90"}`, children: I.chevDown })
1795
+ ] }),
1796
+ open && /* @__PURE__ */ jsxs3("div", { className: "px-4 pb-4 space-y-2.5", children: [
1797
+ children,
1798
+ action
1799
+ ] })
1800
+ ] });
1801
+ }
1802
+ function Row({ label, children }) {
1803
+ return /* @__PURE__ */ jsxs3("div", { className: "flex items-start gap-3 text-[12.5px]", children: [
1804
+ /* @__PURE__ */ jsx5("span", { className: "w-28 shrink-0 text-slate-500 pt-0.5", children: label }),
1805
+ /* @__PURE__ */ jsx5("div", { className: "flex-1 min-w-0 text-slate-800", children })
1806
+ ] });
1807
+ }
1808
+ var PROPERTY_CATALOG = [
1809
+ { id: "856235", title: "Apto 80m\xB2 \xB7 Jardins \xB7 2 dorm" },
1810
+ { id: "856301", title: "Apto 65m\xB2 \xB7 Vila Mariana \xB7 2 dorm" },
1811
+ { id: "857188", title: "Cobertura 120m\xB2 \xB7 Itaim \xB7 3 dorm" },
1812
+ { id: "854902", title: "Casa 180m\xB2 \xB7 Alto de Pinheiros \xB7 4 dorm" },
1813
+ { id: "855417", title: "Studio 35m\xB2 \xB7 Pinheiros \xB7 1 dorm" },
1814
+ { id: "858033", title: "Apto 95m\xB2 \xB7 Moema \xB7 3 dorm" },
1815
+ { id: "858720", title: "Apto 110m\xB2 \xB7 Perdizes \xB7 3 dorm" }
1816
+ ];
1817
+ function PropertyLinker() {
1818
+ const [linked, setLinked] = useState4([PROPERTY_CATALOG[0], PROPERTY_CATALOG[5]]);
1819
+ const [query, setQuery] = useState4("");
1820
+ const [adding, setAdding] = useState4(false);
1821
+ const inputRef = useRef3(null);
1822
+ const wrapRef = useRef3(null);
1823
+ useEffect4(() => {
1824
+ var _a;
1825
+ if (adding) (_a = inputRef.current) == null ? void 0 : _a.focus();
1826
+ }, [adding]);
1827
+ useEffect4(() => {
1828
+ if (!adding) return;
1829
+ const onDoc = (e) => {
1830
+ if (wrapRef.current && !wrapRef.current.contains(e.target)) closeAdd();
1831
+ };
1832
+ document.addEventListener("mousedown", onDoc);
1833
+ return () => document.removeEventListener("mousedown", onDoc);
1834
+ }, [adding]);
1835
+ const suggestions = useMemo2(() => {
1836
+ const q = query.trim().toLowerCase();
1837
+ const linkedIds = new Set(linked.map((p) => p.id));
1838
+ return PROPERTY_CATALOG.filter(
1839
+ (p) => !linkedIds.has(p.id) && (q === "" || p.id.toLowerCase().includes(q) || p.title.toLowerCase().includes(q))
1840
+ ).slice(0, 5);
1841
+ }, [query, linked]);
1842
+ const closeAdd = () => {
1843
+ setAdding(false);
1844
+ setQuery("");
1845
+ };
1846
+ const addProperty = (p) => {
1847
+ setLinked((l) => [...l, p]);
1848
+ closeAdd();
1849
+ };
1850
+ const removeProperty = (id) => setLinked((l) => l.filter((p) => p.id !== id));
1851
+ return /* @__PURE__ */ jsxs3("div", { ref: wrapRef, className: "w-full", children: [
1852
+ /* @__PURE__ */ jsxs3("div", { className: "flex flex-wrap items-center gap-x-3 gap-y-1", children: [
1853
+ linked.map((p) => /* @__PURE__ */ jsxs3("div", { className: "group inline-flex items-center gap-0.5 text-[13px] leading-tight", children: [
1854
+ /* @__PURE__ */ jsxs3(
1855
+ "a",
1856
+ {
1857
+ href: "#",
1858
+ title: p.title,
1859
+ className: "text-slate-700 underline underline-offset-2 hover:text-emerald-700 inline-flex items-center gap-1 tabular-nums",
1860
+ children: [
1861
+ p.id,
1862
+ /* @__PURE__ */ jsx5("span", { className: "text-slate-400 group-hover:text-emerald-600", children: I.external })
1863
+ ]
1864
+ }
1865
+ ),
1866
+ /* @__PURE__ */ jsx5(
1867
+ "button",
1868
+ {
1869
+ onClick: () => removeProperty(p.id),
1870
+ title: "Desvincular",
1871
+ className: "opacity-0 group-hover:opacity-100 p-0.5 text-slate-400 hover:text-rose-500 transition-opacity",
1872
+ children: /* @__PURE__ */ jsxs3("svg", { width: "11", height: "11", viewBox: "0 0 24 24", stroke: "currentColor", strokeWidth: "2.5", fill: "none", strokeLinecap: "round", children: [
1873
+ /* @__PURE__ */ jsx5("line", { x1: "6", y1: "6", x2: "18", y2: "18" }),
1874
+ /* @__PURE__ */ jsx5("line", { x1: "6", y1: "18", x2: "18", y2: "6" })
1875
+ ] })
1876
+ }
1877
+ )
1878
+ ] }, p.id)),
1879
+ !adding && /* @__PURE__ */ jsx5(
1880
+ "button",
1881
+ {
1882
+ onClick: () => setAdding(true),
1883
+ title: "Vincular im\xF3vel",
1884
+ className: "text-[11px] text-slate-500 hover:text-slate-800 inline-flex items-center gap-0.5 px-1.5 py-0.5 rounded-full border border-dashed border-slate-300 hover:border-slate-400 hover:bg-slate-50",
1885
+ children: "+ im\xF3vel"
1886
+ }
1887
+ )
1888
+ ] }),
1889
+ adding && /* @__PURE__ */ jsxs3("div", { className: "relative mt-2", children: [
1890
+ /* @__PURE__ */ jsx5("span", { className: "absolute left-2 top-1/2 -translate-y-1/2 text-slate-400 pointer-events-none", children: I.search }),
1891
+ /* @__PURE__ */ jsx5(
1892
+ "input",
1893
+ {
1894
+ ref: inputRef,
1895
+ value: query,
1896
+ onChange: (e) => setQuery(e.target.value),
1897
+ onKeyDown: (e) => {
1898
+ if (e.key === "Escape") closeAdd();
1899
+ },
1900
+ placeholder: "C\xF3digo ou bairro\u2026",
1901
+ className: "w-full pl-7 pr-2 py-1.5 text-[12px] rounded-lg bg-white border border-slate-300 outline-none focus:border-slate-400 placeholder:text-slate-400"
1902
+ }
1903
+ ),
1904
+ suggestions.length > 0 && /* @__PURE__ */ jsx5("div", { className: "absolute top-full left-0 right-0 mt-1 z-30 bg-white border border-slate-200 rounded-lg shadow-lg overflow-hidden", children: suggestions.map((p) => /* @__PURE__ */ jsxs3(
1905
+ "button",
1906
+ {
1907
+ onClick: () => addProperty(p),
1908
+ className: "w-full text-left px-2.5 py-1.5 hover:bg-slate-50 flex items-center gap-2 border-b border-slate-100 last:border-b-0",
1909
+ children: [
1910
+ /* @__PURE__ */ jsx5("span", { className: "text-[12.5px] font-mono font-semibold text-slate-700 tabular-nums", children: p.id }),
1911
+ /* @__PURE__ */ jsx5("span", { className: "text-slate-300", children: "\xB7" }),
1912
+ /* @__PURE__ */ jsx5("span", { className: "text-[11.5px] text-slate-500 truncate flex-1 min-w-0", children: p.title }),
1913
+ /* @__PURE__ */ jsx5("span", { className: "text-slate-300 shrink-0", children: I.plus })
1914
+ ]
1915
+ },
1916
+ p.id
1917
+ )) }),
1918
+ query.trim() && suggestions.length === 0 && /* @__PURE__ */ jsxs3("div", { className: "absolute top-full left-0 right-0 mt-1 z-30 bg-white border border-slate-200 rounded-lg shadow-lg px-3 py-2 text-[12px] text-slate-500", children: [
1919
+ 'Nenhum im\xF3vel encontrado para "',
1920
+ query.trim(),
1921
+ '".'
1922
+ ] })
1923
+ ] })
1924
+ ] });
1925
+ }
1926
+ function ActionRow({ icon, label, children, onClick }) {
1927
+ const [open, setOpen] = useState4(false);
1928
+ const hasSubmenu = !!children;
1929
+ const handle = () => hasSubmenu ? setOpen((v) => !v) : onClick == null ? void 0 : onClick();
1930
+ return /* @__PURE__ */ jsxs3("div", { children: [
1931
+ /* @__PURE__ */ jsxs3(
1932
+ "button",
1933
+ {
1934
+ onClick: handle,
1935
+ className: "w-full flex items-center gap-2 text-[13px] text-slate-700 hover:bg-slate-50 -mx-1 px-1 py-1 rounded-md",
1936
+ children: [
1937
+ /* @__PURE__ */ jsx5("span", { className: "text-slate-500", children: icon }),
1938
+ /* @__PURE__ */ jsx5("span", { className: "flex-1 text-left", children: label }),
1939
+ /* @__PURE__ */ jsx5("span", { className: `text-slate-400 transition-transform ${hasSubmenu && open ? "rotate-90" : ""}`, children: hasSubmenu ? I.chevRight : I.plus })
1940
+ ]
1941
+ }
1942
+ ),
1943
+ hasSubmenu && open && /* @__PURE__ */ jsx5("div", { className: "ml-7 mt-0.5 mb-1 border-l border-slate-200 pl-3 space-y-0.5", children })
1944
+ ] });
1945
+ }
1946
+ function SubAction({ label, onClick }) {
1947
+ return /* @__PURE__ */ jsx5(
1948
+ "button",
1949
+ {
1950
+ onClick,
1951
+ className: "w-full text-left text-[12.5px] text-slate-600 hover:text-slate-900 hover:bg-slate-50 -mx-1 px-1.5 py-1 rounded-md",
1952
+ children: label
1953
+ }
1954
+ );
1955
+ }
1956
+ function DetailsTab({ c }) {
1957
+ const palette = ["sky", "rose", "violet", "emerald", "amber", "slate"];
1958
+ const [tags, setTags] = useState4([
1959
+ { label: "Comprador", tone: "sky" },
1960
+ { label: "Quente", tone: "rose" },
1961
+ { label: "Apto 2-3 dorm", tone: "violet" },
1962
+ { label: "Zona Sul", tone: "emerald" },
1963
+ { label: "At\xE9 R$ 900k", tone: "amber" }
1964
+ ]);
1965
+ const [expanded, setExpanded] = useState4(false);
1966
+ const [adding, setAdding] = useState4(false);
1967
+ const [newTag, setNewTag] = useState4("");
1968
+ const tagInputRef = useRef3(null);
1969
+ useEffect4(() => {
1970
+ var _a;
1971
+ if (adding) (_a = tagInputRef.current) == null ? void 0 : _a.focus();
1972
+ }, [adding]);
1973
+ const VISIBLE = 3;
1974
+ const shownTags = expanded ? tags : tags.slice(0, VISIBLE);
1975
+ const hiddenCount = Math.max(0, tags.length - VISIBLE);
1976
+ const addTag = () => {
1977
+ const v = newTag.trim();
1978
+ if (v) setTags((t) => [...t, { label: v, tone: palette[t.length % palette.length] }]);
1979
+ setNewTag("");
1980
+ setAdding(false);
1981
+ };
1982
+ const removeTag = (i) => setTags((t) => t.filter((_, idx) => idx !== i));
1983
+ return /* @__PURE__ */ jsxs3(Fragment, { children: [
1984
+ /* @__PURE__ */ jsxs3("div", { className: "px-4 pt-4 pb-3 flex items-start gap-3", children: [
1985
+ /* @__PURE__ */ jsx5(Avatar, { name: c.name, color: c.avatarColor, size: "xl", online: true }),
1986
+ /* @__PURE__ */ jsxs3("div", { className: "min-w-0 flex-1", children: [
1987
+ /* @__PURE__ */ jsx5("div", { className: "font-semibold truncate", children: c.name }),
1988
+ /* @__PURE__ */ jsx5("div", { className: "text-[12px] text-slate-500 truncate", children: c.phone }),
1989
+ /* @__PURE__ */ jsxs3("div", { className: "flex flex-wrap gap-1 mt-1.5", children: [
1990
+ shownTags.map((t, i) => /* @__PURE__ */ jsxs3(Pill, { tone: t.tone, children: [
1991
+ t.label,
1992
+ /* @__PURE__ */ jsx5(
1993
+ "button",
1994
+ {
1995
+ onClick: () => removeTag(i),
1996
+ title: "Remover",
1997
+ className: "ml-0.5 -mr-0.5 opacity-60 hover:opacity-100",
1998
+ children: /* @__PURE__ */ jsxs3("svg", { width: "10", height: "10", viewBox: "0 0 24 24", stroke: "currentColor", strokeWidth: "3", fill: "none", strokeLinecap: "round", children: [
1999
+ /* @__PURE__ */ jsx5("line", { x1: "6", y1: "6", x2: "18", y2: "18" }),
2000
+ /* @__PURE__ */ jsx5("line", { x1: "6", y1: "18", x2: "18", y2: "6" })
2001
+ ] })
2002
+ }
2003
+ )
2004
+ ] }, `${t.label}-${i}`)),
2005
+ !expanded && hiddenCount > 0 && /* @__PURE__ */ jsxs3(
2006
+ "button",
2007
+ {
2008
+ onClick: () => setExpanded(true),
2009
+ className: "text-[11px] text-slate-500 hover:text-slate-800 px-1.5 py-0.5 rounded-full hover:bg-slate-100 self-center",
2010
+ children: [
2011
+ "+",
2012
+ hiddenCount
2013
+ ]
2014
+ }
2015
+ ),
2016
+ expanded && tags.length > VISIBLE && /* @__PURE__ */ jsx5(
2017
+ "button",
2018
+ {
2019
+ onClick: () => setExpanded(false),
2020
+ className: "text-[11px] text-slate-500 hover:text-slate-800 px-1.5 py-0.5 rounded-full hover:bg-slate-100 self-center",
2021
+ children: "mostrar menos"
2022
+ }
2023
+ ),
2024
+ adding ? /* @__PURE__ */ jsx5(
2025
+ "input",
2026
+ {
2027
+ ref: tagInputRef,
2028
+ value: newTag,
2029
+ onChange: (e) => setNewTag(e.target.value),
2030
+ onBlur: addTag,
2031
+ onKeyDown: (e) => {
2032
+ if (e.key === "Enter") {
2033
+ e.preventDefault();
2034
+ addTag();
2035
+ }
2036
+ if (e.key === "Escape") {
2037
+ setNewTag("");
2038
+ setAdding(false);
2039
+ }
2040
+ },
2041
+ placeholder: "nova tag\u2026",
2042
+ className: "text-[11px] px-2 py-0.5 rounded-full bg-white border border-slate-300 outline-none focus:border-slate-500 w-24"
2043
+ }
2044
+ ) : /* @__PURE__ */ jsx5(
2045
+ "button",
2046
+ {
2047
+ onClick: () => {
2048
+ setExpanded(true);
2049
+ setAdding(true);
2050
+ },
2051
+ title: "Adicionar tag",
2052
+ className: "text-[11px] text-slate-500 hover:text-slate-800 inline-flex items-center gap-0.5 px-1.5 py-0.5 rounded-full border border-dashed border-slate-300 hover:border-slate-400 hover:bg-slate-50",
2053
+ children: "+ tag"
2054
+ }
2055
+ )
2056
+ ] })
2057
+ ] })
2058
+ ] }),
2059
+ /* @__PURE__ */ jsxs3(Section, { title: "Atribui\xE7\xE3o", children: [
2060
+ /* @__PURE__ */ jsx5(Row, { label: "Atendente", children: /* @__PURE__ */ jsxs3("span", { className: "inline-flex items-center gap-1.5", children: [
2061
+ /* @__PURE__ */ jsx5(Avatar, { name: "Maria Eduarda", size: "sm", color: "bg-amber-500" }),
2062
+ " Maria Eduarda"
2063
+ ] }) }),
2064
+ /* @__PURE__ */ jsx5(Row, { label: "Departamento", children: /* @__PURE__ */ jsxs3("span", { className: "inline-flex items-center gap-1.5", children: [
2065
+ /* @__PURE__ */ jsx5("span", { className: "w-5 h-5 rounded-md bg-rose-500 text-white text-[10px] flex items-center justify-center font-bold", children: "CO" }),
2066
+ "Comercial"
2067
+ ] }) }),
2068
+ /* @__PURE__ */ jsx5(Row, { label: "Origem", children: /* @__PURE__ */ jsxs3("span", { className: "inline-flex items-center gap-1.5 text-emerald-700", children: [
2069
+ I.whatsapp,
2070
+ " WhatsApp Business"
2071
+ ] }) })
2072
+ ] }),
2073
+ /* @__PURE__ */ jsxs3(Section, { title: "Ticket", children: [
2074
+ /* @__PURE__ */ jsx5(Row, { label: "Tipo", children: /* @__PURE__ */ jsx5(Pill, { tone: "rose", children: "\u{1F3E0} Interesse em compra" }) }),
2075
+ /* @__PURE__ */ jsx5(Row, { label: "Status", children: /* @__PURE__ */ jsx5(Pill, { tone: statusInfo[c.status].tone, children: statusInfo[c.status].label }) }),
2076
+ /* @__PURE__ */ jsx5(Row, { label: "Prioridade", children: /* @__PURE__ */ jsx5(Pill, { tone: c.priority === "urgent" ? "rose" : c.priority === "high" ? "amber" : "slate", children: "Alta" }) }),
2077
+ /* @__PURE__ */ jsx5(Row, { label: "Im\xF3veis", children: /* @__PURE__ */ jsx5(PropertyLinker, {}) }),
2078
+ /* @__PURE__ */ jsx5(Row, { label: "Aberto", children: "h\xE1 18 min" })
2079
+ ] }),
2080
+ /* @__PURE__ */ jsxs3(Section, { title: "A\xE7\xF5es", children: [
2081
+ /* @__PURE__ */ jsxs3(ActionRow, { icon: I.userPlus, label: "Adicionar cliente", children: [
2082
+ /* @__PURE__ */ jsx5(SubAction, { label: "Propriet\xE1rio" }),
2083
+ /* @__PURE__ */ jsx5(SubAction, { label: "Cliente" })
2084
+ ] }),
2085
+ /* @__PURE__ */ jsx5(ActionRow, { icon: I.checkCircle, label: "Criar tarefa" }),
2086
+ /* @__PURE__ */ jsx5(ActionRow, { icon: I.calendar, label: "Agendar visita" }),
2087
+ /* @__PURE__ */ jsx5(ActionRow, { icon: I.file, label: "Enviar documentos" })
2088
+ ] })
2089
+ ] });
2090
+ }
2091
+ function NotesTab() {
2092
+ return /* @__PURE__ */ jsxs3("div", { className: "p-4 space-y-3", children: [
2093
+ /* @__PURE__ */ jsxs3("div", { className: "bg-yellow-50 border border-yellow-200 rounded-xl p-3", children: [
2094
+ /* @__PURE__ */ jsxs3("div", { className: "flex items-center justify-between mb-1.5", children: [
2095
+ /* @__PURE__ */ jsxs3("span", { className: "text-[11.5px] font-semibold text-yellow-800 inline-flex items-center gap-1", children: [
2096
+ I.pin,
2097
+ " Maria Eduarda"
2098
+ ] }),
2099
+ /* @__PURE__ */ jsx5("span", { className: "text-[11px] text-yellow-700", children: "h\xE1 11 min" })
2100
+ ] }),
2101
+ /* @__PURE__ */ jsx5("p", { className: "text-[13px] text-yellow-900", children: "Cliente Gold \u2014 perfil quente, decis\xE3o r\xE1pida. J\xE1 visitou conosco em fev/26 (ticket #7892), gostou da regi\xE3o mas o im\xF3vel estava acima do or\xE7amento." })
2102
+ ] }),
2103
+ /* @__PURE__ */ jsxs3("div", { className: "bg-yellow-50 border border-yellow-200 rounded-xl p-3", children: [
2104
+ /* @__PURE__ */ jsxs3("div", { className: "flex items-center justify-between mb-1.5", children: [
2105
+ /* @__PURE__ */ jsxs3("span", { className: "text-[11.5px] font-semibold text-yellow-800 inline-flex items-center gap-1", children: [
2106
+ I.pin,
2107
+ " Alissa Mendes"
2108
+ ] }),
2109
+ /* @__PURE__ */ jsx5("span", { className: "text-[11px] text-yellow-700", children: "h\xE1 4 min" })
2110
+ ] }),
2111
+ /* @__PURE__ */ jsx5("p", { className: "text-[13px] text-yellow-900", children: "Confirmei com os propriet\xE1rios \u2014 Vila Mariana e Moema liberados pra visita amanh\xE3 das 10h \xE0s 17h." })
2112
+ ] }),
2113
+ /* @__PURE__ */ jsxs3("button", { className: "w-full text-[12.5px] py-2 rounded-lg border border-dashed border-slate-300 text-slate-500 hover:bg-slate-50 inline-flex items-center justify-center gap-1", children: [
2114
+ I.plus,
2115
+ " Nova nota"
2116
+ ] })
2117
+ ] });
2118
+ }
2119
+ function HistoryTab() {
2120
+ const items = [
2121
+ { t: "Ticket #7892 \u2014 Visita apto Itaim", s: "Sem proposta", when: "fev/26", tone: "slate" },
2122
+ { t: "Ticket #7541 \u2014 Interesse em cobertura", s: "Resolvido", when: "jan/26", tone: "emerald" },
2123
+ { t: "Ticket #7233 \u2014 Pedido de matr\xEDcula", s: "Resolvido", when: "dez/25", tone: "emerald" },
2124
+ { t: "Ticket #6890 \u2014 Primeira simula\xE7\xE3o", s: "Resolvido", when: "out/25", tone: "emerald" }
2125
+ ];
2126
+ return /* @__PURE__ */ jsx5("div", { className: "p-4 space-y-2", children: items.map((it, i) => /* @__PURE__ */ jsxs3("button", { className: "w-full text-left bg-white border border-slate-200 hover:border-slate-300 rounded-xl p-3 flex items-start gap-3", children: [
2127
+ /* @__PURE__ */ jsx5("span", { className: "w-8 h-8 rounded-lg bg-slate-100 text-slate-500 flex items-center justify-center", children: I.chat }),
2128
+ /* @__PURE__ */ jsxs3("div", { className: "flex-1 min-w-0", children: [
2129
+ /* @__PURE__ */ jsx5("p", { className: "text-[13px] font-medium truncate", children: it.t }),
2130
+ /* @__PURE__ */ jsxs3("div", { className: "flex items-center gap-2 mt-1", children: [
2131
+ /* @__PURE__ */ jsx5(Pill, { tone: it.tone, children: it.s }),
2132
+ /* @__PURE__ */ jsx5("span", { className: "text-[11.5px] text-slate-500", children: it.when })
2133
+ ] })
2134
+ ] }),
2135
+ /* @__PURE__ */ jsx5("span", { className: "text-slate-400 mt-1", children: I.chevRight })
2136
+ ] }, i)) });
2137
+ }
2138
+
2139
+ // src/PloyChat.jsx
2140
+ import { jsx as jsx6 } from "react/jsx-runtime";
2141
+ function PloyChat({
2142
+ apiBase,
2143
+ workspaceId,
2144
+ getToken,
2145
+ supabase,
2146
+ supabaseUrl,
2147
+ supabaseAnonKey,
2148
+ className
2149
+ }) {
2150
+ const config = { apiBase, workspaceId, getToken, supabase, supabaseUrl, supabaseAnonKey };
2151
+ return /* @__PURE__ */ jsx6(PloyConfigProvider, { config, children: /* @__PURE__ */ jsx6("div", { className, style: { height: "100%", width: "100%" }, children: /* @__PURE__ */ jsx6(App, {}) }) });
2152
+ }
2153
+ var PloyChat_default = PloyChat;
2154
+ export {
2155
+ PloyChat,
2156
+ PloyChat_default as default
2157
+ };
2158
+ //# sourceMappingURL=index.js.map