@flowengage/react-chatbot 8.0.84 → 8.0.86
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.
|
@@ -42,38 +42,38 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
|
|
|
42
42
|
if (A) try {
|
|
43
43
|
window.localStorage.removeItem(k.chatId);
|
|
44
44
|
} catch {}
|
|
45
|
-
},
|
|
45
|
+
}, j = () => A ? typeof crypto < "u" && crypto.randomUUID ? crypto.randomUUID() : `${Date.now()}-${Math.random().toString(16).slice(2)}` : "server-chat-id", M = (e) => e ? `flowengage.entrySeen.${e}` : null, se = (e) => {
|
|
46
46
|
if (!A || !e) return !1;
|
|
47
47
|
try {
|
|
48
|
-
let t =
|
|
48
|
+
let t = M(e);
|
|
49
49
|
return t ? window.localStorage.getItem(t) === "1" : !1;
|
|
50
50
|
} catch {
|
|
51
51
|
return !1;
|
|
52
52
|
}
|
|
53
|
-
},
|
|
53
|
+
}, ce = (e) => {
|
|
54
54
|
if (!(!A || !e)) try {
|
|
55
|
-
let t =
|
|
55
|
+
let t = M(e);
|
|
56
56
|
t && window.localStorage.setItem(t, "1");
|
|
57
57
|
} catch {}
|
|
58
|
-
},
|
|
58
|
+
}, le = (e) => e ? `flowengage.persistedChatId.${e}` : null, ue = (e) => {
|
|
59
59
|
if (!A || !e) return null;
|
|
60
60
|
try {
|
|
61
|
-
let t =
|
|
61
|
+
let t = le(e), n = t ? window.localStorage.getItem(t) : null;
|
|
62
62
|
return n && String(n).trim() ? String(n).trim() : null;
|
|
63
63
|
} catch {
|
|
64
64
|
return null;
|
|
65
65
|
}
|
|
66
|
-
},
|
|
66
|
+
}, de = (e) => {
|
|
67
67
|
if (!(!A || !e)) try {
|
|
68
|
-
let t =
|
|
68
|
+
let t = le(e);
|
|
69
69
|
t && window.localStorage.removeItem(t);
|
|
70
70
|
} catch {}
|
|
71
|
-
},
|
|
71
|
+
}, fe = (e, t) => {
|
|
72
72
|
if (!(!A || !e || !t)) try {
|
|
73
|
-
let n =
|
|
73
|
+
let n = le(e);
|
|
74
74
|
n && window.localStorage.setItem(n, String(t).trim());
|
|
75
75
|
} catch {}
|
|
76
|
-
},
|
|
76
|
+
}, pe = () => A ? {
|
|
77
77
|
isOpen: !1,
|
|
78
78
|
activeScreen: window.sessionStorage.getItem(k.activeScreen) || "ai",
|
|
79
79
|
isHumanHandled: window.sessionStorage.getItem(k.isHumanHandled) === "true",
|
|
@@ -87,7 +87,7 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
|
|
|
87
87
|
agentName: null,
|
|
88
88
|
agentHeadshot: null,
|
|
89
89
|
visitorEmail: ""
|
|
90
|
-
},
|
|
90
|
+
}, me = (e) => {
|
|
91
91
|
A && Object.entries(e).forEach(([e, t]) => {
|
|
92
92
|
let n = k[e];
|
|
93
93
|
if (n) {
|
|
@@ -98,7 +98,7 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
|
|
|
98
98
|
window.sessionStorage.setItem(n, String(t));
|
|
99
99
|
}
|
|
100
100
|
});
|
|
101
|
-
},
|
|
101
|
+
}, he = (e) => {
|
|
102
102
|
if (!A || !e) return "";
|
|
103
103
|
let t = ie(e), n = window.localStorage.getItem(t);
|
|
104
104
|
if (!n) {
|
|
@@ -106,7 +106,7 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
|
|
|
106
106
|
e && (window.localStorage.setItem(t, e), window.sessionStorage.removeItem(k.visitorEmail), n = e);
|
|
107
107
|
}
|
|
108
108
|
return n || "";
|
|
109
|
-
},
|
|
109
|
+
}, ge = (e, t) => {
|
|
110
110
|
if (!A) return;
|
|
111
111
|
let n = ie(t);
|
|
112
112
|
if (!n) return;
|
|
@@ -116,91 +116,91 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
|
|
|
116
116
|
return;
|
|
117
117
|
}
|
|
118
118
|
window.localStorage.setItem(n, r), window.sessionStorage.removeItem(k.visitorEmail);
|
|
119
|
-
},
|
|
119
|
+
}, _e = (e) => e ? `flowengage.visitorId.${e}` : null, N = () => `v_${Date.now().toString(36)}_${typeof crypto < "u" && crypto.randomUUID ? crypto.randomUUID().replace(/-/g, "").slice(0, 16) : Math.random().toString(36).slice(2, 18)}`, ve = (e) => {
|
|
120
120
|
if (!A || !e) return null;
|
|
121
121
|
try {
|
|
122
|
-
let t =
|
|
122
|
+
let t = _e(e), n = t ? window.localStorage.getItem(t) : null;
|
|
123
123
|
return n && String(n).trim() ? String(n).trim() : null;
|
|
124
124
|
} catch {
|
|
125
125
|
return null;
|
|
126
126
|
}
|
|
127
|
-
},
|
|
127
|
+
}, ye = (e) => {
|
|
128
128
|
if (!A || !e) return null;
|
|
129
129
|
try {
|
|
130
|
-
let t =
|
|
130
|
+
let t = ve(e);
|
|
131
131
|
if (t) return t;
|
|
132
|
-
let n =
|
|
132
|
+
let n = N(), r = _e(e);
|
|
133
133
|
return r && window.localStorage.setItem(r, n), n;
|
|
134
134
|
} catch {
|
|
135
|
-
return
|
|
135
|
+
return N();
|
|
136
136
|
}
|
|
137
|
-
},
|
|
137
|
+
}, be = "flowengage.tabId", xe = () => {
|
|
138
138
|
if (!A) return "default";
|
|
139
139
|
try {
|
|
140
|
-
let e = window.sessionStorage.getItem(
|
|
141
|
-
return e || (e = typeof crypto < "u" && crypto.randomUUID ? crypto.randomUUID().replace(/-/g, "").slice(0, 12) : Math.random().toString(36).slice(2, 14), window.sessionStorage.setItem(
|
|
140
|
+
let e = window.sessionStorage.getItem(be);
|
|
141
|
+
return e || (e = typeof crypto < "u" && crypto.randomUUID ? crypto.randomUUID().replace(/-/g, "").slice(0, 12) : Math.random().toString(36).slice(2, 14), window.sessionStorage.setItem(be, e)), e;
|
|
142
142
|
} catch {
|
|
143
143
|
return "default";
|
|
144
144
|
}
|
|
145
|
-
},
|
|
145
|
+
}, Se = (e) => e ? `flowengage.voice.transcript.${e}.${xe()}` : null, Ce = 600 * 1e3, P = (e, t, n = {}) => {
|
|
146
146
|
if (!A || !e) return;
|
|
147
147
|
let r = typeof t == "string" ? t.trim() : "";
|
|
148
148
|
if (!r) return;
|
|
149
|
-
let i = Number.isFinite(n.ttlMs) ? n.ttlMs :
|
|
149
|
+
let i = Number.isFinite(n.ttlMs) ? n.ttlMs : Ce, a = {
|
|
150
150
|
transcript: r,
|
|
151
151
|
expiresAt: Date.now() + i
|
|
152
152
|
};
|
|
153
153
|
try {
|
|
154
|
-
let t =
|
|
154
|
+
let t = Se(e);
|
|
155
155
|
t && window.localStorage.setItem(t, JSON.stringify(a));
|
|
156
156
|
} catch {}
|
|
157
|
-
},
|
|
157
|
+
}, we = (e) => {
|
|
158
158
|
if (!A || !e) return null;
|
|
159
159
|
try {
|
|
160
|
-
let t =
|
|
160
|
+
let t = Se(e), n = t ? window.localStorage.getItem(t) : null;
|
|
161
161
|
if (!n) return null;
|
|
162
162
|
let r = JSON.parse(n);
|
|
163
163
|
return !r || typeof r.transcript != "string" ? null : Number.isFinite(r.expiresAt) && Date.now() > r.expiresAt ? (window.localStorage.removeItem(t), null) : r;
|
|
164
164
|
} catch {
|
|
165
165
|
return null;
|
|
166
166
|
}
|
|
167
|
-
},
|
|
167
|
+
}, Te = (e) => {
|
|
168
168
|
if (!(!A || !e)) try {
|
|
169
|
-
let t =
|
|
169
|
+
let t = Se(e);
|
|
170
170
|
t && window.localStorage.removeItem(t);
|
|
171
171
|
} catch {}
|
|
172
|
-
},
|
|
172
|
+
}, F = "flowengage.voice.pendingResume", Ee = () => {
|
|
173
173
|
if (A) try {
|
|
174
|
-
window.sessionStorage.setItem(
|
|
174
|
+
window.sessionStorage.setItem(F, "1");
|
|
175
175
|
} catch {}
|
|
176
|
-
},
|
|
176
|
+
}, De = () => {
|
|
177
177
|
if (!A) return !1;
|
|
178
178
|
try {
|
|
179
|
-
return window.sessionStorage.getItem(
|
|
179
|
+
return window.sessionStorage.getItem(F) === "1" ? (window.sessionStorage.removeItem(F), !0) : !1;
|
|
180
180
|
} catch {
|
|
181
181
|
return !1;
|
|
182
182
|
}
|
|
183
|
-
},
|
|
183
|
+
}, Oe = "flowengage.chat.pendingReopen", I = () => {
|
|
184
184
|
if (A) try {
|
|
185
|
-
window.sessionStorage.setItem(
|
|
185
|
+
window.sessionStorage.setItem(Oe, "1");
|
|
186
186
|
} catch {}
|
|
187
|
-
},
|
|
187
|
+
}, ke = () => {
|
|
188
188
|
if (!A) return !1;
|
|
189
189
|
try {
|
|
190
|
-
return window.sessionStorage.getItem(
|
|
190
|
+
return window.sessionStorage.getItem(Oe) === "1" ? (window.sessionStorage.removeItem(Oe), !0) : !1;
|
|
191
191
|
} catch {
|
|
192
192
|
return !1;
|
|
193
193
|
}
|
|
194
|
-
},
|
|
194
|
+
}, Ae = () => {
|
|
195
195
|
if (!A) return !1;
|
|
196
196
|
try {
|
|
197
|
-
return window.sessionStorage.getItem(
|
|
197
|
+
return window.sessionStorage.getItem(F) === "1";
|
|
198
198
|
} catch {
|
|
199
199
|
return !1;
|
|
200
200
|
}
|
|
201
|
-
},
|
|
201
|
+
}, je = (e) => e ? `flowengage.voice.navState.${e}.${xe()}` : null, Me = (e, t, n, r) => {
|
|
202
202
|
if (!(!A || !e || !t)) try {
|
|
203
|
-
let i =
|
|
203
|
+
let i = je(e);
|
|
204
204
|
i && window.sessionStorage.setItem(i, JSON.stringify({
|
|
205
205
|
previousPage: String(t),
|
|
206
206
|
targetPath: n ? new URL(String(n), window.location.href).pathname : null,
|
|
@@ -211,7 +211,7 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
|
|
|
211
211
|
}, Ne = (e) => {
|
|
212
212
|
if (!A || !e) return null;
|
|
213
213
|
try {
|
|
214
|
-
let t =
|
|
214
|
+
let t = je(e);
|
|
215
215
|
if (!t) return null;
|
|
216
216
|
let n = window.sessionStorage.getItem(t);
|
|
217
217
|
if (!n) return null;
|
|
@@ -231,7 +231,7 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
|
|
|
231
231
|
throw n.status = e.status, n;
|
|
232
232
|
}
|
|
233
233
|
return t;
|
|
234
|
-
},
|
|
234
|
+
}, R = async (e, t = {}) => {
|
|
235
235
|
try {
|
|
236
236
|
return await fetch(e, {
|
|
237
237
|
mode: "cors",
|
|
@@ -241,9 +241,9 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
|
|
|
241
241
|
let n = /* @__PURE__ */ Error(`Network error reaching ${e}. Check: (1) backend is running, (2) CORS allows this origin, (3) siteId is correct. Original: ${t.message}`);
|
|
242
242
|
throw n.status = 0, n.cause = t, n;
|
|
243
243
|
}
|
|
244
|
-
},
|
|
244
|
+
}, Pe = async ({ apiBaseUrl: e, userId: t, siteId: n, priorChatId: r = null, forceNew: i = !1, resumeChatId: a = null, visitorId: o = null }) => {
|
|
245
245
|
let s = `${e}/api/visitors/resolve-session`, c = { siteId: n };
|
|
246
|
-
return r && String(r).trim() && (c.priorChatId = String(r).trim()), i && (c.forceNew = !0), a && (c.resumeChatId = a), o && (c.visitorId = o), L(await
|
|
246
|
+
return r && String(r).trim() && (c.priorChatId = String(r).trim()), i && (c.forceNew = !0), a && (c.resumeChatId = a), o && (c.visitorId = o), L(await R(s, {
|
|
247
247
|
method: "POST",
|
|
248
248
|
mode: "cors",
|
|
249
249
|
headers: {
|
|
@@ -254,13 +254,13 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
|
|
|
254
254
|
},
|
|
255
255
|
body: JSON.stringify(c)
|
|
256
256
|
}));
|
|
257
|
-
},
|
|
257
|
+
}, Fe = async ({ apiBaseUrl: e, siteId: t }) => {
|
|
258
258
|
let n = typeof window < "u" ? window.location.origin : "http://localhost";
|
|
259
|
-
return (await L(await
|
|
259
|
+
return (await L(await R(`${e}/api/widget/chatbot-loader?${new URLSearchParams({
|
|
260
260
|
siteId: t,
|
|
261
261
|
origin: n
|
|
262
262
|
}).toString()}`, { method: "GET" }))).data;
|
|
263
|
-
},
|
|
263
|
+
}, Ie = ({ apiBaseUrl: e, userId: t, siteId: n, visitorId: r = null }) => {
|
|
264
264
|
let i = (t, n) => {
|
|
265
265
|
let r = `${e}${t}`, i = JSON.stringify(n);
|
|
266
266
|
if (typeof navigator < "u" && navigator.sendBeacon) try {
|
|
@@ -274,7 +274,7 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
|
|
|
274
274
|
headers: { "Content-Type": "application/json" },
|
|
275
275
|
body: i
|
|
276
276
|
}).catch(() => {}), !0) : !1;
|
|
277
|
-
}, a = async (i, a = {}) => L(await
|
|
277
|
+
}, a = async (i, a = {}) => L(await R(`${e}${i}`, {
|
|
278
278
|
...a,
|
|
279
279
|
headers: {
|
|
280
280
|
"Content-Type": "application/json",
|
|
@@ -289,7 +289,7 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
|
|
|
289
289
|
...n ? { "x-site-id": n } : {},
|
|
290
290
|
...a.headers || {}
|
|
291
291
|
};
|
|
292
|
-
return L(await
|
|
292
|
+
return L(await R(`${e}${r}`, {
|
|
293
293
|
...a,
|
|
294
294
|
body: i,
|
|
295
295
|
headers: o
|
|
@@ -415,7 +415,7 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
|
|
|
415
415
|
});
|
|
416
416
|
},
|
|
417
417
|
async getIceServersConfig() {
|
|
418
|
-
return L(await
|
|
418
|
+
return L(await R(`${e}/api/calls/ice-config`, {
|
|
419
419
|
method: "GET",
|
|
420
420
|
headers: {
|
|
421
421
|
"x-user-id": t,
|
|
@@ -470,82 +470,82 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
|
|
|
470
470
|
return i.append("chatId", r), i.append("type", "widget_closed"), t && i.append("userId", String(t)), n && i.append("siteId", String(n)), navigator.sendBeacon(`${e}/api/chat/status`, i);
|
|
471
471
|
}
|
|
472
472
|
};
|
|
473
|
-
},
|
|
474
|
-
|
|
475
|
-
var
|
|
476
|
-
Object.keys(
|
|
477
|
-
|
|
473
|
+
}, z = Object.create(null);
|
|
474
|
+
z.open = "0", z.close = "1", z.ping = "2", z.pong = "3", z.message = "4", z.upgrade = "5", z.noop = "6";
|
|
475
|
+
var Le = Object.create(null);
|
|
476
|
+
Object.keys(z).forEach((e) => {
|
|
477
|
+
Le[z[e]] = e;
|
|
478
478
|
});
|
|
479
|
-
var
|
|
479
|
+
var Re = {
|
|
480
480
|
type: "error",
|
|
481
481
|
data: "parser error"
|
|
482
|
-
},
|
|
482
|
+
}, ze = typeof Blob == "function" || typeof Blob < "u" && Object.prototype.toString.call(Blob) === "[object BlobConstructor]", Be = typeof ArrayBuffer == "function", Ve = (e) => typeof ArrayBuffer.isView == "function" ? ArrayBuffer.isView(e) : e && e.buffer instanceof ArrayBuffer, He = ({ type: e, data: t }, n, r) => ze && t instanceof Blob ? n ? r(t) : Ue(t, r) : Be && (t instanceof ArrayBuffer || Ve(t)) ? n ? r(t) : Ue(new Blob([t]), r) : r(z[e] + (t || "")), Ue = (e, t) => {
|
|
483
483
|
let n = new FileReader();
|
|
484
484
|
return n.onload = function() {
|
|
485
485
|
let e = n.result.split(",")[1];
|
|
486
486
|
t("b" + (e || ""));
|
|
487
487
|
}, n.readAsDataURL(e);
|
|
488
488
|
};
|
|
489
|
-
function
|
|
489
|
+
function We(e) {
|
|
490
490
|
return e instanceof Uint8Array ? e : e instanceof ArrayBuffer ? new Uint8Array(e) : new Uint8Array(e.buffer, e.byteOffset, e.byteLength);
|
|
491
491
|
}
|
|
492
|
-
var
|
|
493
|
-
function
|
|
494
|
-
if (
|
|
495
|
-
if (
|
|
496
|
-
|
|
497
|
-
|
|
492
|
+
var Ge;
|
|
493
|
+
function Ke(e, t) {
|
|
494
|
+
if (ze && e.data instanceof Blob) return e.data.arrayBuffer().then(We).then(t);
|
|
495
|
+
if (Be && (e.data instanceof ArrayBuffer || Ve(e.data))) return t(We(e.data));
|
|
496
|
+
He(e, !1, (e) => {
|
|
497
|
+
Ge ||= new TextEncoder(), t(Ge.encode(e));
|
|
498
498
|
});
|
|
499
499
|
}
|
|
500
500
|
//#endregion
|
|
501
501
|
//#region node_modules/engine.io-parser/build/esm/contrib/base64-arraybuffer.js
|
|
502
|
-
var
|
|
503
|
-
for (let e = 0; e < 64; e++)
|
|
504
|
-
var
|
|
502
|
+
var qe = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", Je = typeof Uint8Array > "u" ? [] : new Uint8Array(256);
|
|
503
|
+
for (let e = 0; e < 64; e++) Je[qe.charCodeAt(e)] = e;
|
|
504
|
+
var Ye = (e) => {
|
|
505
505
|
let t = e.length * .75, n = e.length, r, i = 0, a, o, s, c;
|
|
506
506
|
e[e.length - 1] === "=" && (t--, e[e.length - 2] === "=" && t--);
|
|
507
507
|
let l = new ArrayBuffer(t), u = new Uint8Array(l);
|
|
508
|
-
for (r = 0; r < n; r += 4) a =
|
|
508
|
+
for (r = 0; r < n; r += 4) a = Je[e.charCodeAt(r)], o = Je[e.charCodeAt(r + 1)], s = Je[e.charCodeAt(r + 2)], c = Je[e.charCodeAt(r + 3)], u[i++] = a << 2 | o >> 4, u[i++] = (o & 15) << 4 | s >> 2, u[i++] = (s & 3) << 6 | c & 63;
|
|
509
509
|
return l;
|
|
510
|
-
},
|
|
510
|
+
}, B = typeof ArrayBuffer == "function", V = (e, t) => {
|
|
511
511
|
if (typeof e != "string") return {
|
|
512
512
|
type: "message",
|
|
513
|
-
data:
|
|
513
|
+
data: Ze(e, t)
|
|
514
514
|
};
|
|
515
515
|
let n = e.charAt(0);
|
|
516
516
|
return n === "b" ? {
|
|
517
517
|
type: "message",
|
|
518
|
-
data:
|
|
519
|
-
} :
|
|
520
|
-
type:
|
|
518
|
+
data: Xe(e.substring(1), t)
|
|
519
|
+
} : Le[n] ? e.length > 1 ? {
|
|
520
|
+
type: Le[n],
|
|
521
521
|
data: e.substring(1)
|
|
522
|
-
} : { type:
|
|
523
|
-
},
|
|
522
|
+
} : { type: Le[n] } : Re;
|
|
523
|
+
}, Xe = (e, t) => B ? Ze(Ye(e), t) : {
|
|
524
524
|
base64: !0,
|
|
525
525
|
data: e
|
|
526
|
-
},
|
|
526
|
+
}, Ze = (e, t) => {
|
|
527
527
|
switch (t) {
|
|
528
528
|
case "blob": return e instanceof Blob ? e : new Blob([e]);
|
|
529
529
|
default: return e instanceof ArrayBuffer ? e : e.buffer;
|
|
530
530
|
}
|
|
531
|
-
},
|
|
531
|
+
}, Qe = "", $e = (e, t) => {
|
|
532
532
|
let n = e.length, r = Array(n), i = 0;
|
|
533
533
|
e.forEach((e, a) => {
|
|
534
|
-
|
|
535
|
-
r[a] = e, ++i === n && t(r.join(
|
|
534
|
+
He(e, !1, (e) => {
|
|
535
|
+
r[a] = e, ++i === n && t(r.join(Qe));
|
|
536
536
|
});
|
|
537
537
|
});
|
|
538
|
-
},
|
|
539
|
-
let n = e.split(
|
|
538
|
+
}, et = (e, t) => {
|
|
539
|
+
let n = e.split(Qe), r = [];
|
|
540
540
|
for (let e = 0; e < n.length; e++) {
|
|
541
|
-
let i =
|
|
541
|
+
let i = V(n[e], t);
|
|
542
542
|
if (r.push(i), i.type === "error") break;
|
|
543
543
|
}
|
|
544
544
|
return r;
|
|
545
545
|
};
|
|
546
|
-
function
|
|
546
|
+
function H() {
|
|
547
547
|
return new TransformStream({ transform(e, t) {
|
|
548
|
-
|
|
548
|
+
Ke(e, (n) => {
|
|
549
549
|
let r = n.length, i;
|
|
550
550
|
if (r < 126) i = new Uint8Array(1), new DataView(i.buffer).setUint8(0, r);
|
|
551
551
|
else if (r < 65536) {
|
|
@@ -561,44 +561,44 @@ function V() {
|
|
|
561
561
|
});
|
|
562
562
|
} });
|
|
563
563
|
}
|
|
564
|
-
var
|
|
565
|
-
function
|
|
564
|
+
var U;
|
|
565
|
+
function tt(e) {
|
|
566
566
|
return e.reduce((e, t) => e + t.length, 0);
|
|
567
567
|
}
|
|
568
|
-
function
|
|
568
|
+
function nt(e, t) {
|
|
569
569
|
if (e[0].length === t) return e.shift();
|
|
570
570
|
let n = new Uint8Array(t), r = 0;
|
|
571
571
|
for (let i = 0; i < t; i++) n[i] = e[0][r++], r === e[0].length && (e.shift(), r = 0);
|
|
572
572
|
return e.length && r < e[0].length && (e[0] = e[0].slice(r)), n;
|
|
573
573
|
}
|
|
574
|
-
function
|
|
575
|
-
|
|
574
|
+
function rt(e, t) {
|
|
575
|
+
U ||= new TextDecoder();
|
|
576
576
|
let n = [], r = 0, i = -1, a = !1;
|
|
577
577
|
return new TransformStream({ transform(o, s) {
|
|
578
578
|
for (n.push(o);;) {
|
|
579
579
|
if (r === 0) {
|
|
580
|
-
if (
|
|
581
|
-
let e =
|
|
580
|
+
if (tt(n) < 1) break;
|
|
581
|
+
let e = nt(n, 1);
|
|
582
582
|
a = (e[0] & 128) == 128, i = e[0] & 127, r = i < 126 ? 3 : i === 126 ? 1 : 2;
|
|
583
583
|
} else if (r === 1) {
|
|
584
|
-
if (
|
|
585
|
-
let e =
|
|
584
|
+
if (tt(n) < 2) break;
|
|
585
|
+
let e = nt(n, 2);
|
|
586
586
|
i = new DataView(e.buffer, e.byteOffset, e.length).getUint16(0), r = 3;
|
|
587
587
|
} else if (r === 2) {
|
|
588
|
-
if (
|
|
589
|
-
let e =
|
|
588
|
+
if (tt(n) < 8) break;
|
|
589
|
+
let e = nt(n, 8), t = new DataView(e.buffer, e.byteOffset, e.length), a = t.getUint32(0);
|
|
590
590
|
if (a > 2 ** 21 - 1) {
|
|
591
|
-
s.enqueue(
|
|
591
|
+
s.enqueue(Re);
|
|
592
592
|
break;
|
|
593
593
|
}
|
|
594
594
|
i = a * 2 ** 32 + t.getUint32(4), r = 3;
|
|
595
595
|
} else {
|
|
596
|
-
if (
|
|
597
|
-
let e =
|
|
598
|
-
s.enqueue(
|
|
596
|
+
if (tt(n) < i) break;
|
|
597
|
+
let e = nt(n, i);
|
|
598
|
+
s.enqueue(V(a ? e : U.decode(e), t)), r = 0;
|
|
599
599
|
}
|
|
600
600
|
if (i === 0 || i > e) {
|
|
601
|
-
s.enqueue(
|
|
601
|
+
s.enqueue(Re);
|
|
602
602
|
break;
|
|
603
603
|
}
|
|
604
604
|
}
|
|
@@ -606,21 +606,21 @@ function it(e, t) {
|
|
|
606
606
|
}
|
|
607
607
|
//#endregion
|
|
608
608
|
//#region node_modules/@socket.io/component-emitter/lib/esm/index.js
|
|
609
|
-
function
|
|
610
|
-
if (e) return
|
|
609
|
+
function W(e) {
|
|
610
|
+
if (e) return it(e);
|
|
611
611
|
}
|
|
612
|
-
function
|
|
613
|
-
for (var t in
|
|
612
|
+
function it(e) {
|
|
613
|
+
for (var t in W.prototype) e[t] = W.prototype[t];
|
|
614
614
|
return e;
|
|
615
615
|
}
|
|
616
|
-
|
|
616
|
+
W.prototype.on = W.prototype.addEventListener = function(e, t) {
|
|
617
617
|
return this._callbacks = this._callbacks || {}, (this._callbacks["$" + e] = this._callbacks["$" + e] || []).push(t), this;
|
|
618
|
-
},
|
|
618
|
+
}, W.prototype.once = function(e, t) {
|
|
619
619
|
function n() {
|
|
620
620
|
this.off(e, n), t.apply(this, arguments);
|
|
621
621
|
}
|
|
622
622
|
return n.fn = t, this.on(e, n), this;
|
|
623
|
-
},
|
|
623
|
+
}, W.prototype.off = W.prototype.removeListener = W.prototype.removeAllListeners = W.prototype.removeEventListener = function(e, t) {
|
|
624
624
|
if (this._callbacks = this._callbacks || {}, arguments.length == 0) return this._callbacks = {}, this;
|
|
625
625
|
var n = this._callbacks["$" + e];
|
|
626
626
|
if (!n) return this;
|
|
@@ -630,7 +630,7 @@ U.prototype.on = U.prototype.addEventListener = function(e, t) {
|
|
|
630
630
|
break;
|
|
631
631
|
}
|
|
632
632
|
return n.length === 0 && delete this._callbacks["$" + e], this;
|
|
633
|
-
},
|
|
633
|
+
}, W.prototype.emit = function(e) {
|
|
634
634
|
this._callbacks = this._callbacks || {};
|
|
635
635
|
for (var t = Array(arguments.length - 1), n = this._callbacks["$" + e], r = 1; r < arguments.length; r++) t[r - 1] = arguments[r];
|
|
636
636
|
if (n) {
|
|
@@ -638,43 +638,43 @@ U.prototype.on = U.prototype.addEventListener = function(e, t) {
|
|
|
638
638
|
for (var r = 0, i = n.length; r < i; ++r) n[r].apply(this, t);
|
|
639
639
|
}
|
|
640
640
|
return this;
|
|
641
|
-
},
|
|
641
|
+
}, W.prototype.emitReserved = W.prototype.emit, W.prototype.listeners = function(e) {
|
|
642
642
|
return this._callbacks = this._callbacks || {}, this._callbacks["$" + e] || [];
|
|
643
|
-
},
|
|
643
|
+
}, W.prototype.hasListeners = function(e) {
|
|
644
644
|
return !!this.listeners(e).length;
|
|
645
645
|
};
|
|
646
646
|
//#endregion
|
|
647
647
|
//#region node_modules/engine.io-client/build/esm/globals.js
|
|
648
|
-
var
|
|
648
|
+
var at = typeof Promise == "function" && typeof Promise.resolve == "function" ? (e) => Promise.resolve().then(e) : (e, t) => t(e, 0), G = typeof self < "u" ? self : typeof window < "u" ? window : Function("return this")(), ot = "arraybuffer";
|
|
649
649
|
//#endregion
|
|
650
650
|
//#region node_modules/engine.io-client/build/esm/util.js
|
|
651
|
-
function
|
|
651
|
+
function st(e, ...t) {
|
|
652
652
|
return t.reduce((t, n) => (e.hasOwnProperty(n) && (t[n] = e[n]), t), {});
|
|
653
653
|
}
|
|
654
|
-
var
|
|
655
|
-
function
|
|
656
|
-
t.useNativeTimers ? (e.setTimeoutFn =
|
|
654
|
+
var ct = G.setTimeout, lt = G.clearTimeout;
|
|
655
|
+
function ut(e, t) {
|
|
656
|
+
t.useNativeTimers ? (e.setTimeoutFn = ct.bind(G), e.clearTimeoutFn = lt.bind(G)) : (e.setTimeoutFn = G.setTimeout.bind(G), e.clearTimeoutFn = G.clearTimeout.bind(G));
|
|
657
657
|
}
|
|
658
|
-
var
|
|
659
|
-
function
|
|
660
|
-
return typeof e == "string" ?
|
|
658
|
+
var dt = 1.33;
|
|
659
|
+
function ft(e) {
|
|
660
|
+
return typeof e == "string" ? pt(e) : Math.ceil((e.byteLength || e.size) * dt);
|
|
661
661
|
}
|
|
662
|
-
function
|
|
662
|
+
function pt(e) {
|
|
663
663
|
let t = 0, n = 0;
|
|
664
664
|
for (let r = 0, i = e.length; r < i; r++) t = e.charCodeAt(r), t < 128 ? n += 1 : t < 2048 ? n += 2 : t < 55296 || t >= 57344 ? n += 3 : (r++, n += 4);
|
|
665
665
|
return n;
|
|
666
666
|
}
|
|
667
|
-
function
|
|
667
|
+
function mt() {
|
|
668
668
|
return Date.now().toString(36).substring(3) + Math.random().toString(36).substring(2, 5);
|
|
669
669
|
}
|
|
670
670
|
//#endregion
|
|
671
671
|
//#region node_modules/engine.io-client/build/esm/contrib/parseqs.js
|
|
672
|
-
function
|
|
672
|
+
function ht(e) {
|
|
673
673
|
let t = "";
|
|
674
674
|
for (let n in e) e.hasOwnProperty(n) && (t.length && (t += "&"), t += encodeURIComponent(n) + "=" + encodeURIComponent(e[n]));
|
|
675
675
|
return t;
|
|
676
676
|
}
|
|
677
|
-
function
|
|
677
|
+
function gt(e) {
|
|
678
678
|
let t = {}, n = e.split("&");
|
|
679
679
|
for (let e = 0, r = n.length; e < r; e++) {
|
|
680
680
|
let r = n[e].split("=");
|
|
@@ -684,16 +684,16 @@ function _t(e) {
|
|
|
684
684
|
}
|
|
685
685
|
//#endregion
|
|
686
686
|
//#region node_modules/engine.io-client/build/esm/transport.js
|
|
687
|
-
var
|
|
687
|
+
var _t = class extends Error {
|
|
688
688
|
constructor(e, t, n) {
|
|
689
689
|
super(e), this.description = t, this.context = n, this.type = "TransportError";
|
|
690
690
|
}
|
|
691
|
-
},
|
|
691
|
+
}, vt = class extends W {
|
|
692
692
|
constructor(e) {
|
|
693
|
-
super(), this.writable = !1,
|
|
693
|
+
super(), this.writable = !1, ut(this, e), this.opts = e, this.query = e.query, this.socket = e.socket, this.supportsBinary = !e.forceBase64;
|
|
694
694
|
}
|
|
695
695
|
onError(e, t, n) {
|
|
696
|
-
return super.emitReserved("error", new
|
|
696
|
+
return super.emitReserved("error", new _t(e, t, n)), this;
|
|
697
697
|
}
|
|
698
698
|
open() {
|
|
699
699
|
return this.readyState = "opening", this.doOpen(), this;
|
|
@@ -708,7 +708,7 @@ var vt = class extends Error {
|
|
|
708
708
|
this.readyState = "open", this.writable = !0, super.emitReserved("open");
|
|
709
709
|
}
|
|
710
710
|
onData(e) {
|
|
711
|
-
let t =
|
|
711
|
+
let t = V(e, this.socket.binaryType);
|
|
712
712
|
this.onPacket(t);
|
|
713
713
|
}
|
|
714
714
|
onPacket(e) {
|
|
@@ -729,10 +729,10 @@ var vt = class extends Error {
|
|
|
729
729
|
return this.opts.port && (this.opts.secure && Number(this.opts.port) !== 443 || !this.opts.secure && Number(this.opts.port) !== 80) ? ":" + this.opts.port : "";
|
|
730
730
|
}
|
|
731
731
|
_query(e) {
|
|
732
|
-
let t =
|
|
732
|
+
let t = ht(e);
|
|
733
733
|
return t.length ? "?" + t : "";
|
|
734
734
|
}
|
|
735
|
-
},
|
|
735
|
+
}, yt = class extends vt {
|
|
736
736
|
constructor() {
|
|
737
737
|
super(...arguments), this._polling = !1;
|
|
738
738
|
}
|
|
@@ -760,7 +760,7 @@ var vt = class extends Error {
|
|
|
760
760
|
this._polling = !0, this.doPoll(), this.emitReserved("poll");
|
|
761
761
|
}
|
|
762
762
|
onData(e) {
|
|
763
|
-
|
|
763
|
+
et(e, this.socket.binaryType).forEach((e) => {
|
|
764
764
|
if (this.readyState === "opening" && e.type === "open" && this.onOpen(), e.type === "close") return this.onClose({ description: "transport closed by the server" }), !1;
|
|
765
765
|
this.onPacket(e);
|
|
766
766
|
}), this.readyState !== "closed" && (this._polling = !1, this.emitReserved("pollComplete"), this.readyState === "open" && this._poll());
|
|
@@ -772,7 +772,7 @@ var vt = class extends Error {
|
|
|
772
772
|
this.readyState === "open" ? e() : this.once("open", e);
|
|
773
773
|
}
|
|
774
774
|
write(e) {
|
|
775
|
-
this.writable = !1,
|
|
775
|
+
this.writable = !1, $e(e, (e) => {
|
|
776
776
|
this.doWrite(e, () => {
|
|
777
777
|
this.writable = !0, this.emitReserved("drain");
|
|
778
778
|
});
|
|
@@ -780,17 +780,17 @@ var vt = class extends Error {
|
|
|
780
780
|
}
|
|
781
781
|
uri() {
|
|
782
782
|
let e = this.opts.secure ? "https" : "http", t = this.query || {};
|
|
783
|
-
return !1 !== this.opts.timestampRequests && (t[this.opts.timestampParam] =
|
|
783
|
+
return !1 !== this.opts.timestampRequests && (t[this.opts.timestampParam] = mt()), !this.supportsBinary && !t.sid && (t.b64 = 1), this.createUri(e, t);
|
|
784
784
|
}
|
|
785
|
-
},
|
|
785
|
+
}, bt = !1;
|
|
786
786
|
try {
|
|
787
|
-
|
|
787
|
+
bt = typeof XMLHttpRequest < "u" && "withCredentials" in new XMLHttpRequest();
|
|
788
788
|
} catch {}
|
|
789
|
-
var
|
|
789
|
+
var xt = bt;
|
|
790
790
|
//#endregion
|
|
791
791
|
//#region node_modules/engine.io-client/build/esm/transports/polling-xhr.js
|
|
792
|
-
function
|
|
793
|
-
var
|
|
792
|
+
function St() {}
|
|
793
|
+
var Ct = class extends yt {
|
|
794
794
|
constructor(e) {
|
|
795
795
|
if (super(e), typeof location < "u") {
|
|
796
796
|
let t = location.protocol === "https:", n = location.port;
|
|
@@ -812,13 +812,13 @@ var wt = class extends bt {
|
|
|
812
812
|
this.onError("xhr poll error", e, t);
|
|
813
813
|
}), this.pollXhr = e;
|
|
814
814
|
}
|
|
815
|
-
},
|
|
815
|
+
}, wt = class e extends W {
|
|
816
816
|
constructor(e, t, n) {
|
|
817
|
-
super(), this.createRequest = e,
|
|
817
|
+
super(), this.createRequest = e, ut(this, n), this._opts = n, this._method = n.method || "GET", this._uri = t, this._data = n.data === void 0 ? null : n.data, this._create();
|
|
818
818
|
}
|
|
819
819
|
_create() {
|
|
820
820
|
var t;
|
|
821
|
-
let n =
|
|
821
|
+
let n = st(this._opts, "agent", "pfx", "key", "passphrase", "cert", "ca", "ciphers", "rejectUnauthorized", "autoUnref");
|
|
822
822
|
n.xdomain = !!this._opts.xd;
|
|
823
823
|
let r = this._xhr = this.createRequest(n);
|
|
824
824
|
try {
|
|
@@ -854,7 +854,7 @@ var wt = class extends bt {
|
|
|
854
854
|
}
|
|
855
855
|
_cleanup(t) {
|
|
856
856
|
if (!(this._xhr === void 0 || this._xhr === null)) {
|
|
857
|
-
if (this._xhr.onreadystatechange =
|
|
857
|
+
if (this._xhr.onreadystatechange = St, t) try {
|
|
858
858
|
this._xhr.abort();
|
|
859
859
|
} catch {}
|
|
860
860
|
typeof document < "u" && delete e.requests[this._index], this._xhr = null;
|
|
@@ -868,46 +868,46 @@ var wt = class extends bt {
|
|
|
868
868
|
this._cleanup();
|
|
869
869
|
}
|
|
870
870
|
};
|
|
871
|
-
if (
|
|
872
|
-
if (typeof attachEvent == "function") attachEvent("onunload",
|
|
871
|
+
if (wt.requestsCount = 0, wt.requests = {}, typeof document < "u") {
|
|
872
|
+
if (typeof attachEvent == "function") attachEvent("onunload", Tt);
|
|
873
873
|
else if (typeof addEventListener == "function") {
|
|
874
|
-
let e = "onpagehide" in
|
|
875
|
-
addEventListener(e,
|
|
874
|
+
let e = "onpagehide" in G ? "pagehide" : "unload";
|
|
875
|
+
addEventListener(e, Tt, !1);
|
|
876
876
|
}
|
|
877
877
|
}
|
|
878
|
-
function
|
|
879
|
-
for (let e in
|
|
878
|
+
function Tt() {
|
|
879
|
+
for (let e in wt.requests) wt.requests.hasOwnProperty(e) && wt.requests[e].abort();
|
|
880
880
|
}
|
|
881
|
-
var
|
|
881
|
+
var Et = (function() {
|
|
882
882
|
let e = Ot({ xdomain: !1 });
|
|
883
883
|
return e && e.responseType !== null;
|
|
884
|
-
})(), Dt = class extends
|
|
884
|
+
})(), Dt = class extends Ct {
|
|
885
885
|
constructor(e) {
|
|
886
886
|
super(e);
|
|
887
887
|
let t = e && e.forceBase64;
|
|
888
|
-
this.supportsBinary =
|
|
888
|
+
this.supportsBinary = Et && !t;
|
|
889
889
|
}
|
|
890
890
|
request(e = {}) {
|
|
891
|
-
return Object.assign(e, { xd: this.xd }, this.opts), new
|
|
891
|
+
return Object.assign(e, { xd: this.xd }, this.opts), new wt(Ot, this.uri(), e);
|
|
892
892
|
}
|
|
893
893
|
};
|
|
894
894
|
function Ot(e) {
|
|
895
895
|
let t = e.xdomain;
|
|
896
896
|
try {
|
|
897
|
-
if (typeof XMLHttpRequest < "u" && (!t ||
|
|
897
|
+
if (typeof XMLHttpRequest < "u" && (!t || xt)) return new XMLHttpRequest();
|
|
898
898
|
} catch {}
|
|
899
899
|
if (!t) try {
|
|
900
|
-
return new
|
|
900
|
+
return new G[["Active", "Object"].join("X")]("Microsoft.XMLHTTP");
|
|
901
901
|
} catch {}
|
|
902
902
|
}
|
|
903
903
|
//#endregion
|
|
904
904
|
//#region node_modules/engine.io-client/build/esm/transports/websocket.js
|
|
905
|
-
var kt = typeof navigator < "u" && typeof navigator.product == "string" && navigator.product.toLowerCase() === "reactnative", At = class extends
|
|
905
|
+
var kt = typeof navigator < "u" && typeof navigator.product == "string" && navigator.product.toLowerCase() === "reactnative", At = class extends vt {
|
|
906
906
|
get name() {
|
|
907
907
|
return "websocket";
|
|
908
908
|
}
|
|
909
909
|
doOpen() {
|
|
910
|
-
let e = this.uri(), t = this.opts.protocols, n = kt ? {} :
|
|
910
|
+
let e = this.uri(), t = this.opts.protocols, n = kt ? {} : st(this.opts, "agent", "perMessageDeflate", "pfx", "key", "passphrase", "cert", "ca", "ciphers", "rejectUnauthorized", "localAddress", "protocolVersion", "origin", "maxPayload", "family", "checkServerIdentity");
|
|
911
911
|
this.opts.extraHeaders && (n.headers = this.opts.extraHeaders);
|
|
912
912
|
try {
|
|
913
913
|
this.ws = this.createSocket(e, t, n);
|
|
@@ -928,11 +928,11 @@ var kt = typeof navigator < "u" && typeof navigator.product == "string" && navig
|
|
|
928
928
|
this.writable = !1;
|
|
929
929
|
for (let t = 0; t < e.length; t++) {
|
|
930
930
|
let n = e[t], r = t === e.length - 1;
|
|
931
|
-
|
|
931
|
+
He(n, this.supportsBinary, (e) => {
|
|
932
932
|
try {
|
|
933
933
|
this.doWrite(n, e);
|
|
934
934
|
} catch {}
|
|
935
|
-
r &&
|
|
935
|
+
r && at(() => {
|
|
936
936
|
this.writable = !0, this.emitReserved("drain");
|
|
937
937
|
}, this.setTimeoutFn);
|
|
938
938
|
});
|
|
@@ -943,9 +943,9 @@ var kt = typeof navigator < "u" && typeof navigator.product == "string" && navig
|
|
|
943
943
|
}
|
|
944
944
|
uri() {
|
|
945
945
|
let e = this.opts.secure ? "wss" : "ws", t = this.query || {};
|
|
946
|
-
return this.opts.timestampRequests && (t[this.opts.timestampParam] =
|
|
946
|
+
return this.opts.timestampRequests && (t[this.opts.timestampParam] = mt()), this.supportsBinary || (t.b64 = 1), this.createUri(e, t);
|
|
947
947
|
}
|
|
948
|
-
}, jt =
|
|
948
|
+
}, jt = G.WebSocket || G.MozWebSocket, Mt = {
|
|
949
949
|
websocket: class extends At {
|
|
950
950
|
createSocket(e, t, n) {
|
|
951
951
|
return kt ? new jt(e, t, n) : t ? new jt(e, t) : new jt(e);
|
|
@@ -954,7 +954,7 @@ var kt = typeof navigator < "u" && typeof navigator.product == "string" && navig
|
|
|
954
954
|
this.ws.send(t);
|
|
955
955
|
}
|
|
956
956
|
},
|
|
957
|
-
webtransport: class extends
|
|
957
|
+
webtransport: class extends vt {
|
|
958
958
|
get name() {
|
|
959
959
|
return "webtransport";
|
|
960
960
|
}
|
|
@@ -970,7 +970,7 @@ var kt = typeof navigator < "u" && typeof navigator.product == "string" && navig
|
|
|
970
970
|
this.onError("webtransport error", e);
|
|
971
971
|
}), this._transport.ready.then(() => {
|
|
972
972
|
this._transport.createBidirectionalStream().then((e) => {
|
|
973
|
-
let t =
|
|
973
|
+
let t = rt(2 ** 53 - 1, this.socket.binaryType), n = e.readable.pipeThrough(t).getReader(), r = H();
|
|
974
974
|
r.readable.pipeTo(e.writable), this._writer = r.writable.getWriter();
|
|
975
975
|
let i = () => {
|
|
976
976
|
n.read().then(({ done: e, value: t }) => {
|
|
@@ -988,7 +988,7 @@ var kt = typeof navigator < "u" && typeof navigator.product == "string" && navig
|
|
|
988
988
|
for (let t = 0; t < e.length; t++) {
|
|
989
989
|
let n = e[t], r = t === e.length - 1;
|
|
990
990
|
this._writer.write(n).then(() => {
|
|
991
|
-
r &&
|
|
991
|
+
r && at(() => {
|
|
992
992
|
this.writable = !0, this.emitReserved("drain");
|
|
993
993
|
}, this.setTimeoutFn);
|
|
994
994
|
});
|
|
@@ -1040,13 +1040,13 @@ var Rt = typeof addEventListener == "function" && typeof removeEventListener ==
|
|
|
1040
1040
|
Rt && addEventListener("offline", () => {
|
|
1041
1041
|
zt.forEach((e) => e());
|
|
1042
1042
|
}, !1);
|
|
1043
|
-
var Bt = class e extends
|
|
1043
|
+
var Bt = class e extends W {
|
|
1044
1044
|
constructor(e, t) {
|
|
1045
|
-
if (super(), this.binaryType =
|
|
1045
|
+
if (super(), this.binaryType = ot, this.writeBuffer = [], this._prevBufferLen = 0, this._pingInterval = -1, this._pingTimeout = -1, this._maxPayload = -1, this._pingTimeoutTime = Infinity, e && typeof e == "object" && (t = e, e = null), e) {
|
|
1046
1046
|
let n = Ft(e);
|
|
1047
1047
|
t.hostname = n.host, t.secure = n.protocol === "https" || n.protocol === "wss", t.port = n.port, n.query && (t.query = n.query);
|
|
1048
1048
|
} else t.host && (t.hostname = Ft(t.host).host);
|
|
1049
|
-
|
|
1049
|
+
ut(this, t), this.secure = t.secure == null ? typeof location < "u" && location.protocol === "https:" : t.secure, t.hostname && !t.port && (t.port = this.secure ? "443" : "80"), this.hostname = t.hostname || (typeof location < "u" ? location.hostname : "localhost"), this.port = t.port || (typeof location < "u" && location.port ? location.port : this.secure ? "443" : "80"), this.transports = [], this._transportsByName = {}, t.transports.forEach((e) => {
|
|
1050
1050
|
let t = e.prototype.name;
|
|
1051
1051
|
this.transports.push(t), this._transportsByName[t] = e;
|
|
1052
1052
|
}), this.opts = Object.assign({
|
|
@@ -1061,7 +1061,7 @@ var Bt = class e extends U {
|
|
|
1061
1061
|
perMessageDeflate: { threshold: 1024 },
|
|
1062
1062
|
transportOptions: {},
|
|
1063
1063
|
closeOnBeforeunload: !1
|
|
1064
|
-
}, t), this.opts.path = this.opts.path.replace(/\/$/, "") + (this.opts.addTrailingSlash ? "/" : ""), typeof this.opts.query == "string" && (this.opts.query =
|
|
1064
|
+
}, t), this.opts.path = this.opts.path.replace(/\/$/, "") + (this.opts.addTrailingSlash ? "/" : ""), typeof this.opts.query == "string" && (this.opts.query = gt(this.opts.query)), Rt && (this.opts.closeOnBeforeunload && (this._beforeunloadEventListener = () => {
|
|
1065
1065
|
this.transport && (this.transport.removeAllListeners(), this.transport.close());
|
|
1066
1066
|
}, addEventListener("beforeunload", this._beforeunloadEventListener, !1)), this.hostname !== "localhost" && (this._offlineEventListener = () => {
|
|
1067
1067
|
this._onClose("transport close", { description: "network connection lost" });
|
|
@@ -1138,7 +1138,7 @@ var Bt = class e extends U {
|
|
|
1138
1138
|
let e = 1;
|
|
1139
1139
|
for (let t = 0; t < this.writeBuffer.length; t++) {
|
|
1140
1140
|
let n = this.writeBuffer[t].data;
|
|
1141
|
-
if (n && (e +=
|
|
1141
|
+
if (n && (e += ft(n)), t > 0 && e > this._maxPayload) return this.writeBuffer.slice(0, t);
|
|
1142
1142
|
e += 2;
|
|
1143
1143
|
}
|
|
1144
1144
|
return this.writeBuffer;
|
|
@@ -1146,7 +1146,7 @@ var Bt = class e extends U {
|
|
|
1146
1146
|
_hasPingExpired() {
|
|
1147
1147
|
if (!this._pingTimeoutTime) return !0;
|
|
1148
1148
|
let e = Date.now() > this._pingTimeoutTime;
|
|
1149
|
-
return e && (this._pingTimeoutTime = 0,
|
|
1149
|
+
return e && (this._pingTimeoutTime = 0, at(() => {
|
|
1150
1150
|
this._onClose("ping timeout");
|
|
1151
1151
|
}, this.setTimeoutFn)), e;
|
|
1152
1152
|
}
|
|
@@ -1365,7 +1365,7 @@ var rn = class {
|
|
|
1365
1365
|
let t = Zt(e), n = this.encodeAsString(t.packet), r = t.buffers;
|
|
1366
1366
|
return r.unshift(n), r;
|
|
1367
1367
|
}
|
|
1368
|
-
}, an = class e extends
|
|
1368
|
+
}, an = class e extends W {
|
|
1369
1369
|
constructor(e) {
|
|
1370
1370
|
super(), this.opts = Object.assign({
|
|
1371
1371
|
reviver: void 0,
|
|
@@ -1498,7 +1498,7 @@ var mn = Object.freeze({
|
|
|
1498
1498
|
disconnecting: 1,
|
|
1499
1499
|
newListener: 1,
|
|
1500
1500
|
removeListener: 1
|
|
1501
|
-
}), hn = class extends
|
|
1501
|
+
}), hn = class extends W {
|
|
1502
1502
|
constructor(e, t, n) {
|
|
1503
1503
|
super(), this.connected = !1, this.recovered = !1, this.receiveBuffer = [], this.sendBuffer = [], this._queue = [], this._queueSeq = 0, this.ids = 0, this.acks = {}, this.flags = {}, this.io = e, this.nsp = t, n && n.auth && (this.auth = n.auth), this._opts = Object.assign({}, n), this.io._autoConnect && this.open();
|
|
1504
1504
|
}
|
|
@@ -1751,9 +1751,9 @@ gn.prototype.duration = function() {
|
|
|
1751
1751
|
};
|
|
1752
1752
|
//#endregion
|
|
1753
1753
|
//#region node_modules/socket.io-client/build/esm/manager.js
|
|
1754
|
-
var _n = class extends
|
|
1754
|
+
var _n = class extends W {
|
|
1755
1755
|
constructor(e, t) {
|
|
1756
|
-
super(), this.nsps = {}, this.subs = [], e && typeof e == "object" && (t = e, e = void 0), t ||= {}, t.path = t.path || "/socket.io", this.opts = t,
|
|
1756
|
+
super(), this.nsps = {}, this.subs = [], e && typeof e == "object" && (t = e, e = void 0), t ||= {}, t.path = t.path || "/socket.io", this.opts = t, ut(this, t), this.reconnection(t.reconnection !== !1), this.reconnectionAttempts(t.reconnectionAttempts || Infinity), this.reconnectionDelay(t.reconnectionDelay || 1e3), this.reconnectionDelayMax(t.reconnectionDelayMax || 5e3), this.randomizationFactor(t.randomizationFactor ?? .5), this.backoff = new gn({
|
|
1757
1757
|
min: this.reconnectionDelay(),
|
|
1758
1758
|
max: this.reconnectionDelayMax(),
|
|
1759
1759
|
jitter: this.randomizationFactor()
|
|
@@ -1824,7 +1824,7 @@ var _n = class extends U {
|
|
|
1824
1824
|
}
|
|
1825
1825
|
}
|
|
1826
1826
|
ondecoded(e) {
|
|
1827
|
-
|
|
1827
|
+
at(() => {
|
|
1828
1828
|
this.emitReserved("packet", e);
|
|
1829
1829
|
}, this.setTimeoutFn);
|
|
1830
1830
|
}
|
|
@@ -2817,11 +2817,11 @@ async function br(e, t = {}) {
|
|
|
2817
2817
|
try {
|
|
2818
2818
|
window.history.pushState({}, "", e), window.dispatchEvent(new PopStateEvent("popstate", { state: {} }));
|
|
2819
2819
|
} catch {}
|
|
2820
|
-
return n && mr(n), r ||
|
|
2820
|
+
return n && mr(n), r || I(), window.location.assign(i.href), { navigated: !0 };
|
|
2821
2821
|
}
|
|
2822
2822
|
return { navigated: !0 };
|
|
2823
2823
|
}
|
|
2824
|
-
return n && mr(n), r ||
|
|
2824
|
+
return n && mr(n), r || I(), window.location.assign(i.href), { navigated: !0 };
|
|
2825
2825
|
} catch (t) {
|
|
2826
2826
|
console.warn("[FlowEngage] shadowNavigate error:", t), n && mr(n);
|
|
2827
2827
|
try {
|
|
@@ -2919,108 +2919,108 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
2919
2919
|
message: "Looks like you're already on this page!",
|
|
2920
2920
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
2921
2921
|
}]);
|
|
2922
|
-
}, []), [T, D] = m(
|
|
2922
|
+
}, []), [T, D] = m(pe().isOpen), [ee, O] = m(pe().activeScreen), [k, A] = m(pe().isHumanHandled), [ie, M] = m(pe().agentName), [se, ce] = m(pe().agentHeadshot), [le, _e] = m(() => he(i?.siteId)), [N, ve] = m(!1), [be, xe] = m(!1), [Se, Ce] = m("idle"), [P, we] = m(!1), [Te, F] = m(!1), [De, Oe] = m(""), [I, ke] = m(!1), [Ae, je] = m(0), [Me, Ne] = m(0), [L, R] = m(!1), [z, Le] = m(null), [Re, ze] = m(null), [Be, Ve] = m("idle"), [He, Ue] = m(null), [We, Ge] = m(!1), [Ke, qe] = m(""), [Je, Ye] = m(!1), B = p(null), V = p(null), Xe = p(""), Ze = p(!1), Qe = p(null), $e = p(null), et = p(null), H = p(null), U = p(null), tt = p(null), nt = p(null), rt = p(!1), W = p({
|
|
2923
2923
|
url: null,
|
|
2924
2924
|
at: 0
|
|
2925
|
-
}),
|
|
2925
|
+
}), it = o((e, t) => {
|
|
2926
2926
|
let n = e;
|
|
2927
2927
|
try {
|
|
2928
2928
|
n = new URL(e, window.location.origin).href;
|
|
2929
2929
|
} catch {}
|
|
2930
|
-
let r =
|
|
2930
|
+
let r = W.current;
|
|
2931
2931
|
return r.url === n && Date.now() - r.at < 4e3 ? Promise.resolve({
|
|
2932
2932
|
navigated: !0,
|
|
2933
2933
|
deduped: !0
|
|
2934
|
-
}) : (
|
|
2934
|
+
}) : (W.current = {
|
|
2935
2935
|
url: n,
|
|
2936
2936
|
at: Date.now()
|
|
2937
2937
|
}, br(e, t));
|
|
2938
|
-
}, []),
|
|
2938
|
+
}, []), at = p([]), G = p(null), ot = p(null), st = p(null), ct = p(!1), lt = p(!1), ut = p(""), dt = p(null), ft = p(null), pt = p([]), mt = p(0), ht = p(ie), gt = p([]), _t = p(!1), vt = p(!1), yt = p(i), bt = p({
|
|
2939
2939
|
notifyRouteChange: () => {},
|
|
2940
2940
|
cleanup: () => {}
|
|
2941
|
-
}),
|
|
2941
|
+
}), xt = o((e = {}) => {
|
|
2942
2942
|
let t = !!e.is_human_handled;
|
|
2943
|
-
return A(t), t ? (O("agent"), e.agent_info?.name &&
|
|
2944
|
-
}, []),
|
|
2943
|
+
return A(t), t ? (O("agent"), e.agent_info?.name && M(e.agent_info.name), e.agent_info?.headshot && ce(e.agent_info.headshot), t) : (O("ai"), t);
|
|
2944
|
+
}, []), St = f(() => {
|
|
2945
2945
|
let e = _?.widgetSettings?.call?.maxDurationSeconds ?? i?.widgetSettings?.call?.maxDurationSeconds ?? i?.callMaxDurationSeconds, t = Number(e);
|
|
2946
2946
|
return Number.isFinite(t) && t > 0 ? t : ne;
|
|
2947
2947
|
}, [i, _]);
|
|
2948
2948
|
c(() => {
|
|
2949
|
-
|
|
2950
|
-
}, [
|
|
2951
|
-
|
|
2949
|
+
$e.current = z;
|
|
2950
|
+
}, [z]), c(() => {
|
|
2951
|
+
ht.current = ie;
|
|
2952
2952
|
}, [ie]), c(() => {
|
|
2953
|
-
|
|
2954
|
-
}, [
|
|
2955
|
-
|
|
2953
|
+
vt.current = I;
|
|
2954
|
+
}, [I]), c(() => {
|
|
2955
|
+
yt.current = i;
|
|
2956
2956
|
}, [i]);
|
|
2957
|
-
let
|
|
2958
|
-
|
|
2959
|
-
},
|
|
2960
|
-
|
|
2961
|
-
}, []),
|
|
2957
|
+
let Ct = () => {
|
|
2958
|
+
qe("");
|
|
2959
|
+
}, wt = o(() => {
|
|
2960
|
+
st.current &&= (window.clearTimeout(st.current), null);
|
|
2961
|
+
}, []), Tt = (e) => {
|
|
2962
2962
|
let t = typeof e == "string" ? e.trim().toLowerCase() : "";
|
|
2963
|
-
return
|
|
2963
|
+
return _e(t), ge(t, i?.siteId), t;
|
|
2964
2964
|
};
|
|
2965
2965
|
c(() => {
|
|
2966
2966
|
let e = i?.siteId;
|
|
2967
2967
|
if (!e) return;
|
|
2968
|
-
let t =
|
|
2968
|
+
let t = he(e);
|
|
2969
2969
|
if (t) {
|
|
2970
|
-
|
|
2970
|
+
_e(t);
|
|
2971
2971
|
return;
|
|
2972
2972
|
}
|
|
2973
|
-
|
|
2973
|
+
_e((t) => (t && ge(t, e), t));
|
|
2974
2974
|
}, [i?.siteId]);
|
|
2975
|
-
let
|
|
2976
|
-
let t =
|
|
2977
|
-
if (
|
|
2975
|
+
let Et = (e = "unspecified") => {
|
|
2976
|
+
let t = G.current || tt.current?.callId, n = mt.current, r = dt.current;
|
|
2977
|
+
if (dt.current = null, mt.current = 0, r && r.state !== "inactive") {
|
|
2978
2978
|
r.onstop = () => {
|
|
2979
|
-
let e =
|
|
2980
|
-
if (
|
|
2979
|
+
let e = pt.current;
|
|
2980
|
+
if (pt.current = [], e.length > 0 && t && V.current) {
|
|
2981
2981
|
let r = new Blob(e, { type: e[0].type }), i = n > 0 ? Math.round((Date.now() - n) / 1e3) : 0;
|
|
2982
|
-
|
|
2982
|
+
V.current.uploadRecording(t, r, i).then((e) => console.log("[FlowEngageCall] recording upload success", e)).catch((e) => console.warn("[FlowEngageCall] recording upload failed", e));
|
|
2983
2983
|
}
|
|
2984
2984
|
};
|
|
2985
2985
|
try {
|
|
2986
2986
|
r.stop();
|
|
2987
2987
|
} catch {
|
|
2988
|
-
r.onstop = null,
|
|
2988
|
+
r.onstop = null, pt.current = [];
|
|
2989
2989
|
}
|
|
2990
2990
|
} else if (r && r.state === "inactive") {
|
|
2991
|
-
let e =
|
|
2992
|
-
if (
|
|
2991
|
+
let e = pt.current;
|
|
2992
|
+
if (pt.current = [], e.length > 0 && t && V.current) {
|
|
2993
2993
|
let r = new Blob(e, { type: e[0].type }), i = n > 0 ? Math.round((Date.now() - n) / 1e3) : 0;
|
|
2994
|
-
|
|
2994
|
+
V.current.uploadRecording(t, r, i).then((e) => console.log("[FlowEngageCall] recording upload success", e)).catch((e) => console.warn("[FlowEngageCall] recording upload failed", e));
|
|
2995
2995
|
}
|
|
2996
|
-
} else
|
|
2997
|
-
if (
|
|
2996
|
+
} else pt.current = [];
|
|
2997
|
+
if (ft.current) {
|
|
2998
2998
|
try {
|
|
2999
|
-
|
|
2999
|
+
ft.current.close();
|
|
3000
3000
|
} catch {}
|
|
3001
|
-
|
|
3001
|
+
ft.current = null;
|
|
3002
3002
|
}
|
|
3003
|
-
|
|
3003
|
+
et.current &&= (et.current.close(), null), H.current &&= (H.current.getTracks().forEach((e) => e.stop()), null), U.current &&= (U.current.srcObject = null, U.current.remove(), null), wt(), tt.current = null, at.current = [], G.current = null, ot.current = null, ct.current = !1, Ge(!1), Le(null), ze(null), Ve("idle"), Ue(null);
|
|
3004
3004
|
}, Dt = (e = (/* @__PURE__ */ new Date()).toISOString()) => {
|
|
3005
|
-
let t =
|
|
3006
|
-
if (!(!t?.connected || !n ||
|
|
3007
|
-
|
|
3005
|
+
let t = B.current, n = G.current || tt.current?.callId;
|
|
3006
|
+
if (!(!t?.connected || !n || ct.current)) {
|
|
3007
|
+
ct.current = !0, t.emit("call:connected", {
|
|
3008
3008
|
callId: n,
|
|
3009
|
-
chatId:
|
|
3009
|
+
chatId: Xe.current,
|
|
3010
3010
|
connectedAt: e
|
|
3011
3011
|
});
|
|
3012
3012
|
try {
|
|
3013
|
-
let e =
|
|
3014
|
-
if (e && t && !
|
|
3015
|
-
|
|
3013
|
+
let e = H.current, t = U.current?.srcObject;
|
|
3014
|
+
if (e && t && !dt.current) {
|
|
3015
|
+
pt.current = [];
|
|
3016
3016
|
let n = new (window.AudioContext || window.webkitAudioContext)();
|
|
3017
|
-
|
|
3017
|
+
ft.current = n;
|
|
3018
3018
|
let r = n.createMediaStreamDestination();
|
|
3019
3019
|
n.createMediaStreamSource(e).connect(r), n.createMediaStreamSource(t).connect(r);
|
|
3020
3020
|
let i = window.MediaRecorder.isTypeSupported("audio/webm") ? "audio/webm" : "audio/mp4", a = new window.MediaRecorder(r.stream, { mimeType: i });
|
|
3021
3021
|
a.ondataavailable = (e) => {
|
|
3022
|
-
e.data && e.data.size > 0 &&
|
|
3023
|
-
},
|
|
3022
|
+
e.data && e.data.size > 0 && pt.current.push(e.data);
|
|
3023
|
+
}, dt.current = a, mt.current = Date.now(), a.start(1e3), setTimeout(() => {
|
|
3024
3024
|
try {
|
|
3025
3025
|
if (!window.speechSynthesis) return;
|
|
3026
3026
|
let e = new SpeechSynthesisUtterance("This call is being recorded for quality and training purposes.");
|
|
@@ -3050,80 +3050,80 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3050
3050
|
}
|
|
3051
3051
|
}, Ot = (e = {}) => {
|
|
3052
3052
|
if (!e.callId) return;
|
|
3053
|
-
let t =
|
|
3053
|
+
let t = ot.current === e.callId, n = G.current === e.callId, r = $e.current?.callId === e.callId;
|
|
3054
3054
|
if (!(!t && !n && !r)) {
|
|
3055
|
-
if (
|
|
3056
|
-
|
|
3055
|
+
if (wt(), Le(null), t || n) {
|
|
3056
|
+
G.current = e.callId, ze(e.callId), Ve((e) => e === "connected" ? e : "connecting"), D(!0);
|
|
3057
3057
|
return;
|
|
3058
3058
|
}
|
|
3059
|
-
|
|
3059
|
+
Ve("idle");
|
|
3060
3060
|
}
|
|
3061
3061
|
}, kt = (e = {}) => {
|
|
3062
3062
|
if (!e.callId) return;
|
|
3063
|
-
let t =
|
|
3063
|
+
let t = ot.current === e.callId, n = G.current === e.callId, r = $e.current?.callId === e.callId;
|
|
3064
3064
|
if (!(!t && !n && !r)) {
|
|
3065
|
-
if (
|
|
3066
|
-
|
|
3065
|
+
if (wt(), n) {
|
|
3066
|
+
Et();
|
|
3067
3067
|
return;
|
|
3068
3068
|
}
|
|
3069
|
-
|
|
3069
|
+
ot.current = null, tt.current = null, at.current = [], Le(null), Ve("idle");
|
|
3070
3070
|
}
|
|
3071
3071
|
}, At = async (e = {}) => {
|
|
3072
|
-
let t =
|
|
3072
|
+
let t = et.current, n = B.current, r = e.sdpOffer || e.offer?.sdp;
|
|
3073
3073
|
if (!t || !n?.connected || !r || !e.callId) {
|
|
3074
3074
|
console.log("[FlowEngageProvider] deferring remote offer until peer/socket ready", {
|
|
3075
3075
|
callId: e.callId,
|
|
3076
|
-
chatId:
|
|
3076
|
+
chatId: Xe.current,
|
|
3077
3077
|
hasPeerConnection: !!t,
|
|
3078
3078
|
socketConnected: !!n?.connected,
|
|
3079
3079
|
hasOffer: !!r
|
|
3080
|
-
}),
|
|
3080
|
+
}), tt.current = e;
|
|
3081
3081
|
return;
|
|
3082
3082
|
}
|
|
3083
3083
|
if (await t.setRemoteDescription(new RTCSessionDescription({
|
|
3084
3084
|
type: "offer",
|
|
3085
3085
|
sdp: r
|
|
3086
|
-
})),
|
|
3086
|
+
})), at.current.length > 0) {
|
|
3087
3087
|
console.log("[FlowEngageProvider] flushing queued agent ICE candidates after remote offer", {
|
|
3088
3088
|
callId: e.callId,
|
|
3089
|
-
chatId:
|
|
3090
|
-
queuedCount:
|
|
3089
|
+
chatId: Xe.current,
|
|
3090
|
+
queuedCount: at.current.length
|
|
3091
3091
|
});
|
|
3092
|
-
for (let e of
|
|
3093
|
-
|
|
3092
|
+
for (let e of at.current) await t.addIceCandidate(new RTCIceCandidate(e));
|
|
3093
|
+
at.current = [];
|
|
3094
3094
|
}
|
|
3095
3095
|
let i = await t.createAnswer();
|
|
3096
3096
|
await t.setLocalDescription(i), n.emit("call:answer", {
|
|
3097
3097
|
callId: e.callId,
|
|
3098
3098
|
sdpAnswer: i.sdp,
|
|
3099
|
-
chatId:
|
|
3099
|
+
chatId: Xe.current
|
|
3100
3100
|
});
|
|
3101
3101
|
};
|
|
3102
3102
|
c(() => {
|
|
3103
|
-
|
|
3103
|
+
me({
|
|
3104
3104
|
isOpen: T,
|
|
3105
3105
|
activeScreen: ee,
|
|
3106
3106
|
isHumanHandled: k,
|
|
3107
3107
|
agentName: ie,
|
|
3108
|
-
agentHeadshot:
|
|
3108
|
+
agentHeadshot: se
|
|
3109
3109
|
});
|
|
3110
3110
|
}, [
|
|
3111
3111
|
T,
|
|
3112
3112
|
ee,
|
|
3113
3113
|
k,
|
|
3114
3114
|
ie,
|
|
3115
|
-
|
|
3115
|
+
se
|
|
3116
3116
|
]), c(() => {
|
|
3117
3117
|
let e = !0;
|
|
3118
3118
|
return (async () => {
|
|
3119
|
-
|
|
3119
|
+
Ye(!0);
|
|
3120
3120
|
try {
|
|
3121
|
-
let t = E(i), n = await
|
|
3121
|
+
let t = E(i), n = await Fe(t);
|
|
3122
3122
|
if (!e) return;
|
|
3123
|
-
let a = t.siteId, o =
|
|
3123
|
+
let a = t.siteId, o = ue(a), s = ye(a), c = "";
|
|
3124
3124
|
try {
|
|
3125
|
-
let e =
|
|
3126
|
-
if (
|
|
3125
|
+
let e = Ze.current, r = Qe.current;
|
|
3126
|
+
if (Ze.current = !1, Qe.current = null, c = (await Pe({
|
|
3127
3127
|
apiBaseUrl: t.apiBaseUrl,
|
|
3128
3128
|
userId: n.userId,
|
|
3129
3129
|
siteId: a,
|
|
@@ -3132,18 +3132,18 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3132
3132
|
resumeChatId: r,
|
|
3133
3133
|
visitorId: s
|
|
3134
3134
|
}))?.data?.chatId, !c) throw Error("resolve-session returned no chatId");
|
|
3135
|
-
oe(),
|
|
3135
|
+
oe(), fe(a, c);
|
|
3136
3136
|
} catch (e) {
|
|
3137
|
-
console.warn("[FlowEngageProvider] resolve-session failed, reusing persisted or ephemeral chat id", e?.message || e), c = o ||
|
|
3137
|
+
console.warn("[FlowEngageProvider] resolve-session failed, reusing persisted or ephemeral chat id", e?.message || e), c = o || j(), fe(a, c);
|
|
3138
3138
|
}
|
|
3139
|
-
|
|
3140
|
-
let l =
|
|
3139
|
+
Xe.current = c;
|
|
3140
|
+
let l = Ie({
|
|
3141
3141
|
apiBaseUrl: t.apiBaseUrl,
|
|
3142
3142
|
userId: n.userId,
|
|
3143
3143
|
siteId: t.siteId,
|
|
3144
3144
|
visitorId: s
|
|
3145
3145
|
});
|
|
3146
|
-
|
|
3146
|
+
V.current = l, v({
|
|
3147
3147
|
...n,
|
|
3148
3148
|
apiBaseUrl: t.apiBaseUrl
|
|
3149
3149
|
}), b(c);
|
|
@@ -3153,24 +3153,24 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3153
3153
|
chatId: c,
|
|
3154
3154
|
siteId: t.siteId
|
|
3155
3155
|
});
|
|
3156
|
-
|
|
3157
|
-
|
|
3158
|
-
let e =
|
|
3159
|
-
if (e &&
|
|
3160
|
-
|
|
3156
|
+
B.current = f, f.on("connect", async () => {
|
|
3157
|
+
Ce("connected");
|
|
3158
|
+
let e = Xe.current;
|
|
3159
|
+
if (e && V.current) try {
|
|
3160
|
+
xt(await V.current.checkHumanHandled(e));
|
|
3161
3161
|
} catch {}
|
|
3162
3162
|
}), f.on("disconnect", () => {
|
|
3163
|
-
|
|
3163
|
+
Ce("disconnected");
|
|
3164
3164
|
}), f.on("aiTyping", () => {
|
|
3165
|
-
|
|
3165
|
+
xe(!0);
|
|
3166
3166
|
}), f.on("ai:typing", () => {
|
|
3167
|
-
|
|
3167
|
+
xe(!0);
|
|
3168
3168
|
}), f.on("messageReceived", (e) => {
|
|
3169
3169
|
let t = e.message || e, n = {
|
|
3170
3170
|
...t,
|
|
3171
3171
|
message: Tr(t.message)
|
|
3172
3172
|
};
|
|
3173
|
-
|
|
3173
|
+
xe(!1), ve(!1), !(n.type === "call_recording" || typeof n.message == "string" && n.message.includes("AI chat recording")) && S((e) => [...e.filter((e) => !e.isPending), {
|
|
3174
3174
|
...n,
|
|
3175
3175
|
isPending: !1,
|
|
3176
3176
|
id: n.messageId || `${n.sender}-${Date.now()}-${Math.random()}`
|
|
@@ -3188,7 +3188,7 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3188
3188
|
...t,
|
|
3189
3189
|
message: Tr(t.message)
|
|
3190
3190
|
};
|
|
3191
|
-
|
|
3191
|
+
xe(!1), !(n.type === "call_recording" || typeof n.message == "string" && n.message.includes("AI chat recording")) && ((n.sender === "agent" || n.agent_name || n.sender === "ai" || n.sender === "bot") && ve(!1), S((e) => n.sender === "bot" || n.sender === "ai" ? [...e, {
|
|
3192
3192
|
...n,
|
|
3193
3193
|
isPending: !1,
|
|
3194
3194
|
id: n.messageId || `${n.sender}-${Date.now()}-${Math.random()}`
|
|
@@ -3200,20 +3200,20 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3200
3200
|
...n,
|
|
3201
3201
|
isPending: !1,
|
|
3202
3202
|
id: n.messageId || `${n.sender}-${Date.now()}-${Math.random()}`
|
|
3203
|
-
}]), (n.sender === "agent" || n.agent_name) && (A(!0), O("agent"),
|
|
3203
|
+
}]), (n.sender === "agent" || n.agent_name) && (A(!0), O("agent"), M(Ar([
|
|
3204
3204
|
n.agent_name,
|
|
3205
3205
|
n.agentName,
|
|
3206
3206
|
n.metadata?.agentName
|
|
3207
|
-
], d)), n.sender_headshot &&
|
|
3207
|
+
], d)), n.sender_headshot && ce(n.sender_headshot), D(!0), je((e) => e + 1)));
|
|
3208
3208
|
});
|
|
3209
3209
|
let p = (e = {}) => {
|
|
3210
3210
|
let t = Ar([
|
|
3211
3211
|
e.agent?.name,
|
|
3212
3212
|
e.agentName,
|
|
3213
3213
|
e.agent_name,
|
|
3214
|
-
|
|
3214
|
+
ht.current
|
|
3215
3215
|
], d);
|
|
3216
|
-
A(!0), O("agent"),
|
|
3216
|
+
A(!0), O("agent"), M(t), ce(e.agent?.headshot || null), D(!0), je((e) => e + 1), S((e) => jr(e, {
|
|
3217
3217
|
id: `agent-joined-${Date.now()}`,
|
|
3218
3218
|
sender: "system",
|
|
3219
3219
|
message: `${t} has joined the chat.`,
|
|
@@ -3225,7 +3225,7 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3225
3225
|
e.agent?.name,
|
|
3226
3226
|
e.agentName,
|
|
3227
3227
|
e.agent_name,
|
|
3228
|
-
|
|
3228
|
+
ht.current
|
|
3229
3229
|
], d);
|
|
3230
3230
|
A(!1), O("ai"), S((e) => jr(e, {
|
|
3231
3231
|
id: `agent-left-${Date.now()}`,
|
|
@@ -3236,7 +3236,7 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3236
3236
|
}));
|
|
3237
3237
|
};
|
|
3238
3238
|
f.on("agent:joined", p), f.on("agentJoined", p), f.on("agent:left", m), f.on("agentLeft", m), f.on("conversationEnded", (e) => {
|
|
3239
|
-
|
|
3239
|
+
R(!0);
|
|
3240
3240
|
let t = e?.message || "This conversation has ended. Thank you for reaching out!";
|
|
3241
3241
|
S((e) => [...e, {
|
|
3242
3242
|
id: `conversation-ended-${Date.now()}`,
|
|
@@ -3247,30 +3247,30 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3247
3247
|
}]);
|
|
3248
3248
|
}), f.on("chat:history_update", (e) => {
|
|
3249
3249
|
let t = Er(e.chat_history || []);
|
|
3250
|
-
S(t), t.length === 0 && (
|
|
3250
|
+
S(t), t.length === 0 && (R(!1), A(!1), O("ai"), xe(!1), ve(!1));
|
|
3251
3251
|
}), f.on("conversation:reset", () => {
|
|
3252
|
-
S([]),
|
|
3252
|
+
S([]), R(!1), A(!1), O("ai"), xe(!1), ve(!1);
|
|
3253
3253
|
}), f.on("voice:end_session", (e = {}) => {
|
|
3254
|
-
console.log("[FlowEngageProvider] voice:end_session received — ending voice session"), Ne((e) => e + 1), D(!0),
|
|
3254
|
+
console.log("[FlowEngageProvider] voice:end_session received — ending voice session"), Ne((e) => e + 1), D(!0), je((e) => e + 1);
|
|
3255
3255
|
}), f.on("typing:start", (e) => {
|
|
3256
|
-
e.sender === "agent" &&
|
|
3256
|
+
e.sender === "agent" && ve(!0);
|
|
3257
3257
|
}), f.on("typing:stop", (e) => {
|
|
3258
|
-
e.sender === "agent" &&
|
|
3258
|
+
e.sender === "agent" && ve(!1);
|
|
3259
3259
|
}), f.on("call:incoming", (e = {}) => {
|
|
3260
3260
|
let t = Ar([
|
|
3261
3261
|
e.agentName,
|
|
3262
3262
|
e.ownerName,
|
|
3263
3263
|
e.agent?.name,
|
|
3264
|
-
|
|
3264
|
+
ht.current
|
|
3265
3265
|
], "Agent");
|
|
3266
|
-
|
|
3266
|
+
Ct(), wt(), ct.current = !1, Le({
|
|
3267
3267
|
callId: e.callId,
|
|
3268
3268
|
from: e.from || "owner",
|
|
3269
3269
|
agentId: e.agentId || null,
|
|
3270
3270
|
agentName: t
|
|
3271
|
-
}),
|
|
3271
|
+
}), M((e) => Ar([t, e], "Agent")), Ve("incoming"), Ue(null), D(!0);
|
|
3272
3272
|
}), f.on("call:offer", async (e = {}) => {
|
|
3273
|
-
|
|
3273
|
+
tt.current = e;
|
|
3274
3274
|
try {
|
|
3275
3275
|
await At(e);
|
|
3276
3276
|
} catch (e) {
|
|
@@ -3283,20 +3283,20 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3283
3283
|
console.warn("[FlowEngageProvider] ignoring invalid ICE candidate payload", e);
|
|
3284
3284
|
return;
|
|
3285
3285
|
}
|
|
3286
|
-
if (!
|
|
3286
|
+
if (!et.current || !et.current.remoteDescription) {
|
|
3287
3287
|
console.log("[FlowEngageProvider] queueing agent ICE candidate until peer/remote description is ready", {
|
|
3288
3288
|
callId: e.callId,
|
|
3289
|
-
chatId: e.chatId ||
|
|
3290
|
-
queueSize:
|
|
3291
|
-
}),
|
|
3289
|
+
chatId: e.chatId || Xe.current,
|
|
3290
|
+
queueSize: at.current.length + 1
|
|
3291
|
+
}), at.current.push(t);
|
|
3292
3292
|
return;
|
|
3293
3293
|
}
|
|
3294
|
-
await
|
|
3294
|
+
await et.current.addIceCandidate(new RTCIceCandidate(t));
|
|
3295
3295
|
} catch (e) {
|
|
3296
3296
|
console.error("[FlowEngageProvider] failed to add ICE candidate", e);
|
|
3297
3297
|
}
|
|
3298
3298
|
}), f.on("call:ended", () => {
|
|
3299
|
-
|
|
3299
|
+
Ct(), Et("socket:call_ended");
|
|
3300
3300
|
}), f.on("call:accepted", (e = {}) => {
|
|
3301
3301
|
Ot(e);
|
|
3302
3302
|
}), f.on("call:accepted_by_other", (e = {}) => {
|
|
@@ -3309,18 +3309,18 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3309
3309
|
kt(e);
|
|
3310
3310
|
}), f.on("call:connected", (e = {}) => {
|
|
3311
3311
|
if (!e.callId) return;
|
|
3312
|
-
let t =
|
|
3312
|
+
let t = ot.current === e.callId, n = G.current === e.callId, r = tt.current?.callId === e.callId, i = $e.current?.callId === e.callId;
|
|
3313
3313
|
if (!t && !n && !r) {
|
|
3314
|
-
i && (
|
|
3314
|
+
i && (Le(null), Ve("idle"));
|
|
3315
3315
|
return;
|
|
3316
3316
|
}
|
|
3317
|
-
|
|
3317
|
+
ct.current = !0, ot.current = null, G.current = e.callId, ze(e.callId), Le(null), Ve("connected"), Ue(e.connectedAt || (/* @__PURE__ */ new Date()).toISOString()), D(!0);
|
|
3318
3318
|
}), f.on("call:unavailable", (e = {}) => {
|
|
3319
|
-
|
|
3319
|
+
Et("socket:call_unavailable"), qe(Or(e, "This visitor is not available for a call right now.")), D(!0);
|
|
3320
3320
|
}), f.on("call:error", (e = {}) => {
|
|
3321
|
-
|
|
3321
|
+
Et("socket:call_error"), qe(Or(e, "We couldn't connect the call right now.")), D(!0);
|
|
3322
3322
|
}), f.on("visitor:navigate", async ({ url: e, section: t, highlight: n } = {}) => {
|
|
3323
|
-
e &&
|
|
3323
|
+
e && it(e, { voiceActive: vt.current }).then(({ navigated: e, reason: r }) => {
|
|
3324
3324
|
if (!e) {
|
|
3325
3325
|
r === "not-found" ? C() : r === "already-on-page" && w();
|
|
3326
3326
|
return;
|
|
@@ -3337,7 +3337,7 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3337
3337
|
n && lr(n);
|
|
3338
3338
|
}), f.on("visitor:clear_highlight", () => {
|
|
3339
3339
|
ur();
|
|
3340
|
-
}),
|
|
3340
|
+
}), bt.current = xn({
|
|
3341
3341
|
socket: f,
|
|
3342
3342
|
chatId: c
|
|
3343
3343
|
});
|
|
@@ -3345,83 +3345,83 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3345
3345
|
if (!e) return;
|
|
3346
3346
|
S(Er(h.chat_history || [])), A(!!h.is_human_handled), O(h.is_human_handled ? "agent" : ee);
|
|
3347
3347
|
let g = h?.visitor_email || h?.visitorEmail;
|
|
3348
|
-
if (g && String(g).trim() &&
|
|
3348
|
+
if (g && String(g).trim() && Tt(String(g).trim()), await new Promise((e) => setTimeout(e, 500)), !e) return;
|
|
3349
3349
|
u("ready");
|
|
3350
3350
|
} catch (t) {
|
|
3351
3351
|
if (!e) return;
|
|
3352
3352
|
h(t), u("error");
|
|
3353
3353
|
} finally {
|
|
3354
|
-
e &&
|
|
3354
|
+
e && Ye(!1);
|
|
3355
3355
|
}
|
|
3356
3356
|
})(), () => {
|
|
3357
|
-
e = !1,
|
|
3357
|
+
e = !1, bt.current?.cleanup?.(), Et(), B.current?.disconnect();
|
|
3358
3358
|
};
|
|
3359
3359
|
}, [
|
|
3360
3360
|
i,
|
|
3361
3361
|
r,
|
|
3362
3362
|
a
|
|
3363
3363
|
]), c(() => () => {
|
|
3364
|
-
if (
|
|
3365
|
-
let e =
|
|
3366
|
-
n && e && t.length > 0 && (console.log("[FlowEngageProvider] safety-net: syncing voice transcript on unmount"), n.beaconSyncVoice(e, t) || n.syncVoice(e, t).catch(() => {}),
|
|
3364
|
+
if (I && !_t.current && gt.current.length > 0) {
|
|
3365
|
+
let e = Xe.current, t = gt.current, n = V.current;
|
|
3366
|
+
n && e && t.length > 0 && (console.log("[FlowEngageProvider] safety-net: syncing voice transcript on unmount"), n.beaconSyncVoice(e, t) || n.syncVoice(e, t).catch(() => {}), _t.current = !0);
|
|
3367
3367
|
}
|
|
3368
|
-
}, [
|
|
3368
|
+
}, [I, _]);
|
|
3369
3369
|
let jt = p(null);
|
|
3370
3370
|
c(() => {
|
|
3371
|
-
let e =
|
|
3371
|
+
let e = V.current;
|
|
3372
3372
|
!e || !y || jt.current !== T && (T && jt.current !== null ? e.updateChatStatus(y, "open").catch(() => {}) : jt.current === !0 && e.updateChatStatus(y, "widget_closed").catch(() => {}), jt.current = T);
|
|
3373
3373
|
}, [T, y]), c(() => {
|
|
3374
3374
|
let e = () => {
|
|
3375
|
-
let e =
|
|
3375
|
+
let e = Xe.current, t = V.current;
|
|
3376
3376
|
!e || !t || typeof navigator > "u" || t.beaconWidgetClosed?.(e) || t.updateChatStatus(e, "widget_closed").catch(() => {});
|
|
3377
3377
|
};
|
|
3378
3378
|
return window.addEventListener("pagehide", e), () => window.removeEventListener("pagehide", e);
|
|
3379
3379
|
}, []);
|
|
3380
3380
|
let Mt = async () => {
|
|
3381
|
-
if (!(!
|
|
3382
|
-
|
|
3381
|
+
if (!(!z?.callId || !V.current || !B.current || !y)) {
|
|
3382
|
+
Ct(), ot.current = z.callId, wt();
|
|
3383
3383
|
try {
|
|
3384
3384
|
let e = await navigator.mediaDevices.getUserMedia({ audio: !0 });
|
|
3385
|
-
|
|
3385
|
+
H.current = e;
|
|
3386
3386
|
let t = [{ urls: "stun:stun.l.google.com:19302" }];
|
|
3387
3387
|
try {
|
|
3388
|
-
let e = await
|
|
3388
|
+
let e = await V.current.getIceServersConfig();
|
|
3389
3389
|
e?.data?.iceServers?.length && (t = e.data.iceServers);
|
|
3390
3390
|
} catch (e) {
|
|
3391
3391
|
console.warn("[FlowEngageProvider] ice-config fetch failed, using STUN default", e);
|
|
3392
3392
|
}
|
|
3393
3393
|
let n = new RTCPeerConnection({ iceServers: t });
|
|
3394
|
-
|
|
3394
|
+
et.current = n, n.onconnectionstatechange = () => {
|
|
3395
3395
|
let e = n.connectionState;
|
|
3396
3396
|
if (e === "connected") {
|
|
3397
3397
|
let e = (/* @__PURE__ */ new Date()).toISOString();
|
|
3398
|
-
|
|
3398
|
+
Ve("connected"), Ue((t) => t || e), Dt(e);
|
|
3399
3399
|
return;
|
|
3400
3400
|
}
|
|
3401
3401
|
if (e === "connecting") {
|
|
3402
|
-
|
|
3402
|
+
Ve((e) => e === "connected" ? e : "connecting");
|
|
3403
3403
|
return;
|
|
3404
3404
|
}
|
|
3405
|
-
(e === "failed" || e === "closed") &&
|
|
3405
|
+
(e === "failed" || e === "closed") && Et(`peer:connection_${e}`);
|
|
3406
3406
|
}, n.oniceconnectionstatechange = () => {
|
|
3407
3407
|
let e = n.iceConnectionState;
|
|
3408
3408
|
if (e === "connected" || e === "completed") {
|
|
3409
3409
|
let e = (/* @__PURE__ */ new Date()).toISOString();
|
|
3410
|
-
|
|
3410
|
+
Ve("connected"), Ue((t) => t || e), Dt(e);
|
|
3411
3411
|
return;
|
|
3412
3412
|
}
|
|
3413
3413
|
if (e === "checking" || e === "new") {
|
|
3414
|
-
|
|
3414
|
+
Ve((e) => e === "connected" ? e : "connecting");
|
|
3415
3415
|
return;
|
|
3416
3416
|
}
|
|
3417
|
-
(e === "failed" || e === "closed") &&
|
|
3417
|
+
(e === "failed" || e === "closed") && Et(`peer:ice_${e}`);
|
|
3418
3418
|
}, n.onsignalingstatechange = () => {}, n.onicegatheringstatechange = () => {}, e.getTracks().forEach((t) => {
|
|
3419
3419
|
n.addTrack(t, e);
|
|
3420
3420
|
}), n.onicecandidate = (e) => {
|
|
3421
|
-
if (!e.candidate || !
|
|
3421
|
+
if (!e.candidate || !B.current?.connected) return;
|
|
3422
3422
|
let t = e.candidate;
|
|
3423
|
-
|
|
3424
|
-
callId:
|
|
3423
|
+
B.current.emit("call:ice-candidate", {
|
|
3424
|
+
callId: z.callId,
|
|
3425
3425
|
candidate: t.candidate,
|
|
3426
3426
|
sdpMid: t.sdpMid,
|
|
3427
3427
|
sdpMLineIndex: t.sdpMLineIndex,
|
|
@@ -3430,122 +3430,122 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3430
3430
|
});
|
|
3431
3431
|
}, n.ontrack = (e) => {
|
|
3432
3432
|
let [t] = e.streams || [], [n] = t?.getAudioTracks?.() || [];
|
|
3433
|
-
if (!
|
|
3433
|
+
if (!U.current) {
|
|
3434
3434
|
let e = document.createElement("audio");
|
|
3435
|
-
e.id = "flowengage-remote-audio", e.autoplay = !0, e.playsInline = !0, e.onplay = () => {}, e.onpause = () => {}, e.onended = () => {}, e.onerror = (e) => {},
|
|
3435
|
+
e.id = "flowengage-remote-audio", e.autoplay = !0, e.playsInline = !0, e.onplay = () => {}, e.onpause = () => {}, e.onended = () => {}, e.onerror = (e) => {}, U.current = e, document.body.appendChild(e);
|
|
3436
3436
|
}
|
|
3437
|
-
|
|
3438
|
-
let r =
|
|
3439
|
-
if (!
|
|
3437
|
+
U.current.srcObject = e.streams[0];
|
|
3438
|
+
let r = z?.callId, i = r && (ot.current === r || G.current === r);
|
|
3439
|
+
if (!ct.current && i) {
|
|
3440
3440
|
let e = (/* @__PURE__ */ new Date()).toISOString();
|
|
3441
|
-
|
|
3441
|
+
Ve("connected"), Ue((t) => t || e), G.current = r, ze(r), Dt(e);
|
|
3442
3442
|
}
|
|
3443
|
-
|
|
3444
|
-
let a =
|
|
3443
|
+
U.current.srcObject = t || null;
|
|
3444
|
+
let a = U.current.play?.();
|
|
3445
3445
|
a?.catch && a.catch((e) => {});
|
|
3446
3446
|
};
|
|
3447
|
-
let r =
|
|
3447
|
+
let r = tt.current;
|
|
3448
3448
|
r && (console.log("[FlowEngageProvider] found pending remote offer during accept", {
|
|
3449
|
-
callId: r.callId ||
|
|
3449
|
+
callId: r.callId || z.callId,
|
|
3450
3450
|
chatId: y
|
|
3451
3451
|
}), await At({
|
|
3452
3452
|
...r,
|
|
3453
|
-
callId: r.callId ||
|
|
3454
|
-
})), await
|
|
3455
|
-
callId:
|
|
3453
|
+
callId: r.callId || z.callId
|
|
3454
|
+
})), await V.current.acceptCall(z.callId, y), B.current?.emit("call:accepted", {
|
|
3455
|
+
callId: z.callId,
|
|
3456
3456
|
chatId: y
|
|
3457
|
-
}),
|
|
3457
|
+
}), G.current = z.callId, ze(z.callId), Ve((e) => e === "connected" || ct.current ? "connected" : "connecting"), Le(null), D(!0);
|
|
3458
3458
|
} catch (e) {
|
|
3459
|
-
if (
|
|
3460
|
-
|
|
3459
|
+
if (ot.current = null, Et("accept_call_failed"), e?.status === 404 || e?.status === 409 || e?.status === 422) {
|
|
3460
|
+
qe(Or(e, "This visitor call is no longer available."));
|
|
3461
3461
|
return;
|
|
3462
3462
|
}
|
|
3463
3463
|
if (e?.name === "NotAllowedError" || e?.name === "PermissionDeniedError") {
|
|
3464
3464
|
try {
|
|
3465
|
-
await
|
|
3465
|
+
await V.current.rejectCall(z.callId, y);
|
|
3466
3466
|
} catch (e) {
|
|
3467
3467
|
console.error("[FlowEngageProvider] failed to reject call after microphone denial", e);
|
|
3468
3468
|
}
|
|
3469
|
-
|
|
3469
|
+
qe("Microphone access was denied. Please allow microphone access to accept the call.");
|
|
3470
3470
|
return;
|
|
3471
3471
|
}
|
|
3472
|
-
|
|
3472
|
+
qe("We couldn't connect the call right now. Please try again.");
|
|
3473
3473
|
}
|
|
3474
3474
|
}
|
|
3475
3475
|
}, Nt = async () => {
|
|
3476
|
-
if (!
|
|
3477
|
-
|
|
3476
|
+
if (!z?.callId || !V.current || !y) {
|
|
3477
|
+
Et("reject_call_without_server_context");
|
|
3478
3478
|
return;
|
|
3479
3479
|
}
|
|
3480
|
-
let e =
|
|
3481
|
-
|
|
3480
|
+
let e = z.callId;
|
|
3481
|
+
wt(), Ct(), B.current?.emit("call:rejected", {
|
|
3482
3482
|
callId: e,
|
|
3483
3483
|
chatId: y,
|
|
3484
3484
|
reason: "visitor_declined"
|
|
3485
3485
|
});
|
|
3486
3486
|
try {
|
|
3487
|
-
await
|
|
3487
|
+
await V.current.rejectCall(e, y);
|
|
3488
3488
|
} catch (e) {
|
|
3489
|
-
|
|
3489
|
+
qe(Or(e, "We couldn't decline the call cleanly."));
|
|
3490
3490
|
} finally {
|
|
3491
|
-
|
|
3491
|
+
Et("reject_call_finally");
|
|
3492
3492
|
}
|
|
3493
3493
|
}, Pt = p(Nt);
|
|
3494
3494
|
Pt.current = Nt, c(() => {
|
|
3495
|
-
if (!
|
|
3496
|
-
|
|
3495
|
+
if (!z?.callId || Re) {
|
|
3496
|
+
wt();
|
|
3497
3497
|
return;
|
|
3498
3498
|
}
|
|
3499
|
-
let e =
|
|
3500
|
-
return
|
|
3501
|
-
|
|
3499
|
+
let e = z.callId;
|
|
3500
|
+
return wt(), st.current = window.setTimeout(() => {
|
|
3501
|
+
$e.current?.callId === e && ot.current !== e && G.current !== e && Pt.current();
|
|
3502
3502
|
}, re), () => {
|
|
3503
|
-
|
|
3503
|
+
st.current &&= (window.clearTimeout(st.current), null);
|
|
3504
3504
|
};
|
|
3505
3505
|
}, [
|
|
3506
|
-
|
|
3507
|
-
|
|
3508
|
-
|
|
3506
|
+
Re,
|
|
3507
|
+
wt,
|
|
3508
|
+
z?.callId
|
|
3509
3509
|
]);
|
|
3510
3510
|
let Ft = async () => {
|
|
3511
|
-
if (!
|
|
3512
|
-
|
|
3511
|
+
if (!Re || !V.current || !y) {
|
|
3512
|
+
Et("end_call_without_server_context");
|
|
3513
3513
|
return;
|
|
3514
3514
|
}
|
|
3515
|
-
|
|
3515
|
+
Ct();
|
|
3516
3516
|
try {
|
|
3517
|
-
await
|
|
3517
|
+
await V.current.endWebRTCCall(Re, y);
|
|
3518
3518
|
} catch (e) {
|
|
3519
|
-
|
|
3519
|
+
qe(Or(e, "The call ended locally, but the server could not be updated."));
|
|
3520
3520
|
} finally {
|
|
3521
|
-
|
|
3521
|
+
Et("end_call_finally");
|
|
3522
3522
|
}
|
|
3523
3523
|
}, It = () => {
|
|
3524
|
-
let e =
|
|
3524
|
+
let e = H.current?.getAudioTracks?.() || [], t = et.current?.getSenders?.().map((e) => e.track).filter((e) => e?.kind === "audio") || [], n = [...e, ...t].filter(Boolean);
|
|
3525
3525
|
if (n.length === 0) return;
|
|
3526
|
-
let r = !
|
|
3526
|
+
let r = !We;
|
|
3527
3527
|
n.forEach((e) => {
|
|
3528
3528
|
e.enabled = !r;
|
|
3529
|
-
}),
|
|
3529
|
+
}), Ge(r);
|
|
3530
3530
|
}, Lt = async (e = {}) => {
|
|
3531
3531
|
let t = e.notifyChatInitiated === !0;
|
|
3532
|
-
if (D(!0), !(!t || !
|
|
3532
|
+
if (D(!0), !(!t || !V.current || !y || typeof window > "u")) {
|
|
3533
3533
|
try {
|
|
3534
|
-
await
|
|
3534
|
+
await V.current.trackVisitor({
|
|
3535
3535
|
chatId: y,
|
|
3536
3536
|
currentPagePath: window.location.pathname || "/"
|
|
3537
3537
|
});
|
|
3538
3538
|
} catch {}
|
|
3539
3539
|
try {
|
|
3540
|
-
await
|
|
3540
|
+
await V.current.updateChatStatus(y, "open");
|
|
3541
3541
|
} catch {}
|
|
3542
3542
|
}
|
|
3543
3543
|
}, Rt = async (e) => {
|
|
3544
|
-
let t =
|
|
3545
|
-
if (!t || !
|
|
3544
|
+
let t = Tt(e);
|
|
3545
|
+
if (!t || !V.current || !Xe.current) return t;
|
|
3546
3546
|
try {
|
|
3547
|
-
await
|
|
3548
|
-
chatId:
|
|
3547
|
+
await V.current.trackVisitor({
|
|
3548
|
+
chatId: Xe.current,
|
|
3549
3549
|
currentPagePath: typeof window < "u" && window.location.pathname || "/",
|
|
3550
3550
|
email: t
|
|
3551
3551
|
});
|
|
@@ -3554,18 +3554,18 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3554
3554
|
}
|
|
3555
3555
|
return t;
|
|
3556
3556
|
}, zt = () => {
|
|
3557
|
-
!y || !
|
|
3557
|
+
!y || !B.current?.connected || lt.current || (lt.current = !0, B.current.emit("typing:start", {
|
|
3558
3558
|
chatId: y,
|
|
3559
3559
|
sender: "user"
|
|
3560
3560
|
}));
|
|
3561
3561
|
}, Bt = () => {
|
|
3562
|
-
!y || !
|
|
3562
|
+
!y || !B.current?.connected || !lt.current || (lt.current = !1, B.current.emit("typing:stop", {
|
|
3563
3563
|
chatId: y,
|
|
3564
3564
|
sender: "user"
|
|
3565
3565
|
}));
|
|
3566
3566
|
}, Vt = (e = "") => {
|
|
3567
3567
|
let t = typeof e == "string" ? e : "";
|
|
3568
|
-
!y || !
|
|
3568
|
+
!y || !B.current?.connected || t !== "" && ut.current === t || (ut.current = t, B.current.emit("typing:update", {
|
|
3569
3569
|
chatId: y,
|
|
3570
3570
|
sender: "user",
|
|
3571
3571
|
text: t
|
|
@@ -3584,22 +3584,22 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3584
3584
|
}
|
|
3585
3585
|
let Ut = async (e, t = "", n = null, i = {}) => {
|
|
3586
3586
|
let a = typeof e == "string" ? e.trim() : "";
|
|
3587
|
-
if (!a || !
|
|
3588
|
-
Bt(),
|
|
3587
|
+
if (!a || !V.current || !y || l !== "ready" || L) return;
|
|
3588
|
+
Bt(), rt.current = !1;
|
|
3589
3589
|
let o = /^\s*(yes|yeah|sure|ok|okay|go ahead|take me(?: there)?(?!\s+\w)|navigate(?!\s+(?:me\s+)?to\s+\w)|yep|absolutely|please do|do it|let'?s go|go there|show me(?!\s+(?:the|a|an)\s+\w)|go to it|bring me there|navigate me there)\b/i, s = /^\s*(?:yes|yeah|sure|ok|okay|yep|absolutely)\s+(?!(?:please|do\s+it|let'?s|that|this|there|it|thanks|go|cool|great|perfect|sounds|alright|proceed)\b)\w/i, c = /\b(take me|navigate|go to|show me|bring me|open|go there|navigate to|take me to|let'?s go to)\b/i;
|
|
3590
|
-
if (
|
|
3591
|
-
let { url: e, section: t } =
|
|
3592
|
-
|
|
3590
|
+
if (nt.current && o.test(a) && !s.test(a)) {
|
|
3591
|
+
let { url: e, section: t } = nt.current;
|
|
3592
|
+
nt.current = null, rt.current = !0, console.log("[FWH Nav] Client-side nav firing →", e), it(e, { voiceActive: vt.current }).then(({ navigated: e, reason: n }) => {
|
|
3593
3593
|
if (!e) {
|
|
3594
3594
|
n === "not-found" ? C() : n === "already-on-page" && w();
|
|
3595
3595
|
return;
|
|
3596
3596
|
}
|
|
3597
|
-
!t || !
|
|
3597
|
+
!t || !vt.current || setTimeout(() => {
|
|
3598
3598
|
let e = cr(null, t);
|
|
3599
3599
|
e && lr(e);
|
|
3600
3600
|
}, 300);
|
|
3601
3601
|
});
|
|
3602
|
-
} else o.test(a) || (
|
|
3602
|
+
} else o.test(a) || (nt.current = null);
|
|
3603
3603
|
let u = `pending-user-${Date.now()}`, d = {
|
|
3604
3604
|
id: u,
|
|
3605
3605
|
sender: "user",
|
|
@@ -3613,25 +3613,25 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3613
3613
|
S((e) => [...e, d]);
|
|
3614
3614
|
let f = k;
|
|
3615
3615
|
if (f) try {
|
|
3616
|
-
f =
|
|
3616
|
+
f = xt(await V.current.checkHumanHandled(y));
|
|
3617
3617
|
} catch {}
|
|
3618
|
-
if (f &&
|
|
3619
|
-
|
|
3618
|
+
if (f && B.current?.connected) {
|
|
3619
|
+
B.current.emit("customer:message", {
|
|
3620
3620
|
chatId: y,
|
|
3621
3621
|
content: e,
|
|
3622
3622
|
sender: "user",
|
|
3623
|
-
email:
|
|
3623
|
+
email: le || void 0,
|
|
3624
3624
|
type: i?.type || "text",
|
|
3625
3625
|
metadata: i?.metadata || {},
|
|
3626
3626
|
...n || {}
|
|
3627
3627
|
});
|
|
3628
3628
|
return;
|
|
3629
3629
|
}
|
|
3630
|
-
|
|
3630
|
+
we(!0);
|
|
3631
3631
|
try {
|
|
3632
|
-
let o = await
|
|
3632
|
+
let o = await V.current.sendAiMessage(y, e, r, t, {
|
|
3633
3633
|
...n || {},
|
|
3634
|
-
...
|
|
3634
|
+
...le ? { email: le } : {}
|
|
3635
3635
|
}, {
|
|
3636
3636
|
...i,
|
|
3637
3637
|
currentPageUrl: typeof window < "u" ? window.location.href : void 0,
|
|
@@ -3650,7 +3650,7 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3650
3650
|
url: o.pending_navigate.url,
|
|
3651
3651
|
section: o.pending_navigate.section || null
|
|
3652
3652
|
};
|
|
3653
|
-
c.test(a) ? (console.log("[FWH Nav] Auto-navigating (intent detected) →", e.url),
|
|
3653
|
+
c.test(a) ? (console.log("[FWH Nav] Auto-navigating (intent detected) →", e.url), it(e.url, { voiceActive: vt.current }).then(({ navigated: t, reason: n }) => {
|
|
3654
3654
|
if (!t) {
|
|
3655
3655
|
n === "not-found" ? C() : n === "already-on-page" && w();
|
|
3656
3656
|
return;
|
|
@@ -3659,12 +3659,12 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3659
3659
|
let t = cr(null, e.section);
|
|
3660
3660
|
t && lr(t);
|
|
3661
3661
|
}, 300);
|
|
3662
|
-
})) : (
|
|
3662
|
+
})) : (nt.current = e, console.log("[FWH Nav] Stored pending nav →", nt.current));
|
|
3663
3663
|
}
|
|
3664
|
-
if (o.navigate?.url) if (
|
|
3664
|
+
if (o.navigate?.url) if (rt.current) rt.current = !1;
|
|
3665
3665
|
else {
|
|
3666
3666
|
let { url: e, section: t } = o.navigate;
|
|
3667
|
-
|
|
3667
|
+
it(e, { voiceActive: vt.current }).then(({ navigated: e, reason: n }) => {
|
|
3668
3668
|
if (!e) {
|
|
3669
3669
|
n === "not-found" ? C() : n === "already-on-page" && w();
|
|
3670
3670
|
return;
|
|
@@ -3686,19 +3686,19 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3686
3686
|
if (e?.message) {
|
|
3687
3687
|
let t = Dr(e.message);
|
|
3688
3688
|
t && pr(t.url, {
|
|
3689
|
-
siteId:
|
|
3690
|
-
apiBaseUrl:
|
|
3689
|
+
siteId: yt.current?.siteId,
|
|
3690
|
+
apiBaseUrl: yt.current?.apiBaseUrl
|
|
3691
3691
|
}).then(({ allowed: e, correctedUrl: n }) => {
|
|
3692
3692
|
if (!e) {
|
|
3693
3693
|
C();
|
|
3694
3694
|
return;
|
|
3695
3695
|
}
|
|
3696
|
-
|
|
3696
|
+
it(n || t.url, { voiceActive: vt.current }).then(({ navigated: e, reason: n }) => {
|
|
3697
3697
|
if (!e) {
|
|
3698
3698
|
n === "not-found" ? C() : n === "already-on-page" && w();
|
|
3699
3699
|
return;
|
|
3700
3700
|
}
|
|
3701
|
-
!t.section || !
|
|
3701
|
+
!t.section || !vt.current || setTimeout(() => {
|
|
3702
3702
|
let e = cr(null, t.section);
|
|
3703
3703
|
e && lr(e);
|
|
3704
3704
|
}, 300);
|
|
@@ -3706,27 +3706,27 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3706
3706
|
});
|
|
3707
3707
|
}
|
|
3708
3708
|
}
|
|
3709
|
-
S(Er(s)), A(!!o.is_human_handled), O(o.is_human_handled ? "agent" : "ai"),
|
|
3709
|
+
S(Er(s)), A(!!o.is_human_handled), O(o.is_human_handled ? "agent" : "ai"), xe(!1), we(!1), await V.current.updateChatStatus(y, "messageSent");
|
|
3710
3710
|
} catch (e) {
|
|
3711
|
-
S((e) => e.filter((e) => e.id !== u)),
|
|
3712
|
-
|
|
3711
|
+
S((e) => e.filter((e) => e.id !== u)), xe(!1), we(!1), e.status === 429 ? (F(!0), Oe(e.message), window.setTimeout(() => {
|
|
3712
|
+
F(!1), Oe("");
|
|
3713
3713
|
}, te)) : h(e);
|
|
3714
3714
|
}
|
|
3715
3715
|
}, Wt = async (e) => {
|
|
3716
|
-
if (!
|
|
3717
|
-
return
|
|
3716
|
+
if (!V.current || !e) throw Error("Upload is unavailable right now.");
|
|
3717
|
+
return V.current.uploadChatFile(e);
|
|
3718
3718
|
}, Gt = async (e) => {
|
|
3719
|
-
if (!(!
|
|
3719
|
+
if (!(!V.current || !y)) {
|
|
3720
3720
|
try {
|
|
3721
3721
|
let t = e ? "voice" : "text";
|
|
3722
|
-
await
|
|
3722
|
+
await V.current.setChatMode(y, t);
|
|
3723
3723
|
} catch {}
|
|
3724
|
-
|
|
3724
|
+
ke(e), e && (_t.current = !1);
|
|
3725
3725
|
}
|
|
3726
3726
|
}, Kt = async (e) => {
|
|
3727
|
-
if (
|
|
3728
|
-
if (
|
|
3729
|
-
|
|
3727
|
+
if (_t.current) return;
|
|
3728
|
+
if (_t.current = !0, !V.current || !y || !e?.length) {
|
|
3729
|
+
ke(!1);
|
|
3730
3730
|
return;
|
|
3731
3731
|
}
|
|
3732
3732
|
let t = () => {
|
|
@@ -3738,10 +3738,10 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3738
3738
|
});
|
|
3739
3739
|
};
|
|
3740
3740
|
try {
|
|
3741
|
-
let n = await
|
|
3741
|
+
let n = await V.current.syncVoice(y, e);
|
|
3742
3742
|
if (n?.chat_history?.length) S(Er(n.chat_history));
|
|
3743
3743
|
else if (n?.success) try {
|
|
3744
|
-
let e = await
|
|
3744
|
+
let e = await V.current.loadHistory(y, r);
|
|
3745
3745
|
e?.chat_history?.length ? S(Er(e.chat_history)) : t();
|
|
3746
3746
|
} catch {
|
|
3747
3747
|
t();
|
|
@@ -3750,19 +3750,19 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3750
3750
|
} catch {
|
|
3751
3751
|
t();
|
|
3752
3752
|
} finally {
|
|
3753
|
-
|
|
3753
|
+
ke(!1);
|
|
3754
3754
|
}
|
|
3755
3755
|
}, qt = async () => {
|
|
3756
|
-
if (!(!
|
|
3757
|
-
|
|
3756
|
+
if (!(!V.current || !y)) {
|
|
3757
|
+
I && !_t.current && gt.current.length > 0 && await Kt(gt.current);
|
|
3758
3758
|
try {
|
|
3759
|
-
await
|
|
3759
|
+
await V.current.endConversation(y);
|
|
3760
3760
|
} catch {
|
|
3761
3761
|
try {
|
|
3762
|
-
await
|
|
3762
|
+
await V.current.updateChatStatus(y, "ended");
|
|
3763
3763
|
} catch {}
|
|
3764
3764
|
}
|
|
3765
|
-
|
|
3765
|
+
R(!0), S((e) => [...e, {
|
|
3766
3766
|
id: `conversation-ended-${Date.now()}`,
|
|
3767
3767
|
sender: "system",
|
|
3768
3768
|
message: "This conversation has ended. Thank you for reaching out!",
|
|
@@ -3772,27 +3772,27 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3772
3772
|
}
|
|
3773
3773
|
};
|
|
3774
3774
|
c(() => {
|
|
3775
|
-
if (
|
|
3776
|
-
let e = new Date(
|
|
3777
|
-
|
|
3775
|
+
if (Be !== "connected" || !Re || !y || !He || !St) return;
|
|
3776
|
+
let e = new Date(He).getTime(), t = Number.isFinite(e) ? Date.now() - e : 0, n = Math.max(0, St * 1e3 - t), r = window.setTimeout(() => {
|
|
3777
|
+
qe("The call ended because it reached the time limit."), Ft();
|
|
3778
3778
|
}, n);
|
|
3779
3779
|
return () => window.clearTimeout(r);
|
|
3780
3780
|
}, [
|
|
3781
|
-
|
|
3782
|
-
|
|
3783
|
-
|
|
3781
|
+
Re,
|
|
3782
|
+
He,
|
|
3783
|
+
Be,
|
|
3784
3784
|
y,
|
|
3785
3785
|
Ft,
|
|
3786
|
-
|
|
3786
|
+
St
|
|
3787
3787
|
]), c(() => {
|
|
3788
3788
|
let e = () => {
|
|
3789
|
-
let e =
|
|
3789
|
+
let e = Xe.current, t = V.current;
|
|
3790
3790
|
if (!t || !e) return;
|
|
3791
|
-
if (
|
|
3792
|
-
t.beaconEndWebRTCCall(
|
|
3791
|
+
if (vt.current && gt.current.length > 0 && Ee(), !_t.current && gt.current.length > 0 && (t.beaconSyncVoice(e, gt.current) || t.syncVoice(e, gt.current).catch(() => {}), _t.current = !0), G.current) {
|
|
3792
|
+
t.beaconEndWebRTCCall(G.current, e);
|
|
3793
3793
|
return;
|
|
3794
3794
|
}
|
|
3795
|
-
let n =
|
|
3795
|
+
let n = ot.current || $e.current?.callId;
|
|
3796
3796
|
n && t.beaconCustomerUnavailable(n, e);
|
|
3797
3797
|
};
|
|
3798
3798
|
return window.addEventListener("pagehide", e), window.addEventListener("beforeunload", e), () => {
|
|
@@ -3801,9 +3801,9 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3801
3801
|
}, []);
|
|
3802
3802
|
let Jt = o(() => {
|
|
3803
3803
|
let e = i?.siteId;
|
|
3804
|
-
|
|
3804
|
+
de(e), Ze.current = !0, Qe.current = null, B.current?.disconnect(), S([]), b(""), Xe.current = "", R(!1), A(!1), M(null), ce(null), Ye(!0), s((e) => e + 1);
|
|
3805
3805
|
}, [i?.siteId]), Yt = o((e) => {
|
|
3806
|
-
i?.siteId,
|
|
3806
|
+
i?.siteId, Ze.current = !1, Qe.current = e, B.current?.disconnect(), S([]), b(""), Xe.current = "", R(!1), A(!1), M(null), ce(null), Ye(!0), s((e) => e + 1);
|
|
3807
3807
|
}, [i?.siteId]), Xt = f(() => ({
|
|
3808
3808
|
status: l,
|
|
3809
3809
|
error: d,
|
|
@@ -3815,34 +3815,34 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3815
3815
|
activeScreen: ee,
|
|
3816
3816
|
isHumanHandled: k,
|
|
3817
3817
|
agentName: ie,
|
|
3818
|
-
agentHeadshot:
|
|
3819
|
-
visitorEmail:
|
|
3820
|
-
isAgentTyping:
|
|
3821
|
-
isAiTyping:
|
|
3822
|
-
connectionStatus:
|
|
3823
|
-
isLoading:
|
|
3824
|
-
isVoiceMode:
|
|
3825
|
-
isRateLimited:
|
|
3826
|
-
rateLimitMessage:
|
|
3818
|
+
agentHeadshot: se,
|
|
3819
|
+
visitorEmail: le,
|
|
3820
|
+
isAgentTyping: N,
|
|
3821
|
+
isAiTyping: be,
|
|
3822
|
+
connectionStatus: Se,
|
|
3823
|
+
isLoading: P,
|
|
3824
|
+
isVoiceMode: I,
|
|
3825
|
+
isRateLimited: Te,
|
|
3826
|
+
rateLimitMessage: De,
|
|
3827
3827
|
isConversationEnded: L,
|
|
3828
|
-
isSessionRestoring:
|
|
3829
|
-
openToChatCounter:
|
|
3830
|
-
voiceEndCounter:
|
|
3831
|
-
incomingCall:
|
|
3832
|
-
activeCallId:
|
|
3833
|
-
callConnectionState:
|
|
3834
|
-
callConnectedAt:
|
|
3835
|
-
isCallMuted:
|
|
3836
|
-
webRTCError:
|
|
3828
|
+
isSessionRestoring: Je,
|
|
3829
|
+
openToChatCounter: Ae,
|
|
3830
|
+
voiceEndCounter: Me,
|
|
3831
|
+
incomingCall: z,
|
|
3832
|
+
activeCallId: Re,
|
|
3833
|
+
callConnectionState: Be,
|
|
3834
|
+
callConnectedAt: He,
|
|
3835
|
+
isCallMuted: We,
|
|
3836
|
+
webRTCError: Ke,
|
|
3837
3837
|
language: r,
|
|
3838
|
-
historyRef:
|
|
3839
|
-
hasSyncedRef:
|
|
3840
|
-
dismissCallError:
|
|
3838
|
+
historyRef: gt,
|
|
3839
|
+
hasSyncedRef: _t,
|
|
3840
|
+
dismissCallError: Ct,
|
|
3841
3841
|
captureVisitorEmail: Rt,
|
|
3842
3842
|
startTyping: zt,
|
|
3843
3843
|
stopTyping: Bt,
|
|
3844
3844
|
updateTypingDraft: Vt,
|
|
3845
|
-
notifyRouteChange: () =>
|
|
3845
|
+
notifyRouteChange: () => bt.current?.notifyRouteChange?.(),
|
|
3846
3846
|
openWidget: Lt,
|
|
3847
3847
|
closeWidget: () => D(!1),
|
|
3848
3848
|
toggleWidget: () => {
|
|
@@ -3859,8 +3859,8 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3859
3859
|
endConversation: qt,
|
|
3860
3860
|
startNewChat: Jt,
|
|
3861
3861
|
resumeChat: Yt,
|
|
3862
|
-
getVisitorChatHistory: () =>
|
|
3863
|
-
getVisitorChatThread: (e) =>
|
|
3862
|
+
getVisitorChatHistory: () => V.current?.getVisitorChatHistory?.(),
|
|
3863
|
+
getVisitorChatThread: (e) => V.current?.getVisitorChatThread?.(e),
|
|
3864
3864
|
acceptCall: Mt,
|
|
3865
3865
|
rejectCall: Nt,
|
|
3866
3866
|
endWebRTCCall: Ft,
|
|
@@ -3876,25 +3876,25 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3876
3876
|
ee,
|
|
3877
3877
|
k,
|
|
3878
3878
|
ie,
|
|
3879
|
-
|
|
3880
|
-
|
|
3881
|
-
M,
|
|
3882
|
-
xe,
|
|
3883
|
-
Ce,
|
|
3879
|
+
se,
|
|
3880
|
+
le,
|
|
3884
3881
|
N,
|
|
3885
|
-
|
|
3886
|
-
|
|
3887
|
-
|
|
3888
|
-
L,
|
|
3889
|
-
Ye,
|
|
3890
|
-
je,
|
|
3882
|
+
be,
|
|
3883
|
+
Se,
|
|
3884
|
+
P,
|
|
3891
3885
|
I,
|
|
3892
|
-
|
|
3893
|
-
|
|
3894
|
-
|
|
3895
|
-
|
|
3896
|
-
|
|
3897
|
-
|
|
3886
|
+
Te,
|
|
3887
|
+
De,
|
|
3888
|
+
L,
|
|
3889
|
+
Je,
|
|
3890
|
+
Ae,
|
|
3891
|
+
Me,
|
|
3892
|
+
z,
|
|
3893
|
+
Re,
|
|
3894
|
+
Be,
|
|
3895
|
+
He,
|
|
3896
|
+
We,
|
|
3897
|
+
Ke,
|
|
3898
3898
|
r,
|
|
3899
3899
|
Rt,
|
|
3900
3900
|
zt,
|
|
@@ -3911,7 +3911,7 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3911
3911
|
Kt,
|
|
3912
3912
|
qt,
|
|
3913
3913
|
Jt,
|
|
3914
|
-
|
|
3914
|
+
Ct
|
|
3915
3915
|
]);
|
|
3916
3916
|
return /* @__PURE__ */ g(Sn.Provider, {
|
|
3917
3917
|
value: Xt,
|
|
@@ -8947,61 +8947,61 @@ async function Lm(e) {
|
|
|
8947
8947
|
}
|
|
8948
8948
|
}, ee = (e, t, n) => {
|
|
8949
8949
|
t && (T.role && T.role !== e && D(), T.role = e, T.text = T.text ? `${T.text} ${t}`.replace(/\s+/g, " ") : t, n && (T.debug = n), T.timer && clearTimeout(T.timer), T.timer = setTimeout(D, Sm));
|
|
8950
|
-
}, O = !1, k = !1, te = !1, ne = !1, re = !0, A = 0, ie = !1, ae = !1, oe = Cm,
|
|
8951
|
-
|
|
8950
|
+
}, O = !1, k = !1, te = !1, ne = !1, re = !0, A = 0, ie = !1, ae = !1, oe = Cm, j = wm, M = null, se = !1, ce = !1, le = () => {
|
|
8951
|
+
M && clearTimeout(M);
|
|
8952
8952
|
let e = () => {
|
|
8953
8953
|
if (!O) {
|
|
8954
|
-
if (
|
|
8955
|
-
|
|
8954
|
+
if (ue.isPlaying()) {
|
|
8955
|
+
M = setTimeout(e, 150);
|
|
8956
8956
|
return;
|
|
8957
8957
|
}
|
|
8958
|
-
if (
|
|
8958
|
+
if (M = null, se) {
|
|
8959
8959
|
p?.();
|
|
8960
8960
|
return;
|
|
8961
8961
|
}
|
|
8962
|
-
!O && C.readyState === WebSocket.OPEN && C.send(JSON.stringify({ type: "PlaybackDrained" })),
|
|
8962
|
+
!O && C.readyState === WebSocket.OPEN && C.send(JSON.stringify({ type: "PlaybackDrained" })), ce && (ce = !1, d?.());
|
|
8963
8963
|
}
|
|
8964
8964
|
};
|
|
8965
|
-
|
|
8966
|
-
},
|
|
8965
|
+
M = setTimeout(e, 150);
|
|
8966
|
+
}, ue = Fm(_, () => {
|
|
8967
8967
|
ne && (ne = !1, c?.({ mode: "listening" }));
|
|
8968
|
-
}, v),
|
|
8969
|
-
|
|
8970
|
-
let
|
|
8971
|
-
|
|
8968
|
+
}, v), de = _.createMediaStreamSource(g);
|
|
8969
|
+
de.connect(v);
|
|
8970
|
+
let fe = _.createScriptProcessor(xm, 1, 1), pe = !1, me = 0, he = 0;
|
|
8971
|
+
fe.onaudioprocess = (e) => {
|
|
8972
8972
|
if (O || C.readyState !== WebSocket.OPEN) return;
|
|
8973
8973
|
let t = e.inputBuffer.getChannelData(0), n = () => C.send(new Int16Array(t.length).buffer);
|
|
8974
8974
|
if (k) {
|
|
8975
|
-
te || (te = !0, console.debug("[FlowEngage] mic held — streaming silence to keep socket alive")),
|
|
8975
|
+
te || (te = !0, console.debug("[FlowEngage] mic held — streaming silence to keep socket alive")), pe = !1, me = 0, he = 0, n();
|
|
8976
8976
|
return;
|
|
8977
8977
|
}
|
|
8978
8978
|
let r = Om(t);
|
|
8979
|
-
if (
|
|
8979
|
+
if (ue.isPlaying() || ae ? (pe = !1, me = 0, he = 0) : r >= Tm ? (he = 0, me += 1, !pe && me >= Em && (pe = !0, c?.({ mode: "user-speaking" }))) : (me = 0, pe && ++he >= Dm && (pe = !1, he = 0, c?.({
|
|
8980
8980
|
mode: "thinking",
|
|
8981
8981
|
tentative: !0
|
|
8982
|
-
}))), (
|
|
8982
|
+
}))), (ue.isPlaying() || ae) && !ie) {
|
|
8983
8983
|
if (r < oe) {
|
|
8984
8984
|
A = 0, n();
|
|
8985
8985
|
return;
|
|
8986
8986
|
}
|
|
8987
|
-
if (A += 1, A <
|
|
8987
|
+
if (A += 1, A < j) {
|
|
8988
8988
|
n();
|
|
8989
8989
|
return;
|
|
8990
8990
|
}
|
|
8991
8991
|
ie = !0, A = 0;
|
|
8992
|
-
let e =
|
|
8993
|
-
|
|
8992
|
+
let e = ue.playedMs();
|
|
8993
|
+
ue.stop(), re = !1, ae = !1, M && !se && (clearTimeout(M), M = null), ce = !1, C.send(JSON.stringify({
|
|
8994
8994
|
type: "VisitorInterrupted",
|
|
8995
8995
|
played_ms: Math.round(e)
|
|
8996
8996
|
})), console.debug("[FlowEngage] barge-in — visitor spoke over the agent");
|
|
8997
8997
|
}
|
|
8998
8998
|
C.send(km(t).buffer);
|
|
8999
|
-
},
|
|
9000
|
-
let
|
|
8999
|
+
}, de.connect(fe), fe.connect(_.destination);
|
|
9000
|
+
let ge = () => {
|
|
9001
9001
|
if (!O) {
|
|
9002
|
-
O = !0,
|
|
9002
|
+
O = !0, M &&= (clearTimeout(M), null), D(), ue.stop();
|
|
9003
9003
|
try {
|
|
9004
|
-
|
|
9004
|
+
fe.disconnect(), de.disconnect();
|
|
9005
9005
|
} catch {}
|
|
9006
9006
|
if (g.getTracks().forEach((e) => e.stop()), x && x.state !== "inactive") {
|
|
9007
9007
|
x.onstop = () => Pm(t, n, S, b, y);
|
|
@@ -9013,7 +9013,7 @@ async function Lm(e) {
|
|
|
9013
9013
|
} else b.length && Pm(t, n, S, b, y);
|
|
9014
9014
|
_.close().catch(() => {}), (C.readyState === WebSocket.OPEN || C.readyState === WebSocket.CONNECTING) && C.close();
|
|
9015
9015
|
}
|
|
9016
|
-
},
|
|
9016
|
+
}, _e = async (e) => {
|
|
9017
9017
|
let t = i[e.name];
|
|
9018
9018
|
if (!t) return u?.({ tool_name: e.name }), { error: `Unknown tool ${e.name}` };
|
|
9019
9019
|
let n = {};
|
|
@@ -9025,10 +9025,10 @@ async function Lm(e) {
|
|
|
9025
9025
|
} catch (e) {
|
|
9026
9026
|
return { error: e?.message || "Tool execution failed" };
|
|
9027
9027
|
}
|
|
9028
|
-
},
|
|
9028
|
+
}, N = async (e) => {
|
|
9029
9029
|
for (let t of e.functions || []) {
|
|
9030
9030
|
if (!t.client_side) continue;
|
|
9031
|
-
let e = await
|
|
9031
|
+
let e = await _e(t);
|
|
9032
9032
|
if (O || C.readyState !== WebSocket.OPEN) return;
|
|
9033
9033
|
C.send(JSON.stringify({
|
|
9034
9034
|
type: "FunctionCallResponse",
|
|
@@ -9037,10 +9037,10 @@ async function Lm(e) {
|
|
|
9037
9037
|
content: typeof e == "string" ? e : JSON.stringify(e ?? {})
|
|
9038
9038
|
}));
|
|
9039
9039
|
}
|
|
9040
|
-
},
|
|
9040
|
+
}, ve = (e) => {
|
|
9041
9041
|
switch (e.type) {
|
|
9042
9042
|
case "Welcome":
|
|
9043
|
-
Number.isFinite(e.barge_in_rms) && e.barge_in_rms > 0 && (oe = e.barge_in_rms), Number.isFinite(e.barge_in_frames) && e.barge_in_frames > 0 && (
|
|
9043
|
+
Number.isFinite(e.barge_in_rms) && e.barge_in_rms > 0 && (oe = e.barge_in_rms), Number.isFinite(e.barge_in_frames) && e.barge_in_frames > 0 && (j = e.barge_in_frames), S = e.session_id || r || n || null, a?.({ conversationId: S });
|
|
9044
9044
|
break;
|
|
9045
9045
|
case "ConversationText": {
|
|
9046
9046
|
let t = String(e.content || "");
|
|
@@ -9059,25 +9059,25 @@ async function Lm(e) {
|
|
|
9059
9059
|
break;
|
|
9060
9060
|
}
|
|
9061
9061
|
case "UserStartedSpeaking":
|
|
9062
|
-
D(),
|
|
9062
|
+
D(), ue.stop(), ae = !1, re = !1, ne = !1, M && !se && (clearTimeout(M), M = null), ce = !1, c?.({ mode: "listening" });
|
|
9063
9063
|
break;
|
|
9064
9064
|
case "AgentStartedSpeaking":
|
|
9065
9065
|
re = !0, ne = !0, ie = !1, A = 0, c?.({ mode: "speaking" });
|
|
9066
9066
|
break;
|
|
9067
9067
|
case "AgentAudioDone":
|
|
9068
|
-
ae = !1, D(),
|
|
9068
|
+
ae = !1, D(), le(), ue.isPlaying() || (ne = !1, c?.({ mode: "listening" }));
|
|
9069
9069
|
break;
|
|
9070
9070
|
case "FunctionCallRequest":
|
|
9071
|
-
|
|
9071
|
+
N(e);
|
|
9072
9072
|
break;
|
|
9073
9073
|
case "AgentPreparing":
|
|
9074
9074
|
ae = !0;
|
|
9075
9075
|
break;
|
|
9076
9076
|
case "AgentTurnComplete":
|
|
9077
|
-
|
|
9077
|
+
ce = !0, le();
|
|
9078
9078
|
break;
|
|
9079
9079
|
case "SessionEnding":
|
|
9080
|
-
console.debug("[FlowEngage] server is ending the session:", e.reason || "unspecified"),
|
|
9080
|
+
console.debug("[FlowEngage] server is ending the session:", e.reason || "unspecified"), se = !0;
|
|
9081
9081
|
break;
|
|
9082
9082
|
case "AgentThinking":
|
|
9083
9083
|
c?.({ mode: "thinking" });
|
|
@@ -9094,16 +9094,16 @@ async function Lm(e) {
|
|
|
9094
9094
|
};
|
|
9095
9095
|
return C.onopen = () => C.send(JSON.stringify(h)), C.onmessage = (e) => {
|
|
9096
9096
|
if (e.data instanceof ArrayBuffer) {
|
|
9097
|
-
re &&
|
|
9097
|
+
re && ue.enqueue(new Int16Array(e.data));
|
|
9098
9098
|
return;
|
|
9099
9099
|
}
|
|
9100
9100
|
try {
|
|
9101
|
-
|
|
9101
|
+
ve(JSON.parse(e.data));
|
|
9102
9102
|
} catch {}
|
|
9103
9103
|
}, C.onerror = () => l?.(/* @__PURE__ */ Error("Voice connection failed")), C.onclose = () => {
|
|
9104
|
-
|
|
9104
|
+
ge(), o?.();
|
|
9105
9105
|
}, {
|
|
9106
|
-
endSession: async () =>
|
|
9106
|
+
endSession: async () => ge(),
|
|
9107
9107
|
sendContextualUpdate: (e) => {
|
|
9108
9108
|
O || C.readyState !== WebSocket.OPEN || !e || C.send(JSON.stringify({
|
|
9109
9109
|
type: "UpdatePrompt",
|
|
@@ -12107,10 +12107,10 @@ function xg(e) {
|
|
|
12107
12107
|
sender: "user",
|
|
12108
12108
|
message: e
|
|
12109
12109
|
}]);
|
|
12110
|
-
n &&
|
|
12110
|
+
n && P(t, n);
|
|
12111
12111
|
}
|
|
12112
12112
|
} catch {}
|
|
12113
|
-
|
|
12113
|
+
Ee();
|
|
12114
12114
|
let e = a;
|
|
12115
12115
|
try {
|
|
12116
12116
|
e = new URL(a, typeof window < "u" ? window.location.href : "").href;
|
|
@@ -12120,7 +12120,7 @@ function xg(e) {
|
|
|
12120
12120
|
let e = new URL(a, window.location.href).pathname.split("/").filter(Boolean).pop() || "";
|
|
12121
12121
|
n = e ? e.replace(/[-_]/g, " ").replace(/\b\w/g, (e) => e.toUpperCase()) : "Home";
|
|
12122
12122
|
} catch {}
|
|
12123
|
-
t && typeof window < "u" &&
|
|
12123
|
+
t && typeof window < "u" && Me(t, window.location.href, e, n), gr(e), $("fwh-navigate-mvp → real navigation", a);
|
|
12124
12124
|
let i = typeof window < "u" && !!qn();
|
|
12125
12125
|
if (typeof window < "u" && window.__fe_triggerVoiceNavHooks && window.__fe_triggerVoiceNavHooks(), i && Rn(12e3), br(a, { voiceActive: !0 }).catch(() => {}), i) try {
|
|
12126
12126
|
let e = new URL(a, window.location.origin).pathname, t = window.location.pathname, n = Date.now() + 2e3;
|
|
@@ -12838,62 +12838,64 @@ function Pg({ copy: e, orbColors: t, primaryColor: n, onVoice: r, onText: i, onC
|
|
|
12838
12838
|
}
|
|
12839
12839
|
function Fg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i, apiBaseUrl: a, chatId: s, historyRef: l, onMessageSync: u, voiceEndCounter: d, websiteName: f, voiceFirstMessage: h, captureVisitorEmail: v, emailRequired: y, emailCaptureEnabled: b = !0, listeningLabel: x = "Listening...", thinkingLabel: S = "Thinking...", enterChatModeLabel: C = "Enter Chat Mode", endConversationLabel: w = "End Conversation" }) {
|
|
12840
12840
|
c(() => (console.log("[FlowEngage:VoiceDebug] 🔵 VoiceMode MOUNTED"), () => console.log("[FlowEngage:VoiceDebug] 🔴 VoiceMode UNMOUNTED")), []);
|
|
12841
|
-
let [T, E] = m("idle"), [D, ee] = m(!1), [O, k] = m(!1), [te, ne] = m(!1), [re, A] = m(""), [ie, ae] = m(""), oe = p(!1),
|
|
12842
|
-
|
|
12841
|
+
let [T, E] = m("idle"), [D, ee] = m(!1), [O, k] = m(!1), [te, ne] = m(!1), [re, A] = m(""), [ie, ae] = m(""), oe = p(!1), j = p(!1), M = p(null), se = p(0), ce = p(""), le = p(!1), ue = p(0), de = p(!1), fe = p(!1), pe = p(!1), me = p([]), he = p(null), ge = (e) => {
|
|
12842
|
+
de.current = e, e || (fe.current = !1), N.current?.setWalkthroughActive?.(e);
|
|
12843
12843
|
};
|
|
12844
|
-
|
|
12845
|
-
if (
|
|
12846
|
-
let e =
|
|
12847
|
-
|
|
12848
|
-
let t =
|
|
12844
|
+
he.current = async () => {
|
|
12845
|
+
if (fe.current) return;
|
|
12846
|
+
let e = me.current;
|
|
12847
|
+
_e.current += 1;
|
|
12848
|
+
let t = _e.current, n = e[t];
|
|
12849
12849
|
if (!n) {
|
|
12850
|
-
|
|
12850
|
+
ge(!1), e.length && N.current?.sendUserMessage?.("That was the last section. Say so in one short sentence and ask if they want to explore any section further.");
|
|
12851
12851
|
return;
|
|
12852
12852
|
}
|
|
12853
12853
|
try {
|
|
12854
|
-
await
|
|
12855
|
-
} catch {
|
|
12856
|
-
|
|
12854
|
+
await ve.current?.highlightOnPage?.({ section_text: n });
|
|
12855
|
+
} catch (e) {
|
|
12856
|
+
console.warn("[FlowEngage] walkthrough highlight failed:", e?.message || e);
|
|
12857
|
+
}
|
|
12858
|
+
console.debug(`[FlowEngage] walkthrough step ${t + 1}/${e.length}: ${n}`), N.current?.sendUserMessage?.(`Describe the section titled "${n}" in 3-4 sentences, starting with ${t === 0 ? "Starting with" : "Next —"} ${n}. Describe ONLY this section. If this section contains named sub-items (steps, checklist entries, cards, plans, FAQs, team members), name EVERY one of them in order with a short phrase each — never skip or collapse them into a summary; read the section's content silently first (fwh-read-content-mvp) if you don't already have it. This section is ON THE PAGE THE VISITOR IS ALREADY ON — do NOT call fwh-navigate-mvp, do not go to a product/detail page, and do not offer to, even if this section's name also matches a page name. Do not mention any other section, do not ask whether to continue, then stop.`, { suppressQuestion: !0 });
|
|
12857
12859
|
};
|
|
12858
|
-
let
|
|
12860
|
+
let _e = p(0), N = p(null), ve = p(null), ye = p(""), be = p(async () => {}), xe = p(!1), Se = p(!1), Ce = p(!1), F = p(!1), De = p("minimized"), Oe = p(null), I = p(null), ke = p(null), je = p(0), Me = p(!1), L = p("idle"), R = p(null), Pe = p(!1), Fe = p(null), Ie = o((e = "minimized") => {
|
|
12859
12861
|
console.warn("[FlowEngage:VoiceDebug] 🛑 requestSessionShutdown called", {
|
|
12860
12862
|
destination: e,
|
|
12861
12863
|
stack: (/* @__PURE__ */ Error()).stack?.split("\n").slice(1, 4).join(" | ")
|
|
12862
|
-
}),
|
|
12864
|
+
}), De.current = e, F.current = !0, queueMicrotask(() => {
|
|
12863
12865
|
xe.current || (xe.current = !0, be.current?.());
|
|
12864
12866
|
});
|
|
12865
|
-
}, [l]),
|
|
12866
|
-
|
|
12867
|
+
}, [l]), z = o(() => {
|
|
12868
|
+
M.current &&= (clearTimeout(M.current), null);
|
|
12867
12869
|
}, []);
|
|
12868
12870
|
c(() => {
|
|
12869
12871
|
if (y) {
|
|
12870
12872
|
oe.current = !1;
|
|
12871
12873
|
return;
|
|
12872
12874
|
}
|
|
12873
|
-
if (oe.current = !0,
|
|
12874
|
-
|
|
12875
|
-
let e =
|
|
12876
|
-
|
|
12877
|
-
}
|
|
12878
|
-
|
|
12879
|
-
}, [y,
|
|
12880
|
-
let
|
|
12881
|
-
|
|
12882
|
-
if (!(!
|
|
12883
|
-
|
|
12875
|
+
if (oe.current = !0, j.current = !1, ne(!1), z(), le.current) {
|
|
12876
|
+
le.current = !1, N.current?.setMicMuted?.(!1);
|
|
12877
|
+
let e = ce.current;
|
|
12878
|
+
ce.current = "", N.current?.injectAgentSpeech?.("Thanks — I already have your email on file.", "interrupt"), e && N.current?.sendUserMessage?.(`The visitor's email is already on file — do not ask for it. Answer their question now: "${e}"`);
|
|
12879
|
+
}
|
|
12880
|
+
N.current?.sendContextualUpdate?.("EMAIL REQUIREMENT SATISFIED — the visitor's email is already on file. All earlier instructions about requiring or asking for an email are VOID. Never ask for it again.");
|
|
12881
|
+
}, [y, z]);
|
|
12882
|
+
let Le = /(walk\s*(me\s*)?through|walkthrough|take me through|(complete|full|detailed) (overview|understanding|walkthrough|picture|breakdown|explanation)|give me (a|an|the) (overview|tour|walk)|tell me about (each|all)|go through (it|them|each|all)|overview of|one by one|tell me everything|explain (me )?(this|the) (whole |entire |full )?page|everything (about|on) this page|show me (each|all|around))/i, Re = /(that covers everything|that was all|covered everything|that(?:'|’)?s everything)/i, ze = /^((uh+|um+|so|well|okay|ok|yeah)[,.\s]+)*(yes|yeah|yep|yup|sure|ok(ay)?|please|continue|go on|next|keep going|carry on|go ahead|resume|back to the tour)[\s.!,]*$/i, Be = o(() => {
|
|
12883
|
+
z(), M.current = setTimeout(() => {
|
|
12884
|
+
if (!(!j.current || oe.current)) if (se.current < 3) {
|
|
12885
|
+
se.current += 1;
|
|
12884
12886
|
try {
|
|
12885
|
-
|
|
12887
|
+
N.current?.injectAgentSpeech?.("I still need your email in the box below to continue — could you enter it, please?", "queue");
|
|
12886
12888
|
} catch {}
|
|
12887
12889
|
Be();
|
|
12888
12890
|
} else {
|
|
12889
12891
|
try {
|
|
12890
|
-
|
|
12892
|
+
N.current?.injectAgentSpeech?.("Since I haven't received your email, I'll close this session for now. Feel free to come back anytime — take care!", "queue");
|
|
12891
12893
|
} catch {}
|
|
12892
|
-
|
|
12894
|
+
j.current = !1, ne(!1), z(), Me.current = !0;
|
|
12893
12895
|
}
|
|
12894
12896
|
}, 1e4);
|
|
12895
|
-
}, [
|
|
12896
|
-
|
|
12897
|
+
}, [z]), Ve = o(async (e) => {
|
|
12898
|
+
F.current = !0;
|
|
12897
12899
|
try {
|
|
12898
12900
|
On();
|
|
12899
12901
|
} catch {}
|
|
@@ -12901,9 +12903,9 @@ function Fg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
12901
12903
|
Ne(i);
|
|
12902
12904
|
} catch {}
|
|
12903
12905
|
try {
|
|
12904
|
-
await
|
|
12906
|
+
await N.current?.endSession?.();
|
|
12905
12907
|
} catch {}
|
|
12906
|
-
let t = Oe.current, n =
|
|
12908
|
+
let t = Oe.current, n = I.current;
|
|
12907
12909
|
if (t && s && a) {
|
|
12908
12910
|
let e = n ? Math.round((Date.now() - n) / 1e3) : 0;
|
|
12909
12911
|
fetch(`${a}/api/voice/save-chat-recording`, {
|
|
@@ -12917,8 +12919,8 @@ function Fg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
12917
12919
|
})
|
|
12918
12920
|
}).catch((e) => console.warn("[FlowEngage] save-chat-recording failed:", e.message));
|
|
12919
12921
|
}
|
|
12920
|
-
if (Oe.current = null,
|
|
12921
|
-
|
|
12922
|
+
if (Oe.current = null, I.current = null, N.current = null, E("idle"), ee(!1), xe.current = !1, wr(), i) try {
|
|
12923
|
+
Te(i);
|
|
12922
12924
|
} catch {}
|
|
12923
12925
|
typeof u == "function" && await u(l.current), e?.();
|
|
12924
12926
|
}, [
|
|
@@ -12928,7 +12930,7 @@ function Fg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
12928
12930
|
s,
|
|
12929
12931
|
a
|
|
12930
12932
|
]);
|
|
12931
|
-
be.current = () => Ve(
|
|
12933
|
+
be.current = () => Ve(De.current === "chat" ? t : n), c(() => {
|
|
12932
12934
|
Se.current = D;
|
|
12933
12935
|
}, [D]), c(() => {
|
|
12934
12936
|
d && Ie("chat");
|
|
@@ -12941,13 +12943,13 @@ function Fg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
12941
12943
|
}
|
|
12942
12944
|
try {
|
|
12943
12945
|
if ((await navigator.mediaDevices.getUserMedia({ audio: !0 })).getTracks().forEach((e) => e.stop()), e) return;
|
|
12944
|
-
l.current = [], ye.current = "", xe.current = !1, Ce.current = !1,
|
|
12946
|
+
l.current = [], ye.current = "", xe.current = !1, Ce.current = !1, F.current = !1, De.current = "minimized", Cr({ onBeforeNavigate: () => {
|
|
12945
12947
|
if (i && l.current.length > 0) try {
|
|
12946
12948
|
let e = Fh(l.current);
|
|
12947
|
-
e &&
|
|
12949
|
+
e && P(i, e);
|
|
12948
12950
|
} catch {}
|
|
12949
12951
|
if (!qn()) {
|
|
12950
|
-
let e = Oe.current, t =
|
|
12952
|
+
let e = Oe.current, t = I.current;
|
|
12951
12953
|
if (e && s && a) try {
|
|
12952
12954
|
let n = t ? Math.round((Date.now() - t) / 1e3) : 0, r = JSON.stringify({
|
|
12953
12955
|
chatId: s,
|
|
@@ -12960,29 +12962,31 @@ function Fg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
12960
12962
|
headers: { "Content-Type": "application/json" },
|
|
12961
12963
|
body: r,
|
|
12962
12964
|
keepalive: !0
|
|
12963
|
-
}).catch(() => {}), Oe.current = null,
|
|
12965
|
+
}).catch(() => {}), Oe.current = null, I.current = null;
|
|
12964
12966
|
} catch {}
|
|
12965
12967
|
}
|
|
12966
|
-
|
|
12968
|
+
Ee();
|
|
12967
12969
|
} });
|
|
12968
12970
|
let t = wg(xg({
|
|
12969
12971
|
siteId: i || null,
|
|
12970
12972
|
apiBaseUrl: a || null,
|
|
12971
12973
|
chatId: s || null,
|
|
12972
12974
|
getLastUserVoiceText: () => ye.current,
|
|
12973
|
-
isWalkthroughActive: () =>
|
|
12975
|
+
isWalkthroughActive: () => de.current && !fe.current,
|
|
12974
12976
|
requestEndSession: () => {
|
|
12975
12977
|
Me.current = !0;
|
|
12976
12978
|
},
|
|
12977
12979
|
requestEmailCollection: () => {
|
|
12978
|
-
b && (oe.current ||
|
|
12980
|
+
b && (oe.current || j.current || (j.current = !0, se.current = 0, ne(!0), Be()));
|
|
12979
12981
|
}
|
|
12980
|
-
})), n = i ?
|
|
12982
|
+
})), n = i ? we(i) : null, r = !!n?.transcript, u = i ? Ne(i) : null, p = !!u, m = typeof window < "u" ? window.location.pathname : "/", g = typeof document < "u" ? document.title : "", _ = m.replace(/^\/[a-z]{2}(?:-[a-z]{2})?(?=\/|$)/i, "") || "/", v = _ === "/" || _ === "", x = {
|
|
12981
12983
|
apiBaseUrl: a,
|
|
12982
12984
|
siteId: i,
|
|
12983
12985
|
chatId: s,
|
|
12984
12986
|
clientTools: t
|
|
12985
|
-
}
|
|
12987
|
+
};
|
|
12988
|
+
ve.current = t;
|
|
12989
|
+
let S = (m.split("/").filter(Boolean).pop() || "").replace(/[-_]/g, " ").replace(/\b\w/g, (e) => e.toUpperCase()), C = "";
|
|
12986
12990
|
g && g.includes("|") && (C = g.split("|").map((e) => e.trim()).filter(Boolean).reduce((e, t) => e.length <= t.length ? e : t));
|
|
12987
12991
|
let w = C || S || "this page", T = (() => {
|
|
12988
12992
|
if (!u?.targetUrl) return !0;
|
|
@@ -13008,17 +13012,17 @@ function Fg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
13008
13012
|
let e = f || "";
|
|
13009
13013
|
x.greeting = h || (v ? e ? `Hi, welcome to ${e}! How may I help you?` : "Hi, welcome! How may I help you?" : `Welcome to the ${w} page!`), v || console.log(`[FlowEngage] 🏠 Page-context greeting: "${w}" for ${m}`);
|
|
13010
13014
|
}
|
|
13011
|
-
let O = !1, k = p ? `NAVIGATION COMPLETE — The exact phrase "I have navigated you on [page] page. Do you want to know about any specific section or want a complete overview?" has already been spoken as your firstMessage. DO NOT repeat it. PRIOR CONVERSATION CONTEXT:\n${n?.transcript ? `Prior transcript:\n${n.transcript}\n` : "(no prior transcript)"}\nNow STOP — wait silently for the visitor's reply. Do NOT speak, do NOT call any tool until the visitor responds. When they reply: if they name a specific section → call fwh-get-current-page-mvp then answer immediately; if they say "overview" or anything non-specific → call fwh-get-current-page-mvp (zero speech) then do a full highlighted walkthrough.` : null, te = !1, re = !p && !r ? "Your greeting has been spoken. Wait for the visitor to ask a question or tell you what they need. Do NOT auto-start a walkthrough or highlight any sections — let the visitor lead." : null, A = r && !p, ie = !1, ae = A ? `The question "Would you like me to continue what I was explaining before, or would you like to know about this page instead?" has already been spoken as your firstMessage. DO NOT repeat it. PRIOR CONVERSATION CONTEXT:\n${n?.transcript ? `Prior transcript:\n${n.transcript}\n` : "(no prior transcript, or the visitor navigated before saying much)"}\nNow STOP — wait silently for the visitor's reply. Do NOT speak, do NOT call any tool until they respond. When they reply: if they want you to CONTINUE the previous topic → resume verbally from the prior transcript above, do NOT call fwh-get-current-page-mvp or describe the new page unless they ask. If they want to know about THIS page → call fwh-get-current-page-mvp (zero speech) then proceed as a normal fresh-page walkthrough/description. If their reply is ambiguous, ask them to clarify which they'd prefer rather than guessing.` : null,
|
|
13015
|
+
let O = !1, k = p ? `NAVIGATION COMPLETE — The exact phrase "I have navigated you on [page] page. Do you want to know about any specific section or want a complete overview?" has already been spoken as your firstMessage. DO NOT repeat it. PRIOR CONVERSATION CONTEXT:\n${n?.transcript ? `Prior transcript:\n${n.transcript}\n` : "(no prior transcript)"}\nNow STOP — wait silently for the visitor's reply. Do NOT speak, do NOT call any tool until the visitor responds. When they reply: if they name a specific section → call fwh-get-current-page-mvp then answer immediately; if they say "overview" or anything non-specific → call fwh-get-current-page-mvp (zero speech) then do a full highlighted walkthrough.` : null, te = !1, re = !p && !r ? "Your greeting has been spoken. Wait for the visitor to ask a question or tell you what they need. Do NOT auto-start a walkthrough or highlight any sections — let the visitor lead." : null, A = r && !p, ie = !1, ae = A ? `The question "Would you like me to continue what I was explaining before, or would you like to know about this page instead?" has already been spoken as your firstMessage. DO NOT repeat it. PRIOR CONVERSATION CONTEXT:\n${n?.transcript ? `Prior transcript:\n${n.transcript}\n` : "(no prior transcript, or the visitor navigated before saying much)"}\nNow STOP — wait silently for the visitor's reply. Do NOT speak, do NOT call any tool until they respond. When they reply: if they want you to CONTINUE the previous topic → resume verbally from the prior transcript above, do NOT call fwh-get-current-page-mvp or describe the new page unless they ask. If they want to know about THIS page → call fwh-get-current-page-mvp (zero speech) then proceed as a normal fresh-page walkthrough/description. If their reply is ambiguous, ask them to clarify which they'd prefer rather than guessing.` : null, M = !1, be = !1, Te = b && !!y && !pe.current, ke = await Rm.startSession({
|
|
13012
13016
|
...x,
|
|
13013
13017
|
onConnect: ({ conversationId: e }) => {
|
|
13014
|
-
Oe.current = e,
|
|
13018
|
+
Oe.current = e, I.current = Date.now(), console.log("[FlowEngage] 🎙️ AI chat session connected:", e);
|
|
13015
13019
|
},
|
|
13016
13020
|
onUnhandledClientToolCall: (e) => console.error("[FlowEngage] Unhandled tool:", e?.tool_name),
|
|
13017
13021
|
onSessionInfo: ({ emailOnFile: e }) => {
|
|
13018
|
-
|
|
13022
|
+
pe.current = !!e, e && (oe.current = !0, j.current = !1, ne(!1), z(), console.log("[FlowEngage] email already on file per server — gate disabled"));
|
|
13019
13023
|
},
|
|
13020
13024
|
onAgentTurnEnd: () => {
|
|
13021
|
-
e ||
|
|
13025
|
+
e || de.current && (fe.current || le.current || setTimeout(() => he.current?.(), 250));
|
|
13022
13026
|
},
|
|
13023
13027
|
onSessionEnding: () => {
|
|
13024
13028
|
e || Ie("minimized");
|
|
@@ -13026,104 +13030,104 @@ function Fg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
13026
13030
|
onModeChange: ({ mode: t, tentative: n }) => {
|
|
13027
13031
|
if (!e) {
|
|
13028
13032
|
if (t === "speaking") {
|
|
13029
|
-
|
|
13033
|
+
R.current &&= (clearTimeout(R.current), null), Fe.current &&= (clearTimeout(Fe.current), null), E("speaking"), L.current = "speaking", Pe.current = !1;
|
|
13030
13034
|
return;
|
|
13031
13035
|
}
|
|
13032
13036
|
if (t === "user-speaking") {
|
|
13033
|
-
if (Fe.current &&= (clearTimeout(Fe.current), null),
|
|
13037
|
+
if (Fe.current &&= (clearTimeout(Fe.current), null), L.current === "speaking") return;
|
|
13034
13038
|
try {
|
|
13035
13039
|
On();
|
|
13036
13040
|
} catch {}
|
|
13037
|
-
|
|
13041
|
+
R.current &&= (clearTimeout(R.current), null), L.current !== "listening" && (E("listening"), L.current = "listening");
|
|
13038
13042
|
return;
|
|
13039
13043
|
}
|
|
13040
13044
|
if (t === "thinking") {
|
|
13041
|
-
if (
|
|
13042
|
-
E("thinking"),
|
|
13043
|
-
Fe.current = null, !(e ||
|
|
13045
|
+
if (R.current &&= (clearTimeout(R.current), null), Fe.current &&= (clearTimeout(Fe.current), null), L.current === "speaking") return;
|
|
13046
|
+
E("thinking"), L.current = "thinking", n && (Fe.current = setTimeout(() => {
|
|
13047
|
+
Fe.current = null, !(e || L.current !== "thinking") && (L.current = "listening", E("listening"));
|
|
13044
13048
|
}, 4e3));
|
|
13045
13049
|
return;
|
|
13046
13050
|
}
|
|
13047
|
-
if (
|
|
13051
|
+
if (L.current = "listening", Me.current) {
|
|
13048
13052
|
Me.current = !1, Ie();
|
|
13049
13053
|
return;
|
|
13050
13054
|
}
|
|
13051
|
-
if (
|
|
13055
|
+
if (Te && !be && !oe.current && !pe.current) {
|
|
13052
13056
|
be = !0, O = !0, te = !0;
|
|
13053
13057
|
try {
|
|
13054
|
-
|
|
13058
|
+
N.current?.sendContextualUpdate?.("CRITICAL — EMAIL REQUIRED BEFORE ANYTHING ELSE. The visitor has not provided their email. Do NOT speak right now. Wait silently for the visitor to speak first. The MOMENT the visitor says ANYTHING — a question, a request, or just a greeting — your ENTIRE next response must be EXACTLY this one sentence: \"Before I answer that, could you please enter your email in the text box below?\" Do NOT answer their question. Do NOT say anything about the topic. Do NOT begin an answer and then switch — your first word must be \"Before\". After you say that sentence, stay completely silent until you receive an EMAIL_SAVED message, then thank them briefly and answer their question in full.");
|
|
13055
13059
|
} catch {}
|
|
13056
13060
|
}
|
|
13057
13061
|
if (k && !O) {
|
|
13058
13062
|
O = !0;
|
|
13059
13063
|
try {
|
|
13060
|
-
|
|
13064
|
+
N.current?.sendContextualUpdate?.(k);
|
|
13061
13065
|
} catch {}
|
|
13062
13066
|
}
|
|
13063
13067
|
if (ae && !ie) {
|
|
13064
13068
|
ie = !0;
|
|
13065
13069
|
try {
|
|
13066
|
-
|
|
13070
|
+
N.current?.sendContextualUpdate?.(ae);
|
|
13067
13071
|
} catch {}
|
|
13068
13072
|
}
|
|
13069
13073
|
if (re && !te) {
|
|
13070
13074
|
te = !0;
|
|
13071
13075
|
try {
|
|
13072
|
-
|
|
13076
|
+
N.current?.sendContextualUpdate?.(re);
|
|
13073
13077
|
} catch {}
|
|
13074
13078
|
}
|
|
13075
|
-
|
|
13076
|
-
e ||
|
|
13079
|
+
R.current && clearTimeout(R.current), R.current = setTimeout(() => {
|
|
13080
|
+
e || L.current !== "speaking" && (Pe.current || (R.current = null, L.current = "listening", E("listening")));
|
|
13077
13081
|
}, 1200);
|
|
13078
13082
|
}
|
|
13079
13083
|
},
|
|
13080
13084
|
onMessage: (t) => {
|
|
13081
|
-
if (e ||
|
|
13082
|
-
if (t.role === "user" &&
|
|
13083
|
-
else if (t.role === "user" &&
|
|
13085
|
+
if (e || le.current && t.role !== "user" && !/email/i.test(String(t.message || ""))) return;
|
|
13086
|
+
if (t.role === "user" && Le.test(String(t.message || ""))) typeof window < "u" && (window.__fe_user_nav_during_speech = null), ge(!0), fe.current = !1, ue.current = 0, _e.current = -1, me.current = Cg(), setTimeout(() => he.current?.(), 400), console.log(`[FlowEngage] walkthrough armed — ${me.current.length} sections on this page`);
|
|
13087
|
+
else if (t.role === "user" && de.current) {
|
|
13084
13088
|
let e = String(t.message || "").trim();
|
|
13085
|
-
ze.test(e) ?
|
|
13089
|
+
ze.test(e) ? fe.current && (fe.current = !1, console.debug("[FlowEngage] walkthrough resumed by visitor"), setTimeout(() => he.current?.(), 300)) : (fe.current = !0, console.debug("[FlowEngage] walkthrough paused — visitor interjected"));
|
|
13086
13090
|
}
|
|
13087
13091
|
if (t.role !== "user" && Re.test(String(t.message || ""))) {
|
|
13088
|
-
let e =
|
|
13089
|
-
!e ||
|
|
13092
|
+
let e = me.current.length;
|
|
13093
|
+
!e || _e.current >= e - 1 ? ge(!1) : console.debug(`[FlowEngage] agent claimed completion at step ${_e.current + 1}/${e} — ignoring, tour continues`);
|
|
13090
13094
|
}
|
|
13091
13095
|
let n = t.role === "user" ? "user" : "bot", r = t.message || t.text || t.content || "";
|
|
13092
13096
|
if (r) {
|
|
13093
|
-
if (n === "user" && (ye.current = r, typeof window < "u" && (window.__fe_user_nav_during_speech = null), Pe.current = !0,
|
|
13097
|
+
if (n === "user" && (ye.current = r, typeof window < "u" && (window.__fe_user_nav_during_speech = null), Pe.current = !0, R.current &&= (clearTimeout(R.current), null), L.current !== "speaking" && (E("thinking"), L.current = "thinking"), Te && !M && !oe.current && !pe.current && (M = !0, ce.current = r, le.current = !0, N.current?.injectAgentSpeech?.("Before I answer that, could you please enter your email in the text box below?", "interrupt"), N.current?.setMicMuted?.(!0), j.current || (j.current = !0, se.current = 0, ne(!0), Be()))), l.current = [...l.current, {
|
|
13094
13098
|
sender: n,
|
|
13095
13099
|
message: r,
|
|
13096
13100
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
13097
13101
|
debug: t.debug
|
|
13098
13102
|
}], i) try {
|
|
13099
13103
|
let e = Fh(l.current);
|
|
13100
|
-
e &&
|
|
13104
|
+
e && P(i, e);
|
|
13101
13105
|
} catch {}
|
|
13102
13106
|
if (jg(n, r)) {
|
|
13103
13107
|
Me.current = !0;
|
|
13104
13108
|
return;
|
|
13105
13109
|
}
|
|
13106
|
-
if (Se.current && n === "bot" && /are you still there|still there\??|hello\?|anyone there|checking in|you there|are you available|is anyone|did you step away/i.test(r)) if (
|
|
13107
|
-
|
|
13110
|
+
if (Se.current && n === "bot" && /are you still there|still there\??|hello\?|anyone there|checking in|you there|are you available|is anyone|did you step away/i.test(r)) if (je.current += 1, je.current === 2) try {
|
|
13111
|
+
N.current?.sendContextualUpdate?.("IMPORTANT: The visitor is muted and has not responded to your last 2 checks. Make exactly ONE more check. If there is still no response, say: 'I feel like you are not active, so I'm ending this session. You can connect with me anytime.' then immediately call the fwh-end-session-mvp tool to end the voice session. Do NOT ask again after that.");
|
|
13108
13112
|
} catch {}
|
|
13109
|
-
else
|
|
13113
|
+
else je.current >= 5 && Ie("minimized");
|
|
13110
13114
|
}
|
|
13111
13115
|
},
|
|
13112
13116
|
onError: (t) => {
|
|
13113
|
-
if (!e && !
|
|
13117
|
+
if (!e && !F.current && !Ce.current && !Ae()) {
|
|
13114
13118
|
Ce.current = !0, console.error("[FlowEngageVoiceCall] session:error", {
|
|
13115
13119
|
message: t?.message,
|
|
13116
13120
|
name: t?.name,
|
|
13117
13121
|
raw: t
|
|
13118
13122
|
});
|
|
13119
13123
|
try {
|
|
13120
|
-
|
|
13124
|
+
N.current?.setMicMuted?.(!0);
|
|
13121
13125
|
} catch {}
|
|
13122
13126
|
ee(!0), E("error"), Ie("chat");
|
|
13123
13127
|
}
|
|
13124
13128
|
},
|
|
13125
13129
|
onDisconnect: (t) => {
|
|
13126
|
-
if (e ||
|
|
13130
|
+
if (e || F.current || Ce.current || Ae()) return;
|
|
13127
13131
|
let n = l.current?.length || 0;
|
|
13128
13132
|
console.warn("[FlowEngageVoiceCall] session:disconnected", {
|
|
13129
13133
|
historyCount: n,
|
|
@@ -13134,16 +13138,16 @@ function Fg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
13134
13138
|
wasMuted: Se.current
|
|
13135
13139
|
}), Ce.current = !0;
|
|
13136
13140
|
try {
|
|
13137
|
-
|
|
13141
|
+
N.current?.setMicMuted?.(!0);
|
|
13138
13142
|
} catch {}
|
|
13139
13143
|
ee(!0), Ie("chat");
|
|
13140
13144
|
}
|
|
13141
13145
|
});
|
|
13142
13146
|
if (e) {
|
|
13143
|
-
console.warn("[FlowEngage:VoiceDebug] ❌ cancelled=true after startSession resolved — killing session immediately"),
|
|
13147
|
+
console.warn("[FlowEngage:VoiceDebug] ❌ cancelled=true after startSession resolved — killing session immediately"), ke.endSession().catch(() => {});
|
|
13144
13148
|
return;
|
|
13145
13149
|
}
|
|
13146
|
-
o =
|
|
13150
|
+
o = ke, N.current = ke, E("listening");
|
|
13147
13151
|
try {
|
|
13148
13152
|
let e = typeof window < "u" ? window.location.href : "", a = "[]";
|
|
13149
13153
|
try {
|
|
@@ -13155,7 +13159,7 @@ function Fg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
13155
13159
|
n.length || (n = Array.from(document.body.querySelectorAll("h1, h2, h3")).filter((t) => !t.closest(e)).map((e) => e.textContent.replace(/\s+/g, " ").trim()).filter((e) => e.length > 2 && e.length < 200)), n.length && (o = [...new Set(n)].slice(0, 15).join(" | "));
|
|
13156
13160
|
} catch {}
|
|
13157
13161
|
let s = r && !p ? `RESUMING PRIOR SESSION — DO NOT GREET. The visitor is continuing the same conversation after a page reload. Do not introduce yourself or re-state your capabilities. Wait silently until the visitor speaks; if you must speak first, briefly acknowledge where you left off in one short sentence.\nPrior transcript:\n${n?.transcript || ""}\n\n` : "";
|
|
13158
|
-
|
|
13162
|
+
ke.sendContextualUpdate(`${s}SESSION_CONTEXT (NOT a tool result — do NOT treat as CURRENT_PAGE): Visitor is on: ${e} | Approx headings for awareness only: ${o}. SiteId: ${i || "unknown"}. Forms: ${a}. ${y ? "" : "Visitor's email is already on file from a prior session — do NOT ask for it again. "}The visitor is ALREADY on this page — do NOT offer to navigate there. WALKTHROUGH RULE: When the visitor asks for a walkthrough or overview of this page, you MUST IMMEDIATELY call fwh-get-current-page-mvp (zero speech — call it silently with NO words before it) to get the exact highlightable headings. The approximate headings above are for routing awareness ONLY — they are NOT precise enough for fwh-highlight-mvp. Do NOT skip fwh-get-current-page-mvp. Voice: call end_voice_session or say you are ending the session to stop.`);
|
|
13159
13163
|
} catch {}
|
|
13160
13164
|
if (typeof window < "u") {
|
|
13161
13165
|
let t = window.location.pathname, n = Date.now(), r = (e) => {
|
|
@@ -13201,7 +13205,7 @@ function Fg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
13201
13205
|
ts: Date.now()
|
|
13202
13206
|
}), console.log(`[FlowEngage] visitor navigation detected: "${a}" → "${i}" (agent target: ${D || "none"})`);
|
|
13203
13207
|
try {
|
|
13204
|
-
|
|
13208
|
+
N.current?.sendUserMessage?.(`[SYSTEM: I navigated away mid-walkthrough — I am now on the "${d}" page (${o}). Page title: "${s}". Sections: ${JSON.stringify(c)}. STOP everything. Do NOT describe the new page. Say EXACTLY: "I see you've navigated to the ${d} page — would you like me to continue what I was explaining, or shall I walk you through this page?" Then wait for my answer. IF I say continue/yes/carry on: resume speaking verbally from where you left off — do NOT call fwh-navigate-mvp, do NOT call fwh-highlight-mvp, the visitor will navigate themselves if needed. IF I want to hear about this page: call fwh-highlight-mvp for sections of "${d}" only.]`);
|
|
13205
13209
|
} catch {}
|
|
13206
13210
|
};
|
|
13207
13211
|
c = window.history.pushState.bind(window.history), window.history.pushState = (...e) => {
|
|
@@ -13209,7 +13213,7 @@ function Fg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
13209
13213
|
}, d = () => setTimeout(i, 50), window.addEventListener("popstate", d);
|
|
13210
13214
|
}
|
|
13211
13215
|
} catch (r) {
|
|
13212
|
-
e || (console.error("[FlowEngage] startSession failed", r), r.message && r.message.includes("Too many voice sessions") ? (alert(r.message), n && n("minimized")) : (E("error"),
|
|
13216
|
+
e || (console.error("[FlowEngage] startSession failed", r), r.message && r.message.includes("Too many voice sessions") ? (alert(r.message), n && n("minimized")) : (E("error"), De.current = "chat", window.setTimeout(() => {
|
|
13213
13217
|
e || t?.();
|
|
13214
13218
|
}, 0)));
|
|
13215
13219
|
}
|
|
@@ -13218,15 +13222,15 @@ function Fg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
13218
13222
|
agentId: r,
|
|
13219
13223
|
siteId: i,
|
|
13220
13224
|
apiBaseUrl: a
|
|
13221
|
-
}), e = !0,
|
|
13225
|
+
}), e = !0, F.current = !0;
|
|
13222
13226
|
try {
|
|
13223
13227
|
On();
|
|
13224
13228
|
} catch {}
|
|
13225
13229
|
if (i) try {
|
|
13226
13230
|
Ne(i);
|
|
13227
13231
|
} catch {}
|
|
13228
|
-
typeof window < "u" && (window.__fe_user_nav_during_speech = null), wr(),
|
|
13229
|
-
let t = o ||
|
|
13232
|
+
typeof window < "u" && (window.__fe_user_nav_during_speech = null), wr(), R.current &&= (clearTimeout(R.current), null), Fe.current &&= (clearTimeout(Fe.current), null), M.current &&= (clearTimeout(M.current), null), Pe.current = !1, L.current = "idle", c && typeof window < "u" && (window.history.pushState = c), d && typeof window < "u" && window.removeEventListener("popstate", d);
|
|
13233
|
+
let t = o || N.current, n = Oe.current, f = I.current;
|
|
13230
13234
|
if (t?.endSession?.().catch(() => {}), n && s && a) {
|
|
13231
13235
|
let e = f ? Math.round((Date.now() - f) / 1e3) : 0, t = JSON.stringify({
|
|
13232
13236
|
chatId: s,
|
|
@@ -13239,7 +13243,7 @@ function Fg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
13239
13243
|
headers: { "Content-Type": "application/json" },
|
|
13240
13244
|
body: t,
|
|
13241
13245
|
keepalive: !0
|
|
13242
|
-
}).catch(() => {}), Oe.current = null,
|
|
13246
|
+
}).catch(() => {}), Oe.current = null, I.current = null;
|
|
13243
13247
|
}
|
|
13244
13248
|
typeof u == "function" && l.current.length > 0 && u(l.current).catch?.(() => {});
|
|
13245
13249
|
};
|
|
@@ -13252,21 +13256,21 @@ function Fg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
13252
13256
|
if (!O) return;
|
|
13253
13257
|
let e = (e) => {
|
|
13254
13258
|
let t = e.composedPath?.()?.[0] || e.target;
|
|
13255
|
-
|
|
13259
|
+
ke.current && !ke.current.contains(t) && k(!1);
|
|
13256
13260
|
};
|
|
13257
13261
|
return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
|
|
13258
13262
|
}, [O]);
|
|
13259
13263
|
let He = async () => {
|
|
13260
|
-
if (
|
|
13264
|
+
if (N.current) try {
|
|
13261
13265
|
if (D) {
|
|
13262
|
-
|
|
13266
|
+
je.current = 0, await N.current.setMicMuted?.(!1), ee(!1);
|
|
13263
13267
|
try {
|
|
13264
|
-
|
|
13268
|
+
N.current.sendContextualUpdate?.("The visitor has unmuted. Resume normal interaction and wait for them to speak.");
|
|
13265
13269
|
} catch {}
|
|
13266
13270
|
} else {
|
|
13267
|
-
|
|
13271
|
+
je.current = 0, await N.current.setMicMuted?.(!0), ee(!0);
|
|
13268
13272
|
try {
|
|
13269
|
-
|
|
13273
|
+
N.current.sendContextualUpdate?.("The visitor has muted their microphone. Do NOT speak, ask if they are there, or prompt them in any way. Stay completely silent until they unmute.");
|
|
13270
13274
|
} catch {}
|
|
13271
13275
|
}
|
|
13272
13276
|
} catch {}
|
|
@@ -13277,23 +13281,23 @@ function Fg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
13277
13281
|
ae("Please enter a valid email address.");
|
|
13278
13282
|
return;
|
|
13279
13283
|
}
|
|
13280
|
-
ae(""), oe.current = !0,
|
|
13284
|
+
ae(""), oe.current = !0, j.current = !1, z(), ne(!1), A(""), le.current = !1;
|
|
13281
13285
|
try {
|
|
13282
13286
|
typeof v == "function" && await v(t);
|
|
13283
13287
|
} catch {}
|
|
13284
|
-
|
|
13285
|
-
let n =
|
|
13286
|
-
|
|
13288
|
+
N.current?.setMicMuted?.(!1);
|
|
13289
|
+
let n = ce.current;
|
|
13290
|
+
ce.current = "";
|
|
13287
13291
|
try {
|
|
13288
|
-
|
|
13292
|
+
N.current?.injectAgentSpeech?.("Thank you for submitting your email."), N.current?.sendUserMessage?.(n || "The visitor's email is on file. Carry on helping them and never ask for it again.");
|
|
13289
13293
|
} catch {}
|
|
13290
13294
|
}, [
|
|
13291
13295
|
re,
|
|
13292
13296
|
v,
|
|
13293
|
-
|
|
13297
|
+
z
|
|
13294
13298
|
]), We = Array.isArray(e) && e[0] || "#3B82F6";
|
|
13295
13299
|
return /* @__PURE__ */ _("div", {
|
|
13296
|
-
ref:
|
|
13300
|
+
ref: ke,
|
|
13297
13301
|
style: {
|
|
13298
13302
|
position: "relative",
|
|
13299
13303
|
display: "flex",
|
|
@@ -13531,7 +13535,7 @@ function Fg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
13531
13535
|
children: [
|
|
13532
13536
|
/* @__PURE__ */ _("button", {
|
|
13533
13537
|
onClick: () => {
|
|
13534
|
-
k(!1),
|
|
13538
|
+
k(!1), De.current = "chat", Ve(t);
|
|
13535
13539
|
},
|
|
13536
13540
|
style: {
|
|
13537
13541
|
display: "flex",
|
|
@@ -13560,7 +13564,7 @@ function Fg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
13560
13564
|
}),
|
|
13561
13565
|
/* @__PURE__ */ _("button", {
|
|
13562
13566
|
onClick: () => {
|
|
13563
|
-
k(!1),
|
|
13567
|
+
k(!1), De.current = "minimized", Ve(n);
|
|
13564
13568
|
},
|
|
13565
13569
|
style: {
|
|
13566
13570
|
display: "flex",
|
|
@@ -13686,54 +13690,54 @@ var Lg = () => /* @__PURE__ */ g("div", {
|
|
|
13686
13690
|
} }, e))
|
|
13687
13691
|
})
|
|
13688
13692
|
});
|
|
13689
|
-
function Rg({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i, quickChatOptions: a, onQuickChatSelect: o, isMobile: s, chatHistory: l, isAiTyping: u, isAgentTyping: d, activeScreen: f, agentName: v, agentHeadshot: y, fallbackAgentName: b, input: x, setInput: S, onSubmit: C, isConversationEnded: w, isLoading: T, isRateLimited: E, rateLimitMessage: D, selectedFile: ee, onFileSelect: O, onRemoveSelectedFile: k, attachmentError: te, isUploadingAttachment: ne, requiresEmail: re, emailInput: A, setEmailInput: ie, emailError: ae, emailCaptureSuccess: oe, replyContext:
|
|
13690
|
-
let
|
|
13693
|
+
function Rg({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i, quickChatOptions: a, onQuickChatSelect: o, isMobile: s, chatHistory: l, isAiTyping: u, isAgentTyping: d, activeScreen: f, agentName: v, agentHeadshot: y, fallbackAgentName: b, input: x, setInput: S, onSubmit: C, isConversationEnded: w, isLoading: T, isRateLimited: E, rateLimitMessage: D, selectedFile: ee, onFileSelect: O, onRemoveSelectedFile: k, attachmentError: te, isUploadingAttachment: ne, requiresEmail: re, emailInput: A, setEmailInput: ie, emailError: ae, emailCaptureSuccess: oe, replyContext: j, setReplyContext: M, webRTCError: se, micError: ce, setMicError: le, dismissCallError: ue, activeCallId: de, isCallMuted: fe, toggleCallMute: pe, endWebRTCCall: me, formatCallDuration: he, callDurationSeconds: ge, isCallMinimized: _e, onExpand: N, onCollapse: ve, onStartVoice: ye, voiceEnabled: be, headerBgColor: xe, onNewChat: Se, showPoweredBy: Ce, privacyPolicyUrl: P, getVisitorChatHistory: we, resumeChat: Te, isSessionRestoring: F, isClosing: Ee }) {
|
|
13694
|
+
let De = l.length > 0, Oe = T || E || w, I = !!de, [ke, Ae] = m(!1), [je, Me] = m(!1), [Ne, L] = m([]), [R, Pe] = m(!1), Fe = p(null), [Ie, z] = m(() => typeof window < "u" ? window.visualViewport?.height ?? window.innerHeight : 600), [Le, Re] = m(0);
|
|
13691
13695
|
c(() => {
|
|
13692
13696
|
if (!s) return;
|
|
13693
13697
|
let e = window.visualViewport;
|
|
13694
13698
|
if (!e) return;
|
|
13695
13699
|
let t = () => {
|
|
13696
|
-
|
|
13700
|
+
z(e.height), Re(Math.max(0, window.innerHeight - e.offsetTop - e.height));
|
|
13697
13701
|
};
|
|
13698
13702
|
return e.addEventListener("resize", t), e.addEventListener("scroll", t), t(), () => {
|
|
13699
13703
|
e.removeEventListener("resize", t), e.removeEventListener("scroll", t);
|
|
13700
13704
|
};
|
|
13701
13705
|
}, [s]);
|
|
13702
|
-
let
|
|
13703
|
-
|
|
13706
|
+
let ze = s && window.innerHeight - Ie > 150, Be = async () => {
|
|
13707
|
+
Ae(!1), Me(!0), Pe(!0);
|
|
13704
13708
|
try {
|
|
13705
|
-
let e = await
|
|
13709
|
+
let e = await we();
|
|
13706
13710
|
e?.data && L(e.data);
|
|
13707
13711
|
} catch (e) {
|
|
13708
13712
|
console.error(e);
|
|
13709
13713
|
} finally {
|
|
13710
|
-
|
|
13714
|
+
Pe(!1);
|
|
13711
13715
|
}
|
|
13712
|
-
},
|
|
13713
|
-
|
|
13716
|
+
}, Ve = async (e) => {
|
|
13717
|
+
Me(!1), Te?.(e.chatId);
|
|
13714
13718
|
};
|
|
13715
13719
|
return c(() => {
|
|
13716
|
-
if (!
|
|
13720
|
+
if (!ke) return;
|
|
13717
13721
|
let e = (e) => {
|
|
13718
13722
|
let t = e.composedPath?.()?.[0] || e.target;
|
|
13719
|
-
|
|
13723
|
+
Fe.current && !Fe.current.contains(t) && Ae(!1);
|
|
13720
13724
|
};
|
|
13721
13725
|
return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
|
|
13722
|
-
}, [
|
|
13726
|
+
}, [ke]), /* @__PURE__ */ _("div", {
|
|
13723
13727
|
style: s ? {
|
|
13724
13728
|
"--flowengage-primary": n,
|
|
13725
13729
|
"--flowengage-accent": n,
|
|
13726
13730
|
position: "fixed",
|
|
13727
13731
|
left: "0",
|
|
13728
13732
|
right: "0",
|
|
13729
|
-
bottom: `${
|
|
13730
|
-
height:
|
|
13733
|
+
bottom: `${Le}px`,
|
|
13734
|
+
height: Ie > 0 ? `${Math.round(Ie * (ze ? 1 : .92))}px` : "90dvh",
|
|
13731
13735
|
background: r,
|
|
13732
13736
|
borderRadius: "16px 16px 0 0",
|
|
13733
13737
|
display: "flex",
|
|
13734
13738
|
flexDirection: "column",
|
|
13735
13739
|
overflow: "hidden",
|
|
13736
|
-
animation:
|
|
13740
|
+
animation: Ee ? "fe-orb-slide-down 0.28s cubic-bezier(0.16,1,0.3,1) forwards" : "fe-orb-slide-up 0.28s cubic-bezier(0.16,1,0.3,1)"
|
|
13737
13741
|
} : {
|
|
13738
13742
|
"--flowengage-primary": n,
|
|
13739
13743
|
"--flowengage-accent": n,
|
|
@@ -13746,7 +13750,7 @@ function Rg({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
13746
13750
|
flexDirection: "column",
|
|
13747
13751
|
overflow: "hidden",
|
|
13748
13752
|
position: "relative",
|
|
13749
|
-
animation:
|
|
13753
|
+
animation: Ee ? "fe-orb-slide-down 0.28s cubic-bezier(0.16,1,0.3,1) forwards" : "fe-orb-slide-up 0.36s cubic-bezier(0.16,1,0.3,1)"
|
|
13750
13754
|
},
|
|
13751
13755
|
children: [
|
|
13752
13756
|
/* @__PURE__ */ _("div", {
|
|
@@ -13756,7 +13760,7 @@ function Rg({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
13756
13760
|
alignItems: "center",
|
|
13757
13761
|
columnGap: "14px",
|
|
13758
13762
|
padding: "16px 10px 14px",
|
|
13759
|
-
background:
|
|
13763
|
+
background: xe || "transparent",
|
|
13760
13764
|
flexShrink: 0,
|
|
13761
13765
|
position: "relative",
|
|
13762
13766
|
zIndex: 30
|
|
@@ -13769,7 +13773,7 @@ function Rg({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
13769
13773
|
alignItems: "center"
|
|
13770
13774
|
},
|
|
13771
13775
|
children: /* @__PURE__ */ g("button", {
|
|
13772
|
-
onClick:
|
|
13776
|
+
onClick: ve,
|
|
13773
13777
|
style: {
|
|
13774
13778
|
width: "40px",
|
|
13775
13779
|
height: "40px",
|
|
@@ -13871,10 +13875,10 @@ function Rg({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
13871
13875
|
isolation: "isolate",
|
|
13872
13876
|
zIndex: 10
|
|
13873
13877
|
},
|
|
13874
|
-
ref:
|
|
13878
|
+
ref: Fe,
|
|
13875
13879
|
children: [/* @__PURE__ */ g("button", {
|
|
13876
13880
|
type: "button",
|
|
13877
|
-
onClick: () =>
|
|
13881
|
+
onClick: () => Ae((e) => !e),
|
|
13878
13882
|
style: {
|
|
13879
13883
|
width: "40px",
|
|
13880
13884
|
height: "40px",
|
|
@@ -13920,7 +13924,7 @@ function Rg({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
13920
13924
|
})
|
|
13921
13925
|
]
|
|
13922
13926
|
})
|
|
13923
|
-
}),
|
|
13927
|
+
}), ke && /* @__PURE__ */ _("div", {
|
|
13924
13928
|
style: {
|
|
13925
13929
|
position: "absolute",
|
|
13926
13930
|
top: "34px",
|
|
@@ -13936,10 +13940,10 @@ function Rg({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
13936
13940
|
animation: "fe-orb-fade-in 0.18s ease"
|
|
13937
13941
|
},
|
|
13938
13942
|
children: [
|
|
13939
|
-
|
|
13943
|
+
be && /* @__PURE__ */ _(h, { children: [/* @__PURE__ */ _("button", {
|
|
13940
13944
|
type: "button",
|
|
13941
13945
|
onClick: () => {
|
|
13942
|
-
|
|
13946
|
+
Ae(!1), ye?.();
|
|
13943
13947
|
},
|
|
13944
13948
|
style: {
|
|
13945
13949
|
display: "flex",
|
|
@@ -13981,7 +13985,7 @@ function Rg({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
13981
13985
|
/* @__PURE__ */ _("button", {
|
|
13982
13986
|
type: "button",
|
|
13983
13987
|
onClick: () => {
|
|
13984
|
-
|
|
13988
|
+
Ae(!1), Se?.();
|
|
13985
13989
|
},
|
|
13986
13990
|
style: {
|
|
13987
13991
|
display: "flex",
|
|
@@ -14016,13 +14020,13 @@ function Rg({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
14016
14020
|
children: [/* @__PURE__ */ g("path", { d: "M12 5H5a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-7" }), /* @__PURE__ */ g("path", { d: "M18.5 2.5a2.121 2.121 0 013 3L12 15l-4 1 1-4 9.5-9.5z" })]
|
|
14017
14021
|
}), "Start new chat"]
|
|
14018
14022
|
}),
|
|
14019
|
-
|
|
14023
|
+
we && /* @__PURE__ */ _(h, { children: [/* @__PURE__ */ g("div", { style: {
|
|
14020
14024
|
height: "1px",
|
|
14021
14025
|
background: "rgba(255,255,255,0.07)",
|
|
14022
14026
|
margin: "0 14px"
|
|
14023
14027
|
} }), /* @__PURE__ */ _("button", {
|
|
14024
14028
|
type: "button",
|
|
14025
|
-
onClick:
|
|
14029
|
+
onClick: Be,
|
|
14026
14030
|
style: {
|
|
14027
14031
|
display: "flex",
|
|
14028
14032
|
alignItems: "center",
|
|
@@ -14064,7 +14068,7 @@ function Rg({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
14064
14068
|
/* @__PURE__ */ _("button", {
|
|
14065
14069
|
type: "button",
|
|
14066
14070
|
onClick: () => {
|
|
14067
|
-
|
|
14071
|
+
Ae(!1), ve?.();
|
|
14068
14072
|
},
|
|
14069
14073
|
style: {
|
|
14070
14074
|
display: "flex",
|
|
@@ -14123,23 +14127,23 @@ function Rg({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
14123
14127
|
]
|
|
14124
14128
|
}),
|
|
14125
14129
|
/* @__PURE__ */ g(_h, {
|
|
14126
|
-
webRTCError:
|
|
14127
|
-
micError:
|
|
14128
|
-
setMicError:
|
|
14129
|
-
dismissCallError:
|
|
14130
|
+
webRTCError: se,
|
|
14131
|
+
micError: ce,
|
|
14132
|
+
setMicError: le,
|
|
14133
|
+
dismissCallError: ue,
|
|
14130
14134
|
isRateLimited: E,
|
|
14131
14135
|
rateLimitMessage: D
|
|
14132
14136
|
}),
|
|
14133
|
-
|
|
14137
|
+
_e && /* @__PURE__ */ g(Ph, {
|
|
14134
14138
|
agentName: v,
|
|
14135
14139
|
agentHeadshot: y,
|
|
14136
14140
|
fallbackAgentName: b,
|
|
14137
|
-
callDurationSeconds:
|
|
14138
|
-
isCallMuted:
|
|
14139
|
-
formatCallDuration:
|
|
14140
|
-
toggleCallMute:
|
|
14141
|
-
endWebRTCCall:
|
|
14142
|
-
onExpand:
|
|
14141
|
+
callDurationSeconds: ge,
|
|
14142
|
+
isCallMuted: fe,
|
|
14143
|
+
formatCallDuration: he,
|
|
14144
|
+
toggleCallMute: pe,
|
|
14145
|
+
endWebRTCCall: me,
|
|
14146
|
+
onExpand: N,
|
|
14143
14147
|
primaryColor: n
|
|
14144
14148
|
}),
|
|
14145
14149
|
/* @__PURE__ */ _("div", {
|
|
@@ -14151,7 +14155,7 @@ function Rg({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
14151
14155
|
background: "transparent",
|
|
14152
14156
|
position: "relative"
|
|
14153
14157
|
},
|
|
14154
|
-
children: [
|
|
14158
|
+
children: [je ? /* @__PURE__ */ _("div", {
|
|
14155
14159
|
style: {
|
|
14156
14160
|
position: "absolute",
|
|
14157
14161
|
inset: 0,
|
|
@@ -14170,7 +14174,7 @@ function Rg({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
14170
14174
|
flexShrink: 0
|
|
14171
14175
|
},
|
|
14172
14176
|
children: /* @__PURE__ */ _("button", {
|
|
14173
|
-
onClick: () =>
|
|
14177
|
+
onClick: () => Me(!1),
|
|
14174
14178
|
style: {
|
|
14175
14179
|
background: "none",
|
|
14176
14180
|
border: "none",
|
|
@@ -14204,7 +14208,7 @@ function Rg({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
14204
14208
|
overflowY: "auto",
|
|
14205
14209
|
position: "relative"
|
|
14206
14210
|
},
|
|
14207
|
-
children:
|
|
14211
|
+
children: R ? /* @__PURE__ */ g("div", {
|
|
14208
14212
|
style: {
|
|
14209
14213
|
padding: "40px 20px",
|
|
14210
14214
|
textAlign: "center",
|
|
@@ -14213,7 +14217,7 @@ function Rg({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
14213
14217
|
},
|
|
14214
14218
|
children: "Loading past conversations..."
|
|
14215
14219
|
}) : Ne.length > 0 ? /* @__PURE__ */ g("div", { children: Ne.map((e) => /* @__PURE__ */ _("div", {
|
|
14216
|
-
onClick: () =>
|
|
14220
|
+
onClick: () => Ve(e),
|
|
14217
14221
|
style: {
|
|
14218
14222
|
padding: "16px 20px",
|
|
14219
14223
|
borderBottom: "1px solid #f3f4f6",
|
|
@@ -14264,18 +14268,18 @@ function Rg({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
14264
14268
|
children: "No previous chats found."
|
|
14265
14269
|
})
|
|
14266
14270
|
})]
|
|
14267
|
-
}) : null,
|
|
14271
|
+
}) : null, De ? /* @__PURE__ */ g(mh, {
|
|
14268
14272
|
chatHistory: l,
|
|
14269
14273
|
isAiTyping: u,
|
|
14270
14274
|
isLoading: T,
|
|
14271
14275
|
isAgentTyping: d,
|
|
14272
|
-
setReplyContext:
|
|
14276
|
+
setReplyContext: M,
|
|
14273
14277
|
TypingDots: Lg,
|
|
14274
14278
|
primaryColor: n,
|
|
14275
14279
|
agentHeadshot: y,
|
|
14276
14280
|
agentDisplayName: v || b,
|
|
14277
14281
|
botAvatarNode: /* @__PURE__ */ g(Ig, { orbColors: t })
|
|
14278
|
-
}) :
|
|
14282
|
+
}) : F ? /* @__PURE__ */ _("div", {
|
|
14279
14283
|
style: {
|
|
14280
14284
|
flex: 1,
|
|
14281
14285
|
display: "flex",
|
|
@@ -14411,13 +14415,13 @@ function Rg({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
14411
14415
|
setInput: S,
|
|
14412
14416
|
onSubmit: C,
|
|
14413
14417
|
isConversationEnded: w,
|
|
14414
|
-
callUiActive:
|
|
14415
|
-
handleToggleVoice:
|
|
14418
|
+
callUiActive: I,
|
|
14419
|
+
handleToggleVoice: ye,
|
|
14416
14420
|
showVoiceToggle: f === "agent",
|
|
14417
14421
|
activeScreen: f,
|
|
14418
|
-
inputDisabled:
|
|
14419
|
-
replyContext:
|
|
14420
|
-
clearReplyContext: () =>
|
|
14422
|
+
inputDisabled: Oe,
|
|
14423
|
+
replyContext: j,
|
|
14424
|
+
clearReplyContext: () => M(null),
|
|
14421
14425
|
onFileSelect: O,
|
|
14422
14426
|
selectedFile: ee,
|
|
14423
14427
|
onRemoveSelectedFile: k,
|
|
@@ -14430,7 +14434,7 @@ function Rg({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
14430
14434
|
inputPlaceholder: e.inputPlaceholder
|
|
14431
14435
|
})
|
|
14432
14436
|
}),
|
|
14433
|
-
!
|
|
14437
|
+
!ze && /* @__PURE__ */ _("div", {
|
|
14434
14438
|
style: {
|
|
14435
14439
|
flexShrink: 0,
|
|
14436
14440
|
textAlign: "center",
|
|
@@ -14438,7 +14442,7 @@ function Rg({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
14438
14442
|
paddingBottom: "max(12px, env(safe-area-inset-bottom, 12px))",
|
|
14439
14443
|
pointerEvents: "none"
|
|
14440
14444
|
},
|
|
14441
|
-
children: [
|
|
14445
|
+
children: [P && /* @__PURE__ */ _("p", {
|
|
14442
14446
|
style: {
|
|
14443
14447
|
margin: "0 0 4px",
|
|
14444
14448
|
fontSize: "10px",
|
|
@@ -14451,7 +14455,7 @@ function Rg({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
14451
14455
|
"This conversation is recorded for quality assurance purposes.",
|
|
14452
14456
|
" ",
|
|
14453
14457
|
/* @__PURE__ */ g("a", {
|
|
14454
|
-
href:
|
|
14458
|
+
href: P,
|
|
14455
14459
|
target: "_blank",
|
|
14456
14460
|
rel: "noopener noreferrer",
|
|
14457
14461
|
style: {
|
|
@@ -14461,7 +14465,7 @@ function Rg({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
14461
14465
|
children: "See our privacy policy"
|
|
14462
14466
|
})
|
|
14463
14467
|
]
|
|
14464
|
-
}),
|
|
14468
|
+
}), Ce && /* @__PURE__ */ _("span", {
|
|
14465
14469
|
style: {
|
|
14466
14470
|
fontSize: "11px",
|
|
14467
14471
|
color: "#9ca3af",
|
|
@@ -14481,162 +14485,162 @@ function Rg({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
14481
14485
|
});
|
|
14482
14486
|
}
|
|
14483
14487
|
function zg() {
|
|
14484
|
-
let { status: e, runtimeConfig: t, resolvedConfig: n, chatHistory: r, isOpen: i, activeScreen: a, isHumanHandled: s, agentName: l, agentHeadshot: u, visitorEmail: h, isAgentTyping: v, isAiTyping: y, isLoading: b, isRateLimited: x, rateLimitMessage: S, isConversationEnded: C, incomingCall: w, activeCallId: T, callConnectionState: E, callConnectedAt: D, isCallMuted: ee, webRTCError: O, language: k, chatId: te, historyRef: ne, onMessageSync: re, sendMessage: A, uploadChatFile: ie, openWidget: ae, captureVisitorEmail: oe, setVoiceMode:
|
|
14488
|
+
let { status: e, runtimeConfig: t, resolvedConfig: n, chatHistory: r, isOpen: i, activeScreen: a, isHumanHandled: s, agentName: l, agentHeadshot: u, visitorEmail: h, isAgentTyping: v, isAiTyping: y, isLoading: b, isRateLimited: x, rateLimitMessage: S, isConversationEnded: C, incomingCall: w, activeCallId: T, callConnectionState: E, callConnectedAt: D, isCallMuted: ee, webRTCError: O, language: k, chatId: te, historyRef: ne, onMessageSync: re, sendMessage: A, uploadChatFile: ie, openWidget: ae, captureVisitorEmail: oe, setVoiceMode: j, endConversation: M, startNewChat: le, acceptCall: ue, rejectCall: de, endWebRTCCall: fe, toggleCallMute: pe, dismissCallError: me, startTyping: he, stopTyping: ge, updateTypingDraft: _e, getVisitorChatHistory: N, resumeChat: ve, isSessionRestoring: ye, openToChatCounter: be, voiceEndCounter: xe } = Cn();
|
|
14485
14489
|
c(() => {
|
|
14486
14490
|
try {
|
|
14487
14491
|
or();
|
|
14488
14492
|
} catch {}
|
|
14489
14493
|
}, []), c(() => {
|
|
14490
|
-
|
|
14491
|
-
}, [
|
|
14492
|
-
let
|
|
14493
|
-
...
|
|
14494
|
-
...
|
|
14495
|
-
},
|
|
14496
|
-
...
|
|
14497
|
-
...
|
|
14498
|
-
},
|
|
14499
|
-
...
|
|
14500
|
-
...
|
|
14501
|
-
},
|
|
14494
|
+
be && H !== "voice_mode" && H !== "text_chat" && H !== "call_screen" && (j?.(!1), U("text_chat"));
|
|
14495
|
+
}, [be]);
|
|
14496
|
+
let Se = t?.widgetSettings || {}, Ce = n?.widgetSettings || {}, P = {
|
|
14497
|
+
...Se.branding || {},
|
|
14498
|
+
...Ce.branding || {}
|
|
14499
|
+
}, F = {
|
|
14500
|
+
...Se.theme || {},
|
|
14501
|
+
...Ce.theme || {}
|
|
14502
|
+
}, Ee = {
|
|
14503
|
+
...Se.features || {},
|
|
14504
|
+
...Ce.features || {}
|
|
14505
|
+
}, Oe = Ee.voice !== !1, I = Array.isArray(F.orbColors) && F.orbColors.length > 0 ? F.orbColors : null, Ae = F.buttonColor || F.primaryColor || I?.[0] || "#3B82F6", je = {
|
|
14502
14506
|
small: 50,
|
|
14503
14507
|
medium: 64,
|
|
14504
14508
|
large: 80
|
|
14505
|
-
},
|
|
14509
|
+
}, Me = je[F.orbSize] || je.small, Ne = F.position || "bottom-right", L = P.fallbackAgentName || "Agent", R = Eg(I ?? F.chatBgColors), Pe = P.logo || P.logoUrl || null, Fe = k || "en", Ie = Se.recommendations?.[Fe] || [], z = (Ce.recommendations?.[Fe] ?? Ie).filter((e) => String(e?.label ?? "").trim()).map((e, t) => ({
|
|
14506
14510
|
id: e.key || `qr-${t}`,
|
|
14507
14511
|
label: e.label,
|
|
14508
14512
|
message: e.label,
|
|
14509
14513
|
text: e.label
|
|
14510
|
-
})),
|
|
14514
|
+
})), Le = Array.isArray(P.quickChatOptions) && P.quickChatOptions.length > 0 ? P.quickChatOptions : z, Re = P.hideWatermark === !0 ? !1 : P.showPoweredBy !== !1, ze = P.headerBgColor || null, Be = F.bottomPosition == null ? "1.5rem" : `${F.bottomPosition}px`, Ve = P.privacyPolicyUrl || null, He = P.chatbotEnabled !== !1 && F.chatbotEnabled !== !1, [Ue, We] = m(() => typeof window < "u" ? window.location.pathname : "/");
|
|
14511
14515
|
c(() => {
|
|
14512
14516
|
if (typeof window > "u") return;
|
|
14513
|
-
let e = () =>
|
|
14517
|
+
let e = () => We(window.location.pathname), t = window.history.pushState.bind(window.history);
|
|
14514
14518
|
return window.history.pushState = (...n) => {
|
|
14515
14519
|
t(...n), setTimeout(e, 50);
|
|
14516
14520
|
}, window.addEventListener("popstate", e), () => {
|
|
14517
14521
|
window.history.pushState = t, window.removeEventListener("popstate", e);
|
|
14518
14522
|
};
|
|
14519
14523
|
}, []);
|
|
14520
|
-
let
|
|
14524
|
+
let Ge = (() => {
|
|
14521
14525
|
let e = {
|
|
14522
|
-
...
|
|
14523
|
-
...
|
|
14526
|
+
...Se.pageVisibility || {},
|
|
14527
|
+
...Ce.pageVisibility || {}
|
|
14524
14528
|
};
|
|
14525
14529
|
return Array.isArray(e.allowedPaths) ? e.allowedPaths.filter(Boolean) : [];
|
|
14526
|
-
})(),
|
|
14527
|
-
entryPrompt:
|
|
14528
|
-
yesLabel:
|
|
14529
|
-
laterLabel:
|
|
14530
|
-
connectionTitle:
|
|
14531
|
-
connectionSubtitle:
|
|
14532
|
-
voiceLabel:
|
|
14533
|
-
textLabel:
|
|
14534
|
-
chatTitle:
|
|
14535
|
-
hasCustomTitle: !!(
|
|
14536
|
-
introGreeting:
|
|
14537
|
-
inputPlaceholder:
|
|
14538
|
-
analysingLabel:
|
|
14539
|
-
},
|
|
14530
|
+
})(), Ke = Ge.length === 0 || Ge.some((e) => e === "*" || e === "/*" ? !0 : e.endsWith("/*") ? Ue.startsWith(e.slice(0, -1)) : Ue.replace(/\/$/, "") === e.replace(/\/$/, "")), qe = Se.greetings?.[k] || Ce.greetings?.[k] || P.introGreeting || "Hello, I'm here to help you know more about OpenSense Labs.", Je = {
|
|
14531
|
+
entryPrompt: P.entryPrompt || "Do you want to explore in a new way?",
|
|
14532
|
+
yesLabel: P.yesLabel || "Yes",
|
|
14533
|
+
laterLabel: P.laterLabel || "Later",
|
|
14534
|
+
connectionTitle: P.connectionTitle || "How would you like to connect?",
|
|
14535
|
+
connectionSubtitle: P.connectionSubtitle || "",
|
|
14536
|
+
voiceLabel: P.voiceLabel || "Voice",
|
|
14537
|
+
textLabel: P.textLabel || "Text",
|
|
14538
|
+
chatTitle: P.headerName || "Chat with FlowEngage",
|
|
14539
|
+
hasCustomTitle: !!(P.headerName && String(P.headerName).trim()),
|
|
14540
|
+
introGreeting: qe,
|
|
14541
|
+
inputPlaceholder: P.inputPlaceholder || "Type your message",
|
|
14542
|
+
analysingLabel: P.analysingLabel || "analysing..."
|
|
14543
|
+
}, Ye = Ce.elevenLabsAgentId || t?.elevenLabsAgentId || null, B = t?.siteId || n?.siteId || null, V = t?.apiBaseUrl || "";
|
|
14540
14544
|
c(() => {
|
|
14541
14545
|
Kn(t?.siteType || null);
|
|
14542
14546
|
}, [t?.siteType]);
|
|
14543
|
-
let
|
|
14547
|
+
let Xe = f(() => l && String(l).trim() || t?.ownerName && String(t.ownerName).trim() || t?.websiteName && String(t.websiteName).trim() || "Agent", [
|
|
14544
14548
|
l,
|
|
14545
14549
|
t?.ownerName,
|
|
14546
14550
|
t?.websiteName
|
|
14547
|
-
]),
|
|
14551
|
+
]), Ze = u && String(u).trim() || t?.ownerProfileImageUrl && String(t.ownerProfileImageUrl).trim() || null, Qe = r.some((e) => e.sender === "user"), $e = f(() => {
|
|
14548
14552
|
let e = r.findIndex((e) => e.sender === "user");
|
|
14549
14553
|
return e === -1 ? !1 : r.slice(e + 1).some((e) => e.sender === "bot" || e.sender === "ai" || e.sender === "agent");
|
|
14550
|
-
}, [r]),
|
|
14554
|
+
}, [r]), et = !!(Ce._dashboardLivePreview || Se._dashboardLivePreview), [H, U] = m(() => et ? "text_chat" : "entry_prompt"), [tt, nt] = m(""), [rt, W] = m(null), [it, at] = m(h || ""), [G, ot] = m(""), [st, ct] = m(!1), [lt, ut] = m(0), [dt, ft] = m(null), [pt, mt] = m(null), [ht, gt] = m(""), [_t, vt] = m(!1), [yt, bt] = m(!1), [xt, St] = m(!1), Ct = p(null), wt = p(!1), Tt = !h && Qe && $e && H !== "voice_mode";
|
|
14551
14555
|
d(() => {
|
|
14552
|
-
if (e !== "ready" ||
|
|
14553
|
-
if (
|
|
14554
|
-
|
|
14556
|
+
if (e !== "ready" || wt.current) return;
|
|
14557
|
+
if (wt.current = !0, !Oe) {
|
|
14558
|
+
U("minimized_orb");
|
|
14555
14559
|
return;
|
|
14556
14560
|
}
|
|
14557
14561
|
let t = !1;
|
|
14558
14562
|
try {
|
|
14559
14563
|
t = vr().shouldResumeVoice;
|
|
14560
14564
|
} catch {}
|
|
14561
|
-
let n =
|
|
14565
|
+
let n = De(), r = B ? we(B) : null, i = n || !!r?.transcript;
|
|
14562
14566
|
if (t) {
|
|
14563
|
-
ae?.({ notifyChatInitiated: !0 }),
|
|
14567
|
+
ae?.({ notifyChatInitiated: !0 }), j?.(!0), U("voice_mode");
|
|
14564
14568
|
return;
|
|
14565
14569
|
}
|
|
14566
|
-
if (
|
|
14567
|
-
ae?.({ notifyChatInitiated: !1 }),
|
|
14570
|
+
if (ke()) {
|
|
14571
|
+
ae?.({ notifyChatInitiated: !1 }), U("text_chat");
|
|
14568
14572
|
return;
|
|
14569
14573
|
}
|
|
14570
14574
|
if (i) {
|
|
14571
14575
|
if ((typeof performance < "u" ? performance.getEntriesByType?.("navigation")?.[0]?.type ?? "navigate" : "navigate") === "reload") {
|
|
14572
|
-
|
|
14576
|
+
U("minimized_orb");
|
|
14573
14577
|
return;
|
|
14574
14578
|
}
|
|
14575
|
-
ae?.({ notifyChatInitiated: !0 }),
|
|
14579
|
+
ae?.({ notifyChatInitiated: !0 }), j?.(!0), U("voice_mode");
|
|
14576
14580
|
return;
|
|
14577
14581
|
}
|
|
14578
|
-
if (
|
|
14579
|
-
|
|
14582
|
+
if (B) try {
|
|
14583
|
+
Te(B);
|
|
14580
14584
|
} catch {}
|
|
14581
|
-
if (
|
|
14582
|
-
|
|
14585
|
+
if (se(B)) {
|
|
14586
|
+
U("minimized_orb");
|
|
14583
14587
|
return;
|
|
14584
14588
|
}
|
|
14585
14589
|
}, [e, r]);
|
|
14586
|
-
let [
|
|
14590
|
+
let [Et, Dt] = m(() => typeof window < "u" && window.matchMedia("(max-width: 640px)").matches);
|
|
14587
14591
|
c(() => {
|
|
14588
14592
|
let e = window.matchMedia("(max-width: 640px)"), t = (e) => Dt(e.matches);
|
|
14589
14593
|
return e.addEventListener("change", t), () => e.removeEventListener("change", t);
|
|
14590
14594
|
}, []), c(() => {
|
|
14591
|
-
|
|
14595
|
+
at(h || ""), h && ot("");
|
|
14592
14596
|
}, [h]);
|
|
14593
14597
|
let Ot = o(() => {
|
|
14594
|
-
|
|
14598
|
+
mt(null), gt("");
|
|
14595
14599
|
}, []), kt = o((e) => {
|
|
14596
14600
|
let t = lh(e);
|
|
14597
14601
|
if (t) {
|
|
14598
|
-
|
|
14602
|
+
mt(null), gt(t);
|
|
14599
14603
|
return;
|
|
14600
14604
|
}
|
|
14601
|
-
|
|
14605
|
+
mt(e), gt("");
|
|
14602
14606
|
}, []);
|
|
14603
14607
|
c(() => {
|
|
14604
14608
|
if (!D || E !== "connected") {
|
|
14605
|
-
|
|
14609
|
+
ut(0);
|
|
14606
14610
|
return;
|
|
14607
14611
|
}
|
|
14608
14612
|
let e = () => {
|
|
14609
14613
|
let e = new Date(D).getTime();
|
|
14610
|
-
isNaN(e) ||
|
|
14614
|
+
isNaN(e) || ut(Math.max(0, Math.floor((Date.now() - e) / 1e3)));
|
|
14611
14615
|
};
|
|
14612
14616
|
e();
|
|
14613
14617
|
let t = window.setInterval(e, 1e3);
|
|
14614
14618
|
return () => window.clearInterval(t);
|
|
14615
14619
|
}, [D, E]);
|
|
14616
14620
|
let At = o(() => {
|
|
14617
|
-
|
|
14621
|
+
U("call_screen"), bt(!1);
|
|
14618
14622
|
}, []), jt = o(() => {
|
|
14619
|
-
|
|
14623
|
+
U("text_chat"), bt(!0);
|
|
14620
14624
|
}, []);
|
|
14621
14625
|
c(() => {
|
|
14622
14626
|
let e = w?.callId || T || null;
|
|
14623
14627
|
if (!e) {
|
|
14624
|
-
|
|
14628
|
+
Ct.current = null;
|
|
14625
14629
|
return;
|
|
14626
14630
|
}
|
|
14627
14631
|
if (w?.callId || E === "connecting" || E === "connected") {
|
|
14628
|
-
if (
|
|
14629
|
-
|
|
14632
|
+
if (H === "minimized_orb" && yt && T && !w?.callId) {
|
|
14633
|
+
Ct.current = e;
|
|
14630
14634
|
return;
|
|
14631
14635
|
}
|
|
14632
|
-
!(!i ||
|
|
14636
|
+
!(!i || H === "minimized_orb" || H === "voice_mode") && Ct.current === e || (console.log("[FlowEngageWidget] forcing call UI to front", {
|
|
14633
14637
|
forcedKey: e,
|
|
14634
14638
|
isOpen: i,
|
|
14635
|
-
surface:
|
|
14639
|
+
surface: H,
|
|
14636
14640
|
hasIncomingCall: !!w?.callId,
|
|
14637
14641
|
activeCallId: T,
|
|
14638
14642
|
callConnectionState: E
|
|
14639
|
-
}),
|
|
14643
|
+
}), Ct.current = e, H === "voice_mode" && j?.(!1), ae?.(), At());
|
|
14640
14644
|
}
|
|
14641
14645
|
}, [
|
|
14642
14646
|
T,
|
|
@@ -14645,39 +14649,39 @@ function zg() {
|
|
|
14645
14649
|
w?.callId,
|
|
14646
14650
|
i,
|
|
14647
14651
|
ae,
|
|
14648
|
-
|
|
14649
|
-
|
|
14652
|
+
j,
|
|
14653
|
+
H
|
|
14650
14654
|
]), c(() => {
|
|
14651
|
-
!w && !T &&
|
|
14655
|
+
!w && !T && H === "call_screen" && U("text_chat");
|
|
14652
14656
|
}, [
|
|
14653
14657
|
w,
|
|
14654
14658
|
T,
|
|
14655
|
-
|
|
14659
|
+
H
|
|
14656
14660
|
]), c(() => {
|
|
14657
|
-
!T &&
|
|
14658
|
-
}, [T,
|
|
14661
|
+
!T && yt && bt(!1);
|
|
14662
|
+
}, [T, yt]), c(() => {
|
|
14659
14663
|
if (!s || C) {
|
|
14660
|
-
|
|
14664
|
+
_e?.(""), ge?.();
|
|
14661
14665
|
return;
|
|
14662
14666
|
}
|
|
14663
|
-
if (!
|
|
14664
|
-
|
|
14665
|
-
let e = window.setTimeout(() =>
|
|
14667
|
+
if (!tt.trim() || pt) {
|
|
14668
|
+
_e?.("");
|
|
14669
|
+
let e = window.setTimeout(() => ge?.(), 100);
|
|
14666
14670
|
return () => window.clearTimeout(e);
|
|
14667
14671
|
}
|
|
14668
|
-
|
|
14669
|
-
let e = window.setTimeout(() =>
|
|
14672
|
+
he?.();
|
|
14673
|
+
let e = window.setTimeout(() => _e?.(tt), 120), t = window.setTimeout(() => ge?.(), 1200);
|
|
14670
14674
|
return () => {
|
|
14671
14675
|
window.clearTimeout(e), window.clearTimeout(t);
|
|
14672
14676
|
};
|
|
14673
14677
|
}, [
|
|
14674
|
-
|
|
14675
|
-
|
|
14678
|
+
tt,
|
|
14679
|
+
pt,
|
|
14676
14680
|
s,
|
|
14677
14681
|
C,
|
|
14682
|
+
he,
|
|
14678
14683
|
ge,
|
|
14679
|
-
_e
|
|
14680
|
-
ve
|
|
14684
|
+
_e
|
|
14681
14685
|
]);
|
|
14682
14686
|
let Mt = (e) => e ? {
|
|
14683
14687
|
replyTo: e.messageId || e.id || null,
|
|
@@ -14685,42 +14689,42 @@ function zg() {
|
|
|
14685
14689
|
replyToSender: e.sender || null
|
|
14686
14690
|
} : null, Nt = async (e) => {
|
|
14687
14691
|
if (e.preventDefault(), C) return;
|
|
14688
|
-
if (
|
|
14689
|
-
let e =
|
|
14692
|
+
if (Tt) {
|
|
14693
|
+
let e = it.trim().toLowerCase();
|
|
14690
14694
|
if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e)) {
|
|
14691
|
-
|
|
14695
|
+
ot("Please enter a valid email so we can continue helping you.");
|
|
14692
14696
|
return;
|
|
14693
14697
|
}
|
|
14694
|
-
await oe(e),
|
|
14698
|
+
await oe(e), ot(""), ct(!0), setTimeout(() => ct(!1), 3e3);
|
|
14695
14699
|
return;
|
|
14696
14700
|
}
|
|
14697
|
-
let t = Mt(
|
|
14698
|
-
if (!
|
|
14699
|
-
if (
|
|
14701
|
+
let t = Mt(rt);
|
|
14702
|
+
if (!tt.trim() && !pt) return;
|
|
14703
|
+
if (pt) {
|
|
14700
14704
|
try {
|
|
14701
|
-
|
|
14702
|
-
let e = await ie(
|
|
14703
|
-
|
|
14705
|
+
vt(!0), gt("");
|
|
14706
|
+
let e = await ie(pt), n = e?.data || e, r = tt.trim() || `Shared file: ${dh(pt)}`;
|
|
14707
|
+
nt(""), W(null), Ot(), await A(r, "", t, {
|
|
14704
14708
|
type: "file",
|
|
14705
14709
|
metadata: {
|
|
14706
14710
|
fileUrl: n?.fileUrl,
|
|
14707
|
-
fileName: n?.fileName ||
|
|
14708
|
-
fileType: n?.fileType ||
|
|
14709
|
-
fileSize: n?.fileSize ||
|
|
14711
|
+
fileName: n?.fileName || pt.name,
|
|
14712
|
+
fileType: n?.fileType || pt.type,
|
|
14713
|
+
fileSize: n?.fileSize || pt.size
|
|
14710
14714
|
}
|
|
14711
14715
|
});
|
|
14712
14716
|
} catch (e) {
|
|
14713
|
-
|
|
14717
|
+
gt(e?.message || "Failed to upload the selected file.");
|
|
14714
14718
|
} finally {
|
|
14715
|
-
|
|
14719
|
+
vt(!1);
|
|
14716
14720
|
}
|
|
14717
14721
|
return;
|
|
14718
14722
|
}
|
|
14719
|
-
let n =
|
|
14720
|
-
|
|
14723
|
+
let n = tt.trim();
|
|
14724
|
+
nt(""), W(null), await A(n, "", t);
|
|
14721
14725
|
}, Pt = o(() => {
|
|
14722
|
-
r.length !== 0 &&
|
|
14723
|
-
}, [r.length,
|
|
14726
|
+
r.length !== 0 && le?.();
|
|
14727
|
+
}, [r.length, le]), Ft = (e) => {
|
|
14724
14728
|
let t = Math.floor(e / 60);
|
|
14725
14729
|
return `${String(t).padStart(2, "0")}:${String(e % 60).padStart(2, "0")}`;
|
|
14726
14730
|
}, It = o(async (e) => {
|
|
@@ -14731,44 +14735,44 @@ function zg() {
|
|
|
14731
14735
|
C,
|
|
14732
14736
|
b,
|
|
14733
14737
|
A
|
|
14734
|
-
]), Lt =
|
|
14738
|
+
]), Lt = Et && H === "entry_prompt" ? { inset: 0 } : Et && H === "text_chat" ? {
|
|
14735
14739
|
left: 0,
|
|
14736
14740
|
right: 0,
|
|
14737
14741
|
bottom: 0
|
|
14738
|
-
} :
|
|
14742
|
+
} : Et && H === "call_screen" ? {
|
|
14739
14743
|
left: 0,
|
|
14740
14744
|
right: 0,
|
|
14741
14745
|
bottom: 0,
|
|
14742
14746
|
height: "90dvh",
|
|
14743
14747
|
overflow: "hidden",
|
|
14744
14748
|
borderRadius: "16px 16px 0 0"
|
|
14745
|
-
} :
|
|
14749
|
+
} : Et && H === "connection_modal" ? {
|
|
14746
14750
|
left: "12px",
|
|
14747
14751
|
right: "12px",
|
|
14748
14752
|
bottom: "12px"
|
|
14749
|
-
} :
|
|
14753
|
+
} : H === "call_screen" ? {
|
|
14750
14754
|
width: "min(350px, calc(100vw - 40px))",
|
|
14751
14755
|
height: "min(640px, calc(100vh - 120px))",
|
|
14752
14756
|
borderRadius: "22px",
|
|
14753
14757
|
overflow: "hidden",
|
|
14754
14758
|
...Ne === "bottom-left" ? {
|
|
14755
14759
|
left: "1.5rem",
|
|
14756
|
-
bottom:
|
|
14760
|
+
bottom: Be
|
|
14757
14761
|
} : {
|
|
14758
14762
|
right: "1.5rem",
|
|
14759
|
-
bottom:
|
|
14763
|
+
bottom: Be
|
|
14760
14764
|
}
|
|
14761
14765
|
} : Ne === "bottom-left" ? {
|
|
14762
14766
|
left: "1.5rem",
|
|
14763
|
-
bottom:
|
|
14767
|
+
bottom: Be
|
|
14764
14768
|
} : {
|
|
14765
14769
|
right: "1.5rem",
|
|
14766
|
-
bottom:
|
|
14770
|
+
bottom: Be
|
|
14767
14771
|
}, Rt = o(() => {
|
|
14768
|
-
|
|
14769
|
-
|
|
14772
|
+
H !== "minimized_orb" && (St(!0), setTimeout(() => {
|
|
14773
|
+
U("minimized_orb"), St(!1), T && bt(!0);
|
|
14770
14774
|
}, 280));
|
|
14771
|
-
}, [T,
|
|
14775
|
+
}, [T, H]), zt = () => U("connection_modal"), Bt = () => {
|
|
14772
14776
|
try {
|
|
14773
14777
|
let e = window.AudioContext || window.webkitAudioContext;
|
|
14774
14778
|
if (e) {
|
|
@@ -14776,13 +14780,13 @@ function zg() {
|
|
|
14776
14780
|
t.resume().catch(() => {}), setTimeout(() => t.close().catch(() => {}), 3e3);
|
|
14777
14781
|
}
|
|
14778
14782
|
} catch {}
|
|
14779
|
-
ae({ notifyChatInitiated: !0 }),
|
|
14783
|
+
ae({ notifyChatInitiated: !0 }), j?.(!0), U("voice_mode");
|
|
14780
14784
|
}, Vt = () => {
|
|
14781
|
-
ae({ notifyChatInitiated: !0 }),
|
|
14785
|
+
ae({ notifyChatInitiated: !0 }), j?.(!1), U("text_chat");
|
|
14782
14786
|
}, Ht = () => {
|
|
14783
|
-
|
|
14787
|
+
j?.(!1), Rt();
|
|
14784
14788
|
};
|
|
14785
|
-
return e !== "ready" || !
|
|
14789
|
+
return e !== "ready" || !He || Ee.chat === !1 || !Ke ? null : /* @__PURE__ */ _("div", {
|
|
14786
14790
|
className: "flowengage-widget-root",
|
|
14787
14791
|
style: {
|
|
14788
14792
|
position: "fixed",
|
|
@@ -14792,20 +14796,20 @@ function zg() {
|
|
|
14792
14796
|
onWheel: (e) => e.stopPropagation(),
|
|
14793
14797
|
onTouchMove: (e) => e.stopPropagation(),
|
|
14794
14798
|
children: [
|
|
14795
|
-
|
|
14796
|
-
copy:
|
|
14797
|
-
orbColors:
|
|
14798
|
-
primaryColor:
|
|
14799
|
+
H === "entry_prompt" && /* @__PURE__ */ g(Ng, {
|
|
14800
|
+
copy: Je,
|
|
14801
|
+
orbColors: I,
|
|
14802
|
+
primaryColor: Ae,
|
|
14799
14803
|
onYes: () => {
|
|
14800
|
-
|
|
14804
|
+
ce(B), Bt();
|
|
14801
14805
|
},
|
|
14802
14806
|
onLater: () => {
|
|
14803
|
-
|
|
14807
|
+
ce(B), Rt();
|
|
14804
14808
|
},
|
|
14805
|
-
isMobile:
|
|
14806
|
-
isClosing:
|
|
14809
|
+
isMobile: Et,
|
|
14810
|
+
isClosing: xt
|
|
14807
14811
|
}),
|
|
14808
|
-
|
|
14812
|
+
H === "minimized_orb" && /* @__PURE__ */ _(ym.div, {
|
|
14809
14813
|
layoutId: "fe-main-orb",
|
|
14810
14814
|
initial: {
|
|
14811
14815
|
scale: .4,
|
|
@@ -14831,7 +14835,7 @@ function zg() {
|
|
|
14831
14835
|
type: "button",
|
|
14832
14836
|
onClick: At,
|
|
14833
14837
|
style: {
|
|
14834
|
-
maxWidth:
|
|
14838
|
+
maxWidth: Et ? "220px" : "240px",
|
|
14835
14839
|
padding: "10px 14px",
|
|
14836
14840
|
borderRadius: "18px",
|
|
14837
14841
|
border: "1px solid rgba(255,255,255,0.7)",
|
|
@@ -14872,124 +14876,124 @@ function zg() {
|
|
|
14872
14876
|
marginTop: "2px",
|
|
14873
14877
|
whiteSpace: "nowrap"
|
|
14874
14878
|
},
|
|
14875
|
-
children: E === "connected" ? `${Ft(
|
|
14879
|
+
children: E === "connected" ? `${Ft(lt)} with ${Xe}` : `Tap to return to ${Xe}`
|
|
14876
14880
|
})]
|
|
14877
14881
|
})]
|
|
14878
14882
|
}), /* @__PURE__ */ g(Mg, {
|
|
14879
|
-
size:
|
|
14880
|
-
orbColors:
|
|
14881
|
-
onClick: T ? At :
|
|
14883
|
+
size: Me,
|
|
14884
|
+
orbColors: I,
|
|
14885
|
+
onClick: T ? At : Oe ? zt : Vt
|
|
14882
14886
|
})]
|
|
14883
14887
|
}),
|
|
14884
|
-
|
|
14885
|
-
copy:
|
|
14886
|
-
orbColors:
|
|
14887
|
-
primaryColor:
|
|
14888
|
+
H === "connection_modal" && /* @__PURE__ */ g(Pg, {
|
|
14889
|
+
copy: Je,
|
|
14890
|
+
orbColors: I,
|
|
14891
|
+
primaryColor: Ae,
|
|
14888
14892
|
onVoice: Bt,
|
|
14889
14893
|
onText: Vt,
|
|
14890
14894
|
onClose: Rt,
|
|
14891
|
-
isMobile:
|
|
14892
|
-
isClosing:
|
|
14895
|
+
isMobile: Et,
|
|
14896
|
+
isClosing: xt
|
|
14893
14897
|
}),
|
|
14894
|
-
|
|
14895
|
-
orbColors:
|
|
14898
|
+
H === "voice_mode" && /* @__PURE__ */ g(Fg, {
|
|
14899
|
+
orbColors: I,
|
|
14896
14900
|
onEnterChat: Vt,
|
|
14897
14901
|
onEndChat: Ht,
|
|
14898
|
-
agentId:
|
|
14899
|
-
siteId:
|
|
14900
|
-
apiBaseUrl:
|
|
14902
|
+
agentId: Ye,
|
|
14903
|
+
siteId: B,
|
|
14904
|
+
apiBaseUrl: V,
|
|
14901
14905
|
chatId: te,
|
|
14902
14906
|
historyRef: ne,
|
|
14903
14907
|
onMessageSync: re,
|
|
14904
|
-
voiceEndCounter:
|
|
14908
|
+
voiceEndCounter: xe,
|
|
14905
14909
|
websiteName: t?.websiteName,
|
|
14906
|
-
voiceFirstMessage:
|
|
14910
|
+
voiceFirstMessage: Se.voiceFirstMessage || null,
|
|
14907
14911
|
captureVisitorEmail: oe,
|
|
14908
14912
|
emailRequired: !h,
|
|
14909
|
-
emailCaptureEnabled:
|
|
14910
|
-
listeningLabel:
|
|
14911
|
-
thinkingLabel:
|
|
14912
|
-
enterChatModeLabel:
|
|
14913
|
-
endConversationLabel:
|
|
14913
|
+
emailCaptureEnabled: P.disableEmailCapture !== !0,
|
|
14914
|
+
listeningLabel: P.voiceListeningLabel || "Listening...",
|
|
14915
|
+
thinkingLabel: P.voiceThinkingLabel || "Thinking...",
|
|
14916
|
+
enterChatModeLabel: P.voiceEnterChatLabel || "Enter Chat Mode",
|
|
14917
|
+
endConversationLabel: P.voiceEndConversationLabel || "End Conversation"
|
|
14914
14918
|
}, "voice"),
|
|
14915
|
-
|
|
14919
|
+
H === "call_screen" && /* @__PURE__ */ g(Nh, {
|
|
14916
14920
|
incomingCall: w,
|
|
14917
14921
|
activeCallId: T,
|
|
14918
14922
|
callConnectionState: E,
|
|
14919
|
-
callDurationSeconds:
|
|
14923
|
+
callDurationSeconds: lt,
|
|
14920
14924
|
isCallMuted: ee,
|
|
14921
|
-
agentName:
|
|
14922
|
-
agentHeadshot:
|
|
14925
|
+
agentName: Xe,
|
|
14926
|
+
agentHeadshot: Ze,
|
|
14923
14927
|
fallbackAgentName: L,
|
|
14924
|
-
acceptCall:
|
|
14925
|
-
rejectCall:
|
|
14926
|
-
endWebRTCCall:
|
|
14927
|
-
toggleCallMute:
|
|
14928
|
+
acceptCall: ue,
|
|
14929
|
+
rejectCall: de,
|
|
14930
|
+
endWebRTCCall: fe,
|
|
14931
|
+
toggleCallMute: pe,
|
|
14928
14932
|
formatCallDuration: Ft,
|
|
14929
14933
|
onMinimize: jt,
|
|
14930
|
-
primaryColor:
|
|
14931
|
-
orbColors:
|
|
14934
|
+
primaryColor: Ae,
|
|
14935
|
+
orbColors: I,
|
|
14932
14936
|
chatHistory: r
|
|
14933
14937
|
}),
|
|
14934
|
-
|
|
14935
|
-
isClosing:
|
|
14936
|
-
copy:
|
|
14937
|
-
orbColors:
|
|
14938
|
-
primaryColor:
|
|
14939
|
-
chatBgGradient:
|
|
14940
|
-
logo:
|
|
14941
|
-
quickChatOptions:
|
|
14938
|
+
H === "text_chat" && /* @__PURE__ */ g(Rg, {
|
|
14939
|
+
isClosing: xt,
|
|
14940
|
+
copy: Je,
|
|
14941
|
+
orbColors: I,
|
|
14942
|
+
primaryColor: Ae,
|
|
14943
|
+
chatBgGradient: R,
|
|
14944
|
+
logo: Pe,
|
|
14945
|
+
quickChatOptions: Le,
|
|
14942
14946
|
onQuickChatSelect: It,
|
|
14943
|
-
isMobile:
|
|
14947
|
+
isMobile: Et,
|
|
14944
14948
|
chatHistory: r,
|
|
14945
14949
|
isAiTyping: y,
|
|
14946
14950
|
isAgentTyping: v,
|
|
14947
14951
|
activeScreen: a,
|
|
14948
|
-
agentName:
|
|
14949
|
-
agentHeadshot:
|
|
14952
|
+
agentName: Xe,
|
|
14953
|
+
agentHeadshot: Ze,
|
|
14950
14954
|
fallbackAgentName: L,
|
|
14951
|
-
input:
|
|
14952
|
-
setInput:
|
|
14955
|
+
input: tt,
|
|
14956
|
+
setInput: nt,
|
|
14953
14957
|
onSubmit: Nt,
|
|
14954
14958
|
isConversationEnded: C,
|
|
14955
14959
|
isLoading: b,
|
|
14956
14960
|
isRateLimited: x,
|
|
14957
14961
|
rateLimitMessage: S,
|
|
14958
|
-
selectedFile:
|
|
14962
|
+
selectedFile: pt,
|
|
14959
14963
|
onFileSelect: kt,
|
|
14960
14964
|
onRemoveSelectedFile: Ot,
|
|
14961
|
-
attachmentError:
|
|
14962
|
-
isUploadingAttachment:
|
|
14963
|
-
requiresEmail:
|
|
14964
|
-
emailInput:
|
|
14965
|
-
setEmailInput:
|
|
14966
|
-
emailError:
|
|
14967
|
-
emailCaptureSuccess:
|
|
14968
|
-
replyContext:
|
|
14969
|
-
setReplyContext:
|
|
14965
|
+
attachmentError: ht,
|
|
14966
|
+
isUploadingAttachment: _t,
|
|
14967
|
+
requiresEmail: Tt,
|
|
14968
|
+
emailInput: it,
|
|
14969
|
+
setEmailInput: at,
|
|
14970
|
+
emailError: G,
|
|
14971
|
+
emailCaptureSuccess: st,
|
|
14972
|
+
replyContext: rt,
|
|
14973
|
+
setReplyContext: W,
|
|
14970
14974
|
webRTCError: O,
|
|
14971
|
-
micError:
|
|
14972
|
-
setMicError:
|
|
14973
|
-
dismissCallError:
|
|
14975
|
+
micError: dt,
|
|
14976
|
+
setMicError: ft,
|
|
14977
|
+
dismissCallError: me,
|
|
14974
14978
|
activeCallId: T,
|
|
14975
14979
|
isCallMuted: ee,
|
|
14976
|
-
toggleCallMute:
|
|
14977
|
-
endWebRTCCall:
|
|
14980
|
+
toggleCallMute: pe,
|
|
14981
|
+
endWebRTCCall: fe,
|
|
14978
14982
|
formatCallDuration: Ft,
|
|
14979
|
-
callDurationSeconds:
|
|
14983
|
+
callDurationSeconds: lt,
|
|
14980
14984
|
onCollapse: Rt,
|
|
14981
14985
|
onStartVoice: Bt,
|
|
14982
|
-
voiceEnabled:
|
|
14986
|
+
voiceEnabled: Oe,
|
|
14983
14987
|
onNewChat: Pt,
|
|
14984
14988
|
onMinimize: jt,
|
|
14985
14989
|
onExpand: At,
|
|
14986
14990
|
isCallMinimized: !!T,
|
|
14987
|
-
showPoweredBy:
|
|
14988
|
-
privacyPolicyUrl:
|
|
14989
|
-
headerBgColor:
|
|
14990
|
-
getVisitorChatHistory:
|
|
14991
|
-
resumeChat:
|
|
14992
|
-
isSessionRestoring:
|
|
14991
|
+
showPoweredBy: Re,
|
|
14992
|
+
privacyPolicyUrl: Ve,
|
|
14993
|
+
headerBgColor: ze,
|
|
14994
|
+
getVisitorChatHistory: N,
|
|
14995
|
+
resumeChat: ve,
|
|
14996
|
+
isSessionRestoring: ye
|
|
14993
14997
|
}),
|
|
14994
14998
|
/* @__PURE__ */ g("style", { children: "\n /* Force any SVG (or img) inside LogoSlot to fill the container height\n regardless of whether the component forwards its style prop. */\n .fe-logo-slot svg,\n .fe-logo-slot img { height: 100%; width: auto; display: block; }\n\n @keyframes fe-orb-breathe { 0%,100%{transform:scale(1)} 50%{transform:scale(1.04)} }\n @keyframes fe-orb-breathe-subtle { 0%,100%{transform:scale(1)} 50%{transform:scale(1.025)} }\n @keyframes fe-orb-pulse { 0%{transform:scale(1);opacity:.65} 50%{transform:scale(1.28);opacity:.1} 100%{transform:scale(1);opacity:.65} }\n @keyframes fe-orb-glow { from{opacity:.35} to{opacity:.75} }\n @keyframes fe-orb-fade-in { from{opacity:0} to{opacity:1} }\n @keyframes fe-orb-slide-up { from{opacity:0;transform:translateY(18px)} to{opacity:1;transform:translateY(0)} }\n @keyframes fe-orb-slide-down { from{opacity:1;transform:translateY(0)} to{opacity:0;transform:translateY(24px)} }\n @keyframes fe-orb-bar-0 { from{height:6px} to{height:18px} }\n @keyframes fe-orb-bar-1 { from{height:10px} to{height:22px} }\n @keyframes fe-orb-bar-2 { from{height:14px} to{height:26px} }\n @keyframes fe-orb-bar-3 { from{height:8px} to{height:20px} }\n @keyframes fe-orb-bar-4 { from{height:6px} to{height:16px} }\n @keyframes fe-dot-bounce { 0%,80%,100%{transform:translateY(0);opacity:.5} 40%{transform:translateY(-5px);opacity:1} }\n " })
|
|
14995
14999
|
]
|