@flowengage/react-chatbot 8.0.15 → 8.0.16-test
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/flowengage-embed.js +22 -22
- package/dist/flowengage-react-chatbot.cjs +16 -16
- package/dist/flowengage-react-chatbot.mjs +718 -597
- package/package.json +1 -1
|
@@ -18,15 +18,15 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
|
|
|
18
18
|
}, T = (e) => x.call(e, "module.exports") ? e["module.exports"] : w(v({}, "__esModule", { value: !0 }), e), ee = (e) => {
|
|
19
19
|
if (!e || typeof e != "object") throw Error("FlowEngage config is required");
|
|
20
20
|
if (!e.siteId || typeof e.siteId != "string") throw Error("[FlowEngage] config.siteId is required. Pass it as <FlowEngageProvider siteId=\"your-site-id\" /> or config={{ siteId: 'your-site-id' }}.");
|
|
21
|
-
let t = (e.apiBaseUrl || "
|
|
21
|
+
let t = (e.apiBaseUrl || "http://localhost:5008").replace(/\/+$/, "");
|
|
22
22
|
return {
|
|
23
23
|
siteId: e.siteId.trim(),
|
|
24
24
|
apiBaseUrl: t
|
|
25
25
|
};
|
|
26
|
-
},
|
|
26
|
+
}, E = (e, t) => {
|
|
27
27
|
let n = Number.parseInt(String(e ?? ""), 10);
|
|
28
28
|
return Number.isFinite(n) && n > 0 ? n : t;
|
|
29
|
-
},
|
|
29
|
+
}, te = E(void 0, 1e4), ne = E(void 0, 15e3), D = {
|
|
30
30
|
chatId: "flowengage.chatId",
|
|
31
31
|
isOpen: "flowengage.isOpen",
|
|
32
32
|
activeScreen: "flowengage.activeScreen",
|
|
@@ -34,51 +34,51 @@ 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
|
-
},
|
|
38
|
-
if (!
|
|
39
|
-
let e = window.localStorage.getItem(
|
|
37
|
+
}, re = 6e4, ie = 480 * 60, ae = 3e4, O = typeof window < "u", oe = (e) => e ? `flowengage.visitorEmail.${e}` : null, se = () => {
|
|
38
|
+
if (!O) return null;
|
|
39
|
+
let e = window.localStorage.getItem(D.chatId);
|
|
40
40
|
return e && String(e).trim() ? String(e).trim() : null;
|
|
41
|
-
},
|
|
42
|
-
if (
|
|
43
|
-
window.localStorage.removeItem(
|
|
41
|
+
}, ce = () => {
|
|
42
|
+
if (O) try {
|
|
43
|
+
window.localStorage.removeItem(D.chatId);
|
|
44
44
|
} catch {}
|
|
45
|
-
},
|
|
46
|
-
if (!
|
|
45
|
+
}, le = () => O ? typeof crypto < "u" && crypto.randomUUID ? crypto.randomUUID() : `${Date.now()}-${Math.random().toString(16).slice(2)}` : "server-chat-id", ue = (e) => e ? `flowengage.entrySeen.${e}` : null, de = (e) => {
|
|
46
|
+
if (!O || !e) return !1;
|
|
47
47
|
try {
|
|
48
|
-
let t =
|
|
48
|
+
let t = ue(e);
|
|
49
49
|
return t ? window.localStorage.getItem(t) === "1" : !1;
|
|
50
50
|
} catch {
|
|
51
51
|
return !1;
|
|
52
52
|
}
|
|
53
|
-
},
|
|
54
|
-
if (!(!
|
|
55
|
-
let t =
|
|
53
|
+
}, fe = (e) => {
|
|
54
|
+
if (!(!O || !e)) try {
|
|
55
|
+
let t = ue(e);
|
|
56
56
|
t && window.localStorage.setItem(t, "1");
|
|
57
57
|
} catch {}
|
|
58
|
-
},
|
|
59
|
-
if (!
|
|
58
|
+
}, pe = (e) => e ? `flowengage.persistedChatId.${e}` : null, me = (e) => {
|
|
59
|
+
if (!O || !e) return null;
|
|
60
60
|
try {
|
|
61
|
-
let t =
|
|
61
|
+
let t = pe(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
|
+
}, he = (e) => {
|
|
67
|
+
if (!(!O || !e)) try {
|
|
68
|
+
let t = pe(e);
|
|
69
69
|
t && window.localStorage.removeItem(t);
|
|
70
70
|
} catch {}
|
|
71
|
-
},
|
|
72
|
-
if (!(!
|
|
73
|
-
let n =
|
|
71
|
+
}, ge = (e, t) => {
|
|
72
|
+
if (!(!O || !e || !t)) try {
|
|
73
|
+
let n = pe(e);
|
|
74
74
|
n && window.localStorage.setItem(n, String(t).trim());
|
|
75
75
|
} catch {}
|
|
76
|
-
},
|
|
76
|
+
}, _e = () => O ? {
|
|
77
77
|
isOpen: !1,
|
|
78
|
-
activeScreen: window.sessionStorage.getItem(
|
|
79
|
-
isHumanHandled: window.sessionStorage.getItem(
|
|
80
|
-
agentName: window.sessionStorage.getItem(
|
|
81
|
-
agentHeadshot: window.sessionStorage.getItem(
|
|
78
|
+
activeScreen: window.sessionStorage.getItem(D.activeScreen) || "ai",
|
|
79
|
+
isHumanHandled: window.sessionStorage.getItem(D.isHumanHandled) === "true",
|
|
80
|
+
agentName: window.sessionStorage.getItem(D.agentName),
|
|
81
|
+
agentHeadshot: window.sessionStorage.getItem(D.agentHeadshot),
|
|
82
82
|
visitorEmail: ""
|
|
83
83
|
} : {
|
|
84
84
|
isOpen: !1,
|
|
@@ -87,9 +87,9 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
|
|
|
87
87
|
agentName: null,
|
|
88
88
|
agentHeadshot: null,
|
|
89
89
|
visitorEmail: ""
|
|
90
|
-
},
|
|
91
|
-
|
|
92
|
-
let n =
|
|
90
|
+
}, ve = (e) => {
|
|
91
|
+
O && Object.entries(e).forEach(([e, t]) => {
|
|
92
|
+
let n = D[e];
|
|
93
93
|
if (n) {
|
|
94
94
|
if (t == null || t === !1) {
|
|
95
95
|
window.sessionStorage.removeItem(n);
|
|
@@ -98,109 +98,109 @@ 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
|
+
}, ye = (e) => {
|
|
102
|
+
if (!O || !e) return "";
|
|
103
|
+
let t = oe(e), n = window.localStorage.getItem(t);
|
|
104
104
|
if (!n) {
|
|
105
|
-
let e = window.sessionStorage.getItem(
|
|
106
|
-
e && (window.localStorage.setItem(t, e), window.sessionStorage.removeItem(
|
|
105
|
+
let e = window.sessionStorage.getItem(D.visitorEmail);
|
|
106
|
+
e && (window.localStorage.setItem(t, e), window.sessionStorage.removeItem(D.visitorEmail), n = e);
|
|
107
107
|
}
|
|
108
108
|
return n || "";
|
|
109
|
-
},
|
|
110
|
-
if (!
|
|
111
|
-
let n =
|
|
109
|
+
}, be = (e, t) => {
|
|
110
|
+
if (!O) return;
|
|
111
|
+
let n = oe(t);
|
|
112
112
|
if (!n) return;
|
|
113
113
|
let r = typeof e == "string" ? e.trim() : "";
|
|
114
114
|
if (!r) {
|
|
115
|
-
window.localStorage.removeItem(n), window.sessionStorage.removeItem(
|
|
115
|
+
window.localStorage.removeItem(n), window.sessionStorage.removeItem(D.visitorEmail);
|
|
116
116
|
return;
|
|
117
117
|
}
|
|
118
|
-
window.localStorage.setItem(n, r), window.sessionStorage.removeItem(
|
|
119
|
-
},
|
|
120
|
-
if (!
|
|
118
|
+
window.localStorage.setItem(n, r), window.sessionStorage.removeItem(D.visitorEmail);
|
|
119
|
+
}, xe = (e) => e ? `flowengage.visitorId.${e}` : null, Se = () => `v_${Date.now().toString(36)}_${typeof crypto < "u" && crypto.randomUUID ? crypto.randomUUID().replace(/-/g, "").slice(0, 16) : Math.random().toString(36).slice(2, 18)}`, Ce = (e) => {
|
|
120
|
+
if (!O || !e) return null;
|
|
121
121
|
try {
|
|
122
|
-
let t =
|
|
122
|
+
let t = xe(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
|
+
}, we = (e) => {
|
|
128
|
+
if (!O || !e) return null;
|
|
129
129
|
try {
|
|
130
|
-
let t =
|
|
130
|
+
let t = Ce(e);
|
|
131
131
|
if (t) return t;
|
|
132
|
-
let n =
|
|
132
|
+
let n = Se(), r = xe(e);
|
|
133
133
|
return r && window.localStorage.setItem(r, n), n;
|
|
134
134
|
} catch {
|
|
135
|
-
return
|
|
135
|
+
return Se();
|
|
136
136
|
}
|
|
137
|
-
},
|
|
138
|
-
if (!
|
|
137
|
+
}, Te = "flowengage.tabId", Ee = () => {
|
|
138
|
+
if (!O) 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(Te);
|
|
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(Te, e)), e;
|
|
142
142
|
} catch {
|
|
143
143
|
return "default";
|
|
144
144
|
}
|
|
145
|
-
},
|
|
146
|
-
if (!
|
|
145
|
+
}, De = (e) => e ? `flowengage.voice.transcript.${e}.${Ee()}` : null, Oe = 600 * 1e3, k = (e, t, n = {}) => {
|
|
146
|
+
if (!O || !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 : Oe, a = {
|
|
150
150
|
transcript: r,
|
|
151
151
|
expiresAt: Date.now() + i
|
|
152
152
|
};
|
|
153
153
|
try {
|
|
154
|
-
let t =
|
|
154
|
+
let t = De(e);
|
|
155
155
|
t && window.localStorage.setItem(t, JSON.stringify(a));
|
|
156
156
|
} catch {}
|
|
157
|
-
},
|
|
158
|
-
if (!
|
|
157
|
+
}, ke = (e) => {
|
|
158
|
+
if (!O || !e) return null;
|
|
159
159
|
try {
|
|
160
|
-
let t =
|
|
160
|
+
let t = De(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
|
+
}, Ae = (e) => {
|
|
168
|
+
if (!(!O || !e)) try {
|
|
169
|
+
let t = De(e);
|
|
170
170
|
t && window.localStorage.removeItem(t);
|
|
171
171
|
} catch {}
|
|
172
|
-
},
|
|
173
|
-
if (
|
|
174
|
-
window.sessionStorage.setItem(
|
|
172
|
+
}, je = "flowengage.voice.pendingResume", Me = () => {
|
|
173
|
+
if (O) try {
|
|
174
|
+
window.sessionStorage.setItem(je, "1");
|
|
175
175
|
} catch {}
|
|
176
|
-
},
|
|
177
|
-
if (!
|
|
176
|
+
}, Ne = () => {
|
|
177
|
+
if (!O) return !1;
|
|
178
178
|
try {
|
|
179
|
-
return window.sessionStorage.getItem(
|
|
179
|
+
return window.sessionStorage.getItem(je) === "1" ? (window.sessionStorage.removeItem(je), !0) : !1;
|
|
180
180
|
} catch {
|
|
181
181
|
return !1;
|
|
182
182
|
}
|
|
183
|
-
},
|
|
184
|
-
if (
|
|
185
|
-
window.sessionStorage.setItem(
|
|
183
|
+
}, Pe = "flowengage.chat.pendingReopen", Fe = () => {
|
|
184
|
+
if (O) try {
|
|
185
|
+
window.sessionStorage.setItem(Pe, "1");
|
|
186
186
|
} catch {}
|
|
187
|
-
},
|
|
188
|
-
if (!
|
|
187
|
+
}, Ie = () => {
|
|
188
|
+
if (!O) return !1;
|
|
189
189
|
try {
|
|
190
|
-
return window.sessionStorage.getItem(
|
|
190
|
+
return window.sessionStorage.getItem(Pe) === "1" ? (window.sessionStorage.removeItem(Pe), !0) : !1;
|
|
191
191
|
} catch {
|
|
192
192
|
return !1;
|
|
193
193
|
}
|
|
194
|
-
},
|
|
195
|
-
if (!
|
|
194
|
+
}, Le = () => {
|
|
195
|
+
if (!O) return !1;
|
|
196
196
|
try {
|
|
197
|
-
return window.sessionStorage.getItem(
|
|
197
|
+
return window.sessionStorage.getItem(je) === "1";
|
|
198
198
|
} catch {
|
|
199
199
|
return !1;
|
|
200
200
|
}
|
|
201
|
-
},
|
|
202
|
-
if (!(!
|
|
203
|
-
let i =
|
|
201
|
+
}, Re = (e) => e ? `flowengage.voice.navState.${e}.${Ee()}` : null, ze = (e, t, n, r) => {
|
|
202
|
+
if (!(!O || !e || !t)) try {
|
|
203
|
+
let i = Re(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
|
+
}, Be = (e) => {
|
|
212
|
+
if (!O || !e) return null;
|
|
213
213
|
try {
|
|
214
|
-
let t =
|
|
214
|
+
let t = Re(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
|
+
}, A = 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
|
+
}, Ve = async (e, t = {}) => {
|
|
235
235
|
try {
|
|
236
236
|
return await fetch(e, {
|
|
237
237
|
mode: "cors",
|
|
@@ -241,9 +241,9 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
|
|
|
241
241
|
let n = /* @__PURE__ */ Error(`Network error reaching ${e}. Check: (1) backend is running, (2) CORS allows this origin, (3) siteId is correct. Original: ${t.message}`);
|
|
242
242
|
throw n.status = 0, n.cause = t, n;
|
|
243
243
|
}
|
|
244
|
-
},
|
|
244
|
+
}, He = 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), A(await Ve(s, {
|
|
247
247
|
method: "POST",
|
|
248
248
|
mode: "cors",
|
|
249
249
|
headers: {
|
|
@@ -254,13 +254,13 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
|
|
|
254
254
|
},
|
|
255
255
|
body: JSON.stringify(c)
|
|
256
256
|
}));
|
|
257
|
-
},
|
|
257
|
+
}, Ue = async ({ apiBaseUrl: e, siteId: t }) => {
|
|
258
258
|
let n = typeof window < "u" ? window.location.origin : "http://localhost";
|
|
259
|
-
return (await
|
|
259
|
+
return (await A(await Ve(`${e}/api/widget/chatbot-loader?${new URLSearchParams({
|
|
260
260
|
siteId: t,
|
|
261
261
|
origin: n
|
|
262
262
|
}).toString()}`, { method: "GET" }))).data;
|
|
263
|
-
},
|
|
263
|
+
}, We = ({ apiBaseUrl: e, userId: t, siteId: n, visitorId: r = null }) => {
|
|
264
264
|
let i = (t, n) => {
|
|
265
265
|
let r = `${e}${t}`, i = JSON.stringify(n);
|
|
266
266
|
if (typeof navigator < "u" && navigator.sendBeacon) try {
|
|
@@ -274,7 +274,7 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
|
|
|
274
274
|
headers: { "Content-Type": "application/json" },
|
|
275
275
|
body: i
|
|
276
276
|
}).catch(() => {}), !0) : !1;
|
|
277
|
-
}, a = async (i, a = {}) =>
|
|
277
|
+
}, a = async (i, a = {}) => A(await Ve(`${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 A(await Ve(`${e}${r}`, {
|
|
293
293
|
...a,
|
|
294
294
|
body: i,
|
|
295
295
|
headers: o
|
|
@@ -418,7 +418,7 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
|
|
|
418
418
|
});
|
|
419
419
|
},
|
|
420
420
|
async getIceServersConfig() {
|
|
421
|
-
return
|
|
421
|
+
return A(await Ve(`${e}/api/calls/ice-config`, {
|
|
422
422
|
method: "GET",
|
|
423
423
|
headers: {
|
|
424
424
|
"x-user-id": t,
|
|
@@ -473,42 +473,42 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
|
|
|
473
473
|
return i.append("chatId", r), i.append("type", "widget_closed"), t && i.append("userId", String(t)), n && i.append("siteId", String(n)), navigator.sendBeacon(`${e}/api/chat/status`, i);
|
|
474
474
|
}
|
|
475
475
|
};
|
|
476
|
-
},
|
|
477
|
-
|
|
478
|
-
var
|
|
479
|
-
Object.keys(
|
|
480
|
-
|
|
476
|
+
}, Ge = Object.create(null);
|
|
477
|
+
Ge.open = "0", Ge.close = "1", Ge.ping = "2", Ge.pong = "3", Ge.message = "4", Ge.upgrade = "5", Ge.noop = "6";
|
|
478
|
+
var Ke = Object.create(null);
|
|
479
|
+
Object.keys(Ge).forEach((e) => {
|
|
480
|
+
Ke[Ge[e]] = e;
|
|
481
481
|
});
|
|
482
|
-
var
|
|
482
|
+
var qe = {
|
|
483
483
|
type: "error",
|
|
484
484
|
data: "parser error"
|
|
485
|
-
},
|
|
485
|
+
}, Je = typeof Blob == "function" || typeof Blob < "u" && Object.prototype.toString.call(Blob) === "[object BlobConstructor]", Ye = typeof ArrayBuffer == "function", Xe = (e) => typeof ArrayBuffer.isView == "function" ? ArrayBuffer.isView(e) : e && e.buffer instanceof ArrayBuffer, Ze = ({ type: e, data: t }, n, r) => Je && t instanceof Blob ? n ? r(t) : Qe(t, r) : Ye && (t instanceof ArrayBuffer || Xe(t)) ? n ? r(t) : Qe(new Blob([t]), r) : r(Ge[e] + (t || "")), Qe = (e, t) => {
|
|
486
486
|
let n = new FileReader();
|
|
487
487
|
return n.onload = function() {
|
|
488
488
|
let e = n.result.split(",")[1];
|
|
489
489
|
t("b" + (e || ""));
|
|
490
490
|
}, n.readAsDataURL(e);
|
|
491
491
|
};
|
|
492
|
-
function
|
|
492
|
+
function $e(e) {
|
|
493
493
|
return e instanceof Uint8Array ? e : e instanceof ArrayBuffer ? new Uint8Array(e) : new Uint8Array(e.buffer, e.byteOffset, e.byteLength);
|
|
494
494
|
}
|
|
495
|
-
var
|
|
496
|
-
function
|
|
497
|
-
if (
|
|
498
|
-
if (
|
|
499
|
-
|
|
500
|
-
|
|
495
|
+
var et;
|
|
496
|
+
function tt(e, t) {
|
|
497
|
+
if (Je && e.data instanceof Blob) return e.data.arrayBuffer().then($e).then(t);
|
|
498
|
+
if (Ye && (e.data instanceof ArrayBuffer || Xe(e.data))) return t($e(e.data));
|
|
499
|
+
Ze(e, !1, (e) => {
|
|
500
|
+
et ||= new TextEncoder(), t(et.encode(e));
|
|
501
501
|
});
|
|
502
502
|
}
|
|
503
503
|
//#endregion
|
|
504
504
|
//#region node_modules/engine.io-parser/build/esm/contrib/base64-arraybuffer.js
|
|
505
|
-
var
|
|
506
|
-
for (let e = 0; e < 64; e++)
|
|
505
|
+
var nt = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", rt = typeof Uint8Array > "u" ? [] : new Uint8Array(256);
|
|
506
|
+
for (let e = 0; e < 64; e++) rt[nt.charCodeAt(e)] = e;
|
|
507
507
|
var j = (e) => {
|
|
508
508
|
let t = e.length * .75, n = e.length, r, i = 0, a, o, s, c;
|
|
509
509
|
e[e.length - 1] === "=" && (t--, e[e.length - 2] === "=" && t--);
|
|
510
510
|
let l = new ArrayBuffer(t), u = new Uint8Array(l);
|
|
511
|
-
for (r = 0; r < n; r += 4) a =
|
|
511
|
+
for (r = 0; r < n; r += 4) a = rt[e.charCodeAt(r)], o = rt[e.charCodeAt(r + 1)], s = rt[e.charCodeAt(r + 2)], c = rt[e.charCodeAt(r + 3)], u[i++] = a << 2 | o >> 4, u[i++] = (o & 15) << 4 | s >> 2, u[i++] = (s & 3) << 6 | c & 63;
|
|
512
512
|
return l;
|
|
513
513
|
}, it = typeof ArrayBuffer == "function", at = (e, t) => {
|
|
514
514
|
if (typeof e != "string") return {
|
|
@@ -519,10 +519,10 @@ var j = (e) => {
|
|
|
519
519
|
return n === "b" ? {
|
|
520
520
|
type: "message",
|
|
521
521
|
data: ot(e.substring(1), t)
|
|
522
|
-
} :
|
|
523
|
-
type:
|
|
522
|
+
} : Ke[n] ? e.length > 1 ? {
|
|
523
|
+
type: Ke[n],
|
|
524
524
|
data: e.substring(1)
|
|
525
|
-
} : { type:
|
|
525
|
+
} : { type: Ke[n] } : qe;
|
|
526
526
|
}, ot = (e, t) => it ? st(j(e), t) : {
|
|
527
527
|
base64: !0,
|
|
528
528
|
data: e
|
|
@@ -534,7 +534,7 @@ var j = (e) => {
|
|
|
534
534
|
}, ct = "", lt = (e, t) => {
|
|
535
535
|
let n = e.length, r = Array(n), i = 0;
|
|
536
536
|
e.forEach((e, a) => {
|
|
537
|
-
|
|
537
|
+
Ze(e, !1, (e) => {
|
|
538
538
|
r[a] = e, ++i === n && t(r.join(ct));
|
|
539
539
|
});
|
|
540
540
|
});
|
|
@@ -548,7 +548,7 @@ var j = (e) => {
|
|
|
548
548
|
};
|
|
549
549
|
function M() {
|
|
550
550
|
return new TransformStream({ transform(e, t) {
|
|
551
|
-
|
|
551
|
+
tt(e, (n) => {
|
|
552
552
|
let r = n.length, i;
|
|
553
553
|
if (r < 126) i = new Uint8Array(1), new DataView(i.buffer).setUint8(0, r);
|
|
554
554
|
else if (r < 65536) {
|
|
@@ -591,7 +591,7 @@ function mt(e, t) {
|
|
|
591
591
|
if (ft(n) < 8) break;
|
|
592
592
|
let e = pt(n, 8), t = new DataView(e.buffer, e.byteOffset, e.length), a = t.getUint32(0);
|
|
593
593
|
if (a > 2 ** 21 - 1) {
|
|
594
|
-
s.enqueue(
|
|
594
|
+
s.enqueue(qe);
|
|
595
595
|
break;
|
|
596
596
|
}
|
|
597
597
|
i = a * 2 ** 32 + t.getUint32(4), r = 3;
|
|
@@ -601,7 +601,7 @@ function mt(e, t) {
|
|
|
601
601
|
s.enqueue(at(a ? e : dt.decode(e), t)), r = 0;
|
|
602
602
|
}
|
|
603
603
|
if (i === 0 || i > e) {
|
|
604
|
-
s.enqueue(
|
|
604
|
+
s.enqueue(qe);
|
|
605
605
|
break;
|
|
606
606
|
}
|
|
607
607
|
}
|
|
@@ -931,7 +931,7 @@ var Vt = typeof navigator < "u" && typeof navigator.product == "string" && navig
|
|
|
931
931
|
this.writable = !1;
|
|
932
932
|
for (let t = 0; t < e.length; t++) {
|
|
933
933
|
let n = e[t], r = t === e.length - 1;
|
|
934
|
-
|
|
934
|
+
Ze(n, this.supportsBinary, (e) => {
|
|
935
935
|
try {
|
|
936
936
|
this.doWrite(n, e);
|
|
937
937
|
} catch {}
|
|
@@ -1954,7 +1954,7 @@ var Mn = ({ apiBaseUrl: e, userId: t, chatId: n, siteId: r }) => jn(e, {
|
|
|
1954
1954
|
timestamp: Date.now()
|
|
1955
1955
|
});
|
|
1956
1956
|
}, u = () => {
|
|
1957
|
-
i && window.clearInterval(i), i = window.setInterval(l,
|
|
1957
|
+
i && window.clearInterval(i), i = window.setInterval(l, te);
|
|
1958
1958
|
}, d = () => {
|
|
1959
1959
|
i &&= (window.clearInterval(i), null);
|
|
1960
1960
|
}, f = (r) => {
|
|
@@ -1972,7 +1972,7 @@ var Mn = ({ apiBaseUrl: e, userId: t, chatId: n, siteId: r }) => jn(e, {
|
|
|
1972
1972
|
if (document.hidden) {
|
|
1973
1973
|
a && window.clearTimeout(a), a = window.setTimeout(() => {
|
|
1974
1974
|
a = null, d(), f("hidden");
|
|
1975
|
-
},
|
|
1975
|
+
}, ne);
|
|
1976
1976
|
return;
|
|
1977
1977
|
}
|
|
1978
1978
|
a &&= (window.clearTimeout(a), null), f("visible"), l(), u();
|
|
@@ -2004,7 +2004,7 @@ var Mn = ({ apiBaseUrl: e, userId: t, chatId: n, siteId: r }) => jn(e, {
|
|
|
2004
2004
|
};
|
|
2005
2005
|
return window.addEventListener("popstate", m), window.addEventListener("hashchange", m), window.addEventListener("beforeunload", v), window.addEventListener("pagehide", y), window.addEventListener("visibilitychange", p), o(), document.hidden ? a = window.setTimeout(() => {
|
|
2006
2006
|
a = null, d(), f("hidden");
|
|
2007
|
-
},
|
|
2007
|
+
}, ne) : (l(), u()), {
|
|
2008
2008
|
notifyRouteChange: m,
|
|
2009
2009
|
cleanup: () => {
|
|
2010
2010
|
a &&= (window.clearTimeout(a), null), d(), window.history.pushState = h, window.history.replaceState = g, window.removeEventListener("popstate", m), window.removeEventListener("hashchange", m), window.removeEventListener("beforeunload", v), window.removeEventListener("pagehide", y), window.removeEventListener("visibilitychange", p);
|
|
@@ -2784,7 +2784,7 @@ async function Mr(e, t = {}) {
|
|
|
2784
2784
|
} catch {}
|
|
2785
2785
|
return !0;
|
|
2786
2786
|
}
|
|
2787
|
-
return n && Dr(n), r ||
|
|
2787
|
+
return n && Dr(n), r || Fe(), window.location.assign(i.href), !0;
|
|
2788
2788
|
} catch (t) {
|
|
2789
2789
|
console.warn("[FlowEngage] shadowNavigate error:", t), n && Dr(n);
|
|
2790
2790
|
try {
|
|
@@ -2868,36 +2868,36 @@ function Wr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
2868
2868
|
let i = f(() => e ? {
|
|
2869
2869
|
...t || {},
|
|
2870
2870
|
siteId: e
|
|
2871
|
-
} : t || null, [e, t]), [a, s] = m(0), [l, u] = m("booting"), [d, h] = m(null), [_, v] = m(null), [y, b] = m(""), [x, S] = m([]), [C, w] = m(
|
|
2871
|
+
} : t || null, [e, t]), [a, s] = m(0), [l, u] = m("booting"), [d, h] = m(null), [_, v] = m(null), [y, b] = m(""), [x, S] = m([]), [C, w] = m(_e().isOpen), [T, E] = m(_e().activeScreen), [te, ne] = m(_e().isHumanHandled), [D, O] = m(_e().agentName), [oe, ue] = m(_e().agentHeadshot), [de, fe] = m(() => ye(i?.siteId)), [pe, xe] = m(!1), [Se, Ce] = m(!1), [Te, Ee] = m("idle"), [De, Oe] = m(!1), [k, ke] = m(!1), [Ae, je] = m(""), [Ne, Pe] = m(!1), [Fe, Ie] = m(0), [Le, Re] = m(0), [ze, Be] = m(!1), [A, Ve] = m(null), [Ge, Ke] = m(null), [qe, Je] = m("idle"), [Ye, Xe] = m(null), [Ze, Qe] = m(!1), [$e, et] = m(""), [tt, nt] = m(!1), rt = p(null), j = p(null), it = p(""), at = p(!1), ot = p(null), st = p(null), ct = p(null), lt = p(null), ut = p(null), M = p(null), dt = p(null), ft = p(!1), pt = p([]), mt = p(null), N = p(null), ht = p(null), gt = p(!1), _t = p(!1), vt = p(""), yt = p(null), bt = p(null), xt = p([]), St = p(0), Ct = p(D), wt = p([]), Tt = p(!1), Et = p(!1), Dt = p(i), Ot = p({
|
|
2872
2872
|
notifyRouteChange: () => {},
|
|
2873
2873
|
cleanup: () => {}
|
|
2874
2874
|
}), kt = o((e = {}) => {
|
|
2875
2875
|
let t = !!e.is_human_handled;
|
|
2876
|
-
return
|
|
2876
|
+
return ne(t), t ? (E("agent"), e.agent_info?.name && O(e.agent_info.name), e.agent_info?.headshot && ue(e.agent_info.headshot), t) : (E("ai"), t);
|
|
2877
2877
|
}, []), At = f(() => {
|
|
2878
2878
|
let e = _?.widgetSettings?.call?.maxDurationSeconds ?? i?.widgetSettings?.call?.maxDurationSeconds ?? i?.callMaxDurationSeconds, t = Number(e);
|
|
2879
|
-
return Number.isFinite(t) && t > 0 ? t :
|
|
2879
|
+
return Number.isFinite(t) && t > 0 ? t : ie;
|
|
2880
2880
|
}, [i, _]);
|
|
2881
2881
|
c(() => {
|
|
2882
|
-
st.current =
|
|
2883
|
-
}, [
|
|
2884
|
-
Ct.current =
|
|
2885
|
-
}, [
|
|
2886
|
-
Et.current =
|
|
2887
|
-
}, [
|
|
2882
|
+
st.current = A;
|
|
2883
|
+
}, [A]), c(() => {
|
|
2884
|
+
Ct.current = D;
|
|
2885
|
+
}, [D]), c(() => {
|
|
2886
|
+
Et.current = Ne;
|
|
2887
|
+
}, [Ne]), c(() => {
|
|
2888
2888
|
Dt.current = i;
|
|
2889
2889
|
}, [i]);
|
|
2890
2890
|
let jt = () => {
|
|
2891
|
-
|
|
2891
|
+
et("");
|
|
2892
2892
|
}, Mt = o(() => {
|
|
2893
2893
|
ht.current &&= (window.clearTimeout(ht.current), null);
|
|
2894
2894
|
}, []), Nt = (e) => {
|
|
2895
2895
|
let t = typeof e == "string" ? e.trim().toLowerCase() : "";
|
|
2896
|
-
return
|
|
2896
|
+
return fe(t), be(t, i?.siteId), t;
|
|
2897
2897
|
};
|
|
2898
2898
|
c(() => {
|
|
2899
2899
|
let e = i?.siteId;
|
|
2900
|
-
e &&
|
|
2900
|
+
e && fe(ye(e));
|
|
2901
2901
|
}, [i?.siteId]);
|
|
2902
2902
|
let Pt = (e = "unspecified") => {
|
|
2903
2903
|
let t = mt.current || M.current?.callId, n = St.current, r = yt.current;
|
|
@@ -2927,9 +2927,9 @@ function Wr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
2927
2927
|
} catch {}
|
|
2928
2928
|
bt.current = null;
|
|
2929
2929
|
}
|
|
2930
|
-
ct.current &&= (ct.current.close(), null), lt.current &&= (lt.current.getTracks().forEach((e) => e.stop()), null), ut.current &&= (ut.current.srcObject = null, ut.current.remove(), null), Mt(), M.current = null, pt.current = [], mt.current = null, N.current = null, gt.current = !1,
|
|
2930
|
+
ct.current &&= (ct.current.close(), null), lt.current &&= (lt.current.getTracks().forEach((e) => e.stop()), null), ut.current &&= (ut.current.srcObject = null, ut.current.remove(), null), Mt(), M.current = null, pt.current = [], mt.current = null, N.current = null, gt.current = !1, Qe(!1), Ve(null), Ke(null), Je("idle"), Xe(null);
|
|
2931
2931
|
}, Ft = (e = (/* @__PURE__ */ new Date()).toISOString()) => {
|
|
2932
|
-
let t =
|
|
2932
|
+
let t = rt.current, n = mt.current || M.current?.callId;
|
|
2933
2933
|
if (!(!t?.connected || !n || gt.current)) {
|
|
2934
2934
|
gt.current = !0, t.emit("call:connected", {
|
|
2935
2935
|
callId: n,
|
|
@@ -2979,11 +2979,11 @@ function Wr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
2979
2979
|
if (!e.callId) return;
|
|
2980
2980
|
let t = N.current === e.callId, n = mt.current === e.callId, r = st.current?.callId === e.callId;
|
|
2981
2981
|
if (!(!t && !n && !r)) {
|
|
2982
|
-
if (Mt(),
|
|
2983
|
-
mt.current = e.callId,
|
|
2982
|
+
if (Mt(), Ve(null), t || n) {
|
|
2983
|
+
mt.current = e.callId, Ke(e.callId), Je((e) => e === "connected" ? e : "connecting"), w(!0);
|
|
2984
2984
|
return;
|
|
2985
2985
|
}
|
|
2986
|
-
|
|
2986
|
+
Je("idle");
|
|
2987
2987
|
}
|
|
2988
2988
|
}, Lt = (e = {}) => {
|
|
2989
2989
|
if (!e.callId) return;
|
|
@@ -2993,10 +2993,10 @@ function Wr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
2993
2993
|
Pt();
|
|
2994
2994
|
return;
|
|
2995
2995
|
}
|
|
2996
|
-
N.current = null, M.current = null, pt.current = [],
|
|
2996
|
+
N.current = null, M.current = null, pt.current = [], Ve(null), Je("idle");
|
|
2997
2997
|
}
|
|
2998
2998
|
}, Rt = async (e = {}) => {
|
|
2999
|
-
let t = ct.current, n =
|
|
2999
|
+
let t = ct.current, n = rt.current, r = e.sdpOffer || e.offer?.sdp;
|
|
3000
3000
|
if (!t || !n?.connected || !r || !e.callId) {
|
|
3001
3001
|
console.log("[FlowEngageProvider] deferring remote offer until peer/socket ready", {
|
|
3002
3002
|
callId: e.callId,
|
|
@@ -3027,44 +3027,44 @@ function Wr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3027
3027
|
});
|
|
3028
3028
|
};
|
|
3029
3029
|
c(() => {
|
|
3030
|
-
|
|
3030
|
+
ve({
|
|
3031
3031
|
isOpen: C,
|
|
3032
3032
|
activeScreen: T,
|
|
3033
|
-
isHumanHandled:
|
|
3034
|
-
agentName:
|
|
3035
|
-
agentHeadshot:
|
|
3033
|
+
isHumanHandled: te,
|
|
3034
|
+
agentName: D,
|
|
3035
|
+
agentHeadshot: oe
|
|
3036
3036
|
});
|
|
3037
3037
|
}, [
|
|
3038
3038
|
C,
|
|
3039
3039
|
T,
|
|
3040
|
-
|
|
3041
|
-
|
|
3042
|
-
|
|
3040
|
+
te,
|
|
3041
|
+
D,
|
|
3042
|
+
oe
|
|
3043
3043
|
]), c(() => {
|
|
3044
3044
|
let e = !0;
|
|
3045
3045
|
return (async () => {
|
|
3046
|
-
|
|
3046
|
+
nt(!0);
|
|
3047
3047
|
try {
|
|
3048
|
-
let t = ee(i), n = await
|
|
3048
|
+
let t = ee(i), n = await Ue(t);
|
|
3049
3049
|
if (!e) return;
|
|
3050
|
-
let a = t.siteId, o =
|
|
3050
|
+
let a = t.siteId, o = me(a), s = we(a), c = "";
|
|
3051
3051
|
try {
|
|
3052
3052
|
let e = at.current, r = ot.current;
|
|
3053
|
-
if (at.current = !1, ot.current = null, c = (await
|
|
3053
|
+
if (at.current = !1, ot.current = null, c = (await He({
|
|
3054
3054
|
apiBaseUrl: t.apiBaseUrl,
|
|
3055
3055
|
userId: n.userId,
|
|
3056
3056
|
siteId: a,
|
|
3057
|
-
priorChatId: e || r ? null : o ||
|
|
3057
|
+
priorChatId: e || r ? null : o || se(),
|
|
3058
3058
|
forceNew: e,
|
|
3059
3059
|
resumeChatId: r,
|
|
3060
3060
|
visitorId: s
|
|
3061
3061
|
}))?.data?.chatId, !c) throw Error("resolve-session returned no chatId");
|
|
3062
|
-
|
|
3062
|
+
ce(), ge(a, c);
|
|
3063
3063
|
} catch (e) {
|
|
3064
|
-
console.warn("[FlowEngageProvider] resolve-session failed, reusing persisted or ephemeral chat id", e?.message || e), c = o ||
|
|
3064
|
+
console.warn("[FlowEngageProvider] resolve-session failed, reusing persisted or ephemeral chat id", e?.message || e), c = o || le(), ge(a, c);
|
|
3065
3065
|
}
|
|
3066
3066
|
it.current = c;
|
|
3067
|
-
let l =
|
|
3067
|
+
let l = We({
|
|
3068
3068
|
apiBaseUrl: t.apiBaseUrl,
|
|
3069
3069
|
userId: n.userId,
|
|
3070
3070
|
siteId: t.siteId,
|
|
@@ -3080,20 +3080,20 @@ function Wr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3080
3080
|
chatId: c,
|
|
3081
3081
|
siteId: t.siteId
|
|
3082
3082
|
});
|
|
3083
|
-
|
|
3084
|
-
|
|
3083
|
+
rt.current = f, f.on("connect", () => {
|
|
3084
|
+
Ee("connected");
|
|
3085
3085
|
}), f.on("disconnect", () => {
|
|
3086
|
-
|
|
3086
|
+
Ee("disconnected");
|
|
3087
3087
|
}), f.on("aiTyping", () => {
|
|
3088
|
-
|
|
3088
|
+
Ce(!0);
|
|
3089
3089
|
}), f.on("ai:typing", () => {
|
|
3090
|
-
|
|
3090
|
+
Ce(!0);
|
|
3091
3091
|
}), f.on("messageReceived", (e) => {
|
|
3092
3092
|
let t = e.message || e, n = {
|
|
3093
3093
|
...t,
|
|
3094
3094
|
message: Lr(t.message)
|
|
3095
3095
|
};
|
|
3096
|
-
|
|
3096
|
+
Ce(!1), xe(!1), !(n.type === "call_recording" || typeof n.message == "string" && n.message.includes("AI chat recording")) && S((e) => [...e.filter((e) => !e.isPending), {
|
|
3097
3097
|
...n,
|
|
3098
3098
|
isPending: !1,
|
|
3099
3099
|
id: n.messageId || `${n.sender}-${Date.now()}-${Math.random()}`
|
|
@@ -3111,7 +3111,7 @@ function Wr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3111
3111
|
...t,
|
|
3112
3112
|
message: Lr(t.message)
|
|
3113
3113
|
};
|
|
3114
|
-
|
|
3114
|
+
Ce(!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") && xe(!1), S((e) => n.sender === "bot" || n.sender === "ai" ? [...e, {
|
|
3115
3115
|
...n,
|
|
3116
3116
|
isPending: !1,
|
|
3117
3117
|
id: n.messageId || `${n.sender}-${Date.now()}-${Math.random()}`
|
|
@@ -3123,11 +3123,11 @@ function Wr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3123
3123
|
...n,
|
|
3124
3124
|
isPending: !1,
|
|
3125
3125
|
id: n.messageId || `${n.sender}-${Date.now()}-${Math.random()}`
|
|
3126
|
-
}]), (n.sender === "agent" || n.agent_name) && (
|
|
3126
|
+
}]), (n.sender === "agent" || n.agent_name) && (ne(!0), E("agent"), O(Hr([
|
|
3127
3127
|
n.agent_name,
|
|
3128
3128
|
n.agentName,
|
|
3129
3129
|
n.metadata?.agentName
|
|
3130
|
-
], d)), n.sender_headshot &&
|
|
3130
|
+
], d)), n.sender_headshot && ue(n.sender_headshot), w(!0), Ie((e) => e + 1)));
|
|
3131
3131
|
});
|
|
3132
3132
|
let p = (e = {}) => {
|
|
3133
3133
|
let t = Hr([
|
|
@@ -3136,7 +3136,7 @@ function Wr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3136
3136
|
e.agent_name,
|
|
3137
3137
|
Ct.current
|
|
3138
3138
|
], d);
|
|
3139
|
-
|
|
3139
|
+
ne(!0), E("agent"), O(t), ue(e.agent?.headshot || null), w(!0), Ie((e) => e + 1), S((e) => Ur(e, {
|
|
3140
3140
|
id: `agent-joined-${Date.now()}`,
|
|
3141
3141
|
sender: "system",
|
|
3142
3142
|
message: `${t} has joined the chat.`,
|
|
@@ -3150,7 +3150,7 @@ function Wr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3150
3150
|
e.agent_name,
|
|
3151
3151
|
Ct.current
|
|
3152
3152
|
], d);
|
|
3153
|
-
|
|
3153
|
+
ne(!1), E("ai"), S((e) => Ur(e, {
|
|
3154
3154
|
id: `agent-left-${Date.now()}`,
|
|
3155
3155
|
sender: "system",
|
|
3156
3156
|
message: `${t} has left the chat.`,
|
|
@@ -3159,7 +3159,7 @@ function Wr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3159
3159
|
}));
|
|
3160
3160
|
};
|
|
3161
3161
|
f.on("agent:joined", p), f.on("agentJoined", p), f.on("agent:left", m), f.on("agentLeft", m), f.on("conversationEnded", (e) => {
|
|
3162
|
-
|
|
3162
|
+
Be(!0);
|
|
3163
3163
|
let t = e?.message || "This conversation has ended. Thank you for reaching out!";
|
|
3164
3164
|
S((e) => [...e, {
|
|
3165
3165
|
id: `conversation-ended-${Date.now()}`,
|
|
@@ -3170,15 +3170,15 @@ function Wr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3170
3170
|
}]);
|
|
3171
3171
|
}), f.on("chat:history_update", (e) => {
|
|
3172
3172
|
let t = Rr(e.chat_history || []);
|
|
3173
|
-
S(t), t.length === 0 && (
|
|
3173
|
+
S(t), t.length === 0 && (Be(!1), ne(!1), E("ai"), Ce(!1), xe(!1));
|
|
3174
3174
|
}), f.on("conversation:reset", () => {
|
|
3175
|
-
S([]),
|
|
3175
|
+
S([]), Be(!1), ne(!1), E("ai"), Ce(!1), xe(!1);
|
|
3176
3176
|
}), f.on("voice:end_session", (e = {}) => {
|
|
3177
|
-
console.log("[FlowEngageProvider] voice:end_session received — ending ElevenLabs session"),
|
|
3177
|
+
console.log("[FlowEngageProvider] voice:end_session received — ending ElevenLabs session"), Re((e) => e + 1), w(!0), Ie((e) => e + 1);
|
|
3178
3178
|
}), f.on("typing:start", (e) => {
|
|
3179
|
-
e.sender === "agent" &&
|
|
3179
|
+
e.sender === "agent" && xe(!0);
|
|
3180
3180
|
}), f.on("typing:stop", (e) => {
|
|
3181
|
-
e.sender === "agent" &&
|
|
3181
|
+
e.sender === "agent" && xe(!1);
|
|
3182
3182
|
}), f.on("call:incoming", (e = {}) => {
|
|
3183
3183
|
let t = Hr([
|
|
3184
3184
|
e.agentName,
|
|
@@ -3186,12 +3186,12 @@ function Wr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3186
3186
|
e.agent?.name,
|
|
3187
3187
|
Ct.current
|
|
3188
3188
|
], "Agent");
|
|
3189
|
-
jt(), Mt(), gt.current = !1,
|
|
3189
|
+
jt(), Mt(), gt.current = !1, Ve({
|
|
3190
3190
|
callId: e.callId,
|
|
3191
3191
|
from: e.from || "owner",
|
|
3192
3192
|
agentId: e.agentId || null,
|
|
3193
3193
|
agentName: t
|
|
3194
|
-
}),
|
|
3194
|
+
}), O((e) => Hr([t, e], "Agent")), Je("incoming"), Xe(null), w(!0);
|
|
3195
3195
|
}), f.on("call:offer", async (e = {}) => {
|
|
3196
3196
|
M.current = e;
|
|
3197
3197
|
try {
|
|
@@ -3234,14 +3234,14 @@ function Wr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3234
3234
|
if (!e.callId) return;
|
|
3235
3235
|
let t = N.current === e.callId, n = mt.current === e.callId, r = M.current?.callId === e.callId, i = st.current?.callId === e.callId;
|
|
3236
3236
|
if (!t && !n && !r) {
|
|
3237
|
-
i && (
|
|
3237
|
+
i && (Ve(null), Je("idle"));
|
|
3238
3238
|
return;
|
|
3239
3239
|
}
|
|
3240
|
-
gt.current = !0, N.current = null, mt.current = e.callId,
|
|
3240
|
+
gt.current = !0, N.current = null, mt.current = e.callId, Ke(e.callId), Ve(null), Je("connected"), Xe(e.connectedAt || (/* @__PURE__ */ new Date()).toISOString()), w(!0);
|
|
3241
3241
|
}), f.on("call:unavailable", (e = {}) => {
|
|
3242
|
-
Pt("socket:call_unavailable"),
|
|
3242
|
+
Pt("socket:call_unavailable"), et(Br(e, "This visitor is not available for a call right now.")), w(!0);
|
|
3243
3243
|
}), f.on("call:error", (e = {}) => {
|
|
3244
|
-
Pt("socket:call_error"),
|
|
3244
|
+
Pt("socket:call_error"), et(Br(e, "We couldn't connect the call right now.")), w(!0);
|
|
3245
3245
|
}), f.on("visitor:navigate", async ({ url: e, section: n, highlight: r } = {}) => {
|
|
3246
3246
|
e && await Er(e, {
|
|
3247
3247
|
siteId: t.siteId,
|
|
@@ -3265,7 +3265,7 @@ function Wr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3265
3265
|
});
|
|
3266
3266
|
let h = await l.loadHistory(c, r);
|
|
3267
3267
|
if (!e) return;
|
|
3268
|
-
S(Rr(h.chat_history || [])),
|
|
3268
|
+
S(Rr(h.chat_history || [])), ne(!!h.is_human_handled), E(h.is_human_handled ? "agent" : T);
|
|
3269
3269
|
let g = h?.visitor_email || h?.visitorEmail;
|
|
3270
3270
|
if (g && String(g).trim() && Nt(String(g).trim()), await new Promise((e) => setTimeout(e, 500)), !e) return;
|
|
3271
3271
|
u("ready");
|
|
@@ -3273,21 +3273,21 @@ function Wr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3273
3273
|
if (!e) return;
|
|
3274
3274
|
h(t), u("error");
|
|
3275
3275
|
} finally {
|
|
3276
|
-
e &&
|
|
3276
|
+
e && nt(!1);
|
|
3277
3277
|
}
|
|
3278
3278
|
})(), () => {
|
|
3279
|
-
e = !1, Ot.current?.cleanup?.(), Pt(),
|
|
3279
|
+
e = !1, Ot.current?.cleanup?.(), Pt(), rt.current?.disconnect();
|
|
3280
3280
|
};
|
|
3281
3281
|
}, [
|
|
3282
3282
|
i,
|
|
3283
3283
|
r,
|
|
3284
3284
|
a
|
|
3285
3285
|
]), c(() => () => {
|
|
3286
|
-
if (
|
|
3286
|
+
if (Ne && !Tt.current && wt.current.length > 0) {
|
|
3287
3287
|
let e = it.current, t = wt.current, n = j.current;
|
|
3288
3288
|
n && e && t.length > 0 && (console.log("[FlowEngageProvider] safety-net: syncing voice transcript on unmount"), n.beaconSyncVoice(e, t) || n.syncVoice(e, t).catch(() => {}), Tt.current = !0);
|
|
3289
3289
|
}
|
|
3290
|
-
}, [
|
|
3290
|
+
}, [Ne, _]);
|
|
3291
3291
|
let zt = p(null), Bt = p(!1);
|
|
3292
3292
|
c(() => {
|
|
3293
3293
|
let e = j.current;
|
|
@@ -3303,7 +3303,7 @@ function Wr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3303
3303
|
let e = window.setInterval(async () => {
|
|
3304
3304
|
try {
|
|
3305
3305
|
let e = await j.current.checkHumanHandled(y);
|
|
3306
|
-
|
|
3306
|
+
ne(!!e.is_human_handled), e.is_human_handled && (E("agent"), e.agent_info?.name && O(Hr([e.agent_info.name], "Agent")), e.agent_info?.headshot && ue(e.agent_info.headshot)), kt(e);
|
|
3307
3307
|
} catch {}
|
|
3308
3308
|
}, 1e4);
|
|
3309
3309
|
return () => window.clearInterval(e);
|
|
@@ -3313,8 +3313,8 @@ function Wr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3313
3313
|
kt
|
|
3314
3314
|
]);
|
|
3315
3315
|
let Vt = async () => {
|
|
3316
|
-
if (!(!
|
|
3317
|
-
jt(), N.current =
|
|
3316
|
+
if (!(!A?.callId || !j.current || !rt.current || !y)) {
|
|
3317
|
+
jt(), N.current = A.callId, Mt();
|
|
3318
3318
|
try {
|
|
3319
3319
|
let e = await navigator.mediaDevices.getUserMedia({ audio: !0 });
|
|
3320
3320
|
lt.current = e;
|
|
@@ -3330,11 +3330,11 @@ function Wr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3330
3330
|
let e = n.connectionState;
|
|
3331
3331
|
if (e === "connected") {
|
|
3332
3332
|
let e = (/* @__PURE__ */ new Date()).toISOString();
|
|
3333
|
-
|
|
3333
|
+
Je("connected"), Xe((t) => t || e), Ft(e);
|
|
3334
3334
|
return;
|
|
3335
3335
|
}
|
|
3336
3336
|
if (e === "connecting") {
|
|
3337
|
-
|
|
3337
|
+
Je((e) => e === "connected" ? e : "connecting");
|
|
3338
3338
|
return;
|
|
3339
3339
|
}
|
|
3340
3340
|
(e === "failed" || e === "closed") && Pt(`peer:connection_${e}`);
|
|
@@ -3342,21 +3342,21 @@ function Wr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3342
3342
|
let e = n.iceConnectionState;
|
|
3343
3343
|
if (e === "connected" || e === "completed") {
|
|
3344
3344
|
let e = (/* @__PURE__ */ new Date()).toISOString();
|
|
3345
|
-
|
|
3345
|
+
Je("connected"), Xe((t) => t || e), Ft(e);
|
|
3346
3346
|
return;
|
|
3347
3347
|
}
|
|
3348
3348
|
if (e === "checking" || e === "new") {
|
|
3349
|
-
|
|
3349
|
+
Je((e) => e === "connected" ? e : "connecting");
|
|
3350
3350
|
return;
|
|
3351
3351
|
}
|
|
3352
3352
|
(e === "failed" || e === "closed") && Pt(`peer:ice_${e}`);
|
|
3353
3353
|
}, n.onsignalingstatechange = () => {}, n.onicegatheringstatechange = () => {}, e.getTracks().forEach((t) => {
|
|
3354
3354
|
n.addTrack(t, e);
|
|
3355
3355
|
}), n.onicecandidate = (e) => {
|
|
3356
|
-
if (!e.candidate || !
|
|
3356
|
+
if (!e.candidate || !rt.current?.connected) return;
|
|
3357
3357
|
let t = e.candidate;
|
|
3358
|
-
|
|
3359
|
-
callId:
|
|
3358
|
+
rt.current.emit("call:ice-candidate", {
|
|
3359
|
+
callId: A.callId,
|
|
3360
3360
|
candidate: t.candidate,
|
|
3361
3361
|
sdpMid: t.sdpMid,
|
|
3362
3362
|
sdpMLineIndex: t.sdpMLineIndex,
|
|
@@ -3370,10 +3370,10 @@ function Wr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3370
3370
|
e.id = "flowengage-remote-audio", e.autoplay = !0, e.playsInline = !0, e.onplay = () => {}, e.onpause = () => {}, e.onended = () => {}, e.onerror = (e) => {}, ut.current = e, document.body.appendChild(e);
|
|
3371
3371
|
}
|
|
3372
3372
|
ut.current.srcObject = e.streams[0];
|
|
3373
|
-
let r =
|
|
3373
|
+
let r = A?.callId, i = r && (N.current === r || mt.current === r);
|
|
3374
3374
|
if (!gt.current && i) {
|
|
3375
3375
|
let e = (/* @__PURE__ */ new Date()).toISOString();
|
|
3376
|
-
|
|
3376
|
+
Je("connected"), Xe((t) => t || e), mt.current = r, Ke(r), Ft(e);
|
|
3377
3377
|
}
|
|
3378
3378
|
ut.current.srcObject = t || null;
|
|
3379
3379
|
let a = ut.current.play?.();
|
|
@@ -3381,39 +3381,39 @@ function Wr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3381
3381
|
};
|
|
3382
3382
|
let r = M.current;
|
|
3383
3383
|
r && (console.log("[FlowEngageProvider] found pending remote offer during accept", {
|
|
3384
|
-
callId: r.callId ||
|
|
3384
|
+
callId: r.callId || A.callId,
|
|
3385
3385
|
chatId: y
|
|
3386
3386
|
}), await Rt({
|
|
3387
3387
|
...r,
|
|
3388
|
-
callId: r.callId ||
|
|
3389
|
-
})), await j.current.acceptCall(
|
|
3390
|
-
callId:
|
|
3388
|
+
callId: r.callId || A.callId
|
|
3389
|
+
})), await j.current.acceptCall(A.callId, y), rt.current?.emit("call:accepted", {
|
|
3390
|
+
callId: A.callId,
|
|
3391
3391
|
chatId: y
|
|
3392
|
-
}), mt.current =
|
|
3392
|
+
}), mt.current = A.callId, Ke(A.callId), Je((e) => e === "connected" || gt.current ? "connected" : "connecting"), Ve(null), w(!0);
|
|
3393
3393
|
} catch (e) {
|
|
3394
3394
|
if (N.current = null, Pt("accept_call_failed"), e?.status === 404 || e?.status === 409 || e?.status === 422) {
|
|
3395
|
-
|
|
3395
|
+
et(Br(e, "This visitor call is no longer available."));
|
|
3396
3396
|
return;
|
|
3397
3397
|
}
|
|
3398
3398
|
if (e?.name === "NotAllowedError" || e?.name === "PermissionDeniedError") {
|
|
3399
3399
|
try {
|
|
3400
|
-
await j.current.rejectCall(
|
|
3400
|
+
await j.current.rejectCall(A.callId, y);
|
|
3401
3401
|
} catch (e) {
|
|
3402
3402
|
console.error("[FlowEngageProvider] failed to reject call after microphone denial", e);
|
|
3403
3403
|
}
|
|
3404
|
-
|
|
3404
|
+
et("Microphone access was denied. Please allow microphone access to accept the call.");
|
|
3405
3405
|
return;
|
|
3406
3406
|
}
|
|
3407
|
-
|
|
3407
|
+
et("We couldn't connect the call right now. Please try again.");
|
|
3408
3408
|
}
|
|
3409
3409
|
}
|
|
3410
3410
|
}, Ht = async () => {
|
|
3411
|
-
if (!
|
|
3411
|
+
if (!A?.callId || !j.current || !y) {
|
|
3412
3412
|
Pt("reject_call_without_server_context");
|
|
3413
3413
|
return;
|
|
3414
3414
|
}
|
|
3415
|
-
let e =
|
|
3416
|
-
Mt(), jt(),
|
|
3415
|
+
let e = A.callId;
|
|
3416
|
+
Mt(), jt(), rt.current?.emit("call:rejected", {
|
|
3417
3417
|
callId: e,
|
|
3418
3418
|
chatId: y,
|
|
3419
3419
|
reason: "visitor_declined"
|
|
@@ -3421,47 +3421,47 @@ function Wr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3421
3421
|
try {
|
|
3422
3422
|
await j.current.rejectCall(e, y);
|
|
3423
3423
|
} catch (e) {
|
|
3424
|
-
|
|
3424
|
+
et(Br(e, "We couldn't decline the call cleanly."));
|
|
3425
3425
|
} finally {
|
|
3426
3426
|
Pt("reject_call_finally");
|
|
3427
3427
|
}
|
|
3428
3428
|
}, Ut = p(Ht);
|
|
3429
3429
|
Ut.current = Ht, c(() => {
|
|
3430
|
-
if (!
|
|
3430
|
+
if (!A?.callId || Ge) {
|
|
3431
3431
|
Mt();
|
|
3432
3432
|
return;
|
|
3433
3433
|
}
|
|
3434
|
-
let e =
|
|
3434
|
+
let e = A.callId;
|
|
3435
3435
|
return Mt(), ht.current = window.setTimeout(() => {
|
|
3436
3436
|
st.current?.callId === e && N.current !== e && mt.current !== e && Ut.current();
|
|
3437
|
-
},
|
|
3437
|
+
}, ae), () => {
|
|
3438
3438
|
ht.current &&= (window.clearTimeout(ht.current), null);
|
|
3439
3439
|
};
|
|
3440
3440
|
}, [
|
|
3441
|
-
|
|
3441
|
+
Ge,
|
|
3442
3442
|
Mt,
|
|
3443
|
-
|
|
3443
|
+
A?.callId
|
|
3444
3444
|
]);
|
|
3445
3445
|
let Wt = async () => {
|
|
3446
|
-
if (!
|
|
3446
|
+
if (!Ge || !j.current || !y) {
|
|
3447
3447
|
Pt("end_call_without_server_context");
|
|
3448
3448
|
return;
|
|
3449
3449
|
}
|
|
3450
3450
|
jt();
|
|
3451
3451
|
try {
|
|
3452
|
-
await j.current.endWebRTCCall(
|
|
3452
|
+
await j.current.endWebRTCCall(Ge, y);
|
|
3453
3453
|
} catch (e) {
|
|
3454
|
-
|
|
3454
|
+
et(Br(e, "The call ended locally, but the server could not be updated."));
|
|
3455
3455
|
} finally {
|
|
3456
3456
|
Pt("end_call_finally");
|
|
3457
3457
|
}
|
|
3458
3458
|
}, Gt = () => {
|
|
3459
3459
|
let e = lt.current?.getAudioTracks?.() || [], t = ct.current?.getSenders?.().map((e) => e.track).filter((e) => e?.kind === "audio") || [], n = [...e, ...t].filter(Boolean);
|
|
3460
3460
|
if (n.length === 0) return;
|
|
3461
|
-
let r = !
|
|
3461
|
+
let r = !Ze;
|
|
3462
3462
|
n.forEach((e) => {
|
|
3463
3463
|
e.enabled = !r;
|
|
3464
|
-
}),
|
|
3464
|
+
}), Qe(r);
|
|
3465
3465
|
}, Kt = async (e = {}) => {
|
|
3466
3466
|
let t = e.notifyChatInitiated === !0;
|
|
3467
3467
|
if (Bt.current = !0, w(!0), !(!t || !j.current || !y || typeof window > "u")) {
|
|
@@ -3489,18 +3489,18 @@ function Wr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3489
3489
|
}
|
|
3490
3490
|
return t;
|
|
3491
3491
|
}, Jt = () => {
|
|
3492
|
-
!y || !
|
|
3492
|
+
!y || !rt.current?.connected || _t.current || (_t.current = !0, rt.current.emit("typing:start", {
|
|
3493
3493
|
chatId: y,
|
|
3494
3494
|
sender: "user"
|
|
3495
3495
|
}));
|
|
3496
3496
|
}, Yt = () => {
|
|
3497
|
-
!y || !
|
|
3497
|
+
!y || !rt.current?.connected || !_t.current || (_t.current = !1, rt.current.emit("typing:stop", {
|
|
3498
3498
|
chatId: y,
|
|
3499
3499
|
sender: "user"
|
|
3500
3500
|
}));
|
|
3501
3501
|
}, Xt = (e = "") => {
|
|
3502
3502
|
let t = typeof e == "string" ? e : "";
|
|
3503
|
-
!y || !
|
|
3503
|
+
!y || !rt.current?.connected || t !== "" && vt.current === t || (vt.current = t, rt.current.emit("typing:update", {
|
|
3504
3504
|
chatId: y,
|
|
3505
3505
|
sender: "user",
|
|
3506
3506
|
text: t
|
|
@@ -3519,7 +3519,7 @@ function Wr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3519
3519
|
}
|
|
3520
3520
|
let Qt = async (e, t = "", n = null, a = {}) => {
|
|
3521
3521
|
let o = typeof e == "string" ? e.trim() : "";
|
|
3522
|
-
if (!o || !j.current || !y || l !== "ready" ||
|
|
3522
|
+
if (!o || !j.current || !y || l !== "ready" || ze) return;
|
|
3523
3523
|
Yt();
|
|
3524
3524
|
let s = /^\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, c = /^\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, u = /\b(take me|navigate|go to|show me|bring me|open|go there|navigate to|take me to|let'?s go to)\b/i;
|
|
3525
3525
|
if (dt.current && s.test(o) && !c.test(o)) {
|
|
@@ -3542,27 +3542,27 @@ function Wr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3542
3542
|
...n || {}
|
|
3543
3543
|
};
|
|
3544
3544
|
S((e) => [...e, f]);
|
|
3545
|
-
let p =
|
|
3545
|
+
let p = te;
|
|
3546
3546
|
if (p) try {
|
|
3547
3547
|
p = kt(await j.current.checkHumanHandled(y));
|
|
3548
3548
|
} catch {}
|
|
3549
|
-
if (p &&
|
|
3550
|
-
|
|
3549
|
+
if (p && rt.current?.connected) {
|
|
3550
|
+
rt.current.emit("customer:message", {
|
|
3551
3551
|
chatId: y,
|
|
3552
3552
|
content: e,
|
|
3553
3553
|
sender: "user",
|
|
3554
|
-
email:
|
|
3554
|
+
email: de || void 0,
|
|
3555
3555
|
type: a?.type || "text",
|
|
3556
3556
|
metadata: a?.metadata || {},
|
|
3557
3557
|
...n || {}
|
|
3558
3558
|
});
|
|
3559
3559
|
return;
|
|
3560
3560
|
}
|
|
3561
|
-
|
|
3561
|
+
Oe(!0);
|
|
3562
3562
|
try {
|
|
3563
3563
|
let s = await j.current.sendAiMessage(y, e, r, t, {
|
|
3564
3564
|
...n || {},
|
|
3565
|
-
...
|
|
3565
|
+
...de ? { email: de } : {}
|
|
3566
3566
|
}, {
|
|
3567
3567
|
...a,
|
|
3568
3568
|
currentPageUrl: typeof window < "u" ? window.location.href : void 0,
|
|
@@ -3620,11 +3620,11 @@ function Wr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3620
3620
|
});
|
|
3621
3621
|
}
|
|
3622
3622
|
}
|
|
3623
|
-
S(Rr(c)),
|
|
3623
|
+
S(Rr(c)), ne(!!s.is_human_handled), E(s.is_human_handled ? "agent" : "ai"), Ce(!1), Oe(!1), await j.current.updateChatStatus(y, "messageSent");
|
|
3624
3624
|
} catch (e) {
|
|
3625
|
-
S((e) => e.filter((e) => e.id !== d)),
|
|
3626
|
-
|
|
3627
|
-
},
|
|
3625
|
+
S((e) => e.filter((e) => e.id !== d)), Ce(!1), Oe(!1), e.status === 429 ? (ke(!0), je(e.message), window.setTimeout(() => {
|
|
3626
|
+
ke(!1), je("");
|
|
3627
|
+
}, re)) : h(e);
|
|
3628
3628
|
}
|
|
3629
3629
|
}, $t = async (e) => {
|
|
3630
3630
|
if (!j.current || !e) throw Error("Upload is unavailable right now.");
|
|
@@ -3635,12 +3635,12 @@ function Wr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3635
3635
|
let t = e ? "voice" : "text";
|
|
3636
3636
|
await j.current.setChatMode(y, t);
|
|
3637
3637
|
} catch {}
|
|
3638
|
-
|
|
3638
|
+
Pe(e), e && (Tt.current = !1);
|
|
3639
3639
|
}
|
|
3640
3640
|
}, tn = async (e) => {
|
|
3641
3641
|
if (Tt.current) return;
|
|
3642
3642
|
if (Tt.current = !0, !j.current || !y || !e?.length) {
|
|
3643
|
-
|
|
3643
|
+
Pe(!1);
|
|
3644
3644
|
return;
|
|
3645
3645
|
}
|
|
3646
3646
|
let t = () => {
|
|
@@ -3664,11 +3664,11 @@ function Wr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3664
3664
|
} catch {
|
|
3665
3665
|
t();
|
|
3666
3666
|
} finally {
|
|
3667
|
-
|
|
3667
|
+
Pe(!1);
|
|
3668
3668
|
}
|
|
3669
3669
|
}, nn = async () => {
|
|
3670
3670
|
if (!(!j.current || !y)) {
|
|
3671
|
-
|
|
3671
|
+
Ne && !Tt.current && wt.current.length > 0 && await tn(wt.current);
|
|
3672
3672
|
try {
|
|
3673
3673
|
await j.current.endConversation(y);
|
|
3674
3674
|
} catch {
|
|
@@ -3676,7 +3676,7 @@ function Wr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3676
3676
|
await j.current.updateChatStatus(y, "ended");
|
|
3677
3677
|
} catch {}
|
|
3678
3678
|
}
|
|
3679
|
-
|
|
3679
|
+
Be(!0), S((e) => [...e, {
|
|
3680
3680
|
id: `conversation-ended-${Date.now()}`,
|
|
3681
3681
|
sender: "system",
|
|
3682
3682
|
message: "This conversation has ended. Thank you for reaching out!",
|
|
@@ -3686,15 +3686,15 @@ function Wr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3686
3686
|
}
|
|
3687
3687
|
};
|
|
3688
3688
|
c(() => {
|
|
3689
|
-
if (
|
|
3690
|
-
let e = new Date(
|
|
3691
|
-
|
|
3689
|
+
if (qe !== "connected" || !Ge || !y || !Ye || !At) return;
|
|
3690
|
+
let e = new Date(Ye).getTime(), t = Number.isFinite(e) ? Date.now() - e : 0, n = Math.max(0, At * 1e3 - t), r = window.setTimeout(() => {
|
|
3691
|
+
et("The call ended because it reached the time limit."), Wt();
|
|
3692
3692
|
}, n);
|
|
3693
3693
|
return () => window.clearTimeout(r);
|
|
3694
3694
|
}, [
|
|
3695
|
-
|
|
3696
|
-
|
|
3697
|
-
|
|
3695
|
+
Ge,
|
|
3696
|
+
Ye,
|
|
3697
|
+
qe,
|
|
3698
3698
|
y,
|
|
3699
3699
|
Wt,
|
|
3700
3700
|
At
|
|
@@ -3702,7 +3702,7 @@ function Wr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3702
3702
|
let e = () => {
|
|
3703
3703
|
let e = it.current, t = j.current;
|
|
3704
3704
|
if (!t || !e) return;
|
|
3705
|
-
if (Et.current && wt.current.length > 0 &&
|
|
3705
|
+
if (Et.current && wt.current.length > 0 && Me(), !Tt.current && wt.current.length > 0 && (t.beaconSyncVoice(e, wt.current) || t.syncVoice(e, wt.current).catch(() => {}), Tt.current = !0), mt.current) {
|
|
3706
3706
|
t.beaconEndWebRTCCall(mt.current, e);
|
|
3707
3707
|
return;
|
|
3708
3708
|
}
|
|
@@ -3715,9 +3715,9 @@ function Wr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3715
3715
|
}, []);
|
|
3716
3716
|
let rn = o(() => {
|
|
3717
3717
|
let e = i?.siteId;
|
|
3718
|
-
|
|
3718
|
+
he(e), at.current = !0, ot.current = null, rt.current?.disconnect(), S([]), b(""), it.current = "", Be(!1), ne(!1), O(null), ue(null), nt(!0), s((e) => e + 1);
|
|
3719
3719
|
}, [i?.siteId]), an = o((e) => {
|
|
3720
|
-
i?.siteId, at.current = !1, ot.current = e,
|
|
3720
|
+
i?.siteId, at.current = !1, ot.current = e, rt.current?.disconnect(), S([]), b(""), it.current = "", Be(!1), ne(!1), O(null), ue(null), nt(!0), s((e) => e + 1);
|
|
3721
3721
|
}, [i?.siteId]), on = f(() => ({
|
|
3722
3722
|
status: l,
|
|
3723
3723
|
error: d,
|
|
@@ -3727,27 +3727,27 @@ function Wr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3727
3727
|
chatHistory: x,
|
|
3728
3728
|
isOpen: C,
|
|
3729
3729
|
activeScreen: T,
|
|
3730
|
-
isHumanHandled:
|
|
3731
|
-
agentName:
|
|
3732
|
-
agentHeadshot:
|
|
3733
|
-
visitorEmail:
|
|
3734
|
-
isAgentTyping:
|
|
3735
|
-
isAiTyping:
|
|
3736
|
-
connectionStatus:
|
|
3737
|
-
isLoading:
|
|
3738
|
-
isVoiceMode:
|
|
3739
|
-
isRateLimited:
|
|
3740
|
-
rateLimitMessage:
|
|
3741
|
-
isConversationEnded:
|
|
3742
|
-
isSessionRestoring:
|
|
3743
|
-
openToChatCounter:
|
|
3744
|
-
voiceEndCounter:
|
|
3745
|
-
incomingCall:
|
|
3746
|
-
activeCallId:
|
|
3747
|
-
callConnectionState:
|
|
3748
|
-
callConnectedAt:
|
|
3749
|
-
isCallMuted:
|
|
3750
|
-
webRTCError:
|
|
3730
|
+
isHumanHandled: te,
|
|
3731
|
+
agentName: D,
|
|
3732
|
+
agentHeadshot: oe,
|
|
3733
|
+
visitorEmail: de,
|
|
3734
|
+
isAgentTyping: pe,
|
|
3735
|
+
isAiTyping: Se,
|
|
3736
|
+
connectionStatus: Te,
|
|
3737
|
+
isLoading: De,
|
|
3738
|
+
isVoiceMode: Ne,
|
|
3739
|
+
isRateLimited: k,
|
|
3740
|
+
rateLimitMessage: Ae,
|
|
3741
|
+
isConversationEnded: ze,
|
|
3742
|
+
isSessionRestoring: tt,
|
|
3743
|
+
openToChatCounter: Fe,
|
|
3744
|
+
voiceEndCounter: Le,
|
|
3745
|
+
incomingCall: A,
|
|
3746
|
+
activeCallId: Ge,
|
|
3747
|
+
callConnectionState: qe,
|
|
3748
|
+
callConnectedAt: Ye,
|
|
3749
|
+
isCallMuted: Ze,
|
|
3750
|
+
webRTCError: $e,
|
|
3751
3751
|
language: r,
|
|
3752
3752
|
historyRef: wt,
|
|
3753
3753
|
hasSyncedRef: Tt,
|
|
@@ -3788,27 +3788,27 @@ function Wr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3788
3788
|
x,
|
|
3789
3789
|
C,
|
|
3790
3790
|
T,
|
|
3791
|
-
|
|
3792
|
-
|
|
3793
|
-
|
|
3794
|
-
|
|
3795
|
-
|
|
3796
|
-
|
|
3797
|
-
|
|
3798
|
-
|
|
3799
|
-
|
|
3800
|
-
O,
|
|
3801
|
-
je,
|
|
3802
|
-
Be,
|
|
3803
|
-
nt,
|
|
3804
|
-
Ie,
|
|
3805
|
-
Re,
|
|
3791
|
+
te,
|
|
3792
|
+
D,
|
|
3793
|
+
oe,
|
|
3794
|
+
de,
|
|
3795
|
+
pe,
|
|
3796
|
+
Se,
|
|
3797
|
+
Te,
|
|
3798
|
+
De,
|
|
3799
|
+
Ne,
|
|
3806
3800
|
k,
|
|
3807
|
-
|
|
3808
|
-
|
|
3809
|
-
|
|
3810
|
-
|
|
3811
|
-
|
|
3801
|
+
Ae,
|
|
3802
|
+
ze,
|
|
3803
|
+
tt,
|
|
3804
|
+
Fe,
|
|
3805
|
+
Le,
|
|
3806
|
+
A,
|
|
3807
|
+
Ge,
|
|
3808
|
+
qe,
|
|
3809
|
+
Ye,
|
|
3810
|
+
Ze,
|
|
3811
|
+
$e,
|
|
3812
3812
|
r,
|
|
3813
3813
|
qt,
|
|
3814
3814
|
Jt,
|
|
@@ -6737,10 +6737,10 @@ function ed(e) {
|
|
|
6737
6737
|
...d,
|
|
6738
6738
|
...C
|
|
6739
6739
|
}), (r || i) && e.blockInitialAnimation && (b = !1);
|
|
6740
|
-
let
|
|
6741
|
-
b && (!
|
|
6740
|
+
let E = v && y;
|
|
6741
|
+
b && (!E || x) && l.push(...S.map((t) => {
|
|
6742
6742
|
let n = { type: p };
|
|
6743
|
-
if (typeof t == "string" && (r || i) && !
|
|
6743
|
+
if (typeof t == "string" && (r || i) && !E && e.manuallyAnimateOnMount && e.parent) {
|
|
6744
6744
|
let { parent: r } = e, i = oc(r, t);
|
|
6745
6745
|
if (r.enteringChildren && i) {
|
|
6746
6746
|
let { delayChildren: t } = i.transition || {};
|
|
@@ -27283,7 +27283,7 @@ function nO({ chatHistory: e, isAiTyping: t, isLoading: n, isAgentTyping: r, set
|
|
|
27283
27283
|
//#endregion
|
|
27284
27284
|
//#region src/components/ChatInput.jsx
|
|
27285
27285
|
function rO({ input: e, setInput: t, onSubmit: n, isConversationEnded: r, callUiActive: i, handleToggleVoice: a, activeScreen: o, inputDisabled: s, replyContext: c, clearReplyContext: l, requiresEmail: u, emailInput: d, setEmailInput: f, emailError: m, showVoiceToggle: v = !1, voiceEnabled: y = !0, onFileSelect: b, selectedFile: x = null, onRemoveSelectedFile: S, attachmentError: C = "", isUploadingAttachment: w = !1, inputPlaceholder: T = "Type your message" }) {
|
|
27286
|
-
let ee = p(null),
|
|
27286
|
+
let ee = p(null), E = c?.sender === "user" ? "You" : c?.sender === "agent" ? "Agent" : "AI Assistant", te = u ? !!d?.trim() : !!e?.trim() || !!x, ne = s || w || !te, D = !u && y && v;
|
|
27287
27287
|
return /* @__PURE__ */ _("div", {
|
|
27288
27288
|
style: {
|
|
27289
27289
|
padding: "0 16px",
|
|
@@ -27316,7 +27316,7 @@ function rO({ input: e, setInput: t, onSubmit: n, isConversationEnded: r, callUi
|
|
|
27316
27316
|
fontWeight: 600,
|
|
27317
27317
|
color: "var(--flowengage-primary)"
|
|
27318
27318
|
},
|
|
27319
|
-
children: ["Replying to ",
|
|
27319
|
+
children: ["Replying to ", E]
|
|
27320
27320
|
}), /* @__PURE__ */ g("div", {
|
|
27321
27321
|
style: {
|
|
27322
27322
|
overflow: "hidden",
|
|
@@ -27467,7 +27467,7 @@ function rO({ input: e, setInput: t, onSubmit: n, isConversationEnded: r, callUi
|
|
|
27467
27467
|
},
|
|
27468
27468
|
onSubmit: n,
|
|
27469
27469
|
children: [
|
|
27470
|
-
|
|
27470
|
+
D ? /* @__PURE__ */ _(h, { children: [/* @__PURE__ */ g("input", {
|
|
27471
27471
|
ref: ee,
|
|
27472
27472
|
type: "file",
|
|
27473
27473
|
accept: YD,
|
|
@@ -27517,7 +27517,7 @@ function rO({ input: e, setInput: t, onSubmit: n, isConversationEnded: r, callUi
|
|
|
27517
27517
|
fontSize: "14px",
|
|
27518
27518
|
outline: "none",
|
|
27519
27519
|
padding: 0,
|
|
27520
|
-
paddingLeft:
|
|
27520
|
+
paddingLeft: D ? "0" : "8px",
|
|
27521
27521
|
color: "#111827",
|
|
27522
27522
|
background: "transparent",
|
|
27523
27523
|
cursor: "text"
|
|
@@ -27548,13 +27548,13 @@ function rO({ input: e, setInput: t, onSubmit: n, isConversationEnded: r, callUi
|
|
|
27548
27548
|
alignItems: "center",
|
|
27549
27549
|
justifyContent: "center",
|
|
27550
27550
|
transition: "opacity 0.2s ease",
|
|
27551
|
-
cursor:
|
|
27552
|
-
opacity:
|
|
27551
|
+
cursor: ne ? "not-allowed" : "pointer",
|
|
27552
|
+
opacity: ne ? .45 : 1,
|
|
27553
27553
|
flexShrink: 0
|
|
27554
27554
|
},
|
|
27555
|
-
disabled:
|
|
27555
|
+
disabled: ne,
|
|
27556
27556
|
onMouseEnter: (e) => {
|
|
27557
|
-
|
|
27557
|
+
ne || (e.currentTarget.style.opacity = "0.85");
|
|
27558
27558
|
},
|
|
27559
27559
|
onMouseLeave: (e) => {
|
|
27560
27560
|
e.currentTarget.style.opacity = "1";
|
|
@@ -29249,10 +29249,10 @@ function ik(e) {
|
|
|
29249
29249
|
sender: "user",
|
|
29250
29250
|
message: e
|
|
29251
29251
|
}]);
|
|
29252
|
-
n &&
|
|
29252
|
+
n && k(t, n);
|
|
29253
29253
|
}
|
|
29254
29254
|
} catch {}
|
|
29255
|
-
|
|
29255
|
+
Me();
|
|
29256
29256
|
let e = a;
|
|
29257
29257
|
try {
|
|
29258
29258
|
e = new URL(a, typeof window < "u" ? window.location.href : "").href;
|
|
@@ -29262,7 +29262,7 @@ function ik(e) {
|
|
|
29262
29262
|
let e = new URL(a, window.location.href).pathname.split("/").filter(Boolean).pop() || "";
|
|
29263
29263
|
n = e ? e.replace(/[-_]/g, " ").replace(/\b\w/g, (e) => e.toUpperCase()) : "Home";
|
|
29264
29264
|
} catch {}
|
|
29265
|
-
t && typeof window < "u" &&
|
|
29265
|
+
t && typeof window < "u" && ze(t, window.location.href, e, n), kr(e), $("fwh-navigate-mvp → real navigation", a);
|
|
29266
29266
|
let i = typeof window < "u" && !!or();
|
|
29267
29267
|
if (typeof window < "u" && window.__fe_triggerVoiceNavHooks && window.__fe_triggerVoiceNavHooks(), i && Zn(12e3), Mr(a, { voiceActive: !0 }).catch(() => {}), i) try {
|
|
29268
29268
|
let e = new URL(a, window.location.origin).pathname, t = Date.now() + 2e3;
|
|
@@ -29457,6 +29457,7 @@ function ik(e) {
|
|
|
29457
29457
|
return $("fwh-list-nav-links-mvp ✓", `${t.length} links`), `NAV_LINKS (${t.length} total, showing up to 50):\n${r}\n\nIMPORTANT: Use the EXACT text shown above when reading link names to the visitor. Do NOT rename, abbreviate, or invent options not listed here. To navigate, call fwh-navigate-mvp with the href value.`;
|
|
29458
29458
|
},
|
|
29459
29459
|
"fwh-end-session-mvp": async () => ($("fwh-end-session-mvp ▶"), typeof e.requestEndSession == "function" && e.requestEndSession(), "Voice session is ending."),
|
|
29460
|
+
"fwh-request-email-mvp": async () => ($("fwh-request-email-mvp ▶"), typeof e.requestEmailCollection == "function" && e.requestEmailCollection(), "EMAIL_BOX_SHOWN. An email input text box is now visible to the visitor. Say EXACTLY: \"Please enter your email in the text box to continue.\" Then stop and wait silently — do NOT ask them to say it aloud, do NOT repeat, and do NOT answer any other question until you receive the EMAIL_SAVED message."),
|
|
29460
29461
|
"fwh-get-current-page-mvp": async () => {
|
|
29461
29462
|
if ($("fwh-get-current-page-mvp ▶"), typeof window > "u") return "Cannot determine current page (no browser context).";
|
|
29462
29463
|
let e = window.location.href, t = window.location.pathname, n = document.title || "", r = nk();
|
|
@@ -29944,27 +29945,44 @@ function hk({ copy: e, orbColors: t, primaryColor: n, onVoice: r, onText: i, onC
|
|
|
29944
29945
|
]
|
|
29945
29946
|
});
|
|
29946
29947
|
}
|
|
29947
|
-
function gk({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i, apiBaseUrl: a, chatId: s, historyRef: l, onMessageSync: u, voiceEndCounter: d, websiteName: f, voiceFirstMessage: h }) {
|
|
29948
|
+
function gk({ 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 }) {
|
|
29948
29949
|
c(() => (console.log("[FlowEngage:VoiceDebug] 🔵 VoiceMode MOUNTED"), () => console.log("[FlowEngage:VoiceDebug] 🔴 VoiceMode UNMOUNTED")), []);
|
|
29949
|
-
let [
|
|
29950
|
+
let [y, b] = m("idle"), [x, S] = m(!1), [C, w] = m(!1), [T, ee] = m(!1), [E, te] = m(""), [ne, D] = m(""), re = p(!1), ie = p(!1), ae = p(null), O = p(0), oe = p(null), se = p(""), ce = p(async () => {}), le = p(!1), ue = p(!1), de = p(!1), fe = p(!1), pe = p("minimized"), me = p(null), he = p(null), ge = p(null), _e = p(0), ve = p(!1), ye = p("idle"), be = p(!1), xe = p(!1), Se = p(null), Ce = p(null), we = p(!1), Te = o((e = "minimized") => {
|
|
29950
29951
|
console.warn("[FlowEngage:VoiceDebug] 🛑 requestSessionShutdown called", {
|
|
29951
29952
|
destination: e,
|
|
29952
29953
|
stack: (/* @__PURE__ */ Error()).stack?.split("\n").slice(1, 4).join(" | ")
|
|
29953
|
-
}),
|
|
29954
|
-
|
|
29955
|
-
});
|
|
29956
|
-
}, [l]),
|
|
29957
|
-
|
|
29954
|
+
}), pe.current = e, fe.current = !0, queueMicrotask(() => {
|
|
29955
|
+
le.current || (le.current = !0, ce.current?.());
|
|
29956
|
+
});
|
|
29957
|
+
}, [l]), Ee = o(() => {
|
|
29958
|
+
ae.current &&= (clearTimeout(ae.current), null);
|
|
29959
|
+
}, []), De = o(() => {
|
|
29960
|
+
Ee(), ae.current = setTimeout(() => {
|
|
29961
|
+
if (!(!ie.current || re.current)) if (O.current < 3) {
|
|
29962
|
+
O.current += 1;
|
|
29963
|
+
try {
|
|
29964
|
+
oe.current?.sendUserMessage?.("[SYSTEM: The visitor still has NOT entered their email in the text box. Remind them once, briefly and warmly: 'I still need your email in the box below to continue — could you enter it, please?' Then stay completely silent again. Do NOT answer any other question until the email is provided.]");
|
|
29965
|
+
} catch {}
|
|
29966
|
+
De();
|
|
29967
|
+
} else {
|
|
29968
|
+
try {
|
|
29969
|
+
oe.current?.sendUserMessage?.("[SYSTEM: The visitor did not provide their email after multiple reminders. Say a brief, warm goodbye EXACTLY like: 'Since I haven't received your email, I'll close this session for now. Feel free to come back anytime — take care!' Then stop talking. Do NOT ask for the email again.]");
|
|
29970
|
+
} catch {}
|
|
29971
|
+
ie.current = !1, ee(!1), Ee(), ve.current = !0;
|
|
29972
|
+
}
|
|
29973
|
+
}, 2e4);
|
|
29974
|
+
}, [Ee]), Oe = o(async (e) => {
|
|
29975
|
+
fe.current = !0;
|
|
29958
29976
|
try {
|
|
29959
29977
|
Bn();
|
|
29960
29978
|
} catch {}
|
|
29961
29979
|
if (i) try {
|
|
29962
|
-
|
|
29980
|
+
Be(i);
|
|
29963
29981
|
} catch {}
|
|
29964
29982
|
try {
|
|
29965
|
-
await
|
|
29983
|
+
await oe.current?.endSession?.();
|
|
29966
29984
|
} catch {}
|
|
29967
|
-
let t =
|
|
29985
|
+
let t = me.current, n = he.current;
|
|
29968
29986
|
if (t && s && a) {
|
|
29969
29987
|
let e = n ? Math.round((Date.now() - n) / 1e3) : 0;
|
|
29970
29988
|
fetch(`${a}/api/voice/save-chat-recording`, {
|
|
@@ -29978,8 +29996,8 @@ function gk({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
29978
29996
|
})
|
|
29979
29997
|
}).catch((e) => console.warn("[FlowEngage] save-chat-recording failed:", e.message));
|
|
29980
29998
|
}
|
|
29981
|
-
if (
|
|
29982
|
-
|
|
29999
|
+
if (me.current = null, he.current = null, oe.current = null, b("idle"), S(!1), le.current = !1, Ir(), i) try {
|
|
30000
|
+
Ae(i);
|
|
29983
30001
|
} catch {}
|
|
29984
30002
|
typeof u == "function" && await u(l.current), e?.();
|
|
29985
30003
|
}, [
|
|
@@ -29989,26 +30007,26 @@ function gk({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
29989
30007
|
s,
|
|
29990
30008
|
a
|
|
29991
30009
|
]);
|
|
29992
|
-
|
|
29993
|
-
|
|
29994
|
-
}, [
|
|
29995
|
-
d &&
|
|
30010
|
+
ce.current = () => Oe(pe.current === "chat" ? t : n), c(() => {
|
|
30011
|
+
ue.current = x;
|
|
30012
|
+
}, [x]), c(() => {
|
|
30013
|
+
d && Te("chat");
|
|
29996
30014
|
}, [d]), c(() => {
|
|
29997
30015
|
let e = !1, o = null, c = null, d = null;
|
|
29998
30016
|
return (async () => {
|
|
29999
30017
|
if (!r) {
|
|
30000
|
-
|
|
30018
|
+
b("error");
|
|
30001
30019
|
return;
|
|
30002
30020
|
}
|
|
30003
30021
|
try {
|
|
30004
30022
|
if ((await navigator.mediaDevices.getUserMedia({ audio: !0 })).getTracks().forEach((e) => e.stop()), e) return;
|
|
30005
|
-
l.current = [],
|
|
30023
|
+
l.current = [], se.current = "", le.current = !1, de.current = !1, fe.current = !1, pe.current = "minimized", Fr({ onBeforeNavigate: () => {
|
|
30006
30024
|
if (i && l.current.length > 0) try {
|
|
30007
30025
|
let e = SO(l.current);
|
|
30008
|
-
e &&
|
|
30026
|
+
e && k(i, e);
|
|
30009
30027
|
} catch {}
|
|
30010
30028
|
if (!or()) {
|
|
30011
|
-
let e =
|
|
30029
|
+
let e = me.current, t = he.current;
|
|
30012
30030
|
if (e && s && a) try {
|
|
30013
30031
|
let n = t ? Math.round((Date.now() - t) / 1e3) : 0, r = JSON.stringify({
|
|
30014
30032
|
chatId: s,
|
|
@@ -30021,26 +30039,29 @@ function gk({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
30021
30039
|
headers: { "Content-Type": "application/json" },
|
|
30022
30040
|
body: r,
|
|
30023
30041
|
keepalive: !0
|
|
30024
|
-
}).catch(() => {}),
|
|
30042
|
+
}).catch(() => {}), me.current = null, he.current = null;
|
|
30025
30043
|
} catch {}
|
|
30026
30044
|
}
|
|
30027
|
-
|
|
30045
|
+
Me();
|
|
30028
30046
|
} });
|
|
30029
30047
|
let t = ak(ik({
|
|
30030
30048
|
siteId: i || null,
|
|
30031
30049
|
apiBaseUrl: a || null,
|
|
30032
30050
|
chatId: s || null,
|
|
30033
|
-
getLastUserVoiceText: () =>
|
|
30051
|
+
getLastUserVoiceText: () => se.current,
|
|
30034
30052
|
requestEndSession: () => {
|
|
30035
|
-
|
|
30053
|
+
ve.current = !0;
|
|
30054
|
+
},
|
|
30055
|
+
requestEmailCollection: () => {
|
|
30056
|
+
re.current || (ie.current = !0, O.current = 0, ee(!0), De());
|
|
30036
30057
|
}
|
|
30037
|
-
})), n = i ?
|
|
30058
|
+
})), n = i ? ke(i) : null, u = !!n?.transcript, p = i ? Be(i) : null, m = !!p, g = typeof window < "u" ? window.location.pathname : "/", _ = typeof document < "u" ? document.title : "", v = g.replace(/^\/[a-z]{2}(?:-[a-z]{2})?(?=\/|$)/i, "") || "/", y = v === "/" || v === "", x = null;
|
|
30038
30059
|
try {
|
|
30039
30060
|
let e = await fetch(`${a}/api/voice/signed-url?siteId=${encodeURIComponent(i || "")}`, {
|
|
30040
30061
|
method: "GET",
|
|
30041
30062
|
headers: { "Content-Type": "application/json" }
|
|
30042
30063
|
});
|
|
30043
|
-
if (e.ok)
|
|
30064
|
+
if (e.ok) x = (await e.json()).signedUrl || null, x && console.log("[FlowEngage] ✅ Using signed ElevenLabs URL");
|
|
30044
30065
|
else if (e.status === 429) {
|
|
30045
30066
|
let t = await e.json().catch(() => ({}));
|
|
30046
30067
|
throw Error(t.message || "Too many voice sessions started. Please wait a minute before trying again.");
|
|
@@ -30053,51 +30074,51 @@ function gk({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
30053
30074
|
clientTools: t,
|
|
30054
30075
|
connectionType: "websocket",
|
|
30055
30076
|
minSpeechDurationMs: 50,
|
|
30056
|
-
...
|
|
30057
|
-
},
|
|
30058
|
-
_ && _.includes("|") && (
|
|
30059
|
-
let
|
|
30060
|
-
if (
|
|
30061
|
-
let e = p?.pageName ||
|
|
30077
|
+
...x ? { signedUrl: x } : { agentId: r }
|
|
30078
|
+
}, w = (g.split("/").filter(Boolean).pop() || "").replace(/[-_]/g, " ").replace(/\b\w/g, (e) => e.toUpperCase()), T = "";
|
|
30079
|
+
_ && _.includes("|") && (T = _.split("|").map((e) => e.trim()).filter(Boolean).reduce((e, t) => e.length <= t.length ? e : t));
|
|
30080
|
+
let E = T || w || "this page";
|
|
30081
|
+
if (x) if (m) {
|
|
30082
|
+
let e = p?.pageName || E;
|
|
30062
30083
|
C.overrides = { agent: { firstMessage: `I have navigated you on ${e} page. Do you want to know about any specific section or want a complete overview?` } }, console.log(`[FlowEngage] 🔄 Agent-nav resume: firstMessage set for "${e}" (${g})`);
|
|
30063
30084
|
} else if (u) C.overrides = { agent: { firstMessage: "I'm still here. Go ahead!" } };
|
|
30064
30085
|
else {
|
|
30065
30086
|
let e = f || "";
|
|
30066
|
-
C.overrides = { agent: { firstMessage: h || (
|
|
30087
|
+
C.overrides = { agent: { firstMessage: h || (y ? e ? `Hi, welcome to ${e}! How may I help you?` : "Hi, welcome! How may I help you?" : `Welcome to the ${E} page!`) } }, y || console.log(`[FlowEngage] 🏠 Page-context override: "${E}" for ${g}`);
|
|
30067
30088
|
}
|
|
30068
30089
|
else u && (C.overrides = { agent: { firstMessage: "" } });
|
|
30069
|
-
let
|
|
30090
|
+
let te = !1, ne = m ? `NAVIGATION COMPLETE — The exact phrase "I have navigated you on [page] page. Do you want to know about any specific section or want a complete overview?" has already been spoken as your firstMessage. DO NOT repeat it. PRIOR CONVERSATION CONTEXT:\n${n?.transcript ? `Prior transcript:\n${n.transcript}\n` : "(no prior transcript)"}\nNow STOP — wait silently for the visitor's reply. Do NOT speak, do NOT call any tool until the visitor responds. When they reply: if they name a specific section → call fwh-get-current-page-mvp then answer immediately; if they say "overview" or anything non-specific → call fwh-get-current-page-mvp (zero speech) then do a full highlighted walkthrough.` : null, D = !1, ae = !m && !u ? "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, ce = await ED.startSession({
|
|
30070
30091
|
...C,
|
|
30071
30092
|
onConnect: ({ conversationId: e }) => {
|
|
30072
|
-
|
|
30093
|
+
me.current = e, he.current = Date.now(), console.log("[FlowEngage] 🎙️ AI chat session connected:", e);
|
|
30073
30094
|
},
|
|
30074
30095
|
onUnhandledClientToolCall: (e) => console.error("[FlowEngage] Unhandled tool:", e?.tool_name),
|
|
30075
30096
|
onModeChange: ({ mode: t }) => {
|
|
30076
30097
|
if (!e) {
|
|
30077
30098
|
if (t === "speaking") {
|
|
30078
|
-
|
|
30099
|
+
Ce.current &&= (clearTimeout(Ce.current), null), b("speaking"), ye.current = "speaking", be.current = !0, we.current = !1, Se.current &&= (clearTimeout(Se.current), null);
|
|
30079
30100
|
return;
|
|
30080
30101
|
}
|
|
30081
|
-
if (
|
|
30082
|
-
|
|
30102
|
+
if (ye.current = "listening", ve.current) {
|
|
30103
|
+
ve.current = !1, Te();
|
|
30083
30104
|
return;
|
|
30084
30105
|
}
|
|
30085
|
-
if (
|
|
30086
|
-
|
|
30106
|
+
if (ne && !te) {
|
|
30107
|
+
te = !0;
|
|
30087
30108
|
try {
|
|
30088
|
-
|
|
30109
|
+
oe.current?.sendContextualUpdate?.(ne);
|
|
30089
30110
|
} catch {}
|
|
30090
30111
|
}
|
|
30091
|
-
if (
|
|
30092
|
-
|
|
30112
|
+
if (ae && !D) {
|
|
30113
|
+
D = !0;
|
|
30093
30114
|
try {
|
|
30094
|
-
|
|
30115
|
+
oe.current?.sendContextualUpdate?.(ae);
|
|
30095
30116
|
} catch {}
|
|
30096
30117
|
}
|
|
30097
|
-
|
|
30098
|
-
e ||
|
|
30099
|
-
if (!e &&
|
|
30100
|
-
|
|
30118
|
+
Ce.current && clearTimeout(Ce.current), Ce.current = setTimeout(() => {
|
|
30119
|
+
e || ye.current !== "speaking" && (we.current || (Ce.current = null, ye.current = "listening", b("listening"), be.current && xe.current && !ue.current && !ie.current && (Se.current && clearTimeout(Se.current), Se.current = setTimeout(() => {
|
|
30120
|
+
if (!e && ye.current === "listening" && !ue.current && !ie.current) try {
|
|
30121
|
+
oe.current?.sendContextualUpdate?.("The visitor has been silent for a while. Ask one short, natural question to re-engage — for example: 'Is there anything specific you'd like to know more about?' or 'What else can I help you with today?' Keep it to one sentence.");
|
|
30101
30122
|
} catch {}
|
|
30102
30123
|
}, 15e3))));
|
|
30103
30124
|
}, 1200);
|
|
@@ -30108,7 +30129,7 @@ function gk({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
30108
30129
|
let n = t.role === "user" ? "user" : "bot", r = t.message || t.text || t.content || "";
|
|
30109
30130
|
if (r) {
|
|
30110
30131
|
if (n === "user") {
|
|
30111
|
-
|
|
30132
|
+
se.current = r, we.current = !0, xe.current = !0, Ce.current &&= (clearTimeout(Ce.current), null), Se.current &&= (clearTimeout(Se.current), null);
|
|
30112
30133
|
try {
|
|
30113
30134
|
Bn();
|
|
30114
30135
|
} catch {}
|
|
@@ -30119,53 +30140,53 @@ function gk({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
30119
30140
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
30120
30141
|
}], i) try {
|
|
30121
30142
|
let e = SO(l.current);
|
|
30122
|
-
e &&
|
|
30143
|
+
e && k(i, e);
|
|
30123
30144
|
} catch {}
|
|
30124
30145
|
if (fk(n, r)) {
|
|
30125
|
-
|
|
30146
|
+
ve.current = !0;
|
|
30126
30147
|
return;
|
|
30127
30148
|
}
|
|
30128
|
-
if (
|
|
30129
|
-
|
|
30149
|
+
if (ue.current && n === "bot" && /are you still there|still there\??|hello\?|anyone there|checking in|you there|are you available|is anyone|did you step away/i.test(r)) if (_e.current += 1, _e.current === 2) try {
|
|
30150
|
+
oe.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.");
|
|
30130
30151
|
} catch {}
|
|
30131
|
-
else
|
|
30152
|
+
else _e.current >= 5 && Te("minimized");
|
|
30132
30153
|
}
|
|
30133
30154
|
},
|
|
30134
30155
|
onError: (t) => {
|
|
30135
|
-
if (!e && !
|
|
30136
|
-
|
|
30156
|
+
if (!e && !fe.current && !de.current && !Le()) {
|
|
30157
|
+
de.current = !0, console.error("[FlowEngageVoiceCall] session:error", {
|
|
30137
30158
|
message: t?.message,
|
|
30138
30159
|
name: t?.name,
|
|
30139
30160
|
raw: t
|
|
30140
30161
|
});
|
|
30141
30162
|
try {
|
|
30142
|
-
|
|
30163
|
+
oe.current?.setMicMuted?.(!0);
|
|
30143
30164
|
} catch {}
|
|
30144
|
-
|
|
30165
|
+
S(!0), b("error"), Te("chat");
|
|
30145
30166
|
}
|
|
30146
30167
|
},
|
|
30147
30168
|
onDisconnect: (t) => {
|
|
30148
|
-
if (e ||
|
|
30169
|
+
if (e || fe.current || de.current || Le()) return;
|
|
30149
30170
|
let n = l.current?.length || 0;
|
|
30150
30171
|
console.warn("[FlowEngageVoiceCall] session:disconnected", {
|
|
30151
30172
|
historyCount: n,
|
|
30152
30173
|
reason: t?.reason,
|
|
30153
30174
|
closeCode: t?.context?.code,
|
|
30154
30175
|
closeReason: t?.context?.reason || t?.message,
|
|
30155
|
-
lastUserText:
|
|
30156
|
-
wasMuted:
|
|
30157
|
-
}),
|
|
30176
|
+
lastUserText: se.current || "",
|
|
30177
|
+
wasMuted: ue.current
|
|
30178
|
+
}), de.current = !0;
|
|
30158
30179
|
try {
|
|
30159
|
-
|
|
30180
|
+
oe.current?.setMicMuted?.(!0);
|
|
30160
30181
|
} catch {}
|
|
30161
|
-
|
|
30182
|
+
S(!0), Te("chat");
|
|
30162
30183
|
}
|
|
30163
30184
|
});
|
|
30164
30185
|
if (e) {
|
|
30165
|
-
console.warn("[FlowEngage:VoiceDebug] ❌ cancelled=true after startSession resolved — killing session immediately"),
|
|
30186
|
+
console.warn("[FlowEngage:VoiceDebug] ❌ cancelled=true after startSession resolved — killing session immediately"), ce.endSession().catch(() => {});
|
|
30166
30187
|
return;
|
|
30167
30188
|
}
|
|
30168
|
-
o =
|
|
30189
|
+
o = ce, oe.current = ce, b("listening");
|
|
30169
30190
|
try {
|
|
30170
30191
|
let e = typeof window < "u" ? window.location.href : "", r = "[]";
|
|
30171
30192
|
try {
|
|
@@ -30177,7 +30198,7 @@ function gk({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
30177
30198
|
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 && (a = [...new Set(n)].slice(0, 15).join(" | "));
|
|
30178
30199
|
} catch {}
|
|
30179
30200
|
let o = u && !m ? `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` : "";
|
|
30180
|
-
|
|
30201
|
+
ce.sendContextualUpdate(`${o}SESSION_CONTEXT (NOT a tool result — do NOT treat as CURRENT_PAGE): Visitor is on: ${e} | Approx headings for awareness only: ${a}. SiteId: ${i || "unknown"}. Forms: ${r}. The visitor is ALREADY on this page — do NOT offer to navigate there. WALKTHROUGH RULE: When the visitor asks for a walkthrough or overview of this page, you MUST IMMEDIATELY call fwh-get-current-page-mvp (zero speech — call it silently with NO words before it) to get the exact highlightable headings. The approximate headings above are for routing awareness ONLY — they are NOT precise enough for fwh-highlight-mvp. Do NOT skip fwh-get-current-page-mvp. Voice: call end_voice_session or say you are ending the session to stop.`);
|
|
30181
30202
|
} catch {}
|
|
30182
30203
|
if (typeof window < "u") {
|
|
30183
30204
|
let t = window.location.pathname, n = () => {
|
|
@@ -30206,7 +30227,7 @@ function gk({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
30206
30227
|
ts: Date.now()
|
|
30207
30228
|
});
|
|
30208
30229
|
try {
|
|
30209
|
-
|
|
30230
|
+
oe.current?.sendUserMessage?.(`[SYSTEM: I navigated away mid-walkthrough — I am now on the "${l}" page (${i}). Page title: "${a}". Sections: ${JSON.stringify(o)}. STOP everything. Do NOT describe the new page. Say EXACTLY: "I see you've navigated to the ${l} 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 flowengage_navigate, do NOT call flowengage_highlight, the visitor will navigate themselves if needed. IF I want to hear about this page: call flowengage_highlight for sections of "${l}" only.]`);
|
|
30210
30231
|
} catch {}
|
|
30211
30232
|
};
|
|
30212
30233
|
c = window.history.pushState.bind(window.history), window.history.pushState = (...e) => {
|
|
@@ -30214,7 +30235,7 @@ function gk({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
30214
30235
|
}, d = () => setTimeout(n, 50), window.addEventListener("popstate", d);
|
|
30215
30236
|
}
|
|
30216
30237
|
} catch (r) {
|
|
30217
|
-
e || (console.error("[FlowEngage] startSession failed", r), r.message && r.message.includes("Too many voice sessions") ? (alert(r.message), n && n("minimized")) : (
|
|
30238
|
+
e || (console.error("[FlowEngage] startSession failed", r), r.message && r.message.includes("Too many voice sessions") ? (alert(r.message), n && n("minimized")) : (b("error"), pe.current = "chat", window.setTimeout(() => {
|
|
30218
30239
|
e || t?.();
|
|
30219
30240
|
}, 0)));
|
|
30220
30241
|
}
|
|
@@ -30223,15 +30244,15 @@ function gk({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
30223
30244
|
agentId: r,
|
|
30224
30245
|
siteId: i,
|
|
30225
30246
|
apiBaseUrl: a
|
|
30226
|
-
}), e = !0,
|
|
30247
|
+
}), e = !0, fe.current = !0;
|
|
30227
30248
|
try {
|
|
30228
30249
|
Bn();
|
|
30229
30250
|
} catch {}
|
|
30230
30251
|
if (i) try {
|
|
30231
|
-
|
|
30252
|
+
Be(i);
|
|
30232
30253
|
} catch {}
|
|
30233
|
-
typeof window < "u" && (window.__fe_user_nav_during_speech = null), Ir(),
|
|
30234
|
-
let t = o ||
|
|
30254
|
+
typeof window < "u" && (window.__fe_user_nav_during_speech = null), Ir(), Se.current &&= (clearTimeout(Se.current), null), Ce.current &&= (clearTimeout(Ce.current), null), ae.current &&= (clearTimeout(ae.current), null), be.current = !1, we.current = !1, ye.current = "idle", c && typeof window < "u" && (window.history.pushState = c), d && typeof window < "u" && window.removeEventListener("popstate", d);
|
|
30255
|
+
let t = o || oe.current, n = me.current, f = he.current;
|
|
30235
30256
|
if (t?.endSession?.().catch(() => {}), n && s && a) {
|
|
30236
30257
|
let e = f ? Math.round((Date.now() - f) / 1e3) : 0, t = JSON.stringify({
|
|
30237
30258
|
chatId: s,
|
|
@@ -30244,7 +30265,7 @@ function gk({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
30244
30265
|
headers: { "Content-Type": "application/json" },
|
|
30245
30266
|
body: t,
|
|
30246
30267
|
keepalive: !0
|
|
30247
|
-
}).catch(() => {}),
|
|
30268
|
+
}).catch(() => {}), me.current = null, he.current = null;
|
|
30248
30269
|
}
|
|
30249
30270
|
typeof u == "function" && l.current.length > 0 && u(l.current).catch?.(() => {});
|
|
30250
30271
|
};
|
|
@@ -30252,16 +30273,51 @@ function gk({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
30252
30273
|
r,
|
|
30253
30274
|
i,
|
|
30254
30275
|
a,
|
|
30255
|
-
|
|
30276
|
+
Te
|
|
30256
30277
|
]), c(() => {
|
|
30257
|
-
if (!
|
|
30278
|
+
if (!C) return;
|
|
30258
30279
|
let e = (e) => {
|
|
30259
30280
|
let t = e.composedPath?.()?.[0] || e.target;
|
|
30260
|
-
|
|
30281
|
+
ge.current && !ge.current.contains(t) && w(!1);
|
|
30261
30282
|
};
|
|
30262
30283
|
return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
|
|
30263
|
-
}, [
|
|
30264
|
-
|
|
30284
|
+
}, [C]);
|
|
30285
|
+
let je = async () => {
|
|
30286
|
+
if (oe.current) try {
|
|
30287
|
+
if (x) {
|
|
30288
|
+
_e.current = 0, await oe.current.setMicMuted?.(!1), S(!1);
|
|
30289
|
+
try {
|
|
30290
|
+
oe.current.sendContextualUpdate?.("The visitor has unmuted. Resume normal interaction and wait for them to speak.");
|
|
30291
|
+
} catch {}
|
|
30292
|
+
} else {
|
|
30293
|
+
_e.current = 0, await oe.current.setMicMuted?.(!0), S(!0);
|
|
30294
|
+
try {
|
|
30295
|
+
oe.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.");
|
|
30296
|
+
} catch {}
|
|
30297
|
+
}
|
|
30298
|
+
} catch {}
|
|
30299
|
+
}, Ne = o(async (e) => {
|
|
30300
|
+
e?.preventDefault?.();
|
|
30301
|
+
let t = E.trim().toLowerCase();
|
|
30302
|
+
if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t)) {
|
|
30303
|
+
D("Please enter a valid email address.");
|
|
30304
|
+
return;
|
|
30305
|
+
}
|
|
30306
|
+
D("");
|
|
30307
|
+
try {
|
|
30308
|
+
typeof v == "function" && await v(t);
|
|
30309
|
+
} catch {}
|
|
30310
|
+
re.current = !0, ie.current = !1, Ee(), ee(!1), te("");
|
|
30311
|
+
try {
|
|
30312
|
+
oe.current?.sendUserMessage?.("[SYSTEM: EMAIL_SAVED — the visitor typed and submitted their email address. Say a brief 'Thank you!' and immediately answer their original question or continue helping them. Do NOT ask for their email again.]");
|
|
30313
|
+
} catch {}
|
|
30314
|
+
}, [
|
|
30315
|
+
E,
|
|
30316
|
+
v,
|
|
30317
|
+
Ee
|
|
30318
|
+
]), Pe = Array.isArray(e) && e[0] || "#3B82F6";
|
|
30319
|
+
return /* @__PURE__ */ _("div", {
|
|
30320
|
+
ref: ge,
|
|
30265
30321
|
style: {
|
|
30266
30322
|
position: "relative",
|
|
30267
30323
|
display: "flex",
|
|
@@ -30274,7 +30330,7 @@ function gk({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
30274
30330
|
/* @__PURE__ */ _("div", {
|
|
30275
30331
|
style: { position: "relative" },
|
|
30276
30332
|
children: [
|
|
30277
|
-
|
|
30333
|
+
y === "listening" && !x && /* @__PURE__ */ g("span", {
|
|
30278
30334
|
style: {
|
|
30279
30335
|
position: "absolute",
|
|
30280
30336
|
right: "100%",
|
|
@@ -30290,7 +30346,7 @@ function gk({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
30290
30346
|
},
|
|
30291
30347
|
children: "Listening..."
|
|
30292
30348
|
}),
|
|
30293
|
-
|
|
30349
|
+
x && /* @__PURE__ */ g("span", {
|
|
30294
30350
|
style: {
|
|
30295
30351
|
position: "absolute",
|
|
30296
30352
|
right: "100%",
|
|
@@ -30308,13 +30364,13 @@ function gk({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
30308
30364
|
}),
|
|
30309
30365
|
/* @__PURE__ */ g(pk, {
|
|
30310
30366
|
size: 72,
|
|
30311
|
-
voiceState:
|
|
30312
|
-
isMuted:
|
|
30367
|
+
voiceState: y,
|
|
30368
|
+
isMuted: x,
|
|
30313
30369
|
orbColors: e
|
|
30314
30370
|
})
|
|
30315
30371
|
]
|
|
30316
30372
|
}),
|
|
30317
|
-
|
|
30373
|
+
y === "error" && /* @__PURE__ */ g("span", {
|
|
30318
30374
|
style: {
|
|
30319
30375
|
color: "#f87171",
|
|
30320
30376
|
fontSize: "13px",
|
|
@@ -30329,39 +30385,25 @@ function gk({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
30329
30385
|
alignItems: "center"
|
|
30330
30386
|
},
|
|
30331
30387
|
children: [/* @__PURE__ */ g("button", {
|
|
30332
|
-
onClick:
|
|
30333
|
-
|
|
30334
|
-
if (b) {
|
|
30335
|
-
se.current = 0, await w.current.setMicMuted?.(!1), x(!1);
|
|
30336
|
-
try {
|
|
30337
|
-
w.current.sendContextualUpdate?.("The visitor has unmuted. Resume normal interaction and wait for them to speak.");
|
|
30338
|
-
} catch {}
|
|
30339
|
-
} else {
|
|
30340
|
-
se.current = 0, await w.current.setMicMuted?.(!0), x(!0);
|
|
30341
|
-
try {
|
|
30342
|
-
w.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.");
|
|
30343
|
-
} catch {}
|
|
30344
|
-
}
|
|
30345
|
-
} catch {}
|
|
30346
|
-
},
|
|
30347
|
-
title: b ? "Unmute" : "Mute",
|
|
30388
|
+
onClick: je,
|
|
30389
|
+
title: x ? "Unmute" : "Mute",
|
|
30348
30390
|
style: {
|
|
30349
30391
|
width: "24px",
|
|
30350
30392
|
height: "24px",
|
|
30351
30393
|
borderRadius: "50%",
|
|
30352
|
-
background:
|
|
30353
|
-
border:
|
|
30394
|
+
background: x ? "#7f1d1d" : "#1f2937",
|
|
30395
|
+
border: x ? "1.5px solid #ef4444" : "1.5px solid #4b5563",
|
|
30354
30396
|
display: "flex",
|
|
30355
30397
|
alignItems: "center",
|
|
30356
30398
|
justifyContent: "center",
|
|
30357
30399
|
cursor: "pointer",
|
|
30358
|
-
color:
|
|
30400
|
+
color: x ? "#f87171" : "white",
|
|
30359
30401
|
transition: "all 0.2s ease",
|
|
30360
30402
|
boxShadow: "0 2px 8px rgba(0,0,0,0.4)",
|
|
30361
30403
|
padding: 0,
|
|
30362
30404
|
flexShrink: 0
|
|
30363
30405
|
},
|
|
30364
|
-
children:
|
|
30406
|
+
children: x ? /* @__PURE__ */ _("svg", {
|
|
30365
30407
|
width: "16",
|
|
30366
30408
|
height: "16",
|
|
30367
30409
|
viewBox: "0 0 24 24",
|
|
@@ -30397,7 +30439,7 @@ function gk({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
30397
30439
|
color: "currentColor"
|
|
30398
30440
|
})
|
|
30399
30441
|
}), /* @__PURE__ */ g("button", {
|
|
30400
|
-
onClick: () =>
|
|
30442
|
+
onClick: () => w((e) => !e),
|
|
30401
30443
|
style: {
|
|
30402
30444
|
width: "24px",
|
|
30403
30445
|
height: "24px",
|
|
@@ -30420,7 +30462,85 @@ function gk({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
30420
30462
|
})
|
|
30421
30463
|
})]
|
|
30422
30464
|
}),
|
|
30423
|
-
|
|
30465
|
+
T && /* @__PURE__ */ _("form", {
|
|
30466
|
+
onSubmit: Ne,
|
|
30467
|
+
style: {
|
|
30468
|
+
position: "absolute",
|
|
30469
|
+
bottom: 0,
|
|
30470
|
+
left: "50%",
|
|
30471
|
+
transform: "translateX(-50%)",
|
|
30472
|
+
width: "270px",
|
|
30473
|
+
zIndex: 9999,
|
|
30474
|
+
background: "rgba(15,22,36,0.97)",
|
|
30475
|
+
backdropFilter: "blur(14px)",
|
|
30476
|
+
WebkitBackdropFilter: "blur(14px)",
|
|
30477
|
+
borderRadius: "16px",
|
|
30478
|
+
boxShadow: "0 10px 40px rgba(0,0,0,0.45)",
|
|
30479
|
+
padding: "16px",
|
|
30480
|
+
display: "flex",
|
|
30481
|
+
flexDirection: "column",
|
|
30482
|
+
gap: "10px",
|
|
30483
|
+
animation: "fe-orb-fade-in 0.18s ease"
|
|
30484
|
+
},
|
|
30485
|
+
children: [
|
|
30486
|
+
/* @__PURE__ */ g("span", {
|
|
30487
|
+
style: {
|
|
30488
|
+
color: "white",
|
|
30489
|
+
fontSize: "13px",
|
|
30490
|
+
fontWeight: 600,
|
|
30491
|
+
lineHeight: 1.4
|
|
30492
|
+
},
|
|
30493
|
+
children: "Please enter your email to continue"
|
|
30494
|
+
}),
|
|
30495
|
+
/* @__PURE__ */ g("input", {
|
|
30496
|
+
type: "email",
|
|
30497
|
+
inputMode: "email",
|
|
30498
|
+
autoComplete: "email",
|
|
30499
|
+
autoFocus: !0,
|
|
30500
|
+
value: E,
|
|
30501
|
+
onChange: (e) => {
|
|
30502
|
+
te(e.target.value), ne && D("");
|
|
30503
|
+
},
|
|
30504
|
+
placeholder: "you@example.com",
|
|
30505
|
+
style: {
|
|
30506
|
+
width: "100%",
|
|
30507
|
+
boxSizing: "border-box",
|
|
30508
|
+
padding: "10px 12px",
|
|
30509
|
+
borderRadius: "10px",
|
|
30510
|
+
border: ne ? "1.5px solid #ef4444" : "1.5px solid #4b5563",
|
|
30511
|
+
background: "#1f2937",
|
|
30512
|
+
color: "white",
|
|
30513
|
+
fontSize: "14px",
|
|
30514
|
+
outline: "none"
|
|
30515
|
+
}
|
|
30516
|
+
}),
|
|
30517
|
+
ne && /* @__PURE__ */ g("span", {
|
|
30518
|
+
style: {
|
|
30519
|
+
color: "#f87171",
|
|
30520
|
+
fontSize: "12px"
|
|
30521
|
+
},
|
|
30522
|
+
children: ne
|
|
30523
|
+
}),
|
|
30524
|
+
/* @__PURE__ */ g("button", {
|
|
30525
|
+
type: "submit",
|
|
30526
|
+
disabled: !E.trim(),
|
|
30527
|
+
style: {
|
|
30528
|
+
width: "100%",
|
|
30529
|
+
padding: "10px 12px",
|
|
30530
|
+
borderRadius: "10px",
|
|
30531
|
+
border: "none",
|
|
30532
|
+
background: E.trim() ? Pe : "#374151",
|
|
30533
|
+
color: "white",
|
|
30534
|
+
fontSize: "14px",
|
|
30535
|
+
fontWeight: 600,
|
|
30536
|
+
cursor: E.trim() ? "pointer" : "default",
|
|
30537
|
+
transition: "background 0.2s ease"
|
|
30538
|
+
},
|
|
30539
|
+
children: "Submit"
|
|
30540
|
+
})
|
|
30541
|
+
]
|
|
30542
|
+
}),
|
|
30543
|
+
C && /* @__PURE__ */ _("div", {
|
|
30424
30544
|
style: {
|
|
30425
30545
|
position: "absolute",
|
|
30426
30546
|
bottom: 0,
|
|
@@ -30438,7 +30558,7 @@ function gk({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
30438
30558
|
children: [
|
|
30439
30559
|
/* @__PURE__ */ _("button", {
|
|
30440
30560
|
onClick: () => {
|
|
30441
|
-
|
|
30561
|
+
w(!1), pe.current = "chat", Oe(t);
|
|
30442
30562
|
},
|
|
30443
30563
|
style: {
|
|
30444
30564
|
display: "flex",
|
|
@@ -30467,7 +30587,7 @@ function gk({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
30467
30587
|
}),
|
|
30468
30588
|
/* @__PURE__ */ _("button", {
|
|
30469
30589
|
onClick: () => {
|
|
30470
|
-
|
|
30590
|
+
w(!1), pe.current = "minimized", Oe(n);
|
|
30471
30591
|
},
|
|
30472
30592
|
style: {
|
|
30473
30593
|
display: "flex",
|
|
@@ -30495,7 +30615,7 @@ function gk({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
30495
30615
|
children: [/* @__PURE__ */ g(LD, {}), "End Conversation"]
|
|
30496
30616
|
}),
|
|
30497
30617
|
/* @__PURE__ */ g("button", {
|
|
30498
|
-
onClick: () =>
|
|
30618
|
+
onClick: () => w(!1),
|
|
30499
30619
|
style: {
|
|
30500
30620
|
position: "absolute",
|
|
30501
30621
|
bottom: "8px",
|
|
@@ -30593,54 +30713,54 @@ var vk = () => /* @__PURE__ */ g("div", {
|
|
|
30593
30713
|
} }, e))
|
|
30594
30714
|
})
|
|
30595
30715
|
});
|
|
30596
|
-
function yk({ 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: ee, rateLimitMessage:
|
|
30597
|
-
let
|
|
30716
|
+
function yk({ 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: ee, rateLimitMessage: E, selectedFile: te, onFileSelect: ne, onRemoveSelectedFile: D, attachmentError: re, isUploadingAttachment: ie, requiresEmail: ae, emailInput: O, setEmailInput: oe, emailError: se, emailCaptureSuccess: ce, replyContext: le, setReplyContext: ue, webRTCError: de, micError: fe, setMicError: pe, dismissCallError: me, activeCallId: he, isCallMuted: ge, toggleCallMute: _e, endWebRTCCall: ve, formatCallDuration: ye, callDurationSeconds: be, isCallMinimized: xe, onExpand: Se, onCollapse: Ce, onStartVoice: we, voiceEnabled: Te, headerBgColor: Ee, onNewChat: De, showPoweredBy: Oe, privacyPolicyUrl: k, getVisitorChatHistory: ke, resumeChat: Ae, isSessionRestoring: je, isClosing: Me }) {
|
|
30717
|
+
let Ne = l.length > 0, Pe = T || ee || w, Fe = !!he, [Ie, Le] = m(!1), [Re, ze] = m(!1), [Be, A] = m([]), [Ve, He] = m(!1), Ue = p(null), [We, Ge] = m(() => typeof window < "u" ? window.visualViewport?.height ?? window.innerHeight : 600), [Ke, qe] = m(0);
|
|
30598
30718
|
c(() => {
|
|
30599
30719
|
if (!s) return;
|
|
30600
30720
|
let e = window.visualViewport;
|
|
30601
30721
|
if (!e) return;
|
|
30602
30722
|
let t = () => {
|
|
30603
|
-
|
|
30723
|
+
Ge(e.height), qe(Math.max(0, window.innerHeight - e.offsetTop - e.height));
|
|
30604
30724
|
};
|
|
30605
30725
|
return e.addEventListener("resize", t), e.addEventListener("scroll", t), t(), () => {
|
|
30606
30726
|
e.removeEventListener("resize", t), e.removeEventListener("scroll", t);
|
|
30607
30727
|
};
|
|
30608
30728
|
}, [s]);
|
|
30609
|
-
let
|
|
30610
|
-
|
|
30729
|
+
let Je = s && window.innerHeight - We > 150, Ye = async () => {
|
|
30730
|
+
Le(!1), ze(!0), He(!0);
|
|
30611
30731
|
try {
|
|
30612
|
-
let e = await
|
|
30613
|
-
e?.data &&
|
|
30732
|
+
let e = await ke();
|
|
30733
|
+
e?.data && A(e.data);
|
|
30614
30734
|
} catch (e) {
|
|
30615
30735
|
console.error(e);
|
|
30616
30736
|
} finally {
|
|
30617
|
-
|
|
30737
|
+
He(!1);
|
|
30618
30738
|
}
|
|
30619
|
-
},
|
|
30620
|
-
|
|
30739
|
+
}, Xe = async (e) => {
|
|
30740
|
+
ze(!1), Ae?.(e.chatId);
|
|
30621
30741
|
};
|
|
30622
30742
|
return c(() => {
|
|
30623
|
-
if (!
|
|
30743
|
+
if (!Ie) return;
|
|
30624
30744
|
let e = (e) => {
|
|
30625
30745
|
let t = e.composedPath?.()?.[0] || e.target;
|
|
30626
|
-
|
|
30746
|
+
Ue.current && !Ue.current.contains(t) && Le(!1);
|
|
30627
30747
|
};
|
|
30628
30748
|
return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
|
|
30629
|
-
}, [
|
|
30749
|
+
}, [Ie]), /* @__PURE__ */ _("div", {
|
|
30630
30750
|
style: s ? {
|
|
30631
30751
|
"--flowengage-primary": n,
|
|
30632
30752
|
"--flowengage-accent": n,
|
|
30633
30753
|
position: "fixed",
|
|
30634
30754
|
left: "8px",
|
|
30635
30755
|
right: "8px",
|
|
30636
|
-
bottom: `${
|
|
30637
|
-
height:
|
|
30756
|
+
bottom: `${Ke}px`,
|
|
30757
|
+
height: We > 0 ? `${Math.round(We * .92)}px` : "90dvh",
|
|
30638
30758
|
background: r,
|
|
30639
30759
|
borderRadius: "16px 16px 0 0",
|
|
30640
30760
|
display: "flex",
|
|
30641
30761
|
flexDirection: "column",
|
|
30642
30762
|
overflow: "hidden",
|
|
30643
|
-
animation:
|
|
30763
|
+
animation: Me ? "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)"
|
|
30644
30764
|
} : {
|
|
30645
30765
|
"--flowengage-primary": n,
|
|
30646
30766
|
"--flowengage-accent": n,
|
|
@@ -30653,7 +30773,7 @@ function yk({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
30653
30773
|
flexDirection: "column",
|
|
30654
30774
|
overflow: "hidden",
|
|
30655
30775
|
position: "relative",
|
|
30656
|
-
animation:
|
|
30776
|
+
animation: Me ? "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)"
|
|
30657
30777
|
},
|
|
30658
30778
|
children: [
|
|
30659
30779
|
/* @__PURE__ */ _("div", {
|
|
@@ -30663,7 +30783,7 @@ function yk({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
30663
30783
|
alignItems: "center",
|
|
30664
30784
|
columnGap: "14px",
|
|
30665
30785
|
padding: "16px 10px 14px",
|
|
30666
|
-
background:
|
|
30786
|
+
background: Ee || "transparent",
|
|
30667
30787
|
flexShrink: 0,
|
|
30668
30788
|
position: "relative",
|
|
30669
30789
|
zIndex: 30
|
|
@@ -30676,7 +30796,7 @@ function yk({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
30676
30796
|
alignItems: "center"
|
|
30677
30797
|
},
|
|
30678
30798
|
children: /* @__PURE__ */ g("button", {
|
|
30679
|
-
onClick:
|
|
30799
|
+
onClick: Ce,
|
|
30680
30800
|
style: {
|
|
30681
30801
|
width: "40px",
|
|
30682
30802
|
height: "40px",
|
|
@@ -30778,10 +30898,10 @@ function yk({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
30778
30898
|
isolation: "isolate",
|
|
30779
30899
|
zIndex: 10
|
|
30780
30900
|
},
|
|
30781
|
-
ref:
|
|
30901
|
+
ref: Ue,
|
|
30782
30902
|
children: [/* @__PURE__ */ g("button", {
|
|
30783
30903
|
type: "button",
|
|
30784
|
-
onClick: () =>
|
|
30904
|
+
onClick: () => Le((e) => !e),
|
|
30785
30905
|
style: {
|
|
30786
30906
|
width: "40px",
|
|
30787
30907
|
height: "40px",
|
|
@@ -30827,7 +30947,7 @@ function yk({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
30827
30947
|
})
|
|
30828
30948
|
]
|
|
30829
30949
|
})
|
|
30830
|
-
}),
|
|
30950
|
+
}), Ie && /* @__PURE__ */ _("div", {
|
|
30831
30951
|
style: {
|
|
30832
30952
|
position: "absolute",
|
|
30833
30953
|
top: "34px",
|
|
@@ -30843,10 +30963,10 @@ function yk({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
30843
30963
|
animation: "fe-orb-fade-in 0.18s ease"
|
|
30844
30964
|
},
|
|
30845
30965
|
children: [
|
|
30846
|
-
|
|
30966
|
+
Te && /* @__PURE__ */ _(h, { children: [/* @__PURE__ */ _("button", {
|
|
30847
30967
|
type: "button",
|
|
30848
30968
|
onClick: () => {
|
|
30849
|
-
|
|
30969
|
+
Le(!1), we?.();
|
|
30850
30970
|
},
|
|
30851
30971
|
style: {
|
|
30852
30972
|
display: "flex",
|
|
@@ -30888,7 +31008,7 @@ function yk({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
30888
31008
|
/* @__PURE__ */ _("button", {
|
|
30889
31009
|
type: "button",
|
|
30890
31010
|
onClick: () => {
|
|
30891
|
-
|
|
31011
|
+
Le(!1), De?.();
|
|
30892
31012
|
},
|
|
30893
31013
|
style: {
|
|
30894
31014
|
display: "flex",
|
|
@@ -30923,13 +31043,13 @@ function yk({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
30923
31043
|
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" })]
|
|
30924
31044
|
}), "Start new chat"]
|
|
30925
31045
|
}),
|
|
30926
|
-
|
|
31046
|
+
ke && /* @__PURE__ */ _(h, { children: [/* @__PURE__ */ g("div", { style: {
|
|
30927
31047
|
height: "1px",
|
|
30928
31048
|
background: "rgba(255,255,255,0.07)",
|
|
30929
31049
|
margin: "0 14px"
|
|
30930
31050
|
} }), /* @__PURE__ */ _("button", {
|
|
30931
31051
|
type: "button",
|
|
30932
|
-
onClick:
|
|
31052
|
+
onClick: Ye,
|
|
30933
31053
|
style: {
|
|
30934
31054
|
display: "flex",
|
|
30935
31055
|
alignItems: "center",
|
|
@@ -30971,7 +31091,7 @@ function yk({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
30971
31091
|
/* @__PURE__ */ _("button", {
|
|
30972
31092
|
type: "button",
|
|
30973
31093
|
onClick: () => {
|
|
30974
|
-
|
|
31094
|
+
Le(!1), Ce?.();
|
|
30975
31095
|
},
|
|
30976
31096
|
style: {
|
|
30977
31097
|
display: "flex",
|
|
@@ -31030,23 +31150,23 @@ function yk({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
31030
31150
|
]
|
|
31031
31151
|
}),
|
|
31032
31152
|
/* @__PURE__ */ g(iO, {
|
|
31033
|
-
webRTCError:
|
|
31034
|
-
micError:
|
|
31035
|
-
setMicError:
|
|
31036
|
-
dismissCallError:
|
|
31153
|
+
webRTCError: de,
|
|
31154
|
+
micError: fe,
|
|
31155
|
+
setMicError: pe,
|
|
31156
|
+
dismissCallError: me,
|
|
31037
31157
|
isRateLimited: ee,
|
|
31038
|
-
rateLimitMessage:
|
|
31158
|
+
rateLimitMessage: E
|
|
31039
31159
|
}),
|
|
31040
|
-
|
|
31160
|
+
xe && /* @__PURE__ */ g(xO, {
|
|
31041
31161
|
agentName: v,
|
|
31042
31162
|
agentHeadshot: y,
|
|
31043
31163
|
fallbackAgentName: b,
|
|
31044
|
-
callDurationSeconds:
|
|
31045
|
-
isCallMuted:
|
|
31046
|
-
formatCallDuration:
|
|
31047
|
-
toggleCallMute:
|
|
31048
|
-
endWebRTCCall:
|
|
31049
|
-
onExpand:
|
|
31164
|
+
callDurationSeconds: be,
|
|
31165
|
+
isCallMuted: ge,
|
|
31166
|
+
formatCallDuration: ye,
|
|
31167
|
+
toggleCallMute: _e,
|
|
31168
|
+
endWebRTCCall: ve,
|
|
31169
|
+
onExpand: Se,
|
|
31050
31170
|
primaryColor: n
|
|
31051
31171
|
}),
|
|
31052
31172
|
/* @__PURE__ */ _("div", {
|
|
@@ -31058,7 +31178,7 @@ function yk({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
31058
31178
|
background: "transparent",
|
|
31059
31179
|
position: "relative"
|
|
31060
31180
|
},
|
|
31061
|
-
children: [
|
|
31181
|
+
children: [Re ? /* @__PURE__ */ _("div", {
|
|
31062
31182
|
style: {
|
|
31063
31183
|
position: "absolute",
|
|
31064
31184
|
inset: 0,
|
|
@@ -31077,7 +31197,7 @@ function yk({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
31077
31197
|
flexShrink: 0
|
|
31078
31198
|
},
|
|
31079
31199
|
children: /* @__PURE__ */ _("button", {
|
|
31080
|
-
onClick: () =>
|
|
31200
|
+
onClick: () => ze(!1),
|
|
31081
31201
|
style: {
|
|
31082
31202
|
background: "none",
|
|
31083
31203
|
border: "none",
|
|
@@ -31111,7 +31231,7 @@ function yk({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
31111
31231
|
overflowY: "auto",
|
|
31112
31232
|
position: "relative"
|
|
31113
31233
|
},
|
|
31114
|
-
children:
|
|
31234
|
+
children: Ve ? /* @__PURE__ */ g("div", {
|
|
31115
31235
|
style: {
|
|
31116
31236
|
padding: "40px 20px",
|
|
31117
31237
|
textAlign: "center",
|
|
@@ -31119,8 +31239,8 @@ function yk({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
31119
31239
|
fontSize: "14px"
|
|
31120
31240
|
},
|
|
31121
31241
|
children: "Loading past conversations..."
|
|
31122
|
-
}) :
|
|
31123
|
-
onClick: () =>
|
|
31242
|
+
}) : Be.length > 0 ? /* @__PURE__ */ g("div", { children: Be.map((e) => /* @__PURE__ */ _("div", {
|
|
31243
|
+
onClick: () => Xe(e),
|
|
31124
31244
|
style: {
|
|
31125
31245
|
padding: "16px 20px",
|
|
31126
31246
|
borderBottom: "1px solid #f3f4f6",
|
|
@@ -31171,18 +31291,18 @@ function yk({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
31171
31291
|
children: "No previous chats found."
|
|
31172
31292
|
})
|
|
31173
31293
|
})]
|
|
31174
|
-
}) : null,
|
|
31294
|
+
}) : null, Ne ? /* @__PURE__ */ g(nO, {
|
|
31175
31295
|
chatHistory: l,
|
|
31176
31296
|
isAiTyping: u,
|
|
31177
31297
|
isLoading: T,
|
|
31178
31298
|
isAgentTyping: d,
|
|
31179
|
-
setReplyContext:
|
|
31299
|
+
setReplyContext: ue,
|
|
31180
31300
|
TypingDots: vk,
|
|
31181
31301
|
primaryColor: n,
|
|
31182
31302
|
agentHeadshot: y,
|
|
31183
31303
|
agentDisplayName: v || b,
|
|
31184
31304
|
botAvatarNode: /* @__PURE__ */ g(_k, { orbColors: t })
|
|
31185
|
-
}) :
|
|
31305
|
+
}) : je ? /* @__PURE__ */ _("div", {
|
|
31186
31306
|
style: {
|
|
31187
31307
|
flex: 1,
|
|
31188
31308
|
display: "flex",
|
|
@@ -31272,7 +31392,7 @@ function yk({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
31272
31392
|
]
|
|
31273
31393
|
})]
|
|
31274
31394
|
}),
|
|
31275
|
-
|
|
31395
|
+
ce && /* @__PURE__ */ _("div", {
|
|
31276
31396
|
style: {
|
|
31277
31397
|
margin: "0 16px 8px",
|
|
31278
31398
|
padding: "9px 14px",
|
|
@@ -31311,33 +31431,33 @@ function yk({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
31311
31431
|
flexShrink: 0,
|
|
31312
31432
|
position: "relative",
|
|
31313
31433
|
zIndex: 1,
|
|
31314
|
-
padding:
|
|
31434
|
+
padding: ae ? "6px 0 0" : "12px 0 0"
|
|
31315
31435
|
},
|
|
31316
31436
|
children: /* @__PURE__ */ g(rO, {
|
|
31317
31437
|
input: x,
|
|
31318
31438
|
setInput: S,
|
|
31319
31439
|
onSubmit: C,
|
|
31320
31440
|
isConversationEnded: w,
|
|
31321
|
-
callUiActive:
|
|
31322
|
-
handleToggleVoice:
|
|
31441
|
+
callUiActive: Fe,
|
|
31442
|
+
handleToggleVoice: we,
|
|
31323
31443
|
showVoiceToggle: f === "agent",
|
|
31324
31444
|
activeScreen: f,
|
|
31325
|
-
inputDisabled:
|
|
31326
|
-
replyContext:
|
|
31327
|
-
clearReplyContext: () =>
|
|
31328
|
-
onFileSelect:
|
|
31329
|
-
selectedFile:
|
|
31330
|
-
onRemoveSelectedFile:
|
|
31331
|
-
attachmentError:
|
|
31332
|
-
isUploadingAttachment:
|
|
31333
|
-
requiresEmail:
|
|
31334
|
-
emailInput:
|
|
31335
|
-
setEmailInput:
|
|
31336
|
-
emailError:
|
|
31445
|
+
inputDisabled: Pe,
|
|
31446
|
+
replyContext: le,
|
|
31447
|
+
clearReplyContext: () => ue(null),
|
|
31448
|
+
onFileSelect: ne,
|
|
31449
|
+
selectedFile: te,
|
|
31450
|
+
onRemoveSelectedFile: D,
|
|
31451
|
+
attachmentError: re,
|
|
31452
|
+
isUploadingAttachment: ie,
|
|
31453
|
+
requiresEmail: ae,
|
|
31454
|
+
emailInput: O,
|
|
31455
|
+
setEmailInput: oe,
|
|
31456
|
+
emailError: se,
|
|
31337
31457
|
inputPlaceholder: e.inputPlaceholder
|
|
31338
31458
|
})
|
|
31339
31459
|
}),
|
|
31340
|
-
!
|
|
31460
|
+
!Je && /* @__PURE__ */ _("div", {
|
|
31341
31461
|
style: {
|
|
31342
31462
|
flexShrink: 0,
|
|
31343
31463
|
textAlign: "center",
|
|
@@ -31345,7 +31465,7 @@ function yk({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
31345
31465
|
paddingBottom: "max(12px, env(safe-area-inset-bottom, 12px))",
|
|
31346
31466
|
pointerEvents: "none"
|
|
31347
31467
|
},
|
|
31348
|
-
children: [
|
|
31468
|
+
children: [k && /* @__PURE__ */ _("p", {
|
|
31349
31469
|
style: {
|
|
31350
31470
|
margin: "0 0 4px",
|
|
31351
31471
|
fontSize: "10px",
|
|
@@ -31358,7 +31478,7 @@ function yk({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
31358
31478
|
"This conversation is recorded for quality assurance purposes.",
|
|
31359
31479
|
" ",
|
|
31360
31480
|
/* @__PURE__ */ g("a", {
|
|
31361
|
-
href:
|
|
31481
|
+
href: k,
|
|
31362
31482
|
target: "_blank",
|
|
31363
31483
|
rel: "noopener noreferrer",
|
|
31364
31484
|
style: {
|
|
@@ -31368,7 +31488,7 @@ function yk({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
31368
31488
|
children: "See our privacy policy"
|
|
31369
31489
|
})
|
|
31370
31490
|
]
|
|
31371
|
-
}),
|
|
31491
|
+
}), Oe && /* @__PURE__ */ _("span", {
|
|
31372
31492
|
style: {
|
|
31373
31493
|
fontSize: "11px",
|
|
31374
31494
|
color: "#9ca3af",
|
|
@@ -31388,61 +31508,61 @@ function yk({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
31388
31508
|
});
|
|
31389
31509
|
}
|
|
31390
31510
|
function bk() {
|
|
31391
|
-
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: ee, callConnectedAt:
|
|
31511
|
+
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: ee, callConnectedAt: E, isCallMuted: te, webRTCError: ne, language: D, chatId: re, historyRef: ie, onMessageSync: ae, sendMessage: O, uploadChatFile: oe, openWidget: se, captureVisitorEmail: ce, setVoiceMode: le, endConversation: ue, startNewChat: pe, acceptCall: me, rejectCall: he, endWebRTCCall: ge, toggleCallMute: _e, dismissCallError: ve, startTyping: ye, stopTyping: be, updateTypingDraft: xe, getVisitorChatHistory: Se, resumeChat: Ce, isSessionRestoring: we, openToChatCounter: Te, voiceEndCounter: Ee } = Fn();
|
|
31392
31512
|
c(() => {
|
|
31393
31513
|
try {
|
|
31394
31514
|
yr();
|
|
31395
31515
|
} catch {}
|
|
31396
31516
|
}, []), c(() => {
|
|
31397
|
-
|
|
31398
|
-
}, [
|
|
31399
|
-
let
|
|
31400
|
-
...
|
|
31401
|
-
...
|
|
31517
|
+
Te && M !== "voice_mode" && M !== "text_chat" && M !== "call_screen" && (le?.(!1), dt("text_chat"));
|
|
31518
|
+
}, [Te]);
|
|
31519
|
+
let De = t?.widgetSettings || {}, Oe = n?.widgetSettings || {}, k = {
|
|
31520
|
+
...De.branding || {},
|
|
31521
|
+
...Oe.branding || {}
|
|
31522
|
+
}, je = {
|
|
31523
|
+
...De.theme || {},
|
|
31524
|
+
...Oe.theme || {}
|
|
31402
31525
|
}, Me = {
|
|
31403
|
-
...
|
|
31404
|
-
...
|
|
31405
|
-
},
|
|
31406
|
-
...Oe.features || {},
|
|
31407
|
-
...ke.features || {}
|
|
31408
|
-
}, Fe = Ne.voice !== !1, Ie = Array.isArray(Me.orbColors) && Me.orbColors.length > 0 ? Me.orbColors : null, Re = Me.buttonColor || Me.primaryColor || Ie?.[0] || "#3B82F6", ze = {
|
|
31526
|
+
...De.features || {},
|
|
31527
|
+
...Oe.features || {}
|
|
31528
|
+
}, Pe = Me.voice !== !1, Fe = Array.isArray(je.orbColors) && je.orbColors.length > 0 ? je.orbColors : null, Le = je.buttonColor || je.primaryColor || Fe?.[0] || "#3B82F6", Re = {
|
|
31409
31529
|
small: 50,
|
|
31410
31530
|
medium: 64,
|
|
31411
31531
|
large: 80
|
|
31412
|
-
},
|
|
31532
|
+
}, ze = Re[je.orbSize] || Re.small, Be = je.position || "bottom-right", A = k.fallbackAgentName || "Agent", Ve = sk(Fe ?? je.chatBgColors), He = k.logo || k.logoUrl || null, Ue = D || "en", We = De.recommendations?.[Ue] || [], Ge = (Oe.recommendations?.[Ue] ?? We).filter((e) => String(e?.label ?? "").trim()).map((e, t) => ({
|
|
31413
31533
|
id: e.key || `qr-${t}`,
|
|
31414
31534
|
label: e.label,
|
|
31415
31535
|
message: e.label,
|
|
31416
31536
|
text: e.label
|
|
31417
|
-
})),
|
|
31537
|
+
})), Ke = Array.isArray(k.quickChatOptions) && k.quickChatOptions.length > 0 ? k.quickChatOptions : Ge, qe = k.hideWatermark === !0 ? !1 : k.showPoweredBy !== !1, Je = k.headerBgColor || null, Ye = je.bottomPosition == null ? "1.5rem" : `${je.bottomPosition}px`, Xe = k.privacyPolicyUrl || null, Ze = k.chatbotEnabled !== !1 && je.chatbotEnabled !== !1, [Qe, $e] = m(() => typeof window < "u" ? window.location.pathname : "/");
|
|
31418
31538
|
c(() => {
|
|
31419
31539
|
if (typeof window > "u") return;
|
|
31420
|
-
let e = () =>
|
|
31540
|
+
let e = () => $e(window.location.pathname), t = window.history.pushState.bind(window.history);
|
|
31421
31541
|
return window.history.pushState = (...n) => {
|
|
31422
31542
|
t(...n), setTimeout(e, 50);
|
|
31423
31543
|
}, window.addEventListener("popstate", e), () => {
|
|
31424
31544
|
window.history.pushState = t, window.removeEventListener("popstate", e);
|
|
31425
31545
|
};
|
|
31426
31546
|
}, []);
|
|
31427
|
-
let
|
|
31547
|
+
let et = (() => {
|
|
31428
31548
|
let e = {
|
|
31429
|
-
...
|
|
31430
|
-
...
|
|
31549
|
+
...De.pageVisibility || {},
|
|
31550
|
+
...Oe.pageVisibility || {}
|
|
31431
31551
|
};
|
|
31432
31552
|
return Array.isArray(e.allowedPaths) ? e.allowedPaths.filter(Boolean) : [];
|
|
31433
|
-
})(),
|
|
31434
|
-
entryPrompt:
|
|
31435
|
-
yesLabel:
|
|
31436
|
-
laterLabel:
|
|
31437
|
-
connectionTitle:
|
|
31438
|
-
voiceLabel:
|
|
31439
|
-
textLabel:
|
|
31440
|
-
chatTitle:
|
|
31441
|
-
hasCustomTitle: !!(
|
|
31442
|
-
introGreeting:
|
|
31443
|
-
inputPlaceholder:
|
|
31444
|
-
analysingLabel:
|
|
31445
|
-
}, j =
|
|
31553
|
+
})(), tt = et.length === 0 || et.some((e) => e === "*" || e === "/*" ? !0 : e.endsWith("/*") ? Qe.startsWith(e.slice(0, -1)) : Qe.replace(/\/$/, "") === e.replace(/\/$/, "")), nt = De.greetings?.[D] || Oe.greetings?.[D] || k.introGreeting || "Hello, I'm here to help you know more about OpenSense Labs.", rt = {
|
|
31554
|
+
entryPrompt: k.entryPrompt || "Do you want to explore in a new way?",
|
|
31555
|
+
yesLabel: k.yesLabel || "Yes",
|
|
31556
|
+
laterLabel: k.laterLabel || "Later",
|
|
31557
|
+
connectionTitle: k.connectionTitle || "How would you like to connect?",
|
|
31558
|
+
voiceLabel: k.voiceLabel || "Voice",
|
|
31559
|
+
textLabel: k.textLabel || "Text",
|
|
31560
|
+
chatTitle: k.headerName || "Chat with FlowEngage",
|
|
31561
|
+
hasCustomTitle: !!(k.headerName && String(k.headerName).trim()),
|
|
31562
|
+
introGreeting: nt,
|
|
31563
|
+
inputPlaceholder: k.inputPlaceholder || "Type your message",
|
|
31564
|
+
analysingLabel: k.analysingLabel || "analysing..."
|
|
31565
|
+
}, j = Oe.elevenLabsAgentId || t?.elevenLabsAgentId || null, it = t?.siteId || n?.siteId || null, at = t?.apiBaseUrl || "";
|
|
31446
31566
|
c(() => {
|
|
31447
31567
|
ar(t?.siteType || null);
|
|
31448
31568
|
}, [t?.siteType]);
|
|
@@ -31453,10 +31573,10 @@ function bk() {
|
|
|
31453
31573
|
]), st = u && String(u).trim() || t?.ownerProfileImageUrl && String(t.ownerProfileImageUrl).trim() || null, ct = r.some((e) => e.sender === "user"), lt = f(() => {
|
|
31454
31574
|
let e = r.findIndex((e) => e.sender === "user");
|
|
31455
31575
|
return e === -1 ? !1 : r.slice(e + 1).some((e) => e.sender === "bot" || e.sender === "ai" || e.sender === "agent");
|
|
31456
|
-
}, [r]), ut = !!(
|
|
31576
|
+
}, [r]), ut = !!(Oe._dashboardLivePreview || De._dashboardLivePreview), [M, dt] = m(() => ut ? "text_chat" : "entry_prompt"), [ft, pt] = m(""), [mt, N] = m(null), [ht, gt] = m(h || ""), [_t, vt] = m(""), [yt, bt] = m(!1), [xt, St] = m(0), [Ct, wt] = m(null), [Tt, Et] = m(null), [Dt, Ot] = m(""), [kt, At] = m(!1), [jt, Mt] = m(!1), [Nt, Pt] = m(!1), Ft = p(null), It = p(!1), Lt = !h && ct && lt && M !== "voice_mode";
|
|
31457
31577
|
d(() => {
|
|
31458
31578
|
if (e !== "ready" || It.current) return;
|
|
31459
|
-
if (It.current = !0, !
|
|
31579
|
+
if (It.current = !0, !Pe) {
|
|
31460
31580
|
dt("minimized_orb");
|
|
31461
31581
|
return;
|
|
31462
31582
|
}
|
|
@@ -31464,13 +31584,13 @@ function bk() {
|
|
|
31464
31584
|
try {
|
|
31465
31585
|
t = jr().shouldResumeVoice;
|
|
31466
31586
|
} catch {}
|
|
31467
|
-
let n =
|
|
31587
|
+
let n = Ne(), r = it ? ke(it) : null, i = n || !!r?.transcript;
|
|
31468
31588
|
if (t) {
|
|
31469
|
-
|
|
31589
|
+
se?.({ notifyChatInitiated: !0 }), le?.(!0), dt("voice_mode");
|
|
31470
31590
|
return;
|
|
31471
31591
|
}
|
|
31472
|
-
if (
|
|
31473
|
-
|
|
31592
|
+
if (Ie()) {
|
|
31593
|
+
se?.({ notifyChatInitiated: !1 }), dt("text_chat");
|
|
31474
31594
|
return;
|
|
31475
31595
|
}
|
|
31476
31596
|
if (i) {
|
|
@@ -31478,13 +31598,13 @@ function bk() {
|
|
|
31478
31598
|
dt("minimized_orb");
|
|
31479
31599
|
return;
|
|
31480
31600
|
}
|
|
31481
|
-
|
|
31601
|
+
se?.({ notifyChatInitiated: !0 }), le?.(!0), dt("voice_mode");
|
|
31482
31602
|
return;
|
|
31483
31603
|
}
|
|
31484
31604
|
if (it) try {
|
|
31485
|
-
|
|
31605
|
+
Ae(it);
|
|
31486
31606
|
} catch {}
|
|
31487
|
-
if (
|
|
31607
|
+
if (de(it)) {
|
|
31488
31608
|
dt("minimized_orb");
|
|
31489
31609
|
return;
|
|
31490
31610
|
}
|
|
@@ -31507,18 +31627,18 @@ function bk() {
|
|
|
31507
31627
|
Et(e), Ot("");
|
|
31508
31628
|
}, []);
|
|
31509
31629
|
c(() => {
|
|
31510
|
-
if (!
|
|
31630
|
+
if (!E || ee !== "connected") {
|
|
31511
31631
|
St(0);
|
|
31512
31632
|
return;
|
|
31513
31633
|
}
|
|
31514
31634
|
let e = () => {
|
|
31515
|
-
let e = new Date(
|
|
31635
|
+
let e = new Date(E).getTime();
|
|
31516
31636
|
isNaN(e) || St(Math.max(0, Math.floor((Date.now() - e) / 1e3)));
|
|
31517
31637
|
};
|
|
31518
31638
|
e();
|
|
31519
31639
|
let t = window.setInterval(e, 1e3);
|
|
31520
31640
|
return () => window.clearInterval(t);
|
|
31521
|
-
}, [
|
|
31641
|
+
}, [E, ee]);
|
|
31522
31642
|
let Ht = o(() => {
|
|
31523
31643
|
dt("call_screen"), Mt(!1);
|
|
31524
31644
|
}, []), Ut = o(() => {
|
|
@@ -31542,7 +31662,7 @@ function bk() {
|
|
|
31542
31662
|
hasIncomingCall: !!w?.callId,
|
|
31543
31663
|
activeCallId: T,
|
|
31544
31664
|
callConnectionState: ee
|
|
31545
|
-
}), Ft.current = e, M === "voice_mode" &&
|
|
31665
|
+
}), Ft.current = e, M === "voice_mode" && le?.(!1), se?.(), Ht());
|
|
31546
31666
|
}
|
|
31547
31667
|
}, [
|
|
31548
31668
|
T,
|
|
@@ -31550,8 +31670,8 @@ function bk() {
|
|
|
31550
31670
|
Ht,
|
|
31551
31671
|
w?.callId,
|
|
31552
31672
|
i,
|
|
31553
|
-
|
|
31554
|
-
|
|
31673
|
+
se,
|
|
31674
|
+
le,
|
|
31555
31675
|
M
|
|
31556
31676
|
]), c(() => {
|
|
31557
31677
|
!w && !T && M === "call_screen" && dt("text_chat");
|
|
@@ -31563,16 +31683,16 @@ function bk() {
|
|
|
31563
31683
|
!T && jt && Mt(!1);
|
|
31564
31684
|
}, [T, jt]), c(() => {
|
|
31565
31685
|
if (!s || C) {
|
|
31566
|
-
|
|
31686
|
+
xe?.(""), be?.();
|
|
31567
31687
|
return;
|
|
31568
31688
|
}
|
|
31569
31689
|
if (!ft.trim() || Tt) {
|
|
31570
|
-
|
|
31571
|
-
let e = window.setTimeout(() =>
|
|
31690
|
+
xe?.("");
|
|
31691
|
+
let e = window.setTimeout(() => be?.(), 100);
|
|
31572
31692
|
return () => window.clearTimeout(e);
|
|
31573
31693
|
}
|
|
31574
|
-
|
|
31575
|
-
let e = window.setTimeout(() =>
|
|
31694
|
+
ye?.();
|
|
31695
|
+
let e = window.setTimeout(() => xe?.(ft), 120), t = window.setTimeout(() => be?.(), 1200);
|
|
31576
31696
|
return () => {
|
|
31577
31697
|
window.clearTimeout(e), window.clearTimeout(t);
|
|
31578
31698
|
};
|
|
@@ -31581,9 +31701,9 @@ function bk() {
|
|
|
31581
31701
|
Tt,
|
|
31582
31702
|
s,
|
|
31583
31703
|
C,
|
|
31704
|
+
ye,
|
|
31584
31705
|
be,
|
|
31585
|
-
xe
|
|
31586
|
-
Se
|
|
31706
|
+
xe
|
|
31587
31707
|
]);
|
|
31588
31708
|
let Wt = (e) => e ? {
|
|
31589
31709
|
replyTo: e.messageId || e.id || null,
|
|
@@ -31597,7 +31717,7 @@ function bk() {
|
|
|
31597
31717
|
vt("Please enter a valid email so we can continue helping you.");
|
|
31598
31718
|
return;
|
|
31599
31719
|
}
|
|
31600
|
-
await
|
|
31720
|
+
await ce(e), vt(""), bt(!0), setTimeout(() => bt(!1), 3e3);
|
|
31601
31721
|
return;
|
|
31602
31722
|
}
|
|
31603
31723
|
let t = Wt(mt);
|
|
@@ -31605,8 +31725,8 @@ function bk() {
|
|
|
31605
31725
|
if (Tt) {
|
|
31606
31726
|
try {
|
|
31607
31727
|
At(!0), Ot("");
|
|
31608
|
-
let e = await
|
|
31609
|
-
pt(""), N(null), Bt(), await
|
|
31728
|
+
let e = await oe(Tt), n = e?.data || e, r = ft.trim() || `Shared file: ${$D(Tt)}`;
|
|
31729
|
+
pt(""), N(null), Bt(), await O(r, "", t, {
|
|
31610
31730
|
type: "file",
|
|
31611
31731
|
metadata: {
|
|
31612
31732
|
fileUrl: n?.fileUrl,
|
|
@@ -31623,20 +31743,20 @@ function bk() {
|
|
|
31623
31743
|
return;
|
|
31624
31744
|
}
|
|
31625
31745
|
let n = ft.trim();
|
|
31626
|
-
pt(""), N(null), await
|
|
31746
|
+
pt(""), N(null), await O(n, "", t);
|
|
31627
31747
|
}, Kt = o(() => {
|
|
31628
|
-
r.length !== 0 &&
|
|
31629
|
-
}, [r.length,
|
|
31748
|
+
r.length !== 0 && pe?.();
|
|
31749
|
+
}, [r.length, pe]), qt = (e) => {
|
|
31630
31750
|
let t = Math.floor(e / 60);
|
|
31631
31751
|
return `${String(t).padStart(2, "0")}:${String(e % 60).padStart(2, "0")}`;
|
|
31632
31752
|
}, Jt = o(async (e) => {
|
|
31633
31753
|
if (C || b) return;
|
|
31634
31754
|
let t = e.message || e.label || e.text || "";
|
|
31635
|
-
t.trim() && await
|
|
31755
|
+
t.trim() && await O(t.trim(), "");
|
|
31636
31756
|
}, [
|
|
31637
31757
|
C,
|
|
31638
31758
|
b,
|
|
31639
|
-
|
|
31759
|
+
O
|
|
31640
31760
|
]), Yt = Rt && M === "entry_prompt" ? { inset: 0 } : Rt && M === "text_chat" ? {
|
|
31641
31761
|
left: 0,
|
|
31642
31762
|
right: 0,
|
|
@@ -31657,19 +31777,19 @@ function bk() {
|
|
|
31657
31777
|
height: "min(640px, calc(100vh - 120px))",
|
|
31658
31778
|
borderRadius: "22px",
|
|
31659
31779
|
overflow: "hidden",
|
|
31660
|
-
...
|
|
31780
|
+
...Be === "bottom-left" ? {
|
|
31661
31781
|
left: "1.5rem",
|
|
31662
|
-
bottom:
|
|
31782
|
+
bottom: Ye
|
|
31663
31783
|
} : {
|
|
31664
31784
|
right: "1.5rem",
|
|
31665
|
-
bottom:
|
|
31785
|
+
bottom: Ye
|
|
31666
31786
|
}
|
|
31667
|
-
} :
|
|
31787
|
+
} : Be === "bottom-left" ? {
|
|
31668
31788
|
left: "1.5rem",
|
|
31669
|
-
bottom:
|
|
31789
|
+
bottom: Ye
|
|
31670
31790
|
} : {
|
|
31671
31791
|
right: "1.5rem",
|
|
31672
|
-
bottom:
|
|
31792
|
+
bottom: Ye
|
|
31673
31793
|
}, Xt = o(() => {
|
|
31674
31794
|
M !== "minimized_orb" && (Pt(!0), setTimeout(() => {
|
|
31675
31795
|
dt("minimized_orb"), Pt(!1), T && Mt(!0);
|
|
@@ -31682,13 +31802,13 @@ function bk() {
|
|
|
31682
31802
|
t.resume().catch(() => {}), setTimeout(() => t.close().catch(() => {}), 3e3);
|
|
31683
31803
|
}
|
|
31684
31804
|
} catch {}
|
|
31685
|
-
|
|
31805
|
+
se({ notifyChatInitiated: !0 }), le?.(!0), dt("voice_mode");
|
|
31686
31806
|
}, $t = () => {
|
|
31687
|
-
|
|
31807
|
+
se({ notifyChatInitiated: !0 }), le?.(!1), dt("text_chat");
|
|
31688
31808
|
}, en = () => {
|
|
31689
|
-
|
|
31809
|
+
le?.(!1), Xt();
|
|
31690
31810
|
};
|
|
31691
|
-
return e !== "ready" || !
|
|
31811
|
+
return e !== "ready" || !Ze || Me.chat === !1 || !tt ? null : /* @__PURE__ */ _("div", {
|
|
31692
31812
|
className: "flowengage-widget-root",
|
|
31693
31813
|
style: {
|
|
31694
31814
|
position: "fixed",
|
|
@@ -31699,14 +31819,14 @@ function bk() {
|
|
|
31699
31819
|
onTouchMove: (e) => e.stopPropagation(),
|
|
31700
31820
|
children: [
|
|
31701
31821
|
M === "entry_prompt" && /* @__PURE__ */ g(mk, {
|
|
31702
|
-
copy:
|
|
31703
|
-
orbColors:
|
|
31704
|
-
primaryColor:
|
|
31822
|
+
copy: rt,
|
|
31823
|
+
orbColors: Fe,
|
|
31824
|
+
primaryColor: Le,
|
|
31705
31825
|
onYes: () => {
|
|
31706
|
-
|
|
31826
|
+
fe(it), Qt();
|
|
31707
31827
|
},
|
|
31708
31828
|
onLater: () => {
|
|
31709
|
-
|
|
31829
|
+
fe(it), Xt();
|
|
31710
31830
|
},
|
|
31711
31831
|
isMobile: Rt,
|
|
31712
31832
|
isClosing: Nt
|
|
@@ -31730,7 +31850,7 @@ function bk() {
|
|
|
31730
31850
|
transformOrigin: "bottom right",
|
|
31731
31851
|
display: "inline-flex",
|
|
31732
31852
|
flexDirection: "column",
|
|
31733
|
-
alignItems:
|
|
31853
|
+
alignItems: Be === "bottom-left" ? "flex-start" : "flex-end",
|
|
31734
31854
|
gap: "10px"
|
|
31735
31855
|
},
|
|
31736
31856
|
children: [T && /* @__PURE__ */ _("button", {
|
|
@@ -31782,15 +31902,15 @@ function bk() {
|
|
|
31782
31902
|
})]
|
|
31783
31903
|
})]
|
|
31784
31904
|
}), /* @__PURE__ */ g(pk, {
|
|
31785
|
-
size:
|
|
31786
|
-
orbColors:
|
|
31787
|
-
onClick: T ? Ht :
|
|
31905
|
+
size: ze,
|
|
31906
|
+
orbColors: Fe,
|
|
31907
|
+
onClick: T ? Ht : Pe ? Zt : $t
|
|
31788
31908
|
})]
|
|
31789
31909
|
}),
|
|
31790
31910
|
M === "connection_modal" && /* @__PURE__ */ g(hk, {
|
|
31791
|
-
copy:
|
|
31792
|
-
orbColors:
|
|
31793
|
-
primaryColor:
|
|
31911
|
+
copy: rt,
|
|
31912
|
+
orbColors: Fe,
|
|
31913
|
+
primaryColor: Le,
|
|
31794
31914
|
onVoice: Qt,
|
|
31795
31915
|
onText: $t,
|
|
31796
31916
|
onClose: Xt,
|
|
@@ -31798,46 +31918,47 @@ function bk() {
|
|
|
31798
31918
|
isClosing: Nt
|
|
31799
31919
|
}),
|
|
31800
31920
|
M === "voice_mode" && /* @__PURE__ */ g(gk, {
|
|
31801
|
-
orbColors:
|
|
31921
|
+
orbColors: Fe,
|
|
31802
31922
|
onEnterChat: $t,
|
|
31803
31923
|
onEndChat: en,
|
|
31804
31924
|
agentId: j,
|
|
31805
31925
|
siteId: it,
|
|
31806
31926
|
apiBaseUrl: at,
|
|
31807
|
-
chatId:
|
|
31808
|
-
historyRef:
|
|
31809
|
-
onMessageSync:
|
|
31810
|
-
voiceEndCounter:
|
|
31927
|
+
chatId: re,
|
|
31928
|
+
historyRef: ie,
|
|
31929
|
+
onMessageSync: ae,
|
|
31930
|
+
voiceEndCounter: Ee,
|
|
31811
31931
|
websiteName: t?.websiteName,
|
|
31812
|
-
voiceFirstMessage:
|
|
31932
|
+
voiceFirstMessage: De.voiceFirstMessage || null,
|
|
31933
|
+
captureVisitorEmail: ce
|
|
31813
31934
|
}, "voice"),
|
|
31814
31935
|
M === "call_screen" && /* @__PURE__ */ g(bO, {
|
|
31815
31936
|
incomingCall: w,
|
|
31816
31937
|
activeCallId: T,
|
|
31817
31938
|
callConnectionState: ee,
|
|
31818
31939
|
callDurationSeconds: xt,
|
|
31819
|
-
isCallMuted:
|
|
31940
|
+
isCallMuted: te,
|
|
31820
31941
|
agentName: ot,
|
|
31821
31942
|
agentHeadshot: st,
|
|
31822
|
-
fallbackAgentName:
|
|
31823
|
-
acceptCall:
|
|
31824
|
-
rejectCall:
|
|
31825
|
-
endWebRTCCall:
|
|
31826
|
-
toggleCallMute:
|
|
31943
|
+
fallbackAgentName: A,
|
|
31944
|
+
acceptCall: me,
|
|
31945
|
+
rejectCall: he,
|
|
31946
|
+
endWebRTCCall: ge,
|
|
31947
|
+
toggleCallMute: _e,
|
|
31827
31948
|
formatCallDuration: qt,
|
|
31828
31949
|
onMinimize: Ut,
|
|
31829
|
-
primaryColor:
|
|
31830
|
-
orbColors:
|
|
31950
|
+
primaryColor: Le,
|
|
31951
|
+
orbColors: Fe,
|
|
31831
31952
|
chatHistory: r
|
|
31832
31953
|
}),
|
|
31833
31954
|
M === "text_chat" && /* @__PURE__ */ g(yk, {
|
|
31834
31955
|
isClosing: Nt,
|
|
31835
|
-
copy:
|
|
31836
|
-
orbColors:
|
|
31837
|
-
primaryColor:
|
|
31838
|
-
chatBgGradient:
|
|
31839
|
-
logo:
|
|
31840
|
-
quickChatOptions:
|
|
31956
|
+
copy: rt,
|
|
31957
|
+
orbColors: Fe,
|
|
31958
|
+
primaryColor: Le,
|
|
31959
|
+
chatBgGradient: Ve,
|
|
31960
|
+
logo: He,
|
|
31961
|
+
quickChatOptions: Ke,
|
|
31841
31962
|
onQuickChatSelect: Jt,
|
|
31842
31963
|
isMobile: Rt,
|
|
31843
31964
|
chatHistory: r,
|
|
@@ -31846,7 +31967,7 @@ function bk() {
|
|
|
31846
31967
|
activeScreen: a,
|
|
31847
31968
|
agentName: ot,
|
|
31848
31969
|
agentHeadshot: st,
|
|
31849
|
-
fallbackAgentName:
|
|
31970
|
+
fallbackAgentName: A,
|
|
31850
31971
|
input: ft,
|
|
31851
31972
|
setInput: pt,
|
|
31852
31973
|
onSubmit: Gt,
|
|
@@ -31866,29 +31987,29 @@ function bk() {
|
|
|
31866
31987
|
emailCaptureSuccess: yt,
|
|
31867
31988
|
replyContext: mt,
|
|
31868
31989
|
setReplyContext: N,
|
|
31869
|
-
webRTCError:
|
|
31990
|
+
webRTCError: ne,
|
|
31870
31991
|
micError: Ct,
|
|
31871
31992
|
setMicError: wt,
|
|
31872
|
-
dismissCallError:
|
|
31993
|
+
dismissCallError: ve,
|
|
31873
31994
|
activeCallId: T,
|
|
31874
|
-
isCallMuted:
|
|
31875
|
-
toggleCallMute:
|
|
31876
|
-
endWebRTCCall:
|
|
31995
|
+
isCallMuted: te,
|
|
31996
|
+
toggleCallMute: _e,
|
|
31997
|
+
endWebRTCCall: ge,
|
|
31877
31998
|
formatCallDuration: qt,
|
|
31878
31999
|
callDurationSeconds: xt,
|
|
31879
32000
|
onCollapse: Xt,
|
|
31880
32001
|
onStartVoice: Qt,
|
|
31881
|
-
voiceEnabled:
|
|
32002
|
+
voiceEnabled: Pe,
|
|
31882
32003
|
onNewChat: Kt,
|
|
31883
32004
|
onMinimize: Ut,
|
|
31884
32005
|
onExpand: Ht,
|
|
31885
32006
|
isCallMinimized: !!T,
|
|
31886
|
-
showPoweredBy:
|
|
31887
|
-
privacyPolicyUrl:
|
|
31888
|
-
headerBgColor:
|
|
31889
|
-
getVisitorChatHistory:
|
|
31890
|
-
resumeChat:
|
|
31891
|
-
isSessionRestoring:
|
|
32007
|
+
showPoweredBy: qe,
|
|
32008
|
+
privacyPolicyUrl: Xe,
|
|
32009
|
+
headerBgColor: Je,
|
|
32010
|
+
getVisitorChatHistory: Se,
|
|
32011
|
+
resumeChat: Ce,
|
|
32012
|
+
isSessionRestoring: we
|
|
31892
32013
|
}),
|
|
31893
32014
|
/* @__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 " })
|
|
31894
32015
|
]
|