@flowengage/react-chatbot 4.0.11 → 4.0.13
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.
|
@@ -481,7 +481,7 @@ var nt = (e) => {
|
|
|
481
481
|
let l = new ArrayBuffer(t), u = new Uint8Array(l);
|
|
482
482
|
for (r = 0; r < n; r += 4) a = tt[e.charCodeAt(r)], o = tt[e.charCodeAt(r + 1)], s = tt[e.charCodeAt(r + 2)], c = tt[e.charCodeAt(r + 3)], u[i++] = a << 2 | o >> 4, u[i++] = (o & 15) << 4 | s >> 2, u[i++] = (s & 3) << 6 | c & 63;
|
|
483
483
|
return l;
|
|
484
|
-
}, k = typeof ArrayBuffer == "function",
|
|
484
|
+
}, k = typeof ArrayBuffer == "function", rt = (e, t) => {
|
|
485
485
|
if (typeof e != "string") return {
|
|
486
486
|
type: "message",
|
|
487
487
|
data: it(e, t)
|
|
@@ -489,12 +489,12 @@ var nt = (e) => {
|
|
|
489
489
|
let n = e.charAt(0);
|
|
490
490
|
return n === "b" ? {
|
|
491
491
|
type: "message",
|
|
492
|
-
data:
|
|
492
|
+
data: A(e.substring(1), t)
|
|
493
493
|
} : We[n] ? e.length > 1 ? {
|
|
494
494
|
type: We[n],
|
|
495
495
|
data: e.substring(1)
|
|
496
496
|
} : { type: We[n] } : Ge;
|
|
497
|
-
},
|
|
497
|
+
}, A = (e, t) => k ? it(nt(e), t) : {
|
|
498
498
|
base64: !0,
|
|
499
499
|
data: e
|
|
500
500
|
}, it = (e, t) => {
|
|
@@ -512,7 +512,7 @@ var nt = (e) => {
|
|
|
512
512
|
}, st = (e, t) => {
|
|
513
513
|
let n = e.split(at), r = [];
|
|
514
514
|
for (let e = 0; e < n.length; e++) {
|
|
515
|
-
let i =
|
|
515
|
+
let i = rt(n[e], t);
|
|
516
516
|
if (r.push(i), i.type === "error") break;
|
|
517
517
|
}
|
|
518
518
|
return r;
|
|
@@ -569,7 +569,7 @@ function ft(e, t) {
|
|
|
569
569
|
} else {
|
|
570
570
|
if (ut(n) < i) break;
|
|
571
571
|
let e = dt(n, i);
|
|
572
|
-
s.enqueue(
|
|
572
|
+
s.enqueue(rt(a ? e : lt.decode(e), t)), r = 0;
|
|
573
573
|
}
|
|
574
574
|
if (i === 0 || i > e) {
|
|
575
575
|
s.enqueue(Ge);
|
|
@@ -682,7 +682,7 @@ var Dt = class extends Error {
|
|
|
682
682
|
this.readyState = "open", this.writable = !0, super.emitReserved("open");
|
|
683
683
|
}
|
|
684
684
|
onData(e) {
|
|
685
|
-
let t =
|
|
685
|
+
let t = rt(e, this.socket.binaryType);
|
|
686
686
|
this.onPacket(t);
|
|
687
687
|
}
|
|
688
688
|
onPacket(e) {
|
|
@@ -2813,7 +2813,7 @@ function jr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
2813
2813
|
let i = f(() => e ? {
|
|
2814
2814
|
...t || {},
|
|
2815
2815
|
siteId: e
|
|
2816
|
-
} : 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(ve().isOpen), [T, te] = m(ve().activeScreen), [ne, re] = m(ve().isHumanHandled), [E, D] = m(ve().agentName), [se, de] = m(ve().agentHeadshot), [fe, pe] = m(() => be(i?.siteId)), [me, Se] = m(!1), [Ce, we] = m(!1), [Ee, De] = m("idle"), [Oe, ke] = m(!1), [Ae, je] = m(!1), [Me, Ne] = m(""), [Fe, Ie] = m(!1), [Le, ze] = m(!1), [O, Ue] = m(null), [We, Ge] = m(null), [Ke, qe] = m("idle"), [Je, Ye] = m(null), [Xe, Ze] = m(!1), [Qe, $e] = m(""), [et, tt] = m(!1), nt = p(null), k = p(null),
|
|
2816
|
+
} : 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(ve().isOpen), [T, te] = m(ve().activeScreen), [ne, re] = m(ve().isHumanHandled), [E, D] = m(ve().agentName), [se, de] = m(ve().agentHeadshot), [fe, pe] = m(() => be(i?.siteId)), [me, Se] = m(!1), [Ce, we] = m(!1), [Ee, De] = m("idle"), [Oe, ke] = m(!1), [Ae, je] = m(!1), [Me, Ne] = m(""), [Fe, Ie] = m(!1), [Le, ze] = m(!1), [O, Ue] = m(null), [We, Ge] = m(null), [Ke, qe] = m("idle"), [Je, Ye] = m(null), [Xe, Ze] = m(!1), [Qe, $e] = m(""), [et, tt] = m(!1), nt = p(null), k = p(null), rt = p(""), A = p(!1), it = p(null), at = p(null), ot = p(null), st = p(null), ct = p(null), lt = p(null), ut = p([]), dt = p(null), ft = p(null), j = p(null), pt = p(!1), mt = p(!1), ht = p(""), gt = p(null), _t = p(null), vt = p([]), yt = p(0), bt = p(E), xt = p([]), St = p(!1), Ct = p(!1), wt = p(i), Tt = p({
|
|
2817
2817
|
notifyRouteChange: () => {},
|
|
2818
2818
|
cleanup: () => {}
|
|
2819
2819
|
}), Et = o((e = {}) => {
|
|
@@ -2878,7 +2878,7 @@ function jr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
2878
2878
|
if (!(!t?.connected || !n || pt.current)) {
|
|
2879
2879
|
pt.current = !0, t.emit("call:connected", {
|
|
2880
2880
|
callId: n,
|
|
2881
|
-
chatId:
|
|
2881
|
+
chatId: rt.current,
|
|
2882
2882
|
connectedAt: e
|
|
2883
2883
|
});
|
|
2884
2884
|
try {
|
|
@@ -2921,7 +2921,7 @@ function jr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
2921
2921
|
if (!t || !n?.connected || !r || !e.callId) {
|
|
2922
2922
|
console.log("[FlowEngageProvider] deferring remote offer until peer/socket ready", {
|
|
2923
2923
|
callId: e.callId,
|
|
2924
|
-
chatId:
|
|
2924
|
+
chatId: rt.current,
|
|
2925
2925
|
hasPeerConnection: !!t,
|
|
2926
2926
|
socketConnected: !!n?.connected,
|
|
2927
2927
|
hasOffer: !!r
|
|
@@ -2934,7 +2934,7 @@ function jr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
2934
2934
|
})), ut.current.length > 0) {
|
|
2935
2935
|
console.log("[FlowEngageProvider] flushing queued agent ICE candidates after remote offer", {
|
|
2936
2936
|
callId: e.callId,
|
|
2937
|
-
chatId:
|
|
2937
|
+
chatId: rt.current,
|
|
2938
2938
|
queuedCount: ut.current.length
|
|
2939
2939
|
});
|
|
2940
2940
|
for (let e of ut.current) await t.addIceCandidate(new RTCIceCandidate(e));
|
|
@@ -2944,7 +2944,7 @@ function jr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
2944
2944
|
await t.setLocalDescription(i), n.emit("call:answer", {
|
|
2945
2945
|
callId: e.callId,
|
|
2946
2946
|
sdpAnswer: i.sdp,
|
|
2947
|
-
chatId:
|
|
2947
|
+
chatId: rt.current
|
|
2948
2948
|
});
|
|
2949
2949
|
};
|
|
2950
2950
|
c(() => {
|
|
@@ -2970,8 +2970,8 @@ function jr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
2970
2970
|
if (!e) return;
|
|
2971
2971
|
let a = t.siteId, o = he(a), s = Te(a), c = "";
|
|
2972
2972
|
try {
|
|
2973
|
-
let e =
|
|
2974
|
-
if (
|
|
2973
|
+
let e = A.current, r = it.current;
|
|
2974
|
+
if (A.current = !1, it.current = null, c = (await Be({
|
|
2975
2975
|
apiBaseUrl: t.apiBaseUrl,
|
|
2976
2976
|
userId: n.userId,
|
|
2977
2977
|
siteId: a,
|
|
@@ -2984,7 +2984,7 @@ function jr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
2984
2984
|
} catch (e) {
|
|
2985
2985
|
console.warn("[FlowEngageProvider] resolve-session failed, reusing persisted or ephemeral chat id", e?.message || e), c = o || ue(), _e(a, c);
|
|
2986
2986
|
}
|
|
2987
|
-
|
|
2987
|
+
rt.current = c;
|
|
2988
2988
|
let l = He({
|
|
2989
2989
|
apiBaseUrl: t.apiBaseUrl,
|
|
2990
2990
|
userId: n.userId,
|
|
@@ -3128,7 +3128,7 @@ function jr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3128
3128
|
if (!ot.current || !ot.current.remoteDescription) {
|
|
3129
3129
|
console.log("[FlowEngageProvider] queueing agent ICE candidate until peer/remote description is ready", {
|
|
3130
3130
|
callId: e.callId,
|
|
3131
|
-
chatId: e.chatId ||
|
|
3131
|
+
chatId: e.chatId || rt.current,
|
|
3132
3132
|
queueSize: ut.current.length + 1
|
|
3133
3133
|
}), ut.current.push(t);
|
|
3134
3134
|
return;
|
|
@@ -3203,7 +3203,7 @@ function jr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3203
3203
|
a
|
|
3204
3204
|
]), c(() => () => {
|
|
3205
3205
|
if (Fe && !St.current && xt.current.length > 0) {
|
|
3206
|
-
let e =
|
|
3206
|
+
let e = rt.current, t = xt.current, n = k.current;
|
|
3207
3207
|
n && e && t.length > 0 && (console.log("[FlowEngageProvider] safety-net: syncing voice transcript on unmount"), n.beaconSyncVoice(e, t) || n.syncVoice(e, t).catch(() => {}), St.current = !0);
|
|
3208
3208
|
}
|
|
3209
3209
|
}, [Fe, _]), c(() => {
|
|
@@ -3375,10 +3375,10 @@ function jr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3375
3375
|
}
|
|
3376
3376
|
}, Ht = async (e) => {
|
|
3377
3377
|
let t = At(e);
|
|
3378
|
-
if (!t || !k.current || !
|
|
3378
|
+
if (!t || !k.current || !rt.current) return t;
|
|
3379
3379
|
try {
|
|
3380
3380
|
await k.current.trackVisitor({
|
|
3381
|
-
chatId:
|
|
3381
|
+
chatId: rt.current,
|
|
3382
3382
|
currentPagePath: typeof window < "u" && window.location.pathname || "/",
|
|
3383
3383
|
email: t
|
|
3384
3384
|
});
|
|
@@ -3538,7 +3538,7 @@ function jr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3538
3538
|
Dt
|
|
3539
3539
|
]), c(() => {
|
|
3540
3540
|
let e = () => {
|
|
3541
|
-
let e =
|
|
3541
|
+
let e = rt.current, t = k.current;
|
|
3542
3542
|
if (!t || !e) return;
|
|
3543
3543
|
if (Ct.current && xt.current.length > 0) {
|
|
3544
3544
|
let e = wt.current?.siteId;
|
|
@@ -3557,9 +3557,9 @@ function jr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3557
3557
|
}, []);
|
|
3558
3558
|
let Zt = o(() => {
|
|
3559
3559
|
let e = i?.siteId;
|
|
3560
|
-
ge(e),
|
|
3560
|
+
ge(e), A.current = !0, it.current = null, nt.current?.disconnect(), S([]), b(""), rt.current = "", ze(!1), re(!1), D(null), de(null), tt(!0), s((e) => e + 1);
|
|
3561
3561
|
}, [i?.siteId]), Qt = o((e) => {
|
|
3562
|
-
i?.siteId,
|
|
3562
|
+
i?.siteId, A.current = !1, it.current = e, nt.current?.disconnect(), S([]), b(""), rt.current = "", ze(!1), re(!1), D(null), de(null), tt(!0), s((e) => e + 1);
|
|
3563
3563
|
}, [i?.siteId]), $t = f(() => ({
|
|
3564
3564
|
status: l,
|
|
3565
3565
|
error: d,
|
|
@@ -30126,39 +30126,54 @@ function qk({ copy: e, orbColors: t, primaryColor: n, onVoice: r, onText: i, onC
|
|
|
30126
30126
|
]
|
|
30127
30127
|
});
|
|
30128
30128
|
}
|
|
30129
|
-
function Jk({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, voiceId: i, siteId: a, apiBaseUrl: s,
|
|
30130
|
-
let [
|
|
30131
|
-
|
|
30132
|
-
|
|
30129
|
+
function Jk({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, voiceId: i, siteId: a, apiBaseUrl: s, chatId: l, historyRef: u, onMessageSync: d }) {
|
|
30130
|
+
let [f, h] = m("idle"), [v, y] = m(!1), [b, x] = m(!1), S = p(null), C = p(""), w = p(async () => {}), T = p(!1), ee = p(!1), te = p(!1), ne = p(!1), re = p("minimized"), E = p(null), ie = p(null), ae = p(null), oe = o((e = "minimized") => {
|
|
30131
|
+
re.current = e, ne.current = !0, queueMicrotask(() => {
|
|
30132
|
+
T.current || (T.current = !0, w.current?.());
|
|
30133
30133
|
});
|
|
30134
|
-
}, [
|
|
30135
|
-
|
|
30134
|
+
}, [u]), D = o(async (e) => {
|
|
30135
|
+
ne.current = !0;
|
|
30136
30136
|
try {
|
|
30137
|
-
await
|
|
30137
|
+
await S.current?.endSession?.();
|
|
30138
30138
|
} catch {}
|
|
30139
|
-
|
|
30139
|
+
let t = E.current, n = ie.current;
|
|
30140
|
+
if (t && l && s) {
|
|
30141
|
+
let e = n ? Math.round((Date.now() - n) / 1e3) : 0;
|
|
30142
|
+
fetch(`${s}/api/voice/save-chat-recording`, {
|
|
30143
|
+
method: "POST",
|
|
30144
|
+
headers: { "Content-Type": "application/json" },
|
|
30145
|
+
body: JSON.stringify({
|
|
30146
|
+
chatId: l,
|
|
30147
|
+
elevenLabsConversationId: t,
|
|
30148
|
+
duration: e
|
|
30149
|
+
})
|
|
30150
|
+
}).catch((e) => console.warn("[FlowEngage] save-chat-recording failed:", e.message));
|
|
30151
|
+
}
|
|
30152
|
+
if (E.current = null, ie.current = null, S.current = null, h("idle"), y(!1), T.current = !1, Cr(), a) try {
|
|
30140
30153
|
Me(a);
|
|
30141
30154
|
} catch {}
|
|
30142
|
-
typeof
|
|
30155
|
+
typeof d == "function" && await d(u.current), e?.();
|
|
30143
30156
|
}, [
|
|
30144
|
-
l,
|
|
30145
30157
|
u,
|
|
30146
|
-
|
|
30158
|
+
d,
|
|
30159
|
+
a,
|
|
30160
|
+
l,
|
|
30161
|
+
s
|
|
30147
30162
|
]);
|
|
30148
|
-
return
|
|
30149
|
-
|
|
30150
|
-
}, [
|
|
30163
|
+
return w.current = () => D(re.current === "chat" ? t : n), c(() => {
|
|
30164
|
+
ee.current = v;
|
|
30165
|
+
}, [v]), c(() => {
|
|
30151
30166
|
let e = !1, n = null;
|
|
30152
30167
|
return (async () => {
|
|
30153
30168
|
if (!r) {
|
|
30154
|
-
|
|
30169
|
+
h("error");
|
|
30155
30170
|
return;
|
|
30156
30171
|
}
|
|
30157
30172
|
try {
|
|
30158
30173
|
if ((await navigator.mediaDevices.getUserMedia({ audio: !0 })).getTracks().forEach((e) => e.stop()), e) return;
|
|
30159
|
-
|
|
30160
|
-
if (a &&
|
|
30161
|
-
let e = DO(
|
|
30174
|
+
u.current = [], C.current = "", T.current = !1, te.current = !1, ne.current = !1, re.current = "minimized", Sr({ onBeforeNavigate: () => {
|
|
30175
|
+
if (a && u.current.length > 0) try {
|
|
30176
|
+
let e = DO(u.current);
|
|
30162
30177
|
e && Ae(a, e);
|
|
30163
30178
|
} catch {}
|
|
30164
30179
|
if (a && typeof window < "u") try {
|
|
@@ -30169,120 +30184,123 @@ function Jk({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, voiceId: i
|
|
|
30169
30184
|
let t = Rk(Lk({
|
|
30170
30185
|
siteId: a || null,
|
|
30171
30186
|
apiBaseUrl: s || null,
|
|
30172
|
-
getLastUserVoiceText: () =>
|
|
30187
|
+
getLastUserVoiceText: () => C.current,
|
|
30173
30188
|
requestEndSession: () => {
|
|
30174
|
-
|
|
30189
|
+
oe();
|
|
30175
30190
|
}
|
|
30176
|
-
})), i = a ? je(a) : null, o = !!i?.transcript, c = typeof window < "u" ? window.location.pathname : "/",
|
|
30191
|
+
})), i = a ? je(a) : null, o = !!i?.transcript, c = typeof window < "u" ? window.location.pathname : "/", l = typeof document < "u" ? document.title : "", d = c === "/" || c === "", f = null;
|
|
30177
30192
|
try {
|
|
30178
30193
|
let e = await fetch(`${s}/api/voice/signed-url?siteId=${encodeURIComponent(a || "")}`, {
|
|
30179
30194
|
method: "GET",
|
|
30180
30195
|
headers: { "Content-Type": "application/json" }
|
|
30181
30196
|
});
|
|
30182
|
-
e.ok ? (
|
|
30197
|
+
e.ok ? (f = (await e.json()).signedUrl || null, f && console.log("[FlowEngage] ✅ Using signed ElevenLabs URL")) : console.warn("[FlowEngage] ⚠️ Signed URL fetch failed, falling back to agentId");
|
|
30183
30198
|
} catch (e) {
|
|
30184
30199
|
console.warn("[FlowEngage] ⚠️ Signed URL fetch error:", e.message);
|
|
30185
30200
|
}
|
|
30186
|
-
let
|
|
30201
|
+
let p = {
|
|
30187
30202
|
clientTools: t,
|
|
30188
30203
|
connectionType: "websocket",
|
|
30189
|
-
...
|
|
30204
|
+
...f ? { signedUrl: f } : { agentId: r }
|
|
30190
30205
|
};
|
|
30191
|
-
if (
|
|
30192
|
-
if (o)
|
|
30206
|
+
if (f) {
|
|
30207
|
+
if (o) p.overrides = { agent: { firstMessage: "" } };
|
|
30193
30208
|
else if (!d) {
|
|
30194
30209
|
let e = (c.split("/").filter(Boolean).pop() || "").replace(/[-_]/g, " ").replace(/\b\w/g, (e) => e.toUpperCase()), t = "";
|
|
30195
|
-
|
|
30210
|
+
l && l.includes("|") && (t = l.split("|").map((e) => e.trim()).filter(Boolean).reduce((e, t) => e.length <= t.length ? e : t));
|
|
30196
30211
|
let n = t || e || "this page";
|
|
30197
|
-
|
|
30212
|
+
p.overrides = { agent: { firstMessage: `Hi! I see you are currently on the ${n} page. Are you looking for something specific here?` } }, console.log(`[FlowEngage] 🏠 Page-context override: "${n}" for ${c}`);
|
|
30198
30213
|
}
|
|
30199
|
-
} else o && (
|
|
30200
|
-
let
|
|
30201
|
-
...
|
|
30214
|
+
} else o && (p.overrides = { agent: { firstMessage: "" } });
|
|
30215
|
+
let m = await jD.startSession({
|
|
30216
|
+
...p,
|
|
30217
|
+
onConnect: ({ conversationId: e }) => {
|
|
30218
|
+
E.current = e, ie.current = Date.now(), console.log("[FlowEngage] 🎙️ AI chat session connected:", e);
|
|
30219
|
+
},
|
|
30202
30220
|
onUnhandledClientToolCall: (e) => console.error("[FlowEngage] Unhandled tool:", e?.tool_name),
|
|
30203
30221
|
onModeChange: ({ mode: t }) => {
|
|
30204
|
-
e ||
|
|
30222
|
+
e || h(t === "speaking" ? "speaking" : "listening");
|
|
30205
30223
|
},
|
|
30206
30224
|
onMessage: (t) => {
|
|
30207
30225
|
if (e) return;
|
|
30208
30226
|
let n = t.role === "user" ? "user" : "bot", r = t.message || t.text || t.content || "";
|
|
30209
30227
|
if (r) {
|
|
30210
|
-
if (n === "user" && (
|
|
30228
|
+
if (n === "user" && (C.current = r), u.current = [...u.current, {
|
|
30211
30229
|
sender: n,
|
|
30212
30230
|
message: r,
|
|
30213
30231
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
30214
30232
|
}], a) try {
|
|
30215
|
-
let e = DO(
|
|
30233
|
+
let e = DO(u.current);
|
|
30216
30234
|
e && Ae(a, e);
|
|
30217
30235
|
} catch {}
|
|
30218
|
-
Wk(n, r) &&
|
|
30236
|
+
Wk(n, r) && oe("minimized");
|
|
30219
30237
|
}
|
|
30220
30238
|
},
|
|
30221
30239
|
onError: (t) => {
|
|
30222
|
-
if (!e && !
|
|
30223
|
-
|
|
30240
|
+
if (!e && !ne.current && !te.current && !Ie()) {
|
|
30241
|
+
te.current = !0, console.error("[FlowEngageVoiceCall] session:error", {
|
|
30224
30242
|
message: t?.message,
|
|
30225
30243
|
name: t?.name,
|
|
30226
30244
|
raw: t
|
|
30227
30245
|
});
|
|
30228
30246
|
try {
|
|
30229
|
-
|
|
30247
|
+
S.current?.setMicMuted?.(!0);
|
|
30230
30248
|
} catch {}
|
|
30231
|
-
|
|
30249
|
+
y(!0), h("error"), oe("chat");
|
|
30232
30250
|
}
|
|
30233
30251
|
},
|
|
30234
30252
|
onDisconnect: (t) => {
|
|
30235
|
-
if (e ||
|
|
30236
|
-
let n =
|
|
30253
|
+
if (e || ne.current || te.current || Ie()) return;
|
|
30254
|
+
let n = u.current?.length || 0;
|
|
30237
30255
|
console.warn("[FlowEngageVoiceCall] session:disconnected", {
|
|
30238
30256
|
historyCount: n,
|
|
30239
30257
|
reason: t?.reason,
|
|
30240
30258
|
closeCode: t?.context?.code,
|
|
30241
30259
|
closeReason: t?.context?.reason || t?.message,
|
|
30242
|
-
lastUserText:
|
|
30243
|
-
wasMuted:
|
|
30244
|
-
}),
|
|
30260
|
+
lastUserText: C.current || "",
|
|
30261
|
+
wasMuted: ee.current
|
|
30262
|
+
}), te.current = !0;
|
|
30245
30263
|
try {
|
|
30246
|
-
|
|
30264
|
+
S.current?.setMicMuted?.(!0);
|
|
30247
30265
|
} catch {}
|
|
30248
|
-
|
|
30266
|
+
y(!0), oe("chat");
|
|
30249
30267
|
}
|
|
30250
30268
|
});
|
|
30251
30269
|
if (e) {
|
|
30252
|
-
|
|
30270
|
+
m.endSession().catch(() => {});
|
|
30253
30271
|
return;
|
|
30254
30272
|
}
|
|
30255
|
-
n =
|
|
30273
|
+
n = m, S.current = m, h("listening");
|
|
30256
30274
|
try {
|
|
30257
30275
|
let e = typeof window < "u" ? window.location.href : "", n = "[]";
|
|
30258
30276
|
try {
|
|
30259
30277
|
n = await t.list_page_forms();
|
|
30260
30278
|
} catch {}
|
|
30261
30279
|
let r = o ? `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${i.transcript}\n\n` : "";
|
|
30262
|
-
|
|
30280
|
+
m.sendContextualUpdate(`${r}Page: ${e}. SiteId: ${a || "unknown"}. Forms: ${n}. Voice: call end_voice_session or say you are ending the session to stop.`);
|
|
30263
30281
|
} catch {}
|
|
30264
30282
|
} catch (n) {
|
|
30265
|
-
e || (console.error("[FlowEngage] startSession failed", n),
|
|
30283
|
+
e || (console.error("[FlowEngage] startSession failed", n), h("error"), re.current = "chat", window.setTimeout(() => {
|
|
30266
30284
|
e || t?.();
|
|
30267
30285
|
}, 0));
|
|
30268
30286
|
}
|
|
30269
30287
|
})(), () => {
|
|
30270
|
-
e = !0,
|
|
30288
|
+
e = !0, ne.current = !0, Cr(), (n || S.current)?.endSession?.().catch(() => {});
|
|
30271
30289
|
};
|
|
30272
30290
|
}, [
|
|
30273
30291
|
r,
|
|
30274
30292
|
a,
|
|
30275
30293
|
s,
|
|
30276
|
-
|
|
30294
|
+
oe
|
|
30277
30295
|
]), c(() => {
|
|
30278
|
-
if (!
|
|
30296
|
+
if (!b) return;
|
|
30279
30297
|
let e = (e) => {
|
|
30280
30298
|
let t = e.composedPath?.()?.[0] || e.target;
|
|
30281
|
-
|
|
30299
|
+
ae.current && !ae.current.contains(t) && x(!1);
|
|
30282
30300
|
};
|
|
30283
30301
|
return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
|
|
30284
|
-
}, [
|
|
30285
|
-
ref:
|
|
30302
|
+
}, [b]), /* @__PURE__ */ _("div", {
|
|
30303
|
+
ref: ae,
|
|
30286
30304
|
style: {
|
|
30287
30305
|
position: "relative",
|
|
30288
30306
|
display: "flex",
|
|
@@ -30294,7 +30312,7 @@ function Jk({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, voiceId: i
|
|
|
30294
30312
|
children: [
|
|
30295
30313
|
/* @__PURE__ */ _("div", {
|
|
30296
30314
|
style: { position: "relative" },
|
|
30297
|
-
children: [
|
|
30315
|
+
children: [f === "listening" && /* @__PURE__ */ g("span", {
|
|
30298
30316
|
style: {
|
|
30299
30317
|
position: "absolute",
|
|
30300
30318
|
right: "100%",
|
|
@@ -30311,12 +30329,12 @@ function Jk({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, voiceId: i
|
|
|
30311
30329
|
children: "Listening..."
|
|
30312
30330
|
}), /* @__PURE__ */ g(Gk, {
|
|
30313
30331
|
size: 72,
|
|
30314
|
-
voiceState:
|
|
30315
|
-
isMuted:
|
|
30332
|
+
voiceState: f,
|
|
30333
|
+
isMuted: v,
|
|
30316
30334
|
orbColors: e
|
|
30317
30335
|
})]
|
|
30318
30336
|
}),
|
|
30319
|
-
|
|
30337
|
+
f === "error" && /* @__PURE__ */ g("span", {
|
|
30320
30338
|
style: {
|
|
30321
30339
|
color: "#f87171",
|
|
30322
30340
|
fontSize: "13px",
|
|
@@ -30332,28 +30350,28 @@ function Jk({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, voiceId: i
|
|
|
30332
30350
|
},
|
|
30333
30351
|
children: [/* @__PURE__ */ g("button", {
|
|
30334
30352
|
onClick: async () => {
|
|
30335
|
-
if (
|
|
30336
|
-
|
|
30353
|
+
if (S.current) try {
|
|
30354
|
+
v ? (await S.current.setMicMuted?.(!1), y(!1)) : (await S.current.setMicMuted?.(!0), y(!0));
|
|
30337
30355
|
} catch {}
|
|
30338
30356
|
},
|
|
30339
|
-
title:
|
|
30357
|
+
title: v ? "Unmute" : "Mute",
|
|
30340
30358
|
style: {
|
|
30341
30359
|
width: "24px",
|
|
30342
30360
|
height: "24px",
|
|
30343
30361
|
borderRadius: "50%",
|
|
30344
|
-
background:
|
|
30345
|
-
border:
|
|
30362
|
+
background: v ? "#7f1d1d" : "#1f2937",
|
|
30363
|
+
border: v ? "1.5px solid #ef4444" : "1.5px solid #4b5563",
|
|
30346
30364
|
display: "flex",
|
|
30347
30365
|
alignItems: "center",
|
|
30348
30366
|
justifyContent: "center",
|
|
30349
30367
|
cursor: "pointer",
|
|
30350
|
-
color:
|
|
30368
|
+
color: v ? "#f87171" : "white",
|
|
30351
30369
|
transition: "all 0.2s ease",
|
|
30352
30370
|
boxShadow: "0 2px 8px rgba(0,0,0,0.4)",
|
|
30353
30371
|
padding: 0,
|
|
30354
30372
|
flexShrink: 0
|
|
30355
30373
|
},
|
|
30356
|
-
children:
|
|
30374
|
+
children: v ? /* @__PURE__ */ _("svg", {
|
|
30357
30375
|
width: "16",
|
|
30358
30376
|
height: "16",
|
|
30359
30377
|
viewBox: "0 0 24 24",
|
|
@@ -30389,7 +30407,7 @@ function Jk({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, voiceId: i
|
|
|
30389
30407
|
color: "currentColor"
|
|
30390
30408
|
})
|
|
30391
30409
|
}), /* @__PURE__ */ g("button", {
|
|
30392
|
-
onClick: () =>
|
|
30410
|
+
onClick: () => x((e) => !e),
|
|
30393
30411
|
style: {
|
|
30394
30412
|
width: "24px",
|
|
30395
30413
|
height: "24px",
|
|
@@ -30412,7 +30430,7 @@ function Jk({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, voiceId: i
|
|
|
30412
30430
|
})
|
|
30413
30431
|
})]
|
|
30414
30432
|
}),
|
|
30415
|
-
|
|
30433
|
+
b && /* @__PURE__ */ _("div", {
|
|
30416
30434
|
style: {
|
|
30417
30435
|
position: "absolute",
|
|
30418
30436
|
bottom: 0,
|
|
@@ -30430,7 +30448,7 @@ function Jk({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, voiceId: i
|
|
|
30430
30448
|
children: [
|
|
30431
30449
|
/* @__PURE__ */ _("button", {
|
|
30432
30450
|
onClick: () => {
|
|
30433
|
-
|
|
30451
|
+
x(!1), re.current = "chat", D(t);
|
|
30434
30452
|
},
|
|
30435
30453
|
style: {
|
|
30436
30454
|
display: "flex",
|
|
@@ -30459,7 +30477,7 @@ function Jk({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, voiceId: i
|
|
|
30459
30477
|
}),
|
|
30460
30478
|
/* @__PURE__ */ _("button", {
|
|
30461
30479
|
onClick: () => {
|
|
30462
|
-
|
|
30480
|
+
x(!1), re.current = "minimized", D(n);
|
|
30463
30481
|
},
|
|
30464
30482
|
style: {
|
|
30465
30483
|
display: "flex",
|
|
@@ -30487,7 +30505,7 @@ function Jk({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, voiceId: i
|
|
|
30487
30505
|
children: [/* @__PURE__ */ g(HD, {}), "End Conversation"]
|
|
30488
30506
|
}),
|
|
30489
30507
|
/* @__PURE__ */ g("button", {
|
|
30490
|
-
onClick: () =>
|
|
30508
|
+
onClick: () => x(!1),
|
|
30491
30509
|
style: {
|
|
30492
30510
|
position: "absolute",
|
|
30493
30511
|
bottom: "8px",
|
|
@@ -31360,230 +31378,230 @@ function Zk({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
31360
31378
|
});
|
|
31361
31379
|
}
|
|
31362
31380
|
function Qk() {
|
|
31363
|
-
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: te, isCallMuted: ne, webRTCError: re, language: E,
|
|
31381
|
+
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: te, isCallMuted: ne, webRTCError: re, language: E, chatId: ie, historyRef: ae, onMessageSync: oe, sendMessage: D, uploadChatFile: se, openWidget: ce, captureVisitorEmail: le, setVoiceMode: ue, endConversation: de, startNewChat: me, acceptCall: he, rejectCall: ge, endWebRTCCall: _e, toggleCallMute: ve, dismissCallError: ye, startTyping: be, stopTyping: xe, updateTypingDraft: Se, getVisitorChatHistory: Ce, getVisitorChatThread: we, resumeChat: Te, isSessionRestoring: Ee } = Nn();
|
|
31364
31382
|
c(() => {
|
|
31365
31383
|
try {
|
|
31366
31384
|
or();
|
|
31367
31385
|
} catch {}
|
|
31368
31386
|
}, []);
|
|
31369
|
-
let
|
|
31370
|
-
...
|
|
31371
|
-
...
|
|
31372
|
-
}, ke = {
|
|
31373
|
-
...Ee.theme || {},
|
|
31374
|
-
...De.theme || {}
|
|
31387
|
+
let De = t?.widgetSettings || {}, Oe = n?.widgetSettings || {}, ke = {
|
|
31388
|
+
...De.branding || {},
|
|
31389
|
+
...Oe.branding || {}
|
|
31375
31390
|
}, Ae = {
|
|
31376
|
-
...
|
|
31377
|
-
...
|
|
31378
|
-
}, Ne =
|
|
31391
|
+
...De.theme || {},
|
|
31392
|
+
...Oe.theme || {}
|
|
31393
|
+
}, Ne = {
|
|
31394
|
+
...De.features || {},
|
|
31395
|
+
...Oe.features || {}
|
|
31396
|
+
}, Pe = Ne.voice !== !1, Ie = Array.isArray(Ae.orbColors) && Ae.orbColors.length > 0 ? Ae.orbColors : null, Le = Ae.buttonColor || Ae.primaryColor || Ie?.[0] || "#3B82F6", Re = Ae.position || "bottom-right", ze = ke.fallbackAgentName || "Agent", O = Bk(Ie ?? Ae.chatBgColors), Be = ke.logo || ke.logoUrl || null, Ve = E || "en", He = De.recommendations?.[Ve] || [], Ue = (Oe.recommendations?.[Ve] ?? He).filter((e) => String(e?.label ?? "").trim()).map((e, t) => ({
|
|
31379
31397
|
id: e.key || `qr-${t}`,
|
|
31380
31398
|
label: e.label,
|
|
31381
31399
|
message: e.label,
|
|
31382
31400
|
text: e.label
|
|
31383
|
-
})),
|
|
31384
|
-
entryPrompt:
|
|
31385
|
-
yesLabel:
|
|
31386
|
-
laterLabel:
|
|
31387
|
-
connectionTitle:
|
|
31388
|
-
voiceLabel:
|
|
31389
|
-
textLabel:
|
|
31390
|
-
chatTitle:
|
|
31391
|
-
introGreeting:
|
|
31392
|
-
inputPlaceholder:
|
|
31393
|
-
analysingLabel:
|
|
31394
|
-
},
|
|
31401
|
+
})), We = Array.isArray(ke.quickChatOptions) && ke.quickChatOptions.length > 0 ? ke.quickChatOptions : Ue, Ge = ke.hideWatermark === !0 ? !1 : ke.showPoweredBy !== !1, Ke = ke.chatbotEnabled !== !1 && Ae.chatbotEnabled !== !1, qe = De.greetings?.[E] || Oe.greetings?.[E] || ke.introGreeting || "Hello, I'm here to help you know more about OpenSense Labs.", Je = {
|
|
31402
|
+
entryPrompt: ke.entryPrompt || "Do you want to explore in a new way?",
|
|
31403
|
+
yesLabel: ke.yesLabel || "Yes",
|
|
31404
|
+
laterLabel: ke.laterLabel || "Later",
|
|
31405
|
+
connectionTitle: ke.connectionTitle || "How would you like to connect?",
|
|
31406
|
+
voiceLabel: ke.voiceLabel || "Voice",
|
|
31407
|
+
textLabel: ke.textLabel || "Text",
|
|
31408
|
+
chatTitle: ke.headerName || "Chat with FlowEngage",
|
|
31409
|
+
introGreeting: qe,
|
|
31410
|
+
inputPlaceholder: ke.inputPlaceholder || "Type your message",
|
|
31411
|
+
analysingLabel: ke.analysingLabel || "analysing..."
|
|
31412
|
+
}, Ye = Oe.elevenLabsAgentId || t?.elevenLabsAgentId || null, Xe = Oe.elevenLabsVoiceId || t?.elevenLabsVoiceId || null, Ze = t?.siteId || n?.siteId || null, Qe = t?.apiBaseUrl || "", $e = f(() => l && String(l).trim() || t?.ownerName && String(t.ownerName).trim() || t?.websiteName && String(t.websiteName).trim() || "Agent", [
|
|
31395
31413
|
l,
|
|
31396
31414
|
t?.ownerName,
|
|
31397
31415
|
t?.websiteName
|
|
31398
|
-
]),
|
|
31416
|
+
]), et = u && String(u).trim() || t?.ownerProfileImageUrl && String(t.ownerProfileImageUrl).trim() || null, tt = r.some((e) => e.sender === "user"), nt = f(() => {
|
|
31399
31417
|
let e = r.findIndex((e) => e.sender === "user");
|
|
31400
31418
|
return e === -1 ? !1 : r.slice(e + 1).some((e) => e.sender === "bot" || e.sender === "ai" || e.sender === "agent");
|
|
31401
|
-
}, [r]),
|
|
31419
|
+
}, [r]), k = !h && tt && nt, rt = !!(Oe._dashboardLivePreview || De._dashboardLivePreview), [A, it] = m(() => rt ? "text_chat" : "entry_prompt"), [at, ot] = m(""), [st, ct] = m(null), [lt, ut] = m(h || ""), [dt, ft] = m(""), [j, pt] = m(0), [mt, ht] = m(null), [gt, _t] = m(null), [vt, yt] = m(""), [bt, xt] = m(!1), [St, Ct] = m(!1), [wt, Tt] = m(!1), Et = p(null), Dt = p(!1);
|
|
31402
31420
|
d(() => {
|
|
31403
|
-
if (e !== "ready" ||
|
|
31404
|
-
if (
|
|
31405
|
-
|
|
31421
|
+
if (e !== "ready" || Dt.current) return;
|
|
31422
|
+
if (Dt.current = !0, !Pe) {
|
|
31423
|
+
it("minimized_orb");
|
|
31406
31424
|
return;
|
|
31407
31425
|
}
|
|
31408
31426
|
let t = !1;
|
|
31409
31427
|
try {
|
|
31410
31428
|
t = vr().shouldResumeVoice;
|
|
31411
31429
|
} catch {}
|
|
31412
|
-
let n = Fe(), r =
|
|
31430
|
+
let n = Fe(), r = Ze ? je(Ze) : null, i = n || !!r?.transcript;
|
|
31413
31431
|
if (t) {
|
|
31414
|
-
|
|
31432
|
+
ce?.({ notifyChatInitiated: !0 }), ue?.(!0), it("voice_mode");
|
|
31415
31433
|
return;
|
|
31416
31434
|
}
|
|
31417
|
-
if (
|
|
31418
|
-
Me(
|
|
31435
|
+
if (Ze) try {
|
|
31436
|
+
Me(Ze);
|
|
31419
31437
|
} catch {}
|
|
31420
31438
|
if (i) {
|
|
31421
|
-
|
|
31439
|
+
it("minimized_orb");
|
|
31422
31440
|
return;
|
|
31423
31441
|
}
|
|
31424
|
-
if (fe(
|
|
31425
|
-
|
|
31442
|
+
if (fe(Ze)) {
|
|
31443
|
+
it("minimized_orb");
|
|
31426
31444
|
return;
|
|
31427
31445
|
}
|
|
31428
31446
|
}, [e, r]);
|
|
31429
|
-
let [
|
|
31447
|
+
let [Ot, kt] = m(() => typeof window < "u" && window.matchMedia("(max-width: 640px)").matches);
|
|
31430
31448
|
c(() => {
|
|
31431
|
-
let e = window.matchMedia("(max-width: 640px)"), t = (e) =>
|
|
31449
|
+
let e = window.matchMedia("(max-width: 640px)"), t = (e) => kt(e.matches);
|
|
31432
31450
|
return e.addEventListener("change", t), () => e.removeEventListener("change", t);
|
|
31433
31451
|
}, []), c(() => {
|
|
31434
|
-
|
|
31452
|
+
ut(h || ""), h && ft("");
|
|
31435
31453
|
}, [h]);
|
|
31436
|
-
let
|
|
31437
|
-
|
|
31438
|
-
}, []),
|
|
31454
|
+
let At = o(() => {
|
|
31455
|
+
_t(null), yt("");
|
|
31456
|
+
}, []), jt = o((e) => {
|
|
31439
31457
|
let t = nO(e);
|
|
31440
31458
|
if (t) {
|
|
31441
|
-
|
|
31459
|
+
_t(null), yt(t);
|
|
31442
31460
|
return;
|
|
31443
31461
|
}
|
|
31444
|
-
|
|
31462
|
+
_t(e), yt("");
|
|
31445
31463
|
}, []);
|
|
31446
31464
|
c(() => {
|
|
31447
31465
|
if (!te || ee !== "connected") {
|
|
31448
|
-
|
|
31466
|
+
pt(0);
|
|
31449
31467
|
return;
|
|
31450
31468
|
}
|
|
31451
31469
|
let e = () => {
|
|
31452
31470
|
let e = new Date(te).getTime();
|
|
31453
|
-
isNaN(e) ||
|
|
31471
|
+
isNaN(e) || pt(Math.max(0, Math.floor((Date.now() - e) / 1e3)));
|
|
31454
31472
|
};
|
|
31455
31473
|
e();
|
|
31456
31474
|
let t = window.setInterval(e, 1e3);
|
|
31457
31475
|
return () => window.clearInterval(t);
|
|
31458
31476
|
}, [te, ee]);
|
|
31459
|
-
let
|
|
31460
|
-
|
|
31461
|
-
}, []),
|
|
31462
|
-
|
|
31477
|
+
let Mt = o(() => {
|
|
31478
|
+
it("call_screen"), Ct(!1);
|
|
31479
|
+
}, []), Nt = o(() => {
|
|
31480
|
+
it("text_chat"), Ct(!0);
|
|
31463
31481
|
}, []);
|
|
31464
31482
|
c(() => {
|
|
31465
31483
|
let e = w?.callId || T || null;
|
|
31466
31484
|
if (!e) {
|
|
31467
|
-
|
|
31485
|
+
Et.current = null;
|
|
31468
31486
|
return;
|
|
31469
31487
|
}
|
|
31470
31488
|
if (w?.callId || ee === "connecting" || ee === "connected") {
|
|
31471
|
-
if (A === "minimized_orb" &&
|
|
31472
|
-
|
|
31489
|
+
if (A === "minimized_orb" && St && T && !w?.callId) {
|
|
31490
|
+
Et.current = e;
|
|
31473
31491
|
return;
|
|
31474
31492
|
}
|
|
31475
|
-
!(!i || A === "minimized_orb" || A === "voice_mode") &&
|
|
31493
|
+
!(!i || A === "minimized_orb" || A === "voice_mode") && Et.current === e || (console.log("[FlowEngageWidget] forcing call UI to front", {
|
|
31476
31494
|
forcedKey: e,
|
|
31477
31495
|
isOpen: i,
|
|
31478
31496
|
surface: A,
|
|
31479
31497
|
hasIncomingCall: !!w?.callId,
|
|
31480
31498
|
activeCallId: T,
|
|
31481
31499
|
callConnectionState: ee
|
|
31482
|
-
}),
|
|
31500
|
+
}), Et.current = e, A === "voice_mode" && ue?.(!1), ce?.(), Mt());
|
|
31483
31501
|
}
|
|
31484
31502
|
}, [
|
|
31485
31503
|
T,
|
|
31486
31504
|
ee,
|
|
31487
|
-
|
|
31505
|
+
Mt,
|
|
31488
31506
|
w?.callId,
|
|
31489
31507
|
i,
|
|
31490
|
-
|
|
31491
|
-
|
|
31508
|
+
ce,
|
|
31509
|
+
ue,
|
|
31492
31510
|
A
|
|
31493
31511
|
]), c(() => {
|
|
31494
|
-
!w && !T && A === "call_screen" &&
|
|
31512
|
+
!w && !T && A === "call_screen" && it("text_chat");
|
|
31495
31513
|
}, [
|
|
31496
31514
|
w,
|
|
31497
31515
|
T,
|
|
31498
31516
|
A
|
|
31499
31517
|
]), c(() => {
|
|
31500
|
-
!T &&
|
|
31501
|
-
}, [T,
|
|
31518
|
+
!T && St && Ct(!1);
|
|
31519
|
+
}, [T, St]), c(() => {
|
|
31502
31520
|
if (!s || C) {
|
|
31503
|
-
|
|
31521
|
+
Se?.(""), xe?.();
|
|
31504
31522
|
return;
|
|
31505
31523
|
}
|
|
31506
|
-
if (!
|
|
31507
|
-
|
|
31508
|
-
let e = window.setTimeout(() =>
|
|
31524
|
+
if (!at.trim() || gt) {
|
|
31525
|
+
Se?.("");
|
|
31526
|
+
let e = window.setTimeout(() => xe?.(), 100);
|
|
31509
31527
|
return () => window.clearTimeout(e);
|
|
31510
31528
|
}
|
|
31511
|
-
|
|
31512
|
-
let e = window.setTimeout(() =>
|
|
31529
|
+
be?.();
|
|
31530
|
+
let e = window.setTimeout(() => Se?.(at), 120), t = window.setTimeout(() => xe?.(), 1200);
|
|
31513
31531
|
return () => {
|
|
31514
31532
|
window.clearTimeout(e), window.clearTimeout(t);
|
|
31515
31533
|
};
|
|
31516
31534
|
}, [
|
|
31517
|
-
|
|
31518
|
-
|
|
31535
|
+
at,
|
|
31536
|
+
gt,
|
|
31519
31537
|
s,
|
|
31520
31538
|
C,
|
|
31521
|
-
ye,
|
|
31522
31539
|
be,
|
|
31523
|
-
xe
|
|
31540
|
+
xe,
|
|
31541
|
+
Se
|
|
31524
31542
|
]);
|
|
31525
|
-
let
|
|
31543
|
+
let Pt = (e) => e ? {
|
|
31526
31544
|
replyTo: e.messageId || e.id || null,
|
|
31527
31545
|
replyToContent: (e.replyToContent || e.message || "").replace(/<[^>]+>/g, "").trim().slice(0, 200),
|
|
31528
31546
|
replyToSender: e.sender || null
|
|
31529
|
-
} : null,
|
|
31547
|
+
} : null, Ft = async (e) => {
|
|
31530
31548
|
if (e.preventDefault(), C) return;
|
|
31531
|
-
if (
|
|
31532
|
-
let e =
|
|
31549
|
+
if (k) {
|
|
31550
|
+
let e = lt.trim().toLowerCase();
|
|
31533
31551
|
if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e)) {
|
|
31534
|
-
|
|
31552
|
+
ft("Please enter a valid email so we can continue helping you.");
|
|
31535
31553
|
return;
|
|
31536
31554
|
}
|
|
31537
|
-
await
|
|
31555
|
+
await le(e), ft("");
|
|
31538
31556
|
return;
|
|
31539
31557
|
}
|
|
31540
|
-
let t =
|
|
31541
|
-
if (!
|
|
31542
|
-
if (
|
|
31558
|
+
let t = Pt(st);
|
|
31559
|
+
if (!at.trim() && !gt) return;
|
|
31560
|
+
if (gt) {
|
|
31543
31561
|
try {
|
|
31544
|
-
|
|
31545
|
-
let e = await
|
|
31546
|
-
|
|
31562
|
+
xt(!0), yt("");
|
|
31563
|
+
let e = await se(gt), n = e?.data || e, r = at.trim() || `Shared file: ${iO(gt)}`;
|
|
31564
|
+
ot(""), ct(null), At(), await D(r, "", t, {
|
|
31547
31565
|
type: "file",
|
|
31548
31566
|
metadata: {
|
|
31549
31567
|
fileUrl: n?.fileUrl,
|
|
31550
|
-
fileName: n?.fileName ||
|
|
31551
|
-
fileType: n?.fileType ||
|
|
31552
|
-
fileSize: n?.fileSize ||
|
|
31568
|
+
fileName: n?.fileName || gt.name,
|
|
31569
|
+
fileType: n?.fileType || gt.type,
|
|
31570
|
+
fileSize: n?.fileSize || gt.size
|
|
31553
31571
|
}
|
|
31554
31572
|
});
|
|
31555
31573
|
} catch (e) {
|
|
31556
|
-
|
|
31574
|
+
yt(e?.message || "Failed to upload the selected file.");
|
|
31557
31575
|
} finally {
|
|
31558
|
-
|
|
31576
|
+
xt(!1);
|
|
31559
31577
|
}
|
|
31560
31578
|
return;
|
|
31561
31579
|
}
|
|
31562
|
-
let n =
|
|
31563
|
-
|
|
31564
|
-
},
|
|
31580
|
+
let n = at.trim();
|
|
31581
|
+
ot(""), ct(null), await D(n, "", t);
|
|
31582
|
+
}, It = (e) => {
|
|
31565
31583
|
let t = Math.floor(e / 60);
|
|
31566
31584
|
return `${String(t).padStart(2, "0")}:${String(e % 60).padStart(2, "0")}`;
|
|
31567
|
-
},
|
|
31585
|
+
}, Lt = o(async (e) => {
|
|
31568
31586
|
if (C || b) return;
|
|
31569
31587
|
let t = e.message || e.label || e.text || "";
|
|
31570
|
-
t.trim() && await
|
|
31588
|
+
t.trim() && await D(t.trim(), "");
|
|
31571
31589
|
}, [
|
|
31572
31590
|
C,
|
|
31573
31591
|
b,
|
|
31574
|
-
|
|
31575
|
-
]),
|
|
31592
|
+
D
|
|
31593
|
+
]), Rt = Ot && A === "entry_prompt" ? { inset: 0 } : Ot && A === "text_chat" ? {
|
|
31576
31594
|
left: 0,
|
|
31577
31595
|
right: 0,
|
|
31578
31596
|
bottom: 0
|
|
31579
|
-
} :
|
|
31597
|
+
} : Ot && A === "call_screen" ? {
|
|
31580
31598
|
left: 0,
|
|
31581
31599
|
right: 0,
|
|
31582
31600
|
bottom: 0,
|
|
31583
31601
|
height: "90dvh",
|
|
31584
31602
|
overflow: "hidden",
|
|
31585
31603
|
borderRadius: "16px 16px 0 0"
|
|
31586
|
-
} :
|
|
31604
|
+
} : Ot && A === "connection_modal" ? {
|
|
31587
31605
|
left: "28px",
|
|
31588
31606
|
right: "12px",
|
|
31589
31607
|
bottom: "12px"
|
|
@@ -31592,24 +31610,24 @@ function Qk() {
|
|
|
31592
31610
|
height: "min(640px, calc(100vh - 120px))",
|
|
31593
31611
|
borderRadius: "22px",
|
|
31594
31612
|
overflow: "hidden",
|
|
31595
|
-
...
|
|
31613
|
+
...Re === "bottom-left" ? {
|
|
31596
31614
|
left: "1.5rem",
|
|
31597
31615
|
bottom: "1.5rem"
|
|
31598
31616
|
} : {
|
|
31599
31617
|
right: "1.5rem",
|
|
31600
31618
|
bottom: "1.5rem"
|
|
31601
31619
|
}
|
|
31602
|
-
} :
|
|
31620
|
+
} : Re === "bottom-left" ? {
|
|
31603
31621
|
left: "1.5rem",
|
|
31604
31622
|
bottom: "1.5rem"
|
|
31605
31623
|
} : {
|
|
31606
31624
|
right: "1.5rem",
|
|
31607
31625
|
bottom: "1.5rem"
|
|
31608
|
-
},
|
|
31609
|
-
A !== "minimized_orb" && (
|
|
31610
|
-
|
|
31626
|
+
}, zt = o(() => {
|
|
31627
|
+
A !== "minimized_orb" && (Tt(!0), setTimeout(() => {
|
|
31628
|
+
it("minimized_orb"), Tt(!1);
|
|
31611
31629
|
}, 280));
|
|
31612
|
-
}, [A]),
|
|
31630
|
+
}, [A]), Bt = () => it("connection_modal"), Vt = () => {
|
|
31613
31631
|
try {
|
|
31614
31632
|
let e = window.AudioContext || window.webkitAudioContext;
|
|
31615
31633
|
if (e) {
|
|
@@ -31617,34 +31635,34 @@ function Qk() {
|
|
|
31617
31635
|
t.resume().catch(() => {}), setTimeout(() => t.close().catch(() => {}), 3e3);
|
|
31618
31636
|
}
|
|
31619
31637
|
} catch {}
|
|
31620
|
-
|
|
31621
|
-
}, Vt = () => {
|
|
31622
|
-
se({ notifyChatInitiated: !0 }), le?.(!1), rt("text_chat");
|
|
31638
|
+
ce({ notifyChatInitiated: !0 }), ue?.(!0), it("voice_mode");
|
|
31623
31639
|
}, Ht = () => {
|
|
31624
|
-
|
|
31640
|
+
ce({ notifyChatInitiated: !0 }), ue?.(!1), it("text_chat");
|
|
31641
|
+
}, Ut = () => {
|
|
31642
|
+
ue?.(!1), zt();
|
|
31625
31643
|
};
|
|
31626
|
-
return e !== "ready" || !
|
|
31644
|
+
return e !== "ready" || !Ke || Ne.chat === !1 ? null : /* @__PURE__ */ _("div", {
|
|
31627
31645
|
className: "flowengage-widget-root",
|
|
31628
31646
|
style: {
|
|
31629
31647
|
position: "fixed",
|
|
31630
31648
|
zIndex: 999999,
|
|
31631
|
-
...
|
|
31649
|
+
...Rt
|
|
31632
31650
|
},
|
|
31633
31651
|
onWheel: (e) => e.stopPropagation(),
|
|
31634
31652
|
onTouchMove: (e) => e.stopPropagation(),
|
|
31635
31653
|
children: [
|
|
31636
31654
|
A === "entry_prompt" && /* @__PURE__ */ g(Kk, {
|
|
31637
|
-
copy:
|
|
31638
|
-
orbColors:
|
|
31639
|
-
primaryColor:
|
|
31655
|
+
copy: Je,
|
|
31656
|
+
orbColors: Ie,
|
|
31657
|
+
primaryColor: Le,
|
|
31640
31658
|
onYes: () => {
|
|
31641
|
-
pe(
|
|
31659
|
+
pe(Ze), Vt();
|
|
31642
31660
|
},
|
|
31643
31661
|
onLater: () => {
|
|
31644
|
-
pe(
|
|
31662
|
+
pe(Ze), zt();
|
|
31645
31663
|
},
|
|
31646
|
-
isMobile:
|
|
31647
|
-
isClosing:
|
|
31664
|
+
isMobile: Ot,
|
|
31665
|
+
isClosing: wt
|
|
31648
31666
|
}),
|
|
31649
31667
|
A === "minimized_orb" && /* @__PURE__ */ _(bm.div, {
|
|
31650
31668
|
layoutId: "fe-main-orb",
|
|
@@ -31665,14 +31683,14 @@ function Qk() {
|
|
|
31665
31683
|
transformOrigin: "bottom right",
|
|
31666
31684
|
display: "inline-flex",
|
|
31667
31685
|
flexDirection: "column",
|
|
31668
|
-
alignItems:
|
|
31686
|
+
alignItems: Re === "bottom-left" ? "flex-start" : "flex-end",
|
|
31669
31687
|
gap: "10px"
|
|
31670
31688
|
},
|
|
31671
|
-
children: [T &&
|
|
31689
|
+
children: [T && St && /* @__PURE__ */ _("button", {
|
|
31672
31690
|
type: "button",
|
|
31673
|
-
onClick:
|
|
31691
|
+
onClick: Mt,
|
|
31674
31692
|
style: {
|
|
31675
|
-
maxWidth:
|
|
31693
|
+
maxWidth: Ot ? "220px" : "240px",
|
|
31676
31694
|
padding: "10px 14px",
|
|
31677
31695
|
borderRadius: "18px",
|
|
31678
31696
|
border: "1px solid rgba(255,255,255,0.7)",
|
|
@@ -31713,112 +31731,113 @@ function Qk() {
|
|
|
31713
31731
|
marginTop: "2px",
|
|
31714
31732
|
whiteSpace: "nowrap"
|
|
31715
31733
|
},
|
|
31716
|
-
children: ee === "connected" ? `${
|
|
31734
|
+
children: ee === "connected" ? `${It(j)} with ${$e}` : `Tap to return to ${$e}`
|
|
31717
31735
|
})]
|
|
31718
31736
|
})]
|
|
31719
31737
|
}), /* @__PURE__ */ g(Gk, {
|
|
31720
31738
|
size: 50,
|
|
31721
|
-
orbColors:
|
|
31722
|
-
onClick: T &&
|
|
31739
|
+
orbColors: Ie,
|
|
31740
|
+
onClick: T && St ? Mt : Pe ? Bt : Ht
|
|
31723
31741
|
})]
|
|
31724
31742
|
}),
|
|
31725
31743
|
A === "connection_modal" && /* @__PURE__ */ g(qk, {
|
|
31726
|
-
copy:
|
|
31727
|
-
orbColors:
|
|
31728
|
-
primaryColor:
|
|
31729
|
-
onVoice:
|
|
31730
|
-
onText:
|
|
31731
|
-
onClose:
|
|
31732
|
-
isMobile:
|
|
31733
|
-
isClosing:
|
|
31744
|
+
copy: Je,
|
|
31745
|
+
orbColors: Ie,
|
|
31746
|
+
primaryColor: Le,
|
|
31747
|
+
onVoice: Vt,
|
|
31748
|
+
onText: Ht,
|
|
31749
|
+
onClose: zt,
|
|
31750
|
+
isMobile: Ot,
|
|
31751
|
+
isClosing: wt
|
|
31734
31752
|
}),
|
|
31735
31753
|
A === "voice_mode" && /* @__PURE__ */ g(Jk, {
|
|
31736
|
-
orbColors:
|
|
31737
|
-
onEnterChat:
|
|
31738
|
-
onEndChat:
|
|
31739
|
-
agentId:
|
|
31740
|
-
voiceId:
|
|
31741
|
-
siteId:
|
|
31742
|
-
apiBaseUrl:
|
|
31743
|
-
|
|
31744
|
-
|
|
31754
|
+
orbColors: Ie,
|
|
31755
|
+
onEnterChat: Ht,
|
|
31756
|
+
onEndChat: Ut,
|
|
31757
|
+
agentId: Ye,
|
|
31758
|
+
voiceId: Xe,
|
|
31759
|
+
siteId: Ze,
|
|
31760
|
+
apiBaseUrl: Qe,
|
|
31761
|
+
chatId: ie,
|
|
31762
|
+
historyRef: ae,
|
|
31763
|
+
onMessageSync: oe
|
|
31745
31764
|
}, "voice"),
|
|
31746
31765
|
A === "call_screen" && /* @__PURE__ */ g(TO, {
|
|
31747
31766
|
incomingCall: w,
|
|
31748
31767
|
activeCallId: T,
|
|
31749
31768
|
callConnectionState: ee,
|
|
31750
|
-
callDurationSeconds:
|
|
31769
|
+
callDurationSeconds: j,
|
|
31751
31770
|
isCallMuted: ne,
|
|
31752
|
-
agentName:
|
|
31753
|
-
agentHeadshot:
|
|
31754
|
-
fallbackAgentName:
|
|
31755
|
-
acceptCall:
|
|
31756
|
-
rejectCall:
|
|
31757
|
-
endWebRTCCall:
|
|
31758
|
-
toggleCallMute:
|
|
31759
|
-
formatCallDuration:
|
|
31760
|
-
onMinimize:
|
|
31761
|
-
primaryColor:
|
|
31762
|
-
orbColors:
|
|
31771
|
+
agentName: $e,
|
|
31772
|
+
agentHeadshot: et,
|
|
31773
|
+
fallbackAgentName: ze,
|
|
31774
|
+
acceptCall: he,
|
|
31775
|
+
rejectCall: ge,
|
|
31776
|
+
endWebRTCCall: _e,
|
|
31777
|
+
toggleCallMute: ve,
|
|
31778
|
+
formatCallDuration: It,
|
|
31779
|
+
onMinimize: Nt,
|
|
31780
|
+
primaryColor: Le,
|
|
31781
|
+
orbColors: Ie,
|
|
31763
31782
|
chatHistory: r
|
|
31764
31783
|
}),
|
|
31765
31784
|
A === "text_chat" && /* @__PURE__ */ g(Zk, {
|
|
31766
|
-
isClosing:
|
|
31767
|
-
copy:
|
|
31768
|
-
orbColors:
|
|
31769
|
-
primaryColor:
|
|
31770
|
-
chatBgGradient:
|
|
31771
|
-
logo:
|
|
31772
|
-
quickChatOptions:
|
|
31773
|
-
onQuickChatSelect:
|
|
31774
|
-
isMobile:
|
|
31785
|
+
isClosing: wt,
|
|
31786
|
+
copy: Je,
|
|
31787
|
+
orbColors: Ie,
|
|
31788
|
+
primaryColor: Le,
|
|
31789
|
+
chatBgGradient: O,
|
|
31790
|
+
logo: Be,
|
|
31791
|
+
quickChatOptions: We,
|
|
31792
|
+
onQuickChatSelect: Lt,
|
|
31793
|
+
isMobile: Ot,
|
|
31775
31794
|
chatHistory: r,
|
|
31776
31795
|
isAiTyping: y,
|
|
31777
31796
|
isAgentTyping: v,
|
|
31778
31797
|
activeScreen: a,
|
|
31779
|
-
agentName:
|
|
31780
|
-
agentHeadshot:
|
|
31781
|
-
fallbackAgentName:
|
|
31782
|
-
input:
|
|
31783
|
-
setInput:
|
|
31784
|
-
onSubmit:
|
|
31798
|
+
agentName: $e,
|
|
31799
|
+
agentHeadshot: et,
|
|
31800
|
+
fallbackAgentName: ze,
|
|
31801
|
+
input: at,
|
|
31802
|
+
setInput: ot,
|
|
31803
|
+
onSubmit: Ft,
|
|
31785
31804
|
isConversationEnded: C,
|
|
31786
31805
|
isLoading: b,
|
|
31787
31806
|
isRateLimited: x,
|
|
31788
31807
|
rateLimitMessage: S,
|
|
31789
|
-
selectedFile:
|
|
31790
|
-
onFileSelect:
|
|
31791
|
-
onRemoveSelectedFile:
|
|
31792
|
-
attachmentError:
|
|
31793
|
-
isUploadingAttachment:
|
|
31794
|
-
requiresEmail:
|
|
31795
|
-
emailInput:
|
|
31796
|
-
setEmailInput:
|
|
31797
|
-
emailError:
|
|
31798
|
-
replyContext:
|
|
31799
|
-
setReplyContext:
|
|
31808
|
+
selectedFile: gt,
|
|
31809
|
+
onFileSelect: jt,
|
|
31810
|
+
onRemoveSelectedFile: At,
|
|
31811
|
+
attachmentError: vt,
|
|
31812
|
+
isUploadingAttachment: bt,
|
|
31813
|
+
requiresEmail: k,
|
|
31814
|
+
emailInput: lt,
|
|
31815
|
+
setEmailInput: ut,
|
|
31816
|
+
emailError: dt,
|
|
31817
|
+
replyContext: st,
|
|
31818
|
+
setReplyContext: ct,
|
|
31800
31819
|
webRTCError: re,
|
|
31801
|
-
micError:
|
|
31802
|
-
setMicError:
|
|
31803
|
-
dismissCallError:
|
|
31820
|
+
micError: mt,
|
|
31821
|
+
setMicError: ht,
|
|
31822
|
+
dismissCallError: ye,
|
|
31804
31823
|
activeCallId: T,
|
|
31805
31824
|
isCallMuted: ne,
|
|
31806
|
-
toggleCallMute:
|
|
31807
|
-
endWebRTCCall:
|
|
31808
|
-
formatCallDuration:
|
|
31809
|
-
callDurationSeconds:
|
|
31810
|
-
onCollapse:
|
|
31811
|
-
onStartVoice:
|
|
31812
|
-
onNewChat:
|
|
31813
|
-
onEndConversation:
|
|
31814
|
-
onMinimize:
|
|
31815
|
-
onExpand:
|
|
31816
|
-
isCallMinimized:
|
|
31817
|
-
showPoweredBy:
|
|
31818
|
-
getVisitorChatHistory:
|
|
31819
|
-
getVisitorChatThread:
|
|
31820
|
-
resumeChat:
|
|
31821
|
-
isSessionRestoring:
|
|
31825
|
+
toggleCallMute: ve,
|
|
31826
|
+
endWebRTCCall: _e,
|
|
31827
|
+
formatCallDuration: It,
|
|
31828
|
+
callDurationSeconds: j,
|
|
31829
|
+
onCollapse: zt,
|
|
31830
|
+
onStartVoice: Vt,
|
|
31831
|
+
onNewChat: me,
|
|
31832
|
+
onEndConversation: de,
|
|
31833
|
+
onMinimize: Nt,
|
|
31834
|
+
onExpand: Mt,
|
|
31835
|
+
isCallMinimized: St && !!T,
|
|
31836
|
+
showPoweredBy: Ge,
|
|
31837
|
+
getVisitorChatHistory: Ce,
|
|
31838
|
+
getVisitorChatThread: we,
|
|
31839
|
+
resumeChat: Te,
|
|
31840
|
+
isSessionRestoring: Ee
|
|
31822
31841
|
}),
|
|
31823
31842
|
/* @__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 " })
|
|
31824
31843
|
]
|