@flowengage/react-chatbot 5.0.18 → 5.0.20
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.
|
@@ -459,23 +459,13 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
|
|
|
459
459
|
},
|
|
460
460
|
beaconSyncVoice(r, i) {
|
|
461
461
|
if (typeof navigator > "u" || !navigator.sendBeacon) return !1;
|
|
462
|
-
let a =
|
|
463
|
-
|
|
464
|
-
messages: i,
|
|
465
|
-
...t ? { userId: String(t) } : {},
|
|
466
|
-
...n ? { siteId: String(n) } : {}
|
|
467
|
-
}, o = new Blob([JSON.stringify(a)], { type: "application/json" });
|
|
468
|
-
return navigator.sendBeacon(`${e}/api/ai/voice/sync`, o);
|
|
462
|
+
let a = new URLSearchParams();
|
|
463
|
+
return a.append("session_id", r), a.append("messages", JSON.stringify(i)), t && a.append("userId", String(t)), n && a.append("siteId", String(n)), navigator.sendBeacon(`${e}/api/ai/voice/sync`, a);
|
|
469
464
|
},
|
|
470
465
|
beaconWidgetClosed(r) {
|
|
471
466
|
if (typeof navigator > "u" || !navigator.sendBeacon) return !1;
|
|
472
|
-
let i =
|
|
473
|
-
|
|
474
|
-
type: "widget_closed",
|
|
475
|
-
...t ? { userId: String(t) } : {},
|
|
476
|
-
...n ? { siteId: String(n) } : {}
|
|
477
|
-
}, a = new Blob([JSON.stringify(i)], { type: "application/json" });
|
|
478
|
-
return navigator.sendBeacon(`${e}/api/chat/status`, a);
|
|
467
|
+
let i = new URLSearchParams();
|
|
468
|
+
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);
|
|
479
469
|
}
|
|
480
470
|
};
|
|
481
471
|
}, qe = Object.create(null);
|
|
@@ -3251,14 +3241,11 @@ function Nr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3251
3241
|
n && e && t.length > 0 && (console.log("[FlowEngageProvider] safety-net: syncing voice transcript on unmount"), n.beaconSyncVoice(e, t) || n.syncVoice(e, t).catch(() => {}), Et.current = !0);
|
|
3252
3242
|
}
|
|
3253
3243
|
}, [Fe, _]);
|
|
3254
|
-
let Bt = p(null);
|
|
3244
|
+
let Bt = p(null), Vt = A.current;
|
|
3255
3245
|
c(() => {
|
|
3256
|
-
|
|
3257
|
-
|
|
3258
|
-
|
|
3259
|
-
}
|
|
3260
|
-
Bt.current = C;
|
|
3261
|
-
}, [C]), c(() => {
|
|
3246
|
+
let e = A.current, t = k.current;
|
|
3247
|
+
t && e && Bt.current !== C && (C ? t.updateChatStatus(e, "open").catch(() => {}) : Bt.current === !0 && t.updateChatStatus(e, "widget_closed").catch(() => {}), Bt.current = C);
|
|
3248
|
+
}, [C, Vt]), c(() => {
|
|
3262
3249
|
let e = () => {
|
|
3263
3250
|
let e = A.current, t = k.current;
|
|
3264
3251
|
!e || !t || typeof navigator > "u" || t.beaconWidgetClosed?.(e) || t.updateChatStatus(e, "widget_closed").catch(() => {});
|
|
@@ -3278,7 +3265,7 @@ function Nr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3278
3265
|
l,
|
|
3279
3266
|
At
|
|
3280
3267
|
]);
|
|
3281
|
-
let
|
|
3268
|
+
let Ht = async () => {
|
|
3282
3269
|
if (!(!O?.callId || !k.current || !ot.current || !y)) {
|
|
3283
3270
|
Mt(), gt.current = O.callId, Nt();
|
|
3284
3271
|
try {
|
|
@@ -3368,7 +3355,7 @@ function Nr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3368
3355
|
rt("We couldn't connect the call right now. Please try again.");
|
|
3369
3356
|
}
|
|
3370
3357
|
}
|
|
3371
|
-
},
|
|
3358
|
+
}, Ut = async () => {
|
|
3372
3359
|
if (!O?.callId || !k.current || !y) {
|
|
3373
3360
|
Ft("reject_call_without_server_context");
|
|
3374
3361
|
return;
|
|
@@ -3381,15 +3368,15 @@ function Nr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3381
3368
|
} finally {
|
|
3382
3369
|
Ft("reject_call_finally");
|
|
3383
3370
|
}
|
|
3384
|
-
},
|
|
3385
|
-
|
|
3371
|
+
}, Wt = p(Ut);
|
|
3372
|
+
Wt.current = Ut, c(() => {
|
|
3386
3373
|
if (!O?.callId || Je) {
|
|
3387
3374
|
Nt();
|
|
3388
3375
|
return;
|
|
3389
3376
|
}
|
|
3390
3377
|
let e = O.callId;
|
|
3391
3378
|
return Nt(), j.current = window.setTimeout(() => {
|
|
3392
|
-
lt.current?.callId === e && gt.current !== e && ht.current !== e &&
|
|
3379
|
+
lt.current?.callId === e && gt.current !== e && ht.current !== e && Wt.current();
|
|
3393
3380
|
}, oe), () => {
|
|
3394
3381
|
j.current &&= (window.clearTimeout(j.current), null);
|
|
3395
3382
|
};
|
|
@@ -3398,7 +3385,7 @@ function Nr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3398
3385
|
Nt,
|
|
3399
3386
|
O?.callId
|
|
3400
3387
|
]);
|
|
3401
|
-
let
|
|
3388
|
+
let Gt = async () => {
|
|
3402
3389
|
if (!Je || !k.current || !y) {
|
|
3403
3390
|
Ft("end_call_without_server_context");
|
|
3404
3391
|
return;
|
|
@@ -3411,14 +3398,14 @@ function Nr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3411
3398
|
} finally {
|
|
3412
3399
|
Ft("end_call_finally");
|
|
3413
3400
|
}
|
|
3414
|
-
},
|
|
3401
|
+
}, Kt = () => {
|
|
3415
3402
|
let e = dt.current?.getAudioTracks?.() || [], t = ut.current?.getSenders?.().map((e) => e.track).filter((e) => e?.kind === "audio") || [], n = [...e, ...t].filter(Boolean);
|
|
3416
3403
|
if (n.length === 0) return;
|
|
3417
3404
|
let r = !et;
|
|
3418
3405
|
n.forEach((e) => {
|
|
3419
3406
|
e.enabled = !r;
|
|
3420
3407
|
}), tt(r);
|
|
3421
|
-
},
|
|
3408
|
+
}, qt = async (e = {}) => {
|
|
3422
3409
|
let t = e.notifyChatInitiated === !0;
|
|
3423
3410
|
if (w(!0), !(!t || !k.current || !y || typeof window > "u")) {
|
|
3424
3411
|
try {
|
|
@@ -3431,7 +3418,7 @@ function Nr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3431
3418
|
await k.current.updateChatStatus(y, "open");
|
|
3432
3419
|
} catch {}
|
|
3433
3420
|
}
|
|
3434
|
-
},
|
|
3421
|
+
}, Jt = async (e) => {
|
|
3435
3422
|
let t = Pt(e);
|
|
3436
3423
|
if (!t || !k.current || !A.current) return t;
|
|
3437
3424
|
try {
|
|
@@ -3444,26 +3431,26 @@ function Nr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3444
3431
|
console.error("[FlowEngageProvider] failed to persist visitor email", e);
|
|
3445
3432
|
}
|
|
3446
3433
|
return t;
|
|
3447
|
-
},
|
|
3434
|
+
}, Yt = () => {
|
|
3448
3435
|
!y || !ot.current?.connected || vt.current || (vt.current = !0, ot.current.emit("typing:start", {
|
|
3449
3436
|
chatId: y,
|
|
3450
3437
|
sender: "user"
|
|
3451
3438
|
}));
|
|
3452
|
-
},
|
|
3439
|
+
}, Xt = () => {
|
|
3453
3440
|
!y || !ot.current?.connected || !vt.current || (vt.current = !1, ot.current.emit("typing:stop", {
|
|
3454
3441
|
chatId: y,
|
|
3455
3442
|
sender: "user"
|
|
3456
3443
|
}));
|
|
3457
|
-
},
|
|
3444
|
+
}, Zt = (e = "") => {
|
|
3458
3445
|
let t = typeof e == "string" ? e : "";
|
|
3459
3446
|
!y || !ot.current?.connected || t !== "" && yt.current === t || (yt.current = t, ot.current.emit("typing:update", {
|
|
3460
3447
|
chatId: y,
|
|
3461
3448
|
sender: "user",
|
|
3462
3449
|
text: t
|
|
3463
3450
|
}));
|
|
3464
|
-
},
|
|
3451
|
+
}, Qt = async (e, t = "", n = null, a = {}) => {
|
|
3465
3452
|
if (!(typeof e == "string" && e.trim()) || !k.current || !y || l !== "ready" || He) return;
|
|
3466
|
-
|
|
3453
|
+
Xt();
|
|
3467
3454
|
let o = `pending-user-${Date.now()}`, s = {
|
|
3468
3455
|
id: o,
|
|
3469
3456
|
sender: "user",
|
|
@@ -3522,10 +3509,10 @@ function Nr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3522
3509
|
je(!1), Ne("");
|
|
3523
3510
|
}, ie)) : h(e);
|
|
3524
3511
|
}
|
|
3525
|
-
},
|
|
3512
|
+
}, $t = async (e) => {
|
|
3526
3513
|
if (!k.current || !e) throw Error("Upload is unavailable right now.");
|
|
3527
3514
|
return k.current.uploadChatFile(e);
|
|
3528
|
-
},
|
|
3515
|
+
}, en = async (e) => {
|
|
3529
3516
|
if (!(!k.current || !y)) {
|
|
3530
3517
|
try {
|
|
3531
3518
|
let t = e ? "voice" : "text";
|
|
@@ -3533,7 +3520,7 @@ function Nr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3533
3520
|
} catch {}
|
|
3534
3521
|
Ie(e), e && (Et.current = !1);
|
|
3535
3522
|
}
|
|
3536
|
-
},
|
|
3523
|
+
}, tn = async (e) => {
|
|
3537
3524
|
if (Et.current) return;
|
|
3538
3525
|
if (Et.current = !0, !k.current || !y || !e?.length) {
|
|
3539
3526
|
Ie(!1);
|
|
@@ -3562,9 +3549,9 @@ function Nr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3562
3549
|
} finally {
|
|
3563
3550
|
Ie(!1);
|
|
3564
3551
|
}
|
|
3565
|
-
},
|
|
3552
|
+
}, nn = async () => {
|
|
3566
3553
|
if (!(!k.current || !y)) {
|
|
3567
|
-
Fe && !Et.current && Tt.current.length > 0 && await
|
|
3554
|
+
Fe && !Et.current && Tt.current.length > 0 && await tn(Tt.current);
|
|
3568
3555
|
try {
|
|
3569
3556
|
await k.current.endConversation(y);
|
|
3570
3557
|
} catch {
|
|
@@ -3584,7 +3571,7 @@ function Nr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3584
3571
|
c(() => {
|
|
3585
3572
|
if (Xe !== "connected" || !Je || !y || !Qe || !jt) return;
|
|
3586
3573
|
let e = new Date(Qe).getTime(), t = Number.isFinite(e) ? Date.now() - e : 0, n = Math.max(0, jt * 1e3 - t), r = window.setTimeout(() => {
|
|
3587
|
-
rt("The call ended because it reached the time limit."),
|
|
3574
|
+
rt("The call ended because it reached the time limit."), Gt();
|
|
3588
3575
|
}, n);
|
|
3589
3576
|
return () => window.clearTimeout(r);
|
|
3590
3577
|
}, [
|
|
@@ -3592,7 +3579,7 @@ function Nr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3592
3579
|
Qe,
|
|
3593
3580
|
Xe,
|
|
3594
3581
|
y,
|
|
3595
|
-
|
|
3582
|
+
Gt,
|
|
3596
3583
|
jt
|
|
3597
3584
|
]), c(() => {
|
|
3598
3585
|
let e = () => {
|
|
@@ -3613,12 +3600,12 @@ function Nr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3613
3600
|
window.removeEventListener("pagehide", e), window.removeEventListener("beforeunload", e);
|
|
3614
3601
|
};
|
|
3615
3602
|
}, []);
|
|
3616
|
-
let
|
|
3603
|
+
let rn = o(() => {
|
|
3617
3604
|
let e = i?.siteId;
|
|
3618
3605
|
ge(e), st.current = !0, ct.current = null, ot.current?.disconnect(), S([]), b(""), A.current = "", Ue(!1), re(!1), D(null), de(null), at(!0), s((e) => e + 1);
|
|
3619
|
-
}, [i?.siteId]),
|
|
3606
|
+
}, [i?.siteId]), an = o((e) => {
|
|
3620
3607
|
i?.siteId, st.current = !1, ct.current = e, ot.current?.disconnect(), S([]), b(""), A.current = "", Ue(!1), re(!1), D(null), de(null), at(!0), s((e) => e + 1);
|
|
3621
|
-
}, [i?.siteId]),
|
|
3608
|
+
}, [i?.siteId]), on = f(() => ({
|
|
3622
3609
|
status: l,
|
|
3623
3610
|
error: d,
|
|
3624
3611
|
runtimeConfig: _,
|
|
@@ -3652,33 +3639,33 @@ function Nr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3652
3639
|
historyRef: Tt,
|
|
3653
3640
|
hasSyncedRef: Et,
|
|
3654
3641
|
dismissCallError: Mt,
|
|
3655
|
-
captureVisitorEmail:
|
|
3656
|
-
startTyping:
|
|
3657
|
-
stopTyping:
|
|
3658
|
-
updateTypingDraft:
|
|
3642
|
+
captureVisitorEmail: Jt,
|
|
3643
|
+
startTyping: Yt,
|
|
3644
|
+
stopTyping: Xt,
|
|
3645
|
+
updateTypingDraft: Zt,
|
|
3659
3646
|
notifyRouteChange: () => kt.current?.notifyRouteChange?.(),
|
|
3660
|
-
openWidget:
|
|
3647
|
+
openWidget: qt,
|
|
3661
3648
|
closeWidget: () => w(!1),
|
|
3662
3649
|
toggleWidget: () => {
|
|
3663
3650
|
if (C) {
|
|
3664
3651
|
w(!1);
|
|
3665
3652
|
return;
|
|
3666
3653
|
}
|
|
3667
|
-
|
|
3654
|
+
qt({ notifyChatInitiated: !0 });
|
|
3668
3655
|
},
|
|
3669
|
-
sendMessage:
|
|
3670
|
-
uploadChatFile:
|
|
3671
|
-
setVoiceMode:
|
|
3672
|
-
onMessageSync:
|
|
3673
|
-
endConversation:
|
|
3674
|
-
startNewChat:
|
|
3675
|
-
resumeChat:
|
|
3656
|
+
sendMessage: Qt,
|
|
3657
|
+
uploadChatFile: $t,
|
|
3658
|
+
setVoiceMode: en,
|
|
3659
|
+
onMessageSync: tn,
|
|
3660
|
+
endConversation: nn,
|
|
3661
|
+
startNewChat: rn,
|
|
3662
|
+
resumeChat: an,
|
|
3676
3663
|
getVisitorChatHistory: () => k.current?.getVisitorChatHistory?.(),
|
|
3677
3664
|
getVisitorChatThread: (e) => k.current?.getVisitorChatThread?.(e),
|
|
3678
|
-
acceptCall:
|
|
3679
|
-
rejectCall:
|
|
3680
|
-
endWebRTCCall:
|
|
3681
|
-
toggleCallMute:
|
|
3665
|
+
acceptCall: Ht,
|
|
3666
|
+
rejectCall: Ut,
|
|
3667
|
+
endWebRTCCall: Gt,
|
|
3668
|
+
toggleCallMute: Kt
|
|
3682
3669
|
}), [
|
|
3683
3670
|
l,
|
|
3684
3671
|
d,
|
|
@@ -3710,25 +3697,25 @@ function Nr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3710
3697
|
et,
|
|
3711
3698
|
nt,
|
|
3712
3699
|
r,
|
|
3713
|
-
qt,
|
|
3714
3700
|
Jt,
|
|
3715
3701
|
Yt,
|
|
3716
3702
|
Xt,
|
|
3717
|
-
|
|
3703
|
+
Zt,
|
|
3718
3704
|
Ht,
|
|
3719
|
-
|
|
3705
|
+
Ut,
|
|
3720
3706
|
Gt,
|
|
3721
3707
|
Kt,
|
|
3722
|
-
|
|
3708
|
+
qt,
|
|
3723
3709
|
Qt,
|
|
3724
3710
|
$t,
|
|
3725
3711
|
en,
|
|
3726
3712
|
tn,
|
|
3727
3713
|
nn,
|
|
3714
|
+
rn,
|
|
3728
3715
|
Mt
|
|
3729
3716
|
]);
|
|
3730
3717
|
return /* @__PURE__ */ g(In.Provider, {
|
|
3731
|
-
value:
|
|
3718
|
+
value: on,
|
|
3732
3719
|
children: n
|
|
3733
3720
|
});
|
|
3734
3721
|
}
|