@fayz-ai/plugin-support 0.3.0-canary.20261028142749 → 0.3.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/{HelpdeskConsole-QY534ASZ.js → HelpdeskConsole-EATEBVLN.js} +10 -7
- package/dist/HelpdeskConsole-EATEBVLN.js.map +1 -0
- package/dist/{LiveChatAgentWatcher-J6PNLYWT.js → LiveChatAgentWatcher-WEUHRRLC.js} +17 -23
- package/dist/LiveChatAgentWatcher-WEUHRRLC.js.map +1 -0
- package/dist/{OpenTicketFromConversation-KDXK7A6L.js → OpenTicketFromConversation-RC26KHN3.js} +4 -4
- package/dist/{OpenTicketFromConversation-KDXK7A6L.js.map → OpenTicketFromConversation-RC26KHN3.js.map} +1 -1
- package/dist/{SupportCenter-JBBBJTKU.js → SupportCenter-HGQL4PBX.js} +12 -9
- package/dist/SupportCenter-HGQL4PBX.js.map +1 -0
- package/dist/{SupportSettingsPage-PB6A3VCI.js → SupportSettingsPage-LIVZY2XQ.js} +3 -3
- package/dist/{SupportSettingsPage-PB6A3VCI.js.map → SupportSettingsPage-LIVZY2XQ.js.map} +1 -1
- package/dist/chunk-3WPESEK2.js +136 -0
- package/dist/chunk-3WPESEK2.js.map +1 -0
- package/dist/chunk-5MGCM5C4.js +181 -0
- package/dist/chunk-5MGCM5C4.js.map +1 -0
- package/dist/{chunk-PIMV3VRT.js → chunk-DTO5R6GN.js} +26 -126
- package/dist/chunk-DTO5R6GN.js.map +1 -0
- package/dist/chunk-E5242OSS.js +88 -0
- package/dist/chunk-E5242OSS.js.map +1 -0
- package/dist/{chunk-M4LUNCKI.js → chunk-E5EXC7QW.js} +57 -16
- package/dist/chunk-E5EXC7QW.js.map +1 -0
- package/dist/chunk-JOS2QQML.js +17 -0
- package/dist/chunk-JOS2QQML.js.map +1 -0
- package/dist/{chunk-WOZTA5LS.js → chunk-L2HGTGW4.js} +6 -4
- package/dist/chunk-L2HGTGW4.js.map +1 -0
- package/dist/{chunk-37ZZRVI7.js → chunk-P4VNMWIT.js} +79 -186
- package/dist/chunk-P4VNMWIT.js.map +1 -0
- package/dist/{chunk-CWCN5PDE.js → chunk-PHIPTZSD.js} +48 -5
- package/dist/chunk-PHIPTZSD.js.map +1 -0
- package/dist/chunk-QBOQYER7.js +1603 -0
- package/dist/chunk-QBOQYER7.js.map +1 -0
- package/dist/{chunk-MQXGB4IO.js → chunk-S766CRAY.js} +42 -239
- package/dist/chunk-S766CRAY.js.map +1 -0
- package/dist/chunk-WHEJ63CM.js +156 -0
- package/dist/chunk-WHEJ63CM.js.map +1 -0
- package/dist/chunk-Y673XGDK.js +261 -0
- package/dist/chunk-Y673XGDK.js.map +1 -0
- package/dist/data/api.d.ts +5 -0
- package/dist/data/api.d.ts.map +1 -1
- package/dist/data/console.d.ts +6 -0
- package/dist/data/console.d.ts.map +1 -1
- package/dist/data/mock-host.d.ts.map +1 -1
- package/dist/data/provider.d.ts +12 -0
- package/dist/data/provider.d.ts.map +1 -1
- package/dist/host.d.ts +21 -0
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +24 -10
- package/dist/host.js.map +1 -1
- package/dist/in-chat-install-2BTKBF2Z.js +11 -0
- package/dist/in-chat-install-2BTKBF2Z.js.map +1 -0
- package/dist/index.js +18 -191
- package/dist/index.js.map +1 -1
- package/dist/lib/imported.d.ts +27 -0
- package/dist/lib/imported.d.ts.map +1 -0
- package/dist/lib/report-tool.d.ts +54 -9
- package/dist/lib/report-tool.d.ts.map +1 -1
- package/dist/lib/vocabulary.d.ts.map +1 -1
- package/dist/livechat/LiveChatAgentWatcher.d.ts +3 -2
- package/dist/livechat/LiveChatAgentWatcher.d.ts.map +1 -1
- package/dist/livechat/in-chat-install.d.ts +19 -0
- package/dist/livechat/in-chat-install.d.ts.map +1 -0
- package/dist/livechat/in-chat-link.d.ts +10 -0
- package/dist/livechat/in-chat-link.d.ts.map +1 -0
- package/dist/livechat/in-chat-machine.d.ts +99 -0
- package/dist/livechat/in-chat-machine.d.ts.map +1 -0
- package/dist/livechat/in-chat-request-machine.d.ts +147 -0
- package/dist/livechat/in-chat-request-machine.d.ts.map +1 -0
- package/dist/livechat/in-chat-request.d.ts +94 -0
- package/dist/livechat/in-chat-request.d.ts.map +1 -0
- package/dist/livechat/in-chat-widgets.d.ts +39 -0
- package/dist/livechat/in-chat-widgets.d.ts.map +1 -0
- package/dist/livechat/in-chat.d.ts +119 -0
- package/dist/livechat/in-chat.d.ts.map +1 -0
- package/dist/livechat/report-intake.d.ts +45 -0
- package/dist/livechat/report-intake.d.ts.map +1 -0
- package/dist/livechat/screen-capture.d.ts +7 -0
- package/dist/livechat/screen-capture.d.ts.map +1 -0
- package/dist/migrations/index.d.ts +2 -0
- package/dist/migrations/index.d.ts.map +1 -1
- package/dist/migrations/main.browser.js +3 -1
- package/dist/migrations/main.browser.js.map +1 -1
- package/dist/migrations/main.js +1181 -2
- package/dist/migrations/main.js.map +1 -1
- package/dist/realtime-HQVWBTML.js +3 -0
- package/dist/realtime-HQVWBTML.js.map +1 -0
- package/dist/screen-capture-FRMTTRUY.js +77 -0
- package/dist/screen-capture-FRMTTRUY.js.map +1 -0
- package/dist/types.d.ts +5 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/views/SupportRequestsPanel.d.ts.map +1 -1
- package/dist/views/TicketSheet.d.ts +11 -1
- package/dist/views/TicketSheet.d.ts.map +1 -1
- package/package.json +5 -5
- package/dist/HelpdeskConsole-QY534ASZ.js.map +0 -1
- package/dist/LiveChatAgentWatcher-J6PNLYWT.js.map +0 -1
- package/dist/SupportCenter-JBBBJTKU.js.map +0 -1
- package/dist/chunk-37ZZRVI7.js.map +0 -1
- package/dist/chunk-CWCN5PDE.js.map +0 -1
- package/dist/chunk-JT4ZPWH7.js +0 -61
- package/dist/chunk-JT4ZPWH7.js.map +0 -1
- package/dist/chunk-M4LUNCKI.js.map +0 -1
- package/dist/chunk-MQXGB4IO.js.map +0 -1
- package/dist/chunk-PIMV3VRT.js.map +0 -1
- package/dist/chunk-STEDUFNR.js +0 -42
- package/dist/chunk-STEDUFNR.js.map +0 -1
- package/dist/chunk-WOZTA5LS.js.map +0 -1
|
@@ -1,120 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { useAgentsOnline, useConversationBell, useTyping } from './chunk-E5242OSS.js';
|
|
2
|
+
import { supportData, supportRealtime } from './chunk-WHEJ63CM.js';
|
|
3
|
+
import { liveChatError, PRESENCE_WAIT_MS, buildTranscript, chatSubject, customerPhase, queueLine } from './chunk-S766CRAY.js';
|
|
3
4
|
import { describeBusinessHours, isWithinBusinessHours } from './chunk-ZEHBREG5.js';
|
|
4
|
-
import
|
|
5
|
-
import { create } from 'zustand';
|
|
5
|
+
import React2 from 'react';
|
|
6
6
|
import { Loader2, Headset, Send } from 'lucide-react';
|
|
7
7
|
import { Button, Skeleton, cn, Textarea } from '@fayz-ai/ui';
|
|
8
8
|
import { currentAppPath } from '@fayz-ai/core';
|
|
9
9
|
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
10
10
|
|
|
11
|
-
var
|
|
12
|
-
requests: [],
|
|
13
|
-
loadingList: false,
|
|
14
|
-
scope: "mine",
|
|
15
|
-
filter: "all",
|
|
16
|
-
selectedId: null,
|
|
17
|
-
detail: null,
|
|
18
|
-
loadingDetail: false,
|
|
19
|
-
unread: 0,
|
|
20
|
-
setScope: (scope) => {
|
|
21
|
-
set({ scope });
|
|
22
|
-
void get().loadList();
|
|
23
|
-
},
|
|
24
|
-
setFilter: (filter) => {
|
|
25
|
-
set({ filter });
|
|
26
|
-
void get().loadList();
|
|
27
|
-
},
|
|
28
|
-
loadList: async () => {
|
|
29
|
-
set({ loadingList: true });
|
|
30
|
-
try {
|
|
31
|
-
const requests = await supportData().listRequests(get().scope, get().filter);
|
|
32
|
-
set({ requests });
|
|
33
|
-
} finally {
|
|
34
|
-
set({ loadingList: false });
|
|
35
|
-
}
|
|
36
|
-
},
|
|
37
|
-
select: async (id) => {
|
|
38
|
-
set({ selectedId: id, detail: null });
|
|
39
|
-
if (!id) return;
|
|
40
|
-
set({ loadingDetail: true });
|
|
41
|
-
try {
|
|
42
|
-
const detail = await supportData().getRequestDetail(id);
|
|
43
|
-
set({ detail });
|
|
44
|
-
await supportData().markNotificationsRead(id);
|
|
45
|
-
void get().refreshUnread();
|
|
46
|
-
} finally {
|
|
47
|
-
set({ loadingDetail: false });
|
|
48
|
-
}
|
|
49
|
-
},
|
|
50
|
-
refreshDetail: async () => {
|
|
51
|
-
const id = get().selectedId;
|
|
52
|
-
if (!id) return;
|
|
53
|
-
const detail = await supportData().getRequestDetail(id);
|
|
54
|
-
set({ detail });
|
|
55
|
-
},
|
|
56
|
-
refreshUnread: async () => {
|
|
57
|
-
set({ unread: await supportData().unreadCount() });
|
|
58
|
-
},
|
|
59
|
-
create: async (input, attachments) => {
|
|
60
|
-
const res = await supportData().createRequest(input, attachments);
|
|
61
|
-
await get().loadList();
|
|
62
|
-
return res;
|
|
63
|
-
},
|
|
64
|
-
sendMessage: async (body) => {
|
|
65
|
-
const id = get().selectedId;
|
|
66
|
-
if (!id || !body.trim()) return;
|
|
67
|
-
await supportData().addMessage(id, body);
|
|
68
|
-
await get().refreshDetail();
|
|
69
|
-
},
|
|
70
|
-
cancel: async () => {
|
|
71
|
-
const id = get().selectedId;
|
|
72
|
-
if (!id) return;
|
|
73
|
-
await supportData().cancelRequest(id);
|
|
74
|
-
await Promise.all([get().refreshDetail(), get().loadList()]);
|
|
75
|
-
},
|
|
76
|
-
validate: async (ok, reason) => {
|
|
77
|
-
const id = get().selectedId;
|
|
78
|
-
if (!id) return;
|
|
79
|
-
await supportData().validateRequest(id, ok, reason);
|
|
80
|
-
await Promise.all([get().refreshDetail(), get().loadList()]);
|
|
81
|
-
},
|
|
82
|
-
reset: () => set({ requests: [], loadingList: false, scope: "mine", filter: "all", selectedId: null, detail: null, loadingDetail: false, unread: 0 })
|
|
83
|
-
}));
|
|
84
|
-
function useLiveRequestDetail(id) {
|
|
85
|
-
const refresh = useSupportStore((s) => s.refreshDetail);
|
|
86
|
-
React3.useEffect(() => {
|
|
87
|
-
if (!id || typeof document === "undefined") return;
|
|
88
|
-
let timer = null;
|
|
89
|
-
const every = supportData().pollMs?.detail ?? 15e3;
|
|
90
|
-
const start = () => {
|
|
91
|
-
if (!timer) timer = setInterval(() => {
|
|
92
|
-
void refresh().catch(() => {
|
|
93
|
-
});
|
|
94
|
-
}, every);
|
|
95
|
-
};
|
|
96
|
-
const stop = () => {
|
|
97
|
-
if (timer) {
|
|
98
|
-
clearInterval(timer);
|
|
99
|
-
timer = null;
|
|
100
|
-
}
|
|
101
|
-
};
|
|
102
|
-
const onVis = () => document.visibilityState === "visible" ? start() : stop();
|
|
103
|
-
onVis();
|
|
104
|
-
document.addEventListener("visibilitychange", onVis);
|
|
105
|
-
return () => {
|
|
106
|
-
stop();
|
|
107
|
-
document.removeEventListener("visibilitychange", onVis);
|
|
108
|
-
};
|
|
109
|
-
}, [id, refresh]);
|
|
110
|
-
}
|
|
111
|
-
var SupportRailChromeContext = React3.createContext(null);
|
|
11
|
+
var SupportRailChromeContext = React2.createContext(null);
|
|
112
12
|
function useSupportRailChrome() {
|
|
113
|
-
return
|
|
13
|
+
return React2.useContext(SupportRailChromeContext);
|
|
114
14
|
}
|
|
115
15
|
function LiveChatPanel({ onBack, onOpenForm, requestId, transcript, originConversationId, route }) {
|
|
116
|
-
const [stage, setStage] =
|
|
117
|
-
|
|
16
|
+
const [stage, setStage] = React2.useState(requestId ? { t: "chat", id: requestId } : { t: "loading" });
|
|
17
|
+
React2.useEffect(() => {
|
|
118
18
|
if (requestId) return;
|
|
119
19
|
let alive = true;
|
|
120
20
|
supportData().chatAvailability().then((a) => {
|
|
@@ -161,14 +61,14 @@ function Connecting({ availability, transcript, originConversationId, route, onC
|
|
|
161
61
|
const counted = typeof availability.online === "number";
|
|
162
62
|
const watched = useAgentsOnline(counted ? null : availability.homeId);
|
|
163
63
|
const online = counted ? availability.online : watched;
|
|
164
|
-
const [timedOut, setTimedOut] =
|
|
165
|
-
const opening =
|
|
166
|
-
|
|
64
|
+
const [timedOut, setTimedOut] = React2.useState(false);
|
|
65
|
+
const opening = React2.useRef(false);
|
|
66
|
+
React2.useEffect(() => {
|
|
167
67
|
const t = setTimeout(() => setTimedOut(true), PRESENCE_WAIT_MS);
|
|
168
68
|
return () => clearTimeout(t);
|
|
169
69
|
}, []);
|
|
170
70
|
const available = (online ?? 0) > 0;
|
|
171
|
-
|
|
71
|
+
React2.useEffect(() => {
|
|
172
72
|
if (!available || opening.current) return;
|
|
173
73
|
opening.current = true;
|
|
174
74
|
const msgs = transcript ?? [];
|
|
@@ -182,7 +82,7 @@ function Connecting({ availability, transcript, originConversationId, route, onC
|
|
|
182
82
|
onError(liveChatError(e));
|
|
183
83
|
});
|
|
184
84
|
}, [available]);
|
|
185
|
-
|
|
85
|
+
React2.useEffect(() => {
|
|
186
86
|
if (!available && timedOut) onNobody();
|
|
187
87
|
}, [available, timedOut, onNobody]);
|
|
188
88
|
return /* @__PURE__ */ jsxs(Centered, { children: [
|
|
@@ -220,13 +120,13 @@ function fmtTime(iso) {
|
|
|
220
120
|
}
|
|
221
121
|
function ChatView({ requestId, onBack }) {
|
|
222
122
|
const rail = useSupportRailChrome();
|
|
223
|
-
const [state, setState] =
|
|
224
|
-
const [messages, setMessages] =
|
|
225
|
-
const [draft, setDraft] =
|
|
226
|
-
const [sending, setSending] =
|
|
227
|
-
const [error, setError] =
|
|
228
|
-
const scrollRef =
|
|
229
|
-
const reload =
|
|
123
|
+
const [state, setState] = React2.useState(null);
|
|
124
|
+
const [messages, setMessages] = React2.useState(null);
|
|
125
|
+
const [draft, setDraft] = React2.useState("");
|
|
126
|
+
const [sending, setSending] = React2.useState(false);
|
|
127
|
+
const [error, setError] = React2.useState(null);
|
|
128
|
+
const scrollRef = React2.useRef(null);
|
|
129
|
+
const reload = React2.useCallback(async () => {
|
|
230
130
|
try {
|
|
231
131
|
const [s, m] = await Promise.all([supportData().chatState(requestId), supportData().chatThread(requestId)]);
|
|
232
132
|
setState(s);
|
|
@@ -236,14 +136,14 @@ function ChatView({ requestId, onBack }) {
|
|
|
236
136
|
setError(liveChatError(e));
|
|
237
137
|
}
|
|
238
138
|
}, [requestId]);
|
|
239
|
-
|
|
139
|
+
React2.useEffect(() => {
|
|
240
140
|
void reload();
|
|
241
141
|
}, [reload]);
|
|
242
142
|
const live = supportRealtime();
|
|
243
143
|
useConversationBell(live ? state?.conversationId : null, (e) => {
|
|
244
144
|
if (e.event !== "typing") void reload();
|
|
245
145
|
});
|
|
246
|
-
|
|
146
|
+
React2.useEffect(() => {
|
|
247
147
|
let timer = null;
|
|
248
148
|
const every = supportData().pollMs?.chat ?? 2e4;
|
|
249
149
|
const start = () => {
|
|
@@ -266,7 +166,7 @@ function ChatView({ requestId, onBack }) {
|
|
|
266
166
|
};
|
|
267
167
|
}, [reload]);
|
|
268
168
|
const { otherTyping, notifyTyping } = useTyping(live ? state?.conversationId : null, "customer");
|
|
269
|
-
|
|
169
|
+
React2.useEffect(() => {
|
|
270
170
|
scrollRef.current?.scrollTo({ top: scrollRef.current.scrollHeight, behavior: "smooth" });
|
|
271
171
|
}, [messages?.length, otherTyping]);
|
|
272
172
|
async function send() {
|
|
@@ -368,6 +268,6 @@ function ChatView({ requestId, onBack }) {
|
|
|
368
268
|
] });
|
|
369
269
|
}
|
|
370
270
|
|
|
371
|
-
export { LiveChatPanel, SupportRailChromeContext,
|
|
372
|
-
//# sourceMappingURL=chunk-
|
|
373
|
-
//# sourceMappingURL=chunk-
|
|
271
|
+
export { LiveChatPanel, SupportRailChromeContext, useSupportRailChrome };
|
|
272
|
+
//# sourceMappingURL=chunk-DTO5R6GN.js.map
|
|
273
|
+
//# sourceMappingURL=chunk-DTO5R6GN.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/lib/rail-chrome.ts","../src/livechat/LiveChatPanel.tsx"],"names":["React"],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AS,MAAM,KAAK,MAAK,EAAG,YAAA,EAAW,UAC7F,QAAA,kBAAA,GAAA,CAAC,IAAA,EAAA,EAAK,SAAA,EAAU,SAAA,EAAU,CAAA,EAC5B;AAAA,KAAA,EACF,CAAA,EAEJ;AAAA,GAAA,EACF,CAAA;AAEJ","file":"chunk-DTO5R6GN.js","sourcesContent":["import React from 'react'\n\n// The support screens inside a column whose header is the shell's (the\n// assistant's right rail): the panel hands its title and \"Voltar\" to that\n// header, and the screens below stop drawing their own — one back link, one\n// title, never two.\nexport interface SupportRailChrome {\n /** Leaving support from its first screen (back to the assistant's chat). */\n onExit: () => void\n}\n\nexport const SupportRailChromeContext = React.createContext<SupportRailChrome | null>(null)\n\n/** Inside the rail: the header is the shell's, so the screen draws no back link or title of its own. */\nexport function useSupportRailChrome(): SupportRailChrome | null {\n return React.useContext(SupportRailChromeContext)\n}\n","import React from 'react'\nimport { Headset, Loader2, Send } from 'lucide-react'\nimport { Button, Skeleton, Textarea, cn } from '@fayz-ai/ui'\nimport { currentAppPath } from '@fayz-ai/core'\nimport { describeBusinessHours, isWithinBusinessHours } from '../lib/support-settings'\nimport { supportData, supportRealtime, type ChatThreadMessage } from '../data/provider'\nimport { liveChatError, type ChatAvailability, type ChatState } from './api'\nimport { useAgentsOnline, useConversationBell, useTyping } from './hooks'\nimport { PRESENCE_WAIT_MS, customerPhase, queueLine, type TranscriptMessage, buildTranscript, chatSubject } from './rules'\nimport { useSupportRailChrome } from '../lib/rail-chrome'\n\n// ---------------------------------------------------------------------------\n// \"Conversar com um atendente\" — the customer's side of the live chat (V1\n// ConnectToAgent + the chat ticket in the support panel, FLOW.md K3–K7).\n//\n// One click says what the person wants: with an agent online the conversation\n// opens by itself, no second \"confirm\" (V1). Without anyone online — or before\n// the presence says anything in 4 s — the central's offline message, its hours\n// and the way to leave a request (V1's absence screen, which V1 only shows in\n// a race; here it is the honest answer whenever nobody can take the chat).\n//\n// The conversation is the ticket's thread in the central's inbox (/conversations\n// on the agent's side): messages travel through the support RPCs, and the\n// screen re-reads on the conversation's bell (`conversa:<id>`). In a host\n// (`@fayz-ai/plugin-support/host`) everything goes through the host's data\n// provider and, with no Realtime of this pool in the page, the screen polls and\n// the server counts the agents online (their clock-in) instead of the presence.\n// ---------------------------------------------------------------------------\n\ntype ThreadMessage = ChatThreadMessage\n\nexport interface LiveChatPanelProps {\n /** Back to the support menu / list. */\n onBack: () => void\n /** \"Abrir uma solicitação\" from the absence screen. */\n onOpenForm: () => void\n /** Reopen this chat directly (\"Voltar à conversa\"). */\n requestId?: string | null\n /** The assistant conversation so far (V1: it goes along so nobody repeats). */\n transcript?: TranscriptMessage[]\n originConversationId?: string | null\n /** Where the person asked from (the assistant hand-off); default: the current path. */\n route?: string | null\n}\n\ntype Stage =\n | { t: 'loading' }\n | { t: 'connecting'; availability: ChatAvailability }\n | { t: 'offline'; availability: ChatAvailability | null }\n | { t: 'chat'; id: string }\n | { t: 'error'; message: string }\n\nexport function LiveChatPanel({ onBack, onOpenForm, requestId, transcript, originConversationId, route }: LiveChatPanelProps) {\n const [stage, setStage] = React.useState<Stage>(requestId ? { t: 'chat', id: requestId } : { t: 'loading' })\n\n React.useEffect(() => {\n if (requestId) return\n let alive = true\n supportData().chatAvailability()\n .then((a) => {\n if (!alive) return\n if (a?.activeChat) setStage({ t: 'chat', id: a.activeChat.id })\n else if (!a || !a.enabled || !a.homeId) setStage({ t: 'offline', availability: a })\n else setStage({ t: 'connecting', availability: a })\n })\n .catch((e) => { if (alive) setStage({ t: 'error', message: liveChatError(e) }) })\n return () => { alive = false }\n }, [requestId])\n\n if (stage.t === 'loading') return <Centered><Loader2 className=\"h-6 w-6 animate-spin text-muted-foreground\" /><p>Procurando um atendente disponível…</p></Centered>\n if (stage.t === 'error') return <Centered><p className=\"text-destructive\">{stage.message}</p><Button variant=\"outline\" onClick={onBack}>Voltar</Button></Centered>\n if (stage.t === 'offline') return <Offline availability={stage.availability} onOpenForm={onOpenForm} onBack={onBack} />\n if (stage.t === 'connecting') {\n return (\n <Connecting\n availability={stage.availability}\n transcript={transcript}\n originConversationId={originConversationId}\n route={route}\n onConnected={(id) => setStage({ t: 'chat', id })}\n onNobody={() => setStage({ t: 'offline', availability: stage.availability })}\n onError={(message) => setStage({ t: 'error', message })}\n />\n )\n }\n return <ChatView requestId={stage.id} onBack={onBack} />\n}\n\nfunction Centered({ children }: { children: React.ReactNode }) {\n return <div className=\"flex flex-col items-center justify-center gap-3 py-10 text-center text-sm text-muted-foreground\" aria-live=\"polite\">{children}</div>\n}\n\nfunction Connecting({ availability, transcript, originConversationId, route, onConnected, onNobody, onError }: {\n availability: ChatAvailability\n transcript?: TranscriptMessage[]\n originConversationId?: string | null\n route?: string | null\n onConnected: (id: string) => void\n onNobody: () => void\n onError: (message: string) => void\n}) {\n // Counted by the server (a host) or watched on the presence (the platform).\n const counted = typeof availability.online === 'number'\n const watched = useAgentsOnline(counted ? null : availability.homeId)\n const online = counted ? availability.online! : watched\n const [timedOut, setTimedOut] = React.useState(false)\n const opening = React.useRef(false)\n React.useEffect(() => { const t = setTimeout(() => setTimedOut(true), PRESENCE_WAIT_MS); return () => clearTimeout(t) }, [])\n\n const available = (online ?? 0) > 0\n React.useEffect(() => {\n if (!available || opening.current) return\n opening.current = true // strict mode runs effects twice: one conversation only\n const msgs = transcript ?? []\n supportData().openChat({\n subject: chatSubject(msgs),\n description: msgs.length ? buildTranscript(msgs) : null,\n route: route ?? currentAppPath(),\n originConversationId: originConversationId ?? null,\n })\n .then((r) => onConnected(r.id))\n .catch((e) => { opening.current = false; onError(liveChatError(e)) })\n }, [available]) // eslint-disable-line react-hooks/exhaustive-deps\n\n React.useEffect(() => {\n // The first sync can arrive before the agents' joins: \"nobody\" only counts\n // once the 4 s are over (V1 ESPERA_PRESENCA_MS).\n if (!available && timedOut) onNobody()\n }, [available, timedOut, onNobody])\n\n return (\n <Centered>\n <Loader2 className=\"h-6 w-6 animate-spin text-muted-foreground\" />\n <p>{available ? 'Chamando um atendente…' : 'Procurando um atendente disponível…'}</p>\n </Centered>\n )\n}\n\nfunction Offline({ availability, onOpenForm, onBack }: { availability: ChatAvailability | null; onOpenForm: () => void; onBack: () => void }) {\n const hours = availability ? describeBusinessHours({ businessHours: availability.businessHours }) : ''\n const inHours = availability ? isWithinBusinessHours({ businessHours: availability.businessHours, timezone: availability.timezone }) : false\n return (\n <div className=\"space-y-4 py-4\" data-testid=\"livechat-offline\">\n <div className=\"space-y-2 text-center\">\n <Headset className=\"mx-auto h-8 w-8 text-muted-foreground\" />\n <h2 className=\"text-base font-semibold\">Nenhum atendente disponível agora</h2>\n <p className=\"text-sm text-muted-foreground\">\n {availability?.offlineMessage ?? 'Abra uma solicitação e respondemos por aqui e por e-mail.'}\n </p>\n {hours && (\n <p className=\"text-xs text-muted-foreground\">\n Horário de atendimento: {hours}.{!inHours && ' Agora estamos fora desse horário.'}\n </p>\n )}\n </div>\n <div className=\"flex flex-col gap-2\">\n <Button onClick={onOpenForm}>Abrir uma solicitação</Button>\n <Button variant=\"ghost\" onClick={onBack}>Voltar</Button>\n </div>\n </div>\n )\n}\n\nfunction fmtTime(iso: string): string {\n try { return new Date(iso).toLocaleTimeString('pt-BR', { hour: '2-digit', minute: '2-digit' }) } catch { return '' }\n}\n\nfunction ChatView({ requestId, onBack }: { requestId: string; onBack: () => void }) {\n const rail = useSupportRailChrome()\n const [state, setState] = React.useState<ChatState | null>(null)\n const [messages, setMessages] = React.useState<ThreadMessage[] | null>(null)\n const [draft, setDraft] = React.useState('')\n const [sending, setSending] = React.useState(false)\n const [error, setError] = React.useState<string | null>(null)\n const scrollRef = React.useRef<HTMLDivElement>(null)\n\n const reload = React.useCallback(async () => {\n try {\n const [s, m] = await Promise.all([supportData().chatState(requestId), supportData().chatThread(requestId)])\n setState(s); setMessages(m); setError(null)\n } catch (e) { setError(liveChatError(e)) }\n }, [requestId])\n\n React.useEffect(() => { void reload() }, [reload])\n // The bell re-reads (message, changed). A slow safety net while the tab is\n // visible covers a dropped realtime connection.\n const live = supportRealtime()\n useConversationBell(live ? state?.conversationId : null, (e) => { if (e.event !== 'typing') void reload() })\n React.useEffect(() => {\n let timer: ReturnType<typeof setInterval> | null = null\n const every = supportData().pollMs?.chat ?? 20_000\n const start = () => { if (!timer) timer = setInterval(() => { void reload() }, every) }\n const stop = () => { if (timer) { clearInterval(timer); timer = null } }\n const onVis = () => (document.visibilityState === 'visible' ? start() : stop())\n onVis()\n document.addEventListener('visibilitychange', onVis)\n return () => { stop(); document.removeEventListener('visibilitychange', onVis) }\n }, [reload])\n\n const { otherTyping, notifyTyping } = useTyping(live ? state?.conversationId : null, 'customer')\n\n React.useEffect(() => {\n scrollRef.current?.scrollTo({ top: scrollRef.current.scrollHeight, behavior: 'smooth' })\n }, [messages?.length, otherTyping])\n\n async function send() {\n const body = draft.trim()\n if (!body) return\n setSending(true)\n try { await supportData().addMessage(requestId, body); setDraft(''); await reload() }\n catch (e) { setError(liveChatError(e)) }\n finally { setSending(false) }\n }\n\n async function validate(ok: boolean) {\n setSending(true)\n try { await supportData().validateRequest(requestId, ok, ok ? undefined : 'Ainda não resolveu (conversa ao vivo)'); await reload() }\n catch (e) { setError(liveChatError(e)) }\n finally { setSending(false) }\n }\n\n if (!state || !messages) {\n return (\n <div className=\"space-y-3 p-1\">\n {error ? <p className=\"text-sm text-destructive\">{error}</p> : <><Skeleton className=\"h-6 w-48\" /><Skeleton className=\"h-40 w-full\" /><Skeleton className=\"h-12 w-full\" /></>}\n </div>\n )\n }\n\n const phase = customerPhase(state)\n const subtitle = phase === 'waiting'\n ? 'Aguardando um atendente'\n : state.agentName ? `${state.agentName}, do suporte` : 'Equipe de suporte'\n\n return (\n <div className=\"flex h-[min(34rem,70vh)] min-h-[22rem] flex-col\" data-testid=\"livechat-chat\">\n <div className=\"flex items-center gap-3 border-b pb-3\">\n {!rail && <button onClick={onBack} className=\"rounded px-1 text-sm text-muted-foreground hover:bg-muted hover:text-foreground\" aria-label=\"Voltar\">←</button>}\n <span className=\"flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-success-soft text-success-soft-foreground\">\n <Headset className=\"h-4 w-4\" />\n </span>\n <div className=\"min-w-0 flex-1\">\n {/* In the rail its header already says \"Conversa com o suporte\". */}\n {!rail && <p className=\"truncate text-sm font-semibold\">Conversa com o suporte</p>}\n <p className={cn('truncate', rail ? 'text-sm font-medium' : 'text-xs text-muted-foreground')}>#{state.number} · {subtitle}</p>\n </div>\n </div>\n\n <div ref={scrollRef} className=\"min-h-0 flex-1 space-y-2 overflow-y-auto py-3\">\n {messages.map((m) => (\n <div key={m.id} className={m.mine ? 'flex justify-end' : 'flex justify-start'}>\n <div className={cn('max-w-[85%] rounded-2xl px-3 py-2 text-sm', m.mine ? 'rounded-br-sm bg-primary text-primary-foreground' : 'rounded-bl-sm bg-muted text-foreground')}>\n <div className={cn('mb-0.5 text-[10px]', m.mine ? 'text-primary-foreground/70' : 'text-muted-foreground')}>\n {m.mine ? 'Você' : (m.author ?? 'Suporte')} · {fmtTime(m.at)}\n </div>\n <div className=\"whitespace-pre-wrap\">{m.body}</div>\n </div>\n </div>\n ))}\n {phase === 'waiting' && (\n <div className=\"flex items-start gap-2 rounded-lg border border-dashed p-3 text-xs text-muted-foreground\" data-testid=\"livechat-waiting\">\n <span className=\"mt-1 h-2 w-2 shrink-0 animate-pulse rounded-full bg-success\" />\n <div>\n <p>Aguardando um atendente. A equipe já recebeu a sua conversa, não precisa repetir.</p>\n {queueLine(state.position) && <p className=\"mt-0.5 font-medium text-foreground\">{queueLine(state.position)}</p>}\n </div>\n </div>\n )}\n {otherTyping && (\n <p className=\"text-xs italic text-muted-foreground\" data-testid=\"livechat-agent-typing\">Suporte está digitando…</p>\n )}\n </div>\n\n {error && <p className=\"pb-2 text-xs text-destructive\">{error}</p>}\n\n <div className=\"border-t pt-3\">\n {phase === 'resolved' ? (\n <div className=\"space-y-2\" data-testid=\"livechat-resolved\">\n <p className=\"text-sm\">A equipe marcou como resolvida. Ficou bom?</p>\n <div className=\"flex justify-end gap-2\">\n <Button variant=\"outline\" size=\"sm\" disabled={sending} onClick={() => void validate(false)}>Ainda não resolveu</Button>\n <Button size=\"sm\" disabled={sending} onClick={() => void validate(true)}>Ficou bom</Button>\n </div>\n </div>\n ) : phase === 'closed' ? (\n <p className=\"text-center text-xs text-muted-foreground\" data-testid=\"livechat-closed\">Conversa encerrada. Obrigado pelo contato!</p>\n ) : (\n <div className=\"flex items-end gap-2\">\n <Textarea\n rows={1}\n value={draft}\n onChange={(e) => { setDraft(e.target.value); if (e.target.value.trim()) notifyTyping() }}\n onKeyDown={(e) => { if (e.key === 'Enter' && !e.shiftKey) { e.preventDefault(); void send() } }}\n placeholder=\"Escreva sua mensagem…\"\n aria-label=\"Mensagem para o suporte\"\n className=\"max-h-32 min-h-[40px] flex-1 resize-none\"\n />\n <Button size=\"icon\" disabled={sending || !draft.trim()} onClick={() => void send()} aria-label=\"Enviar\">\n <Send className=\"h-4 w-4\" />\n </Button>\n </div>\n )}\n </div>\n </div>\n )\n}\n"]}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { TYPING_SHOW_MS, TYPING_EVERY_MS } from './chunk-S766CRAY.js';
|
|
2
|
+
import { observeAgentsOnline, listenTopic, conversationTopic, sendTyping } from './chunk-3WPESEK2.js';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
|
|
5
|
+
var KEY = "suporte:disponivel";
|
|
6
|
+
var subscribers = /* @__PURE__ */ new Set();
|
|
7
|
+
function read() {
|
|
8
|
+
try {
|
|
9
|
+
return localStorage.getItem(KEY) !== "0";
|
|
10
|
+
} catch {
|
|
11
|
+
return true;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
function setAgentAvailable(on) {
|
|
15
|
+
try {
|
|
16
|
+
localStorage.setItem(KEY, on ? "1" : "0");
|
|
17
|
+
} catch {
|
|
18
|
+
}
|
|
19
|
+
memo = on;
|
|
20
|
+
for (const f of [...subscribers]) f();
|
|
21
|
+
}
|
|
22
|
+
var memo = null;
|
|
23
|
+
function snapshot() {
|
|
24
|
+
return memo ?? (memo = read());
|
|
25
|
+
}
|
|
26
|
+
function useAgentAvailable() {
|
|
27
|
+
const value = React.useSyncExternalStore(
|
|
28
|
+
(cb) => {
|
|
29
|
+
subscribers.add(cb);
|
|
30
|
+
return () => {
|
|
31
|
+
subscribers.delete(cb);
|
|
32
|
+
};
|
|
33
|
+
},
|
|
34
|
+
snapshot,
|
|
35
|
+
() => true
|
|
36
|
+
);
|
|
37
|
+
return [value, setAgentAvailable];
|
|
38
|
+
}
|
|
39
|
+
function useAgentsOnline(centralId) {
|
|
40
|
+
const [n, setN] = React.useState(null);
|
|
41
|
+
React.useEffect(() => {
|
|
42
|
+
setN(null);
|
|
43
|
+
if (!centralId) return;
|
|
44
|
+
return observeAgentsOnline(centralId, setN);
|
|
45
|
+
}, [centralId]);
|
|
46
|
+
return n;
|
|
47
|
+
}
|
|
48
|
+
function useConversationBell(conversationId, onEvent) {
|
|
49
|
+
const ref = React.useRef(onEvent);
|
|
50
|
+
ref.current = onEvent;
|
|
51
|
+
React.useEffect(() => {
|
|
52
|
+
if (!conversationId) return;
|
|
53
|
+
return listenTopic(conversationTopic(conversationId), (e) => ref.current(e));
|
|
54
|
+
}, [conversationId]);
|
|
55
|
+
}
|
|
56
|
+
function useTyping(conversationId, me) {
|
|
57
|
+
const [otherTyping, setOtherTyping] = React.useState(false);
|
|
58
|
+
const last = React.useRef(0);
|
|
59
|
+
const timer = React.useRef(null);
|
|
60
|
+
useConversationBell(conversationId, (e) => {
|
|
61
|
+
if (e.event === "typing") {
|
|
62
|
+
if (e.payload.from === me) return;
|
|
63
|
+
setOtherTyping(true);
|
|
64
|
+
if (timer.current) clearTimeout(timer.current);
|
|
65
|
+
timer.current = setTimeout(() => setOtherTyping(false), TYPING_SHOW_MS);
|
|
66
|
+
} else if (e.event === "message" && e.payload.direction === (me === "customer" ? "outbound" : "inbound")) {
|
|
67
|
+
setOtherTyping(false);
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
React.useEffect(() => () => {
|
|
71
|
+
if (timer.current) clearTimeout(timer.current);
|
|
72
|
+
}, []);
|
|
73
|
+
React.useEffect(() => {
|
|
74
|
+
setOtherTyping(false);
|
|
75
|
+
}, [conversationId]);
|
|
76
|
+
const notifyTyping = React.useCallback(() => {
|
|
77
|
+
if (!conversationId) return;
|
|
78
|
+
const now = Date.now();
|
|
79
|
+
if (now - last.current < TYPING_EVERY_MS) return;
|
|
80
|
+
last.current = now;
|
|
81
|
+
sendTyping(conversationId, me);
|
|
82
|
+
}, [conversationId, me]);
|
|
83
|
+
return { otherTyping, notifyTyping };
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export { useAgentAvailable, useAgentsOnline, useConversationBell, useTyping };
|
|
87
|
+
//# sourceMappingURL=chunk-E5242OSS.js.map
|
|
88
|
+
//# sourceMappingURL=chunk-E5242OSS.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/livechat/hooks.ts"],"names":[],"mappings":";;;;AAUA,IAAM,GAAA,GAAM,oBAAA;AACZ,IAAM,WAAA,uBAAkB,GAAA,EAAgB;AAExC,SAAS,IAAA,GAAgB;AACvB,EAAA,IAAI;AAAE,IAAA,OAAO,YAAA,CAAa,OAAA,CAAQ,GAAG,CAAA,KAAM,GAAA;AAAA,EAAI,CAAA,CAAA,MAAQ;AAAE,IAAA,OAAO,IAAA;AAAA,EAAK;AACvE;AAEO,SAAS,kBAAkB,EAAA,EAAmB;AACnD,EAAA,IAAI;AAAE,IAAA,YAAA,CAAa,OAAA,CAAQ,GAAA,EAAK,EAAA,GAAK,GAAA,GAAM,GAAG,CAAA;AAAA,EAAE,CAAA,CAAA,MAAQ;AAAA,EAAyD;AACjH,EAAA,IAAA,GAAO,EAAA;AACP,EAAA,KAAA,MAAW,CAAA,IAAK,CAAC,GAAG,WAAW,GAAG,CAAA,EAAE;AACtC;AAEA,IAAI,IAAA,GAAuB,IAAA;AAC3B,SAAS,QAAA,GA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GAAA,GAAM,IAAA,CAAK,OAAA,GAAU,eAAA,EAAiB;AAC1C,IAAA,IAAA,CAAK,OAAA,GAAU,GAAA;AACf,IAAA,UAAA,CAAW,gBAAgB,EAAE,CAAA;AAAA,EAC/B,CAAA,EAAG,CAAC,cAAA,EAAgB,EAAE,CAAC,CAAA;AAEvB,EAAA,OAAO,EAAE,aAAa,YAAA,EAAa;AACrC","file":"chunk-E5242OSS.js","sourcesContent":["import React from 'react'\nimport {\n listenTopic, conversationTopic, sendTyping, observeAgentsOnline, type TypingSide, type LiveEvent,\n} from './realtime'\nimport { TYPING_EVERY_MS, TYPING_SHOW_MS } from './rules'\n\n// ── the agent's \"Disponível para conversas\" switch ─────────────────────────\n// One value per browser (V1: localStorage 'suporte:disponivel'), shared by the\n// board's switch and the header watcher that announces the presence.\n\nconst KEY = 'suporte:disponivel'\nconst subscribers = new Set<() => void>()\n\nfunction read(): boolean {\n try { return localStorage.getItem(KEY) !== '0' } catch { return true }\n}\n\nexport function setAgentAvailable(on: boolean): void {\n try { localStorage.setItem(KEY, on ? '1' : '0') } catch { /* no storage: the session still follows the switch */ }\n memo = on\n for (const f of [...subscribers]) f()\n}\n\nlet memo: boolean | null = null\nfunction snapshot(): boolean { return (memo ??= read()) }\n\nexport function useAgentAvailable(): [boolean, (on: boolean) => void] {\n const value = React.useSyncExternalStore(\n (cb) => { subscribers.add(cb); return () => { subscribers.delete(cb) } },\n snapshot,\n () => true,\n )\n return [value, setAgentAvailable]\n}\n\n// ── the customer's side ───────────────────────────────────────────────────\n\n/** Online agents of a central; null until the presence synced (V1 useAgentsOnline). */\nexport function useAgentsOnline(centralId: string | null | undefined): number | null {\n const [n, setN] = React.useState<number | null>(null)\n React.useEffect(() => {\n setN(null)\n if (!centralId) return\n return observeAgentsOnline(centralId, setN)\n }, [centralId])\n return n\n}\n\n/** Run `onEvent` on every bell of a conversation (message / changed / typing). */\nexport function useConversationBell(conversationId: string | null | undefined, onEvent: (e: LiveEvent) => void): void {\n const ref = React.useRef(onEvent)\n ref.current = onEvent\n React.useEffect(() => {\n if (!conversationId) return\n return listenTopic(conversationTopic(conversationId), (e) => ref.current(e))\n }, [conversationId])\n}\n\n/**\n * \"Digitando…\" of a conversation (V1 useTyping). `otherTyping` lights when the\n * OTHER side types and goes out on its own after 4 s; `notifyTyping` sends at\n * most one signal every 2 s.\n */\nexport function useTyping(conversationId: string | null | undefined, me: TypingSide) {\n const [otherTyping, setOtherTyping] = React.useState(false)\n const last = React.useRef(0)\n const timer = React.useRef<ReturnType<typeof setTimeout> | null>(null)\n\n useConversationBell(conversationId, (e) => {\n if (e.event === 'typing') {\n if (e.payload.from === me) return\n setOtherTyping(true)\n if (timer.current) clearTimeout(timer.current)\n timer.current = setTimeout(() => setOtherTyping(false), TYPING_SHOW_MS)\n } else if (e.event === 'message' && e.payload.direction === (me === 'customer' ? 'outbound' : 'inbound')) {\n // The message arrived: the other side stopped typing.\n setOtherTyping(false)\n }\n })\n React.useEffect(() => () => { if (timer.current) clearTimeout(timer.current) }, [])\n React.useEffect(() => { setOtherTyping(false) }, [conversationId])\n\n const notifyTyping = React.useCallback(() => {\n if (!conversationId) return\n const now = Date.now()\n if (now - last.current < TYPING_EVERY_MS) return\n last.current = now\n sendTyping(conversationId, me)\n }, [conversationId, me])\n\n return { otherTyping, notifyTyping }\n}\n"]}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { useConversationBell,
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { useConversationBell, useAgentAvailable } from './chunk-E5242OSS.js';
|
|
2
|
+
import { wakeV1Bridge, signedUrl, chatQueue, atChatLimit, limitLine, waitingFor, acceptChat, liveChatError, isActiveChatStatus, closeChat } from './chunk-S766CRAY.js';
|
|
3
|
+
import { listenTopic, queueTopic } from './chunk-3WPESEK2.js';
|
|
4
|
+
import { consoleDetail, consoleAgents, splitImportedAttachments, consoleThread, consoleThreadMessages, v1TicketAttachments, mergeV1Attachments, consoleSetStatus, consoleSetPriority, consoleAssign, consoleNote, consoleSetDevReference, consoleMarkDuplicate, consoleStartThread, consoleReply } from './chunk-PHIPTZSD.js';
|
|
5
|
+
import { TEAM_STATUS_ORDER, KIND_LABEL, TEAM_STATUS_LABEL, TEAM_PRIORITY_ORDER, PRIORITY_LABEL, teamEventLine, STATUS_LABEL, eventLine } from './chunk-L2HGTGW4.js';
|
|
4
6
|
import React2 from 'react';
|
|
5
7
|
import { MessageSquare, Lock, Sparkles, Headset, Loader2 } from 'lucide-react';
|
|
6
8
|
import { Sheet, SheetContent, SheetTitle, Button, Skeleton, SheetHeader, SheetDescription, cn, Select, SelectTrigger, SelectValue, SelectContent, SelectItem, SheetBody, SheetFooter, Textarea, Input, ModalTask, Thumbnail, TooltipProvider, Tooltip, TooltipTrigger, TooltipContent, PageHeaderActions, Switch, toast } from '@fayz-ai/ui';
|
|
@@ -340,6 +342,10 @@ function TicketSheet({ id, full, me, policy, pulse, onClose, onChanged, readOnly
|
|
|
340
342
|
detail.origin === "v1" && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
341
343
|
" \xB7 ",
|
|
342
344
|
/* @__PURE__ */ jsx(V1Badge, {})
|
|
345
|
+
] }),
|
|
346
|
+
detail.importedAt && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
347
|
+
" \xB7 ",
|
|
348
|
+
/* @__PURE__ */ jsx(ImportedBadge, { at: detail.importedAt })
|
|
343
349
|
] })
|
|
344
350
|
] }),
|
|
345
351
|
/* @__PURE__ */ jsx(SheetTitle, { className: "text-base font-semibold leading-snug", children: detail.subject || KIND_LABEL[detail.kind] }),
|
|
@@ -422,8 +428,13 @@ function TicketSheet({ id, full, me, policy, pulse, onClose, onChanged, readOnly
|
|
|
422
428
|
] }),
|
|
423
429
|
/* @__PURE__ */ jsxs(SheetBody, { className: "space-y-4", children: [
|
|
424
430
|
/* @__PURE__ */ jsx("div", { className: "whitespace-pre-wrap rounded-lg bg-muted/60 p-3 text-sm leading-relaxed", children: detail.description }),
|
|
425
|
-
|
|
426
|
-
|
|
431
|
+
(() => {
|
|
432
|
+
const split = splitImportedAttachments(detail.attachments);
|
|
433
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
434
|
+
split.stored.length > 0 && /* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-2", children: split.stored.map((a) => /* @__PURE__ */ jsx(AttachmentCard, { att: a }, a.id)) }),
|
|
435
|
+
detail.origin === "v1" && /* @__PURE__ */ jsx(V1Attachments, { requestId: detail.id, imported: split })
|
|
436
|
+
] });
|
|
437
|
+
})(),
|
|
427
438
|
/* @__PURE__ */ jsx(ActivityTrail, { snapshot: detail.screenSnapshot }),
|
|
428
439
|
/* @__PURE__ */ jsxs("fieldset", { disabled: readOnly, className: "m-0 min-w-0 space-y-4 border-0 p-0", children: [
|
|
429
440
|
/* @__PURE__ */ jsx(TicketConversation, { detail, onApplied: (d) => {
|
|
@@ -833,7 +844,7 @@ function sizeLabel(bytes) {
|
|
|
833
844
|
if (bytes < 1024 * 1024) return `${Math.max(1, Math.round(bytes / 1024))} KB`;
|
|
834
845
|
return `${(bytes / (1024 * 1024)).toFixed(1).replace(".", ",")} MB`;
|
|
835
846
|
}
|
|
836
|
-
function V1Attachments({ requestId, load = v1TicketAttachments }) {
|
|
847
|
+
function V1Attachments({ requestId, load = v1TicketAttachments, imported }) {
|
|
837
848
|
const [state, setState] = React2.useState(null);
|
|
838
849
|
const [n, setN] = React2.useState(0);
|
|
839
850
|
React2.useEffect(() => {
|
|
@@ -847,22 +858,37 @@ function V1Attachments({ requestId, load = v1TicketAttachments }) {
|
|
|
847
858
|
};
|
|
848
859
|
}, [requestId, load, n]);
|
|
849
860
|
if (!state) return /* @__PURE__ */ jsx(Skeleton, { className: "h-12 w-full", "data-testid": "v1-attachments-loading" });
|
|
861
|
+
const merged = mergeV1Attachments(state.ok ? state.attachments : null, imported ?? { inV1: [], copiedIds: /* @__PURE__ */ new Set() });
|
|
862
|
+
const names = merged.names.length > 0 && /* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-2", "data-testid": "v1-attachments-names", children: merged.names.map((a) => /* @__PURE__ */ jsx(V1StoredName, { att: a }, a.id)) });
|
|
850
863
|
if (!state.ok) {
|
|
851
|
-
return /* @__PURE__ */ jsxs("div", { className: "
|
|
852
|
-
/* @__PURE__ */ jsxs("
|
|
853
|
-
"
|
|
854
|
-
|
|
864
|
+
return /* @__PURE__ */ jsxs("div", { className: "space-y-1.5", children: [
|
|
865
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-2 rounded-lg border border-dashed p-2 text-xs text-muted-foreground", "data-testid": "v1-attachments-error", children: [
|
|
866
|
+
/* @__PURE__ */ jsxs("span", { children: [
|
|
867
|
+
"Anexos do V1: ",
|
|
868
|
+
state.message
|
|
869
|
+
] }),
|
|
870
|
+
/* @__PURE__ */ jsx(Button, { size: "sm", variant: "ghost", onClick: () => setN((x) => x + 1), children: "Tentar de novo" })
|
|
855
871
|
] }),
|
|
856
|
-
|
|
872
|
+
names
|
|
857
873
|
] });
|
|
858
874
|
}
|
|
859
|
-
if (
|
|
875
|
+
if (merged.live.length === 0 && !names) return null;
|
|
860
876
|
return /* @__PURE__ */ jsxs("div", { className: "space-y-1.5", "data-testid": "v1-attachments", children: [
|
|
861
877
|
/* @__PURE__ */ jsxs("p", { className: "text-xs font-medium text-muted-foreground", children: [
|
|
862
878
|
"Anexos do chamado no V1 ",
|
|
863
879
|
/* @__PURE__ */ jsx("span", { className: "font-normal", children: "\xB7 o link vale 10 minutos" })
|
|
864
880
|
] }),
|
|
865
|
-
/* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-2", children:
|
|
881
|
+
merged.live.length > 0 && /* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-2", children: merged.live.map((a) => /* @__PURE__ */ jsx(V1AttachmentCard, { att: a, onExpired: () => setN((x) => x + 1) }, a.id)) }),
|
|
882
|
+
names
|
|
883
|
+
] });
|
|
884
|
+
}
|
|
885
|
+
function V1StoredName({ att }) {
|
|
886
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 rounded-lg border bg-card p-2 opacity-80", "data-attachment": att.externalId ?? att.id, children: [
|
|
887
|
+
/* @__PURE__ */ jsx("div", { className: "flex h-12 w-12 items-center justify-center rounded bg-muted text-[10px] text-muted-foreground", children: "anexo" }),
|
|
888
|
+
/* @__PURE__ */ jsxs("span", { className: "flex min-w-0 flex-col", children: [
|
|
889
|
+
/* @__PURE__ */ jsx("span", { className: "max-w-[10rem] truncate text-xs", children: att.name }),
|
|
890
|
+
/* @__PURE__ */ jsx("span", { className: "text-[10px] text-muted-foreground", children: "no V1" })
|
|
891
|
+
] })
|
|
866
892
|
] });
|
|
867
893
|
}
|
|
868
894
|
function V1AttachmentCard({ att, onExpired }) {
|
|
@@ -883,6 +909,21 @@ function V1AttachmentCard({ att, onExpired }) {
|
|
|
883
909
|
] });
|
|
884
910
|
return gone ? /* @__PURE__ */ jsx("div", { className: "flex items-center gap-2 rounded-lg border bg-card p-2 opacity-70", "data-attachment": att.id, children: body }) : /* @__PURE__ */ jsx("a", { href: att.url, target: "_blank", rel: "noreferrer", onClick: open, className: "flex items-center gap-2 rounded-lg border bg-card p-2 hover:bg-muted", "data-attachment": att.id, children: body });
|
|
885
911
|
}
|
|
912
|
+
function ImportedBadge({ at }) {
|
|
913
|
+
const when = at ? fmtWhen(at) : null;
|
|
914
|
+
return /* @__PURE__ */ jsx(TooltipProvider, { delayDuration: 200, children: /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
915
|
+
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx(
|
|
916
|
+
"span",
|
|
917
|
+
{
|
|
918
|
+
"aria-label": "Migrado do V1",
|
|
919
|
+
"data-testid": "imported-badge",
|
|
920
|
+
className: "inline-flex rounded border border-dashed px-1.5 py-0.5 text-[10px] leading-none text-muted-foreground",
|
|
921
|
+
children: "migrado do V1"
|
|
922
|
+
}
|
|
923
|
+
) }),
|
|
924
|
+
/* @__PURE__ */ jsx(TooltipContent, { children: when ? `Veio na migra\xE7\xE3o do hist\xF3rico do V1 (${when}), n\xE3o pela ponte` : "Veio na migra\xE7\xE3o do hist\xF3rico do V1, n\xE3o pela ponte" })
|
|
925
|
+
] }) });
|
|
926
|
+
}
|
|
886
927
|
function V1Badge() {
|
|
887
928
|
return /* @__PURE__ */ jsx(TooltipProvider, { delayDuration: 200, children: /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
888
929
|
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx(
|
|
@@ -1007,6 +1048,6 @@ function LiveChatQueue({ onOpen, readOnly = false }) {
|
|
|
1007
1048
|
] });
|
|
1008
1049
|
}
|
|
1009
1050
|
|
|
1010
|
-
export { BOARD_COLUMNS, DEFAULT_SLA_POLICY, EMPTY_FILTERS, LEGACY_SETTINGS_SEGMENT, LiveChatQueue, SETTINGS_TAB_ID, TicketSheet, V1Badge, ageOf, applyFilters, cardsOf, dropTarget, initialsOf, onBoardBell, productsOf, resolveSlaPolicy, setConversationSurface, setSlaPolicySource, slaState, supportSettingsPath, ticketNo };
|
|
1011
|
-
//# sourceMappingURL=chunk-
|
|
1012
|
-
//# sourceMappingURL=chunk-
|
|
1051
|
+
export { BOARD_COLUMNS, DEFAULT_SLA_POLICY, EMPTY_FILTERS, ImportedBadge, LEGACY_SETTINGS_SEGMENT, LiveChatQueue, SETTINGS_TAB_ID, TicketSheet, V1Badge, ageOf, applyFilters, cardsOf, dropTarget, initialsOf, onBoardBell, productsOf, resolveSlaPolicy, setConversationSurface, setSlaPolicySource, slaState, supportSettingsPath, ticketNo };
|
|
1052
|
+
//# sourceMappingURL=chunk-E5EXC7QW.js.map
|
|
1053
|
+
//# sourceMappingURL=chunk-E5EXC7QW.js.map
|