@flowengage/react-chatbot 8.0.111 → 8.0.112
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.
|
@@ -34,46 +34,46 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
|
|
|
34
34
|
agentName: "flowengage.agentName",
|
|
35
35
|
agentHeadshot: "flowengage.agentHeadshot",
|
|
36
36
|
visitorEmail: "flowengage.visitorEmail"
|
|
37
|
-
}, ee = 6e4, te = 480 * 60,
|
|
38
|
-
if (!
|
|
37
|
+
}, ee = 6e4, te = 480 * 60, j = 3e4, M = typeof window < "u", N = (e) => e ? `flowengage.visitorEmail.${e}` : null, ne = () => {
|
|
38
|
+
if (!M) return null;
|
|
39
39
|
let e = window.localStorage.getItem(A.chatId);
|
|
40
40
|
return e && String(e).trim() ? String(e).trim() : null;
|
|
41
41
|
}, re = () => {
|
|
42
|
-
if (
|
|
42
|
+
if (M) try {
|
|
43
43
|
window.localStorage.removeItem(A.chatId);
|
|
44
44
|
} catch {}
|
|
45
|
-
}, P = () =>
|
|
46
|
-
if (!
|
|
45
|
+
}, P = () => M ? typeof crypto < "u" && crypto.randomUUID ? crypto.randomUUID() : `${Date.now()}-${Math.random().toString(16).slice(2)}` : "server-chat-id", ie = (e) => e ? `flowengage.entrySeen.${e}` : null, F = (e) => {
|
|
46
|
+
if (!M || !e) return !1;
|
|
47
47
|
try {
|
|
48
48
|
let t = ie(e);
|
|
49
49
|
return t ? window.localStorage.getItem(t) === "1" : !1;
|
|
50
50
|
} catch {
|
|
51
51
|
return !1;
|
|
52
52
|
}
|
|
53
|
-
},
|
|
54
|
-
if (!(!
|
|
53
|
+
}, ae = (e) => {
|
|
54
|
+
if (!(!M || !e)) try {
|
|
55
55
|
let t = ie(e);
|
|
56
56
|
t && window.localStorage.setItem(t, "1");
|
|
57
57
|
} catch {}
|
|
58
|
-
},
|
|
59
|
-
if (!
|
|
58
|
+
}, I = (e) => e ? `flowengage.persistedChatId.${e}` : null, oe = (e) => {
|
|
59
|
+
if (!M || !e) return null;
|
|
60
60
|
try {
|
|
61
|
-
let t =
|
|
61
|
+
let t = I(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
|
-
},
|
|
67
|
-
if (!(!
|
|
68
|
-
let t =
|
|
66
|
+
}, se = (e) => {
|
|
67
|
+
if (!(!M || !e)) try {
|
|
68
|
+
let t = I(e);
|
|
69
69
|
t && window.localStorage.removeItem(t);
|
|
70
70
|
} catch {}
|
|
71
|
-
},
|
|
72
|
-
if (!(!
|
|
73
|
-
let n =
|
|
71
|
+
}, ce = (e, t) => {
|
|
72
|
+
if (!(!M || !e || !t)) try {
|
|
73
|
+
let n = I(e);
|
|
74
74
|
n && window.localStorage.setItem(n, String(t).trim());
|
|
75
75
|
} catch {}
|
|
76
|
-
},
|
|
76
|
+
}, le = () => M ? {
|
|
77
77
|
isOpen: !1,
|
|
78
78
|
activeScreen: window.sessionStorage.getItem(A.activeScreen) || "ai",
|
|
79
79
|
isHumanHandled: window.sessionStorage.getItem(A.isHumanHandled) === "true",
|
|
@@ -87,8 +87,8 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
|
|
|
87
87
|
agentName: null,
|
|
88
88
|
agentHeadshot: null,
|
|
89
89
|
visitorEmail: ""
|
|
90
|
-
},
|
|
91
|
-
|
|
90
|
+
}, ue = (e) => {
|
|
91
|
+
M && Object.entries(e).forEach(([e, t]) => {
|
|
92
92
|
let n = A[e];
|
|
93
93
|
if (n) {
|
|
94
94
|
if (t == null || t === !1) {
|
|
@@ -98,17 +98,17 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
|
|
|
98
98
|
window.sessionStorage.setItem(n, String(t));
|
|
99
99
|
}
|
|
100
100
|
});
|
|
101
|
-
},
|
|
102
|
-
if (!
|
|
103
|
-
let t =
|
|
101
|
+
}, de = (e) => {
|
|
102
|
+
if (!M || !e) return "";
|
|
103
|
+
let t = N(e), n = window.localStorage.getItem(t);
|
|
104
104
|
if (!n) {
|
|
105
105
|
let e = window.sessionStorage.getItem(A.visitorEmail);
|
|
106
106
|
e && (window.localStorage.setItem(t, e), window.sessionStorage.removeItem(A.visitorEmail), n = e);
|
|
107
107
|
}
|
|
108
108
|
return n || "";
|
|
109
|
-
},
|
|
110
|
-
if (!
|
|
111
|
-
let n =
|
|
109
|
+
}, fe = (e, t) => {
|
|
110
|
+
if (!M) return;
|
|
111
|
+
let n = N(t);
|
|
112
112
|
if (!n) return;
|
|
113
113
|
let r = typeof e == "string" ? e.trim() : "";
|
|
114
114
|
if (!r) {
|
|
@@ -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(A.visitorEmail);
|
|
119
|
-
},
|
|
120
|
-
if (!
|
|
119
|
+
}, pe = (e) => e ? `flowengage.visitorId.${e}` : null, me = () => `v_${Date.now().toString(36)}_${typeof crypto < "u" && crypto.randomUUID ? crypto.randomUUID().replace(/-/g, "").slice(0, 16) : Math.random().toString(36).slice(2, 18)}`, he = (e) => {
|
|
120
|
+
if (!M || !e) return null;
|
|
121
121
|
try {
|
|
122
|
-
let t =
|
|
122
|
+
let t = pe(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
|
-
},
|
|
128
|
-
if (!
|
|
127
|
+
}, L = (e) => {
|
|
128
|
+
if (!M || !e) return null;
|
|
129
129
|
try {
|
|
130
|
-
let t =
|
|
130
|
+
let t = he(e);
|
|
131
131
|
if (t) return t;
|
|
132
|
-
let n =
|
|
132
|
+
let n = me(), r = pe(e);
|
|
133
133
|
return r && window.localStorage.setItem(r, n), n;
|
|
134
134
|
} catch {
|
|
135
|
-
return
|
|
135
|
+
return me();
|
|
136
136
|
}
|
|
137
|
-
},
|
|
138
|
-
if (!
|
|
137
|
+
}, ge = "flowengage.tabId", _e = () => {
|
|
138
|
+
if (!M) 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(ge);
|
|
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(ge, e)), e;
|
|
142
142
|
} catch {
|
|
143
143
|
return "default";
|
|
144
144
|
}
|
|
145
|
-
},
|
|
146
|
-
if (!
|
|
145
|
+
}, R = (e) => e ? `flowengage.voice.transcript.${e}.${_e()}` : null, ve = 600 * 1e3, z = (e, t, n = {}) => {
|
|
146
|
+
if (!M || !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 : ve, a = {
|
|
150
150
|
transcript: r,
|
|
151
151
|
expiresAt: Date.now() + i
|
|
152
152
|
};
|
|
153
153
|
try {
|
|
154
|
-
let t =
|
|
154
|
+
let t = R(e);
|
|
155
155
|
t && window.localStorage.setItem(t, JSON.stringify(a));
|
|
156
156
|
} catch {}
|
|
157
|
-
},
|
|
158
|
-
if (!
|
|
157
|
+
}, ye = (e) => {
|
|
158
|
+
if (!M || !e) return null;
|
|
159
159
|
try {
|
|
160
|
-
let t =
|
|
160
|
+
let t = R(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
|
-
},
|
|
168
|
-
if (!(!
|
|
169
|
-
let t =
|
|
167
|
+
}, be = (e) => {
|
|
168
|
+
if (!(!M || !e)) try {
|
|
169
|
+
let t = R(e);
|
|
170
170
|
t && window.localStorage.removeItem(t);
|
|
171
171
|
} catch {}
|
|
172
|
-
},
|
|
173
|
-
if (
|
|
174
|
-
window.sessionStorage.setItem(
|
|
172
|
+
}, xe = "flowengage.voice.pendingResume", Se = () => {
|
|
173
|
+
if (M) try {
|
|
174
|
+
window.sessionStorage.setItem(xe, "1");
|
|
175
175
|
} catch {}
|
|
176
|
-
},
|
|
177
|
-
if (!
|
|
176
|
+
}, Ce = () => {
|
|
177
|
+
if (!M) return !1;
|
|
178
178
|
try {
|
|
179
|
-
return window.sessionStorage.getItem(
|
|
179
|
+
return window.sessionStorage.getItem(xe) === "1" ? (window.sessionStorage.removeItem(xe), !0) : !1;
|
|
180
180
|
} catch {
|
|
181
181
|
return !1;
|
|
182
182
|
}
|
|
183
|
-
},
|
|
184
|
-
if (
|
|
185
|
-
window.sessionStorage.setItem(
|
|
183
|
+
}, we = "flowengage.chat.pendingReopen", Te = () => {
|
|
184
|
+
if (M) try {
|
|
185
|
+
window.sessionStorage.setItem(we, "1");
|
|
186
186
|
} catch {}
|
|
187
|
-
},
|
|
188
|
-
if (!
|
|
187
|
+
}, Ee = () => {
|
|
188
|
+
if (!M) return !1;
|
|
189
189
|
try {
|
|
190
|
-
return window.sessionStorage.getItem(
|
|
190
|
+
return window.sessionStorage.getItem(we) === "1" ? (window.sessionStorage.removeItem(we), !0) : !1;
|
|
191
191
|
} catch {
|
|
192
192
|
return !1;
|
|
193
193
|
}
|
|
194
|
-
},
|
|
195
|
-
if (!
|
|
194
|
+
}, De = () => {
|
|
195
|
+
if (!M) return !1;
|
|
196
196
|
try {
|
|
197
|
-
return window.sessionStorage.getItem(
|
|
197
|
+
return window.sessionStorage.getItem(xe) === "1";
|
|
198
198
|
} catch {
|
|
199
199
|
return !1;
|
|
200
200
|
}
|
|
201
|
-
},
|
|
202
|
-
if (!(!
|
|
203
|
-
let i =
|
|
201
|
+
}, Oe = (e) => e ? `flowengage.voice.navState.${e}.${_e()}` : null, ke = (e, t, n, r) => {
|
|
202
|
+
if (!(!M || !e || !t)) try {
|
|
203
|
+
let i = Oe(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,
|
|
@@ -208,10 +208,10 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
|
|
|
208
208
|
ts: Date.now()
|
|
209
209
|
}));
|
|
210
210
|
} catch {}
|
|
211
|
-
},
|
|
212
|
-
if (!
|
|
211
|
+
}, Ae = (e) => {
|
|
212
|
+
if (!M || !e) return null;
|
|
213
213
|
try {
|
|
214
|
-
let t =
|
|
214
|
+
let t = Oe(e);
|
|
215
215
|
if (!t) return null;
|
|
216
216
|
let n = window.sessionStorage.getItem(t);
|
|
217
217
|
if (!n) return null;
|
|
@@ -224,14 +224,14 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
|
|
|
224
224
|
} catch {
|
|
225
225
|
return null;
|
|
226
226
|
}
|
|
227
|
-
},
|
|
227
|
+
}, je = async (e) => {
|
|
228
228
|
let t = await e.json().catch(() => ({}));
|
|
229
229
|
if (!e.ok) {
|
|
230
230
|
let n = Error(t.message || t.error || `Request failed with status ${e.status}`);
|
|
231
231
|
throw n.status = e.status, n;
|
|
232
232
|
}
|
|
233
233
|
return t;
|
|
234
|
-
},
|
|
234
|
+
}, Me = async (e, t = {}) => {
|
|
235
235
|
try {
|
|
236
236
|
return await fetch(e, {
|
|
237
237
|
mode: "cors",
|
|
@@ -243,7 +243,7 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
|
|
|
243
243
|
}
|
|
244
244
|
}, Ne = 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),
|
|
246
|
+
return r && String(r).trim() && (c.priorChatId = String(r).trim()), i && (c.forceNew = !0), a && (c.resumeChatId = a), o && (c.visitorId = o), je(await Me(s, {
|
|
247
247
|
method: "POST",
|
|
248
248
|
mode: "cors",
|
|
249
249
|
headers: {
|
|
@@ -256,7 +256,7 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
|
|
|
256
256
|
}));
|
|
257
257
|
}, Pe = async ({ apiBaseUrl: e, siteId: t }) => {
|
|
258
258
|
let n = typeof window < "u" ? window.location.origin : "http://localhost";
|
|
259
|
-
return (await
|
|
259
|
+
return (await je(await Me(`${e}/api/widget/chatbot-loader?${new URLSearchParams({
|
|
260
260
|
siteId: t,
|
|
261
261
|
origin: n
|
|
262
262
|
}).toString()}`, { method: "GET" }))).data;
|
|
@@ -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 = {}) =>
|
|
277
|
+
}, a = async (i, a = {}) => je(await Me(`${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
|
|
292
|
+
return je(await Me(`${e}${r}`, {
|
|
293
293
|
...a,
|
|
294
294
|
body: i,
|
|
295
295
|
headers: o
|
|
@@ -320,7 +320,7 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
|
|
|
320
320
|
method: "POST",
|
|
321
321
|
body: JSON.stringify(f)
|
|
322
322
|
});
|
|
323
|
-
let p = await
|
|
323
|
+
let p = await Me(`${e}/api/ai/chat`, {
|
|
324
324
|
method: "POST",
|
|
325
325
|
headers: {
|
|
326
326
|
"Content-Type": "application/json",
|
|
@@ -333,7 +333,7 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
|
|
|
333
333
|
stream: !0
|
|
334
334
|
})
|
|
335
335
|
});
|
|
336
|
-
if (!(p.headers.get("content-type") || "").includes("text/event-stream")) return
|
|
336
|
+
if (!(p.headers.get("content-type") || "").includes("text/event-stream")) return je(p);
|
|
337
337
|
let m = p.body.getReader(), h = new TextDecoder(), g = "", _ = null, v = (e) => {
|
|
338
338
|
let t = e.split("\n").find((e) => e.startsWith("data: "));
|
|
339
339
|
if (t) try {
|
|
@@ -449,7 +449,7 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
|
|
|
449
449
|
});
|
|
450
450
|
},
|
|
451
451
|
async getIceServersConfig() {
|
|
452
|
-
return
|
|
452
|
+
return je(await Me(`${e}/api/calls/ice-config`, {
|
|
453
453
|
method: "GET",
|
|
454
454
|
headers: {
|
|
455
455
|
"x-user-id": t,
|
|
@@ -2855,7 +2855,7 @@ async function wr(e, t = {}) {
|
|
|
2855
2855
|
reason: "already-on-page"
|
|
2856
2856
|
};
|
|
2857
2857
|
let a = i.pathname + i.search + i.hash;
|
|
2858
|
-
if (window.Shopify) return n && mr(n), r ||
|
|
2858
|
+
if (window.Shopify) return n && mr(n), r || Te(), r ? Cr().then(() => window.location.assign(i.href)) : window.location.assign(i.href), { navigated: !0 };
|
|
2859
2859
|
let o = window.next?.router;
|
|
2860
2860
|
if (o?.push) return new Promise((e) => {
|
|
2861
2861
|
let t = () => {
|
|
@@ -2874,11 +2874,11 @@ async function wr(e, t = {}) {
|
|
|
2874
2874
|
try {
|
|
2875
2875
|
window.history.pushState({}, "", e), window.dispatchEvent(new PopStateEvent("popstate", { state: {} }));
|
|
2876
2876
|
} catch {}
|
|
2877
|
-
return n && mr(n), r ||
|
|
2877
|
+
return n && mr(n), r || Te(), window.location.assign(i.href), { navigated: !0 };
|
|
2878
2878
|
}
|
|
2879
2879
|
return { navigated: !0 };
|
|
2880
2880
|
}
|
|
2881
|
-
return n && mr(n), r ||
|
|
2881
|
+
return n && mr(n), r || Te(), window.location.assign(i.href), { navigated: !0 };
|
|
2882
2882
|
} catch (t) {
|
|
2883
2883
|
console.warn("[FlowEngage] shadowNavigate error:", t), n && mr(n);
|
|
2884
2884
|
try {
|
|
@@ -3296,7 +3296,7 @@ function pi({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3296
3296
|
message: "Looks like you're already on this page!",
|
|
3297
3297
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
3298
3298
|
}]);
|
|
3299
|
-
}, []), [D, O] = m(
|
|
3299
|
+
}, []), [D, O] = m(le().isOpen), [k, A] = m(le().activeScreen), [M, N] = m(le().isHumanHandled), [ie, F] = m(le().agentName), [ae, I] = m(le().agentHeadshot), [pe, me] = m(() => de(i?.siteId)), [he, ge] = m(!1), [_e, R] = m(!1), [ve, z] = m("idle"), [ye, be] = m(!1), [xe, Ce] = m(!1), [we, Te] = m(""), [Ee, De] = m(!1), [Oe, ke] = m(0), [Ae, je] = m(0), [Me, B] = m(!1), [V, Ie] = m(null), [Le, Re] = m(null), [ze, Be] = m("idle"), [Ve, He] = m(null), [Ue, We] = m(!1), [Ge, Ke] = m(""), [qe, Je] = m(!1), H = p(null), U = p(null), Ye = p(""), Xe = p(!1), Ze = p(null), Qe = p(null), W = p(null), $e = p(null), et = p(null), tt = p(null), nt = p(null), G = p(!1), rt = p({
|
|
3300
3300
|
url: null,
|
|
3301
3301
|
at: 0
|
|
3302
3302
|
}), it = o((e, t) => {
|
|
@@ -3318,7 +3318,7 @@ function pi({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3318
3318
|
cleanup: () => {}
|
|
3319
3319
|
}), St = o((e = {}) => {
|
|
3320
3320
|
let t = !!e.is_human_handled;
|
|
3321
|
-
return
|
|
3321
|
+
return N(t), t ? (A("agent"), e.agent_info?.name && F(e.agent_info.name), e.agent_info?.headshot && I(e.agent_info.headshot), t) : (A("ai"), t);
|
|
3322
3322
|
}, []), Ct = f(() => {
|
|
3323
3323
|
let e = _?.widgetSettings?.call?.maxDurationSeconds ?? i?.widgetSettings?.call?.maxDurationSeconds ?? i?.callMaxDurationSeconds, t = Number(e);
|
|
3324
3324
|
return Number.isFinite(t) && t > 0 ? t : te;
|
|
@@ -3328,8 +3328,8 @@ function pi({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3328
3328
|
}, [V]), c(() => {
|
|
3329
3329
|
gt.current = ie;
|
|
3330
3330
|
}, [ie]), c(() => {
|
|
3331
|
-
yt.current =
|
|
3332
|
-
}, [
|
|
3331
|
+
yt.current = Ee;
|
|
3332
|
+
}, [Ee]), c(() => {
|
|
3333
3333
|
bt.current = i;
|
|
3334
3334
|
}, [i]);
|
|
3335
3335
|
let wt = () => {
|
|
@@ -3338,17 +3338,17 @@ function pi({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3338
3338
|
ct.current &&= (window.clearTimeout(ct.current), null);
|
|
3339
3339
|
}, []), Et = (e) => {
|
|
3340
3340
|
let t = typeof e == "string" ? e.trim().toLowerCase() : "";
|
|
3341
|
-
return
|
|
3341
|
+
return me(t), fe(t, i?.siteId), t;
|
|
3342
3342
|
};
|
|
3343
3343
|
c(() => {
|
|
3344
3344
|
let e = i?.siteId;
|
|
3345
3345
|
if (!e) return;
|
|
3346
|
-
let t =
|
|
3346
|
+
let t = de(e);
|
|
3347
3347
|
if (t) {
|
|
3348
|
-
|
|
3348
|
+
me(t);
|
|
3349
3349
|
return;
|
|
3350
3350
|
}
|
|
3351
|
-
|
|
3351
|
+
me((t) => (t && fe(t, e), t));
|
|
3352
3352
|
}, [i?.siteId]);
|
|
3353
3353
|
let Dt = (e = "unspecified") => {
|
|
3354
3354
|
let t = ot.current || tt.current?.callId, n = ht.current, r = ft.current;
|
|
@@ -3478,19 +3478,19 @@ function pi({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3478
3478
|
});
|
|
3479
3479
|
};
|
|
3480
3480
|
c(() => {
|
|
3481
|
-
|
|
3481
|
+
ue({
|
|
3482
3482
|
isOpen: D,
|
|
3483
3483
|
activeScreen: k,
|
|
3484
|
-
isHumanHandled:
|
|
3484
|
+
isHumanHandled: M,
|
|
3485
3485
|
agentName: ie,
|
|
3486
|
-
agentHeadshot:
|
|
3486
|
+
agentHeadshot: ae
|
|
3487
3487
|
});
|
|
3488
3488
|
}, [
|
|
3489
3489
|
D,
|
|
3490
3490
|
k,
|
|
3491
|
-
|
|
3491
|
+
M,
|
|
3492
3492
|
ie,
|
|
3493
|
-
|
|
3493
|
+
ae
|
|
3494
3494
|
]), c(() => {
|
|
3495
3495
|
let e = !0;
|
|
3496
3496
|
return (async () => {
|
|
@@ -3498,21 +3498,21 @@ function pi({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3498
3498
|
try {
|
|
3499
3499
|
let t = E(i), n = await Pe(t);
|
|
3500
3500
|
if (!e) return;
|
|
3501
|
-
let a = t.siteId, o =
|
|
3501
|
+
let a = t.siteId, o = oe(a), s = L(a), c = "";
|
|
3502
3502
|
try {
|
|
3503
3503
|
let e = Xe.current, r = Ze.current;
|
|
3504
3504
|
if (Xe.current = !1, Ze.current = null, c = (await Ne({
|
|
3505
3505
|
apiBaseUrl: t.apiBaseUrl,
|
|
3506
3506
|
userId: n.userId,
|
|
3507
3507
|
siteId: a,
|
|
3508
|
-
priorChatId: e || r ? null : o ||
|
|
3508
|
+
priorChatId: e || r ? null : o || ne(),
|
|
3509
3509
|
forceNew: e,
|
|
3510
3510
|
resumeChatId: r,
|
|
3511
3511
|
visitorId: s
|
|
3512
3512
|
}))?.data?.chatId, !c) throw Error("resolve-session returned no chatId");
|
|
3513
|
-
re(),
|
|
3513
|
+
re(), ce(a, c);
|
|
3514
3514
|
} catch (e) {
|
|
3515
|
-
console.warn("[FlowEngageProvider] resolve-session failed, reusing persisted or ephemeral chat id", e?.message || e), c = o || P(),
|
|
3515
|
+
console.warn("[FlowEngageProvider] resolve-session failed, reusing persisted or ephemeral chat id", e?.message || e), c = o || P(), ce(a, c);
|
|
3516
3516
|
}
|
|
3517
3517
|
Ye.current = c;
|
|
3518
3518
|
let l = Fe({
|
|
@@ -3532,23 +3532,23 @@ function pi({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3532
3532
|
siteId: t.siteId
|
|
3533
3533
|
});
|
|
3534
3534
|
H.current = f, f.on("connect", async () => {
|
|
3535
|
-
|
|
3535
|
+
z("connected");
|
|
3536
3536
|
let e = Ye.current;
|
|
3537
3537
|
if (e && U.current) try {
|
|
3538
3538
|
St(await U.current.checkHumanHandled(e));
|
|
3539
3539
|
} catch {}
|
|
3540
3540
|
}), f.on("disconnect", () => {
|
|
3541
|
-
|
|
3541
|
+
z("disconnected");
|
|
3542
3542
|
}), f.on("aiTyping", () => {
|
|
3543
|
-
|
|
3543
|
+
R(!0);
|
|
3544
3544
|
}), f.on("ai:typing", () => {
|
|
3545
|
-
|
|
3545
|
+
R(!0);
|
|
3546
3546
|
}), f.on("messageReceived", (e) => {
|
|
3547
3547
|
let t = e.message || e, n = {
|
|
3548
3548
|
...t,
|
|
3549
3549
|
message: oi(t.message)
|
|
3550
3550
|
};
|
|
3551
|
-
|
|
3551
|
+
R(!1), ge(!1), !(n.type === "call_recording" || typeof n.message == "string" && n.message.includes("AI chat recording")) && S((e) => [...e.filter((e) => !e.isPending), {
|
|
3552
3552
|
...n,
|
|
3553
3553
|
isPending: !1,
|
|
3554
3554
|
id: n.messageId || `${n.sender}-${Date.now()}-${Math.random()}`
|
|
@@ -3566,7 +3566,7 @@ function pi({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3566
3566
|
...t,
|
|
3567
3567
|
message: oi(t.message)
|
|
3568
3568
|
};
|
|
3569
|
-
|
|
3569
|
+
R(!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") && ge(!1), S((e) => n.sender === "bot" || n.sender === "ai" ? [...e, {
|
|
3570
3570
|
...n,
|
|
3571
3571
|
isPending: !1,
|
|
3572
3572
|
id: n.messageId || `${n.sender}-${Date.now()}-${Math.random()}`
|
|
@@ -3578,11 +3578,11 @@ function pi({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3578
3578
|
...n,
|
|
3579
3579
|
isPending: !1,
|
|
3580
3580
|
id: n.messageId || `${n.sender}-${Date.now()}-${Math.random()}`
|
|
3581
|
-
}]), (n.sender === "agent" || n.agent_name) && (
|
|
3581
|
+
}]), (n.sender === "agent" || n.agent_name) && (N(!0), A("agent"), F(di([
|
|
3582
3582
|
n.agent_name,
|
|
3583
3583
|
n.agentName,
|
|
3584
3584
|
n.metadata?.agentName
|
|
3585
|
-
], d)), n.sender_headshot &&
|
|
3585
|
+
], d)), n.sender_headshot && I(n.sender_headshot), O(!0), ke((e) => e + 1)));
|
|
3586
3586
|
});
|
|
3587
3587
|
let p = (e = {}) => {
|
|
3588
3588
|
let t = di([
|
|
@@ -3591,7 +3591,7 @@ function pi({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3591
3591
|
e.agent_name,
|
|
3592
3592
|
gt.current
|
|
3593
3593
|
], d);
|
|
3594
|
-
|
|
3594
|
+
N(!0), A("agent"), F(t), I(e.agent?.headshot || null), O(!0), ke((e) => e + 1), S((e) => fi(e, {
|
|
3595
3595
|
id: `agent-joined-${Date.now()}`,
|
|
3596
3596
|
sender: "system",
|
|
3597
3597
|
message: `${t} has joined the chat.`,
|
|
@@ -3605,7 +3605,7 @@ function pi({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3605
3605
|
e.agent_name,
|
|
3606
3606
|
gt.current
|
|
3607
3607
|
], d);
|
|
3608
|
-
|
|
3608
|
+
N(!1), A("ai"), S((e) => fi(e, {
|
|
3609
3609
|
id: `agent-left-${Date.now()}`,
|
|
3610
3610
|
sender: "system",
|
|
3611
3611
|
message: `${t} has left the chat.`,
|
|
@@ -3625,15 +3625,15 @@ function pi({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3625
3625
|
}]);
|
|
3626
3626
|
}), f.on("chat:history_update", (e) => {
|
|
3627
3627
|
let t = si(e.chat_history || []);
|
|
3628
|
-
S(t), t.length === 0 && (B(!1),
|
|
3628
|
+
S(t), t.length === 0 && (B(!1), N(!1), A("ai"), R(!1), ge(!1));
|
|
3629
3629
|
}), f.on("conversation:reset", () => {
|
|
3630
|
-
S([]), B(!1),
|
|
3630
|
+
S([]), B(!1), N(!1), A("ai"), R(!1), ge(!1);
|
|
3631
3631
|
}), f.on("voice:end_session", (e = {}) => {
|
|
3632
|
-
console.log("[FlowEngageProvider] voice:end_session received — ending voice session"),
|
|
3632
|
+
console.log("[FlowEngageProvider] voice:end_session received — ending voice session"), je((e) => e + 1), O(!0), ke((e) => e + 1);
|
|
3633
3633
|
}), f.on("typing:start", (e) => {
|
|
3634
|
-
e.sender === "agent" &&
|
|
3634
|
+
e.sender === "agent" && ge(!0);
|
|
3635
3635
|
}), f.on("typing:stop", (e) => {
|
|
3636
|
-
e.sender === "agent" &&
|
|
3636
|
+
e.sender === "agent" && ge(!1);
|
|
3637
3637
|
}), f.on("call:incoming", (e = {}) => {
|
|
3638
3638
|
let t = di([
|
|
3639
3639
|
e.agentName,
|
|
@@ -3646,7 +3646,7 @@ function pi({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3646
3646
|
from: e.from || "owner",
|
|
3647
3647
|
agentId: e.agentId || null,
|
|
3648
3648
|
agentName: t
|
|
3649
|
-
}),
|
|
3649
|
+
}), F((e) => di([t, e], "Agent")), Be("incoming"), He(null), O(!0);
|
|
3650
3650
|
}), f.on("call:offer", async (e = {}) => {
|
|
3651
3651
|
tt.current = e;
|
|
3652
3652
|
try {
|
|
@@ -3721,7 +3721,7 @@ function pi({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3721
3721
|
});
|
|
3722
3722
|
let h = await l.loadHistory(c, r);
|
|
3723
3723
|
if (!e) return;
|
|
3724
|
-
S(si(h.chat_history || [])),
|
|
3724
|
+
S(si(h.chat_history || [])), N(!!h.is_human_handled), A(h.is_human_handled ? "agent" : k);
|
|
3725
3725
|
let g = h?.visitor_email || h?.visitorEmail;
|
|
3726
3726
|
if (g && String(g).trim() && Et(String(g).trim()), await new Promise((e) => setTimeout(e, 500)), !e) return;
|
|
3727
3727
|
u("ready");
|
|
@@ -3739,11 +3739,11 @@ function pi({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3739
3739
|
r,
|
|
3740
3740
|
a
|
|
3741
3741
|
]), c(() => () => {
|
|
3742
|
-
if (
|
|
3742
|
+
if (Ee && !vt.current && _t.current.length > 0) {
|
|
3743
3743
|
let e = Ye.current, t = _t.current, n = U.current;
|
|
3744
3744
|
n && e && t.length > 0 && (console.log("[FlowEngageProvider] safety-net: syncing voice transcript on unmount"), n.beaconSyncVoice(e, t) || n.syncVoice(e, t).catch(() => {}), vt.current = !0);
|
|
3745
3745
|
}
|
|
3746
|
-
}, [
|
|
3746
|
+
}, [Ee, _]);
|
|
3747
3747
|
let Mt = p(null);
|
|
3748
3748
|
c(() => {
|
|
3749
3749
|
let e = U.current;
|
|
@@ -3877,7 +3877,7 @@ function pi({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3877
3877
|
let e = V.callId;
|
|
3878
3878
|
return Tt(), ct.current = window.setTimeout(() => {
|
|
3879
3879
|
Qe.current?.callId === e && st.current !== e && ot.current !== e && Ft.current();
|
|
3880
|
-
},
|
|
3880
|
+
}, j), () => {
|
|
3881
3881
|
ct.current &&= (window.clearTimeout(ct.current), null);
|
|
3882
3882
|
};
|
|
3883
3883
|
}, [
|
|
@@ -3962,7 +3962,7 @@ function pi({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3962
3962
|
}
|
|
3963
3963
|
let Wt = async (e, t = "", n = null, i = {}) => {
|
|
3964
3964
|
let a = typeof e == "string" ? e.trim() : "";
|
|
3965
|
-
if (!a || !U.current || !y || l !== "ready" ||
|
|
3965
|
+
if (!a || !U.current || !y || l !== "ready" || Me) return;
|
|
3966
3966
|
Vt(), G.current = !1;
|
|
3967
3967
|
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;
|
|
3968
3968
|
if (nt.current && o.test(a) && !s.test(a)) {
|
|
@@ -3989,7 +3989,7 @@ function pi({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3989
3989
|
...n || {}
|
|
3990
3990
|
};
|
|
3991
3991
|
S((e) => [...e, d]);
|
|
3992
|
-
let f =
|
|
3992
|
+
let f = M;
|
|
3993
3993
|
if (f) try {
|
|
3994
3994
|
f = St(await U.current.checkHumanHandled(y));
|
|
3995
3995
|
} catch {}
|
|
@@ -3998,17 +3998,17 @@ function pi({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3998
3998
|
chatId: y,
|
|
3999
3999
|
content: e,
|
|
4000
4000
|
sender: "user",
|
|
4001
|
-
email:
|
|
4001
|
+
email: pe || void 0,
|
|
4002
4002
|
type: i?.type || "text",
|
|
4003
4003
|
metadata: i?.metadata || {},
|
|
4004
4004
|
...n || {}
|
|
4005
4005
|
});
|
|
4006
4006
|
return;
|
|
4007
4007
|
}
|
|
4008
|
-
|
|
4008
|
+
be(!0);
|
|
4009
4009
|
try {
|
|
4010
4010
|
let o = await Lr(), s = Fr(), l = `stream-preview-${Date.now().toString(36)}`, u = (e) => {
|
|
4011
|
-
|
|
4011
|
+
R(!1), S((t) => {
|
|
4012
4012
|
let n = t.findIndex((e) => e.id === l);
|
|
4013
4013
|
if (n === -1) return [...t, {
|
|
4014
4014
|
id: l,
|
|
@@ -4025,7 +4025,7 @@ function pi({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
4025
4025
|
});
|
|
4026
4026
|
}, d = await U.current.sendAiMessage(y, e, r, t, {
|
|
4027
4027
|
...n || {},
|
|
4028
|
-
...
|
|
4028
|
+
...pe ? { email: pe } : {}
|
|
4029
4029
|
}, {
|
|
4030
4030
|
...i,
|
|
4031
4031
|
currentPageUrl: typeof window < "u" ? window.location.href : void 0,
|
|
@@ -4102,10 +4102,10 @@ function pi({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
4102
4102
|
});
|
|
4103
4103
|
}
|
|
4104
4104
|
}
|
|
4105
|
-
S(si(f)), Array.isArray(d.cart_actions) && d.cart_actions.length && w(d.cart_actions),
|
|
4105
|
+
S(si(f)), Array.isArray(d.cart_actions) && d.cart_actions.length && w(d.cart_actions), N(!!d.is_human_handled), A(d.is_human_handled ? "agent" : "ai"), R(!1), be(!1), await U.current.updateChatStatus(y, "messageSent");
|
|
4106
4106
|
} catch (e) {
|
|
4107
|
-
S((e) => e.filter((e) => e.id !== u && !e.isStreaming)),
|
|
4108
|
-
|
|
4107
|
+
S((e) => e.filter((e) => e.id !== u && !e.isStreaming)), R(!1), be(!1), e.status === 429 ? (Ce(!0), Te(e.message), window.setTimeout(() => {
|
|
4108
|
+
Ce(!1), Te("");
|
|
4109
4109
|
}, ee)) : h(e);
|
|
4110
4110
|
}
|
|
4111
4111
|
}, Gt = async (e) => {
|
|
@@ -4117,12 +4117,12 @@ function pi({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
4117
4117
|
let t = e ? "voice" : "text";
|
|
4118
4118
|
await U.current.setChatMode(y, t);
|
|
4119
4119
|
} catch {}
|
|
4120
|
-
|
|
4120
|
+
De(e), e && (vt.current = !1);
|
|
4121
4121
|
}
|
|
4122
4122
|
}, qt = async (e) => {
|
|
4123
4123
|
if (vt.current) return;
|
|
4124
4124
|
if (vt.current = !0, !U.current || !y || !e?.length) {
|
|
4125
|
-
|
|
4125
|
+
De(!1);
|
|
4126
4126
|
return;
|
|
4127
4127
|
}
|
|
4128
4128
|
let t = () => {
|
|
@@ -4146,11 +4146,11 @@ function pi({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
4146
4146
|
} catch {
|
|
4147
4147
|
t();
|
|
4148
4148
|
} finally {
|
|
4149
|
-
|
|
4149
|
+
De(!1);
|
|
4150
4150
|
}
|
|
4151
4151
|
}, Jt = async () => {
|
|
4152
4152
|
if (!(!U.current || !y)) {
|
|
4153
|
-
|
|
4153
|
+
Ee && !vt.current && _t.current.length > 0 && await qt(_t.current);
|
|
4154
4154
|
try {
|
|
4155
4155
|
await U.current.endConversation(y);
|
|
4156
4156
|
} catch {
|
|
@@ -4184,7 +4184,7 @@ function pi({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
4184
4184
|
let e = () => {
|
|
4185
4185
|
let e = Ye.current, t = U.current;
|
|
4186
4186
|
if (!t || !e) return;
|
|
4187
|
-
if (yt.current && _t.current.length > 0 &&
|
|
4187
|
+
if (yt.current && _t.current.length > 0 && Se(), !vt.current && _t.current.length > 0 && (t.beaconSyncVoice(e, _t.current) || t.syncVoice(e, _t.current).catch(() => {}), vt.current = !0), ot.current) {
|
|
4188
4188
|
t.beaconEndWebRTCCall(ot.current, e);
|
|
4189
4189
|
return;
|
|
4190
4190
|
}
|
|
@@ -4197,9 +4197,9 @@ function pi({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
4197
4197
|
}, []);
|
|
4198
4198
|
let Yt = o(() => {
|
|
4199
4199
|
let e = i?.siteId;
|
|
4200
|
-
|
|
4200
|
+
se(e), Xe.current = !0, Ze.current = null, H.current?.disconnect(), S([]), b(""), Ye.current = "", B(!1), N(!1), F(null), I(null), Je(!0), s((e) => e + 1);
|
|
4201
4201
|
}, [i?.siteId]), Xt = o((e) => {
|
|
4202
|
-
i?.siteId, Xe.current = !1, Ze.current = e, H.current?.disconnect(), S([]), b(""), Ye.current = "", B(!1),
|
|
4202
|
+
i?.siteId, Xe.current = !1, Ze.current = e, H.current?.disconnect(), S([]), b(""), Ye.current = "", B(!1), N(!1), F(null), I(null), Je(!0), s((e) => e + 1);
|
|
4203
4203
|
}, [i?.siteId]), Zt = f(() => ({
|
|
4204
4204
|
status: l,
|
|
4205
4205
|
error: d,
|
|
@@ -4209,21 +4209,21 @@ function pi({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
4209
4209
|
chatHistory: x,
|
|
4210
4210
|
isOpen: D,
|
|
4211
4211
|
activeScreen: k,
|
|
4212
|
-
isHumanHandled:
|
|
4212
|
+
isHumanHandled: M,
|
|
4213
4213
|
agentName: ie,
|
|
4214
|
-
agentHeadshot:
|
|
4215
|
-
visitorEmail:
|
|
4216
|
-
isAgentTyping:
|
|
4217
|
-
isAiTyping:
|
|
4218
|
-
connectionStatus:
|
|
4219
|
-
isLoading:
|
|
4220
|
-
isVoiceMode:
|
|
4221
|
-
isRateLimited:
|
|
4222
|
-
rateLimitMessage:
|
|
4223
|
-
isConversationEnded:
|
|
4214
|
+
agentHeadshot: ae,
|
|
4215
|
+
visitorEmail: pe,
|
|
4216
|
+
isAgentTyping: he,
|
|
4217
|
+
isAiTyping: _e,
|
|
4218
|
+
connectionStatus: ve,
|
|
4219
|
+
isLoading: ye,
|
|
4220
|
+
isVoiceMode: Ee,
|
|
4221
|
+
isRateLimited: xe,
|
|
4222
|
+
rateLimitMessage: we,
|
|
4223
|
+
isConversationEnded: Me,
|
|
4224
4224
|
isSessionRestoring: qe,
|
|
4225
|
-
openToChatCounter:
|
|
4226
|
-
voiceEndCounter:
|
|
4225
|
+
openToChatCounter: Oe,
|
|
4226
|
+
voiceEndCounter: Ae,
|
|
4227
4227
|
incomingCall: V,
|
|
4228
4228
|
activeCallId: Le,
|
|
4229
4229
|
callConnectionState: ze,
|
|
@@ -4270,21 +4270,21 @@ function pi({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
4270
4270
|
x,
|
|
4271
4271
|
D,
|
|
4272
4272
|
k,
|
|
4273
|
-
|
|
4273
|
+
M,
|
|
4274
4274
|
ie,
|
|
4275
|
-
|
|
4275
|
+
ae,
|
|
4276
|
+
pe,
|
|
4276
4277
|
he,
|
|
4277
|
-
|
|
4278
|
+
_e,
|
|
4279
|
+
ve,
|
|
4278
4280
|
ye,
|
|
4279
|
-
|
|
4281
|
+
Ee,
|
|
4280
4282
|
xe,
|
|
4281
|
-
|
|
4282
|
-
|
|
4283
|
-
Te,
|
|
4284
|
-
z,
|
|
4283
|
+
we,
|
|
4284
|
+
Me,
|
|
4285
4285
|
qe,
|
|
4286
|
-
|
|
4287
|
-
|
|
4286
|
+
Oe,
|
|
4287
|
+
Ae,
|
|
4288
4288
|
V,
|
|
4289
4289
|
Le,
|
|
4290
4290
|
ze,
|
|
@@ -9228,13 +9228,18 @@ var Qm = {
|
|
|
9228
9228
|
...Qm,
|
|
9229
9229
|
...Lm,
|
|
9230
9230
|
...$m
|
|
9231
|
-
}, Xp), th = 24e3, nh = 2048, rh = 1200, ih = .
|
|
9232
|
-
function
|
|
9231
|
+
}, Xp), th = 24e3, nh = 2048, rh = 1200, ih = .05, ah = .005, oh = .35, sh = 3, ch = 3, lh = 5, uh = 1.6;
|
|
9232
|
+
function dh(e) {
|
|
9233
|
+
let t = 0;
|
|
9234
|
+
for (let n = 1; n < e.length; n++) e[n - 1] >= 0 != e[n] >= 0 && (t += 1);
|
|
9235
|
+
return t / (e.length - 1);
|
|
9236
|
+
}
|
|
9237
|
+
function fh(e) {
|
|
9233
9238
|
let t = 0;
|
|
9234
9239
|
for (let n = 0; n < e.length; n++) t += e[n] * e[n];
|
|
9235
9240
|
return Math.sqrt(t / e.length);
|
|
9236
9241
|
}
|
|
9237
|
-
function
|
|
9242
|
+
function ph(e) {
|
|
9238
9243
|
let t = new Int16Array(e.length);
|
|
9239
9244
|
for (let n = 0; n < e.length; n++) {
|
|
9240
9245
|
let r = Math.max(-1, Math.min(1, e[n]));
|
|
@@ -9242,16 +9247,16 @@ function ch(e) {
|
|
|
9242
9247
|
}
|
|
9243
9248
|
return t;
|
|
9244
9249
|
}
|
|
9245
|
-
function
|
|
9250
|
+
function mh(e) {
|
|
9246
9251
|
let t = new Float32Array(e.length);
|
|
9247
9252
|
for (let n = 0; n < e.length; n++) t[n] = e[n] / 32768;
|
|
9248
9253
|
return t;
|
|
9249
9254
|
}
|
|
9250
|
-
var
|
|
9251
|
-
function
|
|
9252
|
-
return typeof window > "u" || window.MediaRecorder === void 0 ? null :
|
|
9255
|
+
var hh = .13, gh = ["audio/webm", "audio/mp4"];
|
|
9256
|
+
function _h() {
|
|
9257
|
+
return typeof window > "u" || window.MediaRecorder === void 0 ? null : gh.find((e) => window.MediaRecorder.isTypeSupported(e)) || null;
|
|
9253
9258
|
}
|
|
9254
|
-
function
|
|
9259
|
+
function vh(e, t, n, r, i) {
|
|
9255
9260
|
if (!r.length || !n || !e) return;
|
|
9256
9261
|
let a = new Blob(r, { type: i }), o = new FormData();
|
|
9257
9262
|
o.append("audio", a, `aichat-${n}.webm`), o.append("voiceSessionId", n), o.append("siteId", t || ""), fetch(`${e}/api/voice/upload-chat-recording`, {
|
|
@@ -9261,25 +9266,25 @@ function ph(e, t, n, r, i) {
|
|
|
9261
9266
|
if (!e.ok) throw Error(`HTTP ${e.status}`);
|
|
9262
9267
|
}).catch((e) => console.warn("[FlowEngage] voice recording upload failed:", e.message));
|
|
9263
9268
|
}
|
|
9264
|
-
var
|
|
9265
|
-
function
|
|
9269
|
+
var yh = .02;
|
|
9270
|
+
function bh(e, t, n) {
|
|
9266
9271
|
let r = 0, i = 0, a = [], o = () => {
|
|
9267
9272
|
let t = e.currentTime;
|
|
9268
9273
|
a.forEach(({ source: e, gain: n }) => {
|
|
9269
9274
|
try {
|
|
9270
|
-
n.gain.cancelScheduledValues(t), n.gain.setValueAtTime(n.gain.value, t), n.gain.linearRampToValueAtTime(0, t +
|
|
9275
|
+
n.gain.cancelScheduledValues(t), n.gain.setValueAtTime(n.gain.value, t), n.gain.linearRampToValueAtTime(0, t + yh), e.stop(t + yh);
|
|
9271
9276
|
} catch {}
|
|
9272
9277
|
}), a = [], r = 0, i = 0;
|
|
9273
9278
|
}, s = () => r > e.currentTime;
|
|
9274
9279
|
return {
|
|
9275
9280
|
enqueue: (o) => {
|
|
9276
|
-
let c =
|
|
9281
|
+
let c = mh(o), l = e.createBuffer(1, c.length, th);
|
|
9277
9282
|
l.copyToChannel(c, 0);
|
|
9278
9283
|
let u = e.createBufferSource();
|
|
9279
9284
|
u.buffer = l;
|
|
9280
9285
|
let d = e.createGain();
|
|
9281
9286
|
u.connect(d), d.connect(e.destination), n && d.connect(n);
|
|
9282
|
-
let f = s() ? r : e.currentTime +
|
|
9287
|
+
let f = s() ? r : e.currentTime + hh;
|
|
9283
9288
|
i ||= f, u.start(f), r = f + l.duration;
|
|
9284
9289
|
let p = {
|
|
9285
9290
|
source: u,
|
|
@@ -9294,7 +9299,7 @@ function hh(e, t, n) {
|
|
|
9294
9299
|
playedMs: () => Math.max(0, (e.currentTime - i) * 1e3)
|
|
9295
9300
|
};
|
|
9296
9301
|
}
|
|
9297
|
-
async function
|
|
9302
|
+
async function xh(e, t, n) {
|
|
9298
9303
|
let r = new URLSearchParams({ siteId: t || "" });
|
|
9299
9304
|
n && r.set("chatId", n);
|
|
9300
9305
|
let i = Fr();
|
|
@@ -9312,8 +9317,8 @@ async function gh(e, t, n) {
|
|
|
9312
9317
|
if (!o?.success || !o.wsUrl) throw Error(o?.error || "Voice session was refused.");
|
|
9313
9318
|
return o;
|
|
9314
9319
|
}
|
|
9315
|
-
async function
|
|
9316
|
-
let { apiBaseUrl: t, siteId: n, chatId: r, clientTools: i = {}, onConnect: a, onDisconnect: o, onMessage: s, onModeChange: c, onError: l, onUnhandledClientToolCall: u, onAgentTurnEnd: d, onSessionInfo: f, onSessionEnding: p } = e, m = await
|
|
9320
|
+
async function Sh(e) {
|
|
9321
|
+
let { apiBaseUrl: t, siteId: n, chatId: r, clientTools: i = {}, onConnect: a, onDisconnect: o, onMessage: s, onModeChange: c, onError: l, onUnhandledClientToolCall: u, onAgentTurnEnd: d, onSessionInfo: f, onSessionEnding: p } = e, m = await xh(t, n, r);
|
|
9317
9322
|
f?.({ emailOnFile: !!m.emailOnFile });
|
|
9318
9323
|
let h = { type: "Start" };
|
|
9319
9324
|
e.greeting !== void 0 && (h.greeting = e.greeting || null);
|
|
@@ -9324,7 +9329,7 @@ async function _h(e) {
|
|
|
9324
9329
|
autoGainControl: !0
|
|
9325
9330
|
} }), _ = new (window.AudioContext || window.webkitAudioContext)({ sampleRate: th });
|
|
9326
9331
|
_.state === "suspended" && await _.resume();
|
|
9327
|
-
let v = _.createMediaStreamDestination(), y =
|
|
9332
|
+
let v = _.createMediaStreamDestination(), y = _h(), b = [], x = null, S = r || n || null;
|
|
9328
9333
|
y && (x = new window.MediaRecorder(v.stream, { mimeType: y }), x.ondataavailable = (e) => {
|
|
9329
9334
|
e.data && e.data.size > 0 && b.push(e.data);
|
|
9330
9335
|
}, x.start());
|
|
@@ -9354,53 +9359,61 @@ async function _h(e) {
|
|
|
9354
9359
|
}
|
|
9355
9360
|
}, O = (e, t, n) => {
|
|
9356
9361
|
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, rh));
|
|
9357
|
-
}, k = !1, A = !1, ee = !1, te = !1,
|
|
9358
|
-
|
|
9362
|
+
}, k = !1, A = !1, ee = !1, te = !1, j = !1, M = !0, N = 0, ne = 0, re = !1, P = !1, ie = ih, F = null, ae = !1, I = !1, oe = () => {
|
|
9363
|
+
F && clearTimeout(F);
|
|
9359
9364
|
let e = () => {
|
|
9360
9365
|
if (!k) {
|
|
9361
|
-
if (
|
|
9362
|
-
|
|
9366
|
+
if (se.isPlaying()) {
|
|
9367
|
+
F = setTimeout(e, 150);
|
|
9363
9368
|
return;
|
|
9364
9369
|
}
|
|
9365
|
-
if (
|
|
9370
|
+
if (F = null, ae) {
|
|
9366
9371
|
p?.();
|
|
9367
9372
|
return;
|
|
9368
9373
|
}
|
|
9369
|
-
!k && C.readyState === WebSocket.OPEN && C.send(JSON.stringify({ type: "PlaybackDrained" })),
|
|
9374
|
+
!k && C.readyState === WebSocket.OPEN && C.send(JSON.stringify({ type: "PlaybackDrained" })), I && (I = !1, d?.());
|
|
9370
9375
|
}
|
|
9371
9376
|
};
|
|
9372
|
-
|
|
9373
|
-
},
|
|
9374
|
-
te && (te = !1, c?.({ mode:
|
|
9377
|
+
F = setTimeout(e, 150);
|
|
9378
|
+
}, se = bh(_, () => {
|
|
9379
|
+
te && (te = !1, c?.({ mode: j ? "thinking" : "listening" }));
|
|
9375
9380
|
}, v);
|
|
9376
|
-
typeof window < "u" && (window.__fe_agentAudioPlaying = () =>
|
|
9377
|
-
let
|
|
9378
|
-
|
|
9379
|
-
let
|
|
9380
|
-
|
|
9381
|
+
typeof window < "u" && (window.__fe_agentAudioPlaying = () => se.isPlaying());
|
|
9382
|
+
let ce = _.createMediaStreamSource(g);
|
|
9383
|
+
ce.connect(v);
|
|
9384
|
+
let le = _.createScriptProcessor(nh, 1, 1), ue = !1;
|
|
9385
|
+
le.onaudioprocess = (e) => {
|
|
9381
9386
|
if (k || C.readyState !== WebSocket.OPEN) return;
|
|
9382
9387
|
let t = e.inputBuffer.getChannelData(0), n = () => C.send(new Int16Array(t.length).buffer);
|
|
9383
9388
|
if (A) {
|
|
9384
|
-
ee || (ee = !0, console.debug("[FlowEngage] mic held — streaming silence to keep socket alive")),
|
|
9389
|
+
ee || (ee = !0, console.debug("[FlowEngage] mic held — streaming silence to keep socket alive")), ue = !1, N = 0, ne = 0, n();
|
|
9385
9390
|
return;
|
|
9386
9391
|
}
|
|
9387
|
-
let r =
|
|
9388
|
-
|
|
9389
|
-
|
|
9392
|
+
let r = fh(t), i = dh(t), a = se.isPlaying() || P, o = a ? ie * uh : ie, s = a ? lh : sh;
|
|
9393
|
+
if (r >= o && i >= ah && i <= oh ? (ne = 0, N += 1) : ++ne >= ch && (N = 0), a ? ue = !1 : !ue && N >= sh ? (ue = !0, c?.({ mode: "user-speaking" })) : ue && N === 0 && (ue = !1), a && !re && N >= s) {
|
|
9394
|
+
re = !0, j = !1, N = 0;
|
|
9395
|
+
let e = se.playedMs();
|
|
9396
|
+
se.stop(), M = !1, P = !1, F && !ae && (clearTimeout(F), F = null), I = !1, C.send(JSON.stringify({
|
|
9397
|
+
type: "VisitorInterrupted",
|
|
9398
|
+
played_ms: Math.round(e)
|
|
9399
|
+
})), console.debug("[FlowEngage] barge-in — visitor spoke over the agent");
|
|
9400
|
+
}
|
|
9401
|
+
C.send(ph(t).buffer);
|
|
9402
|
+
}, ce.connect(le), le.connect(_.destination);
|
|
9390
9403
|
let de = () => {
|
|
9391
9404
|
if (!k) {
|
|
9392
|
-
k = !0,
|
|
9405
|
+
k = !0, F &&= (clearTimeout(F), null), D(), se.stop(), typeof window < "u" && delete window.__fe_agentAudioPlaying;
|
|
9393
9406
|
try {
|
|
9394
|
-
|
|
9407
|
+
le.disconnect(), ce.disconnect();
|
|
9395
9408
|
} catch {}
|
|
9396
9409
|
if (g.getTracks().forEach((e) => e.stop()), x && x.state !== "inactive") {
|
|
9397
|
-
x.onstop = () =>
|
|
9410
|
+
x.onstop = () => vh(t, n, S, b, y);
|
|
9398
9411
|
try {
|
|
9399
9412
|
x.stop();
|
|
9400
9413
|
} catch {
|
|
9401
9414
|
x.onstop = null;
|
|
9402
9415
|
}
|
|
9403
|
-
} else b.length &&
|
|
9416
|
+
} else b.length && vh(t, n, S, b, y);
|
|
9404
9417
|
_.close().catch(() => {}), (C.readyState === WebSocket.OPEN || C.readyState === WebSocket.CONNECTING) && C.close();
|
|
9405
9418
|
}
|
|
9406
9419
|
}, fe = async (e) => {
|
|
@@ -9430,7 +9443,7 @@ async function _h(e) {
|
|
|
9430
9443
|
}, me = (e) => {
|
|
9431
9444
|
switch (e.type) {
|
|
9432
9445
|
case "Welcome":
|
|
9433
|
-
Number.isFinite(e.barge_in_rms) && e.barge_in_rms > 0 && e.barge_in_rms, Number.isFinite(e.barge_in_frames) && e.barge_in_frames > 0 && e.barge_in_frames, S = e.session_id || r || n || null, a?.({ conversationId: S });
|
|
9446
|
+
Number.isFinite(e.barge_in_rms) && e.barge_in_rms > 0 && (ie = e.barge_in_rms), Number.isFinite(e.barge_in_frames) && e.barge_in_frames > 0 && e.barge_in_frames, S = e.session_id || r || n || null, a?.({ conversationId: S });
|
|
9434
9447
|
break;
|
|
9435
9448
|
case "ConversationText": {
|
|
9436
9449
|
let t = String(e.content || "");
|
|
@@ -9449,28 +9462,28 @@ async function _h(e) {
|
|
|
9449
9462
|
break;
|
|
9450
9463
|
}
|
|
9451
9464
|
case "UserStartedSpeaking":
|
|
9452
|
-
D(),
|
|
9465
|
+
D(), se.stop(), P = !1, M = !1, te = !1, j = !1, F && !ae && (clearTimeout(F), F = null), I = !1, c?.({ mode: "listening" });
|
|
9453
9466
|
break;
|
|
9454
9467
|
case "AgentStartedSpeaking":
|
|
9455
|
-
|
|
9468
|
+
M = !0, te = !0, re = !1, N = 0, c?.({ mode: "speaking" });
|
|
9456
9469
|
break;
|
|
9457
9470
|
case "AgentAudioDone":
|
|
9458
|
-
|
|
9471
|
+
P = !1, D(), oe(), se.isPlaying() || (te = !1, c?.({ mode: j ? "thinking" : "listening" }));
|
|
9459
9472
|
break;
|
|
9460
9473
|
case "FunctionCallRequest":
|
|
9461
9474
|
pe(e);
|
|
9462
9475
|
break;
|
|
9463
9476
|
case "AgentPreparing":
|
|
9464
|
-
|
|
9477
|
+
P = !0;
|
|
9465
9478
|
break;
|
|
9466
9479
|
case "AgentTurnComplete":
|
|
9467
|
-
|
|
9480
|
+
j = !1, I = !0, oe();
|
|
9468
9481
|
break;
|
|
9469
9482
|
case "SessionEnding":
|
|
9470
|
-
console.debug("[FlowEngage] server is ending the session:", e.reason || "unspecified"),
|
|
9483
|
+
console.debug("[FlowEngage] server is ending the session:", e.reason || "unspecified"), ae = !0;
|
|
9471
9484
|
break;
|
|
9472
9485
|
case "AgentThinking":
|
|
9473
|
-
|
|
9486
|
+
j = !0, c?.({ mode: "thinking" });
|
|
9474
9487
|
break;
|
|
9475
9488
|
case "PromptUpdated": break;
|
|
9476
9489
|
case "Error":
|
|
@@ -9484,7 +9497,7 @@ async function _h(e) {
|
|
|
9484
9497
|
};
|
|
9485
9498
|
return C.onopen = () => C.send(JSON.stringify(h)), C.onmessage = (e) => {
|
|
9486
9499
|
if (e.data instanceof ArrayBuffer) {
|
|
9487
|
-
|
|
9500
|
+
M && se.enqueue(new Int16Array(e.data));
|
|
9488
9501
|
return;
|
|
9489
9502
|
}
|
|
9490
9503
|
try {
|
|
@@ -9531,7 +9544,7 @@ async function _h(e) {
|
|
|
9531
9544
|
}
|
|
9532
9545
|
};
|
|
9533
9546
|
}
|
|
9534
|
-
var
|
|
9547
|
+
var Ch = { startSession: Sh }, wh = ({ size: e = 18, color: t = "currentColor" }) => /* @__PURE__ */ _("svg", {
|
|
9535
9548
|
width: e,
|
|
9536
9549
|
height: e,
|
|
9537
9550
|
viewBox: "0 0 24 24",
|
|
@@ -9547,7 +9560,7 @@ var vh = { startSession: _h }, yh = ({ size: e = 18, color: t = "currentColor" }
|
|
|
9547
9560
|
strokeLinecap: "round",
|
|
9548
9561
|
strokeLinejoin: "round"
|
|
9549
9562
|
})]
|
|
9550
|
-
}),
|
|
9563
|
+
}), Th = ({ size: e = 20 }) => /* @__PURE__ */ _("svg", {
|
|
9551
9564
|
width: e,
|
|
9552
9565
|
height: e,
|
|
9553
9566
|
viewBox: "0 0 24 24",
|
|
@@ -9562,7 +9575,7 @@ var vh = { startSession: _h }, yh = ({ size: e = 18, color: t = "currentColor" }
|
|
|
9562
9575
|
x2: "1",
|
|
9563
9576
|
y2: "23"
|
|
9564
9577
|
})]
|
|
9565
|
-
}),
|
|
9578
|
+
}), Eh = ({ size: e = 18 }) => /* @__PURE__ */ _("svg", {
|
|
9566
9579
|
width: e,
|
|
9567
9580
|
height: e,
|
|
9568
9581
|
viewBox: "0 0 24 24",
|
|
@@ -9577,7 +9590,7 @@ var vh = { startSession: _h }, yh = ({ size: e = 18, color: t = "currentColor" }
|
|
|
9577
9590
|
x2: "12",
|
|
9578
9591
|
y2: "5"
|
|
9579
9592
|
}), /* @__PURE__ */ g("polyline", { points: "5 12 12 5 19 12" })]
|
|
9580
|
-
}),
|
|
9593
|
+
}), Dh = () => /* @__PURE__ */ _("svg", {
|
|
9581
9594
|
width: "14",
|
|
9582
9595
|
height: "14",
|
|
9583
9596
|
viewBox: "0 0 24 24",
|
|
@@ -9587,7 +9600,7 @@ var vh = { startSession: _h }, yh = ({ size: e = 18, color: t = "currentColor" }
|
|
|
9587
9600
|
strokeLinecap: "round",
|
|
9588
9601
|
strokeLinejoin: "round",
|
|
9589
9602
|
children: [/* @__PURE__ */ g("polyline", { points: "9 17 4 12 9 7" }), /* @__PURE__ */ g("path", { d: "M20 18v-2a4 4 0 00-4-4H4" })]
|
|
9590
|
-
}),
|
|
9603
|
+
}), Oh = () => /* @__PURE__ */ g("svg", {
|
|
9591
9604
|
width: "18",
|
|
9592
9605
|
height: "18",
|
|
9593
9606
|
viewBox: "0 0 24 24",
|
|
@@ -9597,7 +9610,7 @@ var vh = { startSession: _h }, yh = ({ size: e = 18, color: t = "currentColor" }
|
|
|
9597
9610
|
strokeLinecap: "round",
|
|
9598
9611
|
strokeLinejoin: "round",
|
|
9599
9612
|
children: /* @__PURE__ */ g("path", { d: "M22 16.92v3a2 2 0 01-2.18 2 19.79 19.79 0 01-8.63-3.07 19.42 19.42 0 01-6.12-6.11A19.79 19.79 0 012 4.11 2 2 0 014.11 2h3a2 2 0 012 1.72c.13.96.37 1.91.71 2.81a2 2 0 01-.45 2.11L8.09 9.91a16 16 0 006 6l1.27-1.27a2 2 0 012.11-.45c.9.34 1.85.58 2.81.71A2 2 0 0122 16.92z" })
|
|
9600
|
-
}),
|
|
9613
|
+
}), kh = ({ className: e = "" }) => /* @__PURE__ */ _("svg", {
|
|
9601
9614
|
className: e,
|
|
9602
9615
|
width: "14",
|
|
9603
9616
|
height: "14",
|
|
@@ -9626,7 +9639,7 @@ var vh = { startSession: _h }, yh = ({ size: e = 18, color: t = "currentColor" }
|
|
|
9626
9639
|
y2: "16"
|
|
9627
9640
|
})
|
|
9628
9641
|
]
|
|
9629
|
-
}),
|
|
9642
|
+
}), Ah = ({ size: e = 14 }) => /* @__PURE__ */ _("svg", {
|
|
9630
9643
|
width: e,
|
|
9631
9644
|
height: e,
|
|
9632
9645
|
viewBox: "0 0 24 24",
|
|
@@ -9649,7 +9662,7 @@ var vh = { startSession: _h }, yh = ({ size: e = 18, color: t = "currentColor" }
|
|
|
9649
9662
|
/* @__PURE__ */ g("path", { d: "M15 13v2" }),
|
|
9650
9663
|
/* @__PURE__ */ g("path", { d: "M9 13v2" })
|
|
9651
9664
|
]
|
|
9652
|
-
}),
|
|
9665
|
+
}), jh = ({ size: e = 20, strokeWidth: t = 2, color: n = "currentColor" }) => /* @__PURE__ */ _("svg", {
|
|
9653
9666
|
width: e,
|
|
9654
9667
|
height: e,
|
|
9655
9668
|
viewBox: "0 0 24 24",
|
|
@@ -9669,7 +9682,7 @@ var vh = { startSession: _h }, yh = ({ size: e = 18, color: t = "currentColor" }
|
|
|
9669
9682
|
x2: "19",
|
|
9670
9683
|
y2: "12"
|
|
9671
9684
|
})]
|
|
9672
|
-
}),
|
|
9685
|
+
}), Mh = ({ size: e = 20, color: t = "currentColor" }) => /* @__PURE__ */ _("svg", {
|
|
9673
9686
|
width: e,
|
|
9674
9687
|
height: e,
|
|
9675
9688
|
viewBox: "0 0 24 24",
|
|
@@ -9695,7 +9708,7 @@ var vh = { startSession: _h }, yh = ({ size: e = 18, color: t = "currentColor" }
|
|
|
9695
9708
|
fill: t
|
|
9696
9709
|
})
|
|
9697
9710
|
]
|
|
9698
|
-
}),
|
|
9711
|
+
}), Nh = ({ size: e = 20, color: t = "currentColor" }) => /* @__PURE__ */ _("svg", {
|
|
9699
9712
|
width: "24",
|
|
9700
9713
|
height: "24",
|
|
9701
9714
|
viewBox: "0 0 24 24",
|
|
@@ -9713,7 +9726,7 @@ var vh = { startSession: _h }, yh = ({ size: e = 18, color: t = "currentColor" }
|
|
|
9713
9726
|
"stroke-linecap": "round",
|
|
9714
9727
|
"stroke-linejoin": "round"
|
|
9715
9728
|
})]
|
|
9716
|
-
}),
|
|
9729
|
+
}), Ph = () => /* @__PURE__ */ g("svg", {
|
|
9717
9730
|
width: "24",
|
|
9718
9731
|
height: "24",
|
|
9719
9732
|
viewBox: "0 0 24 24",
|
|
@@ -9725,7 +9738,7 @@ var vh = { startSession: _h }, yh = ({ size: e = 18, color: t = "currentColor" }
|
|
|
9725
9738
|
"stroke-width": "1.5",
|
|
9726
9739
|
"stroke-linejoin": "round"
|
|
9727
9740
|
})
|
|
9728
|
-
}),
|
|
9741
|
+
}), Fh = ({ size: e = 24 }) => /* @__PURE__ */ _("svg", {
|
|
9729
9742
|
xmlns: "http://www.w3.org/2000/svg",
|
|
9730
9743
|
width: e,
|
|
9731
9744
|
height: e,
|
|
@@ -9743,7 +9756,7 @@ var vh = { startSession: _h }, yh = ({ size: e = 18, color: t = "currentColor" }
|
|
|
9743
9756
|
/* @__PURE__ */ g("path", { d: "m2 2 20 20" }),
|
|
9744
9757
|
/* @__PURE__ */ g("path", { d: "M9 9v3a3 3 0 0 0 5.12 2.12" })
|
|
9745
9758
|
]
|
|
9746
|
-
}),
|
|
9759
|
+
}), Ih = (e = "") => String(e).replace(/<[^>]+>/g, "").replace(/\s+/g, " ").trim(), Lh = (e = "") => String(e).replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'"), Rh = new Set([
|
|
9747
9760
|
"p",
|
|
9748
9761
|
"br",
|
|
9749
9762
|
"ul",
|
|
@@ -9754,30 +9767,30 @@ var vh = { startSession: _h }, yh = ({ size: e = 18, color: t = "currentColor" }
|
|
|
9754
9767
|
"b",
|
|
9755
9768
|
"i",
|
|
9756
9769
|
"a"
|
|
9757
|
-
]),
|
|
9758
|
-
function
|
|
9770
|
+
]), zh = /^https?:\/\//i;
|
|
9771
|
+
function Bh(e) {
|
|
9759
9772
|
let t = Array.from(e.childNodes);
|
|
9760
9773
|
for (let n of t) if (n.nodeType === Node.ELEMENT_NODE) {
|
|
9761
9774
|
let t = n.tagName.toLowerCase();
|
|
9762
|
-
if (!
|
|
9775
|
+
if (!Rh.has(t)) {
|
|
9763
9776
|
e.replaceChild(document.createTextNode(n.textContent), n);
|
|
9764
9777
|
continue;
|
|
9765
9778
|
}
|
|
9766
9779
|
let r = {};
|
|
9767
9780
|
if (t === "a") {
|
|
9768
9781
|
let e = n.getAttribute("href") || "";
|
|
9769
|
-
|
|
9782
|
+
zh.test(e) && (r.href = e), r.target = "_blank", r.rel = "noopener noreferrer";
|
|
9770
9783
|
}
|
|
9771
9784
|
for (; n.attributes.length > 0;) n.removeAttribute(n.attributes[0].name);
|
|
9772
9785
|
for (let [e, t] of Object.entries(r)) n.setAttribute(e, t);
|
|
9773
|
-
|
|
9786
|
+
Bh(n);
|
|
9774
9787
|
} else n.nodeType !== Node.TEXT_NODE && e.removeChild(n);
|
|
9775
9788
|
}
|
|
9776
|
-
function
|
|
9789
|
+
function Vh(e) {
|
|
9777
9790
|
let t = document.createElement("div");
|
|
9778
|
-
return t.innerHTML = e,
|
|
9791
|
+
return t.innerHTML = e, Bh(t), t.innerHTML;
|
|
9779
9792
|
}
|
|
9780
|
-
function
|
|
9793
|
+
function Hh(e) {
|
|
9781
9794
|
let t = String(e || "").trim();
|
|
9782
9795
|
if (!t) return t;
|
|
9783
9796
|
let n = /^<p>\s*<strong>([\s\S]*?)<\/strong>\s*<\/p>$/i.exec(t);
|
|
@@ -9789,33 +9802,33 @@ function Lh(e) {
|
|
|
9789
9802
|
}
|
|
9790
9803
|
return e;
|
|
9791
9804
|
}
|
|
9792
|
-
var
|
|
9805
|
+
var Uh = (e = "") => {
|
|
9793
9806
|
let t = String(e || "").trim();
|
|
9794
9807
|
if (!t) return "";
|
|
9795
|
-
if (/<(p|br|ul|ol|li|strong|em|a)\b/i.test(t)) return
|
|
9796
|
-
let n = t.replace(/\r\n/g, "\n").replace(/\n{3,}/g, "\n\n").split(/\n\s*\n/).map((e) => e.trim()).filter(Boolean), r = (e) =>
|
|
9797
|
-
return
|
|
9808
|
+
if (/<(p|br|ul|ol|li|strong|em|a)\b/i.test(t)) return Hh(Vh(t));
|
|
9809
|
+
let n = t.replace(/\r\n/g, "\n").replace(/\n{3,}/g, "\n\n").split(/\n\s*\n/).map((e) => e.trim()).filter(Boolean), r = (e) => Lh(e).replace(/\[([^\]]+)\]\((https?:\/\/[^\s)]+)\)/g, "<a href=\"$2\" target=\"_blank\" rel=\"noopener noreferrer\">$1</a>").replace(/\*\*([^*]+)\*\*/g, "<strong>$1</strong>").replace(/\*([^*\n]+)\*/g, "<em>$1</em>");
|
|
9810
|
+
return Hh(n.map((e) => {
|
|
9798
9811
|
let t = e.split("\n").map((e) => e.trim()).filter(Boolean), n = t.filter((e) => /^[-*]\s+/.test(e));
|
|
9799
9812
|
if (n.length >= 2 && n.length === t.length) return `<ul>${n.map((e) => `<li>${r(e.replace(/^[-*]\s+/, ""))}</li>`).join("")}</ul>`;
|
|
9800
9813
|
let i = e.split(/\s+(?=[-*]\s+\*\*?)/).map((e) => e.trim()).filter(Boolean);
|
|
9801
9814
|
return i.length >= 2 && i.every((e) => /^[-*]\s+/.test(e)) ? `<ul>${i.map((e) => `<li>${r(e.replace(/^[-*]\s+/, ""))}</li>`).join("")}</ul>` : `<p>${r(e).replace(/\n/g, "<br />")}</p>`;
|
|
9802
9815
|
}).join(""));
|
|
9803
|
-
},
|
|
9816
|
+
}, Wh = new Set(["application/pdf", "application/vnd.openxmlformats-officedocument.wordprocessingml.document"]), Gh = new Set([
|
|
9804
9817
|
".pdf",
|
|
9805
9818
|
".docx",
|
|
9806
9819
|
".png",
|
|
9807
9820
|
".jpg",
|
|
9808
9821
|
".jpeg"
|
|
9809
|
-
]),
|
|
9810
|
-
function
|
|
9822
|
+
]), Kh = "image/png,image/jpeg,.pdf,.docx";
|
|
9823
|
+
function qh(e) {
|
|
9811
9824
|
if (!e) return !1;
|
|
9812
9825
|
let t = typeof e.name == "string" ? e.name.toLowerCase() : "", n = t.includes(".") ? `.${t.split(".").pop()}` : "", r = typeof e.type == "string" ? e.type.toLowerCase() : "";
|
|
9813
|
-
return r === "image/png" || r === "image/jpeg" ||
|
|
9826
|
+
return r === "image/png" || r === "image/jpeg" || Wh.has(r) || Gh.has(n);
|
|
9814
9827
|
}
|
|
9815
|
-
function
|
|
9816
|
-
return e ?
|
|
9828
|
+
function Jh(e) {
|
|
9829
|
+
return e ? qh(e) ? e.size > 2097152 ? "File must be 2 MB or smaller." : "" : "Only PNG, JPEG, PDF, and DOCX files are allowed." : "No file selected.";
|
|
9817
9830
|
}
|
|
9818
|
-
function
|
|
9831
|
+
function Yh(e = 0) {
|
|
9819
9832
|
if (!Number.isFinite(e) || e <= 0) return "";
|
|
9820
9833
|
let t = [
|
|
9821
9834
|
"B",
|
|
@@ -9827,12 +9840,12 @@ function Wh(e = 0) {
|
|
|
9827
9840
|
let i = n >= 10 || r === 0 ? 0 : 1;
|
|
9828
9841
|
return `${n.toFixed(i)} ${t[r]}`;
|
|
9829
9842
|
}
|
|
9830
|
-
function
|
|
9843
|
+
function Xh(e) {
|
|
9831
9844
|
return e ? e.name || "Attachment" : "";
|
|
9832
9845
|
}
|
|
9833
9846
|
//#endregion
|
|
9834
9847
|
//#region src/utils/avatarHelpers.js
|
|
9835
|
-
function
|
|
9848
|
+
function Zh(e) {
|
|
9836
9849
|
if (!e || typeof e != "string") return "?";
|
|
9837
9850
|
let t = e.trim();
|
|
9838
9851
|
if (!t) return "?";
|
|
@@ -9841,7 +9854,7 @@ function Kh(e) {
|
|
|
9841
9854
|
}
|
|
9842
9855
|
//#endregion
|
|
9843
9856
|
//#region src/components/AvatarImageOrInitials.jsx
|
|
9844
|
-
function
|
|
9857
|
+
function Qh({ src: e, name: t, imgStyle: n, initialsSpanStyle: r }) {
|
|
9845
9858
|
let [i, a] = m(null), o = typeof e == "string" ? e.trim() : "";
|
|
9846
9859
|
return c(() => {
|
|
9847
9860
|
if (!o) {
|
|
@@ -9864,12 +9877,12 @@ function qh({ src: e, name: t, imgStyle: n, initialsSpanStyle: r }) {
|
|
|
9864
9877
|
onError: () => a(null)
|
|
9865
9878
|
}) : /* @__PURE__ */ g("span", {
|
|
9866
9879
|
style: r,
|
|
9867
|
-
children:
|
|
9880
|
+
children: Zh(t)
|
|
9868
9881
|
});
|
|
9869
9882
|
}
|
|
9870
9883
|
//#endregion
|
|
9871
9884
|
//#region src/components/MessageList.jsx
|
|
9872
|
-
function
|
|
9885
|
+
function $h({ chatHistory: e, isAiTyping: t, isLoading: n, isAgentTyping: r, setReplyContext: i, primaryColor: a = "#3B82F6", agentHeadshot: s = null, agentDisplayName: l = "Agent", botAvatarNode: u = null }) {
|
|
9873
9886
|
let { resolvedConfig: d } = Cn(), f = p(null), [v, y] = m(null), [b, x] = m(null), S = p(e.length), C = p(!0), w = p(null), T = o((e) => {
|
|
9874
9887
|
let t = e.target.closest("a[href]");
|
|
9875
9888
|
if (!t) return;
|
|
@@ -9924,7 +9937,7 @@ function Jh({ chatHistory: e, isAiTyping: t, isLoading: n, isAgentTyping: r, set
|
|
|
9924
9937
|
children: [
|
|
9925
9938
|
e.map((e) => {
|
|
9926
9939
|
if (e.type === "call_recording" || typeof e.message == "string" && e.message.includes("AI chat recording")) return null;
|
|
9927
|
-
let t = e.sender === "system", n = e.sender === "user", r = e.sender === "ai" || e.sender === "bot", o = e.sender === "agent", c = e.isPending, d = e.type === "file" && e.metadata?.fileUrl, f = e.agent_name || e.agentName || e.metadata?.agentName || l, p = typeof e.sender_headshot == "string" && e.sender_headshot.trim() || typeof s == "string" && s.trim() || null, m =
|
|
9940
|
+
let t = e.sender === "system", n = e.sender === "user", r = e.sender === "ai" || e.sender === "bot", o = e.sender === "agent", c = e.isPending, d = e.type === "file" && e.metadata?.fileUrl, f = e.agent_name || e.agentName || e.metadata?.agentName || l, p = typeof e.sender_headshot == "string" && e.sender_headshot.trim() || typeof s == "string" && s.trim() || null, m = Ih(e.replyToContent || e.replyContext?.message || ""), v = e.replyToSender === "user" ? "You" : e.replyToSender === "agent" ? "Agent" : e.replyToSender === "ai" || e.replyToSender === "bot" ? "AI Assistant" : "Message";
|
|
9928
9941
|
return t ? /* @__PURE__ */ g("div", {
|
|
9929
9942
|
style: {
|
|
9930
9943
|
display: "flex",
|
|
@@ -9969,7 +9982,7 @@ function Jh({ chatHistory: e, isAiTyping: t, isLoading: n, isAgentTyping: r, set
|
|
|
9969
9982
|
fontWeight: 800,
|
|
9970
9983
|
marginTop: !c && (r || o) ? "22px" : "0px"
|
|
9971
9984
|
},
|
|
9972
|
-
children: r ? u || /* @__PURE__ */ g(
|
|
9985
|
+
children: r ? u || /* @__PURE__ */ g(Ah, { size: 16 }) : /* @__PURE__ */ g(Qh, {
|
|
9973
9986
|
src: p || "",
|
|
9974
9987
|
name: f,
|
|
9975
9988
|
imgStyle: {
|
|
@@ -10011,7 +10024,7 @@ function Jh({ chatHistory: e, isAiTyping: t, isLoading: n, isAgentTyping: r, set
|
|
|
10011
10024
|
onMouseLeave: (e) => {
|
|
10012
10025
|
e.currentTarget.style.color = "#9ca3af";
|
|
10013
10026
|
},
|
|
10014
|
-
children: [/* @__PURE__ */ g(
|
|
10027
|
+
children: [/* @__PURE__ */ g(Dh, {}), "Reply"]
|
|
10015
10028
|
}),
|
|
10016
10029
|
/* @__PURE__ */ _("div", {
|
|
10017
10030
|
style: {
|
|
@@ -10055,7 +10068,7 @@ function Jh({ chatHistory: e, isAiTyping: t, isLoading: n, isAgentTyping: r, set
|
|
|
10055
10068
|
children: m
|
|
10056
10069
|
})]
|
|
10057
10070
|
}), d ? (() => {
|
|
10058
|
-
let t = e.metadata.fileType || "", r = e.metadata.fileName || e.message || "File", i =
|
|
10071
|
+
let t = e.metadata.fileType || "", r = e.metadata.fileName || e.message || "File", i = Yh(e.metadata.fileSize), a = t.startsWith("image/"), o = `shared file: ${r}`.toLowerCase(), s = (e.message || "").trim(), c = s && s.toLowerCase() !== o && !s.toLowerCase().startsWith("shared file:"), l = t === "application/pdf" ? {
|
|
10059
10072
|
color: "#ef4444",
|
|
10060
10073
|
label: "PDF"
|
|
10061
10074
|
} : t.includes("word") || t.includes("docx") ? {
|
|
@@ -10236,7 +10249,7 @@ function Jh({ chatHistory: e, isAiTyping: t, isLoading: n, isAgentTyping: r, set
|
|
|
10236
10249
|
});
|
|
10237
10250
|
})() : r ? /* @__PURE__ */ g("div", {
|
|
10238
10251
|
className: "flowengage-message-content fe-bot-message",
|
|
10239
|
-
dangerouslySetInnerHTML: { __html:
|
|
10252
|
+
dangerouslySetInnerHTML: { __html: Uh(e.message) },
|
|
10240
10253
|
onClick: T
|
|
10241
10254
|
}) : /* @__PURE__ */ g("div", {
|
|
10242
10255
|
style: { whiteSpace: "pre-wrap" },
|
|
@@ -10301,7 +10314,7 @@ function Jh({ chatHistory: e, isAiTyping: t, isLoading: n, isAgentTyping: r, set
|
|
|
10301
10314
|
boxShadow: u ? "none" : "0 8px 20px rgba(59,130,246,0.24)",
|
|
10302
10315
|
overflow: "hidden"
|
|
10303
10316
|
},
|
|
10304
|
-
children: u || /* @__PURE__ */ g(
|
|
10317
|
+
children: u || /* @__PURE__ */ g(Ah, { size: 16 })
|
|
10305
10318
|
}), /* @__PURE__ */ _("div", {
|
|
10306
10319
|
style: {
|
|
10307
10320
|
display: "flex",
|
|
@@ -10343,7 +10356,7 @@ function Jh({ chatHistory: e, isAiTyping: t, isLoading: n, isAgentTyping: r, set
|
|
|
10343
10356
|
borderRadius: "50%",
|
|
10344
10357
|
overflow: "hidden"
|
|
10345
10358
|
},
|
|
10346
|
-
children: /* @__PURE__ */ g(
|
|
10359
|
+
children: /* @__PURE__ */ g(Qh, {
|
|
10347
10360
|
src: s || "",
|
|
10348
10361
|
name: l,
|
|
10349
10362
|
imgStyle: {
|
|
@@ -10437,23 +10450,23 @@ function Jh({ chatHistory: e, isAiTyping: t, isLoading: n, isAgentTyping: r, set
|
|
|
10437
10450
|
}
|
|
10438
10451
|
//#endregion
|
|
10439
10452
|
//#region src/components/ChatInput.jsx
|
|
10440
|
-
var
|
|
10441
|
-
function
|
|
10453
|
+
var eg = typeof window < "u" && (window.matchMedia?.("(pointer: coarse)").matches || navigator.maxTouchPoints > 0);
|
|
10454
|
+
function tg({ input: e, setInput: t, onSubmit: n, isConversationEnded: r, callUiActive: i, handleToggleVoice: a, activeScreen: o, inputDisabled: s, replyContext: l, clearReplyContext: u, requiresEmail: d, emailInput: f, setEmailInput: m, emailError: v, showVoiceToggle: y = !1, voiceEnabled: b = !0, onFileSelect: x, selectedFile: S = null, onRemoveSelectedFile: C, attachmentError: w = "", isUploadingAttachment: T = !1, inputPlaceholder: E = "Type your message" }) {
|
|
10442
10455
|
let D = p(null), O = p(null), k = (e) => {
|
|
10443
10456
|
e && (e.style.height = "auto", e.style.height = `${Math.min(e.scrollHeight, 120)}px`);
|
|
10444
10457
|
};
|
|
10445
10458
|
c(() => {
|
|
10446
10459
|
d || k(O.current);
|
|
10447
10460
|
}, [e, d]), c(() => {
|
|
10448
|
-
d ||
|
|
10461
|
+
d || eg || e || s || O.current?.focus();
|
|
10449
10462
|
}, [
|
|
10450
10463
|
e,
|
|
10451
10464
|
d,
|
|
10452
10465
|
s
|
|
10453
10466
|
]);
|
|
10454
10467
|
let A = (e) => {
|
|
10455
|
-
e.key === "Enter" && (
|
|
10456
|
-
}, ee = l?.sender === "user" ? "You" : l?.sender === "agent" ? "Agent" : "AI Assistant", te = d ? !!f?.trim() : !!e?.trim() || !!S,
|
|
10468
|
+
e.key === "Enter" && (eg || e.shiftKey || e.altKey || e.ctrlKey || e.metaKey || (e.preventDefault(), e.currentTarget.form?.requestSubmit()));
|
|
10469
|
+
}, ee = l?.sender === "user" ? "You" : l?.sender === "agent" ? "Agent" : "AI Assistant", te = d ? !!f?.trim() : !!e?.trim() || !!S, j = s || T || !te, M = !d && b && y;
|
|
10457
10470
|
return /* @__PURE__ */ _("div", {
|
|
10458
10471
|
style: {
|
|
10459
10472
|
padding: "0 16px",
|
|
@@ -10547,7 +10560,7 @@ function Xh({ input: e, setInput: t, onSubmit: n, isConversationEnded: r, callUi
|
|
|
10547
10560
|
background: "rgba(59,130,246,0.08)",
|
|
10548
10561
|
color: "var(--flowengage-primary)"
|
|
10549
10562
|
},
|
|
10550
|
-
children: /* @__PURE__ */ g(
|
|
10563
|
+
children: /* @__PURE__ */ g(Ah, { size: 13 })
|
|
10551
10564
|
}), /* @__PURE__ */ g("span", { children: "Please provide your email address so we can help you." })]
|
|
10552
10565
|
})
|
|
10553
10566
|
}),
|
|
@@ -10587,7 +10600,7 @@ function Xh({ input: e, setInput: t, onSubmit: n, isConversationEnded: r, callUi
|
|
|
10587
10600
|
overflow: "hidden",
|
|
10588
10601
|
textOverflow: "ellipsis"
|
|
10589
10602
|
},
|
|
10590
|
-
children:
|
|
10603
|
+
children: Xh(S)
|
|
10591
10604
|
}),
|
|
10592
10605
|
/* @__PURE__ */ g("div", {
|
|
10593
10606
|
style: {
|
|
@@ -10595,7 +10608,7 @@ function Xh({ input: e, setInput: t, onSubmit: n, isConversationEnded: r, callUi
|
|
|
10595
10608
|
color: "#6b7280",
|
|
10596
10609
|
marginTop: "2px"
|
|
10597
10610
|
},
|
|
10598
|
-
children:
|
|
10611
|
+
children: Yh(S.size)
|
|
10599
10612
|
})
|
|
10600
10613
|
]
|
|
10601
10614
|
}), /* @__PURE__ */ g("button", {
|
|
@@ -10637,10 +10650,10 @@ function Xh({ input: e, setInput: t, onSubmit: n, isConversationEnded: r, callUi
|
|
|
10637
10650
|
},
|
|
10638
10651
|
onSubmit: n,
|
|
10639
10652
|
children: [
|
|
10640
|
-
|
|
10653
|
+
M ? /* @__PURE__ */ _(h, { children: [/* @__PURE__ */ g("input", {
|
|
10641
10654
|
ref: D,
|
|
10642
10655
|
type: "file",
|
|
10643
|
-
accept:
|
|
10656
|
+
accept: Kh,
|
|
10644
10657
|
style: { display: "none" },
|
|
10645
10658
|
onChange: (e) => {
|
|
10646
10659
|
let t = e.target.files?.[0];
|
|
@@ -10672,7 +10685,7 @@ function Xh({ input: e, setInput: t, onSubmit: n, isConversationEnded: r, callUi
|
|
|
10672
10685
|
onMouseLeave: (e) => {
|
|
10673
10686
|
e.currentTarget.style.opacity = "1";
|
|
10674
10687
|
},
|
|
10675
|
-
children: /* @__PURE__ */ g(
|
|
10688
|
+
children: /* @__PURE__ */ g(jh, {
|
|
10676
10689
|
size: 16,
|
|
10677
10690
|
color: "currentColor"
|
|
10678
10691
|
})
|
|
@@ -10687,7 +10700,7 @@ function Xh({ input: e, setInput: t, onSubmit: n, isConversationEnded: r, callUi
|
|
|
10687
10700
|
fontSize: "14px",
|
|
10688
10701
|
outline: "none",
|
|
10689
10702
|
padding: 0,
|
|
10690
|
-
paddingLeft:
|
|
10703
|
+
paddingLeft: M ? "0" : "8px",
|
|
10691
10704
|
color: "#111827",
|
|
10692
10705
|
background: "transparent",
|
|
10693
10706
|
cursor: "text",
|
|
@@ -10712,7 +10725,7 @@ function Xh({ input: e, setInput: t, onSubmit: n, isConversationEnded: r, callUi
|
|
|
10712
10725
|
lineHeight: "20px",
|
|
10713
10726
|
outline: "none",
|
|
10714
10727
|
padding: "6px 0",
|
|
10715
|
-
paddingLeft:
|
|
10728
|
+
paddingLeft: M ? "0" : "8px",
|
|
10716
10729
|
color: "#111827",
|
|
10717
10730
|
background: "transparent",
|
|
10718
10731
|
cursor: "text",
|
|
@@ -10742,18 +10755,18 @@ function Xh({ input: e, setInput: t, onSubmit: n, isConversationEnded: r, callUi
|
|
|
10742
10755
|
alignItems: "center",
|
|
10743
10756
|
justifyContent: "center",
|
|
10744
10757
|
transition: "opacity 0.2s ease",
|
|
10745
|
-
cursor:
|
|
10746
|
-
opacity:
|
|
10758
|
+
cursor: j ? "not-allowed" : "pointer",
|
|
10759
|
+
opacity: j ? .45 : 1,
|
|
10747
10760
|
flexShrink: 0
|
|
10748
10761
|
},
|
|
10749
|
-
disabled:
|
|
10762
|
+
disabled: j,
|
|
10750
10763
|
onMouseEnter: (e) => {
|
|
10751
|
-
|
|
10764
|
+
j || (e.currentTarget.style.opacity = "0.85");
|
|
10752
10765
|
},
|
|
10753
10766
|
onMouseLeave: (e) => {
|
|
10754
10767
|
e.currentTarget.style.opacity = "1";
|
|
10755
10768
|
},
|
|
10756
|
-
children: /* @__PURE__ */ g(
|
|
10769
|
+
children: /* @__PURE__ */ g(Eh, { size: 16 })
|
|
10757
10770
|
})
|
|
10758
10771
|
]
|
|
10759
10772
|
}),
|
|
@@ -10816,7 +10829,7 @@ function Xh({ input: e, setInput: t, onSubmit: n, isConversationEnded: r, callUi
|
|
|
10816
10829
|
}
|
|
10817
10830
|
//#endregion
|
|
10818
10831
|
//#region src/components/StatusBanners.jsx
|
|
10819
|
-
function
|
|
10832
|
+
function ng({ webRTCError: e, micError: t, setMicError: n, dismissCallError: r, isRateLimited: i, rateLimitMessage: a }) {
|
|
10820
10833
|
return /* @__PURE__ */ _(h, { children: [(e || t) && /* @__PURE__ */ _("div", {
|
|
10821
10834
|
style: {
|
|
10822
10835
|
margin: "0 20px 10px",
|
|
@@ -10829,7 +10842,7 @@ function Zh({ webRTCError: e, micError: t, setMicError: n, dismissCallError: r,
|
|
|
10829
10842
|
gap: "10px"
|
|
10830
10843
|
},
|
|
10831
10844
|
children: [
|
|
10832
|
-
/* @__PURE__ */ g(
|
|
10845
|
+
/* @__PURE__ */ g(kh, { className: "" }),
|
|
10833
10846
|
/* @__PURE__ */ g("span", {
|
|
10834
10847
|
style: {
|
|
10835
10848
|
fontSize: "12px",
|
|
@@ -10875,13 +10888,13 @@ function Zh({ webRTCError: e, micError: t, setMicError: n, dismissCallError: r,
|
|
|
10875
10888
|
}
|
|
10876
10889
|
//#endregion
|
|
10877
10890
|
//#region src/components/AnimatedOrb.jsx
|
|
10878
|
-
var
|
|
10891
|
+
var rg = [
|
|
10879
10892
|
"#135bd8",
|
|
10880
10893
|
"#ef334b",
|
|
10881
10894
|
"#ffbd2e"
|
|
10882
10895
|
];
|
|
10883
|
-
function
|
|
10884
|
-
return !Array.isArray(e) || e.length === 0 ?
|
|
10896
|
+
function ig(e) {
|
|
10897
|
+
return !Array.isArray(e) || e.length === 0 ? rg : e.length === 1 ? [
|
|
10885
10898
|
e[0],
|
|
10886
10899
|
e[0],
|
|
10887
10900
|
e[0]
|
|
@@ -10895,7 +10908,7 @@ function $h(e) {
|
|
|
10895
10908
|
e[2]
|
|
10896
10909
|
];
|
|
10897
10910
|
}
|
|
10898
|
-
var
|
|
10911
|
+
var ag = {
|
|
10899
10912
|
idle: 3,
|
|
10900
10913
|
listening: .75,
|
|
10901
10914
|
thinking: 1,
|
|
@@ -10903,7 +10916,7 @@ var eg = {
|
|
|
10903
10916
|
muted: .75,
|
|
10904
10917
|
error: .08
|
|
10905
10918
|
};
|
|
10906
|
-
function
|
|
10919
|
+
function og(e) {
|
|
10907
10920
|
if (!e || typeof e != "string") return [
|
|
10908
10921
|
0,
|
|
10909
10922
|
0,
|
|
@@ -10916,14 +10929,14 @@ function tg(e) {
|
|
|
10916
10929
|
parseInt(n.slice(4, 6), 16) / 255
|
|
10917
10930
|
];
|
|
10918
10931
|
}
|
|
10919
|
-
function
|
|
10932
|
+
function sg(e, t) {
|
|
10920
10933
|
if (!e || typeof e != "string") return `rgba(0,0,0,${t})`;
|
|
10921
10934
|
if (e.startsWith("rgb")) return e.replace(/[\d.]+\)$/, `${t})`);
|
|
10922
10935
|
let n = e.replace("#", ""), r = n.length === 3 ? n.split("").map((e) => e + e).join("") : n;
|
|
10923
10936
|
return `rgba(${parseInt(r.slice(0, 2), 16)},${parseInt(r.slice(2, 4), 16)},${parseInt(r.slice(4, 6), 16)},${t})`;
|
|
10924
10937
|
}
|
|
10925
|
-
var
|
|
10926
|
-
function
|
|
10938
|
+
var cg = "\n attribute vec2 a_pos;\n varying vec2 v_uv;\n void main() {\n v_uv = a_pos * 0.5 + 0.5;\n gl_Position = vec4(a_pos, 0.0, 1.0);\n }\n", lg = "\n precision highp float;\n\n varying vec2 v_uv;\n uniform float u_time;\n uniform float u_speed;\n uniform vec3 u_c1;\n uniform vec3 u_c2;\n uniform vec3 u_c3;\n\n // ── Gradient noise ─────────────────────────────────────────────────────────\n vec2 hash2(vec2 p) {\n p = vec2(dot(p, vec2(127.1, 311.7)), dot(p, vec2(269.5, 183.3)));\n return -1.0 + 2.0 * fract(sin(p) * 43758.5453123);\n }\n float gnoise(vec2 p) {\n vec2 i = floor(p), f = fract(p);\n vec2 u = f*f*f*(f*(f*6.0-15.0)+10.0);\n return mix(\n mix(dot(hash2(i), f),\n dot(hash2(i+vec2(1,0)), f-vec2(1,0)), u.x),\n mix(dot(hash2(i+vec2(0,1)), f-vec2(0,1)),\n dot(hash2(i+vec2(1,1)), f-vec2(1,1)), u.x),\n u.y\n ) * 0.5 + 0.5;\n }\n\n // ── 3-octave FBM normalised to [0,1] — fewer octaves → larger, softer blobs\n float fbm(vec2 p) {\n float v = 0.0, a = 0.5;\n for (int i = 0; i < 3; i++) {\n v += a * gnoise(p);\n p = p * 2.1 + vec2(100.0);\n a *= 0.5;\n }\n return v / 0.875;\n }\n\n // ── Scalar hash for grain ──────────────────────────────────────────────────\n float hash1(vec2 p) {\n return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453);\n }\n\n void main() {\n vec2 uv = v_uv;\n float t = u_time * u_speed + 47.3;\n\n // ── ① Two-level domain warp — deep organic folding and swirling ───────────\n // First pass: large-scale sweep\n vec2 q = vec2(\n fbm(uv * 1.8 + vec2( t * 0.13, t * 0.11)) * 2.0 - 1.0,\n fbm(uv * 1.8 + vec2( t * 0.11 + 3.7, -t * 0.14 + 1.1)) * 2.0 - 1.0\n );\n // Second pass: warp the warp — creates curling, folding sub-currents\n vec2 r = vec2(\n fbm(uv * 1.8 + q * 0.55 + vec2( t * 0.09, t * 0.07)) * 2.0 - 1.0,\n fbm(uv * 1.8 + q * 0.55 + vec2(-t * 0.07 + 5.1, t * 0.10 + 2.3)) * 2.0 - 1.0\n );\n vec2 wp = uv + r * 0.38;\n\n // ── ② Three independent fields — each drifts inward from its source edge ──\n // Asymmetric velocities: dominant axis matches the inflow direction so the\n // noise texture visually streams inward (left→right, right→left, bottom→top).\n float f1 = fbm(wp * 0.85 + vec2(-t * 0.18, t * 0.04)); // LEFT → right\n float f2 = fbm(wp * 0.85 + vec2( t * 0.18 + 5.3, t * 0.04 + 1.7)); // RIGHT → left\n float f3 = fbm(wp * 0.85 + vec2( t * 0.04 - 3.2, -t * 0.18 + 6.4)); // BOTTOM → up\n\n // ── ③ Breathing blobs — sin pulse makes each field expand and contract ────\n float p1 = 0.88 + 0.12 * sin(t * 0.61);\n float p2 = 0.88 + 0.12 * sin(t * 0.47 + 2.09);\n float p3 = 0.88 + 0.12 * sin(t * 0.53 + 4.19);\n\n // Wide smoothstep (0.26 → 0.70) → soft, diffused blob edges that dissolve\n // gradually into each other, like dye spreading through water.\n float b1 = smoothstep(0.26, 0.70, f1 * p1);\n float b2 = smoothstep(0.26, 0.70, f2 * p2);\n float b3 = smoothstep(0.26, 0.70, f3 * p3);\n\n // ── ④ Directional origin gradients.\n // Each color owns its home edge (value = 1.0) and smoothly fades to zero\n // before reaching the opposite side. The transition windows are offset so\n // they overlap only in the center third — that overlap zone is where the\n // three colors meet and blend, while the edges stay uncontaminated.\n float d1 = 1.0 - smoothstep(0.20, 0.74, uv.x); // c1: LEFT → full at x<0.20, zero by x=0.74\n float d2 = 1.0 - smoothstep(0.20, 0.74, 1.0 - uv.x); // c2: RIGHT → full at x>0.80, zero by x=0.26\n float d3 = 1.0 - smoothstep(0.18, 0.68, uv.y); // c3: BOTTOM → full at y<0.18, zero by y=0.68\n\n float w1 = b1 * d1;\n float w2 = b2 * d2;\n float w3 = b3 * d3;\n\n // ── ⑤ Dye-mixing colour blend ──────────────────────────────────────────────\n // dyeColor is the weighted average of all active colours — exactly how dyes\n // mix in water: overlapping streams blend smoothly, no hard edges.\n float total = w1 + w2 + w3;\n vec3 dyeColor = (u_c1 * w1 + u_c2 * w2 + u_c3 * w3) / max(total, 0.001);\n\n // Boost brightness of the dye to make colors pop and seem less dull\n dyeColor *= 1.65;\n\n // Exponential coverage: cores are rich and opaque; edges dissolve into the\n // near-white base. White only shows through where dye concentration is thin.\n float coverage = 1.0 - exp(-total * 5.0);\n vec3 col = mix(vec3(1.0, 1.0, 1.0), dyeColor, coverage);\n col = clamp(col, 0.0, 1.0);\n\n // ── ⑥ Sphere shading — subtle edge vignette only, no specular ─────────────\n vec2 uvc = v_uv * 2.0 - 1.0;\n\n // ── ⑦ Subtle grain — breaks gradient banding, adds filmic texture ──────────\n float grain = hash1(v_uv * 437.3 + fract(t)) * 2.0 - 1.0;\n col += grain * 0.018;\n\n gl_FragColor = vec4(clamp(col, 0.0, 1.0), 1.0);\n }\n";
|
|
10939
|
+
function ug(e, t, n) {
|
|
10927
10940
|
let r = (t, n) => {
|
|
10928
10941
|
let r = e.createShader(t);
|
|
10929
10942
|
return e.shaderSource(r, n), e.compileShader(r), e.getShaderParameter(r, e.COMPILE_STATUS) ? r : (console.error("[AnimatedOrb shader]", e.getShaderInfoLog(r)), null);
|
|
@@ -10932,10 +10945,10 @@ function ag(e, t, n) {
|
|
|
10932
10945
|
let o = e.createProgram();
|
|
10933
10946
|
return e.attachShader(o, i), e.attachShader(o, a), e.linkProgram(o), e.getProgramParameter(o, e.LINK_STATUS) ? o : (console.error("[AnimatedOrb link]", e.getProgramInfoLog(o)), null);
|
|
10934
10947
|
}
|
|
10935
|
-
function
|
|
10936
|
-
let [s, l, u] =
|
|
10948
|
+
function dg({ size: e = 94, voiceState: t = "idle", isMuted: n = !1, colors: r, onClick: i, style: a, className: o }) {
|
|
10949
|
+
let [s, l, u] = ig(r), d = t === "speaking", f = e <= 50, m = p(null), h = p(ag[t] ?? .35);
|
|
10937
10950
|
c(() => {
|
|
10938
|
-
h.current =
|
|
10951
|
+
h.current = ag[t] ?? .35;
|
|
10939
10952
|
}, [t]), c(() => {
|
|
10940
10953
|
let t = m.current;
|
|
10941
10954
|
if (!t) return;
|
|
@@ -10952,7 +10965,7 @@ function og({ size: e = 94, voiceState: t = "idle", isMuted: n = !1, colors: r,
|
|
|
10952
10965
|
console.warn("[AnimatedOrb] WebGL unavailable.");
|
|
10953
10966
|
return;
|
|
10954
10967
|
}
|
|
10955
|
-
let i =
|
|
10968
|
+
let i = ug(r, cg, lg);
|
|
10956
10969
|
if (!i) {
|
|
10957
10970
|
console.error("[AnimatedOrb] WebGL program failed to compile/link");
|
|
10958
10971
|
return;
|
|
@@ -10982,7 +10995,7 @@ function og({ size: e = 94, voiceState: t = "idle", isMuted: n = !1, colors: r,
|
|
|
10982
10995
|
c2: r.getUniformLocation(i, "u_c2"),
|
|
10983
10996
|
c3: r.getUniformLocation(i, "u_c3")
|
|
10984
10997
|
};
|
|
10985
|
-
r.uniform3fv(c.c1,
|
|
10998
|
+
r.uniform3fv(c.c1, og(s)), r.uniform3fv(c.c2, og(l)), r.uniform3fv(c.c3, og(u)), r.viewport(0, 0, t.width, t.height);
|
|
10986
10999
|
let d = performance.now(), f, p = (e) => {
|
|
10987
11000
|
r.uniform1f(c.time, (e - d) / 1e3), r.uniform1f(c.speed, h.current), r.drawArrays(r.TRIANGLES, 0, 6), f = requestAnimationFrame(p);
|
|
10988
11001
|
};
|
|
@@ -11013,7 +11026,7 @@ function og({ size: e = 94, voiceState: t = "idle", isMuted: n = !1, colors: r,
|
|
|
11013
11026
|
position: "absolute",
|
|
11014
11027
|
inset: -10,
|
|
11015
11028
|
borderRadius: "50%",
|
|
11016
|
-
background: `radial-gradient(circle, ${
|
|
11029
|
+
background: `radial-gradient(circle, ${sg(s, .18)} 0%, transparent 70%)`,
|
|
11017
11030
|
pointerEvents: "none"
|
|
11018
11031
|
},
|
|
11019
11032
|
animate: { opacity: [.3, .75] },
|
|
@@ -11091,17 +11104,17 @@ function og({ size: e = 94, voiceState: t = "idle", isMuted: n = !1, colors: r,
|
|
|
11091
11104
|
}
|
|
11092
11105
|
//#endregion
|
|
11093
11106
|
//#region src/components/CallScreen.jsx
|
|
11094
|
-
var
|
|
11095
|
-
function
|
|
11107
|
+
var fg = "\n @keyframes fe-call-ring-pulse {\n 0% { transform: scale(1); opacity: 0.55; }\n 70% { transform: scale(1.85); opacity: 0; }\n 100% { transform: scale(1.85); opacity: 0; }\n }\n @keyframes fe-call-spin {\n to { transform: rotate(360deg); }\n }\n @keyframes fe-call-slide-up {\n from { opacity: 0; transform: translateY(24px); }\n to { opacity: 1; transform: translateY(0); }\n }\n @keyframes fe-call-fade-in {\n from { opacity: 0; }\n to { opacity: 1; }\n }\n @keyframes fe-call-bar-slide-in {\n from { opacity: 0; transform: translateY(10px) scale(0.97); }\n to { opacity: 1; transform: translateY(0) scale(1); }\n }\n @keyframes fe-call-dot-blink {\n 0%, 100% { opacity: 1; }\n 50% { opacity: 0.35; }\n }\n @keyframes fe-call-avatar-breathe {\n 0%, 100% { opacity: 0.5; transform: scale(1); }\n 50% { opacity: 0.9; transform: scale(1.12); }\n }\n";
|
|
11108
|
+
function pg(e) {
|
|
11096
11109
|
let t = (e || "").replace("#", ""), n = t.length === 3 ? t.split("").map((e) => e + e).join("") : t;
|
|
11097
11110
|
return `${parseInt(n.slice(0, 2), 16)},${parseInt(n.slice(2, 4), 16)},${parseInt(n.slice(4, 6), 16)}`;
|
|
11098
11111
|
}
|
|
11099
|
-
function
|
|
11112
|
+
function mg(e) {
|
|
11100
11113
|
if (!e || typeof e != "string") return "#1a1a1a";
|
|
11101
11114
|
let t = e.replace("#", ""), n = t.length === 3 ? t.split("").map((e) => e + e).join("") : t, r = parseInt(n.slice(0, 2), 16) / 255, i = parseInt(n.slice(2, 4), 16) / 255, a = parseInt(n.slice(4, 6), 16) / 255, o = (e) => e <= .04045 ? e / 12.92 : ((e + .055) / 1.055) ** 2.4;
|
|
11102
11115
|
return .2126 * o(r) + .7152 * o(i) + .0722 * o(a) > .179 ? "#1a1a1a" : "#ffffff";
|
|
11103
11116
|
}
|
|
11104
|
-
function
|
|
11117
|
+
function hg(e, t) {
|
|
11105
11118
|
let n = Array.isArray(e) && e.length > 0 ? e : [t || "#3B82F6"], [r, i, a] = n;
|
|
11106
11119
|
return n.length === 1 ? [
|
|
11107
11120
|
`radial-gradient(ellipse 110% 65% at 50% -5%, ${r}28 0%, transparent 68%)`,
|
|
@@ -11118,8 +11131,8 @@ function ug(e, t) {
|
|
|
11118
11131
|
"#f7f8fa"
|
|
11119
11132
|
].join(", ");
|
|
11120
11133
|
}
|
|
11121
|
-
function
|
|
11122
|
-
let i = (t || "A")[0].toUpperCase(), a =
|
|
11134
|
+
function gg({ headshot: e, name: t, size: n = 80, primaryColor: r = "#3B82F6" }) {
|
|
11135
|
+
let i = (t || "A")[0].toUpperCase(), a = mg(r), o = n > 48 ? {
|
|
11123
11136
|
boxShadow: `0 0 0 3px ${r}44`,
|
|
11124
11137
|
border: "3px solid rgba(255,255,255,0.15)"
|
|
11125
11138
|
} : { border: `1.5px solid ${r}55` };
|
|
@@ -11156,7 +11169,7 @@ function dg({ headshot: e, name: t, size: n = 80, primaryColor: r = "#3B82F6" })
|
|
|
11156
11169
|
children: i
|
|
11157
11170
|
});
|
|
11158
11171
|
}
|
|
11159
|
-
function
|
|
11172
|
+
function _g(e) {
|
|
11160
11173
|
let t = p(null), n = o(() => {
|
|
11161
11174
|
if (!t.current) return;
|
|
11162
11175
|
let { audioContext: e, oscillator: n, interval: r, toneTimeout: i } = t.current;
|
|
@@ -11203,8 +11216,8 @@ function fg(e) {
|
|
|
11203
11216
|
n
|
|
11204
11217
|
]), c(() => () => n(), [n]), n;
|
|
11205
11218
|
}
|
|
11206
|
-
function
|
|
11207
|
-
let y = a || s || "Agent", b = e ? "incoming" : n === "connecting" ? "connecting" : "ongoing", x =
|
|
11219
|
+
function vg({ incomingCall: e, activeCallId: t, callConnectionState: n, callDurationSeconds: r, isCallMuted: i, agentName: a, agentHeadshot: o, fallbackAgentName: s, acceptCall: c, rejectCall: l, endWebRTCCall: u, toggleCallMute: d, formatCallDuration: f, onMinimize: p, primaryColor: m = "#3B82F6", orbColors: h, chatHistory: v = [] }) {
|
|
11220
|
+
let y = a || s || "Agent", b = e ? "incoming" : n === "connecting" ? "connecting" : "ongoing", x = _g(!!e), S = async () => {
|
|
11208
11221
|
x(), await c();
|
|
11209
11222
|
}, C = async () => {
|
|
11210
11223
|
x(), await l();
|
|
@@ -11216,14 +11229,14 @@ function pg({ incomingCall: e, activeCallId: t, callConnectionState: n, callDura
|
|
|
11216
11229
|
flexDirection: "column",
|
|
11217
11230
|
borderRadius: "inherit",
|
|
11218
11231
|
overflow: "hidden",
|
|
11219
|
-
background:
|
|
11232
|
+
background: hg(h, m),
|
|
11220
11233
|
animation: T ? "fe-call-slide-up 0.36s cubic-bezier(0.16,1,0.3,1)" : "fe-call-fade-in 0.32s ease"
|
|
11221
11234
|
};
|
|
11222
11235
|
if (b === "incoming") {
|
|
11223
11236
|
let e = Array.isArray(h) && h.length > 0 ? h : [m];
|
|
11224
11237
|
return /* @__PURE__ */ _("div", {
|
|
11225
11238
|
style: E,
|
|
11226
|
-
children: [/* @__PURE__ */ g("style", { children:
|
|
11239
|
+
children: [/* @__PURE__ */ g("style", { children: fg }), /* @__PURE__ */ _("div", {
|
|
11227
11240
|
style: {
|
|
11228
11241
|
flex: 1,
|
|
11229
11242
|
display: "flex",
|
|
@@ -11254,7 +11267,7 @@ function pg({ incomingCall: e, activeCallId: t, callConnectionState: n, callDura
|
|
|
11254
11267
|
width: "96px",
|
|
11255
11268
|
height: "96px",
|
|
11256
11269
|
borderRadius: "50%",
|
|
11257
|
-
background: `radial-gradient(circle, rgba(${
|
|
11270
|
+
background: `radial-gradient(circle, rgba(${pg(e[0])},0.2) 0%, transparent 70%)`,
|
|
11258
11271
|
filter: "blur(10px)",
|
|
11259
11272
|
zIndex: 0
|
|
11260
11273
|
} }),
|
|
@@ -11271,7 +11284,7 @@ function pg({ incomingCall: e, activeCallId: t, callConnectionState: n, callDura
|
|
|
11271
11284
|
animation: `fe-call-ring-pulse 2.6s cubic-bezier(0.215,0.61,0.355,1) ${t}s infinite`,
|
|
11272
11285
|
zIndex: 1
|
|
11273
11286
|
} }, n)),
|
|
11274
|
-
/* @__PURE__ */ g(
|
|
11287
|
+
/* @__PURE__ */ g(gg, {
|
|
11275
11288
|
headshot: o,
|
|
11276
11289
|
name: y,
|
|
11277
11290
|
size: 82,
|
|
@@ -11351,7 +11364,7 @@ function pg({ incomingCall: e, activeCallId: t, callConnectionState: n, callDura
|
|
|
11351
11364
|
e.currentTarget.style.transform = "scale(1)", e.currentTarget.style.boxShadow = "0 6px 24px rgba(239,68,68,0.5)";
|
|
11352
11365
|
},
|
|
11353
11366
|
"aria-label": "Decline call",
|
|
11354
|
-
children: /* @__PURE__ */ g(
|
|
11367
|
+
children: /* @__PURE__ */ g(Th, { size: 26 })
|
|
11355
11368
|
}), /* @__PURE__ */ g("span", {
|
|
11356
11369
|
style: {
|
|
11357
11370
|
fontSize: "12px",
|
|
@@ -11392,7 +11405,7 @@ function pg({ incomingCall: e, activeCallId: t, callConnectionState: n, callDura
|
|
|
11392
11405
|
e.currentTarget.style.transform = "scale(1)", e.currentTarget.style.boxShadow = "0 6px 24px rgba(34,197,94,0.5)";
|
|
11393
11406
|
},
|
|
11394
11407
|
"aria-label": "Accept call",
|
|
11395
|
-
children: /* @__PURE__ */ g(
|
|
11408
|
+
children: /* @__PURE__ */ g(Oh, {})
|
|
11396
11409
|
}), /* @__PURE__ */ g("span", {
|
|
11397
11410
|
style: {
|
|
11398
11411
|
fontSize: "12px",
|
|
@@ -11409,7 +11422,7 @@ function pg({ incomingCall: e, activeCallId: t, callConnectionState: n, callDura
|
|
|
11409
11422
|
}
|
|
11410
11423
|
return b === "connecting" ? /* @__PURE__ */ _("div", {
|
|
11411
11424
|
style: E,
|
|
11412
|
-
children: [/* @__PURE__ */ g("style", { children:
|
|
11425
|
+
children: [/* @__PURE__ */ g("style", { children: fg }), /* @__PURE__ */ _("div", {
|
|
11413
11426
|
style: {
|
|
11414
11427
|
flex: 1,
|
|
11415
11428
|
display: "flex",
|
|
@@ -11419,7 +11432,7 @@ function pg({ incomingCall: e, activeCallId: t, callConnectionState: n, callDura
|
|
|
11419
11432
|
gap: "24px"
|
|
11420
11433
|
},
|
|
11421
11434
|
children: [
|
|
11422
|
-
/* @__PURE__ */ g(
|
|
11435
|
+
/* @__PURE__ */ g(gg, {
|
|
11423
11436
|
headshot: o,
|
|
11424
11437
|
name: y,
|
|
11425
11438
|
size: 64,
|
|
@@ -11446,7 +11459,7 @@ function pg({ incomingCall: e, activeCallId: t, callConnectionState: n, callDura
|
|
|
11446
11459
|
}) : /* @__PURE__ */ _("div", {
|
|
11447
11460
|
style: E,
|
|
11448
11461
|
children: [
|
|
11449
|
-
/* @__PURE__ */ g("style", { children:
|
|
11462
|
+
/* @__PURE__ */ g("style", { children: fg }),
|
|
11450
11463
|
/* @__PURE__ */ _("div", {
|
|
11451
11464
|
style: {
|
|
11452
11465
|
display: "flex",
|
|
@@ -11492,7 +11505,7 @@ function pg({ incomingCall: e, activeCallId: t, callConnectionState: n, callDura
|
|
|
11492
11505
|
children: /* @__PURE__ */ g("polyline", { points: "15 18 9 12 15 6" })
|
|
11493
11506
|
})
|
|
11494
11507
|
}),
|
|
11495
|
-
/* @__PURE__ */ g(
|
|
11508
|
+
/* @__PURE__ */ g(dg, {
|
|
11496
11509
|
colors: h,
|
|
11497
11510
|
size: 36,
|
|
11498
11511
|
voiceState: w
|
|
@@ -11543,7 +11556,7 @@ function pg({ incomingCall: e, activeCallId: t, callConnectionState: n, callDura
|
|
|
11543
11556
|
gap: "16px",
|
|
11544
11557
|
padding: "0 24px 16px"
|
|
11545
11558
|
},
|
|
11546
|
-
children: [/* @__PURE__ */ g(
|
|
11559
|
+
children: [/* @__PURE__ */ g(gg, {
|
|
11547
11560
|
headshot: o,
|
|
11548
11561
|
name: y,
|
|
11549
11562
|
size: 116,
|
|
@@ -11598,7 +11611,7 @@ function pg({ incomingCall: e, activeCallId: t, callConnectionState: n, callDura
|
|
|
11598
11611
|
transition: "all 0.2s ease"
|
|
11599
11612
|
},
|
|
11600
11613
|
"aria-label": i ? "Unmute" : "Mute",
|
|
11601
|
-
children: [g(i ?
|
|
11614
|
+
children: [g(i ? Fh : wh, { size: 18 }), i ? "Unmute" : "Mute"]
|
|
11602
11615
|
}), /* @__PURE__ */ _("button", {
|
|
11603
11616
|
type: "button",
|
|
11604
11617
|
onClick: u,
|
|
@@ -11626,15 +11639,15 @@ function pg({ incomingCall: e, activeCallId: t, callConnectionState: n, callDura
|
|
|
11626
11639
|
e.currentTarget.style.background = "rgba(239,68,68,0.9)", e.currentTarget.style.transform = "scale(1)";
|
|
11627
11640
|
},
|
|
11628
11641
|
"aria-label": "End call",
|
|
11629
|
-
children: [/* @__PURE__ */ g(
|
|
11642
|
+
children: [/* @__PURE__ */ g(Th, { size: 18 }), "End Call"]
|
|
11630
11643
|
})]
|
|
11631
11644
|
})
|
|
11632
11645
|
]
|
|
11633
11646
|
});
|
|
11634
11647
|
}
|
|
11635
|
-
function
|
|
11648
|
+
function yg({ agentName: e, agentHeadshot: t, fallbackAgentName: n, callDurationSeconds: r, isCallMuted: i, formatCallDuration: a, toggleCallMute: o, endWebRTCCall: s, onExpand: c, primaryColor: l = "#3B82F6" }) {
|
|
11636
11649
|
let u = e || n || "Agent";
|
|
11637
|
-
return /* @__PURE__ */ _(h, { children: [/* @__PURE__ */ g("style", { children:
|
|
11650
|
+
return /* @__PURE__ */ _(h, { children: [/* @__PURE__ */ g("style", { children: fg }), /* @__PURE__ */ _("div", {
|
|
11638
11651
|
role: "button",
|
|
11639
11652
|
tabIndex: 0,
|
|
11640
11653
|
onClick: c,
|
|
@@ -11691,7 +11704,7 @@ function mg({ agentName: e, agentHeadshot: t, fallbackAgentName: n, callDuration
|
|
|
11691
11704
|
borderRadius: "50%",
|
|
11692
11705
|
border: `1.5px solid ${l}55`
|
|
11693
11706
|
} }),
|
|
11694
|
-
/* @__PURE__ */ g(
|
|
11707
|
+
/* @__PURE__ */ g(gg, {
|
|
11695
11708
|
headshot: t,
|
|
11696
11709
|
name: u,
|
|
11697
11710
|
size: 38,
|
|
@@ -11775,7 +11788,7 @@ function mg({ agentName: e, agentHeadshot: t, fallbackAgentName: n, callDuration
|
|
|
11775
11788
|
boxShadow: i ? `0 0 0 3px ${l}12` : "none"
|
|
11776
11789
|
},
|
|
11777
11790
|
"aria-label": i ? "Unmute" : "Mute",
|
|
11778
|
-
children: g(i ?
|
|
11791
|
+
children: g(i ? Fh : wh, { size: 15 })
|
|
11779
11792
|
}), /* @__PURE__ */ g("button", {
|
|
11780
11793
|
type: "button",
|
|
11781
11794
|
onClick: (e) => {
|
|
@@ -11803,7 +11816,7 @@ function mg({ agentName: e, agentHeadshot: t, fallbackAgentName: n, callDuration
|
|
|
11803
11816
|
transition: "all 0.18s ease"
|
|
11804
11817
|
},
|
|
11805
11818
|
"aria-label": "End call",
|
|
11806
|
-
children: /* @__PURE__ */ g(
|
|
11819
|
+
children: /* @__PURE__ */ g(Th, { size: 16 })
|
|
11807
11820
|
})]
|
|
11808
11821
|
})
|
|
11809
11822
|
]
|
|
@@ -11811,7 +11824,7 @@ function mg({ agentName: e, agentHeadshot: t, fallbackAgentName: n, callDuration
|
|
|
11811
11824
|
}
|
|
11812
11825
|
//#endregion
|
|
11813
11826
|
//#region src/utils/voicePriorContext.js
|
|
11814
|
-
function
|
|
11827
|
+
function bg(e, t = {}) {
|
|
11815
11828
|
let n = t.maxChars ?? 4500;
|
|
11816
11829
|
if (!Array.isArray(e) || e.length === 0) return "";
|
|
11817
11830
|
let r = [];
|
|
@@ -11829,7 +11842,7 @@ function hg(e, t = {}) {
|
|
|
11829
11842
|
//#endregion
|
|
11830
11843
|
//#region src/utils/voiceActionVisuals.js
|
|
11831
11844
|
var Q = "fe-vv";
|
|
11832
|
-
function
|
|
11845
|
+
function xg() {
|
|
11833
11846
|
if (typeof document > "u" || document.getElementById(`${Q}-styles`)) return;
|
|
11834
11847
|
let e = `
|
|
11835
11848
|
/* ── Action toast ───────────────────────────────────────────────────────────── */
|
|
@@ -11974,14 +11987,14 @@ function gg() {
|
|
|
11974
11987
|
`, t = document.createElement("style");
|
|
11975
11988
|
t.id = `${Q}-styles`, t.textContent = e, (document.head || document.documentElement).appendChild(t);
|
|
11976
11989
|
}
|
|
11977
|
-
var
|
|
11978
|
-
function
|
|
11979
|
-
return (!
|
|
11990
|
+
var Sg = null, Cg = null;
|
|
11991
|
+
function wg() {
|
|
11992
|
+
return (!Sg || !Sg.isConnected) && (Sg = document.createElement("div"), Sg.id = `${Q}-toast`, document.body.appendChild(Sg)), Sg;
|
|
11980
11993
|
}
|
|
11981
|
-
function
|
|
11994
|
+
function Tg(e, { spinner: t = !0, icon: n = null, duration: r = 0 } = {}) {
|
|
11982
11995
|
if (typeof document > "u") return;
|
|
11983
|
-
|
|
11984
|
-
let i =
|
|
11996
|
+
xg(), Cg &&= (clearTimeout(Cg), null);
|
|
11997
|
+
let i = wg();
|
|
11985
11998
|
if (i.innerHTML = "", n) {
|
|
11986
11999
|
let e = document.createElement("span");
|
|
11987
12000
|
e.className = `${Q}-icon`, e.textContent = n, i.appendChild(e);
|
|
@@ -11990,71 +12003,71 @@ function bg(e, { spinner: t = !0, icon: n = null, duration: r = 0 } = {}) {
|
|
|
11990
12003
|
e.className = `${Q}-spin`, i.appendChild(e);
|
|
11991
12004
|
}
|
|
11992
12005
|
let a = document.createElement("span");
|
|
11993
|
-
a.textContent = e, i.appendChild(a), i.classList.remove(`${Q}-show`), i.offsetHeight, i.classList.add(`${Q}-show`), r > 0 && (
|
|
12006
|
+
a.textContent = e, i.appendChild(a), i.classList.remove(`${Q}-show`), i.offsetHeight, i.classList.add(`${Q}-show`), r > 0 && (Cg = setTimeout(() => Eg(), r));
|
|
11994
12007
|
}
|
|
11995
|
-
function
|
|
11996
|
-
|
|
11997
|
-
|
|
11998
|
-
}, e) :
|
|
12008
|
+
function Eg(e = 0) {
|
|
12009
|
+
Sg && (e > 0 ? Cg = setTimeout(() => {
|
|
12010
|
+
Sg && Sg.classList.remove(`${Q}-show`);
|
|
12011
|
+
}, e) : Sg && Sg.classList.remove(`${Q}-show`));
|
|
11999
12012
|
}
|
|
12000
|
-
var
|
|
12001
|
-
function
|
|
12002
|
-
return (!
|
|
12013
|
+
var Dg = null, Og = [];
|
|
12014
|
+
function kg() {
|
|
12015
|
+
return (!Dg || !Dg.isConnected) && (Dg = document.createElement("div"), Dg.id = `${Q}-bar`, document.body.appendChild(Dg)), Dg;
|
|
12003
12016
|
}
|
|
12004
|
-
function
|
|
12017
|
+
function Ag() {
|
|
12005
12018
|
if (typeof document > "u") return;
|
|
12006
|
-
|
|
12007
|
-
let e =
|
|
12019
|
+
xg(), Og.forEach(clearTimeout), Og = [];
|
|
12020
|
+
let e = kg();
|
|
12008
12021
|
e.style.transition = "none", e.style.width = "0%", e.classList.add(`${Q}-bar-active`), e.offsetHeight, e.style.transition = "width 0.35s ease, opacity 0.25s ease";
|
|
12009
12022
|
let t = [[80, "width 0.6s ease"], [92, "width 1.2s ease"]], n = 50;
|
|
12010
12023
|
for (let [e, r] of t) {
|
|
12011
12024
|
let t = n, i = e, a = r;
|
|
12012
|
-
|
|
12013
|
-
|
|
12025
|
+
Og.push(setTimeout(() => {
|
|
12026
|
+
Dg && (Dg.style.transition = a, Dg.style.width = `${i}%`);
|
|
12014
12027
|
}, t)), n += 800;
|
|
12015
12028
|
}
|
|
12016
12029
|
}
|
|
12017
|
-
function
|
|
12018
|
-
|
|
12019
|
-
|
|
12020
|
-
|
|
12030
|
+
function jg() {
|
|
12031
|
+
Dg && (Og.forEach(clearTimeout), Og = [], Dg.style.transition = "width 0.2s ease", Dg.style.width = "100%", Og.push(setTimeout(() => {
|
|
12032
|
+
Dg && (Dg.style.transition = "opacity 0.35s ease", Dg.style.opacity = "0", Og.push(setTimeout(() => {
|
|
12033
|
+
Dg && (Dg.style.width = "0%", Dg.classList.remove(`${Q}-bar-active`));
|
|
12021
12034
|
}, 380)));
|
|
12022
12035
|
}, 220)));
|
|
12023
12036
|
}
|
|
12024
|
-
var
|
|
12037
|
+
var Mg = `<svg xmlns="http://www.w3.org/2000/svg" width="22" height="22" viewBox="0 0 22 22" fill="none">
|
|
12025
12038
|
<filter id="${Q}-csh">
|
|
12026
12039
|
<feDropShadow dx="1" dy="2" stdDeviation="1.5" flood-color="#00000060"/>
|
|
12027
12040
|
</filter>
|
|
12028
12041
|
<path d="M4 2L19 10.5L11 12.8L8 20L4 2Z"
|
|
12029
12042
|
fill="white" stroke="#1e1b4b" stroke-width="1.6" stroke-linejoin="round"
|
|
12030
12043
|
filter="url(#${Q}-csh)"/>
|
|
12031
|
-
</svg>`,
|
|
12032
|
-
function
|
|
12033
|
-
return (!
|
|
12044
|
+
</svg>`, Ng = null, Pg = !1;
|
|
12045
|
+
function Fg() {
|
|
12046
|
+
return (!Ng || !Ng.isConnected) && (Ng = document.createElement("div"), Ng.id = `${Q}-cursor`, Ng.innerHTML = Mg, document.body.appendChild(Ng), Pg = !1), Ng;
|
|
12034
12047
|
}
|
|
12035
|
-
async function
|
|
12048
|
+
async function Ig(e) {
|
|
12036
12049
|
if (typeof document > "u" || !e) return;
|
|
12037
|
-
|
|
12050
|
+
xg();
|
|
12038
12051
|
let t;
|
|
12039
12052
|
try {
|
|
12040
12053
|
t = e.getBoundingClientRect();
|
|
12041
12054
|
} catch {
|
|
12042
12055
|
return;
|
|
12043
12056
|
}
|
|
12044
|
-
let n = t.left + Math.min(16, t.width * .2), r = t.top + Math.min(12, t.height * .25), i =
|
|
12045
|
-
|
|
12057
|
+
let n = t.left + Math.min(16, t.width * .2), r = t.top + Math.min(12, t.height * .25), i = Fg();
|
|
12058
|
+
Pg ||= (i.style.transition = "none", i.style.left = `${window.innerWidth / 2}px`, i.style.top = `${window.innerHeight * .4}px`, i.classList.add(`${Q}-cursor-visible`), i.offsetHeight, i.style.transition = "left 0.32s cubic-bezier(0.25,0.46,0.45,0.94), top 0.32s cubic-bezier(0.25,0.46,0.45,0.94), opacity 0.2s ease", !0), i.style.left = `${n}px`, i.style.top = `${r}px`, await Bg(360);
|
|
12046
12059
|
}
|
|
12047
|
-
function
|
|
12048
|
-
|
|
12049
|
-
|
|
12060
|
+
function Lg(e = !1) {
|
|
12061
|
+
Ng && (e ? (Ng.classList.remove(`${Q}-cursor-visible`), Pg = !1) : (Ng.classList.remove(`${Q}-cursor-visible`), setTimeout(() => {
|
|
12062
|
+
Pg = !1;
|
|
12050
12063
|
}, 250)));
|
|
12051
12064
|
}
|
|
12052
|
-
async function
|
|
12053
|
-
|
|
12065
|
+
async function Rg(e) {
|
|
12066
|
+
Ng && (Ng.classList.add(`${Q}-cursor-click`), await Bg(280), Ng.classList.remove(`${Q}-cursor-click`));
|
|
12054
12067
|
}
|
|
12055
|
-
function
|
|
12068
|
+
function zg(e) {
|
|
12056
12069
|
if (!e || typeof document > "u") return;
|
|
12057
|
-
|
|
12070
|
+
xg();
|
|
12058
12071
|
let t;
|
|
12059
12072
|
try {
|
|
12060
12073
|
t = e.getBoundingClientRect();
|
|
@@ -12080,29 +12093,29 @@ function Pg(e) {
|
|
|
12080
12093
|
a.remove(), e.style.position = n, e.style.overflow = r;
|
|
12081
12094
|
}, 650);
|
|
12082
12095
|
}
|
|
12083
|
-
function
|
|
12096
|
+
function Bg(e) {
|
|
12084
12097
|
return new Promise((t) => setTimeout(t, e));
|
|
12085
12098
|
}
|
|
12086
12099
|
//#endregion
|
|
12087
12100
|
//#region src/utils/voiceClientTools.js
|
|
12088
|
-
var
|
|
12089
|
-
function
|
|
12090
|
-
return String(e || "").replace(
|
|
12101
|
+
var Vg = /^\/[a-z]{2}(?:-[a-z]{2})?(?=\/|$)/i;
|
|
12102
|
+
function Hg(e) {
|
|
12103
|
+
return String(e || "").replace(Vg, "").replace(/\/+$/, "").toLowerCase() || "/";
|
|
12091
12104
|
}
|
|
12092
|
-
function
|
|
12093
|
-
return
|
|
12105
|
+
function Ug(e, t) {
|
|
12106
|
+
return Hg(e) === Hg(t);
|
|
12094
12107
|
}
|
|
12095
12108
|
function $(...e) {
|
|
12096
12109
|
wn() && console.log("[FlowEngage:voice-tools]", ...e);
|
|
12097
12110
|
}
|
|
12098
|
-
function
|
|
12111
|
+
function Wg(e) {
|
|
12099
12112
|
try {
|
|
12100
12113
|
let t = e.ownerDocument?.defaultView;
|
|
12101
12114
|
if (t) return t.getComputedStyle(e);
|
|
12102
12115
|
} catch {}
|
|
12103
12116
|
return window.getComputedStyle(e);
|
|
12104
12117
|
}
|
|
12105
|
-
function
|
|
12118
|
+
function Gg(e) {
|
|
12106
12119
|
let t = /* @__PURE__ */ new Set();
|
|
12107
12120
|
function n(r) {
|
|
12108
12121
|
if (!r || t.has(r)) return;
|
|
@@ -12115,10 +12128,10 @@ function Bg(e) {
|
|
|
12115
12128
|
}
|
|
12116
12129
|
typeof document < "u" && n(document);
|
|
12117
12130
|
}
|
|
12118
|
-
function
|
|
12131
|
+
function Kg(e) {
|
|
12119
12132
|
return e == null ? null : String(e).replace(/\u00a0/g, " ").replace(/\s*\*+\s*$/u, "").replace(/\s+/g, " ").trim();
|
|
12120
12133
|
}
|
|
12121
|
-
function
|
|
12134
|
+
function qg(e) {
|
|
12122
12135
|
let t = e.ownerDocument || document, n = e.getAttribute("aria-labelledby");
|
|
12123
12136
|
if (n) {
|
|
12124
12137
|
let e = n.trim().split(/\s+/).filter(Boolean), r = [];
|
|
@@ -12126,40 +12139,40 @@ function Hg(e) {
|
|
|
12126
12139
|
let e = t.getElementById(n);
|
|
12127
12140
|
e?.textContent && r.push(e.textContent.trim());
|
|
12128
12141
|
} catch {}
|
|
12129
|
-
if (r.length) return
|
|
12142
|
+
if (r.length) return Kg(r.join(" "));
|
|
12130
12143
|
}
|
|
12131
|
-
if (e.labels && e.labels.length) return
|
|
12144
|
+
if (e.labels && e.labels.length) return Kg(e.labels[0].textContent);
|
|
12132
12145
|
let r = e.id;
|
|
12133
12146
|
if (r) try {
|
|
12134
12147
|
let e = t.querySelector(`label[for="${CSS.escape(r)}"]`);
|
|
12135
|
-
if (e) return
|
|
12148
|
+
if (e) return Kg(e.textContent);
|
|
12136
12149
|
} catch {
|
|
12137
12150
|
let e = t.querySelector(`label[for="${r.replace(/"/g, "\\\"")}"]`);
|
|
12138
|
-
if (e) return
|
|
12151
|
+
if (e) return Kg(e.textContent);
|
|
12139
12152
|
}
|
|
12140
12153
|
let i = e.previousElementSibling;
|
|
12141
12154
|
for (let e = 0; e < 6 && i; e += 1) {
|
|
12142
|
-
if (i.tagName === "LABEL") return
|
|
12155
|
+
if (i.tagName === "LABEL") return Kg(i.textContent);
|
|
12143
12156
|
let e = (i.className || "").toString().toLowerCase();
|
|
12144
12157
|
if (/chakra-form__label|formlabel|field-label|form-label|mui-form-label/.test(e)) {
|
|
12145
|
-
let e =
|
|
12158
|
+
let e = Kg(i.textContent);
|
|
12146
12159
|
if (e) return e;
|
|
12147
12160
|
}
|
|
12148
12161
|
i = i.previousElementSibling;
|
|
12149
12162
|
}
|
|
12150
12163
|
let a = e.parentElement;
|
|
12151
12164
|
for (let e = 0; e < 5 && a; e += 1) {
|
|
12152
|
-
if (a.tagName === "LABEL") return
|
|
12165
|
+
if (a.tagName === "LABEL") return Kg(a.textContent);
|
|
12153
12166
|
let e = a.querySelector?.(":scope > label, :scope > [class*='FormLabel'], :scope > [class*='form__label']");
|
|
12154
|
-
if (e?.textContent) return
|
|
12167
|
+
if (e?.textContent) return Kg(e.textContent);
|
|
12155
12168
|
a = a.parentElement;
|
|
12156
12169
|
}
|
|
12157
12170
|
let o = e.getAttribute("aria-label");
|
|
12158
|
-
return o ?
|
|
12171
|
+
return o ? Kg(o) : null;
|
|
12159
12172
|
}
|
|
12160
|
-
function
|
|
12173
|
+
function Jg() {
|
|
12161
12174
|
let e = [];
|
|
12162
|
-
return
|
|
12175
|
+
return Gg((t) => {
|
|
12163
12176
|
e.push(...Array.from(t.querySelectorAll("input, select, textarea")).filter((e) => {
|
|
12164
12177
|
if (An(e)) return !1;
|
|
12165
12178
|
let t = (e.type || "").toLowerCase();
|
|
@@ -12170,15 +12183,15 @@ function Ug() {
|
|
|
12170
12183
|
"image"
|
|
12171
12184
|
].includes(t) || e.disabled || e.readOnly) return !1;
|
|
12172
12185
|
try {
|
|
12173
|
-
let t =
|
|
12186
|
+
let t = Wg(e);
|
|
12174
12187
|
if (t.display === "none" || t.visibility === "hidden") return !1;
|
|
12175
12188
|
} catch {}
|
|
12176
12189
|
return !0;
|
|
12177
12190
|
}));
|
|
12178
12191
|
}), e;
|
|
12179
12192
|
}
|
|
12180
|
-
function
|
|
12181
|
-
return
|
|
12193
|
+
function Yg() {
|
|
12194
|
+
return Jg().map((e, t) => {
|
|
12182
12195
|
let n = {
|
|
12183
12196
|
formIndex: 0,
|
|
12184
12197
|
fieldIndex: t,
|
|
@@ -12186,7 +12199,7 @@ function Wg() {
|
|
|
12186
12199
|
type: e.type || "text",
|
|
12187
12200
|
name: e.name || null,
|
|
12188
12201
|
id: e.id || null,
|
|
12189
|
-
label:
|
|
12202
|
+
label: qg(e),
|
|
12190
12203
|
placeholder: e.placeholder || null
|
|
12191
12204
|
};
|
|
12192
12205
|
return e.tagName === "SELECT" && (n.options = Array.from(e.options).filter((e) => e.value !== "" && !e.disabled).map((e) => ({
|
|
@@ -12195,13 +12208,13 @@ function Wg() {
|
|
|
12195
12208
|
})), n.currentValue = e.value || null), n;
|
|
12196
12209
|
});
|
|
12197
12210
|
}
|
|
12198
|
-
function
|
|
12211
|
+
function Xg() {
|
|
12199
12212
|
let e = [];
|
|
12200
|
-
return
|
|
12213
|
+
return Gg((t) => {
|
|
12201
12214
|
e.push(...Array.from(t.querySelectorAll("button, [role=\"button\"], input[type=\"submit\"], input[type=\"button\"]")).filter((e) => {
|
|
12202
12215
|
if (An(e) || e.disabled) return !1;
|
|
12203
12216
|
try {
|
|
12204
|
-
let t =
|
|
12217
|
+
let t = Wg(e);
|
|
12205
12218
|
if (t.display === "none" || t.visibility === "hidden") return !1;
|
|
12206
12219
|
} catch {}
|
|
12207
12220
|
return !0;
|
|
@@ -12213,7 +12226,7 @@ function Gg() {
|
|
|
12213
12226
|
type: e.type || e.tagName
|
|
12214
12227
|
}));
|
|
12215
12228
|
}
|
|
12216
|
-
function
|
|
12229
|
+
function Zg(e, t) {
|
|
12217
12230
|
try {
|
|
12218
12231
|
if (!e?.getBoundingClientRect || !t?.getBoundingClientRect) return Infinity;
|
|
12219
12232
|
let n = e.getBoundingClientRect(), r = t.getBoundingClientRect(), i = {
|
|
@@ -12228,7 +12241,7 @@ function Kg(e, t) {
|
|
|
12228
12241
|
return Infinity;
|
|
12229
12242
|
}
|
|
12230
12243
|
}
|
|
12231
|
-
function
|
|
12244
|
+
function Qg(e, t) {
|
|
12232
12245
|
let n = String(t || "").toLowerCase().trim();
|
|
12233
12246
|
if (!n) return 0;
|
|
12234
12247
|
let r = (e.innerText || e.textContent || "").replace(/\s+/g, " ").trim(), i = [
|
|
@@ -12246,21 +12259,21 @@ function qg(e, t) {
|
|
|
12246
12259
|
for (let e of a) i.includes(e) && (o += 1);
|
|
12247
12260
|
return o / a.length * 92;
|
|
12248
12261
|
}
|
|
12249
|
-
function
|
|
12262
|
+
function $g(e, t, n = 6) {
|
|
12250
12263
|
let r = String(t || "").toLowerCase().trim();
|
|
12251
12264
|
if (!r) return !1;
|
|
12252
12265
|
let i = e;
|
|
12253
12266
|
for (let e = 0; e < n && i && (i = i.parentElement, i); e++) if ((i.innerText || i.textContent || "").toLowerCase().includes(r)) return !0;
|
|
12254
12267
|
return !1;
|
|
12255
12268
|
}
|
|
12256
|
-
function
|
|
12269
|
+
function e_(e, t, n) {
|
|
12257
12270
|
let r = [];
|
|
12258
|
-
|
|
12271
|
+
Gg((e) => {
|
|
12259
12272
|
let t = Array.from(e.querySelectorAll("button, [role=\"button\"], input[type=\"submit\"], input[type=\"button\"], a[href]"));
|
|
12260
12273
|
r.push(...t.filter((e) => {
|
|
12261
12274
|
if (An(e) || e.disabled) return !1;
|
|
12262
12275
|
try {
|
|
12263
|
-
let t =
|
|
12276
|
+
let t = Wg(e);
|
|
12264
12277
|
if (t.display === "none" || t.visibility === "hidden" || t.opacity === "0") return !1;
|
|
12265
12278
|
} catch {}
|
|
12266
12279
|
return !0;
|
|
@@ -12268,14 +12281,14 @@ function Yg(e, t, n) {
|
|
|
12268
12281
|
});
|
|
12269
12282
|
let i = 0, a = r.map((t) => ({
|
|
12270
12283
|
el: t,
|
|
12271
|
-
s:
|
|
12284
|
+
s: Qg(t, e)
|
|
12272
12285
|
}));
|
|
12273
12286
|
for (let { s: e } of a) e > i && (i = e);
|
|
12274
12287
|
if (i < 28) return null;
|
|
12275
12288
|
let o = a.filter(({ s: e }) => e === i).map(({ el: e }) => e);
|
|
12276
12289
|
if (o.length === 1) return o[0];
|
|
12277
12290
|
if (n) {
|
|
12278
|
-
let e = o.filter((e) =>
|
|
12291
|
+
let e = o.filter((e) => $g(e, n));
|
|
12279
12292
|
if (e.length === 1) return e[0];
|
|
12280
12293
|
e.length > 1 && (o = e);
|
|
12281
12294
|
}
|
|
@@ -12283,14 +12296,14 @@ function Yg(e, t, n) {
|
|
|
12283
12296
|
if (s.length) {
|
|
12284
12297
|
let e = o[0], t = Infinity;
|
|
12285
12298
|
for (let n of o) for (let r of s) {
|
|
12286
|
-
let i =
|
|
12299
|
+
let i = Zg(n, r);
|
|
12287
12300
|
i < t && (t = i, e = n);
|
|
12288
12301
|
}
|
|
12289
12302
|
return e;
|
|
12290
12303
|
}
|
|
12291
12304
|
return o[0];
|
|
12292
12305
|
}
|
|
12293
|
-
function
|
|
12306
|
+
function t_(e) {
|
|
12294
12307
|
if (e == null) return {};
|
|
12295
12308
|
if (typeof e == "string") {
|
|
12296
12309
|
let t = e.trim();
|
|
@@ -12303,12 +12316,12 @@ function Xg(e) {
|
|
|
12303
12316
|
}
|
|
12304
12317
|
return e;
|
|
12305
12318
|
}
|
|
12306
|
-
function
|
|
12319
|
+
function n_(e) {
|
|
12307
12320
|
if (!e || typeof e != "object") return null;
|
|
12308
12321
|
let t = e.url ?? e.target_url ?? e.page_url ?? e.pageUrl ?? e.link ?? e.href ?? e.path;
|
|
12309
12322
|
return t == null ? null : String(t).trim() || null;
|
|
12310
12323
|
}
|
|
12311
|
-
function
|
|
12324
|
+
function r_() {
|
|
12312
12325
|
let e = {};
|
|
12313
12326
|
document.querySelectorAll("h1, h2, h3, h4, h5, h6").forEach((t) => {
|
|
12314
12327
|
if (t.id) return;
|
|
@@ -12323,7 +12336,7 @@ function Qg() {
|
|
|
12323
12336
|
e[r] = !0, t.id = r;
|
|
12324
12337
|
});
|
|
12325
12338
|
}
|
|
12326
|
-
function
|
|
12339
|
+
function i_() {
|
|
12327
12340
|
let e = (e) => {
|
|
12328
12341
|
let t = Array.from(e).filter((e) => !e.closest("#flowengage-root, .flowengage-shell, .flowengage-widget-root") && !e.closest("nav, footer, header, aside, .nav, .footer, .header, .sidebar")), n = [], r = 0;
|
|
12329
12342
|
for (; r < t.length;) {
|
|
@@ -12378,7 +12391,7 @@ function $g() {
|
|
|
12378
12391
|
containerHeadings: o
|
|
12379
12392
|
};
|
|
12380
12393
|
}
|
|
12381
|
-
function
|
|
12394
|
+
function a_(e) {
|
|
12382
12395
|
if (!e || typeof document > "u") return "";
|
|
12383
12396
|
let t = new Set([
|
|
12384
12397
|
"script",
|
|
@@ -12464,11 +12477,11 @@ function e_(e) {
|
|
|
12464
12477
|
return d.has(t) ? !1 : (d.add(t), !0);
|
|
12465
12478
|
}).join("\n").replace(/\n{3,}/g, "\n\n").trim();
|
|
12466
12479
|
}
|
|
12467
|
-
function
|
|
12480
|
+
function o_(e) {
|
|
12468
12481
|
let t = e.siteId || null, n = (e.apiBaseUrl || "").replace(/\/$/, ""), r = typeof e.getLastUserVoiceText == "function" ? e.getLastUserVoiceText : null, i = [], a = {
|
|
12469
12482
|
"fwh-navigate-mvp": async (n) => {
|
|
12470
12483
|
if ($("fwh-navigate-mvp ▶ raw parameters:", n), e?.isWalkthroughActive?.()) return $("fwh-navigate-mvp ✖ blocked — walkthrough in progress"), "NAVIGATION_BLOCKED_DURING_WALKTHROUGH. A walkthrough of the current page is in progress, so navigation is not allowed. Do NOT tell the visitor you navigated or offer to. Describe the requested section using the CURRENT page's own content (fwh-read-content-mvp), then stop.";
|
|
12471
|
-
let i =
|
|
12484
|
+
let i = t_(n), a = n_(i), o = i.section_text ?? i.sectionText ?? i.section, s = Array.isArray(i.expected_landmarks) ? i.expected_landmarks : Array.isArray(i.expectedLandmarks) ? i.expectedLandmarks : [];
|
|
12472
12485
|
if ($("fwh-navigate-mvp · coerced:", {
|
|
12473
12486
|
url: a,
|
|
12474
12487
|
sectionText: o,
|
|
@@ -12508,18 +12521,18 @@ function t_(e) {
|
|
|
12508
12521
|
correctedUrl: l
|
|
12509
12522
|
}), a = l);
|
|
12510
12523
|
try {
|
|
12511
|
-
|
|
12524
|
+
Tg(`Navigating to ${a}...`, { spinner: !0 }), Ag(), On();
|
|
12512
12525
|
try {
|
|
12513
12526
|
let e = r ? r() : "";
|
|
12514
12527
|
if (e && t) {
|
|
12515
|
-
let n =
|
|
12528
|
+
let n = bg([{
|
|
12516
12529
|
sender: "user",
|
|
12517
12530
|
message: e
|
|
12518
12531
|
}]);
|
|
12519
|
-
n &&
|
|
12532
|
+
n && z(t, n);
|
|
12520
12533
|
}
|
|
12521
12534
|
} catch {}
|
|
12522
|
-
|
|
12535
|
+
Se();
|
|
12523
12536
|
let e = a;
|
|
12524
12537
|
try {
|
|
12525
12538
|
e = new URL(a, typeof window < "u" ? window.location.href : "").href;
|
|
@@ -12529,7 +12542,7 @@ function t_(e) {
|
|
|
12529
12542
|
let e = new URL(a, window.location.href).pathname.split("/").filter(Boolean).pop() || "";
|
|
12530
12543
|
n = e ? e.replace(/[-_]/g, " ").replace(/\b\w/g, (e) => e.toUpperCase()) : "Home";
|
|
12531
12544
|
} catch {}
|
|
12532
|
-
t && typeof window < "u" &&
|
|
12545
|
+
t && typeof window < "u" && ke(t, window.location.href, e, n), gr(e);
|
|
12533
12546
|
try {
|
|
12534
12547
|
window.__fe_agent_nav = {
|
|
12535
12548
|
path: new URL(e, window.location.href).pathname,
|
|
@@ -12547,8 +12560,8 @@ function t_(e) {
|
|
|
12547
12560
|
typeof window < "u" && window.scrollTo(0, 0);
|
|
12548
12561
|
} catch {}
|
|
12549
12562
|
let o = [], s = null, c = "", l = Date.now() + 12e3;
|
|
12550
|
-
for (; Date.now() < l && (await new Promise((e) => setTimeout(e, 300)), {headings: o, pageTitleHeading: s, introText: c} =
|
|
12551
|
-
|
|
12563
|
+
for (; Date.now() < l && (await new Promise((e) => setTimeout(e, 300)), {headings: o, pageTitleHeading: s, introText: c} = i_(), !(o.length >= 1)););
|
|
12564
|
+
r_(), $("fwh-navigate-mvp → page headings collected:", o, "titleHeading:", s);
|
|
12552
12565
|
let u = o.length ? o.join(" | ") : "none", d = o.length ? "Use ONLY these exact heading strings for fwh-highlight-mvp — never invent or abbreviate." : "No headings collected yet — call fwh-get-current-page-mvp immediately (no speech) to get the live headings before speaking or highlighting.", f = s ? ` "${s}" is the PAGE TITLE, not a content section — do not fwh-highlight-mvp it separately; if doing a walkthrough, just fold this intro into your opening line: "${c || "(no intro text found)"}"` : c ? ` No separate page-title heading detected, but this intro text precedes the first section — mention it briefly before covering sections: "${c}"` : "", p = "";
|
|
12553
12566
|
try {
|
|
12554
12567
|
if (o.length > 0) {
|
|
@@ -12556,7 +12569,7 @@ function t_(e) {
|
|
|
12556
12569
|
for (let n of e) {
|
|
12557
12570
|
let e = cr(null, n);
|
|
12558
12571
|
if (e) {
|
|
12559
|
-
let r =
|
|
12572
|
+
let r = a_(e).substring(0, 800);
|
|
12560
12573
|
r && t.push(`[Section: ${n}] ${r}`);
|
|
12561
12574
|
}
|
|
12562
12575
|
}
|
|
@@ -12565,57 +12578,57 @@ function t_(e) {
|
|
|
12565
12578
|
} catch {}
|
|
12566
12579
|
if (yr()) return _r(), $("fwh-navigate-mvp ✖ landed on a not-found/404 page:", i), `NAVIGATION_PAGE_NOT_FOUND. The page at ${i} does not exist — it shows a "not found"/404 error, not real content. Do NOT offer a page overview, do NOT describe or highlight any sections, do NOT claim the navigation succeeded. Tell the visitor EXACTLY: "It looks like that page doesn't exist — I couldn't find it. Would you like me to take you somewhere else?" Then STOP and wait for their reply.`;
|
|
12567
12580
|
let m = Date.now() + 4e3, h = typeof window < "u" ? window.location.pathname : r;
|
|
12568
|
-
for (; Date.now() < m && !
|
|
12581
|
+
for (; Date.now() < m && !Ug(h, e) && Ug(h, t);) await new Promise((e) => setTimeout(e, 120)), h = window.location.pathname;
|
|
12569
12582
|
$("fwh-navigate-mvp route settle:", {
|
|
12570
12583
|
startPath: t,
|
|
12571
12584
|
targetPath: e,
|
|
12572
12585
|
settledPath: h
|
|
12573
12586
|
});
|
|
12574
|
-
let g = typeof window < "u" ? window.location.href : i, _ = (h.split("/").filter(Boolean).pop() || "").replace(/[-_]/g, " ").replace(/\b\w/g, (e) => e.toUpperCase()) || "Home", v =
|
|
12587
|
+
let g = typeof window < "u" ? window.location.href : i, _ = (h.split("/").filter(Boolean).pop() || "").replace(/[-_]/g, " ").replace(/\b\w/g, (e) => e.toUpperCase()) || "Home", v = Ug(h, e), y = !Ug(h, t), b = v || y;
|
|
12575
12588
|
return $("fwh-navigate-mvp settled:", h, "target:", e, "match:", b), b ? (_r(), `OK_NAVIGATE_SPA. Visitor is now on: ${g} (page: "${_}") | Section headings: ${u}.${f} ${d}${p} Now confirm the arrival in ONE short sentence phrased for what the visitor actually asked for — mention the page by name and what it lets them do (e.g. for a contact request: "I've taken you to the Contact Us page — filling in this form sends your query straight to our team."). Do NOT use a fixed template. Then, in the same breath, offer either a specific section or a full overview. Then STOP — wait for their reply.`) : (_r(), `NAVIGATION_DID_NOT_HAPPEN. The visitor is STILL on ${g} (page: "${_}") — the navigation did not go through. Do NOT say "I have navigated you". Do NOT claim success. Tell the visitor EXACTLY: "Sorry, I couldn't open that page just now. Would you like me to try again, or is there something else I can help with?" Then STOP and wait for their reply.`);
|
|
12576
12589
|
} catch {}
|
|
12577
12590
|
return "OK_NAVIGATE_RELOADING. The page is reloading now and this session is ending. Say NOTHING further — do not confirm the navigation, do not describe the page. The arrival greeting is spoken automatically on the new page; you resume from the visitor's next reply.";
|
|
12578
12591
|
} catch (e) {
|
|
12579
12592
|
let t = `Navigation error: ${e?.message || String(e)}`;
|
|
12580
|
-
return $("fwh-navigate-mvp ✖", t),
|
|
12593
|
+
return $("fwh-navigate-mvp ✖", t), Tg("Navigation failed", {
|
|
12581
12594
|
spinner: !1,
|
|
12582
12595
|
icon: "⚠️",
|
|
12583
12596
|
duration: 1800
|
|
12584
12597
|
}), t;
|
|
12585
12598
|
} finally {
|
|
12586
|
-
|
|
12599
|
+
jg(), Eg(900);
|
|
12587
12600
|
}
|
|
12588
12601
|
},
|
|
12589
12602
|
"fwh-highlight-mvp": async (e) => {
|
|
12590
12603
|
$("fwh-highlight-mvp ▶", e);
|
|
12591
|
-
let t =
|
|
12604
|
+
let t = t_(e), n = t?.section_id || t?.sectionId, r = t?.section_text || t?.sectionText;
|
|
12592
12605
|
if (Rn(3e3), typeof window < "u" && window.__fe_user_nav_during_speech) {
|
|
12593
12606
|
let e = window.__fe_user_nav_during_speech, t = window.location.pathname;
|
|
12594
12607
|
if (Date.now() - e.ts >= 3e4) window.__fe_user_nav_during_speech = null;
|
|
12595
12608
|
else return $("flowengage_highlight ✖ blocked — user navigated during speech", e), `NAV_CHANGED: The visitor navigated from "${e.fromPageName}" to "${e.toPageName}" (current path: ${t}) while you were speaking. STOP the current walkthrough immediately. DO NOT call fwh-highlight-mvp again. Say out loud: "I see you've navigated to the ${e.toPageName} page — do you want me to continue what I was explaining, or shall I guide you through this page?" Wait for the visitor's answer before doing anything else.`;
|
|
12596
12609
|
}
|
|
12597
|
-
|
|
12610
|
+
r_();
|
|
12598
12611
|
let i = ((e) => e && e.replace(/^\d+\.\s*/, "").replace(/^["']|["']$/g, "").trim())(r), a = cr(n || null, i || null);
|
|
12599
12612
|
if (!a && i) {
|
|
12600
12613
|
let e = Date.now() + 600;
|
|
12601
|
-
for (; !a && Date.now() < e;) await new Promise((e) => setTimeout(e, 50)),
|
|
12614
|
+
for (; !a && Date.now() < e;) await new Promise((e) => setTimeout(e, 50)), r_(), a = cr(null, i);
|
|
12602
12615
|
}
|
|
12603
12616
|
if (!a) {
|
|
12604
12617
|
$("fwh-highlight-mvp ✖ no element for:", i || n);
|
|
12605
|
-
let { headings: e } =
|
|
12618
|
+
let { headings: e } = i_(), t = e.length ? `Page headings: ${e.map((e) => `"${e}"`).join(" | ")}. Use one of these EXACT strings for section_text — no numbers, no quotes around them.` : "No headings found — skip highlight and continue speaking.";
|
|
12606
12619
|
return `HIGHLIGHT_NOT_FOUND: "${i || n}" on the current page. ${t}`;
|
|
12607
12620
|
}
|
|
12608
12621
|
return Dn(a), $("fwh-highlight-mvp ✓", i || n), `OK_HIGHLIGHT: "${i || n}". Your NEXT response must be speech only (no tool call) describing THIS section — "${i || n}" — using its own content. Do not ask whether to continue.`;
|
|
12609
12622
|
},
|
|
12610
12623
|
"fwh-read-content-mvp": async (e) => {
|
|
12611
12624
|
$("fwh-read-content-mvp ▶", e);
|
|
12612
|
-
let t =
|
|
12625
|
+
let t = t_(e), n = t?.section_text || t?.sectionText || "";
|
|
12613
12626
|
try {
|
|
12614
12627
|
let e = "";
|
|
12615
12628
|
if (n) {
|
|
12616
12629
|
let t = cr(null, n);
|
|
12617
12630
|
if (!t) return `Could not find section "${n}" on the page.`;
|
|
12618
|
-
e =
|
|
12631
|
+
e = a_(t);
|
|
12619
12632
|
} else {
|
|
12620
12633
|
let t = (document.querySelector("main") || document.querySelector("article") || document.querySelector("[role=\"main\"]") || document.querySelector("#content") || document.querySelector(".content") || document.body).cloneNode(!0);
|
|
12621
12634
|
t.querySelectorAll("nav, footer, header, aside, script, style, noscript, .nav, .footer, .header, .sidebar, #flowengage-root, .flowengage-shell, .flowengage-widget-root").forEach((e) => e.remove()), e = t.textContent.replace(/\s+/g, " ").trim();
|
|
@@ -12627,7 +12640,7 @@ function t_(e) {
|
|
|
12627
12640
|
},
|
|
12628
12641
|
"fwh-page-content-mvp": async (e) => {
|
|
12629
12642
|
$("fwh-page-content-mvp ▶", e);
|
|
12630
|
-
let r =
|
|
12643
|
+
let r = t_(e), i = r?.url || r?.page_url || "";
|
|
12631
12644
|
if ($("fwh-page-content-mvp · url:", i, "siteId:", t, "apiBase:", n || "(empty)"), !i) return $("fwh-page-content-mvp ✖ missing url"), "Missing url parameter.";
|
|
12632
12645
|
if (!t) return $("fwh-page-content-mvp ✖ no siteId"), "Site is not configured.";
|
|
12633
12646
|
if (!n) return $("fwh-page-content-mvp ✖ no api base"), "API base URL is missing; cannot fetch page content.";
|
|
@@ -12659,7 +12672,7 @@ function t_(e) {
|
|
|
12659
12672
|
},
|
|
12660
12673
|
"fwh-search-mvp": async (e) => {
|
|
12661
12674
|
$("fwh-search-mvp ▶", e);
|
|
12662
|
-
let r =
|
|
12675
|
+
let r = t_(e).query;
|
|
12663
12676
|
if (!r) return $("fwh-search-mvp ✖ missing query"), "Missing query parameter.";
|
|
12664
12677
|
if (!t) return $("fwh-search-mvp ✖ no siteId"), "Search unavailable (no siteId configured).";
|
|
12665
12678
|
if (!n) return $("fwh-search-mvp ✖ no api base"), "Search unavailable (no API base URL).";
|
|
@@ -12697,7 +12710,7 @@ function t_(e) {
|
|
|
12697
12710
|
"[class*='menu'] a",
|
|
12698
12711
|
"[class*='header'] a"
|
|
12699
12712
|
];
|
|
12700
|
-
if (
|
|
12713
|
+
if (Gg((t) => {
|
|
12701
12714
|
for (let r of n) try {
|
|
12702
12715
|
t.querySelectorAll(r).forEach((t) => {
|
|
12703
12716
|
if (An(t)) return;
|
|
@@ -12705,7 +12718,7 @@ function t_(e) {
|
|
|
12705
12718
|
if (!r || !n || n === "#" || n.startsWith("javascript:")) return;
|
|
12706
12719
|
try {
|
|
12707
12720
|
let e = t.parentElement;
|
|
12708
|
-
if (e &&
|
|
12721
|
+
if (e && Wg(e).display === "none" && !e.closest("nav, [role='navigation'], header, [class*='nav'], [class*='menu']")) return;
|
|
12709
12722
|
} catch {}
|
|
12710
12723
|
let i = r.toLowerCase() + "|" + n;
|
|
12711
12724
|
e.has(i) || e.set(i, {
|
|
@@ -12716,7 +12729,7 @@ function t_(e) {
|
|
|
12716
12729
|
} catch {}
|
|
12717
12730
|
t.querySelectorAll("select").forEach((t) => {
|
|
12718
12731
|
if (An(t)) return;
|
|
12719
|
-
let n =
|
|
12732
|
+
let n = qg(t);
|
|
12720
12733
|
/nav|menu|page|section|go to/i.test(n || t.name || t.id || "") && Array.from(t.options).forEach((r) => {
|
|
12721
12734
|
if (!r.value || r.disabled) return;
|
|
12722
12735
|
let i = r.text.trim();
|
|
@@ -12740,7 +12753,7 @@ function t_(e) {
|
|
|
12740
12753
|
if ($("fwh-get-current-page-mvp ▶"), typeof window > "u") return "Cannot determine current page (no browser context).";
|
|
12741
12754
|
let e = window.location.href, t = window.location.pathname, n = document.title || "";
|
|
12742
12755
|
if (yr()) return $("fwh-get-current-page-mvp ✓ 404 detected", { url: e }), `CURRENT_PAGE_NOT_FOUND. The visitor is currently on a 404 / page-not-found error page (${e}). There is no real content here. Do NOT describe this page, do NOT list sections, do NOT offer a walkthrough, and do NOT describe it from your own knowledge. Tell the visitor plainly that the page they are on doesn't exist, and offer to take them somewhere that does.`;
|
|
12743
|
-
let { headings: r, pageTitleHeading: i, introText: a } =
|
|
12756
|
+
let { headings: r, pageTitleHeading: i, introText: a } = i_();
|
|
12744
12757
|
$("fwh-get-current-page-mvp ✓", {
|
|
12745
12758
|
url: e,
|
|
12746
12759
|
path: t,
|
|
@@ -12752,7 +12765,7 @@ function t_(e) {
|
|
|
12752
12765
|
return `CURRENT_PAGE. URL: ${e} | Title: ${n} | Page sections (${r.length} total): ${s}.${o} *** WALKTHROUGH: do NOT drive it yourself. Do not call fwh-highlight-mvp and do not decide the order — highlighting and section order are handled for you. You will be told which section to describe, one at a time. When told, describe ONLY that section in 3-4 sentences and then stop; never announce another section, never ask whether to continue. ***`;
|
|
12753
12766
|
},
|
|
12754
12767
|
"fwh-list-forms-mvp": async () => {
|
|
12755
|
-
let e =
|
|
12768
|
+
let e = Yg(), t = Xg();
|
|
12756
12769
|
$("fwh-list-forms-mvp ✓", `${e.length} field(s)`, `${t.length} button(s)`);
|
|
12757
12770
|
let n = e.map((e) => ({
|
|
12758
12771
|
...e,
|
|
@@ -12766,12 +12779,12 @@ function t_(e) {
|
|
|
12766
12779
|
},
|
|
12767
12780
|
"fwh-fill-form-mvp": async () => "FORM_FILLING_DISABLED: Form filling is not available at this time. Tell the visitor what fields are present (use fwh-list-forms-mvp) and ask them to fill the form themselves.",
|
|
12768
12781
|
"fwh-click-button-mvp": async (e) => {
|
|
12769
|
-
let t =
|
|
12782
|
+
let t = t_(e), n = (t.button_text ?? t.buttonText ?? t.text ?? "").trim(), r = (t.card_context ?? t.cardContext ?? "").trim();
|
|
12770
12783
|
if ($("fwh-click-button-mvp ▶", n, r ? `(card_context: ${r})` : ""), !n) return "Missing button_text: pass the visible label, e.g. Conduct Audit.";
|
|
12771
|
-
let a =
|
|
12784
|
+
let a = e_(n, i, r);
|
|
12772
12785
|
if (!a) return $("fwh-click-button-mvp ✖ no match"), `Could not find a button matching "${n}". Call fwh-list-forms-mvp to see button texts.`;
|
|
12773
12786
|
try {
|
|
12774
|
-
|
|
12787
|
+
Tg(`Clicking ${n}...`, { spinner: !0 });
|
|
12775
12788
|
try {
|
|
12776
12789
|
a.scrollIntoView({
|
|
12777
12790
|
block: "center",
|
|
@@ -12780,22 +12793,22 @@ function t_(e) {
|
|
|
12780
12793
|
} catch {
|
|
12781
12794
|
a.scrollIntoView(!0);
|
|
12782
12795
|
}
|
|
12783
|
-
await
|
|
12796
|
+
await Ig(a), a.focus?.(), await Rg(a), zg(a), a.click();
|
|
12784
12797
|
let e = (a.textContent || a.value || a.getAttribute("aria-label") || "").trim().slice(0, 80) || "button", t = `OK_CLICK ${e}`;
|
|
12785
|
-
return $("fwh-click-button-mvp ✓", t),
|
|
12798
|
+
return $("fwh-click-button-mvp ✓", t), Tg(`Clicked ${e}`, {
|
|
12786
12799
|
spinner: !1,
|
|
12787
12800
|
icon: "✅",
|
|
12788
12801
|
duration: 1200
|
|
12789
12802
|
}), t;
|
|
12790
12803
|
} catch (e) {
|
|
12791
12804
|
let t = `Click failed: ${e?.message || String(e)}`;
|
|
12792
|
-
return $("fwh-click-button-mvp ✖", t),
|
|
12805
|
+
return $("fwh-click-button-mvp ✖", t), Tg("Click failed", {
|
|
12793
12806
|
spinner: !1,
|
|
12794
12807
|
icon: "⚠️",
|
|
12795
12808
|
duration: 1800
|
|
12796
12809
|
}), t;
|
|
12797
12810
|
} finally {
|
|
12798
|
-
|
|
12811
|
+
Lg(), Eg(700);
|
|
12799
12812
|
}
|
|
12800
12813
|
},
|
|
12801
12814
|
"fwh-cart-get-mvp": async () => {
|
|
@@ -12894,7 +12907,7 @@ function t_(e) {
|
|
|
12894
12907
|
try {
|
|
12895
12908
|
r = new URL(e, window.location.href).href;
|
|
12896
12909
|
} catch {}
|
|
12897
|
-
return t &&
|
|
12910
|
+
return t && ke(t, window.location.href, r, n), gr(r), Cr().then(() => {
|
|
12898
12911
|
window.location.assign(r);
|
|
12899
12912
|
}), `OK_NAVIGATING to ${n}. The page is loading — say one short phrase like "Here you go." and nothing more.`;
|
|
12900
12913
|
}
|
|
@@ -12908,10 +12921,10 @@ function t_(e) {
|
|
|
12908
12921
|
clickPageButton: a["fwh-click-button-mvp"]
|
|
12909
12922
|
};
|
|
12910
12923
|
}
|
|
12911
|
-
var
|
|
12912
|
-
function
|
|
12924
|
+
var s_ = /^(get in touch|contact us|let'?s (talk|connect)|subscribe|newsletter|follow us|quick links|company|solutions|what we do|resources|legal|sitemap|share this)/i;
|
|
12925
|
+
function c_() {
|
|
12913
12926
|
try {
|
|
12914
|
-
let { headings: e, pageTitleHeading: t, containerHeadings: n } =
|
|
12927
|
+
let { headings: e, pageTitleHeading: t, containerHeadings: n } = i_(), r = new Set((n || []).map((e) => e.trim())), i = (e || []).map((e) => typeof e == "string" ? e : e?.text || "").filter(Boolean).filter((e) => !t || e.trim() !== t.trim()).filter((e) => !s_.test(e.trim())), a = i.filter((e) => !r.has(e.trim()));
|
|
12915
12928
|
return a.length ? a : i;
|
|
12916
12929
|
} catch {
|
|
12917
12930
|
return [];
|
|
@@ -12919,7 +12932,7 @@ function r_() {
|
|
|
12919
12932
|
}
|
|
12920
12933
|
//#endregion
|
|
12921
12934
|
//#region src/utils/wrapVoiceToolsForLogging.js
|
|
12922
|
-
function
|
|
12935
|
+
function l_(e) {
|
|
12923
12936
|
return !e || typeof e != "object" ? e : Object.fromEntries(Object.entries(e).map(([e, t]) => [e, async (n) => {
|
|
12924
12937
|
let r = wn();
|
|
12925
12938
|
r ? console.log("[FlowEngage:voice-tool] ▶", e, n) : console.info(`[FlowEngage] voice tool » ${e}`);
|
|
@@ -12936,11 +12949,11 @@ function i_(e) {
|
|
|
12936
12949
|
}
|
|
12937
12950
|
//#endregion
|
|
12938
12951
|
//#region src/components/FlowEngageWidget.jsx
|
|
12939
|
-
var
|
|
12940
|
-
function
|
|
12941
|
-
return `${
|
|
12952
|
+
var u_ = "[PAGE_CONTEXT]";
|
|
12953
|
+
function d_(e, t, n) {
|
|
12954
|
+
return `${u_} SESSION_CONTEXT (NOT a tool result — do NOT treat as CURRENT_PAGE): Visitor is on: ${e} | Approx headings for awareness only: ${t || ""}. ${n ? `Forms: ${n}. ` : ""}The visitor is ALREADY on this page — do NOT offer to navigate there.`;
|
|
12942
12955
|
}
|
|
12943
|
-
var
|
|
12956
|
+
var f_ = {
|
|
12944
12957
|
blue: "#135bd8",
|
|
12945
12958
|
red: "#ef334b",
|
|
12946
12959
|
yellow: "#ffbd2e",
|
|
@@ -12948,7 +12961,7 @@ var s_ = {
|
|
|
12948
12961
|
highlight: "rgba(255,255,255,0.9)",
|
|
12949
12962
|
green: "#10b981"
|
|
12950
12963
|
};
|
|
12951
|
-
function
|
|
12964
|
+
function p_(e) {
|
|
12952
12965
|
if (!Array.isArray(e) || e.length < 2) return "linear-gradient(145deg, #dce8f022 0%, #e8dff522 45%, #f5e0e022 100%), #f7f8fa";
|
|
12953
12966
|
let [t, n, r] = e;
|
|
12954
12967
|
return e.length >= 3 && r ? [
|
|
@@ -12962,12 +12975,12 @@ function c_(e) {
|
|
|
12962
12975
|
"#f7f8fa"
|
|
12963
12976
|
].join(", ");
|
|
12964
12977
|
}
|
|
12965
|
-
function
|
|
12978
|
+
function m_(e) {
|
|
12966
12979
|
if (!e || typeof e != "string") return "#1a1a1a";
|
|
12967
12980
|
let t = e.replace("#", ""), n = t.length === 3 ? t.split("").map((e) => e + e).join("") : t, r = parseInt(n.slice(0, 2), 16) / 255, i = parseInt(n.slice(2, 4), 16) / 255, a = parseInt(n.slice(4, 6), 16) / 255, o = (e) => e <= .04045 ? e / 12.92 : ((e + .055) / 1.055) ** 2.4;
|
|
12968
12981
|
return .2126 * o(r) + .7152 * o(i) + .0722 * o(a) > .179 ? "#1a1a1a" : "#ffffff";
|
|
12969
12982
|
}
|
|
12970
|
-
function
|
|
12983
|
+
function h_(t) {
|
|
12971
12984
|
let [n, r] = e.useState(null), i = typeof t == "string" ? t.trim() : "";
|
|
12972
12985
|
return e.useEffect(() => {
|
|
12973
12986
|
if (!i) {
|
|
@@ -12985,8 +12998,8 @@ function u_(t) {
|
|
|
12985
12998
|
};
|
|
12986
12999
|
}, [i]), n;
|
|
12987
13000
|
}
|
|
12988
|
-
function
|
|
12989
|
-
let r =
|
|
13001
|
+
function g_({ logo: t, style: n }) {
|
|
13002
|
+
let r = h_(typeof t == "string" ? t : null);
|
|
12990
13003
|
if (!t) return null;
|
|
12991
13004
|
if (typeof t == "string") return r ? /* @__PURE__ */ g("img", {
|
|
12992
13005
|
src: r,
|
|
@@ -13011,7 +13024,7 @@ function d_({ logo: t, style: n }) {
|
|
|
13011
13024
|
children: i
|
|
13012
13025
|
}) : null;
|
|
13013
13026
|
}
|
|
13014
|
-
function
|
|
13027
|
+
function __({ title: e }) {
|
|
13015
13028
|
return /* @__PURE__ */ g("div", {
|
|
13016
13029
|
style: {
|
|
13017
13030
|
width: "100%",
|
|
@@ -13029,18 +13042,18 @@ function f_({ title: e }) {
|
|
|
13029
13042
|
children: String(e || "FE").split(/\s+/).filter(Boolean).slice(0, 2).map((e) => e[0]?.toUpperCase() || "").join("") || "FE"
|
|
13030
13043
|
});
|
|
13031
13044
|
}
|
|
13032
|
-
function
|
|
13045
|
+
function v_(e, t) {
|
|
13033
13046
|
let n = (t || "").trim();
|
|
13034
13047
|
return n ? !!(/\b(let'?s|let us)\s+(end|stop|finish|wrap up|close)\s+(the\s+)?(voice\s+)?(session|call|chat)\b/i.test(n) || /\bend\s+(this\s+)?(the\s+)?(voice\s+)?(session|call|chat)\b/i.test(n) || /\b(hang\s+up|disconnect)\b/i.test(n) || e === "bot" && (/\b(that'?s all|we'?re done)\b/i.test(n) || /\b(goodbye|bye)\b/i.test(n) || /\b(I'?ll|I will|Let me|I can|I'?m going to)\s+(end|close)\s+(the\s+)?(voice\s+)?(session|call)\b/i.test(n) || /\b(ending|closing)\s+(the\s+)?(voice\s+)?session\b|\bvoice\s+session\s+(is\s+)?(now\s+)?(ended|over|closing)\b/i.test(n) || /\b(session|call)\s+(is\s+)?(now\s+)?(ended|over)\b/i.test(n) || /\bwe\s+can\s+end\s+(the\s+)?(session|call)?\s*(here|now)\b/i.test(n) || /\b(wrapping\s+up|signing\s+off)\b/i.test(n))) : !1;
|
|
13035
13048
|
}
|
|
13036
|
-
function
|
|
13037
|
-
return /* @__PURE__ */ g(
|
|
13049
|
+
function y_({ orbColors: e, ...t }) {
|
|
13050
|
+
return /* @__PURE__ */ g(dg, {
|
|
13038
13051
|
colors: e,
|
|
13039
13052
|
...t
|
|
13040
13053
|
});
|
|
13041
13054
|
}
|
|
13042
|
-
function
|
|
13043
|
-
let s = n ||
|
|
13055
|
+
function b_({ copy: e, orbColors: t, primaryColor: n, onYes: r, onLater: i, isMobile: a, isClosing: o }) {
|
|
13056
|
+
let s = n || f_.green, c = m_(s), l = a ? 72 : 94, u = /* @__PURE__ */ _("div", {
|
|
13044
13057
|
style: {
|
|
13045
13058
|
display: "flex",
|
|
13046
13059
|
alignItems: a ? "flex-end" : "center",
|
|
@@ -13166,7 +13179,7 @@ function h_({ copy: e, orbColors: t, primaryColor: n, onYes: r, onLater: i, isMo
|
|
|
13166
13179
|
delay: 0
|
|
13167
13180
|
},
|
|
13168
13181
|
style: { flexShrink: 0 },
|
|
13169
|
-
children: /* @__PURE__ */ g(
|
|
13182
|
+
children: /* @__PURE__ */ g(y_, {
|
|
13170
13183
|
size: l,
|
|
13171
13184
|
orbColors: t
|
|
13172
13185
|
})
|
|
@@ -13198,8 +13211,8 @@ function h_({ copy: e, orbColors: t, primaryColor: n, onYes: r, onLater: i, isMo
|
|
|
13198
13211
|
children: u
|
|
13199
13212
|
})] });
|
|
13200
13213
|
}
|
|
13201
|
-
function
|
|
13202
|
-
let c = n ||
|
|
13214
|
+
function x_({ copy: e, orbColors: t, primaryColor: n, onVoice: r, onText: i, onClose: a, isMobile: o, isClosing: s }) {
|
|
13215
|
+
let c = n || f_.green, l = m_(c);
|
|
13203
13216
|
return /* @__PURE__ */ _(eh.div, {
|
|
13204
13217
|
initial: {
|
|
13205
13218
|
scale: 50 / 350,
|
|
@@ -13270,7 +13283,7 @@ function g_({ copy: e, orbColors: t, primaryColor: n, onVoice: r, onText: i, onC
|
|
|
13270
13283
|
children: /* @__PURE__ */ g("polyline", { points: "6 9 12 15 18 9" })
|
|
13271
13284
|
})
|
|
13272
13285
|
}),
|
|
13273
|
-
/* @__PURE__ */ g(
|
|
13286
|
+
/* @__PURE__ */ g(y_, {
|
|
13274
13287
|
size: 72,
|
|
13275
13288
|
orbColors: t
|
|
13276
13289
|
}),
|
|
@@ -13350,55 +13363,55 @@ function g_({ copy: e, orbColors: t, primaryColor: n, onVoice: r, onText: i, onC
|
|
|
13350
13363
|
]
|
|
13351
13364
|
});
|
|
13352
13365
|
}
|
|
13353
|
-
function
|
|
13366
|
+
function S_({ 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" }) {
|
|
13354
13367
|
c(() => (console.log("[FlowEngage:VoiceDebug] 🔵 VoiceMode MOUNTED"), () => console.log("[FlowEngage:VoiceDebug] 🔴 VoiceMode UNMOUNTED")), []);
|
|
13355
|
-
let [T, E] = m("idle"), [D, O] = m(!1), [k, A] = m(!1), [ee, te] = m(!1), [
|
|
13356
|
-
|
|
13368
|
+
let [T, E] = m("idle"), [D, O] = m(!1), [k, A] = m(!1), [ee, te] = m(!1), [j, M] = m(""), [N, ne] = m(""), re = p(!1), P = p(!1), ie = p(null), F = p(0), ae = p(""), I = p(!1), oe = p(0), se = p(!1), ce = p(!1), le = p(!1), ue = p([]), de = p(null), fe = p(""), pe = p(null), me = (e) => {
|
|
13369
|
+
se.current = e, e || (ce.current = !1), L.current?.setWalkthroughActive?.(e);
|
|
13357
13370
|
};
|
|
13358
|
-
|
|
13359
|
-
if (
|
|
13371
|
+
pe.current = async () => {
|
|
13372
|
+
if (ce.current) return;
|
|
13360
13373
|
let e = typeof window < "u" ? window.location.pathname : null;
|
|
13361
|
-
if (e &&
|
|
13362
|
-
console.log("[FlowEngage] walkthrough ended — visitor left " +
|
|
13374
|
+
if (e && de.current && e !== de.current) {
|
|
13375
|
+
console.log("[FlowEngage] walkthrough ended — visitor left " + de.current), de.current = null, ue.current = [], me(!1);
|
|
13363
13376
|
return;
|
|
13364
13377
|
}
|
|
13365
|
-
let t =
|
|
13366
|
-
|
|
13367
|
-
let n =
|
|
13378
|
+
let t = ue.current;
|
|
13379
|
+
he.current += 1;
|
|
13380
|
+
let n = he.current, r = t[n];
|
|
13368
13381
|
if (!r) {
|
|
13369
|
-
if (
|
|
13382
|
+
if (me(!1), t.length) L.current?.sendUserMessage?.("That was the last section. Say so in one short sentence and ask if they want to explore any section further.");
|
|
13370
13383
|
else if (n === 0) {
|
|
13371
13384
|
let e = "";
|
|
13372
13385
|
try {
|
|
13373
|
-
let t = await
|
|
13386
|
+
let t = await ge.current?.["fwh-read-content-mvp"]?.({});
|
|
13374
13387
|
typeof t == "string" && t && !/^Could not/i.test(t) && (e = t.slice(0, 2800));
|
|
13375
13388
|
} catch {}
|
|
13376
|
-
|
|
13389
|
+
L.current?.sendUserMessage?.(e ? `Give the visitor a complete spoken overview of this page in 4-6 sentences, based ONLY on this page content:\n"""${e}"""\nThen ask which part they'd like to hear more about. Do not call any tool.` : "Give the visitor a complete spoken overview of this page in 4-6 sentences based on what you know about it, then ask which part they'd like to hear more about. Do not call any tool.", { suppressQuestion: !0 });
|
|
13377
13390
|
}
|
|
13378
13391
|
return;
|
|
13379
13392
|
}
|
|
13380
13393
|
try {
|
|
13381
|
-
await
|
|
13394
|
+
await ge.current?.highlightOnPage?.({ section_text: r });
|
|
13382
13395
|
} catch (e) {
|
|
13383
13396
|
console.warn("[FlowEngage] walkthrough highlight failed:", e?.message || e);
|
|
13384
13397
|
}
|
|
13385
13398
|
console.debug(`[FlowEngage] walkthrough step ${n + 1}/${t.length}: ${r}`);
|
|
13386
13399
|
let i = "";
|
|
13387
13400
|
try {
|
|
13388
|
-
let e = await
|
|
13401
|
+
let e = await ge.current?.["fwh-read-content-mvp"]?.({ section_text: r });
|
|
13389
13402
|
typeof e == "string" && e && !/^Could not/i.test(e) && (i = e.slice(0, 2500));
|
|
13390
13403
|
} catch {}
|
|
13391
13404
|
let a = i ? `Here is this section's full content — describe it from THIS text only, and do not call any tool:\n"""${i}"""\n` : "read the section's content silently first (fwh-read-content-mvp) if you don't already have it. ";
|
|
13392
|
-
|
|
13405
|
+
L.current?.sendUserMessage?.(`Describe the section titled "${r}" in 3-4 sentences, starting with ${n === 0 ? "Starting with" : "Next —"} ${r}. 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; ` + a + "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 });
|
|
13393
13406
|
};
|
|
13394
|
-
let
|
|
13407
|
+
let he = p(0), L = p(null), ge = p(null), _e = p(""), R = p(async () => {}), ve = p(!1), xe = p(!1), Ce = p(!1), we = p(!1), Te = p("minimized"), Ee = p(null), Oe = p(null), ke = p(null), je = p(0), Me = p(!1), Ne = p("idle"), Pe = p(null), Fe = p(!1), B = p(null), V = o((e = "minimized") => {
|
|
13395
13408
|
console.warn("[FlowEngage:VoiceDebug] 🛑 requestSessionShutdown called", {
|
|
13396
13409
|
destination: e,
|
|
13397
13410
|
stack: (/* @__PURE__ */ Error()).stack?.split("\n").slice(1, 4).join(" | ")
|
|
13398
13411
|
}), Te.current = e, we.current = !0, queueMicrotask(() => {
|
|
13399
|
-
|
|
13412
|
+
ve.current || (ve.current = !0, R.current?.());
|
|
13400
13413
|
});
|
|
13401
|
-
}, [l]),
|
|
13414
|
+
}, [l]), Ie = o(() => {
|
|
13402
13415
|
ie.current &&= (clearTimeout(ie.current), null);
|
|
13403
13416
|
}, []);
|
|
13404
13417
|
c(() => {
|
|
@@ -13406,40 +13419,40 @@ function __({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
13406
13419
|
re.current = !1;
|
|
13407
13420
|
return;
|
|
13408
13421
|
}
|
|
13409
|
-
if (re.current = !0, P.current = !1, te(!1),
|
|
13410
|
-
|
|
13411
|
-
let e =
|
|
13412
|
-
|
|
13413
|
-
}
|
|
13414
|
-
|
|
13415
|
-
}, [y,
|
|
13416
|
-
let
|
|
13417
|
-
|
|
13418
|
-
if (!(!P.current || re.current)) if (
|
|
13419
|
-
|
|
13422
|
+
if (re.current = !0, P.current = !1, te(!1), Ie(), I.current) {
|
|
13423
|
+
I.current = !1, L.current?.setMicMuted?.(!1);
|
|
13424
|
+
let e = ae.current;
|
|
13425
|
+
ae.current = "", L.current?.injectAgentSpeech?.("Thanks — I already have your email on file.", "interrupt"), e && L.current?.sendUserMessage?.(`The visitor's email is already on file — do not ask for it. Answer their question now: "${e}"`);
|
|
13426
|
+
}
|
|
13427
|
+
L.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.");
|
|
13428
|
+
}, [y, Ie]);
|
|
13429
|
+
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 = /(would you like (me )?to take you|shall i take you|want me to take you|would you like to (go|explore|visit|see)|take you there)/i, Ve = /^((uh+|um+|oh|ah|so|well)[,.\s]+)*(cool|nice|great|awesome|wow|lovely|perfect|got it|gotcha|i see|understood|makes sense|interesting|right|alright|sounds good|mm+-?hmm+|hmm+|k)[\s.!,]*$/i, He = (e) => String(e || "").replace(/[\s.,!?]*((uh+|um+|er+|hmm+|mm+)[\s.,!?]*)+$/i, "").trim(), Ue = o(() => {
|
|
13430
|
+
Ie(), ie.current = setTimeout(() => {
|
|
13431
|
+
if (!(!P.current || re.current)) if (F.current < 3) {
|
|
13432
|
+
F.current += 1;
|
|
13420
13433
|
try {
|
|
13421
|
-
|
|
13434
|
+
L.current?.injectAgentSpeech?.("I still need your email in the box below to continue — could you enter it, please?", "queue");
|
|
13422
13435
|
} catch {}
|
|
13423
|
-
|
|
13436
|
+
Ue();
|
|
13424
13437
|
} else {
|
|
13425
13438
|
try {
|
|
13426
|
-
|
|
13439
|
+
L.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");
|
|
13427
13440
|
} catch {}
|
|
13428
|
-
P.current = !1, te(!1),
|
|
13441
|
+
P.current = !1, te(!1), Ie(), Me.current = !0;
|
|
13429
13442
|
}
|
|
13430
13443
|
}, 1e4);
|
|
13431
|
-
}, [
|
|
13444
|
+
}, [Ie]), We = o(async (e) => {
|
|
13432
13445
|
we.current = !0;
|
|
13433
13446
|
try {
|
|
13434
13447
|
On();
|
|
13435
13448
|
} catch {}
|
|
13436
13449
|
if (i) try {
|
|
13437
|
-
|
|
13450
|
+
Ae(i);
|
|
13438
13451
|
} catch {}
|
|
13439
13452
|
try {
|
|
13440
|
-
await
|
|
13453
|
+
await L.current?.endSession?.();
|
|
13441
13454
|
} catch {}
|
|
13442
|
-
let t = Ee.current, n =
|
|
13455
|
+
let t = Ee.current, n = Oe.current;
|
|
13443
13456
|
if (t && s && a) {
|
|
13444
13457
|
let e = n ? Math.round((Date.now() - n) / 1e3) : 0;
|
|
13445
13458
|
fetch(`${a}/api/voice/save-chat-recording`, {
|
|
@@ -13453,8 +13466,8 @@ function __({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
13453
13466
|
})
|
|
13454
13467
|
}).catch((e) => console.warn("[FlowEngage] save-chat-recording failed:", e.message));
|
|
13455
13468
|
}
|
|
13456
|
-
if (Ee.current = null,
|
|
13457
|
-
|
|
13469
|
+
if (Ee.current = null, Oe.current = null, L.current = null, E("idle"), O(!1), ve.current = !1, Or(), i) try {
|
|
13470
|
+
be(i);
|
|
13458
13471
|
} catch {}
|
|
13459
13472
|
typeof u == "function" && await u(l.current), e?.();
|
|
13460
13473
|
}, [
|
|
@@ -13464,10 +13477,10 @@ function __({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
13464
13477
|
s,
|
|
13465
13478
|
a
|
|
13466
13479
|
]);
|
|
13467
|
-
|
|
13468
|
-
|
|
13480
|
+
R.current = () => We(Te.current === "chat" ? t : n), c(() => {
|
|
13481
|
+
xe.current = D;
|
|
13469
13482
|
}, [D]), c(() => {
|
|
13470
|
-
d &&
|
|
13483
|
+
d && V("chat");
|
|
13471
13484
|
}, [d]), c(() => {
|
|
13472
13485
|
let e = !1, o = null, c = null, d = null;
|
|
13473
13486
|
return (async () => {
|
|
@@ -13477,13 +13490,13 @@ function __({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
13477
13490
|
}
|
|
13478
13491
|
try {
|
|
13479
13492
|
if ((await navigator.mediaDevices.getUserMedia({ audio: !0 })).getTracks().forEach((e) => e.stop()), e) return;
|
|
13480
|
-
l.current = [],
|
|
13493
|
+
l.current = [], _e.current = "", ve.current = !1, Ce.current = !1, we.current = !1, Te.current = "minimized", Dr({ onBeforeNavigate: () => {
|
|
13481
13494
|
if (i && l.current.length > 0) try {
|
|
13482
|
-
let e =
|
|
13483
|
-
e &&
|
|
13495
|
+
let e = bg(l.current);
|
|
13496
|
+
e && z(i, e);
|
|
13484
13497
|
} catch {}
|
|
13485
13498
|
if (!qn()) {
|
|
13486
|
-
let e = Ee.current, t =
|
|
13499
|
+
let e = Ee.current, t = Oe.current;
|
|
13487
13500
|
if (e && s && a) try {
|
|
13488
13501
|
let n = t ? Math.round((Date.now() - t) / 1e3) : 0, r = JSON.stringify({
|
|
13489
13502
|
chatId: s,
|
|
@@ -13496,30 +13509,30 @@ function __({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
13496
13509
|
headers: { "Content-Type": "application/json" },
|
|
13497
13510
|
body: r,
|
|
13498
13511
|
keepalive: !0
|
|
13499
|
-
}).catch(() => {}), Ee.current = null,
|
|
13512
|
+
}).catch(() => {}), Ee.current = null, Oe.current = null;
|
|
13500
13513
|
} catch {}
|
|
13501
13514
|
}
|
|
13502
|
-
|
|
13515
|
+
Se();
|
|
13503
13516
|
} });
|
|
13504
|
-
let t =
|
|
13517
|
+
let t = l_(o_({
|
|
13505
13518
|
siteId: i || null,
|
|
13506
13519
|
apiBaseUrl: a || null,
|
|
13507
13520
|
chatId: s || null,
|
|
13508
|
-
getLastUserVoiceText: () =>
|
|
13509
|
-
isWalkthroughActive: () =>
|
|
13521
|
+
getLastUserVoiceText: () => _e.current,
|
|
13522
|
+
isWalkthroughActive: () => se.current && !ce.current,
|
|
13510
13523
|
requestEndSession: () => {
|
|
13511
13524
|
Me.current = !0;
|
|
13512
13525
|
},
|
|
13513
13526
|
requestEmailCollection: () => {
|
|
13514
|
-
b && (re.current || P.current || (P.current = !0,
|
|
13527
|
+
b && (re.current || P.current || (P.current = !0, F.current = 0, te(!0), Ue()));
|
|
13515
13528
|
}
|
|
13516
|
-
})), n = i ?
|
|
13529
|
+
})), n = i ? ye(i) : null, r = !!n?.transcript, u = i ? Ae(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 = {
|
|
13517
13530
|
apiBaseUrl: a,
|
|
13518
13531
|
siteId: i,
|
|
13519
13532
|
chatId: s,
|
|
13520
13533
|
clientTools: t
|
|
13521
13534
|
};
|
|
13522
|
-
|
|
13535
|
+
ge.current = t;
|
|
13523
13536
|
let S = (m.split("/").filter(Boolean).pop() || "").replace(/[-_]/g, " ").replace(/\b\w/g, (e) => e.toUpperCase()), C = "";
|
|
13524
13537
|
g && g.includes("|") && (C = g.split("|").map((e) => e.trim()).filter(Boolean).reduce((e, t) => e.length <= t.length ? e : t));
|
|
13525
13538
|
let w = C || S || "", T = w ? `the ${w} page` : "this page", D = (() => {
|
|
@@ -13546,145 +13559,145 @@ function __({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
13546
13559
|
let e = f || "";
|
|
13547
13560
|
x.greeting = h || (v ? e ? `Hi, welcome to ${e}! How may I help you?` : "Hi, welcome! How may I help you?" : `Welcome to ${T}! How may I help you?`), v || console.log(`[FlowEngage] 🏠 Page-context greeting: "${w}" for ${m}`);
|
|
13548
13561
|
}
|
|
13549
|
-
let A = !1, ee = p ? `NAVIGATION COMPLETE — The exact phrase "I have navigated you to the [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,
|
|
13562
|
+
let A = !1, ee = p ? `NAVIGATION COMPLETE — The exact phrase "I have navigated you to the [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, j = !1, M = !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, N = r && !p, ne = !1, ie = N ? `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, R = !1, be = !1, ke = b && !!y && !le.current, We = await Ch.startSession({
|
|
13550
13563
|
...x,
|
|
13551
13564
|
onConnect: ({ conversationId: e }) => {
|
|
13552
|
-
Ee.current = e,
|
|
13565
|
+
Ee.current = e, Oe.current = Date.now(), console.log("[FlowEngage] 🎙️ AI chat session connected:", e);
|
|
13553
13566
|
},
|
|
13554
13567
|
onUnhandledClientToolCall: (e) => console.error("[FlowEngage] Unhandled tool:", e?.tool_name),
|
|
13555
13568
|
onSessionInfo: ({ emailOnFile: e }) => {
|
|
13556
|
-
|
|
13569
|
+
le.current = !!e, e && (re.current = !0, P.current = !1, te(!1), Ie(), console.log("[FlowEngage] email already on file per server — gate disabled"));
|
|
13557
13570
|
},
|
|
13558
13571
|
onAgentTurnEnd: () => {
|
|
13559
|
-
e ||
|
|
13572
|
+
e || se.current && (ce.current || I.current || setTimeout(() => pe.current?.(), 250));
|
|
13560
13573
|
},
|
|
13561
13574
|
onSessionEnding: () => {
|
|
13562
|
-
e ||
|
|
13575
|
+
e || V("minimized");
|
|
13563
13576
|
},
|
|
13564
13577
|
onModeChange: ({ mode: t, tentative: n }) => {
|
|
13565
13578
|
if (!e) {
|
|
13566
13579
|
if (t === "speaking") {
|
|
13567
|
-
|
|
13580
|
+
Pe.current &&= (clearTimeout(Pe.current), null), B.current &&= (clearTimeout(B.current), null), E("speaking"), Ne.current = "speaking", Fe.current = !1;
|
|
13568
13581
|
return;
|
|
13569
13582
|
}
|
|
13570
13583
|
if (t === "user-speaking") {
|
|
13571
|
-
if (P.current && !re.current &&
|
|
13584
|
+
if (P.current && !re.current && Ue(), B.current &&= (clearTimeout(B.current), null), Ne.current === "speaking") return;
|
|
13572
13585
|
try {
|
|
13573
13586
|
On();
|
|
13574
13587
|
} catch {}
|
|
13575
|
-
|
|
13588
|
+
Pe.current &&= (clearTimeout(Pe.current), null), Ne.current !== "listening" && (E("listening"), Ne.current = "listening");
|
|
13576
13589
|
return;
|
|
13577
13590
|
}
|
|
13578
13591
|
if (t === "thinking") {
|
|
13579
|
-
if (
|
|
13580
|
-
E("thinking"),
|
|
13581
|
-
|
|
13592
|
+
if (Pe.current &&= (clearTimeout(Pe.current), null), B.current &&= (clearTimeout(B.current), null), Ne.current === "speaking") return;
|
|
13593
|
+
E("thinking"), Ne.current = "thinking", n && (B.current = setTimeout(() => {
|
|
13594
|
+
B.current = null, !(e || Ne.current !== "thinking") && (Ne.current = "listening", E("listening"));
|
|
13582
13595
|
}, 4e3));
|
|
13583
13596
|
return;
|
|
13584
13597
|
}
|
|
13585
|
-
if (
|
|
13586
|
-
Me.current = !1,
|
|
13598
|
+
if (Ne.current = "listening", Me.current) {
|
|
13599
|
+
Me.current = !1, V();
|
|
13587
13600
|
return;
|
|
13588
13601
|
}
|
|
13589
|
-
if (ke && !
|
|
13590
|
-
|
|
13602
|
+
if (ke && !be && !re.current && !le.current) {
|
|
13603
|
+
be = !0, A = !0, j = !0;
|
|
13591
13604
|
try {
|
|
13592
|
-
|
|
13605
|
+
L.current?.sendContextualUpdate?.("CRITICAL — EMAIL REQUIRED BEFORE ANYTHING ELSE. The visitor has not provided their email. The app itself speaks the email request out loud — you must NOT say it, and you must NOT answer. Stay completely silent from now until you receive an EMAIL_SAVED message: produce no speech and call no tools, no matter what the visitor says. Remember their question. On EMAIL_SAVED, thank them briefly and answer that remembered question in full.");
|
|
13593
13606
|
} catch {}
|
|
13594
13607
|
}
|
|
13595
13608
|
if (ee && !A) {
|
|
13596
13609
|
A = !0;
|
|
13597
13610
|
try {
|
|
13598
|
-
|
|
13611
|
+
L.current?.sendContextualUpdate?.(ee);
|
|
13599
13612
|
} catch {}
|
|
13600
13613
|
}
|
|
13601
|
-
if (ie && !
|
|
13602
|
-
|
|
13614
|
+
if (ie && !ne) {
|
|
13615
|
+
ne = !0;
|
|
13603
13616
|
try {
|
|
13604
|
-
|
|
13617
|
+
L.current?.sendContextualUpdate?.(ie);
|
|
13605
13618
|
} catch {}
|
|
13606
13619
|
}
|
|
13607
|
-
if (
|
|
13608
|
-
|
|
13620
|
+
if (M && !j) {
|
|
13621
|
+
j = !0;
|
|
13609
13622
|
try {
|
|
13610
|
-
|
|
13623
|
+
L.current?.sendContextualUpdate?.(M);
|
|
13611
13624
|
} catch {}
|
|
13612
13625
|
}
|
|
13613
|
-
|
|
13614
|
-
e ||
|
|
13626
|
+
Pe.current && clearTimeout(Pe.current), Pe.current = setTimeout(() => {
|
|
13627
|
+
e || Ne.current !== "speaking" && (Fe.current || (Pe.current = null, Ne.current = "listening", E("listening")));
|
|
13615
13628
|
}, 1200);
|
|
13616
13629
|
}
|
|
13617
13630
|
},
|
|
13618
13631
|
onMessage: (t) => {
|
|
13619
|
-
if (e ||
|
|
13632
|
+
if (e || I.current && t.role !== "user" && !/email/i.test(String(t.message || ""))) return;
|
|
13620
13633
|
let n = t.role === "user" && /^(Describe the section titled "|\[SYSTEM:|Give the visitor a complete spoken overview|That was the last section)/.test(String(t.message || "").trim()), r = /\b(?:this|that|the)\s+(?:case\s*stud(?:y|ies)|product|article|blog|post|item|service)\b/i.test(String(t.message || ""));
|
|
13621
|
-
if (!n && !r && t.role === "user" &&
|
|
13622
|
-
else if (!n && t.role === "user" &&
|
|
13623
|
-
let e = String(t.message || "").trim(), n =
|
|
13624
|
-
!n || r(e) || r(n) ?
|
|
13634
|
+
if (!n && !r && t.role === "user" && Le.test(String(t.message || ""))) typeof window < "u" && (window.__fe_user_nav_during_speech = null), me(!0), ce.current = !1, oe.current = 0, he.current = -1, ue.current = c_(), de.current = typeof window < "u" ? window.location.pathname : null, setTimeout(() => pe.current?.(), 400), console.log(`[FlowEngage] walkthrough armed — ${ue.current.length} sections on this page`);
|
|
13635
|
+
else if (!n && t.role === "user" && se.current) {
|
|
13636
|
+
let e = String(t.message || "").trim(), n = He(e), r = (e) => !!e && (ze.test(e) || Ve.test(e));
|
|
13637
|
+
Be.test(fe.current || "") ? (console.log("[FlowEngage] walkthrough ended — visitor accepted a navigation offer"), de.current = null, ue.current = [], me(!1)) : !n || r(e) || r(n) ? ce.current && (ce.current = !1, console.debug("[FlowEngage] walkthrough resumed by visitor"), setTimeout(() => pe.current?.(), 300)) : (console.log("[FlowEngage] walkthrough ended — visitor moved to a new topic"), de.current = null, ue.current = [], me(!1));
|
|
13625
13638
|
}
|
|
13626
|
-
if (t.role !== "user" &&
|
|
13627
|
-
let e =
|
|
13628
|
-
!e ||
|
|
13639
|
+
if (t.role !== "user" && !n && (fe.current = String(t.message || "")), t.role !== "user" && Re.test(String(t.message || ""))) {
|
|
13640
|
+
let e = ue.current.length;
|
|
13641
|
+
!e || he.current >= e - 1 ? me(!1) : console.debug(`[FlowEngage] agent claimed completion at step ${he.current + 1}/${e} — ignoring, tour continues`);
|
|
13629
13642
|
}
|
|
13630
13643
|
let a = t.role === "user" ? "user" : "bot", o = t.message || t.text || t.content || "";
|
|
13631
13644
|
if (o) {
|
|
13632
|
-
if (a === "user" && (
|
|
13645
|
+
if (a === "user" && (_e.current = o, typeof window < "u" && (window.__fe_user_nav_during_speech = null), Fe.current = !0, Pe.current &&= (clearTimeout(Pe.current), null), Ne.current !== "speaking" && (E("thinking"), Ne.current = "thinking"), ke && !R && !re.current && !le.current && (R = !0, ae.current = o, I.current = !0, L.current?.injectAgentSpeech?.("Before I answer that, could you please enter your email in the text box below?", "interrupt"), L.current?.setMicMuted?.(!0), P.current || (P.current = !0, F.current = 0, te(!0), Ue()))), l.current = [...l.current, {
|
|
13633
13646
|
sender: a,
|
|
13634
13647
|
message: o,
|
|
13635
13648
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
13636
13649
|
debug: t.debug
|
|
13637
13650
|
}], i) try {
|
|
13638
|
-
let e =
|
|
13639
|
-
e &&
|
|
13651
|
+
let e = bg(l.current);
|
|
13652
|
+
e && z(i, e);
|
|
13640
13653
|
} catch {}
|
|
13641
|
-
if (
|
|
13654
|
+
if (v_(a, o)) {
|
|
13642
13655
|
Me.current = !0;
|
|
13643
13656
|
return;
|
|
13644
13657
|
}
|
|
13645
|
-
if (
|
|
13646
|
-
|
|
13658
|
+
if (xe.current && a === "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(o)) if (je.current += 1, je.current === 2) try {
|
|
13659
|
+
L.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.");
|
|
13647
13660
|
} catch {}
|
|
13648
|
-
else
|
|
13661
|
+
else je.current >= 5 && V("minimized");
|
|
13649
13662
|
}
|
|
13650
13663
|
},
|
|
13651
13664
|
onError: (t) => {
|
|
13652
|
-
if (!e && !we.current && !
|
|
13653
|
-
|
|
13665
|
+
if (!e && !we.current && !Ce.current && !De()) {
|
|
13666
|
+
Ce.current = !0, console.error("[FlowEngageVoiceCall] session:error", {
|
|
13654
13667
|
message: t?.message,
|
|
13655
13668
|
name: t?.name,
|
|
13656
13669
|
raw: t
|
|
13657
13670
|
});
|
|
13658
13671
|
try {
|
|
13659
|
-
|
|
13672
|
+
L.current?.setMicMuted?.(!0);
|
|
13660
13673
|
} catch {}
|
|
13661
|
-
O(!0), E("error"),
|
|
13674
|
+
O(!0), E("error"), V("chat");
|
|
13662
13675
|
}
|
|
13663
13676
|
},
|
|
13664
13677
|
onDisconnect: (t) => {
|
|
13665
|
-
if (e || we.current ||
|
|
13678
|
+
if (e || we.current || Ce.current || De()) return;
|
|
13666
13679
|
let n = l.current?.length || 0;
|
|
13667
13680
|
console.warn("[FlowEngageVoiceCall] session:disconnected", {
|
|
13668
13681
|
historyCount: n,
|
|
13669
13682
|
reason: t?.reason,
|
|
13670
13683
|
closeCode: t?.context?.code,
|
|
13671
13684
|
closeReason: t?.context?.reason || t?.message,
|
|
13672
|
-
lastUserText:
|
|
13673
|
-
wasMuted:
|
|
13674
|
-
}),
|
|
13685
|
+
lastUserText: _e.current || "",
|
|
13686
|
+
wasMuted: xe.current
|
|
13687
|
+
}), Ce.current = !0;
|
|
13675
13688
|
try {
|
|
13676
|
-
|
|
13689
|
+
L.current?.setMicMuted?.(!0);
|
|
13677
13690
|
} catch {}
|
|
13678
|
-
O(!0),
|
|
13691
|
+
O(!0), V("chat");
|
|
13679
13692
|
}
|
|
13680
13693
|
});
|
|
13681
13694
|
if (e) {
|
|
13682
|
-
console.warn("[FlowEngage:VoiceDebug] ❌ cancelled=true after startSession resolved — killing session immediately"),
|
|
13695
|
+
console.warn("[FlowEngage:VoiceDebug] ❌ cancelled=true after startSession resolved — killing session immediately"), We.endSession().catch(() => {});
|
|
13683
13696
|
return;
|
|
13684
13697
|
}
|
|
13685
|
-
o =
|
|
13698
|
+
o = We, L.current = We, E("listening");
|
|
13686
13699
|
try {
|
|
13687
|
-
sessionStorage.setItem(`el_conv_${i}`,
|
|
13700
|
+
sessionStorage.setItem(`el_conv_${i}`, We.getId());
|
|
13688
13701
|
} catch {}
|
|
13689
13702
|
parent.postMessage({ type: "AGENT_EXPAND" }, "*");
|
|
13690
13703
|
try {
|
|
@@ -13698,7 +13711,7 @@ function __({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
13698
13711
|
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(" | "));
|
|
13699
13712
|
} catch {}
|
|
13700
13713
|
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` : "";
|
|
13701
|
-
|
|
13714
|
+
We.sendContextualUpdate(`${s}SiteId: ${i || "unknown"}. ${y ? "" : "Visitor's email is already on file from a prior session — do NOT ask for it again. "}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. Do NOT skip fwh-get-current-page-mvp. Voice: call end_voice_session or say you are ending the session to stop.`), We.sendContextualUpdate(d_(e, o, a));
|
|
13702
13715
|
} catch {}
|
|
13703
13716
|
if (typeof window < "u") {
|
|
13704
13717
|
let t = window.location.pathname, n = Date.now(), r = (e) => {
|
|
@@ -13731,10 +13744,10 @@ function __({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
13731
13744
|
if (o) {
|
|
13732
13745
|
typeof window < "u" && (window.__fe_agent_nav = null), console.log(`[FlowEngage] agent-driven navigation settled: "${s}" → "${i}"`);
|
|
13733
13746
|
try {
|
|
13734
|
-
|
|
13747
|
+
L.current?.sendUserMessage?.(`[SYSTEM: YOU just navigated the visitor to the "${m}" page (${c}) at their request — this was YOUR action, not theirs. Page title: "${l}". Sections: ${JSON.stringify(u)}. Say: "Here we are on the ${m} page." Then introduce this page in 2-3 sentences, and finish by asking: "Would you like me to walk you through it section by section?" NEVER say "I see you've navigated" — the visitor did not navigate, you did. Do NOT call fwh-navigate-mvp again. Wait for their answer before describing sections.]`, { suppressQuestion: !0 });
|
|
13735
13748
|
} catch {}
|
|
13736
13749
|
try {
|
|
13737
|
-
|
|
13750
|
+
L.current?.sendContextualUpdate?.(d_(c, d));
|
|
13738
13751
|
} catch {}
|
|
13739
13752
|
return;
|
|
13740
13753
|
}
|
|
@@ -13746,10 +13759,10 @@ function __({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
13746
13759
|
ts: Date.now()
|
|
13747
13760
|
}), console.log(`[FlowEngage] visitor navigation detected: "${s}" → "${i}" (agent target: ${k || "none"})`);
|
|
13748
13761
|
try {
|
|
13749
|
-
|
|
13762
|
+
L.current?.sendUserMessage?.(`[SYSTEM: I navigated away mid-walkthrough — I am now on the "${m}" page (${c}). Page title: "${l}". Sections: ${JSON.stringify(u)}. STOP everything. Do NOT describe the new page. Say EXACTLY: "I see you've navigated to the ${m} 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 "${m}" only.]`);
|
|
13750
13763
|
} catch {}
|
|
13751
13764
|
try {
|
|
13752
|
-
|
|
13765
|
+
L.current?.sendContextualUpdate?.(d_(c, d));
|
|
13753
13766
|
} catch {}
|
|
13754
13767
|
};
|
|
13755
13768
|
c = window.history.pushState.bind(window.history), window.history.pushState = (...e) => {
|
|
@@ -13771,10 +13784,10 @@ function __({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
13771
13784
|
On();
|
|
13772
13785
|
} catch {}
|
|
13773
13786
|
if (i) try {
|
|
13774
|
-
|
|
13787
|
+
Ae(i);
|
|
13775
13788
|
} catch {}
|
|
13776
|
-
typeof window < "u" && (window.__fe_user_nav_during_speech = null), Or(),
|
|
13777
|
-
let t = o ||
|
|
13789
|
+
typeof window < "u" && (window.__fe_user_nav_during_speech = null), Or(), Pe.current &&= (clearTimeout(Pe.current), null), B.current &&= (clearTimeout(B.current), null), ie.current &&= (clearTimeout(ie.current), null), Fe.current = !1, Ne.current = "idle", c && typeof window < "u" && (window.history.pushState = c), d && typeof window < "u" && window.removeEventListener("popstate", d);
|
|
13790
|
+
let t = o || L.current, n = Ee.current, f = Oe.current;
|
|
13778
13791
|
if (t?.endSession?.().catch(() => {}), n && s && a) {
|
|
13779
13792
|
let e = f ? Math.round((Date.now() - f) / 1e3) : 0, t = JSON.stringify({
|
|
13780
13793
|
chatId: s,
|
|
@@ -13787,7 +13800,7 @@ function __({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
13787
13800
|
headers: { "Content-Type": "application/json" },
|
|
13788
13801
|
body: t,
|
|
13789
13802
|
keepalive: !0
|
|
13790
|
-
}).catch(() => {}), Ee.current = null,
|
|
13803
|
+
}).catch(() => {}), Ee.current = null, Oe.current = null;
|
|
13791
13804
|
}
|
|
13792
13805
|
typeof u == "function" && l.current.length > 0 && u(l.current).catch?.(() => {});
|
|
13793
13806
|
};
|
|
@@ -13795,7 +13808,7 @@ function __({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
13795
13808
|
r,
|
|
13796
13809
|
i,
|
|
13797
13810
|
a,
|
|
13798
|
-
|
|
13811
|
+
V
|
|
13799
13812
|
]), c(() => {
|
|
13800
13813
|
if (!k) return;
|
|
13801
13814
|
let e = (e) => {
|
|
@@ -13804,42 +13817,42 @@ function __({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
13804
13817
|
};
|
|
13805
13818
|
return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
|
|
13806
13819
|
}, [k]);
|
|
13807
|
-
let
|
|
13808
|
-
if (
|
|
13820
|
+
let Ge = async () => {
|
|
13821
|
+
if (L.current) try {
|
|
13809
13822
|
if (D) {
|
|
13810
|
-
|
|
13823
|
+
je.current = 0, await L.current.setMicMuted?.(!1), O(!1);
|
|
13811
13824
|
try {
|
|
13812
|
-
|
|
13825
|
+
L.current.sendContextualUpdate?.("The visitor has unmuted. Resume normal interaction and wait for them to speak.");
|
|
13813
13826
|
} catch {}
|
|
13814
13827
|
} else {
|
|
13815
|
-
|
|
13828
|
+
je.current = 0, await L.current.setMicMuted?.(!0), O(!0);
|
|
13816
13829
|
try {
|
|
13817
|
-
|
|
13830
|
+
L.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.");
|
|
13818
13831
|
} catch {}
|
|
13819
13832
|
}
|
|
13820
13833
|
} catch {}
|
|
13821
|
-
},
|
|
13834
|
+
}, Ke = o(async (e) => {
|
|
13822
13835
|
e?.preventDefault?.();
|
|
13823
|
-
let t =
|
|
13836
|
+
let t = j.trim().toLowerCase();
|
|
13824
13837
|
if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t)) {
|
|
13825
|
-
|
|
13838
|
+
ne("Please enter a valid email address.");
|
|
13826
13839
|
return;
|
|
13827
13840
|
}
|
|
13828
|
-
|
|
13841
|
+
ne(""), re.current = !0, P.current = !1, Ie(), te(!1), M(""), I.current = !1;
|
|
13829
13842
|
try {
|
|
13830
13843
|
typeof v == "function" && await v(t);
|
|
13831
13844
|
} catch {}
|
|
13832
|
-
|
|
13833
|
-
let n =
|
|
13834
|
-
|
|
13845
|
+
L.current?.setMicMuted?.(!1);
|
|
13846
|
+
let n = ae.current;
|
|
13847
|
+
ae.current = "";
|
|
13835
13848
|
try {
|
|
13836
|
-
|
|
13849
|
+
L.current?.injectAgentSpeech?.("Thank you for submitting your email."), L.current?.sendUserMessage?.(n || "The visitor's email is on file. Carry on helping them and never ask for it again.");
|
|
13837
13850
|
} catch {}
|
|
13838
13851
|
}, [
|
|
13839
|
-
|
|
13852
|
+
j,
|
|
13840
13853
|
v,
|
|
13841
|
-
|
|
13842
|
-
]),
|
|
13854
|
+
Ie
|
|
13855
|
+
]), qe = Array.isArray(e) && e[0] || "#3B82F6";
|
|
13843
13856
|
return /* @__PURE__ */ _("div", {
|
|
13844
13857
|
ref: ke,
|
|
13845
13858
|
style: {
|
|
@@ -13852,7 +13865,7 @@ function __({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
13852
13865
|
},
|
|
13853
13866
|
children: [
|
|
13854
13867
|
ee && /* @__PURE__ */ _("form", {
|
|
13855
|
-
onSubmit:
|
|
13868
|
+
onSubmit: Ke,
|
|
13856
13869
|
style: {
|
|
13857
13870
|
width: "270px",
|
|
13858
13871
|
maxWidth: "calc(100vw - 40px)",
|
|
@@ -13883,9 +13896,9 @@ function __({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
13883
13896
|
inputMode: "email",
|
|
13884
13897
|
autoComplete: "email",
|
|
13885
13898
|
autoFocus: !0,
|
|
13886
|
-
value:
|
|
13899
|
+
value: j,
|
|
13887
13900
|
onChange: (e) => {
|
|
13888
|
-
|
|
13901
|
+
M(e.target.value), N && ne("");
|
|
13889
13902
|
},
|
|
13890
13903
|
placeholder: "you@example.com",
|
|
13891
13904
|
style: {
|
|
@@ -13893,33 +13906,33 @@ function __({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
13893
13906
|
boxSizing: "border-box",
|
|
13894
13907
|
padding: "10px 12px",
|
|
13895
13908
|
borderRadius: "10px",
|
|
13896
|
-
border:
|
|
13909
|
+
border: N ? "1.5px solid #ef4444" : "1.5px solid #4b5563",
|
|
13897
13910
|
background: "#1f2937",
|
|
13898
13911
|
color: "white",
|
|
13899
13912
|
fontSize: "14px",
|
|
13900
13913
|
outline: "none"
|
|
13901
13914
|
}
|
|
13902
13915
|
}),
|
|
13903
|
-
|
|
13916
|
+
N && /* @__PURE__ */ g("span", {
|
|
13904
13917
|
style: {
|
|
13905
13918
|
color: "#f87171",
|
|
13906
13919
|
fontSize: "12px"
|
|
13907
13920
|
},
|
|
13908
|
-
children:
|
|
13921
|
+
children: N
|
|
13909
13922
|
}),
|
|
13910
13923
|
/* @__PURE__ */ g("button", {
|
|
13911
13924
|
type: "submit",
|
|
13912
|
-
disabled: !
|
|
13925
|
+
disabled: !j.trim(),
|
|
13913
13926
|
style: {
|
|
13914
13927
|
width: "100%",
|
|
13915
13928
|
padding: "10px 12px",
|
|
13916
13929
|
borderRadius: "10px",
|
|
13917
13930
|
border: "none",
|
|
13918
|
-
background:
|
|
13931
|
+
background: j.trim() ? qe : "#374151",
|
|
13919
13932
|
color: "white",
|
|
13920
13933
|
fontSize: "14px",
|
|
13921
13934
|
fontWeight: 600,
|
|
13922
|
-
cursor:
|
|
13935
|
+
cursor: j.trim() ? "pointer" : "default",
|
|
13923
13936
|
transition: "background 0.2s ease"
|
|
13924
13937
|
},
|
|
13925
13938
|
children: "Submit"
|
|
@@ -13961,7 +13974,7 @@ function __({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
13961
13974
|
},
|
|
13962
13975
|
children: "Muted"
|
|
13963
13976
|
}),
|
|
13964
|
-
/* @__PURE__ */ g(
|
|
13977
|
+
/* @__PURE__ */ g(y_, {
|
|
13965
13978
|
size: 72,
|
|
13966
13979
|
voiceState: T,
|
|
13967
13980
|
isMuted: D,
|
|
@@ -13984,7 +13997,7 @@ function __({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
13984
13997
|
alignItems: "center"
|
|
13985
13998
|
},
|
|
13986
13999
|
children: [/* @__PURE__ */ g("button", {
|
|
13987
|
-
onClick:
|
|
14000
|
+
onClick: Ge,
|
|
13988
14001
|
title: D ? "Unmute" : "Mute",
|
|
13989
14002
|
style: {
|
|
13990
14003
|
width: "24px",
|
|
@@ -14033,7 +14046,7 @@ function __({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
14033
14046
|
y2: "23"
|
|
14034
14047
|
})
|
|
14035
14048
|
]
|
|
14036
|
-
}) : /* @__PURE__ */ g(
|
|
14049
|
+
}) : /* @__PURE__ */ g(wh, {
|
|
14037
14050
|
size: 16,
|
|
14038
14051
|
color: "currentColor"
|
|
14039
14052
|
})
|
|
@@ -14055,7 +14068,7 @@ function __({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
14055
14068
|
padding: 0,
|
|
14056
14069
|
flexShrink: 0
|
|
14057
14070
|
},
|
|
14058
|
-
children: /* @__PURE__ */ g(
|
|
14071
|
+
children: /* @__PURE__ */ g(Mh, {
|
|
14059
14072
|
size: 16,
|
|
14060
14073
|
color: "currentColor"
|
|
14061
14074
|
})
|
|
@@ -14079,7 +14092,7 @@ function __({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
14079
14092
|
children: [
|
|
14080
14093
|
/* @__PURE__ */ _("button", {
|
|
14081
14094
|
onClick: () => {
|
|
14082
|
-
A(!1), Te.current = "chat",
|
|
14095
|
+
A(!1), Te.current = "chat", We(t);
|
|
14083
14096
|
},
|
|
14084
14097
|
style: {
|
|
14085
14098
|
display: "flex",
|
|
@@ -14104,11 +14117,11 @@ function __({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
14104
14117
|
onMouseLeave: (e) => {
|
|
14105
14118
|
e.currentTarget.style.background = "none";
|
|
14106
14119
|
},
|
|
14107
|
-
children: [/* @__PURE__ */ g(
|
|
14120
|
+
children: [/* @__PURE__ */ g(Nh, {}), C]
|
|
14108
14121
|
}),
|
|
14109
14122
|
/* @__PURE__ */ _("button", {
|
|
14110
14123
|
onClick: () => {
|
|
14111
|
-
A(!1), Te.current = "minimized",
|
|
14124
|
+
A(!1), Te.current = "minimized", We(n);
|
|
14112
14125
|
},
|
|
14113
14126
|
style: {
|
|
14114
14127
|
display: "flex",
|
|
@@ -14133,7 +14146,7 @@ function __({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
14133
14146
|
onMouseLeave: (e) => {
|
|
14134
14147
|
e.currentTarget.style.background = "none";
|
|
14135
14148
|
},
|
|
14136
|
-
children: [/* @__PURE__ */ g(
|
|
14149
|
+
children: [/* @__PURE__ */ g(Ph, {}), w]
|
|
14137
14150
|
}),
|
|
14138
14151
|
/* @__PURE__ */ g("button", {
|
|
14139
14152
|
onClick: () => A(!1),
|
|
@@ -14185,7 +14198,7 @@ function __({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
14185
14198
|
]
|
|
14186
14199
|
});
|
|
14187
14200
|
}
|
|
14188
|
-
function
|
|
14201
|
+
function C_({ orbColors: e }) {
|
|
14189
14202
|
let t = Array.isArray(e) && e.length > 0 ? e : [
|
|
14190
14203
|
"#135bd8",
|
|
14191
14204
|
"#ef334b",
|
|
@@ -14204,7 +14217,7 @@ function v_({ orbColors: e }) {
|
|
|
14204
14217
|
`.replace(/\s+/g, " ").trim()
|
|
14205
14218
|
} });
|
|
14206
14219
|
}
|
|
14207
|
-
var
|
|
14220
|
+
var w_ = () => /* @__PURE__ */ g("div", {
|
|
14208
14221
|
style: {
|
|
14209
14222
|
display: "flex",
|
|
14210
14223
|
marginBottom: "12px",
|
|
@@ -14234,8 +14247,8 @@ var y_ = () => /* @__PURE__ */ g("div", {
|
|
|
14234
14247
|
} }, e))
|
|
14235
14248
|
})
|
|
14236
14249
|
});
|
|
14237
|
-
function
|
|
14238
|
-
let
|
|
14250
|
+
function T_({ 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: O, onFileSelect: k, onRemoveSelectedFile: A, attachmentError: ee, isUploadingAttachment: te, requiresEmail: j, emailInput: M, setEmailInput: N, emailError: ne, emailCaptureSuccess: re, replyContext: P, setReplyContext: ie, webRTCError: F, micError: ae, setMicError: I, dismissCallError: oe, activeCallId: se, isCallMuted: ce, toggleCallMute: le, endWebRTCCall: ue, formatCallDuration: de, callDurationSeconds: fe, isCallMinimized: pe, onExpand: me, onCollapse: he, onStartVoice: L, voiceEnabled: ge, headerBgColor: _e, onNewChat: R, showPoweredBy: ve, privacyPolicyUrl: z, getVisitorChatHistory: ye, resumeChat: be, isSessionRestoring: xe, isClosing: Se }) {
|
|
14251
|
+
let Ce = l.length > 0, we = T || E || w, Te = !!se, [Ee, De] = m(!1), [Oe, ke] = m(!1), [Ae, je] = m([]), [Me, Ne] = m(!1), Pe = p(null), [Fe, B] = m(() => typeof window < "u" ? window.visualViewport?.height ?? window.innerHeight : 600), [V, Ie] = m(0);
|
|
14239
14252
|
c(() => {
|
|
14240
14253
|
if (!s) return;
|
|
14241
14254
|
let e = window.visualViewport;
|
|
@@ -14248,26 +14261,26 @@ function b_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
14248
14261
|
};
|
|
14249
14262
|
}, [s]);
|
|
14250
14263
|
let Le = s && window.innerHeight - Fe > 150, Re = async () => {
|
|
14251
|
-
|
|
14264
|
+
De(!1), ke(!0), Ne(!0);
|
|
14252
14265
|
try {
|
|
14253
|
-
let e = await
|
|
14254
|
-
e?.data &&
|
|
14266
|
+
let e = await ye();
|
|
14267
|
+
e?.data && je(e.data);
|
|
14255
14268
|
} catch (e) {
|
|
14256
14269
|
console.error(e);
|
|
14257
14270
|
} finally {
|
|
14258
14271
|
Ne(!1);
|
|
14259
14272
|
}
|
|
14260
14273
|
}, ze = async (e) => {
|
|
14261
|
-
|
|
14274
|
+
ke(!1), be?.(e.chatId);
|
|
14262
14275
|
};
|
|
14263
14276
|
return c(() => {
|
|
14264
|
-
if (!
|
|
14277
|
+
if (!Ee) return;
|
|
14265
14278
|
let e = (e) => {
|
|
14266
14279
|
let t = e.composedPath?.()?.[0] || e.target;
|
|
14267
|
-
Pe.current && !Pe.current.contains(t) &&
|
|
14280
|
+
Pe.current && !Pe.current.contains(t) && De(!1);
|
|
14268
14281
|
};
|
|
14269
14282
|
return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
|
|
14270
|
-
}, [
|
|
14283
|
+
}, [Ee]), /* @__PURE__ */ _("div", {
|
|
14271
14284
|
style: s ? {
|
|
14272
14285
|
"--flowengage-primary": n,
|
|
14273
14286
|
"--flowengage-accent": n,
|
|
@@ -14281,7 +14294,7 @@ function b_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
14281
14294
|
display: "flex",
|
|
14282
14295
|
flexDirection: "column",
|
|
14283
14296
|
overflow: "hidden",
|
|
14284
|
-
animation:
|
|
14297
|
+
animation: Se ? "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)"
|
|
14285
14298
|
} : {
|
|
14286
14299
|
"--flowengage-primary": n,
|
|
14287
14300
|
"--flowengage-accent": n,
|
|
@@ -14294,7 +14307,7 @@ function b_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
14294
14307
|
flexDirection: "column",
|
|
14295
14308
|
overflow: "hidden",
|
|
14296
14309
|
position: "relative",
|
|
14297
|
-
animation:
|
|
14310
|
+
animation: Se ? "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)"
|
|
14298
14311
|
},
|
|
14299
14312
|
children: [
|
|
14300
14313
|
/* @__PURE__ */ _("div", {
|
|
@@ -14304,7 +14317,7 @@ function b_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
14304
14317
|
alignItems: "center",
|
|
14305
14318
|
columnGap: "14px",
|
|
14306
14319
|
padding: "16px 10px 14px",
|
|
14307
|
-
background:
|
|
14320
|
+
background: _e || "transparent",
|
|
14308
14321
|
flexShrink: 0,
|
|
14309
14322
|
position: "relative",
|
|
14310
14323
|
zIndex: 30
|
|
@@ -14317,7 +14330,7 @@ function b_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
14317
14330
|
alignItems: "center"
|
|
14318
14331
|
},
|
|
14319
14332
|
children: /* @__PURE__ */ g("button", {
|
|
14320
|
-
onClick:
|
|
14333
|
+
onClick: he,
|
|
14321
14334
|
style: {
|
|
14322
14335
|
width: "40px",
|
|
14323
14336
|
height: "40px",
|
|
@@ -14374,7 +14387,7 @@ function b_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
14374
14387
|
justifyContent: "center",
|
|
14375
14388
|
height: "40px"
|
|
14376
14389
|
},
|
|
14377
|
-
children: i ? /* @__PURE__ */ g(
|
|
14390
|
+
children: i ? /* @__PURE__ */ g(g_, {
|
|
14378
14391
|
logo: i,
|
|
14379
14392
|
style: {
|
|
14380
14393
|
height: "34px",
|
|
@@ -14387,7 +14400,7 @@ function b_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
14387
14400
|
height: "40px",
|
|
14388
14401
|
flexShrink: 0
|
|
14389
14402
|
},
|
|
14390
|
-
children: /* @__PURE__ */ g(
|
|
14403
|
+
children: /* @__PURE__ */ g(__, { title: e.chatTitle })
|
|
14391
14404
|
})
|
|
14392
14405
|
}), o && /* @__PURE__ */ g("div", {
|
|
14393
14406
|
style: {
|
|
@@ -14422,7 +14435,7 @@ function b_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
14422
14435
|
ref: Pe,
|
|
14423
14436
|
children: [/* @__PURE__ */ g("button", {
|
|
14424
14437
|
type: "button",
|
|
14425
|
-
onClick: () =>
|
|
14438
|
+
onClick: () => De((e) => !e),
|
|
14426
14439
|
style: {
|
|
14427
14440
|
width: "40px",
|
|
14428
14441
|
height: "40px",
|
|
@@ -14468,7 +14481,7 @@ function b_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
14468
14481
|
})
|
|
14469
14482
|
]
|
|
14470
14483
|
})
|
|
14471
|
-
}),
|
|
14484
|
+
}), Ee && /* @__PURE__ */ _("div", {
|
|
14472
14485
|
style: {
|
|
14473
14486
|
position: "absolute",
|
|
14474
14487
|
top: "34px",
|
|
@@ -14484,10 +14497,10 @@ function b_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
14484
14497
|
animation: "fe-orb-fade-in 0.18s ease"
|
|
14485
14498
|
},
|
|
14486
14499
|
children: [
|
|
14487
|
-
|
|
14500
|
+
ge && /* @__PURE__ */ _(h, { children: [/* @__PURE__ */ _("button", {
|
|
14488
14501
|
type: "button",
|
|
14489
14502
|
onClick: () => {
|
|
14490
|
-
|
|
14503
|
+
De(!1), L?.();
|
|
14491
14504
|
},
|
|
14492
14505
|
style: {
|
|
14493
14506
|
display: "flex",
|
|
@@ -14529,7 +14542,7 @@ function b_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
14529
14542
|
/* @__PURE__ */ _("button", {
|
|
14530
14543
|
type: "button",
|
|
14531
14544
|
onClick: () => {
|
|
14532
|
-
|
|
14545
|
+
De(!1), R?.();
|
|
14533
14546
|
},
|
|
14534
14547
|
style: {
|
|
14535
14548
|
display: "flex",
|
|
@@ -14564,7 +14577,7 @@ function b_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
14564
14577
|
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" })]
|
|
14565
14578
|
}), "Start new chat"]
|
|
14566
14579
|
}),
|
|
14567
|
-
|
|
14580
|
+
ye && /* @__PURE__ */ _(h, { children: [/* @__PURE__ */ g("div", { style: {
|
|
14568
14581
|
height: "1px",
|
|
14569
14582
|
background: "rgba(255,255,255,0.07)",
|
|
14570
14583
|
margin: "0 14px"
|
|
@@ -14612,7 +14625,7 @@ function b_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
14612
14625
|
/* @__PURE__ */ _("button", {
|
|
14613
14626
|
type: "button",
|
|
14614
14627
|
onClick: () => {
|
|
14615
|
-
|
|
14628
|
+
De(!1), he?.();
|
|
14616
14629
|
},
|
|
14617
14630
|
style: {
|
|
14618
14631
|
display: "flex",
|
|
@@ -14670,24 +14683,24 @@ function b_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
14670
14683
|
})
|
|
14671
14684
|
]
|
|
14672
14685
|
}),
|
|
14673
|
-
/* @__PURE__ */ g(
|
|
14674
|
-
webRTCError:
|
|
14675
|
-
micError:
|
|
14676
|
-
setMicError:
|
|
14677
|
-
dismissCallError:
|
|
14686
|
+
/* @__PURE__ */ g(ng, {
|
|
14687
|
+
webRTCError: F,
|
|
14688
|
+
micError: ae,
|
|
14689
|
+
setMicError: I,
|
|
14690
|
+
dismissCallError: oe,
|
|
14678
14691
|
isRateLimited: E,
|
|
14679
14692
|
rateLimitMessage: D
|
|
14680
14693
|
}),
|
|
14681
|
-
|
|
14694
|
+
pe && /* @__PURE__ */ g(yg, {
|
|
14682
14695
|
agentName: v,
|
|
14683
14696
|
agentHeadshot: y,
|
|
14684
14697
|
fallbackAgentName: b,
|
|
14685
|
-
callDurationSeconds:
|
|
14686
|
-
isCallMuted:
|
|
14687
|
-
formatCallDuration:
|
|
14688
|
-
toggleCallMute:
|
|
14689
|
-
endWebRTCCall:
|
|
14690
|
-
onExpand:
|
|
14698
|
+
callDurationSeconds: fe,
|
|
14699
|
+
isCallMuted: ce,
|
|
14700
|
+
formatCallDuration: de,
|
|
14701
|
+
toggleCallMute: le,
|
|
14702
|
+
endWebRTCCall: ue,
|
|
14703
|
+
onExpand: me,
|
|
14691
14704
|
primaryColor: n
|
|
14692
14705
|
}),
|
|
14693
14706
|
/* @__PURE__ */ _("div", {
|
|
@@ -14699,7 +14712,7 @@ function b_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
14699
14712
|
background: "transparent",
|
|
14700
14713
|
position: "relative"
|
|
14701
14714
|
},
|
|
14702
|
-
children: [
|
|
14715
|
+
children: [Oe ? /* @__PURE__ */ _("div", {
|
|
14703
14716
|
style: {
|
|
14704
14717
|
position: "absolute",
|
|
14705
14718
|
inset: 0,
|
|
@@ -14718,7 +14731,7 @@ function b_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
14718
14731
|
flexShrink: 0
|
|
14719
14732
|
},
|
|
14720
14733
|
children: /* @__PURE__ */ _("button", {
|
|
14721
|
-
onClick: () =>
|
|
14734
|
+
onClick: () => ke(!1),
|
|
14722
14735
|
style: {
|
|
14723
14736
|
background: "none",
|
|
14724
14737
|
border: "none",
|
|
@@ -14752,7 +14765,7 @@ function b_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
14752
14765
|
overflowY: "auto",
|
|
14753
14766
|
position: "relative"
|
|
14754
14767
|
},
|
|
14755
|
-
children:
|
|
14768
|
+
children: Me ? /* @__PURE__ */ g("div", {
|
|
14756
14769
|
style: {
|
|
14757
14770
|
padding: "40px 20px",
|
|
14758
14771
|
textAlign: "center",
|
|
@@ -14760,7 +14773,7 @@ function b_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
14760
14773
|
fontSize: "14px"
|
|
14761
14774
|
},
|
|
14762
14775
|
children: "Loading past conversations..."
|
|
14763
|
-
}) :
|
|
14776
|
+
}) : Ae.length > 0 ? /* @__PURE__ */ g("div", { children: Ae.map((e) => /* @__PURE__ */ _("div", {
|
|
14764
14777
|
onClick: () => ze(e),
|
|
14765
14778
|
style: {
|
|
14766
14779
|
padding: "16px 20px",
|
|
@@ -14812,18 +14825,18 @@ function b_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
14812
14825
|
children: "No previous chats found."
|
|
14813
14826
|
})
|
|
14814
14827
|
})]
|
|
14815
|
-
}) : null,
|
|
14828
|
+
}) : null, Ce ? /* @__PURE__ */ g($h, {
|
|
14816
14829
|
chatHistory: l,
|
|
14817
14830
|
isAiTyping: u,
|
|
14818
14831
|
isLoading: T,
|
|
14819
14832
|
isAgentTyping: d,
|
|
14820
14833
|
setReplyContext: ie,
|
|
14821
|
-
TypingDots:
|
|
14834
|
+
TypingDots: w_,
|
|
14822
14835
|
primaryColor: n,
|
|
14823
14836
|
agentHeadshot: y,
|
|
14824
14837
|
agentDisplayName: v || b,
|
|
14825
|
-
botAvatarNode: /* @__PURE__ */ g(
|
|
14826
|
-
}) :
|
|
14838
|
+
botAvatarNode: /* @__PURE__ */ g(C_, { orbColors: t })
|
|
14839
|
+
}) : xe ? /* @__PURE__ */ _("div", {
|
|
14827
14840
|
style: {
|
|
14828
14841
|
flex: 1,
|
|
14829
14842
|
display: "flex",
|
|
@@ -14863,7 +14876,7 @@ function b_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
14863
14876
|
padding: "28px 24px"
|
|
14864
14877
|
},
|
|
14865
14878
|
children: [
|
|
14866
|
-
/* @__PURE__ */ g(
|
|
14879
|
+
/* @__PURE__ */ g(y_, {
|
|
14867
14880
|
size: 94,
|
|
14868
14881
|
orbColors: t
|
|
14869
14882
|
}),
|
|
@@ -14952,18 +14965,18 @@ function b_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
14952
14965
|
flexShrink: 0,
|
|
14953
14966
|
position: "relative",
|
|
14954
14967
|
zIndex: 1,
|
|
14955
|
-
padding:
|
|
14968
|
+
padding: j ? "6px 0 0" : "12px 0 0"
|
|
14956
14969
|
},
|
|
14957
|
-
children: /* @__PURE__ */ g(
|
|
14970
|
+
children: /* @__PURE__ */ g(tg, {
|
|
14958
14971
|
input: x,
|
|
14959
14972
|
setInput: S,
|
|
14960
14973
|
onSubmit: C,
|
|
14961
14974
|
isConversationEnded: w,
|
|
14962
|
-
callUiActive:
|
|
14963
|
-
handleToggleVoice:
|
|
14975
|
+
callUiActive: Te,
|
|
14976
|
+
handleToggleVoice: L,
|
|
14964
14977
|
showVoiceToggle: f === "agent",
|
|
14965
14978
|
activeScreen: f,
|
|
14966
|
-
inputDisabled:
|
|
14979
|
+
inputDisabled: we,
|
|
14967
14980
|
replyContext: P,
|
|
14968
14981
|
clearReplyContext: () => ie(null),
|
|
14969
14982
|
onFileSelect: k,
|
|
@@ -14971,10 +14984,10 @@ function b_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
14971
14984
|
onRemoveSelectedFile: A,
|
|
14972
14985
|
attachmentError: ee,
|
|
14973
14986
|
isUploadingAttachment: te,
|
|
14974
|
-
requiresEmail:
|
|
14975
|
-
emailInput:
|
|
14976
|
-
setEmailInput:
|
|
14977
|
-
emailError:
|
|
14987
|
+
requiresEmail: j,
|
|
14988
|
+
emailInput: M,
|
|
14989
|
+
setEmailInput: N,
|
|
14990
|
+
emailError: ne,
|
|
14978
14991
|
inputPlaceholder: e.inputPlaceholder
|
|
14979
14992
|
})
|
|
14980
14993
|
}),
|
|
@@ -14986,7 +14999,7 @@ function b_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
14986
14999
|
paddingBottom: "max(12px, env(safe-area-inset-bottom, 12px))",
|
|
14987
15000
|
pointerEvents: "none"
|
|
14988
15001
|
},
|
|
14989
|
-
children: [
|
|
15002
|
+
children: [z && /* @__PURE__ */ _("p", {
|
|
14990
15003
|
style: {
|
|
14991
15004
|
margin: "0 0 4px",
|
|
14992
15005
|
fontSize: "10px",
|
|
@@ -14999,7 +15012,7 @@ function b_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
14999
15012
|
"This conversation is recorded for quality assurance purposes.",
|
|
15000
15013
|
" ",
|
|
15001
15014
|
/* @__PURE__ */ g("a", {
|
|
15002
|
-
href:
|
|
15015
|
+
href: z,
|
|
15003
15016
|
target: "_blank",
|
|
15004
15017
|
rel: "noopener noreferrer",
|
|
15005
15018
|
style: {
|
|
@@ -15009,7 +15022,7 @@ function b_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
15009
15022
|
children: "See our privacy policy"
|
|
15010
15023
|
})
|
|
15011
15024
|
]
|
|
15012
|
-
}),
|
|
15025
|
+
}), ve && /* @__PURE__ */ _("span", {
|
|
15013
15026
|
style: {
|
|
15014
15027
|
fontSize: "11px",
|
|
15015
15028
|
color: "#9ca3af",
|
|
@@ -15028,34 +15041,34 @@ function b_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
15028
15041
|
]
|
|
15029
15042
|
});
|
|
15030
15043
|
}
|
|
15031
|
-
function
|
|
15032
|
-
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: O, webRTCError: k, language: A, chatId: ee, historyRef: te, onMessageSync:
|
|
15044
|
+
function E_() {
|
|
15045
|
+
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: O, webRTCError: k, language: A, chatId: ee, historyRef: te, onMessageSync: j, sendMessage: M, uploadChatFile: N, openWidget: ne, captureVisitorEmail: re, setVoiceMode: P, endConversation: ie, startNewChat: I, acceptCall: oe, rejectCall: se, endWebRTCCall: ce, toggleCallMute: le, dismissCallError: ue, startTyping: de, stopTyping: fe, updateTypingDraft: pe, getVisitorChatHistory: me, resumeChat: he, isSessionRestoring: L, openToChatCounter: ge, voiceEndCounter: _e } = Cn();
|
|
15033
15046
|
c(() => {
|
|
15034
15047
|
try {
|
|
15035
15048
|
or();
|
|
15036
15049
|
} catch {}
|
|
15037
15050
|
}, []), c(() => {
|
|
15038
|
-
|
|
15039
|
-
}, [
|
|
15040
|
-
let
|
|
15041
|
-
...
|
|
15042
|
-
...
|
|
15043
|
-
},
|
|
15044
|
-
...
|
|
15045
|
-
...
|
|
15046
|
-
},
|
|
15047
|
-
...
|
|
15048
|
-
...
|
|
15049
|
-
},
|
|
15051
|
+
ge && W !== "voice_mode" && W !== "text_chat" && W !== "call_screen" && (P?.(!1), $e("text_chat"));
|
|
15052
|
+
}, [ge]);
|
|
15053
|
+
let R = t?.widgetSettings || {}, ve = n?.widgetSettings || {}, z = {
|
|
15054
|
+
...R.branding || {},
|
|
15055
|
+
...ve.branding || {}
|
|
15056
|
+
}, xe = {
|
|
15057
|
+
...R.theme || {},
|
|
15058
|
+
...ve.theme || {}
|
|
15059
|
+
}, Se = {
|
|
15060
|
+
...R.features || {},
|
|
15061
|
+
...ve.features || {}
|
|
15062
|
+
}, we = Se.voice !== !1, Te = Array.isArray(xe.orbColors) && xe.orbColors.length > 0 ? xe.orbColors : null, De = xe.buttonColor || xe.primaryColor || Te?.[0] || "#3B82F6", Oe = {
|
|
15050
15063
|
small: 50,
|
|
15051
15064
|
medium: 64,
|
|
15052
15065
|
large: 80
|
|
15053
|
-
},
|
|
15066
|
+
}, ke = Oe[xe.orbSize] || Oe.small, Ae = xe.position || "bottom-right", je = z.fallbackAgentName || "Agent", Me = p_(Te ?? xe.chatBgColors), Ne = z.logo || z.logoUrl || null, Pe = A || "en", Fe = R.recommendations?.[Pe] || [], B = (ve.recommendations?.[Pe] ?? Fe).filter((e) => String(e?.label ?? "").trim()).map((e, t) => ({
|
|
15054
15067
|
id: e.key || `qr-${t}`,
|
|
15055
15068
|
label: e.label,
|
|
15056
15069
|
message: e.label,
|
|
15057
15070
|
text: e.label
|
|
15058
|
-
})), V = Array.isArray(
|
|
15071
|
+
})), V = Array.isArray(z.quickChatOptions) && z.quickChatOptions.length > 0 ? z.quickChatOptions : B, Ie = z.hideWatermark === !0 ? !1 : z.showPoweredBy !== !1, Le = z.headerBgColor || null, Re = xe.bottomPosition == null ? "1.5rem" : `${xe.bottomPosition}px`, ze = z.privacyPolicyUrl || null, Be = z.chatbotEnabled !== !1 && xe.chatbotEnabled !== !1, [Ve, He] = m(() => typeof window < "u" ? window.location.pathname : "/");
|
|
15059
15072
|
c(() => {
|
|
15060
15073
|
if (typeof window > "u") return;
|
|
15061
15074
|
let e = () => He(window.location.pathname), t = window.history.pushState.bind(window.history);
|
|
@@ -15067,24 +15080,24 @@ function x_() {
|
|
|
15067
15080
|
}, []);
|
|
15068
15081
|
let Ue = (() => {
|
|
15069
15082
|
let e = {
|
|
15070
|
-
...
|
|
15071
|
-
...
|
|
15083
|
+
...R.pageVisibility || {},
|
|
15084
|
+
...ve.pageVisibility || {}
|
|
15072
15085
|
};
|
|
15073
15086
|
return Array.isArray(e.allowedPaths) ? e.allowedPaths.filter(Boolean) : [];
|
|
15074
|
-
})(), We = Ue.length === 0 || Ue.some((e) => e === "*" || e === "/*" ? !0 : e.endsWith("/*") ? Ve.startsWith(e.slice(0, -1)) : Ve.replace(/\/$/, "") === e.replace(/\/$/, "")), Ge =
|
|
15075
|
-
entryPrompt:
|
|
15076
|
-
yesLabel:
|
|
15077
|
-
laterLabel:
|
|
15078
|
-
connectionTitle:
|
|
15079
|
-
connectionSubtitle:
|
|
15080
|
-
voiceLabel:
|
|
15081
|
-
textLabel:
|
|
15082
|
-
chatTitle:
|
|
15083
|
-
hasCustomTitle: !!(
|
|
15087
|
+
})(), We = Ue.length === 0 || Ue.some((e) => e === "*" || e === "/*" ? !0 : e.endsWith("/*") ? Ve.startsWith(e.slice(0, -1)) : Ve.replace(/\/$/, "") === e.replace(/\/$/, "")), Ge = R.greetings?.[A] || ve.greetings?.[A] || z.introGreeting || "Hello, I'm here to help you know more about OpenSense Labs.", Ke = {
|
|
15088
|
+
entryPrompt: z.entryPrompt || "Do you want to explore in a new way?",
|
|
15089
|
+
yesLabel: z.yesLabel || "Yes",
|
|
15090
|
+
laterLabel: z.laterLabel || "Later",
|
|
15091
|
+
connectionTitle: z.connectionTitle || "How would you like to connect?",
|
|
15092
|
+
connectionSubtitle: z.connectionSubtitle || "",
|
|
15093
|
+
voiceLabel: z.voiceLabel || "Voice",
|
|
15094
|
+
textLabel: z.textLabel || "Text",
|
|
15095
|
+
chatTitle: z.headerName || "Chat with FlowEngage",
|
|
15096
|
+
hasCustomTitle: !!(z.headerName && String(z.headerName).trim()),
|
|
15084
15097
|
introGreeting: Ge,
|
|
15085
|
-
inputPlaceholder:
|
|
15086
|
-
analysingLabel:
|
|
15087
|
-
}, qe =
|
|
15098
|
+
inputPlaceholder: z.inputPlaceholder || "Type your message",
|
|
15099
|
+
analysingLabel: z.analysingLabel || "analysing..."
|
|
15100
|
+
}, qe = ve.elevenLabsAgentId || t?.elevenLabsAgentId || null, Je = t?.siteId || n?.siteId || null, H = t?.apiBaseUrl || "";
|
|
15088
15101
|
c(() => {
|
|
15089
15102
|
Kn(t?.siteType || null);
|
|
15090
15103
|
}, [t?.siteType]);
|
|
@@ -15095,10 +15108,10 @@ function x_() {
|
|
|
15095
15108
|
]), Ye = u && String(u).trim() || t?.ownerProfileImageUrl && String(t.ownerProfileImageUrl).trim() || null, Xe = r.some((e) => e.sender === "user"), Ze = f(() => {
|
|
15096
15109
|
let e = r.findIndex((e) => e.sender === "user");
|
|
15097
15110
|
return e === -1 ? !1 : r.slice(e + 1).some((e) => e.sender === "bot" || e.sender === "ai" || e.sender === "agent");
|
|
15098
|
-
}, [r]), Qe = !!(
|
|
15111
|
+
}, [r]), Qe = !!(ve._dashboardLivePreview || R._dashboardLivePreview), [W, $e] = m(() => Qe ? "text_chat" : "entry_prompt"), [et, tt] = m(""), [nt, G] = m(null), [rt, it] = m(h || ""), [at, 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 && Xe && Ze && W !== "voice_mode";
|
|
15099
15112
|
d(() => {
|
|
15100
15113
|
if (e !== "ready" || wt.current) return;
|
|
15101
|
-
if (wt.current = !0, !
|
|
15114
|
+
if (wt.current = !0, !we) {
|
|
15102
15115
|
$e("minimized_orb");
|
|
15103
15116
|
return;
|
|
15104
15117
|
}
|
|
@@ -15106,13 +15119,13 @@ function x_() {
|
|
|
15106
15119
|
try {
|
|
15107
15120
|
t = vr().shouldResumeVoice;
|
|
15108
15121
|
} catch {}
|
|
15109
|
-
let n =
|
|
15122
|
+
let n = Ce(), r = Je ? ye(Je) : null, i = n || !!r?.transcript;
|
|
15110
15123
|
if (t) {
|
|
15111
|
-
|
|
15124
|
+
ne?.({ notifyChatInitiated: !0 }), P?.(!0), $e("voice_mode");
|
|
15112
15125
|
return;
|
|
15113
15126
|
}
|
|
15114
|
-
if (
|
|
15115
|
-
|
|
15127
|
+
if (Ee()) {
|
|
15128
|
+
ne?.({ notifyChatInitiated: !1 }), $e("text_chat");
|
|
15116
15129
|
return;
|
|
15117
15130
|
}
|
|
15118
15131
|
if (i) {
|
|
@@ -15120,13 +15133,13 @@ function x_() {
|
|
|
15120
15133
|
$e("minimized_orb");
|
|
15121
15134
|
return;
|
|
15122
15135
|
}
|
|
15123
|
-
|
|
15136
|
+
ne?.({ notifyChatInitiated: !0 }), P?.(!0), $e("voice_mode");
|
|
15124
15137
|
return;
|
|
15125
15138
|
}
|
|
15126
15139
|
if (Je) try {
|
|
15127
|
-
|
|
15140
|
+
be(Je);
|
|
15128
15141
|
} catch {}
|
|
15129
|
-
if (
|
|
15142
|
+
if (F(Je)) {
|
|
15130
15143
|
$e("minimized_orb");
|
|
15131
15144
|
return;
|
|
15132
15145
|
}
|
|
@@ -15141,7 +15154,7 @@ function x_() {
|
|
|
15141
15154
|
let Ot = o(() => {
|
|
15142
15155
|
mt(null), gt("");
|
|
15143
15156
|
}, []), kt = o((e) => {
|
|
15144
|
-
let t =
|
|
15157
|
+
let t = Jh(e);
|
|
15145
15158
|
if (t) {
|
|
15146
15159
|
mt(null), gt(t);
|
|
15147
15160
|
return;
|
|
@@ -15184,7 +15197,7 @@ function x_() {
|
|
|
15184
15197
|
hasIncomingCall: !!w?.callId,
|
|
15185
15198
|
activeCallId: T,
|
|
15186
15199
|
callConnectionState: E
|
|
15187
|
-
}), Ct.current = e, W === "voice_mode" && P?.(!1),
|
|
15200
|
+
}), Ct.current = e, W === "voice_mode" && P?.(!1), ne?.(), At());
|
|
15188
15201
|
}
|
|
15189
15202
|
}, [
|
|
15190
15203
|
T,
|
|
@@ -15192,7 +15205,7 @@ function x_() {
|
|
|
15192
15205
|
At,
|
|
15193
15206
|
w?.callId,
|
|
15194
15207
|
i,
|
|
15195
|
-
|
|
15208
|
+
ne,
|
|
15196
15209
|
P,
|
|
15197
15210
|
W
|
|
15198
15211
|
]), c(() => {
|
|
@@ -15205,16 +15218,16 @@ function x_() {
|
|
|
15205
15218
|
!T && yt && bt(!1);
|
|
15206
15219
|
}, [T, yt]), c(() => {
|
|
15207
15220
|
if (!s || C) {
|
|
15208
|
-
|
|
15221
|
+
pe?.(""), fe?.();
|
|
15209
15222
|
return;
|
|
15210
15223
|
}
|
|
15211
15224
|
if (!et.trim() || pt) {
|
|
15212
|
-
|
|
15213
|
-
let e = window.setTimeout(() =>
|
|
15225
|
+
pe?.("");
|
|
15226
|
+
let e = window.setTimeout(() => fe?.(), 100);
|
|
15214
15227
|
return () => window.clearTimeout(e);
|
|
15215
15228
|
}
|
|
15216
|
-
|
|
15217
|
-
let e = window.setTimeout(() =>
|
|
15229
|
+
de?.();
|
|
15230
|
+
let e = window.setTimeout(() => pe?.(et), 120), t = window.setTimeout(() => fe?.(), 1200);
|
|
15218
15231
|
return () => {
|
|
15219
15232
|
window.clearTimeout(e), window.clearTimeout(t);
|
|
15220
15233
|
};
|
|
@@ -15223,9 +15236,9 @@ function x_() {
|
|
|
15223
15236
|
pt,
|
|
15224
15237
|
s,
|
|
15225
15238
|
C,
|
|
15226
|
-
|
|
15227
|
-
|
|
15228
|
-
|
|
15239
|
+
de,
|
|
15240
|
+
fe,
|
|
15241
|
+
pe
|
|
15229
15242
|
]);
|
|
15230
15243
|
let Mt = (e) => e ? {
|
|
15231
15244
|
replyTo: e.messageId || e.id || null,
|
|
@@ -15247,8 +15260,8 @@ function x_() {
|
|
|
15247
15260
|
if (pt) {
|
|
15248
15261
|
try {
|
|
15249
15262
|
vt(!0), gt("");
|
|
15250
|
-
let e = await
|
|
15251
|
-
tt(""), G(null), Ot(), await
|
|
15263
|
+
let e = await N(pt), n = e?.data || e, r = et.trim() || `Shared file: ${Xh(pt)}`;
|
|
15264
|
+
tt(""), G(null), Ot(), await M(r, "", t, {
|
|
15252
15265
|
type: "file",
|
|
15253
15266
|
metadata: {
|
|
15254
15267
|
fileUrl: n?.fileUrl,
|
|
@@ -15265,20 +15278,20 @@ function x_() {
|
|
|
15265
15278
|
return;
|
|
15266
15279
|
}
|
|
15267
15280
|
let n = et.trim();
|
|
15268
|
-
tt(""), G(null), await
|
|
15281
|
+
tt(""), G(null), await M(n, "", t);
|
|
15269
15282
|
}, Pt = o(() => {
|
|
15270
|
-
r.length !== 0 &&
|
|
15271
|
-
}, [r.length,
|
|
15283
|
+
r.length !== 0 && I?.();
|
|
15284
|
+
}, [r.length, I]), Ft = (e) => {
|
|
15272
15285
|
let t = Math.floor(e / 60);
|
|
15273
15286
|
return `${String(t).padStart(2, "0")}:${String(e % 60).padStart(2, "0")}`;
|
|
15274
15287
|
}, It = o(async (e) => {
|
|
15275
15288
|
if (C || b) return;
|
|
15276
15289
|
let t = e.message || e.label || e.text || "";
|
|
15277
|
-
t.trim() && await
|
|
15290
|
+
t.trim() && await M(t.trim(), "");
|
|
15278
15291
|
}, [
|
|
15279
15292
|
C,
|
|
15280
15293
|
b,
|
|
15281
|
-
|
|
15294
|
+
M
|
|
15282
15295
|
]), Lt = Et && W === "entry_prompt" ? { inset: 0 } : Et && W === "text_chat" ? {
|
|
15283
15296
|
left: 0,
|
|
15284
15297
|
right: 0,
|
|
@@ -15299,14 +15312,14 @@ function x_() {
|
|
|
15299
15312
|
height: "min(640px, calc(100vh - 120px))",
|
|
15300
15313
|
borderRadius: "22px",
|
|
15301
15314
|
overflow: "hidden",
|
|
15302
|
-
...
|
|
15315
|
+
...Ae === "bottom-left" ? {
|
|
15303
15316
|
left: "1.5rem",
|
|
15304
15317
|
bottom: Re
|
|
15305
15318
|
} : {
|
|
15306
15319
|
right: "1.5rem",
|
|
15307
15320
|
bottom: Re
|
|
15308
15321
|
}
|
|
15309
|
-
} :
|
|
15322
|
+
} : Ae === "bottom-left" ? {
|
|
15310
15323
|
left: "1.5rem",
|
|
15311
15324
|
bottom: Re
|
|
15312
15325
|
} : {
|
|
@@ -15324,13 +15337,13 @@ function x_() {
|
|
|
15324
15337
|
t.resume().catch(() => {}), setTimeout(() => t.close().catch(() => {}), 3e3);
|
|
15325
15338
|
}
|
|
15326
15339
|
} catch {}
|
|
15327
|
-
|
|
15340
|
+
ne({ notifyChatInitiated: !0 }), P?.(!0), $e("voice_mode");
|
|
15328
15341
|
}, Vt = () => {
|
|
15329
|
-
|
|
15342
|
+
ne({ notifyChatInitiated: !0 }), P?.(!1), $e("text_chat");
|
|
15330
15343
|
}, Ht = () => {
|
|
15331
15344
|
P?.(!1), Rt();
|
|
15332
15345
|
};
|
|
15333
|
-
return e !== "ready" || !Be ||
|
|
15346
|
+
return e !== "ready" || !Be || Se.chat === !1 || !We ? null : /* @__PURE__ */ _("div", {
|
|
15334
15347
|
className: "flowengage-widget-root",
|
|
15335
15348
|
style: {
|
|
15336
15349
|
position: "fixed",
|
|
@@ -15340,15 +15353,15 @@ function x_() {
|
|
|
15340
15353
|
onWheel: (e) => e.stopPropagation(),
|
|
15341
15354
|
onTouchMove: (e) => e.stopPropagation(),
|
|
15342
15355
|
children: [
|
|
15343
|
-
W === "entry_prompt" && /* @__PURE__ */ g(
|
|
15356
|
+
W === "entry_prompt" && /* @__PURE__ */ g(b_, {
|
|
15344
15357
|
copy: Ke,
|
|
15345
|
-
orbColors:
|
|
15346
|
-
primaryColor:
|
|
15358
|
+
orbColors: Te,
|
|
15359
|
+
primaryColor: De,
|
|
15347
15360
|
onYes: () => {
|
|
15348
|
-
|
|
15361
|
+
ae(Je), Bt();
|
|
15349
15362
|
},
|
|
15350
15363
|
onLater: () => {
|
|
15351
|
-
|
|
15364
|
+
ae(Je), Rt();
|
|
15352
15365
|
},
|
|
15353
15366
|
isMobile: Et,
|
|
15354
15367
|
isClosing: xt
|
|
@@ -15372,7 +15385,7 @@ function x_() {
|
|
|
15372
15385
|
transformOrigin: "bottom right",
|
|
15373
15386
|
display: "inline-flex",
|
|
15374
15387
|
flexDirection: "column",
|
|
15375
|
-
alignItems:
|
|
15388
|
+
alignItems: Ae === "bottom-left" ? "flex-start" : "flex-end",
|
|
15376
15389
|
gap: "10px"
|
|
15377
15390
|
},
|
|
15378
15391
|
children: [T && /* @__PURE__ */ _("button", {
|
|
@@ -15423,24 +15436,24 @@ function x_() {
|
|
|
15423
15436
|
children: E === "connected" ? `${Ft(lt)} with ${U}` : `Tap to return to ${U}`
|
|
15424
15437
|
})]
|
|
15425
15438
|
})]
|
|
15426
|
-
}), /* @__PURE__ */ g(
|
|
15427
|
-
size:
|
|
15428
|
-
orbColors:
|
|
15429
|
-
onClick: T ? At :
|
|
15439
|
+
}), /* @__PURE__ */ g(y_, {
|
|
15440
|
+
size: ke,
|
|
15441
|
+
orbColors: Te,
|
|
15442
|
+
onClick: T ? At : we ? zt : Vt
|
|
15430
15443
|
})]
|
|
15431
15444
|
}),
|
|
15432
|
-
W === "connection_modal" && /* @__PURE__ */ g(
|
|
15445
|
+
W === "connection_modal" && /* @__PURE__ */ g(x_, {
|
|
15433
15446
|
copy: Ke,
|
|
15434
|
-
orbColors:
|
|
15435
|
-
primaryColor:
|
|
15447
|
+
orbColors: Te,
|
|
15448
|
+
primaryColor: De,
|
|
15436
15449
|
onVoice: Bt,
|
|
15437
15450
|
onText: Vt,
|
|
15438
15451
|
onClose: Rt,
|
|
15439
15452
|
isMobile: Et,
|
|
15440
15453
|
isClosing: xt
|
|
15441
15454
|
}),
|
|
15442
|
-
W === "voice_mode" && /* @__PURE__ */ g(
|
|
15443
|
-
orbColors:
|
|
15455
|
+
W === "voice_mode" && /* @__PURE__ */ g(S_, {
|
|
15456
|
+
orbColors: Te,
|
|
15444
15457
|
onEnterChat: Vt,
|
|
15445
15458
|
onEndChat: Ht,
|
|
15446
15459
|
agentId: qe,
|
|
@@ -15448,19 +15461,19 @@ function x_() {
|
|
|
15448
15461
|
apiBaseUrl: H,
|
|
15449
15462
|
chatId: ee,
|
|
15450
15463
|
historyRef: te,
|
|
15451
|
-
onMessageSync:
|
|
15452
|
-
voiceEndCounter:
|
|
15464
|
+
onMessageSync: j,
|
|
15465
|
+
voiceEndCounter: _e,
|
|
15453
15466
|
websiteName: t?.websiteName,
|
|
15454
|
-
voiceFirstMessage:
|
|
15467
|
+
voiceFirstMessage: R.voiceFirstMessage || null,
|
|
15455
15468
|
captureVisitorEmail: re,
|
|
15456
15469
|
emailRequired: !h,
|
|
15457
|
-
emailCaptureEnabled:
|
|
15458
|
-
listeningLabel:
|
|
15459
|
-
thinkingLabel:
|
|
15460
|
-
enterChatModeLabel:
|
|
15461
|
-
endConversationLabel:
|
|
15470
|
+
emailCaptureEnabled: Se.emailCapture !== !1 && z.disableEmailCapture !== !0,
|
|
15471
|
+
listeningLabel: z.voiceListeningLabel || "Listening...",
|
|
15472
|
+
thinkingLabel: z.voiceThinkingLabel || "Thinking...",
|
|
15473
|
+
enterChatModeLabel: z.voiceEnterChatLabel || "Enter Chat Mode",
|
|
15474
|
+
endConversationLabel: z.voiceEndConversationLabel || "End Conversation"
|
|
15462
15475
|
}, "voice"),
|
|
15463
|
-
W === "call_screen" && /* @__PURE__ */ g(
|
|
15476
|
+
W === "call_screen" && /* @__PURE__ */ g(vg, {
|
|
15464
15477
|
incomingCall: w,
|
|
15465
15478
|
activeCallId: T,
|
|
15466
15479
|
callConnectionState: E,
|
|
@@ -15468,23 +15481,23 @@ function x_() {
|
|
|
15468
15481
|
isCallMuted: O,
|
|
15469
15482
|
agentName: U,
|
|
15470
15483
|
agentHeadshot: Ye,
|
|
15471
|
-
fallbackAgentName:
|
|
15472
|
-
acceptCall:
|
|
15473
|
-
rejectCall:
|
|
15474
|
-
endWebRTCCall:
|
|
15475
|
-
toggleCallMute:
|
|
15484
|
+
fallbackAgentName: je,
|
|
15485
|
+
acceptCall: oe,
|
|
15486
|
+
rejectCall: se,
|
|
15487
|
+
endWebRTCCall: ce,
|
|
15488
|
+
toggleCallMute: le,
|
|
15476
15489
|
formatCallDuration: Ft,
|
|
15477
15490
|
onMinimize: jt,
|
|
15478
|
-
primaryColor:
|
|
15479
|
-
orbColors:
|
|
15491
|
+
primaryColor: De,
|
|
15492
|
+
orbColors: Te,
|
|
15480
15493
|
chatHistory: r
|
|
15481
15494
|
}),
|
|
15482
|
-
W === "text_chat" && /* @__PURE__ */ g(
|
|
15495
|
+
W === "text_chat" && /* @__PURE__ */ g(T_, {
|
|
15483
15496
|
isClosing: xt,
|
|
15484
15497
|
copy: Ke,
|
|
15485
|
-
orbColors:
|
|
15486
|
-
primaryColor:
|
|
15487
|
-
chatBgGradient:
|
|
15498
|
+
orbColors: Te,
|
|
15499
|
+
primaryColor: De,
|
|
15500
|
+
chatBgGradient: Me,
|
|
15488
15501
|
logo: Ne,
|
|
15489
15502
|
quickChatOptions: V,
|
|
15490
15503
|
onQuickChatSelect: It,
|
|
@@ -15495,7 +15508,7 @@ function x_() {
|
|
|
15495
15508
|
activeScreen: a,
|
|
15496
15509
|
agentName: U,
|
|
15497
15510
|
agentHeadshot: Ye,
|
|
15498
|
-
fallbackAgentName:
|
|
15511
|
+
fallbackAgentName: je,
|
|
15499
15512
|
input: et,
|
|
15500
15513
|
setInput: tt,
|
|
15501
15514
|
onSubmit: Nt,
|
|
@@ -15518,16 +15531,16 @@ function x_() {
|
|
|
15518
15531
|
webRTCError: k,
|
|
15519
15532
|
micError: dt,
|
|
15520
15533
|
setMicError: ft,
|
|
15521
|
-
dismissCallError:
|
|
15534
|
+
dismissCallError: ue,
|
|
15522
15535
|
activeCallId: T,
|
|
15523
15536
|
isCallMuted: O,
|
|
15524
|
-
toggleCallMute:
|
|
15525
|
-
endWebRTCCall:
|
|
15537
|
+
toggleCallMute: le,
|
|
15538
|
+
endWebRTCCall: ce,
|
|
15526
15539
|
formatCallDuration: Ft,
|
|
15527
15540
|
callDurationSeconds: lt,
|
|
15528
15541
|
onCollapse: Rt,
|
|
15529
15542
|
onStartVoice: Bt,
|
|
15530
|
-
voiceEnabled:
|
|
15543
|
+
voiceEnabled: we,
|
|
15531
15544
|
onNewChat: Pt,
|
|
15532
15545
|
onMinimize: jt,
|
|
15533
15546
|
onExpand: At,
|
|
@@ -15535,9 +15548,9 @@ function x_() {
|
|
|
15535
15548
|
showPoweredBy: Ie,
|
|
15536
15549
|
privacyPolicyUrl: ze,
|
|
15537
15550
|
headerBgColor: Le,
|
|
15538
|
-
getVisitorChatHistory:
|
|
15539
|
-
resumeChat:
|
|
15540
|
-
isSessionRestoring:
|
|
15551
|
+
getVisitorChatHistory: me,
|
|
15552
|
+
resumeChat: he,
|
|
15553
|
+
isSessionRestoring: L
|
|
15541
15554
|
}),
|
|
15542
15555
|
/* @__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 " })
|
|
15543
15556
|
]
|
|
@@ -15545,7 +15558,7 @@ function x_() {
|
|
|
15545
15558
|
}
|
|
15546
15559
|
//#endregion
|
|
15547
15560
|
//#region src/components/ErrorBoundary.jsx
|
|
15548
|
-
var
|
|
15561
|
+
var D_ = class extends e.Component {
|
|
15549
15562
|
constructor(e) {
|
|
15550
15563
|
super(e), this.state = { hasError: !1 };
|
|
15551
15564
|
}
|
|
@@ -15560,4 +15573,4 @@ var S_ = class extends e.Component {
|
|
|
15560
15573
|
}
|
|
15561
15574
|
};
|
|
15562
15575
|
//#endregion
|
|
15563
|
-
export {
|
|
15576
|
+
export { dg as AnimatedOrb, D_ as ErrorBoundary, pi as FlowEngageProvider, E_ as FlowEngageWidget, Cn as useFlowEngage };
|