@docgenlab.com/chat-widget 0.4.2 → 0.5.1
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/api.d.ts +12 -0
- package/dist/index.js +561 -463
- package/dist/index.js.map +1 -1
- package/dist/index.umd.cjs +6 -6
- package/dist/index.umd.cjs.map +1 -1
- package/dist/widget.css +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,48 +1,57 @@
|
|
|
1
|
-
import { createRoot as
|
|
1
|
+
import { createRoot as Oe } from "react-dom/client";
|
|
2
2
|
import * as e from "react";
|
|
3
|
-
import { useRef as j, useState as
|
|
4
|
-
const
|
|
5
|
-
function
|
|
3
|
+
import { useRef as j, useState as p, useEffect as T, useCallback as ye, createElement as ve } from "react";
|
|
4
|
+
const I = "/api/v1/public/kb", Ne = "dgl-visitor-id";
|
|
5
|
+
function we() {
|
|
6
6
|
const t = globalThis.crypto;
|
|
7
7
|
return t && typeof t.randomUUID == "function" ? t.randomUUID() : "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (n) => {
|
|
8
|
-
const
|
|
9
|
-
return (n === "x" ?
|
|
8
|
+
const r = Math.random() * 16 | 0;
|
|
9
|
+
return (n === "x" ? r : r & 3 | 8).toString(16);
|
|
10
10
|
});
|
|
11
11
|
}
|
|
12
|
-
function
|
|
12
|
+
function Be() {
|
|
13
13
|
try {
|
|
14
|
-
let t = localStorage.getItem(
|
|
15
|
-
return t || (t =
|
|
14
|
+
let t = localStorage.getItem(Ne);
|
|
15
|
+
return t || (t = we(), localStorage.setItem(Ne, t)), t;
|
|
16
16
|
} catch (t) {
|
|
17
|
-
return
|
|
17
|
+
return we();
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
|
-
class
|
|
20
|
+
class Ae {
|
|
21
21
|
constructor(n) {
|
|
22
|
-
this.agentKey = n.agentKey, this.baseUrl = n.apiBaseUrl.replace(/\/+$/, ""), this.visitorId = n.endUserId ? `user:${n.endUserId}` :
|
|
22
|
+
this.agentKey = n.agentKey, this.baseUrl = n.apiBaseUrl.replace(/\/+$/, ""), this.visitorId = n.endUserId ? `user:${n.endUserId}` : Be(), this.endUserHash = n.endUserHash;
|
|
23
23
|
}
|
|
24
24
|
headers(n) {
|
|
25
|
-
const
|
|
25
|
+
const r = {
|
|
26
26
|
"X-DocGenLab-Key": this.agentKey,
|
|
27
27
|
"X-DocGenLab-Visitor-Id": this.visitorId,
|
|
28
28
|
...n || {}
|
|
29
29
|
};
|
|
30
|
-
return this.endUserHash && (
|
|
30
|
+
return this.endUserHash && (r["X-DocGenLab-User-Hash"] = this.endUserHash), r;
|
|
31
31
|
}
|
|
32
32
|
async getAgent() {
|
|
33
|
-
const n = await fetch(`${this.baseUrl}${
|
|
33
|
+
const n = await fetch(`${this.baseUrl}${I}/agent`, {
|
|
34
34
|
method: "GET",
|
|
35
35
|
headers: this.headers()
|
|
36
36
|
});
|
|
37
37
|
if (!n.ok) throw new Error(`getAgent failed: ${n.status}`);
|
|
38
38
|
return n.json();
|
|
39
39
|
}
|
|
40
|
+
/** List all conversations this visitor has had with this agent.
|
|
41
|
+
* Used by the "All chats" modal to let users browse + jump back
|
|
42
|
+
* to previous threads. Lightweight payload — message bodies are
|
|
43
|
+
* fetched on demand via getConversation when the user opens one. */
|
|
44
|
+
async listConversations() {
|
|
45
|
+
const n = `${this.baseUrl}${I}/conversations`, r = await fetch(n, { headers: this.headers() });
|
|
46
|
+
if (!r.ok) throw new Error(`listConversations failed: ${r.status}`);
|
|
47
|
+
return r.json();
|
|
48
|
+
}
|
|
40
49
|
/** Load a previous conversation's messages so the widget can show
|
|
41
50
|
* history after a refresh / re-open. The visitor-id header is the
|
|
42
51
|
* authorization — the backend only returns conversations owned by
|
|
43
52
|
* the requesting visitor on this agent. */
|
|
44
53
|
async getConversation(n) {
|
|
45
|
-
const
|
|
54
|
+
const r = `${this.baseUrl}${I}/conversations/${encodeURIComponent(n)}`, l = await fetch(r, { headers: this.headers() });
|
|
46
55
|
if (!l.ok) throw new Error(`getConversation failed: ${l.status}`);
|
|
47
56
|
return l.json();
|
|
48
57
|
}
|
|
@@ -51,25 +60,25 @@ class Te {
|
|
|
51
60
|
* raise-ticket / "already on it" / created cards after refresh.
|
|
52
61
|
* Returns kind=null when nothing should show. */
|
|
53
62
|
async getTicketCardState(n) {
|
|
54
|
-
const
|
|
63
|
+
const r = `${this.baseUrl}${I}/conversations/${encodeURIComponent(n)}/ticket-card`, l = await fetch(r, { headers: this.headers() });
|
|
55
64
|
if (!l.ok) throw new Error(`getTicketCardState failed: ${l.status}`);
|
|
56
65
|
return l.json();
|
|
57
66
|
}
|
|
58
67
|
async uploadImage(n) {
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
const l = await fetch(`${this.baseUrl}${
|
|
68
|
+
const r = new FormData();
|
|
69
|
+
r.append("file", n);
|
|
70
|
+
const l = await fetch(`${this.baseUrl}${I}/chat-image`, {
|
|
62
71
|
method: "POST",
|
|
63
72
|
headers: this.headers(),
|
|
64
73
|
// browser sets Content-Type for FormData
|
|
65
|
-
body:
|
|
74
|
+
body: r
|
|
66
75
|
});
|
|
67
76
|
if (!l.ok) {
|
|
68
77
|
let o = `${l.status} ${l.statusText}`;
|
|
69
78
|
try {
|
|
70
|
-
const
|
|
71
|
-
o = (
|
|
72
|
-
} catch (
|
|
79
|
+
const c = await l.json();
|
|
80
|
+
o = (c == null ? void 0 : c.detail) || o;
|
|
81
|
+
} catch (c) {
|
|
73
82
|
}
|
|
74
83
|
throw new Error(o);
|
|
75
84
|
}
|
|
@@ -78,7 +87,7 @@ class Te {
|
|
|
78
87
|
/** Fetch a previously-uploaded image as a blob URL. Caller must
|
|
79
88
|
* URL.revokeObjectURL() when done to avoid memory leaks. */
|
|
80
89
|
async fetchImage(n) {
|
|
81
|
-
const
|
|
90
|
+
const r = `${this.baseUrl}${I}/chat-image?path=${encodeURIComponent(n)}&key=${encodeURIComponent(this.agentKey)}`, l = await fetch(r, {
|
|
82
91
|
method: "GET",
|
|
83
92
|
headers: { "X-DocGenLab-Visitor-Id": this.visitorId }
|
|
84
93
|
});
|
|
@@ -89,8 +98,8 @@ class Te {
|
|
|
89
98
|
/** Raise a support ticket from a conversation. Requires explicit user
|
|
90
99
|
* consent — the widget only calls this after the user clicks the
|
|
91
100
|
* in-chat "Raise a ticket" chip. */
|
|
92
|
-
async raiseTicket(n,
|
|
93
|
-
const l = `${this.baseUrl}${
|
|
101
|
+
async raiseTicket(n, r) {
|
|
102
|
+
const l = `${this.baseUrl}${I}/conversations/${encodeURIComponent(n)}/raise-ticket`, a = await fetch(l, {
|
|
94
103
|
method: "POST",
|
|
95
104
|
headers: {
|
|
96
105
|
"Content-Type": "application/json",
|
|
@@ -98,13 +107,13 @@ class Te {
|
|
|
98
107
|
"X-DocGenLab-Visitor-Id": this.visitorId,
|
|
99
108
|
...this.endUserHash ? { "X-DocGenLab-User-Hash": this.endUserHash } : {}
|
|
100
109
|
},
|
|
101
|
-
body: JSON.stringify(
|
|
110
|
+
body: JSON.stringify(r)
|
|
102
111
|
});
|
|
103
112
|
if (!a.ok) {
|
|
104
113
|
let o = `raiseTicket failed: ${a.status}`;
|
|
105
114
|
try {
|
|
106
115
|
o = (await a.json()).detail || o;
|
|
107
|
-
} catch (
|
|
116
|
+
} catch (c) {
|
|
108
117
|
}
|
|
109
118
|
throw new Error(o);
|
|
110
119
|
}
|
|
@@ -114,7 +123,7 @@ class Te {
|
|
|
114
123
|
* to hydrate ticket cards on conversation reload and to power the
|
|
115
124
|
* "Manage tickets" modal. Optionally filtered by conversation. */
|
|
116
125
|
async listTickets(n) {
|
|
117
|
-
const
|
|
126
|
+
const r = n ? `?conversation_id=${encodeURIComponent(n)}` : "", l = `${this.baseUrl}${I}/tickets${r}`, a = await fetch(l, {
|
|
118
127
|
headers: {
|
|
119
128
|
"X-DocGenLab-Key": this.agentKey,
|
|
120
129
|
"X-DocGenLab-Visitor-Id": this.visitorId
|
|
@@ -124,8 +133,8 @@ class Te {
|
|
|
124
133
|
return a.json();
|
|
125
134
|
}
|
|
126
135
|
/** Fetch the latest status of a ticket the user raised. */
|
|
127
|
-
async getTicket(n,
|
|
128
|
-
const l = `${this.baseUrl}${
|
|
136
|
+
async getTicket(n, r = !1) {
|
|
137
|
+
const l = `${this.baseUrl}${I}/tickets/${encodeURIComponent(n)}${r ? "?refresh=1" : ""}`, a = await fetch(l, {
|
|
129
138
|
headers: {
|
|
130
139
|
"X-DocGenLab-Key": this.agentKey,
|
|
131
140
|
"X-DocGenLab-Visitor-Id": this.visitorId
|
|
@@ -136,8 +145,8 @@ class Te {
|
|
|
136
145
|
}
|
|
137
146
|
/** Fetch a video-source frame attached to a citation chunk.
|
|
138
147
|
* Same auth pattern as fetchImage. */
|
|
139
|
-
async fetchSourceFrame(n,
|
|
140
|
-
const l = `${this.baseUrl}${
|
|
148
|
+
async fetchSourceFrame(n, r) {
|
|
149
|
+
const l = `${this.baseUrl}${I}/sources/${encodeURIComponent(n)}/frame?path=${encodeURIComponent(r)}&key=${encodeURIComponent(this.agentKey)}`, a = await fetch(l, {
|
|
141
150
|
method: "GET",
|
|
142
151
|
headers: { "X-DocGenLab-Visitor-Id": this.visitorId }
|
|
143
152
|
});
|
|
@@ -147,54 +156,54 @@ class Te {
|
|
|
147
156
|
}
|
|
148
157
|
/** Stream a chat response via SSE. Returns an abort fn the caller invokes
|
|
149
158
|
* to cancel the stream. */
|
|
150
|
-
streamChat(n,
|
|
159
|
+
streamChat(n, r) {
|
|
151
160
|
const l = new AbortController();
|
|
152
161
|
return (async () => {
|
|
153
162
|
try {
|
|
154
|
-
const a = await fetch(`${this.baseUrl}${
|
|
163
|
+
const a = await fetch(`${this.baseUrl}${I}/chat`, {
|
|
155
164
|
method: "POST",
|
|
156
165
|
signal: l.signal,
|
|
157
166
|
headers: this.headers({ "Content-Type": "application/json", Accept: "text/event-stream" }),
|
|
158
167
|
body: JSON.stringify(n)
|
|
159
168
|
});
|
|
160
169
|
if (!a.ok || !a.body) {
|
|
161
|
-
let
|
|
170
|
+
let u = `${a.status} ${a.statusText}`;
|
|
162
171
|
try {
|
|
163
|
-
const
|
|
164
|
-
|
|
165
|
-
} catch (
|
|
172
|
+
const E = await a.json();
|
|
173
|
+
u = (E == null ? void 0 : E.detail) || u;
|
|
174
|
+
} catch (E) {
|
|
166
175
|
}
|
|
167
|
-
|
|
176
|
+
r({ type: "error", error: u });
|
|
168
177
|
return;
|
|
169
178
|
}
|
|
170
|
-
const o = a.body.getReader(),
|
|
171
|
-
let
|
|
179
|
+
const o = a.body.getReader(), c = new TextDecoder();
|
|
180
|
+
let i = "";
|
|
172
181
|
for (; ; ) {
|
|
173
|
-
const { value:
|
|
174
|
-
if (
|
|
175
|
-
|
|
176
|
-
let
|
|
177
|
-
for (; (
|
|
182
|
+
const { value: u, done: E } = await o.read();
|
|
183
|
+
if (E) break;
|
|
184
|
+
i += c.decode(u, { stream: !0 });
|
|
185
|
+
let x;
|
|
186
|
+
for (; (x = i.indexOf(`
|
|
178
187
|
|
|
179
188
|
`)) !== -1; ) {
|
|
180
|
-
const
|
|
181
|
-
|
|
182
|
-
const
|
|
183
|
-
if (
|
|
189
|
+
const N = i.slice(0, x);
|
|
190
|
+
i = i.slice(x + 2);
|
|
191
|
+
const y = N.trim();
|
|
192
|
+
if (y.startsWith("data:"))
|
|
184
193
|
try {
|
|
185
|
-
const
|
|
186
|
-
|
|
187
|
-
} catch (
|
|
194
|
+
const $ = JSON.parse(y.slice(5).trim());
|
|
195
|
+
r($);
|
|
196
|
+
} catch ($) {
|
|
188
197
|
}
|
|
189
198
|
}
|
|
190
199
|
}
|
|
191
200
|
} catch (a) {
|
|
192
|
-
(a == null ? void 0 : a.name) !== "AbortError" &&
|
|
201
|
+
(a == null ? void 0 : a.name) !== "AbortError" && r({ type: "error", error: (a == null ? void 0 : a.message) || String(a) });
|
|
193
202
|
}
|
|
194
203
|
})(), () => l.abort();
|
|
195
204
|
}
|
|
196
205
|
}
|
|
197
|
-
const F = {
|
|
206
|
+
const xe = "0.5.1", F = {
|
|
198
207
|
apiBaseUrl: "https://api.docgenlab.com",
|
|
199
208
|
position: "bottom-right",
|
|
200
209
|
primary: "#4F46E5",
|
|
@@ -204,238 +213,254 @@ const F = {
|
|
|
204
213
|
greeting: "How can I help you today?",
|
|
205
214
|
greetingSub: "Ask anything about your uploaded documents. I'll only answer from what's in the knowledge base."
|
|
206
215
|
};
|
|
207
|
-
function
|
|
208
|
-
var
|
|
209
|
-
const n = t.apiBaseUrl || F.apiBaseUrl,
|
|
210
|
-
(!l.current || o.current !== a) && (l.current = new
|
|
216
|
+
function re(t) {
|
|
217
|
+
var ue, ge, he, fe, pe, ke, Ee, be;
|
|
218
|
+
const n = t.apiBaseUrl || F.apiBaseUrl, r = t.enableImageUpload !== !1, l = j(null), a = `${t.agentKey}::${t.endUserId || ""}::${t.endUserHash || ""}`, o = j("");
|
|
219
|
+
(!l.current || o.current !== a) && (l.current = new Ae({
|
|
211
220
|
agentKey: t.agentKey,
|
|
212
221
|
apiBaseUrl: n,
|
|
213
222
|
endUserId: t.endUserId,
|
|
214
223
|
endUserHash: t.endUserHash
|
|
215
224
|
}), o.current = a);
|
|
216
|
-
const
|
|
217
|
-
position: t.position ||
|
|
218
|
-
primary: ((
|
|
219
|
-
primaryText: ((
|
|
220
|
-
radius: ((
|
|
221
|
-
fontFamily: ((
|
|
222
|
-
greeting: t.greeting ||
|
|
223
|
-
agentName: t.agentName ||
|
|
224
|
-
agentAvatarUrl: t.agentAvatarUrl ||
|
|
225
|
-
launcherAvatarUrl:
|
|
226
|
-
hideBranding: (
|
|
227
|
-
openOnLoad: (
|
|
228
|
-
},
|
|
229
|
-
"--dgl-primary":
|
|
230
|
-
"--dgl-primary-text":
|
|
231
|
-
"--dgl-radius":
|
|
232
|
-
"--dgl-font":
|
|
233
|
-
}, [_, R] =
|
|
225
|
+
const c = l.current, [i, u] = p(null), [E, x] = p(null), N = (i == null ? void 0 : i.widget_config) || {}, y = {
|
|
226
|
+
position: t.position || N.position || F.position,
|
|
227
|
+
primary: ((ue = t.theme) == null ? void 0 : ue.primary) || N.primary_color || F.primary,
|
|
228
|
+
primaryText: ((ge = t.theme) == null ? void 0 : ge.primaryText) || N.primary_text_color || F.primaryText,
|
|
229
|
+
radius: ((he = t.theme) == null ? void 0 : he.radius) || N.radius || F.radius,
|
|
230
|
+
fontFamily: ((fe = t.theme) == null ? void 0 : fe.fontFamily) || F.fontFamily,
|
|
231
|
+
greeting: t.greeting || N.greeting || F.greeting,
|
|
232
|
+
agentName: t.agentName || N.agent_name || (i == null ? void 0 : i.name) || "Assistant",
|
|
233
|
+
agentAvatarUrl: t.agentAvatarUrl || N.agent_avatar_url || void 0,
|
|
234
|
+
launcherAvatarUrl: N.launcher_avatar_url || void 0,
|
|
235
|
+
hideBranding: (ke = (pe = t.hideBranding) != null ? pe : N.hide_branding) != null ? ke : !1,
|
|
236
|
+
openOnLoad: (be = (Ee = t.openOnLoad) != null ? Ee : N.open_on_load) != null ? be : !1
|
|
237
|
+
}, $ = {
|
|
238
|
+
"--dgl-primary": y.primary,
|
|
239
|
+
"--dgl-primary-text": y.primaryText,
|
|
240
|
+
"--dgl-radius": y.radius,
|
|
241
|
+
"--dgl-font": y.fontFamily
|
|
242
|
+
}, [_, R] = p(y.openOnLoad), [U, K] = p(!1), [v, L] = p([]), [G, J] = p(""), [P, H] = p(!1), [O, V] = p(null), [se, Q] = p(null), [S, Z] = p(null), [X, ee] = p(!1), ce = j(null), te = j(null), Y = j(""), z = j(null), [ae, ne] = p([]), [Le, oe] = p(!1), [$e, le] = p(!1), [Ie, Se] = p([]);
|
|
234
243
|
T(() => {
|
|
235
|
-
!_ ||
|
|
236
|
-
var
|
|
237
|
-
d
|
|
238
|
-
}).catch((
|
|
239
|
-
var
|
|
240
|
-
|
|
244
|
+
!_ || i || c.getAgent().then((d) => {
|
|
245
|
+
var h;
|
|
246
|
+
u(d), (h = t.onReady) == null || h.call(t, d);
|
|
247
|
+
}).catch((d) => {
|
|
248
|
+
var h;
|
|
249
|
+
x(d.message), (h = t.onError) == null || h.call(t, d.message);
|
|
241
250
|
});
|
|
242
|
-
}, [_,
|
|
251
|
+
}, [_, i, c, t]), T(() => {
|
|
243
252
|
if (!_ || t.disableTicketing) return;
|
|
244
|
-
let
|
|
245
|
-
return
|
|
246
|
-
|
|
253
|
+
let d = !1;
|
|
254
|
+
return c.listTickets().then((h) => {
|
|
255
|
+
d || ne(h);
|
|
247
256
|
}).catch(() => {
|
|
248
257
|
}), () => {
|
|
249
|
-
|
|
258
|
+
d = !0;
|
|
250
259
|
};
|
|
251
|
-
}, [_,
|
|
260
|
+
}, [_, c, t.disableTicketing]), T(() => {
|
|
252
261
|
if (!_) return;
|
|
253
|
-
const
|
|
254
|
-
if (!
|
|
255
|
-
let
|
|
262
|
+
const d = `dgl-chat:${t.agentKey}`, h = localStorage.getItem(d);
|
|
263
|
+
if (!h) return;
|
|
264
|
+
let g = !1;
|
|
256
265
|
return (async () => {
|
|
257
266
|
try {
|
|
258
|
-
const [
|
|
259
|
-
|
|
260
|
-
|
|
267
|
+
const [b, m] = await Promise.all([
|
|
268
|
+
c.getConversation(h),
|
|
269
|
+
c.getTicketCardState(h).catch(() => null)
|
|
261
270
|
]);
|
|
262
|
-
if (
|
|
263
|
-
const
|
|
264
|
-
for (const
|
|
265
|
-
|
|
266
|
-
id:
|
|
271
|
+
if (g) return;
|
|
272
|
+
const s = [];
|
|
273
|
+
for (const C of b.messages || [])
|
|
274
|
+
C.role === "user" ? s.push({
|
|
275
|
+
id: C.id,
|
|
267
276
|
role: "user",
|
|
268
|
-
content:
|
|
269
|
-
imagePath:
|
|
270
|
-
}) :
|
|
271
|
-
id:
|
|
277
|
+
content: C.content || "",
|
|
278
|
+
imagePath: C.image_path || void 0
|
|
279
|
+
}) : C.role === "assistant" && s.push({
|
|
280
|
+
id: C.id,
|
|
272
281
|
role: "assistant",
|
|
273
|
-
content:
|
|
274
|
-
citations:
|
|
282
|
+
content: C.content || "",
|
|
283
|
+
citations: C.retrieved_chunks || void 0
|
|
275
284
|
});
|
|
276
|
-
if (
|
|
277
|
-
let
|
|
278
|
-
for (let
|
|
279
|
-
if (
|
|
280
|
-
|
|
285
|
+
if (m && m.kind && s.length) {
|
|
286
|
+
let C = -1;
|
|
287
|
+
for (let f = s.length - 1; f >= 0; f--)
|
|
288
|
+
if (s[f].role === "assistant") {
|
|
289
|
+
C = f;
|
|
281
290
|
break;
|
|
282
291
|
}
|
|
283
|
-
if (
|
|
284
|
-
const
|
|
285
|
-
|
|
286
|
-
conversationId:
|
|
287
|
-
connectorType:
|
|
288
|
-
connectorName:
|
|
289
|
-
} :
|
|
290
|
-
ticketId:
|
|
291
|
-
externalNumber:
|
|
292
|
-
externalUrl:
|
|
293
|
-
status:
|
|
294
|
-
} :
|
|
295
|
-
id:
|
|
296
|
-
externalNumber:
|
|
297
|
-
externalUrl:
|
|
292
|
+
if (C >= 0) {
|
|
293
|
+
const f = s[C];
|
|
294
|
+
m.kind === "offer" && m.conversation_id && m.connector_type && m.connector_name ? f.ticketOffer = {
|
|
295
|
+
conversationId: m.conversation_id,
|
|
296
|
+
connectorType: m.connector_type,
|
|
297
|
+
connectorName: m.connector_name
|
|
298
|
+
} : m.kind === "existing" && m.ticket_id && m.status ? f.ticketExisting = {
|
|
299
|
+
ticketId: m.ticket_id,
|
|
300
|
+
externalNumber: m.external_ticket_number || null,
|
|
301
|
+
externalUrl: m.external_url || null,
|
|
302
|
+
status: m.status
|
|
303
|
+
} : m.kind === "created" && m.ticket_id && (f.ticketCreated = {
|
|
304
|
+
id: m.ticket_id,
|
|
305
|
+
externalNumber: m.external_ticket_number || null,
|
|
306
|
+
externalUrl: m.external_url || null
|
|
298
307
|
});
|
|
299
308
|
}
|
|
300
309
|
}
|
|
301
|
-
|
|
302
|
-
} catch (
|
|
303
|
-
localStorage.removeItem(
|
|
310
|
+
V(h), L(s);
|
|
311
|
+
} catch (b) {
|
|
312
|
+
localStorage.removeItem(d);
|
|
304
313
|
}
|
|
305
314
|
})(), () => {
|
|
306
|
-
|
|
315
|
+
g = !0;
|
|
307
316
|
};
|
|
308
|
-
}, [t.agentKey,
|
|
309
|
-
|
|
310
|
-
}, [
|
|
311
|
-
|
|
312
|
-
}, [
|
|
313
|
-
const
|
|
314
|
-
|
|
315
|
-
}, [
|
|
316
|
-
if (!
|
|
317
|
-
const
|
|
318
|
-
|
|
319
|
-
}, [
|
|
320
|
-
var
|
|
321
|
-
if (
|
|
322
|
-
const
|
|
323
|
-
let
|
|
324
|
-
if (
|
|
317
|
+
}, [t.agentKey, c, _]), T(() => {
|
|
318
|
+
O && localStorage.setItem(`dgl-chat:${t.agentKey}`, O);
|
|
319
|
+
}, [O, t.agentKey]), T(() => {
|
|
320
|
+
z.current && (z.current.scrollTop = z.current.scrollHeight);
|
|
321
|
+
}, [v]);
|
|
322
|
+
const de = ye(() => {
|
|
323
|
+
S && URL.revokeObjectURL(S), Q(null), Z(null);
|
|
324
|
+
}, [S]), me = ye((d) => {
|
|
325
|
+
if (!d.type.startsWith("image/")) return;
|
|
326
|
+
const h = 10 * 1024 * 1024;
|
|
327
|
+
d.size > h || (S && URL.revokeObjectURL(S), Q(d), Z(URL.createObjectURL(d)));
|
|
328
|
+
}, [S]), Te = async (d) => {
|
|
329
|
+
var m;
|
|
330
|
+
if (d.preventDefault(), !G.trim() || P || X) return;
|
|
331
|
+
const h = G.trim();
|
|
332
|
+
let g, b;
|
|
333
|
+
if (se) {
|
|
325
334
|
try {
|
|
326
|
-
ee(!0),
|
|
327
|
-
} catch (
|
|
328
|
-
(
|
|
335
|
+
ee(!0), g = await c.uploadImage(se);
|
|
336
|
+
} catch (s) {
|
|
337
|
+
(m = t.onError) == null || m.call(t, (s == null ? void 0 : s.message) || "Image upload failed"), ee(!1);
|
|
329
338
|
return;
|
|
330
339
|
}
|
|
331
|
-
ee(!1),
|
|
340
|
+
ee(!1), b = S || void 0;
|
|
332
341
|
}
|
|
333
|
-
|
|
334
|
-
...
|
|
335
|
-
{ role: "user", content:
|
|
342
|
+
J(""), Y.current = "", L((s) => [
|
|
343
|
+
...s,
|
|
344
|
+
{ role: "user", content: h, imagePath: g, imagePreviewUrl: b },
|
|
336
345
|
{ role: "assistant", content: "", streaming: !0 }
|
|
337
|
-
]),
|
|
338
|
-
{ message:
|
|
339
|
-
(
|
|
340
|
-
var
|
|
341
|
-
if (
|
|
342
|
-
|
|
343
|
-
else if (
|
|
344
|
-
|
|
345
|
-
const
|
|
346
|
-
|
|
347
|
-
(
|
|
346
|
+
]), H(!0), Q(null), Z(null), te.current = c.streamChat(
|
|
347
|
+
{ message: h, conversation_id: O || void 0, image_path: g },
|
|
348
|
+
(s) => {
|
|
349
|
+
var C;
|
|
350
|
+
if (s.type === "conversation")
|
|
351
|
+
V(s.conversation_id);
|
|
352
|
+
else if (s.type === "token") {
|
|
353
|
+
Y.current += s.content;
|
|
354
|
+
const f = Y.current;
|
|
355
|
+
L((k) => k.map(
|
|
356
|
+
(w, Fe) => Fe === k.length - 1 && w.role === "assistant" ? { ...w, content: f } : w
|
|
348
357
|
));
|
|
349
|
-
} else if (
|
|
350
|
-
|
|
351
|
-
(
|
|
358
|
+
} else if (s.type === "citations")
|
|
359
|
+
L((f) => f.map(
|
|
360
|
+
(k, w) => w === f.length - 1 && k.role === "assistant" ? { ...k, citations: s.citations } : k
|
|
352
361
|
));
|
|
353
|
-
else if (
|
|
354
|
-
|
|
355
|
-
(
|
|
362
|
+
else if (s.type === "refused")
|
|
363
|
+
Y.current = s.content, L((f) => f.map(
|
|
364
|
+
(k, w) => w === f.length - 1 && k.role === "assistant" ? { ...k, content: s.content, refused: !0 } : k
|
|
356
365
|
));
|
|
357
|
-
else if (
|
|
366
|
+
else if (s.type === "ticket_offer") {
|
|
358
367
|
if (t.disableTicketing) return;
|
|
359
|
-
|
|
360
|
-
(
|
|
361
|
-
...
|
|
368
|
+
L((f) => f.map(
|
|
369
|
+
(k, w) => w === f.length - 1 && k.role === "assistant" ? {
|
|
370
|
+
...k,
|
|
362
371
|
ticketOffer: {
|
|
363
|
-
conversationId:
|
|
364
|
-
connectorType:
|
|
365
|
-
connectorName:
|
|
372
|
+
conversationId: s.conversation_id,
|
|
373
|
+
connectorType: s.connector_type,
|
|
374
|
+
connectorName: s.connector_name
|
|
366
375
|
}
|
|
367
|
-
} :
|
|
376
|
+
} : k
|
|
368
377
|
));
|
|
369
|
-
} else if (
|
|
378
|
+
} else if (s.type === "ticket_existing") {
|
|
370
379
|
if (t.disableTicketing) return;
|
|
371
|
-
|
|
372
|
-
(
|
|
373
|
-
...
|
|
380
|
+
L((f) => f.map(
|
|
381
|
+
(k, w) => w === f.length - 1 && k.role === "assistant" ? {
|
|
382
|
+
...k,
|
|
374
383
|
ticketExisting: {
|
|
375
|
-
ticketId:
|
|
376
|
-
externalNumber:
|
|
377
|
-
externalUrl:
|
|
378
|
-
status:
|
|
384
|
+
ticketId: s.ticket_id,
|
|
385
|
+
externalNumber: s.external_ticket_number,
|
|
386
|
+
externalUrl: s.external_url,
|
|
387
|
+
status: s.status
|
|
379
388
|
}
|
|
380
|
-
} :
|
|
389
|
+
} : k
|
|
381
390
|
));
|
|
382
|
-
} else
|
|
383
|
-
(
|
|
384
|
-
...
|
|
391
|
+
} else s.type === "ticket_status_card" ? L((f) => f.map(
|
|
392
|
+
(k, w) => w === f.length - 1 && k.role === "assistant" ? {
|
|
393
|
+
...k,
|
|
385
394
|
ticketStatus: {
|
|
386
|
-
ticketId:
|
|
387
|
-
externalNumber:
|
|
388
|
-
externalUrl:
|
|
389
|
-
status:
|
|
390
|
-
title:
|
|
391
|
-
priority:
|
|
392
|
-
lastUpdate:
|
|
393
|
-
assignedTo:
|
|
394
|
-
createdAt:
|
|
395
|
+
ticketId: s.ticket_id,
|
|
396
|
+
externalNumber: s.external_number,
|
|
397
|
+
externalUrl: s.external_url,
|
|
398
|
+
status: s.status,
|
|
399
|
+
title: s.title,
|
|
400
|
+
priority: s.priority,
|
|
401
|
+
lastUpdate: s.last_update,
|
|
402
|
+
assignedTo: s.assigned_to,
|
|
403
|
+
createdAt: s.created_at
|
|
395
404
|
}
|
|
396
|
-
} :
|
|
397
|
-
)) :
|
|
398
|
-
(
|
|
399
|
-
)),
|
|
400
|
-
(
|
|
401
|
-
)),
|
|
405
|
+
} : k
|
|
406
|
+
)) : s.type === "done" ? (L((f) => f.map(
|
|
407
|
+
(k, w) => w === f.length - 1 && k.role === "assistant" ? { ...k, streaming: !1, id: s.message_id, cacheHit: s.cache_hit } : k
|
|
408
|
+
)), H(!1)) : s.type === "error" && (L((f) => f.map(
|
|
409
|
+
(k, w) => w === f.length - 1 && k.role === "assistant" ? { ...k, content: `Error: ${s.error}`, streaming: !1, refused: !0 } : k
|
|
410
|
+
)), H(!1), (C = t.onError) == null || C.call(t, s.error));
|
|
402
411
|
}
|
|
403
412
|
);
|
|
404
|
-
},
|
|
405
|
-
te.current && te.current(),
|
|
413
|
+
}, Re = () => {
|
|
414
|
+
te.current && te.current(), L([]), V(null), H(!1), localStorage.removeItem(`dgl-chat:${t.agentKey}`), de();
|
|
406
415
|
};
|
|
407
|
-
return /* @__PURE__ */ e.createElement("div", { className: `dgl-root dgl-pos-${
|
|
416
|
+
return /* @__PURE__ */ e.createElement("div", { className: `dgl-root dgl-pos-${y.position}`, style: $ }, _ && /* @__PURE__ */ e.createElement("div", { className: `dgl-panel ${U ? "dgl-panel-expanded" : ""}` }, /* @__PURE__ */ e.createElement("div", { className: "dgl-header" }, /* @__PURE__ */ e.createElement("div", { className: "dgl-header-info" }, y.agentAvatarUrl ? /* @__PURE__ */ e.createElement("img", { src: y.agentAvatarUrl, alt: "", className: "dgl-avatar" }) : /* @__PURE__ */ e.createElement("div", { className: "dgl-avatar dgl-avatar-fallback dgl-avatar-fallback-light" }, y.agentName.slice(0, 1).toUpperCase()), /* @__PURE__ */ e.createElement("div", { className: "dgl-header-text" }, /* @__PURE__ */ e.createElement("div", { className: "dgl-title" }, y.agentName), (i == null ? void 0 : i.org_name) && /* @__PURE__ */ e.createElement("div", { className: "dgl-subtitle" }, i.org_name))), /* @__PURE__ */ e.createElement("div", { className: "dgl-header-actions" }, /* @__PURE__ */ e.createElement(
|
|
408
417
|
"button",
|
|
409
418
|
{
|
|
410
419
|
type: "button",
|
|
411
|
-
onClick: () =>
|
|
412
|
-
|
|
420
|
+
onClick: async () => {
|
|
421
|
+
le(!0);
|
|
422
|
+
try {
|
|
423
|
+
const d = await c.listConversations();
|
|
424
|
+
Se(d);
|
|
425
|
+
} catch (d) {
|
|
426
|
+
}
|
|
427
|
+
},
|
|
428
|
+
className: "dgl-icon-btn",
|
|
429
|
+
title: "All chats",
|
|
430
|
+
"aria-label": "All chats"
|
|
431
|
+
},
|
|
432
|
+
ot()
|
|
433
|
+
), !t.disableTicketing && /* @__PURE__ */ e.createElement(
|
|
434
|
+
"button",
|
|
435
|
+
{
|
|
436
|
+
type: "button",
|
|
437
|
+
onClick: () => oe(!0),
|
|
438
|
+
className: "dgl-icon-btn dgl-icon-btn-with-badge",
|
|
413
439
|
title: "Your tickets",
|
|
414
440
|
"aria-label": "Your tickets"
|
|
415
441
|
},
|
|
416
|
-
|
|
417
|
-
/* @__PURE__ */ e.createElement("span",
|
|
418
|
-
/* @__PURE__ */ e.createElement("span", { className: "dgl-tix-btn-badge" }, ae.length)
|
|
442
|
+
D(),
|
|
443
|
+
ae.length > 0 && /* @__PURE__ */ e.createElement("span", { className: "dgl-icon-badge" }, ae.length)
|
|
419
444
|
), /* @__PURE__ */ e.createElement(
|
|
420
445
|
"button",
|
|
421
446
|
{
|
|
422
447
|
type: "button",
|
|
423
|
-
onClick:
|
|
448
|
+
onClick: Re,
|
|
424
449
|
className: "dgl-icon-btn",
|
|
425
450
|
title: "New chat",
|
|
426
451
|
"aria-label": "New chat"
|
|
427
452
|
},
|
|
428
|
-
|
|
453
|
+
nt()
|
|
429
454
|
), /* @__PURE__ */ e.createElement(
|
|
430
455
|
"button",
|
|
431
456
|
{
|
|
432
457
|
type: "button",
|
|
433
|
-
onClick: () =>
|
|
458
|
+
onClick: () => K((d) => !d),
|
|
434
459
|
className: "dgl-icon-btn dgl-hide-on-mobile",
|
|
435
|
-
title:
|
|
436
|
-
"aria-label":
|
|
460
|
+
title: U ? "Restore size" : "Expand view",
|
|
461
|
+
"aria-label": U ? "Restore size" : "Expand view"
|
|
437
462
|
},
|
|
438
|
-
|
|
463
|
+
U ? st() : it()
|
|
439
464
|
), /* @__PURE__ */ e.createElement(
|
|
440
465
|
"button",
|
|
441
466
|
{
|
|
@@ -445,102 +470,134 @@ function le(t) {
|
|
|
445
470
|
title: "Close",
|
|
446
471
|
"aria-label": "Close"
|
|
447
472
|
},
|
|
448
|
-
|
|
449
|
-
))),
|
|
450
|
-
|
|
473
|
+
W()
|
|
474
|
+
))), $e && /* @__PURE__ */ e.createElement(
|
|
475
|
+
Ze,
|
|
476
|
+
{
|
|
477
|
+
chats: Ie,
|
|
478
|
+
currentConvId: O,
|
|
479
|
+
onClose: () => le(!1),
|
|
480
|
+
onPick: async (d) => {
|
|
481
|
+
if (le(!1), d !== O)
|
|
482
|
+
try {
|
|
483
|
+
const [h, g] = await Promise.all([
|
|
484
|
+
c.getConversation(d),
|
|
485
|
+
c.getTicketCardState(d).catch(() => null)
|
|
486
|
+
]), b = [];
|
|
487
|
+
for (const m of h.messages || [])
|
|
488
|
+
m.role === "user" ? b.push({ id: m.id, role: "user", content: m.content || "", imagePath: m.image_path || void 0 }) : m.role === "assistant" && b.push({ id: m.id, role: "assistant", content: m.content || "", citations: m.retrieved_chunks || void 0 });
|
|
489
|
+
if (g && g.kind && b.length) {
|
|
490
|
+
for (let m = b.length - 1; m >= 0; m--)
|
|
491
|
+
if (b[m].role === "assistant") {
|
|
492
|
+
const s = b[m];
|
|
493
|
+
g.kind === "offer" && g.conversation_id && g.connector_type && g.connector_name ? s.ticketOffer = { conversationId: g.conversation_id, connectorType: g.connector_type, connectorName: g.connector_name } : g.kind === "existing" && g.ticket_id && g.status ? s.ticketExisting = { ticketId: g.ticket_id, externalNumber: g.external_ticket_number || null, externalUrl: g.external_url || null, status: g.status } : g.kind === "created" && g.ticket_id && (s.ticketCreated = { id: g.ticket_id, externalNumber: g.external_ticket_number || null, externalUrl: g.external_url || null });
|
|
494
|
+
break;
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
V(d), L(b);
|
|
498
|
+
} catch (h) {
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
), Le && /* @__PURE__ */ e.createElement(
|
|
503
|
+
Qe,
|
|
451
504
|
{
|
|
452
505
|
tickets: ae,
|
|
453
|
-
onClose: () =>
|
|
506
|
+
onClose: () => oe(!1),
|
|
454
507
|
onRefresh: async () => {
|
|
455
508
|
try {
|
|
456
|
-
const
|
|
457
|
-
|
|
458
|
-
|
|
509
|
+
const d = await c.listTickets(), h = /* @__PURE__ */ new Set(["open", "pending", "in_progress", "on_hold"]), g = d.filter((s) => h.has((s.status || "open").toLowerCase())), b = await Promise.all(
|
|
510
|
+
g.map((s) => c.getTicket(s.id, !0).catch(() => null))
|
|
511
|
+
), m = /* @__PURE__ */ new Map();
|
|
512
|
+
b.forEach((s) => {
|
|
513
|
+
s && m.set(s.id, s);
|
|
514
|
+
}), ne(d.map((s) => m.get(s.id) || s));
|
|
515
|
+
} catch (d) {
|
|
459
516
|
}
|
|
460
517
|
}
|
|
461
518
|
}
|
|
462
|
-
), /* @__PURE__ */ e.createElement("div", { className: "dgl-messages", ref:
|
|
463
|
-
|
|
519
|
+
), /* @__PURE__ */ e.createElement("div", { className: "dgl-messages", ref: z }, v.length === 0 && !E && /* @__PURE__ */ e.createElement("div", { className: "dgl-empty" }, /* @__PURE__ */ e.createElement("div", { className: "dgl-empty-icon" }, Ue()), /* @__PURE__ */ e.createElement("div", { className: "dgl-empty-text" }, y.greeting), /* @__PURE__ */ e.createElement("div", { className: "dgl-empty-sub" }, (i == null ? void 0 : i.description) || F.greetingSub)), E && /* @__PURE__ */ e.createElement("div", { className: "dgl-error" }, "Couldn't load the assistant: ", E), v.map((d, h) => /* @__PURE__ */ e.createElement(
|
|
520
|
+
Me,
|
|
464
521
|
{
|
|
465
|
-
key:
|
|
466
|
-
message:
|
|
467
|
-
client:
|
|
468
|
-
isLast:
|
|
469
|
-
agentAvatarUrl:
|
|
470
|
-
onPickFollowup: (
|
|
471
|
-
|
|
522
|
+
key: h,
|
|
523
|
+
message: d,
|
|
524
|
+
client: c,
|
|
525
|
+
isLast: h === v.length - 1,
|
|
526
|
+
agentAvatarUrl: y.agentAvatarUrl,
|
|
527
|
+
onPickFollowup: (g) => {
|
|
528
|
+
J(g);
|
|
472
529
|
},
|
|
473
530
|
defaultEmail: t.endUserEmail,
|
|
474
531
|
defaultPhone: t.endUserPhone,
|
|
475
|
-
conversationId:
|
|
476
|
-
onTicketCreated: (
|
|
477
|
-
|
|
478
|
-
...
|
|
532
|
+
conversationId: O || void 0,
|
|
533
|
+
onTicketCreated: (g, b) => {
|
|
534
|
+
L((m) => m.map((s) => s === g ? {
|
|
535
|
+
...s,
|
|
479
536
|
// Either an existing-issue card OR a fresh offer
|
|
480
537
|
// can land here — clear both, render created.
|
|
481
538
|
ticketOffer: void 0,
|
|
482
539
|
ticketExisting: void 0,
|
|
483
540
|
ticketCreated: {
|
|
484
|
-
id:
|
|
485
|
-
externalNumber:
|
|
486
|
-
externalUrl:
|
|
541
|
+
id: b.id,
|
|
542
|
+
externalNumber: b.external_ticket_number,
|
|
543
|
+
externalUrl: b.external_url
|
|
487
544
|
}
|
|
488
|
-
} :
|
|
545
|
+
} : s)), ne((m) => [b, ...m.filter((s) => s.id !== b.id)]);
|
|
489
546
|
}
|
|
490
547
|
}
|
|
491
|
-
))), /* @__PURE__ */ e.createElement("form", { className: "dgl-composer", onSubmit:
|
|
548
|
+
))), /* @__PURE__ */ e.createElement("form", { className: "dgl-composer", onSubmit: Te }, S && /* @__PURE__ */ e.createElement("div", { className: "dgl-staged-image" }, /* @__PURE__ */ e.createElement("img", { src: S, alt: "attachment" }), /* @__PURE__ */ e.createElement(
|
|
492
549
|
"button",
|
|
493
550
|
{
|
|
494
551
|
type: "button",
|
|
495
|
-
onClick:
|
|
552
|
+
onClick: de,
|
|
496
553
|
className: "dgl-staged-remove",
|
|
497
554
|
"aria-label": "Remove image"
|
|
498
555
|
},
|
|
499
|
-
|
|
500
|
-
)), /* @__PURE__ */ e.createElement("div", { className: "dgl-composer-row" },
|
|
556
|
+
W()
|
|
557
|
+
)), /* @__PURE__ */ e.createElement("div", { className: "dgl-composer-row" }, r && /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement(
|
|
501
558
|
"button",
|
|
502
559
|
{
|
|
503
560
|
type: "button",
|
|
504
561
|
className: "dgl-icon-btn",
|
|
505
562
|
onClick: () => {
|
|
506
|
-
var
|
|
507
|
-
return (
|
|
563
|
+
var d;
|
|
564
|
+
return (d = ce.current) == null ? void 0 : d.click();
|
|
508
565
|
},
|
|
509
|
-
disabled:
|
|
566
|
+
disabled: P || X,
|
|
510
567
|
title: "Attach image",
|
|
511
568
|
"aria-label": "Attach image"
|
|
512
569
|
},
|
|
513
|
-
|
|
570
|
+
rt()
|
|
514
571
|
), /* @__PURE__ */ e.createElement(
|
|
515
572
|
"input",
|
|
516
573
|
{
|
|
517
|
-
ref:
|
|
574
|
+
ref: ce,
|
|
518
575
|
type: "file",
|
|
519
576
|
accept: "image/png,image/jpeg,image/webp,image/gif",
|
|
520
577
|
style: { display: "none" },
|
|
521
|
-
onChange: (
|
|
522
|
-
var
|
|
523
|
-
const
|
|
524
|
-
|
|
578
|
+
onChange: (d) => {
|
|
579
|
+
var g;
|
|
580
|
+
const h = (g = d.target.files) == null ? void 0 : g[0];
|
|
581
|
+
h && me(h), d.target && (d.target.value = "");
|
|
525
582
|
}
|
|
526
583
|
}
|
|
527
584
|
)), /* @__PURE__ */ e.createElement(
|
|
528
585
|
"input",
|
|
529
586
|
{
|
|
530
587
|
className: "dgl-input",
|
|
531
|
-
value:
|
|
532
|
-
onChange: (
|
|
533
|
-
placeholder:
|
|
534
|
-
disabled:
|
|
535
|
-
onPaste: (
|
|
536
|
-
var
|
|
537
|
-
if (!
|
|
538
|
-
const
|
|
539
|
-
(
|
|
588
|
+
value: G,
|
|
589
|
+
onChange: (d) => J(d.target.value),
|
|
590
|
+
placeholder: P ? "Thinking…" : S ? "Describe what to know about this image…" : "Type your question…",
|
|
591
|
+
disabled: P,
|
|
592
|
+
onPaste: (d) => {
|
|
593
|
+
var g;
|
|
594
|
+
if (!r) return;
|
|
595
|
+
const h = Array.from(((g = d.clipboardData) == null ? void 0 : g.items) || []).find(
|
|
596
|
+
(b) => b.kind === "file" && b.type.startsWith("image/")
|
|
540
597
|
);
|
|
541
|
-
if (
|
|
542
|
-
const
|
|
543
|
-
|
|
598
|
+
if (h) {
|
|
599
|
+
const b = h.getAsFile();
|
|
600
|
+
b && (d.preventDefault(), me(b));
|
|
544
601
|
}
|
|
545
602
|
}
|
|
546
603
|
}
|
|
@@ -549,105 +606,105 @@ function le(t) {
|
|
|
549
606
|
{
|
|
550
607
|
type: "submit",
|
|
551
608
|
className: "dgl-send-btn",
|
|
552
|
-
disabled: !
|
|
609
|
+
disabled: !G.trim() || P || X,
|
|
553
610
|
"aria-label": "Send"
|
|
554
611
|
},
|
|
555
|
-
|
|
556
|
-
)), !
|
|
612
|
+
P || X ? q() : lt()
|
|
613
|
+
)), !y.hideBranding && /* @__PURE__ */ e.createElement("div", { className: "dgl-branding" }, "Powered by ", /* @__PURE__ */ e.createElement("a", { href: "https://docgenlab.com", target: "_blank", rel: "noopener noreferrer" }, "DocGenLab"), /* @__PURE__ */ e.createElement("span", { className: "dgl-branding-version", title: `Widget version ${xe}` }, "v", xe)))), /* @__PURE__ */ e.createElement(
|
|
557
614
|
"button",
|
|
558
615
|
{
|
|
559
616
|
type: "button",
|
|
560
617
|
className: "dgl-launcher",
|
|
561
|
-
onClick: () => R((
|
|
618
|
+
onClick: () => R((d) => !d),
|
|
562
619
|
"aria-label": _ ? "Close chat" : "Open chat"
|
|
563
620
|
},
|
|
564
|
-
_ ?
|
|
621
|
+
_ ? at() : y.launcherAvatarUrl ? /* @__PURE__ */ e.createElement("img", { src: y.launcherAvatarUrl, alt: "", className: "dgl-launcher-avatar" }) : tt()
|
|
565
622
|
));
|
|
566
623
|
}
|
|
567
|
-
function
|
|
624
|
+
function Me({
|
|
568
625
|
message: t,
|
|
569
626
|
client: n,
|
|
570
|
-
isLast:
|
|
627
|
+
isLast: r,
|
|
571
628
|
agentAvatarUrl: l,
|
|
572
629
|
onPickFollowup: a,
|
|
573
630
|
defaultEmail: o,
|
|
574
|
-
defaultPhone:
|
|
575
|
-
conversationId:
|
|
576
|
-
onTicketCreated:
|
|
631
|
+
defaultPhone: c,
|
|
632
|
+
conversationId: i,
|
|
633
|
+
onTicketCreated: u
|
|
577
634
|
}) {
|
|
578
|
-
var
|
|
635
|
+
var N;
|
|
579
636
|
if (t.role === "user")
|
|
580
|
-
return /* @__PURE__ */ e.createElement("div", { className: "dgl-msg dgl-msg-user" }, /* @__PURE__ */ e.createElement("div", { className: "dgl-bubble dgl-bubble-user" }, (t.imagePath || t.imagePreviewUrl) && /* @__PURE__ */ e.createElement(
|
|
581
|
-
const
|
|
582
|
-
return /* @__PURE__ */ e.createElement("div", { className: "dgl-msg dgl-msg-assistant" }, l ? /* @__PURE__ */ e.createElement("img", { src: l, className: "dgl-avatar", alt: "" }) : /* @__PURE__ */ e.createElement("div", { className: "dgl-avatar dgl-avatar-fallback" },
|
|
637
|
+
return /* @__PURE__ */ e.createElement("div", { className: "dgl-msg dgl-msg-user" }, /* @__PURE__ */ e.createElement("div", { className: "dgl-bubble dgl-bubble-user" }, (t.imagePath || t.imagePreviewUrl) && /* @__PURE__ */ e.createElement(je, { client: n, imagePath: t.imagePath, previewUrl: t.imagePreviewUrl }), t.content));
|
|
638
|
+
const E = He(t.content), x = t.streaming ? [] : Ge(t.content);
|
|
639
|
+
return /* @__PURE__ */ e.createElement("div", { className: "dgl-msg dgl-msg-assistant" }, l ? /* @__PURE__ */ e.createElement("img", { src: l, className: "dgl-avatar", alt: "" }) : /* @__PURE__ */ e.createElement("div", { className: "dgl-avatar dgl-avatar-fallback" }, Ue()), /* @__PURE__ */ e.createElement("div", { className: "dgl-msg-body" }, t.refused ? /* @__PURE__ */ e.createElement("div", { className: "dgl-refused" }, E) : t.ticketStatus ? (
|
|
583
640
|
/* Status query — suppress the markdown body and render
|
|
584
641
|
the rich Jira-style card on its own. */
|
|
585
|
-
/* @__PURE__ */ e.createElement(
|
|
586
|
-
) : /* @__PURE__ */ e.createElement("div", { className: "dgl-assistant-text" }, t.streaming && !
|
|
587
|
-
|
|
642
|
+
/* @__PURE__ */ e.createElement(Je, { ticket: t.ticketStatus })
|
|
643
|
+
) : /* @__PURE__ */ e.createElement("div", { className: "dgl-assistant-text" }, t.streaming && !E ? /* @__PURE__ */ e.createElement(Xe, null) : /* @__PURE__ */ e.createElement(e.Fragment, null, Ve(E), t.streaming && /* @__PURE__ */ e.createElement("span", { className: "dgl-typing-cursor" }, "▍"))), !t.streaming && !t.refused && !!((N = t.citations) != null && N.length) && !t.ticketStatus && /* @__PURE__ */ e.createElement(De, { citations: t.citations, client: n }), !t.streaming && !t.ticketStatus && t.ticketCreated ? /* @__PURE__ */ e.createElement(ze, { created: t.ticketCreated }) : !t.streaming && !t.ticketStatus && t.ticketExisting ? /* @__PURE__ */ e.createElement(
|
|
644
|
+
qe,
|
|
588
645
|
{
|
|
589
646
|
existing: t.ticketExisting,
|
|
590
647
|
client: n,
|
|
591
|
-
conversationId:
|
|
648
|
+
conversationId: i,
|
|
592
649
|
defaultEmail: o,
|
|
593
|
-
defaultPhone:
|
|
594
|
-
onNewTicketRaised: (
|
|
650
|
+
defaultPhone: c,
|
|
651
|
+
onNewTicketRaised: (y) => u == null ? void 0 : u(t, y)
|
|
595
652
|
}
|
|
596
653
|
) : !t.streaming && !t.ticketStatus && t.ticketOffer ? /* @__PURE__ */ e.createElement(
|
|
597
|
-
|
|
654
|
+
Ye,
|
|
598
655
|
{
|
|
599
656
|
client: n,
|
|
600
657
|
offer: t.ticketOffer,
|
|
601
658
|
defaultEmail: o,
|
|
602
|
-
defaultPhone:
|
|
603
|
-
onCreated: (
|
|
659
|
+
defaultPhone: c,
|
|
660
|
+
onCreated: (y) => u == null ? void 0 : u(t, y)
|
|
604
661
|
}
|
|
605
|
-
) : null,
|
|
662
|
+
) : null, x.length > 0 && /* @__PURE__ */ e.createElement(Pe, { suggestions: x, onPick: a })));
|
|
606
663
|
}
|
|
607
|
-
function
|
|
664
|
+
function Pe({
|
|
608
665
|
suggestions: t,
|
|
609
666
|
onPick: n
|
|
610
667
|
}) {
|
|
611
|
-
return /* @__PURE__ */ e.createElement("div", { className: "dgl-followups" }, /* @__PURE__ */ e.createElement("div", { className: "dgl-followups-label" }, "Continue exploring"), /* @__PURE__ */ e.createElement("div", { className: "dgl-followups-list" }, t.map((
|
|
668
|
+
return /* @__PURE__ */ e.createElement("div", { className: "dgl-followups" }, /* @__PURE__ */ e.createElement("div", { className: "dgl-followups-label" }, "Continue exploring"), /* @__PURE__ */ e.createElement("div", { className: "dgl-followups-list" }, t.map((r, l) => /* @__PURE__ */ e.createElement(
|
|
612
669
|
"button",
|
|
613
670
|
{
|
|
614
671
|
key: l,
|
|
615
672
|
type: "button",
|
|
616
673
|
className: "dgl-followup-chip",
|
|
617
|
-
onClick: () => n(
|
|
674
|
+
onClick: () => n(r)
|
|
618
675
|
},
|
|
619
|
-
|
|
676
|
+
r
|
|
620
677
|
))));
|
|
621
678
|
}
|
|
622
|
-
function
|
|
679
|
+
function je({
|
|
623
680
|
client: t,
|
|
624
681
|
imagePath: n,
|
|
625
|
-
previewUrl:
|
|
682
|
+
previewUrl: r
|
|
626
683
|
}) {
|
|
627
|
-
const [l, a] =
|
|
684
|
+
const [l, a] = p(r || null), [o, c] = p(!1);
|
|
628
685
|
return T(() => {
|
|
629
|
-
if (
|
|
630
|
-
let
|
|
631
|
-
return t.fetchImage(n).then((
|
|
632
|
-
|
|
686
|
+
if (r || !n) return;
|
|
687
|
+
let i = null;
|
|
688
|
+
return t.fetchImage(n).then((u) => {
|
|
689
|
+
i = u, a(u);
|
|
633
690
|
}).catch(() => a(null)), () => {
|
|
634
|
-
|
|
691
|
+
i && URL.revokeObjectURL(i);
|
|
635
692
|
};
|
|
636
|
-
}, [t, n,
|
|
693
|
+
}, [t, n, r]), T(() => {
|
|
637
694
|
if (!o) return;
|
|
638
|
-
const
|
|
639
|
-
|
|
695
|
+
const i = (E) => {
|
|
696
|
+
E.key === "Escape" && c(!1);
|
|
640
697
|
};
|
|
641
|
-
window.addEventListener("keydown",
|
|
642
|
-
const
|
|
698
|
+
window.addEventListener("keydown", i);
|
|
699
|
+
const u = document.body.style.overflow;
|
|
643
700
|
return document.body.style.overflow = "hidden", () => {
|
|
644
|
-
window.removeEventListener("keydown",
|
|
701
|
+
window.removeEventListener("keydown", i), document.body.style.overflow = u;
|
|
645
702
|
};
|
|
646
703
|
}, [o]), l ? /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement(
|
|
647
704
|
"button",
|
|
648
705
|
{
|
|
649
706
|
type: "button",
|
|
650
|
-
onClick: () =>
|
|
707
|
+
onClick: () => c(!0),
|
|
651
708
|
className: "dgl-user-image-btn",
|
|
652
709
|
"aria-label": "View image"
|
|
653
710
|
},
|
|
@@ -658,19 +715,19 @@ function Be({
|
|
|
658
715
|
className: "dgl-lightbox",
|
|
659
716
|
role: "dialog",
|
|
660
717
|
"aria-modal": "true",
|
|
661
|
-
onClick: () =>
|
|
718
|
+
onClick: () => c(!1)
|
|
662
719
|
},
|
|
663
720
|
/* @__PURE__ */ e.createElement(
|
|
664
721
|
"button",
|
|
665
722
|
{
|
|
666
723
|
type: "button",
|
|
667
724
|
className: "dgl-lightbox-close",
|
|
668
|
-
onClick: (
|
|
669
|
-
|
|
725
|
+
onClick: (i) => {
|
|
726
|
+
i.stopPropagation(), c(!1);
|
|
670
727
|
},
|
|
671
728
|
"aria-label": "Close image"
|
|
672
729
|
},
|
|
673
|
-
|
|
730
|
+
W()
|
|
674
731
|
),
|
|
675
732
|
/* @__PURE__ */ e.createElement(
|
|
676
733
|
"img",
|
|
@@ -678,98 +735,98 @@ function Be({
|
|
|
678
735
|
src: l,
|
|
679
736
|
className: "dgl-lightbox-img",
|
|
680
737
|
alt: "attached",
|
|
681
|
-
onClick: (
|
|
738
|
+
onClick: (i) => i.stopPropagation()
|
|
682
739
|
}
|
|
683
740
|
)
|
|
684
741
|
)) : null;
|
|
685
742
|
}
|
|
686
|
-
function
|
|
687
|
-
const
|
|
688
|
-
for (const
|
|
689
|
-
const
|
|
690
|
-
(!
|
|
743
|
+
function De({ citations: t, client: n }) {
|
|
744
|
+
const r = {};
|
|
745
|
+
for (const i of t) {
|
|
746
|
+
const u = r[i.source_id];
|
|
747
|
+
(!u || i.score > u.score) && (r[i.source_id] = i);
|
|
691
748
|
}
|
|
692
|
-
const l = Object.values(
|
|
749
|
+
const l = Object.values(r).sort((i, u) => u.score - i.score).slice(0, 3), a = Object.keys(r).length - l.length;
|
|
693
750
|
if (!l.length) return null;
|
|
694
|
-
const [o,
|
|
695
|
-
return /* @__PURE__ */ e.createElement("div", { className: "dgl-citations" }, l.map((
|
|
696
|
-
|
|
751
|
+
const [o, c] = p(null);
|
|
752
|
+
return /* @__PURE__ */ e.createElement("div", { className: "dgl-citations" }, l.map((i) => /* @__PURE__ */ e.createElement(
|
|
753
|
+
Ke,
|
|
697
754
|
{
|
|
698
|
-
key:
|
|
699
|
-
citation:
|
|
755
|
+
key: i.chunk_id,
|
|
756
|
+
citation: i,
|
|
700
757
|
client: n,
|
|
701
|
-
isOpen: o ===
|
|
702
|
-
onToggle: () =>
|
|
758
|
+
isOpen: o === i.chunk_id,
|
|
759
|
+
onToggle: () => c(o === i.chunk_id ? null : i.chunk_id)
|
|
703
760
|
}
|
|
704
761
|
)), a > 0 && /* @__PURE__ */ e.createElement("span", { className: "dgl-citation-more" }, "+", a, " more"));
|
|
705
762
|
}
|
|
706
|
-
function
|
|
763
|
+
function Ke({
|
|
707
764
|
citation: t,
|
|
708
765
|
client: n,
|
|
709
|
-
isOpen:
|
|
766
|
+
isOpen: r,
|
|
710
767
|
onToggle: l
|
|
711
768
|
}) {
|
|
712
|
-
const a = t, o = !!a.frame_path,
|
|
769
|
+
const a = t, o = !!a.frame_path, c = a.heading ? `${a.heading}${a.subheading ? " › " + a.subheading : ""}` : null, i = a.start_seconds != null ? `${Math.floor(a.start_seconds / 60)}:${String(a.start_seconds % 60).padStart(2, "0")}` : null;
|
|
713
770
|
return /* @__PURE__ */ e.createElement("span", { className: "dgl-citation-wrap" }, /* @__PURE__ */ e.createElement(
|
|
714
771
|
"button",
|
|
715
772
|
{
|
|
716
773
|
type: "button",
|
|
717
|
-
className: `dgl-citation ${
|
|
774
|
+
className: `dgl-citation ${r ? "dgl-citation-open" : ""}`,
|
|
718
775
|
onClick: l,
|
|
719
776
|
title: a.snippet || ""
|
|
720
777
|
},
|
|
721
778
|
o && /* @__PURE__ */ e.createElement("span", { className: "dgl-citation-icon" }, "▶"),
|
|
722
779
|
a.source_name,
|
|
723
|
-
|
|
780
|
+
i && /* @__PURE__ */ e.createElement("span", { className: "dgl-citation-stamp" }, " · ", i),
|
|
724
781
|
a.page && /* @__PURE__ */ e.createElement("span", { className: "dgl-citation-stamp" }, " · p", a.page)
|
|
725
|
-
),
|
|
726
|
-
|
|
782
|
+
), r && /* @__PURE__ */ e.createElement("div", { className: "dgl-citation-popover" }, a.frame_path && /* @__PURE__ */ e.createElement(
|
|
783
|
+
We,
|
|
727
784
|
{
|
|
728
785
|
client: n,
|
|
729
786
|
sourceId: a.source_id,
|
|
730
787
|
framePath: a.frame_path
|
|
731
788
|
}
|
|
732
|
-
),
|
|
789
|
+
), c && /* @__PURE__ */ e.createElement("div", { className: "dgl-citation-breadcrumb" }, c), a.snippet && /* @__PURE__ */ e.createElement("div", { className: "dgl-citation-snippet" }, a.snippet)));
|
|
733
790
|
}
|
|
734
|
-
function
|
|
791
|
+
function We({
|
|
735
792
|
client: t,
|
|
736
793
|
sourceId: n,
|
|
737
|
-
framePath:
|
|
794
|
+
framePath: r
|
|
738
795
|
}) {
|
|
739
|
-
const [l, a] =
|
|
796
|
+
const [l, a] = p(null);
|
|
740
797
|
return T(() => {
|
|
741
798
|
let o = null;
|
|
742
|
-
return t.fetchSourceFrame(n,
|
|
743
|
-
o =
|
|
799
|
+
return t.fetchSourceFrame(n, r).then((c) => {
|
|
800
|
+
o = c, a(c);
|
|
744
801
|
}).catch(() => a(null)), () => {
|
|
745
802
|
o && URL.revokeObjectURL(o);
|
|
746
803
|
};
|
|
747
|
-
}, [t, n,
|
|
804
|
+
}, [t, n, r]), l ? /* @__PURE__ */ e.createElement("a", { href: l, target: "_blank", rel: "noopener noreferrer", className: "dgl-citation-frame-link" }, /* @__PURE__ */ e.createElement("img", { src: l, alt: "", className: "dgl-citation-frame" })) : /* @__PURE__ */ e.createElement("div", { className: "dgl-citation-frame-loading" });
|
|
748
805
|
}
|
|
749
|
-
function
|
|
806
|
+
function Ge(t) {
|
|
750
807
|
const n = t.match(/<followups>([\s\S]*?)<\/followups>/i);
|
|
751
808
|
return n ? n[1].split(`
|
|
752
|
-
`).map((
|
|
809
|
+
`).map((r) => r.trim()).map((r) => r.replace(/^[-*•\d.)\s"']+|["']$/g, "").trim()).filter((r) => r.length >= 4 && r.length <= 120).slice(0, 3) : [];
|
|
753
810
|
}
|
|
754
|
-
function
|
|
755
|
-
const n = /\s*I\s+(don'?t|do not)\s+have\s+(?:specific|enough|that|the|any)?\s*information\s+on\s+(?:this|that)[^.]*?\.(?:\s*Please\s+(?:contact|reach\s*out\s+to)\s+(?:your\s+)?(?:support|admin)[^.]*?\.)?/gi,
|
|
811
|
+
function He(t) {
|
|
812
|
+
const n = /\s*I\s+(don'?t|do not)\s+have\s+(?:specific|enough|that|the|any)?\s*information\s+on\s+(?:this|that)[^.]*?\.(?:\s*Please\s+(?:contact|reach\s*out\s+to)\s+(?:your\s+)?(?:support|admin)[^.]*?\.)?/gi, r = /\n*<followups>[\s\S]*?(<\/followups>|$)/gi, l = t.replace(r, ""), a = l.replace(n, "").trim();
|
|
756
813
|
return (l.trim().length > 0 && a.length < 20 ? t : t.replace(n, "")).replace(/\n*<followups>[\s\S]*?(<\/followups>|$)/gi, "").replace(/\s*\[\s*Section:[^\]]*\]?/gi, "").replace(/\s*\[\s*doc:[^\]]*\]?/gi, "").replace(/\s*\[\s*(?:document|doc|source|ref|reference)[^\]]*\]?/gi, "").replace(/\s*\[\s*(?:p\.?\s*)?\d+(?:\s*[,–-]\s*\d+)*\s*\]/gi, "").replace(/[,;]?\s*doc:\s*[0-9a-fA-F][0-9a-fA-F-]{6,}\]?/gi, "").replace(/[,;]\s*(?:\d+|doc:?\s*[0-9a-fA-F-]+)\s*\]?/gi, "").replace(/([\w%])\s*\]/g, "$1").replace(/\s+([,.;:!?])/g, "$1").replace(/[ \t]+/g, " ").replace(/\n{3,}/g, `
|
|
757
814
|
|
|
758
815
|
`).trim();
|
|
759
816
|
}
|
|
760
|
-
function
|
|
761
|
-
return t.split(/\n{2,}/).map((
|
|
762
|
-
const a =
|
|
817
|
+
function Ve(t) {
|
|
818
|
+
return t.split(/\n{2,}/).map((r, l) => {
|
|
819
|
+
const a = r.split(`
|
|
763
820
|
`);
|
|
764
|
-
if (a.every((
|
|
765
|
-
const
|
|
766
|
-
return /* @__PURE__ */ e.createElement(
|
|
821
|
+
if (a.every((c) => /^(\s*)([-*]|\d+\.)\s/.test(c)) && a.length > 0) {
|
|
822
|
+
const c = /^\d+\./.test(a[0].trim()), i = a.map((E) => E.replace(/^\s*(?:[-*]|\d+\.)\s+/, "")), u = c ? "ol" : "ul";
|
|
823
|
+
return /* @__PURE__ */ e.createElement(u, { key: l, className: `dgl-md-list ${c ? "dgl-md-ol" : "dgl-md-ul"}` }, i.map((E, x) => /* @__PURE__ */ e.createElement("li", { key: x }, _e(E))));
|
|
767
824
|
}
|
|
768
|
-
return /* @__PURE__ */ e.createElement("p", { key: l, className: "dgl-md-p" },
|
|
769
|
-
`).map((
|
|
825
|
+
return /* @__PURE__ */ e.createElement("p", { key: l, className: "dgl-md-p" }, r.split(`
|
|
826
|
+
`).map((c, i, u) => /* @__PURE__ */ e.createElement(e.Fragment, { key: i }, _e(c), i < u.length - 1 && /* @__PURE__ */ e.createElement("br", null))));
|
|
770
827
|
});
|
|
771
828
|
}
|
|
772
|
-
function
|
|
829
|
+
function _e(t) {
|
|
773
830
|
const n = /(`[^`]+`|\*\*[^*\n]+\*\*|\*[^*\n]+\*|\[[^\]]+\]\([^)]+\))/g;
|
|
774
831
|
return t.split(n).map((l, a) => {
|
|
775
832
|
if (!l) return null;
|
|
@@ -783,27 +840,27 @@ function Ne(t) {
|
|
|
783
840
|
return o ? /* @__PURE__ */ e.createElement("a", { key: a, href: o[2], target: "_blank", rel: "noopener noreferrer", className: "dgl-md-link" }, o[1]) : /* @__PURE__ */ e.createElement(e.Fragment, { key: a }, l);
|
|
784
841
|
});
|
|
785
842
|
}
|
|
786
|
-
function
|
|
843
|
+
function Xe() {
|
|
787
844
|
return /* @__PURE__ */ e.createElement("span", { className: "dgl-thinking" }, /* @__PURE__ */ e.createElement("span", { className: "dgl-thinking-dot" }), /* @__PURE__ */ e.createElement("span", { className: "dgl-thinking-dot" }), /* @__PURE__ */ e.createElement("span", { className: "dgl-thinking-dot" }));
|
|
788
845
|
}
|
|
789
|
-
const
|
|
846
|
+
const M = {
|
|
790
847
|
open: { label: "Open", stripe: "linear-gradient(90deg,#3b82f6,#6366f1)", iconBg: "#3b82f6", pillBg: "#dbeafe", pillFg: "#1e40af" },
|
|
791
848
|
in_progress: { label: "In progress", stripe: "linear-gradient(90deg,#8b5cf6,#d946ef)", iconBg: "#8b5cf6", pillBg: "#ede9fe", pillFg: "#5b21b6" },
|
|
792
849
|
on_hold: { label: "On hold", stripe: "linear-gradient(90deg,#f59e0b,#f97316)", iconBg: "#f59e0b", pillBg: "#fef3c7", pillFg: "#92400e" },
|
|
793
850
|
resolved: { label: "Resolved", stripe: "linear-gradient(90deg,#10b981,#14b8a6)", iconBg: "#10b981", pillBg: "#d1fae5", pillFg: "#065f46" },
|
|
794
851
|
closed: { label: "Closed", stripe: "linear-gradient(90deg,#94a3b8,#64748b)", iconBg: "#64748b", pillBg: "#f1f5f9", pillFg: "#334155" },
|
|
795
852
|
cancelled: { label: "Cancelled", stripe: "linear-gradient(90deg,#ef4444,#f43f5e)", iconBg: "#ef4444", pillBg: "#fee2e2", pillFg: "#991b1b" }
|
|
796
|
-
},
|
|
853
|
+
}, Ce = {
|
|
797
854
|
low: { bg: "#f1f5f9", fg: "#475569" },
|
|
798
855
|
medium: { bg: "#dbeafe", fg: "#1e40af" },
|
|
799
856
|
high: { bg: "#fef3c7", fg: "#92400e" },
|
|
800
857
|
urgent: { bg: "#fee2e2", fg: "#991b1b" }
|
|
801
858
|
};
|
|
802
|
-
function
|
|
859
|
+
function ie(t) {
|
|
803
860
|
if (!t) return "—";
|
|
804
|
-
const n = new Date(t),
|
|
805
|
-
if (Number.isNaN(
|
|
806
|
-
const l = Math.floor(
|
|
861
|
+
const n = new Date(t), r = Date.now() - n.getTime();
|
|
862
|
+
if (Number.isNaN(r)) return t;
|
|
863
|
+
const l = Math.floor(r / 6e4);
|
|
807
864
|
if (l < 1) return "just now";
|
|
808
865
|
if (l < 60) return `${l}m ago`;
|
|
809
866
|
const a = Math.floor(l / 60);
|
|
@@ -811,41 +868,41 @@ function xe(t) {
|
|
|
811
868
|
const o = Math.floor(a / 24);
|
|
812
869
|
return o < 7 ? `${o}d ago` : n.toLocaleDateString();
|
|
813
870
|
}
|
|
814
|
-
function
|
|
871
|
+
function Ye({
|
|
815
872
|
client: t,
|
|
816
873
|
offer: n,
|
|
817
|
-
defaultEmail:
|
|
874
|
+
defaultEmail: r,
|
|
818
875
|
defaultPhone: l,
|
|
819
876
|
onCreated: a
|
|
820
877
|
}) {
|
|
821
|
-
const [o,
|
|
878
|
+
const [o, c] = p(r || ""), [i, u] = p(l || ""), [E, x] = p(!r), [N, y] = p("medium"), [$, _] = p(!1), [R, U] = p(null), K = async () => {
|
|
822
879
|
if (!o.trim()) {
|
|
823
|
-
|
|
880
|
+
U("Email is required so the team can follow up.");
|
|
824
881
|
return;
|
|
825
882
|
}
|
|
826
|
-
_(!0),
|
|
883
|
+
_(!0), U(null);
|
|
827
884
|
try {
|
|
828
|
-
const
|
|
885
|
+
const v = await t.raiseTicket(n.conversationId, {
|
|
829
886
|
consent: !0,
|
|
830
887
|
end_user_email: o.trim(),
|
|
831
|
-
end_user_phone:
|
|
832
|
-
priority:
|
|
888
|
+
end_user_phone: i.trim() || void 0,
|
|
889
|
+
priority: N
|
|
833
890
|
});
|
|
834
|
-
a(
|
|
835
|
-
} catch (
|
|
836
|
-
|
|
891
|
+
a(v);
|
|
892
|
+
} catch (v) {
|
|
893
|
+
U((v == null ? void 0 : v.message) || "Could not create ticket. Try again.");
|
|
837
894
|
} finally {
|
|
838
895
|
_(!1);
|
|
839
896
|
}
|
|
840
897
|
};
|
|
841
|
-
return /* @__PURE__ */ e.createElement("div", { className: "dgl-ticket-card" }, /* @__PURE__ */ e.createElement("div", { className: "dgl-ticket-card-stripe", style: { background: "linear-gradient(90deg,#6366f1,#8b5cf6)" } }), /* @__PURE__ */ e.createElement("div", { className: "dgl-ticket-card-body" }, /* @__PURE__ */ e.createElement("div", { className: "dgl-ticket-card-head" }, /* @__PURE__ */ e.createElement("div", { className: "dgl-ticket-card-icon", style: { background: "linear-gradient(135deg,#6366f1,#8b5cf6,#ec4899)" } },
|
|
898
|
+
return /* @__PURE__ */ e.createElement("div", { className: "dgl-ticket-card" }, /* @__PURE__ */ e.createElement("div", { className: "dgl-ticket-card-stripe", style: { background: "linear-gradient(90deg,#6366f1,#8b5cf6)" } }), /* @__PURE__ */ e.createElement("div", { className: "dgl-ticket-card-body" }, /* @__PURE__ */ e.createElement("div", { className: "dgl-ticket-card-head" }, /* @__PURE__ */ e.createElement("div", { className: "dgl-ticket-card-icon", style: { background: "linear-gradient(135deg,#6366f1,#8b5cf6,#ec4899)" } }, D()), /* @__PURE__ */ e.createElement("div", { className: "dgl-ticket-card-titles" }, /* @__PURE__ */ e.createElement("div", { className: "dgl-ticket-card-eyebrow" }, "Support escalation"), /* @__PURE__ */ e.createElement("div", { className: "dgl-ticket-card-title" }, "Need a human to look at this?"))), /* @__PURE__ */ e.createElement("div", { className: "dgl-ticket-card-desc" }, "We'll summarise this chat and raise a ticket. Our team will follow up on the email below."), /* @__PURE__ */ e.createElement("div", { className: "dgl-ticket-form-grid" }, /* @__PURE__ */ e.createElement("div", null, /* @__PURE__ */ e.createElement("div", { className: "dgl-ticket-field-label" }, "Reply to"), E ? /* @__PURE__ */ e.createElement(
|
|
842
899
|
"input",
|
|
843
900
|
{
|
|
844
901
|
type: "email",
|
|
845
902
|
className: "dgl-ticket-input",
|
|
846
903
|
value: o,
|
|
847
|
-
onChange: (
|
|
848
|
-
onBlur: () => o &&
|
|
904
|
+
onChange: (v) => c(v.target.value),
|
|
905
|
+
onBlur: () => o && x(!1),
|
|
849
906
|
placeholder: "you@example.com",
|
|
850
907
|
autoFocus: !0
|
|
851
908
|
}
|
|
@@ -854,7 +911,7 @@ function We({
|
|
|
854
911
|
{
|
|
855
912
|
type: "button",
|
|
856
913
|
className: "dgl-ticket-email-link",
|
|
857
|
-
onClick: () =>
|
|
914
|
+
onClick: () => x(!0),
|
|
858
915
|
title: "Click to change"
|
|
859
916
|
},
|
|
860
917
|
o || "Set email",
|
|
@@ -864,8 +921,8 @@ function We({
|
|
|
864
921
|
"select",
|
|
865
922
|
{
|
|
866
923
|
className: "dgl-ticket-input",
|
|
867
|
-
value:
|
|
868
|
-
onChange: (
|
|
924
|
+
value: N,
|
|
925
|
+
onChange: (v) => y(v.target.value)
|
|
869
926
|
},
|
|
870
927
|
/* @__PURE__ */ e.createElement("option", { value: "low" }, "Low"),
|
|
871
928
|
/* @__PURE__ */ e.createElement("option", { value: "medium" }, "Medium"),
|
|
@@ -876,65 +933,65 @@ function We({
|
|
|
876
933
|
{
|
|
877
934
|
type: "button",
|
|
878
935
|
className: "dgl-ticket-submit",
|
|
879
|
-
onClick:
|
|
880
|
-
disabled:
|
|
936
|
+
onClick: K,
|
|
937
|
+
disabled: $ || !o.trim()
|
|
881
938
|
},
|
|
882
|
-
|
|
883
|
-
/* @__PURE__ */ e.createElement("span", null,
|
|
939
|
+
$ ? q() : D(),
|
|
940
|
+
/* @__PURE__ */ e.createElement("span", null, $ ? "Submitting…" : "Submit ticket")
|
|
884
941
|
))));
|
|
885
942
|
}
|
|
886
|
-
function
|
|
887
|
-
const n =
|
|
888
|
-
return /* @__PURE__ */ e.createElement("div", { className: "dgl-ticket-card" }, /* @__PURE__ */ e.createElement("div", { className: "dgl-ticket-card-stripe", style: { background: "linear-gradient(90deg,#10b981,#14b8a6)" } }), /* @__PURE__ */ e.createElement("div", { className: "dgl-ticket-card-body" }, /* @__PURE__ */ e.createElement("div", { className: "dgl-ticket-card-head" }, /* @__PURE__ */ e.createElement("div", { className: "dgl-ticket-card-icon", style: { background: "linear-gradient(135deg,#10b981,#14b8a6)" } },
|
|
943
|
+
function ze({ created: t }) {
|
|
944
|
+
const n = M.open;
|
|
945
|
+
return /* @__PURE__ */ e.createElement("div", { className: "dgl-ticket-card" }, /* @__PURE__ */ e.createElement("div", { className: "dgl-ticket-card-stripe", style: { background: "linear-gradient(90deg,#10b981,#14b8a6)" } }), /* @__PURE__ */ e.createElement("div", { className: "dgl-ticket-card-body" }, /* @__PURE__ */ e.createElement("div", { className: "dgl-ticket-card-head" }, /* @__PURE__ */ e.createElement("div", { className: "dgl-ticket-card-icon", style: { background: "linear-gradient(135deg,#10b981,#14b8a6)" } }, et()), /* @__PURE__ */ e.createElement("div", { className: "dgl-ticket-card-titles" }, /* @__PURE__ */ e.createElement("div", { className: "dgl-ticket-card-eyebrow", style: { color: "#059669" } }, "Ticket created"), /* @__PURE__ */ e.createElement("div", { className: "dgl-ticket-card-title" }, "#", t.externalNumber || t.id.slice(0, 8))), t.externalUrl && /* @__PURE__ */ e.createElement("a", { className: "dgl-ticket-open-btn", href: t.externalUrl, target: "_blank", rel: "noopener noreferrer" }, "Open")), /* @__PURE__ */ e.createElement("div", { className: "dgl-ticket-pills" }, /* @__PURE__ */ e.createElement("span", { className: "dgl-ticket-pill", style: { background: n.pillBg, color: n.pillFg } }, /* @__PURE__ */ e.createElement("span", { className: "dgl-ticket-pill-dot", style: { background: n.iconBg } }), " Open")), /* @__PURE__ */ e.createElement("div", { className: "dgl-ticket-card-desc" }, "Support team has been notified — they'll follow up directly on your email.")));
|
|
889
946
|
}
|
|
890
|
-
function
|
|
947
|
+
function qe({
|
|
891
948
|
existing: t,
|
|
892
949
|
client: n,
|
|
893
|
-
conversationId:
|
|
950
|
+
conversationId: r,
|
|
894
951
|
defaultEmail: l,
|
|
895
952
|
defaultPhone: a,
|
|
896
953
|
onNewTicketRaised: o
|
|
897
954
|
}) {
|
|
898
|
-
const
|
|
899
|
-
if (!
|
|
900
|
-
|
|
955
|
+
const c = M[t.status] || M.open, [i, u] = p(!1), [E, x] = p(l || ""), [N, y] = p("medium"), [$, _] = p(!1), [R, U] = p(null), K = async () => {
|
|
956
|
+
if (!E.trim()) {
|
|
957
|
+
U("Email is required so the team can follow up.");
|
|
901
958
|
return;
|
|
902
959
|
}
|
|
903
|
-
if (!
|
|
904
|
-
|
|
960
|
+
if (!r) {
|
|
961
|
+
U("Conversation not available yet.");
|
|
905
962
|
return;
|
|
906
963
|
}
|
|
907
|
-
_(!0),
|
|
964
|
+
_(!0), U(null);
|
|
908
965
|
try {
|
|
909
|
-
const
|
|
966
|
+
const v = await n.raiseTicket(r, {
|
|
910
967
|
consent: !0,
|
|
911
|
-
end_user_email:
|
|
968
|
+
end_user_email: E.trim(),
|
|
912
969
|
end_user_phone: a || void 0,
|
|
913
|
-
priority:
|
|
970
|
+
priority: N,
|
|
914
971
|
force_new: !0
|
|
915
972
|
});
|
|
916
|
-
o == null || o(
|
|
917
|
-
} catch (
|
|
918
|
-
|
|
973
|
+
o == null || o(v);
|
|
974
|
+
} catch (v) {
|
|
975
|
+
U((v == null ? void 0 : v.message) || "Could not create ticket. Try again.");
|
|
919
976
|
} finally {
|
|
920
977
|
_(!1);
|
|
921
978
|
}
|
|
922
979
|
};
|
|
923
|
-
return /* @__PURE__ */ e.createElement("div", { className: "dgl-ticket-card" }, /* @__PURE__ */ e.createElement("div", { className: "dgl-ticket-card-stripe", style: { background:
|
|
980
|
+
return /* @__PURE__ */ e.createElement("div", { className: "dgl-ticket-card" }, /* @__PURE__ */ e.createElement("div", { className: "dgl-ticket-card-stripe", style: { background: c.stripe } }), /* @__PURE__ */ e.createElement("div", { className: "dgl-ticket-card-body" }, /* @__PURE__ */ e.createElement("div", { className: "dgl-ticket-card-head" }, /* @__PURE__ */ e.createElement("div", { className: "dgl-ticket-card-icon", style: { background: c.iconBg } }, D()), /* @__PURE__ */ e.createElement("div", { className: "dgl-ticket-card-titles" }, /* @__PURE__ */ e.createElement("div", { className: "dgl-ticket-card-eyebrow" }, "We're already on it"), /* @__PURE__ */ e.createElement("div", { className: "dgl-ticket-card-title" }, "#", t.externalNumber || t.ticketId.slice(0, 8))), t.externalUrl && /* @__PURE__ */ e.createElement("a", { className: "dgl-ticket-open-btn", href: t.externalUrl, target: "_blank", rel: "noopener noreferrer" }, "Open")), /* @__PURE__ */ e.createElement("div", { className: "dgl-ticket-pills" }, /* @__PURE__ */ e.createElement("span", { className: "dgl-ticket-pill", style: { background: c.pillBg, color: c.pillFg } }, /* @__PURE__ */ e.createElement("span", { className: "dgl-ticket-pill-dot", style: { background: c.iconBg } }), " ", c.label)), /* @__PURE__ */ e.createElement("div", { className: "dgl-ticket-card-desc" }, "A ticket has already been raised for this conversation. Our team will follow up — no need to file another."), i ? /* @__PURE__ */ e.createElement("div", { className: "dgl-ticket-diff-form" }, /* @__PURE__ */ e.createElement("div", { className: "dgl-ticket-field-label", style: { marginTop: 4 } }, "File a separate ticket for a new issue"), /* @__PURE__ */ e.createElement("div", { className: "dgl-ticket-form-grid" }, /* @__PURE__ */ e.createElement("div", null, /* @__PURE__ */ e.createElement("div", { className: "dgl-ticket-field-label" }, "Reply to"), /* @__PURE__ */ e.createElement(
|
|
924
981
|
"input",
|
|
925
982
|
{
|
|
926
983
|
type: "email",
|
|
927
984
|
className: "dgl-ticket-input",
|
|
928
|
-
value:
|
|
929
|
-
onChange: (
|
|
985
|
+
value: E,
|
|
986
|
+
onChange: (v) => x(v.target.value),
|
|
930
987
|
placeholder: "you@example.com"
|
|
931
988
|
}
|
|
932
989
|
)), /* @__PURE__ */ e.createElement("div", null, /* @__PURE__ */ e.createElement("div", { className: "dgl-ticket-field-label" }, "Priority"), /* @__PURE__ */ e.createElement(
|
|
933
990
|
"select",
|
|
934
991
|
{
|
|
935
992
|
className: "dgl-ticket-input",
|
|
936
|
-
value:
|
|
937
|
-
onChange: (
|
|
993
|
+
value: N,
|
|
994
|
+
onChange: (v) => y(v.target.value)
|
|
938
995
|
},
|
|
939
996
|
/* @__PURE__ */ e.createElement("option", { value: "low" }, "Low"),
|
|
940
997
|
/* @__PURE__ */ e.createElement("option", { value: "medium" }, "Medium"),
|
|
@@ -945,7 +1002,7 @@ function He({
|
|
|
945
1002
|
{
|
|
946
1003
|
type: "button",
|
|
947
1004
|
className: "dgl-ticket-diff-cancel",
|
|
948
|
-
onClick: () =>
|
|
1005
|
+
onClick: () => u(!1)
|
|
949
1006
|
},
|
|
950
1007
|
"Cancel"
|
|
951
1008
|
), /* @__PURE__ */ e.createElement(
|
|
@@ -953,51 +1010,51 @@ function He({
|
|
|
953
1010
|
{
|
|
954
1011
|
type: "button",
|
|
955
1012
|
className: "dgl-ticket-submit",
|
|
956
|
-
onClick:
|
|
957
|
-
disabled:
|
|
1013
|
+
onClick: K,
|
|
1014
|
+
disabled: $ || !E.trim()
|
|
958
1015
|
},
|
|
959
|
-
|
|
960
|
-
/* @__PURE__ */ e.createElement("span", null,
|
|
1016
|
+
$ ? q() : D(),
|
|
1017
|
+
/* @__PURE__ */ e.createElement("span", null, $ ? "Submitting…" : "Submit new ticket")
|
|
961
1018
|
))) : /* @__PURE__ */ e.createElement(
|
|
962
1019
|
"button",
|
|
963
1020
|
{
|
|
964
1021
|
type: "button",
|
|
965
1022
|
className: "dgl-ticket-diff-link",
|
|
966
|
-
onClick: () =>
|
|
1023
|
+
onClick: () => u(!0)
|
|
967
1024
|
},
|
|
968
1025
|
"Different issue? Raise new ticket →"
|
|
969
1026
|
)));
|
|
970
1027
|
}
|
|
971
|
-
function
|
|
1028
|
+
function Je({
|
|
972
1029
|
ticket: t
|
|
973
1030
|
}) {
|
|
974
|
-
const n =
|
|
975
|
-
return /* @__PURE__ */ e.createElement("div", { className: "dgl-ticket-card" }, /* @__PURE__ */ e.createElement("div", { className: "dgl-ticket-card-stripe", style: { background: n.stripe } }), /* @__PURE__ */ e.createElement("div", { className: "dgl-ticket-card-body" }, /* @__PURE__ */ e.createElement("div", { className: "dgl-ticket-card-head" }, /* @__PURE__ */ e.createElement("div", { className: "dgl-ticket-card-icon", style: { background: n.iconBg } },
|
|
1031
|
+
const n = M[t.status] || M.open, r = Ce[(t.priority || "medium").toLowerCase()] || Ce.medium;
|
|
1032
|
+
return /* @__PURE__ */ e.createElement("div", { className: "dgl-ticket-card" }, /* @__PURE__ */ e.createElement("div", { className: "dgl-ticket-card-stripe", style: { background: n.stripe } }), /* @__PURE__ */ e.createElement("div", { className: "dgl-ticket-card-body" }, /* @__PURE__ */ e.createElement("div", { className: "dgl-ticket-card-head" }, /* @__PURE__ */ e.createElement("div", { className: "dgl-ticket-card-icon", style: { background: n.iconBg } }, D()), /* @__PURE__ */ e.createElement("div", { className: "dgl-ticket-card-titles" }, /* @__PURE__ */ e.createElement("div", { className: "dgl-ticket-card-eyebrow" }, "Support ticket"), /* @__PURE__ */ e.createElement("div", { className: "dgl-ticket-card-title" }, "#", t.externalNumber || t.ticketId.slice(0, 8))), t.externalUrl && /* @__PURE__ */ e.createElement("a", { className: "dgl-ticket-open-btn", href: t.externalUrl, target: "_blank", rel: "noopener noreferrer" }, "Open")), /* @__PURE__ */ e.createElement("div", { className: "dgl-ticket-pills" }, /* @__PURE__ */ e.createElement("span", { className: "dgl-ticket-pill", style: { background: n.pillBg, color: n.pillFg } }, /* @__PURE__ */ e.createElement("span", { className: "dgl-ticket-pill-dot", style: { background: n.iconBg } }), " ", n.label), /* @__PURE__ */ e.createElement("span", { className: "dgl-ticket-pill", style: { background: r.bg, color: r.fg } }, t.priority || "medium", " priority")), t.title && /* @__PURE__ */ e.createElement("div", { className: "dgl-ticket-card-body-title" }, t.title), /* @__PURE__ */ e.createElement("div", { className: "dgl-ticket-meta-grid" }, /* @__PURE__ */ e.createElement("div", null, /* @__PURE__ */ e.createElement("div", { className: "dgl-ticket-meta-label" }, "Last update"), /* @__PURE__ */ e.createElement("div", { className: "dgl-ticket-meta-value" }, ie(t.lastUpdate))), /* @__PURE__ */ e.createElement("div", null, /* @__PURE__ */ e.createElement("div", { className: "dgl-ticket-meta-label" }, "Assigned to"), /* @__PURE__ */ e.createElement("div", { className: "dgl-ticket-meta-value" }, t.assignedTo || "Unassigned")))));
|
|
976
1033
|
}
|
|
977
|
-
function
|
|
1034
|
+
function Qe({
|
|
978
1035
|
tickets: t,
|
|
979
1036
|
onClose: n,
|
|
980
|
-
onRefresh:
|
|
1037
|
+
onRefresh: r
|
|
981
1038
|
}) {
|
|
982
|
-
const [l, a] =
|
|
1039
|
+
const [l, a] = p(!1);
|
|
983
1040
|
T(() => {
|
|
984
|
-
const
|
|
985
|
-
|
|
1041
|
+
const i = (u) => {
|
|
1042
|
+
u.key === "Escape" && n();
|
|
986
1043
|
};
|
|
987
|
-
return window.addEventListener("keydown",
|
|
1044
|
+
return window.addEventListener("keydown", i), () => window.removeEventListener("keydown", i);
|
|
988
1045
|
}, [n]);
|
|
989
1046
|
const o = async () => {
|
|
990
1047
|
a(!0);
|
|
991
1048
|
try {
|
|
992
|
-
await
|
|
1049
|
+
await r();
|
|
993
1050
|
} finally {
|
|
994
1051
|
a(!1);
|
|
995
1052
|
}
|
|
996
|
-
},
|
|
997
|
-
const
|
|
998
|
-
return (
|
|
1053
|
+
}, c = [...t].sort((i, u) => {
|
|
1054
|
+
const E = i.created_at ? new Date(i.created_at).getTime() : 0;
|
|
1055
|
+
return (u.created_at ? new Date(u.created_at).getTime() : 0) - E;
|
|
999
1056
|
});
|
|
1000
|
-
return /* @__PURE__ */ e.createElement("div", { className: "dgl-tix-modal-backdrop", onClick: n }, /* @__PURE__ */ e.createElement("div", { className: "dgl-tix-modal", onClick: (
|
|
1057
|
+
return /* @__PURE__ */ e.createElement("div", { className: "dgl-tix-modal-backdrop", onClick: n }, /* @__PURE__ */ e.createElement("div", { className: "dgl-tix-modal", onClick: (i) => i.stopPropagation() }, /* @__PURE__ */ e.createElement("div", { className: "dgl-tix-modal-header" }, /* @__PURE__ */ e.createElement("div", null, /* @__PURE__ */ e.createElement("div", { className: "dgl-tix-modal-title" }, "Your tickets"), /* @__PURE__ */ e.createElement("div", { className: "dgl-tix-modal-sub" }, t.length === 0 ? "No tickets yet" : `${t.length} ticket${t.length === 1 ? "" : "s"} on this assistant`)), /* @__PURE__ */ e.createElement("div", { style: { display: "flex", gap: 4 } }, /* @__PURE__ */ e.createElement(
|
|
1001
1058
|
"button",
|
|
1002
1059
|
{
|
|
1003
1060
|
type: "button",
|
|
@@ -1008,7 +1065,7 @@ function Ve({
|
|
|
1008
1065
|
disabled: l,
|
|
1009
1066
|
style: { color: "#475569" }
|
|
1010
1067
|
},
|
|
1011
|
-
l ?
|
|
1068
|
+
l ? q() : ct()
|
|
1012
1069
|
), /* @__PURE__ */ e.createElement(
|
|
1013
1070
|
"button",
|
|
1014
1071
|
{
|
|
@@ -1019,86 +1076,127 @@ function Ve({
|
|
|
1019
1076
|
"aria-label": "Close",
|
|
1020
1077
|
style: { color: "#475569" }
|
|
1021
1078
|
},
|
|
1022
|
-
|
|
1023
|
-
))), /* @__PURE__ */ e.createElement("div", { className: "dgl-tix-modal-list" },
|
|
1024
|
-
const
|
|
1025
|
-
return /* @__PURE__ */ e.createElement("div", { key:
|
|
1079
|
+
W()
|
|
1080
|
+
))), /* @__PURE__ */ e.createElement("div", { className: "dgl-tix-modal-list" }, c.length === 0 ? /* @__PURE__ */ e.createElement("div", { className: "dgl-tix-empty" }, "You haven't raised any support tickets here yet. They'll show up here once you do.") : c.map((i) => {
|
|
1081
|
+
const u = M[i.status] || M.open;
|
|
1082
|
+
return /* @__PURE__ */ e.createElement("div", { key: i.id, className: "dgl-tix-row" }, /* @__PURE__ */ e.createElement("div", { className: "dgl-tix-row-head" }, /* @__PURE__ */ e.createElement("span", { className: "dgl-tix-row-num" }, "#", i.external_ticket_number || i.id.slice(0, 8)), /* @__PURE__ */ e.createElement(
|
|
1026
1083
|
"span",
|
|
1027
1084
|
{
|
|
1028
1085
|
className: "dgl-ticket-pill",
|
|
1029
|
-
style: { background:
|
|
1086
|
+
style: { background: u.pillBg, color: u.pillFg }
|
|
1030
1087
|
},
|
|
1031
|
-
/* @__PURE__ */ e.createElement("span", { className: "dgl-ticket-pill-dot", style: { background:
|
|
1032
|
-
|
|
1033
|
-
),
|
|
1088
|
+
/* @__PURE__ */ e.createElement("span", { className: "dgl-ticket-pill-dot", style: { background: u.iconBg } }),
|
|
1089
|
+
u.label
|
|
1090
|
+
), i.external_url && /* @__PURE__ */ e.createElement(
|
|
1034
1091
|
"a",
|
|
1035
1092
|
{
|
|
1036
|
-
href:
|
|
1093
|
+
href: i.external_url,
|
|
1037
1094
|
target: "_blank",
|
|
1038
1095
|
rel: "noopener noreferrer",
|
|
1039
1096
|
className: "dgl-ticket-open-btn",
|
|
1040
1097
|
style: { marginLeft: "auto" }
|
|
1041
1098
|
},
|
|
1042
1099
|
"Open"
|
|
1043
|
-
)),
|
|
1100
|
+
)), i.title && /* @__PURE__ */ e.createElement("div", { className: "dgl-tix-row-title" }, i.title), /* @__PURE__ */ e.createElement("div", { className: "dgl-tix-row-meta" }, i.priority || "medium", " priority · raised ", ie(i.created_at)));
|
|
1044
1101
|
}))));
|
|
1045
1102
|
}
|
|
1046
|
-
function
|
|
1103
|
+
function Ze({
|
|
1104
|
+
chats: t,
|
|
1105
|
+
currentConvId: n,
|
|
1106
|
+
onClose: r,
|
|
1107
|
+
onPick: l
|
|
1108
|
+
}) {
|
|
1109
|
+
return T(() => {
|
|
1110
|
+
const a = (o) => {
|
|
1111
|
+
o.key === "Escape" && r();
|
|
1112
|
+
};
|
|
1113
|
+
return window.addEventListener("keydown", a), () => window.removeEventListener("keydown", a);
|
|
1114
|
+
}, [r]), /* @__PURE__ */ e.createElement("div", { className: "dgl-tix-modal-backdrop", onClick: r }, /* @__PURE__ */ e.createElement("div", { className: "dgl-tix-modal", onClick: (a) => a.stopPropagation() }, /* @__PURE__ */ e.createElement("div", { className: "dgl-tix-modal-header" }, /* @__PURE__ */ e.createElement("div", null, /* @__PURE__ */ e.createElement("div", { className: "dgl-tix-modal-title" }, "Your chats"), /* @__PURE__ */ e.createElement("div", { className: "dgl-tix-modal-sub" }, t.length === 0 ? "No conversations yet" : `${t.length} conversation${t.length === 1 ? "" : "s"}`)), /* @__PURE__ */ e.createElement(
|
|
1115
|
+
"button",
|
|
1116
|
+
{
|
|
1117
|
+
type: "button",
|
|
1118
|
+
onClick: r,
|
|
1119
|
+
className: "dgl-icon-btn",
|
|
1120
|
+
title: "Close",
|
|
1121
|
+
"aria-label": "Close",
|
|
1122
|
+
style: { color: "#475569" }
|
|
1123
|
+
},
|
|
1124
|
+
W()
|
|
1125
|
+
)), /* @__PURE__ */ e.createElement("div", { className: "dgl-tix-modal-list" }, t.length === 0 ? /* @__PURE__ */ e.createElement("div", { className: "dgl-tix-empty" }, "Your conversations with this assistant will show up here.") : t.map((a) => {
|
|
1126
|
+
const o = a.id === n, c = a.title || a.preview || `Conversation ${a.id.slice(0, 8)}`;
|
|
1127
|
+
return /* @__PURE__ */ e.createElement(
|
|
1128
|
+
"button",
|
|
1129
|
+
{
|
|
1130
|
+
key: a.id,
|
|
1131
|
+
type: "button",
|
|
1132
|
+
onClick: () => l(a.id),
|
|
1133
|
+
className: `dgl-chat-row${o ? " dgl-chat-row-current" : ""}`,
|
|
1134
|
+
title: o ? "Current conversation" : "Open this conversation"
|
|
1135
|
+
},
|
|
1136
|
+
/* @__PURE__ */ e.createElement("div", { className: "dgl-chat-row-title" }, c),
|
|
1137
|
+
/* @__PURE__ */ e.createElement("div", { className: "dgl-chat-row-meta" }, a.message_count, " message", a.message_count === 1 ? "" : "s", a.updated_at ? ` · ${ie(a.updated_at)}` : "", o ? " · current" : "")
|
|
1138
|
+
);
|
|
1139
|
+
}))));
|
|
1140
|
+
}
|
|
1141
|
+
function D() {
|
|
1047
1142
|
return /* @__PURE__ */ e.createElement("svg", { viewBox: "0 0 24 24", width: "16", height: "16", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }, /* @__PURE__ */ e.createElement("circle", { cx: "12", cy: "12", r: "10" }), /* @__PURE__ */ e.createElement("circle", { cx: "12", cy: "12", r: "4" }), /* @__PURE__ */ e.createElement("path", { d: "M4.93 4.93l4.24 4.24M14.83 14.83l4.24 4.24M14.83 9.17l4.24-4.24M14.83 9.17l3.53-3.53M4.93 19.07l4.24-4.24" }));
|
|
1048
1143
|
}
|
|
1049
|
-
function
|
|
1144
|
+
function et() {
|
|
1050
1145
|
return /* @__PURE__ */ e.createElement("svg", { viewBox: "0 0 24 24", width: "16", height: "16", fill: "none", stroke: "white", strokeWidth: "3", strokeLinecap: "round", strokeLinejoin: "round" }, /* @__PURE__ */ e.createElement("path", { d: "M20 6L9 17l-5-5" }));
|
|
1051
1146
|
}
|
|
1052
|
-
function
|
|
1147
|
+
function tt() {
|
|
1053
1148
|
return /* @__PURE__ */ e.createElement("svg", { viewBox: "0 0 24 24", width: "22", height: "22", fill: "currentColor" }, /* @__PURE__ */ e.createElement("path", { d: "M4 4h16a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H8l-4 4V6a2 2 0 0 1 2-2z" }));
|
|
1054
1149
|
}
|
|
1055
|
-
function
|
|
1150
|
+
function at() {
|
|
1056
1151
|
return /* @__PURE__ */ e.createElement("svg", { viewBox: "0 0 24 24", width: "22", height: "22", fill: "none", stroke: "currentColor", strokeWidth: "2.5", strokeLinecap: "round", strokeLinejoin: "round" }, /* @__PURE__ */ e.createElement("polyline", { points: "6 9 12 15 18 9" }));
|
|
1057
1152
|
}
|
|
1058
|
-
function
|
|
1153
|
+
function W() {
|
|
1059
1154
|
return /* @__PURE__ */ e.createElement("svg", { viewBox: "0 0 24 24", width: "16", height: "16", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }, /* @__PURE__ */ e.createElement("line", { x1: "18", y1: "6", x2: "6", y2: "18" }), /* @__PURE__ */ e.createElement("line", { x1: "6", y1: "6", x2: "18", y2: "18" }));
|
|
1060
1155
|
}
|
|
1061
|
-
function
|
|
1156
|
+
function nt() {
|
|
1062
1157
|
return /* @__PURE__ */ e.createElement("svg", { viewBox: "0 0 24 24", width: "16", height: "16", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }, /* @__PURE__ */ e.createElement("line", { x1: "12", y1: "5", x2: "12", y2: "19" }), /* @__PURE__ */ e.createElement("line", { x1: "5", y1: "12", x2: "19", y2: "12" }));
|
|
1063
1158
|
}
|
|
1064
|
-
function
|
|
1159
|
+
function lt() {
|
|
1065
1160
|
return /* @__PURE__ */ e.createElement("svg", { viewBox: "0 0 24 24", width: "16", height: "16", fill: "currentColor" }, /* @__PURE__ */ e.createElement("path", { d: "M2 21l21-9L2 3v7l15 2-15 2z" }));
|
|
1066
1161
|
}
|
|
1067
|
-
function
|
|
1162
|
+
function rt() {
|
|
1068
1163
|
return /* @__PURE__ */ e.createElement("svg", { viewBox: "0 0 24 24", width: "18", height: "18", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }, /* @__PURE__ */ e.createElement("rect", { x: "3", y: "3", width: "18", height: "18", rx: "2" }), /* @__PURE__ */ e.createElement("circle", { cx: "8.5", cy: "8.5", r: "1.5" }), /* @__PURE__ */ e.createElement("polyline", { points: "21 15 16 10 5 21" }));
|
|
1069
1164
|
}
|
|
1070
|
-
function
|
|
1165
|
+
function q() {
|
|
1071
1166
|
return /* @__PURE__ */ e.createElement("svg", { viewBox: "0 0 24 24", width: "16", height: "16", className: "dgl-spin", fill: "none", stroke: "currentColor", strokeWidth: "3", strokeLinecap: "round" }, /* @__PURE__ */ e.createElement("path", { d: "M21 12a9 9 0 1 1-6.219-8.56" }));
|
|
1072
1167
|
}
|
|
1073
|
-
function
|
|
1168
|
+
function it() {
|
|
1074
1169
|
return /* @__PURE__ */ e.createElement("svg", { viewBox: "0 0 24 24", width: "14", height: "14", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }, /* @__PURE__ */ e.createElement("polyline", { points: "15 3 21 3 21 9" }), /* @__PURE__ */ e.createElement("polyline", { points: "9 21 3 21 3 15" }), /* @__PURE__ */ e.createElement("line", { x1: "21", y1: "3", x2: "14", y2: "10" }), /* @__PURE__ */ e.createElement("line", { x1: "3", y1: "21", x2: "10", y2: "14" }));
|
|
1075
1170
|
}
|
|
1076
|
-
function
|
|
1171
|
+
function st() {
|
|
1077
1172
|
return /* @__PURE__ */ e.createElement("svg", { viewBox: "0 0 24 24", width: "14", height: "14", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }, /* @__PURE__ */ e.createElement("polyline", { points: "4 14 10 14 10 20" }), /* @__PURE__ */ e.createElement("polyline", { points: "20 10 14 10 14 4" }), /* @__PURE__ */ e.createElement("line", { x1: "14", y1: "10", x2: "21", y2: "3" }), /* @__PURE__ */ e.createElement("line", { x1: "3", y1: "21", x2: "10", y2: "14" }));
|
|
1078
1173
|
}
|
|
1079
|
-
function
|
|
1174
|
+
function ct() {
|
|
1080
1175
|
return /* @__PURE__ */ e.createElement("svg", { viewBox: "0 0 24 24", width: "14", height: "14", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }, /* @__PURE__ */ e.createElement("polyline", { points: "23 4 23 10 17 10" }), /* @__PURE__ */ e.createElement("polyline", { points: "1 20 1 14 7 14" }), /* @__PURE__ */ e.createElement("path", { d: "M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15" }));
|
|
1081
1176
|
}
|
|
1082
|
-
function
|
|
1177
|
+
function ot() {
|
|
1178
|
+
return /* @__PURE__ */ e.createElement("svg", { viewBox: "0 0 24 24", width: "16", height: "16", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }, /* @__PURE__ */ e.createElement("path", { d: "M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z" }), /* @__PURE__ */ e.createElement("line", { x1: "7", y1: "9", x2: "17", y2: "9" }), /* @__PURE__ */ e.createElement("line", { x1: "7", y1: "13", x2: "13", y2: "13" }));
|
|
1179
|
+
}
|
|
1180
|
+
function Ue() {
|
|
1083
1181
|
return /* @__PURE__ */ e.createElement("svg", { viewBox: "0 0 24 24", width: "14", height: "14", fill: "currentColor" }, /* @__PURE__ */ e.createElement("path", { d: "M12 2l2.39 6.95L21 11l-6.61 2.05L12 20l-2.39-6.95L3 11l6.61-2.05L12 2z" }));
|
|
1084
1182
|
}
|
|
1085
|
-
let B = null,
|
|
1086
|
-
function
|
|
1183
|
+
let B = null, A = null;
|
|
1184
|
+
function dt(t) {
|
|
1087
1185
|
if (typeof document == "undefined")
|
|
1088
1186
|
throw new Error("DocGenLab.init() requires a browser environment.");
|
|
1089
1187
|
if (B) {
|
|
1090
|
-
B.render(
|
|
1188
|
+
B.render(ve(re, t));
|
|
1091
1189
|
return;
|
|
1092
1190
|
}
|
|
1093
|
-
|
|
1191
|
+
A = document.createElement("div"), A.id = "docgenlab-chat-widget-root", document.body.appendChild(A), B = Oe(A), B.render(ve(re, t));
|
|
1094
1192
|
}
|
|
1095
|
-
function
|
|
1096
|
-
B && (B.unmount(), B = null),
|
|
1193
|
+
function mt() {
|
|
1194
|
+
B && (B.unmount(), B = null), A && (A.remove(), A = null);
|
|
1097
1195
|
}
|
|
1098
|
-
typeof window != "undefined" && (window.DocGenLab = { init:
|
|
1196
|
+
typeof window != "undefined" && (window.DocGenLab = { init: dt, destroy: mt, DocGenLabChat: re });
|
|
1099
1197
|
export {
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1198
|
+
re as DocGenLabChat,
|
|
1199
|
+
mt as destroy,
|
|
1200
|
+
dt as init
|
|
1103
1201
|
};
|
|
1104
1202
|
//# sourceMappingURL=index.js.map
|