@docgenlab.com/chat-widget 0.2.4 → 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 +51 -1
- package/dist/index.js +940 -333
- package/dist/index.js.map +1 -1
- package/dist/index.umd.cjs +6 -6
- package/dist/index.umd.cjs.map +1 -1
- package/dist/types.d.ts +92 -0
- package/dist/widget.css +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,134 +1,209 @@
|
|
|
1
|
-
import { createRoot as
|
|
1
|
+
import { createRoot as Oe } from "react-dom/client";
|
|
2
2
|
import * as e from "react";
|
|
3
|
-
import { useRef 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
|
-
return t && typeof t.randomUUID == "function" ? t.randomUUID() : "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (
|
|
8
|
-
const
|
|
9
|
-
return (
|
|
7
|
+
return t && typeof t.randomUUID == "function" ? t.randomUUID() : "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (n) => {
|
|
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
|
|
21
|
-
constructor(
|
|
22
|
-
this.agentKey =
|
|
20
|
+
class Ae {
|
|
21
|
+
constructor(n) {
|
|
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
|
-
headers(
|
|
25
|
-
const
|
|
24
|
+
headers(n) {
|
|
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
|
|
33
|
+
const n = await fetch(`${this.baseUrl}${I}/agent`, {
|
|
34
34
|
method: "GET",
|
|
35
35
|
headers: this.headers()
|
|
36
36
|
});
|
|
37
|
-
if (!
|
|
38
|
-
return
|
|
37
|
+
if (!n.ok) throw new Error(`getAgent failed: ${n.status}`);
|
|
38
|
+
return n.json();
|
|
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
|
+
}
|
|
49
|
+
/** Load a previous conversation's messages so the widget can show
|
|
50
|
+
* history after a refresh / re-open. The visitor-id header is the
|
|
51
|
+
* authorization — the backend only returns conversations owned by
|
|
52
|
+
* the requesting visitor on this agent. */
|
|
53
|
+
async getConversation(n) {
|
|
54
|
+
const r = `${this.baseUrl}${I}/conversations/${encodeURIComponent(n)}`, l = await fetch(r, { headers: this.headers() });
|
|
55
|
+
if (!l.ok) throw new Error(`getConversation failed: ${l.status}`);
|
|
56
|
+
return l.json();
|
|
39
57
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
58
|
+
/** Reconstruct the ticket card that SHOULD currently be on the
|
|
59
|
+
* conversation, based on persisted state. Lets the widget restore
|
|
60
|
+
* raise-ticket / "already on it" / created cards after refresh.
|
|
61
|
+
* Returns kind=null when nothing should show. */
|
|
62
|
+
async getTicketCardState(n) {
|
|
63
|
+
const r = `${this.baseUrl}${I}/conversations/${encodeURIComponent(n)}/ticket-card`, l = await fetch(r, { headers: this.headers() });
|
|
64
|
+
if (!l.ok) throw new Error(`getTicketCardState failed: ${l.status}`);
|
|
65
|
+
return l.json();
|
|
66
|
+
}
|
|
67
|
+
async uploadImage(n) {
|
|
68
|
+
const r = new FormData();
|
|
69
|
+
r.append("file", n);
|
|
70
|
+
const l = await fetch(`${this.baseUrl}${I}/chat-image`, {
|
|
44
71
|
method: "POST",
|
|
45
72
|
headers: this.headers(),
|
|
46
73
|
// browser sets Content-Type for FormData
|
|
47
|
-
body:
|
|
74
|
+
body: r
|
|
48
75
|
});
|
|
49
|
-
if (!
|
|
50
|
-
let o = `${
|
|
76
|
+
if (!l.ok) {
|
|
77
|
+
let o = `${l.status} ${l.statusText}`;
|
|
51
78
|
try {
|
|
52
|
-
const
|
|
53
|
-
o = (
|
|
54
|
-
} catch (
|
|
79
|
+
const c = await l.json();
|
|
80
|
+
o = (c == null ? void 0 : c.detail) || o;
|
|
81
|
+
} catch (c) {
|
|
55
82
|
}
|
|
56
83
|
throw new Error(o);
|
|
57
84
|
}
|
|
58
|
-
return (await
|
|
85
|
+
return (await l.json()).image_path;
|
|
59
86
|
}
|
|
60
87
|
/** Fetch a previously-uploaded image as a blob URL. Caller must
|
|
61
88
|
* URL.revokeObjectURL() when done to avoid memory leaks. */
|
|
62
|
-
async fetchImage(
|
|
63
|
-
const
|
|
89
|
+
async fetchImage(n) {
|
|
90
|
+
const r = `${this.baseUrl}${I}/chat-image?path=${encodeURIComponent(n)}&key=${encodeURIComponent(this.agentKey)}`, l = await fetch(r, {
|
|
64
91
|
method: "GET",
|
|
65
92
|
headers: { "X-DocGenLab-Visitor-Id": this.visitorId }
|
|
66
93
|
});
|
|
67
|
-
if (!
|
|
68
|
-
const
|
|
69
|
-
return URL.createObjectURL(
|
|
94
|
+
if (!l.ok) throw new Error(`fetchImage failed: ${l.status}`);
|
|
95
|
+
const a = await l.blob();
|
|
96
|
+
return URL.createObjectURL(a);
|
|
97
|
+
}
|
|
98
|
+
/** Raise a support ticket from a conversation. Requires explicit user
|
|
99
|
+
* consent — the widget only calls this after the user clicks the
|
|
100
|
+
* in-chat "Raise a ticket" chip. */
|
|
101
|
+
async raiseTicket(n, r) {
|
|
102
|
+
const l = `${this.baseUrl}${I}/conversations/${encodeURIComponent(n)}/raise-ticket`, a = await fetch(l, {
|
|
103
|
+
method: "POST",
|
|
104
|
+
headers: {
|
|
105
|
+
"Content-Type": "application/json",
|
|
106
|
+
"X-DocGenLab-Key": this.agentKey,
|
|
107
|
+
"X-DocGenLab-Visitor-Id": this.visitorId,
|
|
108
|
+
...this.endUserHash ? { "X-DocGenLab-User-Hash": this.endUserHash } : {}
|
|
109
|
+
},
|
|
110
|
+
body: JSON.stringify(r)
|
|
111
|
+
});
|
|
112
|
+
if (!a.ok) {
|
|
113
|
+
let o = `raiseTicket failed: ${a.status}`;
|
|
114
|
+
try {
|
|
115
|
+
o = (await a.json()).detail || o;
|
|
116
|
+
} catch (c) {
|
|
117
|
+
}
|
|
118
|
+
throw new Error(o);
|
|
119
|
+
}
|
|
120
|
+
return a.json();
|
|
121
|
+
}
|
|
122
|
+
/** List all tickets for THIS visitor on THIS agent. Used by the widget
|
|
123
|
+
* to hydrate ticket cards on conversation reload and to power the
|
|
124
|
+
* "Manage tickets" modal. Optionally filtered by conversation. */
|
|
125
|
+
async listTickets(n) {
|
|
126
|
+
const r = n ? `?conversation_id=${encodeURIComponent(n)}` : "", l = `${this.baseUrl}${I}/tickets${r}`, a = await fetch(l, {
|
|
127
|
+
headers: {
|
|
128
|
+
"X-DocGenLab-Key": this.agentKey,
|
|
129
|
+
"X-DocGenLab-Visitor-Id": this.visitorId
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
if (!a.ok) throw new Error(`listTickets failed: ${a.status}`);
|
|
133
|
+
return a.json();
|
|
134
|
+
}
|
|
135
|
+
/** Fetch the latest status of a ticket the user raised. */
|
|
136
|
+
async getTicket(n, r = !1) {
|
|
137
|
+
const l = `${this.baseUrl}${I}/tickets/${encodeURIComponent(n)}${r ? "?refresh=1" : ""}`, a = await fetch(l, {
|
|
138
|
+
headers: {
|
|
139
|
+
"X-DocGenLab-Key": this.agentKey,
|
|
140
|
+
"X-DocGenLab-Visitor-Id": this.visitorId
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
if (!a.ok) throw new Error(`getTicket failed: ${a.status}`);
|
|
144
|
+
return a.json();
|
|
70
145
|
}
|
|
71
146
|
/** Fetch a video-source frame attached to a citation chunk.
|
|
72
147
|
* Same auth pattern as fetchImage. */
|
|
73
|
-
async fetchSourceFrame(
|
|
74
|
-
const
|
|
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, {
|
|
75
150
|
method: "GET",
|
|
76
151
|
headers: { "X-DocGenLab-Visitor-Id": this.visitorId }
|
|
77
152
|
});
|
|
78
|
-
if (!
|
|
79
|
-
const o = await
|
|
153
|
+
if (!a.ok) throw new Error(`fetchSourceFrame failed: ${a.status}`);
|
|
154
|
+
const o = await a.blob();
|
|
80
155
|
return URL.createObjectURL(o);
|
|
81
156
|
}
|
|
82
157
|
/** Stream a chat response via SSE. Returns an abort fn the caller invokes
|
|
83
158
|
* to cancel the stream. */
|
|
84
|
-
streamChat(
|
|
85
|
-
const
|
|
159
|
+
streamChat(n, r) {
|
|
160
|
+
const l = new AbortController();
|
|
86
161
|
return (async () => {
|
|
87
162
|
try {
|
|
88
|
-
const
|
|
163
|
+
const a = await fetch(`${this.baseUrl}${I}/chat`, {
|
|
89
164
|
method: "POST",
|
|
90
|
-
signal:
|
|
165
|
+
signal: l.signal,
|
|
91
166
|
headers: this.headers({ "Content-Type": "application/json", Accept: "text/event-stream" }),
|
|
92
|
-
body: JSON.stringify(
|
|
167
|
+
body: JSON.stringify(n)
|
|
93
168
|
});
|
|
94
|
-
if (!
|
|
95
|
-
let
|
|
169
|
+
if (!a.ok || !a.body) {
|
|
170
|
+
let u = `${a.status} ${a.statusText}`;
|
|
96
171
|
try {
|
|
97
|
-
const
|
|
98
|
-
|
|
99
|
-
} catch (
|
|
172
|
+
const E = await a.json();
|
|
173
|
+
u = (E == null ? void 0 : E.detail) || u;
|
|
174
|
+
} catch (E) {
|
|
100
175
|
}
|
|
101
|
-
|
|
176
|
+
r({ type: "error", error: u });
|
|
102
177
|
return;
|
|
103
178
|
}
|
|
104
|
-
const o =
|
|
105
|
-
let
|
|
179
|
+
const o = a.body.getReader(), c = new TextDecoder();
|
|
180
|
+
let i = "";
|
|
106
181
|
for (; ; ) {
|
|
107
|
-
const { value:
|
|
108
|
-
if (
|
|
109
|
-
|
|
110
|
-
let
|
|
111
|
-
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(`
|
|
112
187
|
|
|
113
188
|
`)) !== -1; ) {
|
|
114
|
-
const
|
|
115
|
-
|
|
116
|
-
const
|
|
117
|
-
if (
|
|
189
|
+
const N = i.slice(0, x);
|
|
190
|
+
i = i.slice(x + 2);
|
|
191
|
+
const y = N.trim();
|
|
192
|
+
if (y.startsWith("data:"))
|
|
118
193
|
try {
|
|
119
|
-
const
|
|
120
|
-
|
|
121
|
-
} catch (
|
|
194
|
+
const $ = JSON.parse(y.slice(5).trim());
|
|
195
|
+
r($);
|
|
196
|
+
} catch ($) {
|
|
122
197
|
}
|
|
123
198
|
}
|
|
124
199
|
}
|
|
125
|
-
} catch (
|
|
126
|
-
(
|
|
200
|
+
} catch (a) {
|
|
201
|
+
(a == null ? void 0 : a.name) !== "AbortError" && r({ type: "error", error: (a == null ? void 0 : a.message) || String(a) });
|
|
127
202
|
}
|
|
128
|
-
})(), () =>
|
|
203
|
+
})(), () => l.abort();
|
|
129
204
|
}
|
|
130
205
|
}
|
|
131
|
-
const
|
|
206
|
+
const xe = "0.5.1", F = {
|
|
132
207
|
apiBaseUrl: "https://api.docgenlab.com",
|
|
133
208
|
position: "bottom-right",
|
|
134
209
|
primary: "#4F46E5",
|
|
@@ -138,194 +213,391 @@ const x = {
|
|
|
138
213
|
greeting: "How can I help you today?",
|
|
139
214
|
greetingSub: "Ask anything about your uploaded documents. I'll only answer from what's in the knowledge base."
|
|
140
215
|
};
|
|
141
|
-
function
|
|
142
|
-
var
|
|
143
|
-
const
|
|
144
|
-
(!
|
|
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({
|
|
145
220
|
agentKey: t.agentKey,
|
|
146
|
-
apiBaseUrl:
|
|
221
|
+
apiBaseUrl: n,
|
|
147
222
|
endUserId: t.endUserId,
|
|
148
223
|
endUserHash: t.endUserHash
|
|
149
|
-
}), o.current =
|
|
150
|
-
const
|
|
151
|
-
position: t.position ||
|
|
152
|
-
primary: ((
|
|
153
|
-
primaryText: ((
|
|
154
|
-
radius: ((
|
|
155
|
-
fontFamily: ((
|
|
156
|
-
greeting: t.greeting ||
|
|
157
|
-
agentName: t.agentName ||
|
|
158
|
-
agentAvatarUrl: t.agentAvatarUrl ||
|
|
159
|
-
launcherAvatarUrl:
|
|
160
|
-
hideBranding: (
|
|
161
|
-
openOnLoad: (
|
|
162
|
-
},
|
|
163
|
-
"--dgl-primary":
|
|
164
|
-
"--dgl-primary-text":
|
|
165
|
-
"--dgl-radius":
|
|
166
|
-
"--dgl-font":
|
|
167
|
-
}, [
|
|
168
|
-
|
|
169
|
-
!
|
|
170
|
-
var
|
|
171
|
-
|
|
172
|
-
}).catch((
|
|
173
|
-
var
|
|
174
|
-
|
|
224
|
+
}), o.current = a);
|
|
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([]);
|
|
243
|
+
T(() => {
|
|
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);
|
|
175
250
|
});
|
|
176
|
-
}, [
|
|
177
|
-
|
|
178
|
-
d
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
251
|
+
}, [_, i, c, t]), T(() => {
|
|
252
|
+
if (!_ || t.disableTicketing) return;
|
|
253
|
+
let d = !1;
|
|
254
|
+
return c.listTickets().then((h) => {
|
|
255
|
+
d || ne(h);
|
|
256
|
+
}).catch(() => {
|
|
257
|
+
}), () => {
|
|
258
|
+
d = !0;
|
|
259
|
+
};
|
|
260
|
+
}, [_, c, t.disableTicketing]), T(() => {
|
|
261
|
+
if (!_) return;
|
|
262
|
+
const d = `dgl-chat:${t.agentKey}`, h = localStorage.getItem(d);
|
|
263
|
+
if (!h) return;
|
|
264
|
+
let g = !1;
|
|
265
|
+
return (async () => {
|
|
266
|
+
try {
|
|
267
|
+
const [b, m] = await Promise.all([
|
|
268
|
+
c.getConversation(h),
|
|
269
|
+
c.getTicketCardState(h).catch(() => null)
|
|
270
|
+
]);
|
|
271
|
+
if (g) return;
|
|
272
|
+
const s = [];
|
|
273
|
+
for (const C of b.messages || [])
|
|
274
|
+
C.role === "user" ? s.push({
|
|
275
|
+
id: C.id,
|
|
276
|
+
role: "user",
|
|
277
|
+
content: C.content || "",
|
|
278
|
+
imagePath: C.image_path || void 0
|
|
279
|
+
}) : C.role === "assistant" && s.push({
|
|
280
|
+
id: C.id,
|
|
281
|
+
role: "assistant",
|
|
282
|
+
content: C.content || "",
|
|
283
|
+
citations: C.retrieved_chunks || void 0
|
|
284
|
+
});
|
|
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;
|
|
290
|
+
break;
|
|
291
|
+
}
|
|
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
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
V(h), L(s);
|
|
311
|
+
} catch (b) {
|
|
312
|
+
localStorage.removeItem(d);
|
|
313
|
+
}
|
|
314
|
+
})(), () => {
|
|
315
|
+
g = !0;
|
|
316
|
+
};
|
|
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) {
|
|
196
334
|
try {
|
|
197
|
-
|
|
198
|
-
} catch (
|
|
199
|
-
(
|
|
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);
|
|
200
338
|
return;
|
|
201
339
|
}
|
|
202
|
-
|
|
340
|
+
ee(!1), b = S || void 0;
|
|
203
341
|
}
|
|
204
|
-
|
|
205
|
-
...
|
|
206
|
-
{ role: "user", content:
|
|
342
|
+
J(""), Y.current = "", L((s) => [
|
|
343
|
+
...s,
|
|
344
|
+
{ role: "user", content: h, imagePath: g, imagePreviewUrl: b },
|
|
207
345
|
{ role: "assistant", content: "", streaming: !0 }
|
|
208
|
-
]),
|
|
209
|
-
{ message:
|
|
210
|
-
(
|
|
211
|
-
var
|
|
212
|
-
if (
|
|
213
|
-
|
|
214
|
-
else if (
|
|
215
|
-
|
|
216
|
-
const
|
|
217
|
-
|
|
218
|
-
(
|
|
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
|
|
357
|
+
));
|
|
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
|
|
361
|
+
));
|
|
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
|
|
365
|
+
));
|
|
366
|
+
else if (s.type === "ticket_offer") {
|
|
367
|
+
if (t.disableTicketing) return;
|
|
368
|
+
L((f) => f.map(
|
|
369
|
+
(k, w) => w === f.length - 1 && k.role === "assistant" ? {
|
|
370
|
+
...k,
|
|
371
|
+
ticketOffer: {
|
|
372
|
+
conversationId: s.conversation_id,
|
|
373
|
+
connectorType: s.connector_type,
|
|
374
|
+
connectorName: s.connector_name
|
|
375
|
+
}
|
|
376
|
+
} : k
|
|
377
|
+
));
|
|
378
|
+
} else if (s.type === "ticket_existing") {
|
|
379
|
+
if (t.disableTicketing) return;
|
|
380
|
+
L((f) => f.map(
|
|
381
|
+
(k, w) => w === f.length - 1 && k.role === "assistant" ? {
|
|
382
|
+
...k,
|
|
383
|
+
ticketExisting: {
|
|
384
|
+
ticketId: s.ticket_id,
|
|
385
|
+
externalNumber: s.external_ticket_number,
|
|
386
|
+
externalUrl: s.external_url,
|
|
387
|
+
status: s.status
|
|
388
|
+
}
|
|
389
|
+
} : k
|
|
219
390
|
));
|
|
220
|
-
} else
|
|
221
|
-
(
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
391
|
+
} else s.type === "ticket_status_card" ? L((f) => f.map(
|
|
392
|
+
(k, w) => w === f.length - 1 && k.role === "assistant" ? {
|
|
393
|
+
...k,
|
|
394
|
+
ticketStatus: {
|
|
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
|
|
404
|
+
}
|
|
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));
|
|
229
411
|
}
|
|
230
412
|
);
|
|
231
|
-
},
|
|
232
|
-
|
|
413
|
+
}, Re = () => {
|
|
414
|
+
te.current && te.current(), L([]), V(null), H(!1), localStorage.removeItem(`dgl-chat:${t.agentKey}`), de();
|
|
233
415
|
};
|
|
234
|
-
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(
|
|
235
417
|
"button",
|
|
236
418
|
{
|
|
237
419
|
type: "button",
|
|
238
|
-
onClick:
|
|
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",
|
|
439
|
+
title: "Your tickets",
|
|
440
|
+
"aria-label": "Your tickets"
|
|
441
|
+
},
|
|
442
|
+
D(),
|
|
443
|
+
ae.length > 0 && /* @__PURE__ */ e.createElement("span", { className: "dgl-icon-badge" }, ae.length)
|
|
444
|
+
), /* @__PURE__ */ e.createElement(
|
|
445
|
+
"button",
|
|
446
|
+
{
|
|
447
|
+
type: "button",
|
|
448
|
+
onClick: Re,
|
|
239
449
|
className: "dgl-icon-btn",
|
|
240
450
|
title: "New chat",
|
|
241
451
|
"aria-label": "New chat"
|
|
242
452
|
},
|
|
243
|
-
|
|
453
|
+
nt()
|
|
244
454
|
), /* @__PURE__ */ e.createElement(
|
|
245
455
|
"button",
|
|
246
456
|
{
|
|
247
457
|
type: "button",
|
|
248
|
-
onClick: () =>
|
|
458
|
+
onClick: () => K((d) => !d),
|
|
249
459
|
className: "dgl-icon-btn dgl-hide-on-mobile",
|
|
250
|
-
title:
|
|
251
|
-
"aria-label":
|
|
460
|
+
title: U ? "Restore size" : "Expand view",
|
|
461
|
+
"aria-label": U ? "Restore size" : "Expand view"
|
|
252
462
|
},
|
|
253
|
-
|
|
463
|
+
U ? st() : it()
|
|
254
464
|
), /* @__PURE__ */ e.createElement(
|
|
255
465
|
"button",
|
|
256
466
|
{
|
|
257
467
|
type: "button",
|
|
258
|
-
onClick: () =>
|
|
468
|
+
onClick: () => R(!1),
|
|
259
469
|
className: "dgl-icon-btn",
|
|
260
470
|
title: "Close",
|
|
261
471
|
"aria-label": "Close"
|
|
262
472
|
},
|
|
263
|
-
|
|
264
|
-
))),
|
|
265
|
-
|
|
266
|
-
{
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
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,
|
|
504
|
+
{
|
|
505
|
+
tickets: ae,
|
|
506
|
+
onClose: () => oe(!1),
|
|
507
|
+
onRefresh: async () => {
|
|
508
|
+
try {
|
|
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) {
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
}
|
|
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,
|
|
521
|
+
{
|
|
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);
|
|
529
|
+
},
|
|
530
|
+
defaultEmail: t.endUserEmail,
|
|
531
|
+
defaultPhone: t.endUserPhone,
|
|
532
|
+
conversationId: O || void 0,
|
|
533
|
+
onTicketCreated: (g, b) => {
|
|
534
|
+
L((m) => m.map((s) => s === g ? {
|
|
535
|
+
...s,
|
|
536
|
+
// Either an existing-issue card OR a fresh offer
|
|
537
|
+
// can land here — clear both, render created.
|
|
538
|
+
ticketOffer: void 0,
|
|
539
|
+
ticketExisting: void 0,
|
|
540
|
+
ticketCreated: {
|
|
541
|
+
id: b.id,
|
|
542
|
+
externalNumber: b.external_ticket_number,
|
|
543
|
+
externalUrl: b.external_url
|
|
544
|
+
}
|
|
545
|
+
} : s)), ne((m) => [b, ...m.filter((s) => s.id !== b.id)]);
|
|
274
546
|
}
|
|
275
547
|
}
|
|
276
|
-
))), /* @__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(
|
|
277
549
|
"button",
|
|
278
550
|
{
|
|
279
551
|
type: "button",
|
|
280
|
-
onClick:
|
|
552
|
+
onClick: de,
|
|
281
553
|
className: "dgl-staged-remove",
|
|
282
554
|
"aria-label": "Remove image"
|
|
283
555
|
},
|
|
284
|
-
|
|
285
|
-
)), /* @__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(
|
|
286
558
|
"button",
|
|
287
559
|
{
|
|
288
560
|
type: "button",
|
|
289
561
|
className: "dgl-icon-btn",
|
|
290
562
|
onClick: () => {
|
|
291
|
-
var
|
|
292
|
-
return (
|
|
563
|
+
var d;
|
|
564
|
+
return (d = ce.current) == null ? void 0 : d.click();
|
|
293
565
|
},
|
|
294
|
-
disabled:
|
|
566
|
+
disabled: P || X,
|
|
295
567
|
title: "Attach image",
|
|
296
568
|
"aria-label": "Attach image"
|
|
297
569
|
},
|
|
298
|
-
|
|
570
|
+
rt()
|
|
299
571
|
), /* @__PURE__ */ e.createElement(
|
|
300
572
|
"input",
|
|
301
573
|
{
|
|
302
|
-
ref:
|
|
574
|
+
ref: ce,
|
|
303
575
|
type: "file",
|
|
304
576
|
accept: "image/png,image/jpeg,image/webp,image/gif",
|
|
305
577
|
style: { display: "none" },
|
|
306
|
-
onChange: (
|
|
307
|
-
var
|
|
308
|
-
const
|
|
309
|
-
|
|
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 = "");
|
|
310
582
|
}
|
|
311
583
|
}
|
|
312
584
|
)), /* @__PURE__ */ e.createElement(
|
|
313
585
|
"input",
|
|
314
586
|
{
|
|
315
587
|
className: "dgl-input",
|
|
316
|
-
value:
|
|
317
|
-
onChange: (
|
|
318
|
-
placeholder:
|
|
319
|
-
disabled:
|
|
320
|
-
onPaste: (
|
|
321
|
-
var
|
|
322
|
-
if (!
|
|
323
|
-
const
|
|
324
|
-
(
|
|
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/")
|
|
325
597
|
);
|
|
326
|
-
if (
|
|
327
|
-
const
|
|
328
|
-
|
|
598
|
+
if (h) {
|
|
599
|
+
const b = h.getAsFile();
|
|
600
|
+
b && (d.preventDefault(), me(b));
|
|
329
601
|
}
|
|
330
602
|
}
|
|
331
603
|
}
|
|
@@ -334,262 +606,597 @@ function z(t) {
|
|
|
334
606
|
{
|
|
335
607
|
type: "submit",
|
|
336
608
|
className: "dgl-send-btn",
|
|
337
|
-
disabled: !
|
|
609
|
+
disabled: !G.trim() || P || X,
|
|
338
610
|
"aria-label": "Send"
|
|
339
611
|
},
|
|
340
|
-
|
|
341
|
-
)), !
|
|
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(
|
|
342
614
|
"button",
|
|
343
615
|
{
|
|
344
616
|
type: "button",
|
|
345
617
|
className: "dgl-launcher",
|
|
346
|
-
onClick: () =>
|
|
347
|
-
"aria-label":
|
|
618
|
+
onClick: () => R((d) => !d),
|
|
619
|
+
"aria-label": _ ? "Close chat" : "Open chat"
|
|
348
620
|
},
|
|
349
|
-
|
|
621
|
+
_ ? at() : y.launcherAvatarUrl ? /* @__PURE__ */ e.createElement("img", { src: y.launcherAvatarUrl, alt: "", className: "dgl-launcher-avatar" }) : tt()
|
|
350
622
|
));
|
|
351
623
|
}
|
|
352
|
-
function
|
|
624
|
+
function Me({
|
|
353
625
|
message: t,
|
|
354
|
-
client:
|
|
355
|
-
isLast:
|
|
356
|
-
agentAvatarUrl:
|
|
357
|
-
onPickFollowup:
|
|
626
|
+
client: n,
|
|
627
|
+
isLast: r,
|
|
628
|
+
agentAvatarUrl: l,
|
|
629
|
+
onPickFollowup: a,
|
|
630
|
+
defaultEmail: o,
|
|
631
|
+
defaultPhone: c,
|
|
632
|
+
conversationId: i,
|
|
633
|
+
onTicketCreated: u
|
|
358
634
|
}) {
|
|
359
|
-
var
|
|
635
|
+
var N;
|
|
360
636
|
if (t.role === "user")
|
|
361
|
-
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(
|
|
362
|
-
const
|
|
363
|
-
return /* @__PURE__ */ e.createElement("div", { className: "dgl-msg dgl-msg-assistant" },
|
|
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 ? (
|
|
640
|
+
/* Status query — suppress the markdown body and render
|
|
641
|
+
the rich Jira-style card on its own. */
|
|
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,
|
|
645
|
+
{
|
|
646
|
+
existing: t.ticketExisting,
|
|
647
|
+
client: n,
|
|
648
|
+
conversationId: i,
|
|
649
|
+
defaultEmail: o,
|
|
650
|
+
defaultPhone: c,
|
|
651
|
+
onNewTicketRaised: (y) => u == null ? void 0 : u(t, y)
|
|
652
|
+
}
|
|
653
|
+
) : !t.streaming && !t.ticketStatus && t.ticketOffer ? /* @__PURE__ */ e.createElement(
|
|
654
|
+
Ye,
|
|
655
|
+
{
|
|
656
|
+
client: n,
|
|
657
|
+
offer: t.ticketOffer,
|
|
658
|
+
defaultEmail: o,
|
|
659
|
+
defaultPhone: c,
|
|
660
|
+
onCreated: (y) => u == null ? void 0 : u(t, y)
|
|
661
|
+
}
|
|
662
|
+
) : null, x.length > 0 && /* @__PURE__ */ e.createElement(Pe, { suggestions: x, onPick: a })));
|
|
364
663
|
}
|
|
365
|
-
function
|
|
664
|
+
function Pe({
|
|
366
665
|
suggestions: t,
|
|
367
|
-
onPick:
|
|
666
|
+
onPick: n
|
|
368
667
|
}) {
|
|
369
|
-
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(
|
|
370
669
|
"button",
|
|
371
670
|
{
|
|
372
|
-
key:
|
|
671
|
+
key: l,
|
|
373
672
|
type: "button",
|
|
374
673
|
className: "dgl-followup-chip",
|
|
375
|
-
onClick: () =>
|
|
674
|
+
onClick: () => n(r)
|
|
376
675
|
},
|
|
377
|
-
|
|
676
|
+
r
|
|
378
677
|
))));
|
|
379
678
|
}
|
|
380
|
-
function
|
|
679
|
+
function je({
|
|
381
680
|
client: t,
|
|
382
|
-
imagePath:
|
|
383
|
-
previewUrl:
|
|
681
|
+
imagePath: n,
|
|
682
|
+
previewUrl: r
|
|
384
683
|
}) {
|
|
385
|
-
const [
|
|
386
|
-
return
|
|
387
|
-
if (
|
|
388
|
-
let
|
|
389
|
-
return t.fetchImage(
|
|
390
|
-
|
|
391
|
-
}).catch(() =>
|
|
392
|
-
|
|
684
|
+
const [l, a] = p(r || null), [o, c] = p(!1);
|
|
685
|
+
return T(() => {
|
|
686
|
+
if (r || !n) return;
|
|
687
|
+
let i = null;
|
|
688
|
+
return t.fetchImage(n).then((u) => {
|
|
689
|
+
i = u, a(u);
|
|
690
|
+
}).catch(() => a(null)), () => {
|
|
691
|
+
i && URL.revokeObjectURL(i);
|
|
393
692
|
};
|
|
394
|
-
}, [t,
|
|
693
|
+
}, [t, n, r]), T(() => {
|
|
395
694
|
if (!o) return;
|
|
396
|
-
const
|
|
397
|
-
|
|
695
|
+
const i = (E) => {
|
|
696
|
+
E.key === "Escape" && c(!1);
|
|
398
697
|
};
|
|
399
|
-
window.addEventListener("keydown",
|
|
400
|
-
const
|
|
698
|
+
window.addEventListener("keydown", i);
|
|
699
|
+
const u = document.body.style.overflow;
|
|
401
700
|
return document.body.style.overflow = "hidden", () => {
|
|
402
|
-
window.removeEventListener("keydown",
|
|
701
|
+
window.removeEventListener("keydown", i), document.body.style.overflow = u;
|
|
403
702
|
};
|
|
404
|
-
}, [o]),
|
|
703
|
+
}, [o]), l ? /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement(
|
|
405
704
|
"button",
|
|
406
705
|
{
|
|
407
706
|
type: "button",
|
|
408
|
-
onClick: () =>
|
|
707
|
+
onClick: () => c(!0),
|
|
409
708
|
className: "dgl-user-image-btn",
|
|
410
709
|
"aria-label": "View image"
|
|
411
710
|
},
|
|
412
|
-
/* @__PURE__ */ e.createElement("img", { src:
|
|
711
|
+
/* @__PURE__ */ e.createElement("img", { src: l, className: "dgl-user-image", alt: "attached" })
|
|
413
712
|
), o && /* @__PURE__ */ e.createElement(
|
|
414
713
|
"div",
|
|
415
714
|
{
|
|
416
715
|
className: "dgl-lightbox",
|
|
417
716
|
role: "dialog",
|
|
418
717
|
"aria-modal": "true",
|
|
419
|
-
onClick: () =>
|
|
718
|
+
onClick: () => c(!1)
|
|
420
719
|
},
|
|
421
720
|
/* @__PURE__ */ e.createElement(
|
|
422
721
|
"button",
|
|
423
722
|
{
|
|
424
723
|
type: "button",
|
|
425
724
|
className: "dgl-lightbox-close",
|
|
426
|
-
onClick: (
|
|
427
|
-
|
|
725
|
+
onClick: (i) => {
|
|
726
|
+
i.stopPropagation(), c(!1);
|
|
428
727
|
},
|
|
429
728
|
"aria-label": "Close image"
|
|
430
729
|
},
|
|
431
|
-
|
|
730
|
+
W()
|
|
432
731
|
),
|
|
433
732
|
/* @__PURE__ */ e.createElement(
|
|
434
733
|
"img",
|
|
435
734
|
{
|
|
436
|
-
src:
|
|
735
|
+
src: l,
|
|
437
736
|
className: "dgl-lightbox-img",
|
|
438
737
|
alt: "attached",
|
|
439
|
-
onClick: (
|
|
738
|
+
onClick: (i) => i.stopPropagation()
|
|
440
739
|
}
|
|
441
740
|
)
|
|
442
741
|
)) : null;
|
|
443
742
|
}
|
|
444
|
-
function
|
|
445
|
-
const
|
|
446
|
-
for (const
|
|
447
|
-
const
|
|
448
|
-
(!
|
|
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);
|
|
449
748
|
}
|
|
450
|
-
const
|
|
451
|
-
if (!
|
|
452
|
-
const [o,
|
|
453
|
-
return /* @__PURE__ */ e.createElement("div", { className: "dgl-citations" },
|
|
454
|
-
|
|
455
|
-
{
|
|
456
|
-
key:
|
|
457
|
-
citation:
|
|
458
|
-
client:
|
|
459
|
-
isOpen: o ===
|
|
460
|
-
onToggle: () =>
|
|
749
|
+
const l = Object.values(r).sort((i, u) => u.score - i.score).slice(0, 3), a = Object.keys(r).length - l.length;
|
|
750
|
+
if (!l.length) return null;
|
|
751
|
+
const [o, c] = p(null);
|
|
752
|
+
return /* @__PURE__ */ e.createElement("div", { className: "dgl-citations" }, l.map((i) => /* @__PURE__ */ e.createElement(
|
|
753
|
+
Ke,
|
|
754
|
+
{
|
|
755
|
+
key: i.chunk_id,
|
|
756
|
+
citation: i,
|
|
757
|
+
client: n,
|
|
758
|
+
isOpen: o === i.chunk_id,
|
|
759
|
+
onToggle: () => c(o === i.chunk_id ? null : i.chunk_id)
|
|
461
760
|
}
|
|
462
|
-
)),
|
|
761
|
+
)), a > 0 && /* @__PURE__ */ e.createElement("span", { className: "dgl-citation-more" }, "+", a, " more"));
|
|
463
762
|
}
|
|
464
|
-
function
|
|
763
|
+
function Ke({
|
|
465
764
|
citation: t,
|
|
466
|
-
client:
|
|
467
|
-
isOpen:
|
|
468
|
-
onToggle:
|
|
765
|
+
client: n,
|
|
766
|
+
isOpen: r,
|
|
767
|
+
onToggle: l
|
|
469
768
|
}) {
|
|
470
|
-
const
|
|
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;
|
|
471
770
|
return /* @__PURE__ */ e.createElement("span", { className: "dgl-citation-wrap" }, /* @__PURE__ */ e.createElement(
|
|
472
771
|
"button",
|
|
473
772
|
{
|
|
474
773
|
type: "button",
|
|
475
|
-
className: `dgl-citation ${
|
|
476
|
-
onClick:
|
|
477
|
-
title:
|
|
774
|
+
className: `dgl-citation ${r ? "dgl-citation-open" : ""}`,
|
|
775
|
+
onClick: l,
|
|
776
|
+
title: a.snippet || ""
|
|
478
777
|
},
|
|
479
778
|
o && /* @__PURE__ */ e.createElement("span", { className: "dgl-citation-icon" }, "▶"),
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
),
|
|
484
|
-
|
|
485
|
-
{
|
|
486
|
-
client:
|
|
487
|
-
sourceId:
|
|
488
|
-
framePath:
|
|
779
|
+
a.source_name,
|
|
780
|
+
i && /* @__PURE__ */ e.createElement("span", { className: "dgl-citation-stamp" }, " · ", i),
|
|
781
|
+
a.page && /* @__PURE__ */ e.createElement("span", { className: "dgl-citation-stamp" }, " · p", a.page)
|
|
782
|
+
), r && /* @__PURE__ */ e.createElement("div", { className: "dgl-citation-popover" }, a.frame_path && /* @__PURE__ */ e.createElement(
|
|
783
|
+
We,
|
|
784
|
+
{
|
|
785
|
+
client: n,
|
|
786
|
+
sourceId: a.source_id,
|
|
787
|
+
framePath: a.frame_path
|
|
489
788
|
}
|
|
490
|
-
),
|
|
789
|
+
), c && /* @__PURE__ */ e.createElement("div", { className: "dgl-citation-breadcrumb" }, c), a.snippet && /* @__PURE__ */ e.createElement("div", { className: "dgl-citation-snippet" }, a.snippet)));
|
|
491
790
|
}
|
|
492
|
-
function
|
|
791
|
+
function We({
|
|
493
792
|
client: t,
|
|
494
|
-
sourceId:
|
|
495
|
-
framePath:
|
|
793
|
+
sourceId: n,
|
|
794
|
+
framePath: r
|
|
496
795
|
}) {
|
|
497
|
-
const [
|
|
498
|
-
return
|
|
796
|
+
const [l, a] = p(null);
|
|
797
|
+
return T(() => {
|
|
499
798
|
let o = null;
|
|
500
|
-
return t.fetchSourceFrame(
|
|
501
|
-
o =
|
|
502
|
-
}).catch(() =>
|
|
799
|
+
return t.fetchSourceFrame(n, r).then((c) => {
|
|
800
|
+
o = c, a(c);
|
|
801
|
+
}).catch(() => a(null)), () => {
|
|
503
802
|
o && URL.revokeObjectURL(o);
|
|
504
803
|
};
|
|
505
|
-
}, [t,
|
|
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" });
|
|
506
805
|
}
|
|
507
|
-
function
|
|
508
|
-
const
|
|
509
|
-
return
|
|
510
|
-
`).map((
|
|
806
|
+
function Ge(t) {
|
|
807
|
+
const n = t.match(/<followups>([\s\S]*?)<\/followups>/i);
|
|
808
|
+
return n ? n[1].split(`
|
|
809
|
+
`).map((r) => r.trim()).map((r) => r.replace(/^[-*•\d.)\s"']+|["']$/g, "").trim()).filter((r) => r.length >= 4 && r.length <= 120).slice(0, 3) : [];
|
|
511
810
|
}
|
|
512
|
-
function
|
|
513
|
-
|
|
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();
|
|
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, `
|
|
514
814
|
|
|
515
815
|
`).trim();
|
|
516
816
|
}
|
|
517
|
-
function
|
|
518
|
-
return t.split(/\n{2,}/).map((
|
|
519
|
-
const
|
|
817
|
+
function Ve(t) {
|
|
818
|
+
return t.split(/\n{2,}/).map((r, l) => {
|
|
819
|
+
const a = r.split(`
|
|
520
820
|
`);
|
|
521
|
-
if (
|
|
522
|
-
const
|
|
523
|
-
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))));
|
|
524
824
|
}
|
|
525
|
-
return /* @__PURE__ */ e.createElement("p", { key:
|
|
526
|
-
`).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))));
|
|
527
827
|
});
|
|
528
828
|
}
|
|
529
|
-
function
|
|
530
|
-
const
|
|
531
|
-
return t.split(
|
|
532
|
-
if (!
|
|
533
|
-
if (
|
|
534
|
-
return /* @__PURE__ */ e.createElement("code", { key:
|
|
535
|
-
if (
|
|
536
|
-
return /* @__PURE__ */ e.createElement("strong", { key:
|
|
537
|
-
if (
|
|
538
|
-
return /* @__PURE__ */ e.createElement("em", { key:
|
|
539
|
-
const o =
|
|
540
|
-
return o ? /* @__PURE__ */ e.createElement("a", { key:
|
|
829
|
+
function _e(t) {
|
|
830
|
+
const n = /(`[^`]+`|\*\*[^*\n]+\*\*|\*[^*\n]+\*|\[[^\]]+\]\([^)]+\))/g;
|
|
831
|
+
return t.split(n).map((l, a) => {
|
|
832
|
+
if (!l) return null;
|
|
833
|
+
if (l.startsWith("`") && l.endsWith("`"))
|
|
834
|
+
return /* @__PURE__ */ e.createElement("code", { key: a, className: "dgl-md-code" }, l.slice(1, -1));
|
|
835
|
+
if (l.startsWith("**") && l.endsWith("**"))
|
|
836
|
+
return /* @__PURE__ */ e.createElement("strong", { key: a }, l.slice(2, -2));
|
|
837
|
+
if (l.startsWith("*") && l.endsWith("*") && l.length > 2)
|
|
838
|
+
return /* @__PURE__ */ e.createElement("em", { key: a }, l.slice(1, -1));
|
|
839
|
+
const o = l.match(/^\[([^\]]+)\]\(([^)]+)\)$/);
|
|
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);
|
|
541
841
|
});
|
|
542
842
|
}
|
|
543
|
-
function
|
|
843
|
+
function Xe() {
|
|
544
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" }));
|
|
545
845
|
}
|
|
546
|
-
|
|
846
|
+
const M = {
|
|
847
|
+
open: { label: "Open", stripe: "linear-gradient(90deg,#3b82f6,#6366f1)", iconBg: "#3b82f6", pillBg: "#dbeafe", pillFg: "#1e40af" },
|
|
848
|
+
in_progress: { label: "In progress", stripe: "linear-gradient(90deg,#8b5cf6,#d946ef)", iconBg: "#8b5cf6", pillBg: "#ede9fe", pillFg: "#5b21b6" },
|
|
849
|
+
on_hold: { label: "On hold", stripe: "linear-gradient(90deg,#f59e0b,#f97316)", iconBg: "#f59e0b", pillBg: "#fef3c7", pillFg: "#92400e" },
|
|
850
|
+
resolved: { label: "Resolved", stripe: "linear-gradient(90deg,#10b981,#14b8a6)", iconBg: "#10b981", pillBg: "#d1fae5", pillFg: "#065f46" },
|
|
851
|
+
closed: { label: "Closed", stripe: "linear-gradient(90deg,#94a3b8,#64748b)", iconBg: "#64748b", pillBg: "#f1f5f9", pillFg: "#334155" },
|
|
852
|
+
cancelled: { label: "Cancelled", stripe: "linear-gradient(90deg,#ef4444,#f43f5e)", iconBg: "#ef4444", pillBg: "#fee2e2", pillFg: "#991b1b" }
|
|
853
|
+
}, Ce = {
|
|
854
|
+
low: { bg: "#f1f5f9", fg: "#475569" },
|
|
855
|
+
medium: { bg: "#dbeafe", fg: "#1e40af" },
|
|
856
|
+
high: { bg: "#fef3c7", fg: "#92400e" },
|
|
857
|
+
urgent: { bg: "#fee2e2", fg: "#991b1b" }
|
|
858
|
+
};
|
|
859
|
+
function ie(t) {
|
|
860
|
+
if (!t) return "—";
|
|
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);
|
|
864
|
+
if (l < 1) return "just now";
|
|
865
|
+
if (l < 60) return `${l}m ago`;
|
|
866
|
+
const a = Math.floor(l / 60);
|
|
867
|
+
if (a < 24) return `${a}h ago`;
|
|
868
|
+
const o = Math.floor(a / 24);
|
|
869
|
+
return o < 7 ? `${o}d ago` : n.toLocaleDateString();
|
|
870
|
+
}
|
|
871
|
+
function Ye({
|
|
872
|
+
client: t,
|
|
873
|
+
offer: n,
|
|
874
|
+
defaultEmail: r,
|
|
875
|
+
defaultPhone: l,
|
|
876
|
+
onCreated: a
|
|
877
|
+
}) {
|
|
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 () => {
|
|
879
|
+
if (!o.trim()) {
|
|
880
|
+
U("Email is required so the team can follow up.");
|
|
881
|
+
return;
|
|
882
|
+
}
|
|
883
|
+
_(!0), U(null);
|
|
884
|
+
try {
|
|
885
|
+
const v = await t.raiseTicket(n.conversationId, {
|
|
886
|
+
consent: !0,
|
|
887
|
+
end_user_email: o.trim(),
|
|
888
|
+
end_user_phone: i.trim() || void 0,
|
|
889
|
+
priority: N
|
|
890
|
+
});
|
|
891
|
+
a(v);
|
|
892
|
+
} catch (v) {
|
|
893
|
+
U((v == null ? void 0 : v.message) || "Could not create ticket. Try again.");
|
|
894
|
+
} finally {
|
|
895
|
+
_(!1);
|
|
896
|
+
}
|
|
897
|
+
};
|
|
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(
|
|
899
|
+
"input",
|
|
900
|
+
{
|
|
901
|
+
type: "email",
|
|
902
|
+
className: "dgl-ticket-input",
|
|
903
|
+
value: o,
|
|
904
|
+
onChange: (v) => c(v.target.value),
|
|
905
|
+
onBlur: () => o && x(!1),
|
|
906
|
+
placeholder: "you@example.com",
|
|
907
|
+
autoFocus: !0
|
|
908
|
+
}
|
|
909
|
+
) : /* @__PURE__ */ e.createElement(
|
|
910
|
+
"button",
|
|
911
|
+
{
|
|
912
|
+
type: "button",
|
|
913
|
+
className: "dgl-ticket-email-link",
|
|
914
|
+
onClick: () => x(!0),
|
|
915
|
+
title: "Click to change"
|
|
916
|
+
},
|
|
917
|
+
o || "Set email",
|
|
918
|
+
" ",
|
|
919
|
+
/* @__PURE__ */ e.createElement("span", { className: "dgl-ticket-email-change" }, "(change)")
|
|
920
|
+
)), /* @__PURE__ */ e.createElement("div", null, /* @__PURE__ */ e.createElement("div", { className: "dgl-ticket-field-label" }, "Priority"), /* @__PURE__ */ e.createElement(
|
|
921
|
+
"select",
|
|
922
|
+
{
|
|
923
|
+
className: "dgl-ticket-input",
|
|
924
|
+
value: N,
|
|
925
|
+
onChange: (v) => y(v.target.value)
|
|
926
|
+
},
|
|
927
|
+
/* @__PURE__ */ e.createElement("option", { value: "low" }, "Low"),
|
|
928
|
+
/* @__PURE__ */ e.createElement("option", { value: "medium" }, "Medium"),
|
|
929
|
+
/* @__PURE__ */ e.createElement("option", { value: "high" }, "High"),
|
|
930
|
+
/* @__PURE__ */ e.createElement("option", { value: "urgent" }, "Urgent")
|
|
931
|
+
))), R && /* @__PURE__ */ e.createElement("div", { className: "dgl-ticket-error" }, R), /* @__PURE__ */ e.createElement("div", { className: "dgl-ticket-card-footer" }, /* @__PURE__ */ e.createElement("span", { className: "dgl-ticket-hint" }, "The bot writes the title + description from this chat."), /* @__PURE__ */ e.createElement(
|
|
932
|
+
"button",
|
|
933
|
+
{
|
|
934
|
+
type: "button",
|
|
935
|
+
className: "dgl-ticket-submit",
|
|
936
|
+
onClick: K,
|
|
937
|
+
disabled: $ || !o.trim()
|
|
938
|
+
},
|
|
939
|
+
$ ? q() : D(),
|
|
940
|
+
/* @__PURE__ */ e.createElement("span", null, $ ? "Submitting…" : "Submit ticket")
|
|
941
|
+
))));
|
|
942
|
+
}
|
|
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.")));
|
|
946
|
+
}
|
|
947
|
+
function qe({
|
|
948
|
+
existing: t,
|
|
949
|
+
client: n,
|
|
950
|
+
conversationId: r,
|
|
951
|
+
defaultEmail: l,
|
|
952
|
+
defaultPhone: a,
|
|
953
|
+
onNewTicketRaised: o
|
|
954
|
+
}) {
|
|
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.");
|
|
958
|
+
return;
|
|
959
|
+
}
|
|
960
|
+
if (!r) {
|
|
961
|
+
U("Conversation not available yet.");
|
|
962
|
+
return;
|
|
963
|
+
}
|
|
964
|
+
_(!0), U(null);
|
|
965
|
+
try {
|
|
966
|
+
const v = await n.raiseTicket(r, {
|
|
967
|
+
consent: !0,
|
|
968
|
+
end_user_email: E.trim(),
|
|
969
|
+
end_user_phone: a || void 0,
|
|
970
|
+
priority: N,
|
|
971
|
+
force_new: !0
|
|
972
|
+
});
|
|
973
|
+
o == null || o(v);
|
|
974
|
+
} catch (v) {
|
|
975
|
+
U((v == null ? void 0 : v.message) || "Could not create ticket. Try again.");
|
|
976
|
+
} finally {
|
|
977
|
+
_(!1);
|
|
978
|
+
}
|
|
979
|
+
};
|
|
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(
|
|
981
|
+
"input",
|
|
982
|
+
{
|
|
983
|
+
type: "email",
|
|
984
|
+
className: "dgl-ticket-input",
|
|
985
|
+
value: E,
|
|
986
|
+
onChange: (v) => x(v.target.value),
|
|
987
|
+
placeholder: "you@example.com"
|
|
988
|
+
}
|
|
989
|
+
)), /* @__PURE__ */ e.createElement("div", null, /* @__PURE__ */ e.createElement("div", { className: "dgl-ticket-field-label" }, "Priority"), /* @__PURE__ */ e.createElement(
|
|
990
|
+
"select",
|
|
991
|
+
{
|
|
992
|
+
className: "dgl-ticket-input",
|
|
993
|
+
value: N,
|
|
994
|
+
onChange: (v) => y(v.target.value)
|
|
995
|
+
},
|
|
996
|
+
/* @__PURE__ */ e.createElement("option", { value: "low" }, "Low"),
|
|
997
|
+
/* @__PURE__ */ e.createElement("option", { value: "medium" }, "Medium"),
|
|
998
|
+
/* @__PURE__ */ e.createElement("option", { value: "high" }, "High"),
|
|
999
|
+
/* @__PURE__ */ e.createElement("option", { value: "urgent" }, "Urgent")
|
|
1000
|
+
))), R && /* @__PURE__ */ e.createElement("div", { className: "dgl-ticket-error" }, R), /* @__PURE__ */ e.createElement("div", { className: "dgl-ticket-card-footer" }, /* @__PURE__ */ e.createElement(
|
|
1001
|
+
"button",
|
|
1002
|
+
{
|
|
1003
|
+
type: "button",
|
|
1004
|
+
className: "dgl-ticket-diff-cancel",
|
|
1005
|
+
onClick: () => u(!1)
|
|
1006
|
+
},
|
|
1007
|
+
"Cancel"
|
|
1008
|
+
), /* @__PURE__ */ e.createElement(
|
|
1009
|
+
"button",
|
|
1010
|
+
{
|
|
1011
|
+
type: "button",
|
|
1012
|
+
className: "dgl-ticket-submit",
|
|
1013
|
+
onClick: K,
|
|
1014
|
+
disabled: $ || !E.trim()
|
|
1015
|
+
},
|
|
1016
|
+
$ ? q() : D(),
|
|
1017
|
+
/* @__PURE__ */ e.createElement("span", null, $ ? "Submitting…" : "Submit new ticket")
|
|
1018
|
+
))) : /* @__PURE__ */ e.createElement(
|
|
1019
|
+
"button",
|
|
1020
|
+
{
|
|
1021
|
+
type: "button",
|
|
1022
|
+
className: "dgl-ticket-diff-link",
|
|
1023
|
+
onClick: () => u(!0)
|
|
1024
|
+
},
|
|
1025
|
+
"Different issue? Raise new ticket →"
|
|
1026
|
+
)));
|
|
1027
|
+
}
|
|
1028
|
+
function Je({
|
|
1029
|
+
ticket: t
|
|
1030
|
+
}) {
|
|
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")))));
|
|
1033
|
+
}
|
|
1034
|
+
function Qe({
|
|
1035
|
+
tickets: t,
|
|
1036
|
+
onClose: n,
|
|
1037
|
+
onRefresh: r
|
|
1038
|
+
}) {
|
|
1039
|
+
const [l, a] = p(!1);
|
|
1040
|
+
T(() => {
|
|
1041
|
+
const i = (u) => {
|
|
1042
|
+
u.key === "Escape" && n();
|
|
1043
|
+
};
|
|
1044
|
+
return window.addEventListener("keydown", i), () => window.removeEventListener("keydown", i);
|
|
1045
|
+
}, [n]);
|
|
1046
|
+
const o = async () => {
|
|
1047
|
+
a(!0);
|
|
1048
|
+
try {
|
|
1049
|
+
await r();
|
|
1050
|
+
} finally {
|
|
1051
|
+
a(!1);
|
|
1052
|
+
}
|
|
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;
|
|
1056
|
+
});
|
|
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(
|
|
1058
|
+
"button",
|
|
1059
|
+
{
|
|
1060
|
+
type: "button",
|
|
1061
|
+
onClick: o,
|
|
1062
|
+
className: "dgl-icon-btn",
|
|
1063
|
+
title: "Refresh",
|
|
1064
|
+
"aria-label": "Refresh tickets",
|
|
1065
|
+
disabled: l,
|
|
1066
|
+
style: { color: "#475569" }
|
|
1067
|
+
},
|
|
1068
|
+
l ? q() : ct()
|
|
1069
|
+
), /* @__PURE__ */ e.createElement(
|
|
1070
|
+
"button",
|
|
1071
|
+
{
|
|
1072
|
+
type: "button",
|
|
1073
|
+
onClick: n,
|
|
1074
|
+
className: "dgl-icon-btn",
|
|
1075
|
+
title: "Close",
|
|
1076
|
+
"aria-label": "Close",
|
|
1077
|
+
style: { color: "#475569" }
|
|
1078
|
+
},
|
|
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(
|
|
1083
|
+
"span",
|
|
1084
|
+
{
|
|
1085
|
+
className: "dgl-ticket-pill",
|
|
1086
|
+
style: { background: u.pillBg, color: u.pillFg }
|
|
1087
|
+
},
|
|
1088
|
+
/* @__PURE__ */ e.createElement("span", { className: "dgl-ticket-pill-dot", style: { background: u.iconBg } }),
|
|
1089
|
+
u.label
|
|
1090
|
+
), i.external_url && /* @__PURE__ */ e.createElement(
|
|
1091
|
+
"a",
|
|
1092
|
+
{
|
|
1093
|
+
href: i.external_url,
|
|
1094
|
+
target: "_blank",
|
|
1095
|
+
rel: "noopener noreferrer",
|
|
1096
|
+
className: "dgl-ticket-open-btn",
|
|
1097
|
+
style: { marginLeft: "auto" }
|
|
1098
|
+
},
|
|
1099
|
+
"Open"
|
|
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)));
|
|
1101
|
+
}))));
|
|
1102
|
+
}
|
|
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() {
|
|
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" }));
|
|
1143
|
+
}
|
|
1144
|
+
function et() {
|
|
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" }));
|
|
1146
|
+
}
|
|
1147
|
+
function tt() {
|
|
547
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" }));
|
|
548
1149
|
}
|
|
549
|
-
function
|
|
1150
|
+
function at() {
|
|
550
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" }));
|
|
551
1152
|
}
|
|
552
|
-
function
|
|
1153
|
+
function W() {
|
|
553
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" }));
|
|
554
1155
|
}
|
|
555
|
-
function
|
|
1156
|
+
function nt() {
|
|
556
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" }));
|
|
557
1158
|
}
|
|
558
|
-
function
|
|
1159
|
+
function lt() {
|
|
559
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" }));
|
|
560
1161
|
}
|
|
561
|
-
function
|
|
1162
|
+
function rt() {
|
|
562
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" }));
|
|
563
1164
|
}
|
|
564
|
-
function
|
|
1165
|
+
function q() {
|
|
565
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" }));
|
|
566
1167
|
}
|
|
567
|
-
function
|
|
1168
|
+
function it() {
|
|
568
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" }));
|
|
569
1170
|
}
|
|
570
|
-
function
|
|
1171
|
+
function st() {
|
|
571
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" }));
|
|
572
1173
|
}
|
|
573
|
-
function
|
|
1174
|
+
function ct() {
|
|
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" }));
|
|
1176
|
+
}
|
|
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() {
|
|
574
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" }));
|
|
575
1182
|
}
|
|
576
|
-
let
|
|
577
|
-
function
|
|
1183
|
+
let B = null, A = null;
|
|
1184
|
+
function dt(t) {
|
|
578
1185
|
if (typeof document == "undefined")
|
|
579
1186
|
throw new Error("DocGenLab.init() requires a browser environment.");
|
|
580
|
-
if (
|
|
581
|
-
|
|
1187
|
+
if (B) {
|
|
1188
|
+
B.render(ve(re, t));
|
|
582
1189
|
return;
|
|
583
1190
|
}
|
|
584
|
-
|
|
1191
|
+
A = document.createElement("div"), A.id = "docgenlab-chat-widget-root", document.body.appendChild(A), B = Oe(A), B.render(ve(re, t));
|
|
585
1192
|
}
|
|
586
|
-
function
|
|
587
|
-
|
|
1193
|
+
function mt() {
|
|
1194
|
+
B && (B.unmount(), B = null), A && (A.remove(), A = null);
|
|
588
1195
|
}
|
|
589
|
-
typeof window != "undefined" && (window.DocGenLab = { init:
|
|
1196
|
+
typeof window != "undefined" && (window.DocGenLab = { init: dt, destroy: mt, DocGenLabChat: re });
|
|
590
1197
|
export {
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
1198
|
+
re as DocGenLabChat,
|
|
1199
|
+
mt as destroy,
|
|
1200
|
+
dt as init
|
|
594
1201
|
};
|
|
595
1202
|
//# sourceMappingURL=index.js.map
|