@flowengage/react-chatbot 5.0.28 → 5.0.30
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.
|
@@ -3241,17 +3241,10 @@ function Nr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3241
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(() => {}), Tt.current = !0);
|
|
3242
3242
|
}
|
|
3243
3243
|
}, [Pe, _]);
|
|
3244
|
-
let zt = p(null);
|
|
3244
|
+
let zt = p(null), Bt = p(!1);
|
|
3245
3245
|
c(() => {
|
|
3246
3246
|
let e = k.current;
|
|
3247
|
-
!e || !y || zt.current !== C && (C ? e.updateChatStatus(y, "open").catch(() => {}) : zt.current === !0 && e.updateChatStatus(y, "widget_closed").catch(() => {}), zt.current = C);
|
|
3248
|
-
}, [C, y]), c(() => {
|
|
3249
|
-
if (!C || !y) return;
|
|
3250
|
-
let e = setInterval(() => {
|
|
3251
|
-
let e = k.current;
|
|
3252
|
-
e && y && e.updateChatStatus(y, "open").catch(() => {});
|
|
3253
|
-
}, 1e4);
|
|
3254
|
-
return () => clearInterval(e);
|
|
3247
|
+
!e || !y || zt.current !== C && (C && zt.current !== null ? (e.updateChatStatus(y, "open").catch(() => {}), Bt.current = !0) : zt.current === !0 && e.updateChatStatus(y, "widget_closed").catch(() => {}), zt.current = C);
|
|
3255
3248
|
}, [C, y]), c(() => {
|
|
3256
3249
|
let e = () => {
|
|
3257
3250
|
let e = ot.current, t = k.current;
|
|
@@ -3272,7 +3265,7 @@ function Nr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3272
3265
|
l,
|
|
3273
3266
|
kt
|
|
3274
3267
|
]);
|
|
3275
|
-
let
|
|
3268
|
+
let Vt = async () => {
|
|
3276
3269
|
if (!(!He?.callId || !k.current || !at.current || !y)) {
|
|
3277
3270
|
jt(), ht.current = He.callId, Mt();
|
|
3278
3271
|
try {
|
|
@@ -3362,7 +3355,7 @@ function Nr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3362
3355
|
nt("We couldn't connect the call right now. Please try again.");
|
|
3363
3356
|
}
|
|
3364
3357
|
}
|
|
3365
|
-
},
|
|
3358
|
+
}, Ht = async () => {
|
|
3366
3359
|
if (!He?.callId || !k.current || !y) {
|
|
3367
3360
|
Pt("reject_call_without_server_context");
|
|
3368
3361
|
return;
|
|
@@ -3375,15 +3368,15 @@ function Nr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3375
3368
|
} finally {
|
|
3376
3369
|
Pt("reject_call_finally");
|
|
3377
3370
|
}
|
|
3378
|
-
},
|
|
3379
|
-
|
|
3371
|
+
}, Ut = p(Ht);
|
|
3372
|
+
Ut.current = Ht, c(() => {
|
|
3380
3373
|
if (!He?.callId || qe) {
|
|
3381
3374
|
Mt();
|
|
3382
3375
|
return;
|
|
3383
3376
|
}
|
|
3384
3377
|
let e = He.callId;
|
|
3385
3378
|
return Mt(), gt.current = window.setTimeout(() => {
|
|
3386
|
-
ct.current?.callId === e && ht.current !== e && mt.current !== e &&
|
|
3379
|
+
ct.current?.callId === e && ht.current !== e && mt.current !== e && Ut.current();
|
|
3387
3380
|
}, oe), () => {
|
|
3388
3381
|
gt.current &&= (window.clearTimeout(gt.current), null);
|
|
3389
3382
|
};
|
|
@@ -3392,7 +3385,7 @@ function Nr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3392
3385
|
Mt,
|
|
3393
3386
|
He?.callId
|
|
3394
3387
|
]);
|
|
3395
|
-
let
|
|
3388
|
+
let Wt = async () => {
|
|
3396
3389
|
if (!qe || !k.current || !y) {
|
|
3397
3390
|
Pt("end_call_without_server_context");
|
|
3398
3391
|
return;
|
|
@@ -3405,16 +3398,16 @@ function Nr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3405
3398
|
} finally {
|
|
3406
3399
|
Pt("end_call_finally");
|
|
3407
3400
|
}
|
|
3408
|
-
},
|
|
3401
|
+
}, Gt = () => {
|
|
3409
3402
|
let e = ut.current?.getAudioTracks?.() || [], t = lt.current?.getSenders?.().map((e) => e.track).filter((e) => e?.kind === "audio") || [], n = [...e, ...t].filter(Boolean);
|
|
3410
3403
|
if (n.length === 0) return;
|
|
3411
3404
|
let r = !$e;
|
|
3412
3405
|
n.forEach((e) => {
|
|
3413
3406
|
e.enabled = !r;
|
|
3414
3407
|
}), et(r);
|
|
3415
|
-
},
|
|
3408
|
+
}, Kt = async (e = {}) => {
|
|
3416
3409
|
let t = e.notifyChatInitiated === !0;
|
|
3417
|
-
if (w(!0), !(!t || !k.current || !y || typeof window > "u")) {
|
|
3410
|
+
if (Bt.current = !0, w(!0), !(!t || !k.current || !y || typeof window > "u")) {
|
|
3418
3411
|
try {
|
|
3419
3412
|
await k.current.trackVisitor({
|
|
3420
3413
|
chatId: y,
|
|
@@ -3425,7 +3418,7 @@ function Nr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3425
3418
|
await k.current.updateChatStatus(y, "open");
|
|
3426
3419
|
} catch {}
|
|
3427
3420
|
}
|
|
3428
|
-
},
|
|
3421
|
+
}, qt = async (e) => {
|
|
3429
3422
|
let t = Nt(e);
|
|
3430
3423
|
if (!t || !k.current || !ot.current) return t;
|
|
3431
3424
|
try {
|
|
@@ -3438,26 +3431,26 @@ function Nr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3438
3431
|
console.error("[FlowEngageProvider] failed to persist visitor email", e);
|
|
3439
3432
|
}
|
|
3440
3433
|
return t;
|
|
3441
|
-
},
|
|
3434
|
+
}, Jt = () => {
|
|
3442
3435
|
!y || !at.current?.connected || _t.current || (_t.current = !0, at.current.emit("typing:start", {
|
|
3443
3436
|
chatId: y,
|
|
3444
3437
|
sender: "user"
|
|
3445
3438
|
}));
|
|
3446
|
-
},
|
|
3439
|
+
}, Yt = () => {
|
|
3447
3440
|
!y || !at.current?.connected || !_t.current || (_t.current = !1, at.current.emit("typing:stop", {
|
|
3448
3441
|
chatId: y,
|
|
3449
3442
|
sender: "user"
|
|
3450
3443
|
}));
|
|
3451
|
-
},
|
|
3444
|
+
}, Xt = (e = "") => {
|
|
3452
3445
|
let t = typeof e == "string" ? e : "";
|
|
3453
3446
|
!y || !at.current?.connected || t !== "" && vt.current === t || (vt.current = t, at.current.emit("typing:update", {
|
|
3454
3447
|
chatId: y,
|
|
3455
3448
|
sender: "user",
|
|
3456
3449
|
text: t
|
|
3457
3450
|
}));
|
|
3458
|
-
},
|
|
3451
|
+
}, Zt = async (e, t = "", n = null, a = {}) => {
|
|
3459
3452
|
if (!(typeof e == "string" && e.trim()) || !k.current || !y || l !== "ready" || Be) return;
|
|
3460
|
-
|
|
3453
|
+
Yt();
|
|
3461
3454
|
let o = `pending-user-${Date.now()}`, s = {
|
|
3462
3455
|
id: o,
|
|
3463
3456
|
sender: "user",
|
|
@@ -3516,10 +3509,10 @@ function Nr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3516
3509
|
je(!1), O("");
|
|
3517
3510
|
}, ie)) : h(e);
|
|
3518
3511
|
}
|
|
3519
|
-
},
|
|
3512
|
+
}, Qt = async (e) => {
|
|
3520
3513
|
if (!k.current || !e) throw Error("Upload is unavailable right now.");
|
|
3521
3514
|
return k.current.uploadChatFile(e);
|
|
3522
|
-
},
|
|
3515
|
+
}, $t = async (e) => {
|
|
3523
3516
|
if (!(!k.current || !y)) {
|
|
3524
3517
|
try {
|
|
3525
3518
|
let t = e ? "voice" : "text";
|
|
@@ -3527,7 +3520,7 @@ function Nr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3527
3520
|
} catch {}
|
|
3528
3521
|
Fe(e), e && (Tt.current = !1);
|
|
3529
3522
|
}
|
|
3530
|
-
},
|
|
3523
|
+
}, en = async (e) => {
|
|
3531
3524
|
if (Tt.current) return;
|
|
3532
3525
|
if (Tt.current = !0, !k.current || !y || !e?.length) {
|
|
3533
3526
|
Fe(!1);
|
|
@@ -3556,9 +3549,9 @@ function Nr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3556
3549
|
} finally {
|
|
3557
3550
|
Fe(!1);
|
|
3558
3551
|
}
|
|
3559
|
-
},
|
|
3552
|
+
}, tn = async () => {
|
|
3560
3553
|
if (!(!k.current || !y)) {
|
|
3561
|
-
Pe && !Tt.current && wt.current.length > 0 && await
|
|
3554
|
+
Pe && !Tt.current && wt.current.length > 0 && await en(wt.current);
|
|
3562
3555
|
try {
|
|
3563
3556
|
await k.current.endConversation(y);
|
|
3564
3557
|
} catch {
|
|
@@ -3578,7 +3571,7 @@ function Nr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3578
3571
|
c(() => {
|
|
3579
3572
|
if (Ye !== "connected" || !qe || !y || !Ze || !At) return;
|
|
3580
3573
|
let e = new Date(Ze).getTime(), t = Number.isFinite(e) ? Date.now() - e : 0, n = Math.max(0, At * 1e3 - t), r = window.setTimeout(() => {
|
|
3581
|
-
nt("The call ended because it reached the time limit."),
|
|
3574
|
+
nt("The call ended because it reached the time limit."), Wt();
|
|
3582
3575
|
}, n);
|
|
3583
3576
|
return () => window.clearTimeout(r);
|
|
3584
3577
|
}, [
|
|
@@ -3586,7 +3579,7 @@ function Nr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3586
3579
|
Ze,
|
|
3587
3580
|
Ye,
|
|
3588
3581
|
y,
|
|
3589
|
-
|
|
3582
|
+
Wt,
|
|
3590
3583
|
At
|
|
3591
3584
|
]), c(() => {
|
|
3592
3585
|
let e = () => {
|
|
@@ -3603,12 +3596,12 @@ function Nr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3603
3596
|
window.removeEventListener("pagehide", e), window.removeEventListener("beforeunload", e);
|
|
3604
3597
|
};
|
|
3605
3598
|
}, []);
|
|
3606
|
-
let
|
|
3599
|
+
let nn = o(() => {
|
|
3607
3600
|
let e = i?.siteId;
|
|
3608
3601
|
ge(e), A.current = !0, st.current = null, at.current?.disconnect(), S([]), b(""), ot.current = "", Ve(!1), re(!1), D(null), de(null), it(!0), s((e) => e + 1);
|
|
3609
|
-
}, [i?.siteId]),
|
|
3602
|
+
}, [i?.siteId]), rn = o((e) => {
|
|
3610
3603
|
i?.siteId, A.current = !1, st.current = e, at.current?.disconnect(), S([]), b(""), ot.current = "", Ve(!1), re(!1), D(null), de(null), it(!0), s((e) => e + 1);
|
|
3611
|
-
}, [i?.siteId]),
|
|
3604
|
+
}, [i?.siteId]), an = f(() => ({
|
|
3612
3605
|
status: l,
|
|
3613
3606
|
error: d,
|
|
3614
3607
|
runtimeConfig: _,
|
|
@@ -3642,33 +3635,33 @@ function Nr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3642
3635
|
historyRef: wt,
|
|
3643
3636
|
hasSyncedRef: Tt,
|
|
3644
3637
|
dismissCallError: jt,
|
|
3645
|
-
captureVisitorEmail:
|
|
3646
|
-
startTyping:
|
|
3647
|
-
stopTyping:
|
|
3648
|
-
updateTypingDraft:
|
|
3638
|
+
captureVisitorEmail: qt,
|
|
3639
|
+
startTyping: Jt,
|
|
3640
|
+
stopTyping: Yt,
|
|
3641
|
+
updateTypingDraft: Xt,
|
|
3649
3642
|
notifyRouteChange: () => Ot.current?.notifyRouteChange?.(),
|
|
3650
|
-
openWidget:
|
|
3643
|
+
openWidget: Kt,
|
|
3651
3644
|
closeWidget: () => w(!1),
|
|
3652
3645
|
toggleWidget: () => {
|
|
3653
3646
|
if (C) {
|
|
3654
3647
|
w(!1);
|
|
3655
3648
|
return;
|
|
3656
3649
|
}
|
|
3657
|
-
|
|
3650
|
+
Kt({ notifyChatInitiated: !0 });
|
|
3658
3651
|
},
|
|
3659
|
-
sendMessage:
|
|
3660
|
-
uploadChatFile:
|
|
3661
|
-
setVoiceMode:
|
|
3662
|
-
onMessageSync:
|
|
3663
|
-
endConversation:
|
|
3664
|
-
startNewChat:
|
|
3665
|
-
resumeChat:
|
|
3652
|
+
sendMessage: Zt,
|
|
3653
|
+
uploadChatFile: Qt,
|
|
3654
|
+
setVoiceMode: $t,
|
|
3655
|
+
onMessageSync: en,
|
|
3656
|
+
endConversation: tn,
|
|
3657
|
+
startNewChat: nn,
|
|
3658
|
+
resumeChat: rn,
|
|
3666
3659
|
getVisitorChatHistory: () => k.current?.getVisitorChatHistory?.(),
|
|
3667
3660
|
getVisitorChatThread: (e) => k.current?.getVisitorChatThread?.(e),
|
|
3668
|
-
acceptCall:
|
|
3669
|
-
rejectCall:
|
|
3670
|
-
endWebRTCCall:
|
|
3671
|
-
toggleCallMute:
|
|
3661
|
+
acceptCall: Vt,
|
|
3662
|
+
rejectCall: Ht,
|
|
3663
|
+
endWebRTCCall: Wt,
|
|
3664
|
+
toggleCallMute: Gt
|
|
3672
3665
|
}), [
|
|
3673
3666
|
l,
|
|
3674
3667
|
d,
|
|
@@ -3700,25 +3693,25 @@ function Nr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3700
3693
|
$e,
|
|
3701
3694
|
tt,
|
|
3702
3695
|
r,
|
|
3703
|
-
Kt,
|
|
3704
3696
|
qt,
|
|
3705
3697
|
Jt,
|
|
3706
3698
|
Yt,
|
|
3707
|
-
|
|
3699
|
+
Xt,
|
|
3708
3700
|
Vt,
|
|
3709
|
-
|
|
3701
|
+
Ht,
|
|
3710
3702
|
Wt,
|
|
3711
3703
|
Gt,
|
|
3712
|
-
|
|
3704
|
+
Kt,
|
|
3713
3705
|
Zt,
|
|
3714
3706
|
Qt,
|
|
3715
3707
|
$t,
|
|
3716
3708
|
en,
|
|
3717
3709
|
tn,
|
|
3710
|
+
nn,
|
|
3718
3711
|
jt
|
|
3719
3712
|
]);
|
|
3720
3713
|
return /* @__PURE__ */ g(In.Provider, {
|
|
3721
|
-
value:
|
|
3714
|
+
value: an,
|
|
3722
3715
|
children: n
|
|
3723
3716
|
});
|
|
3724
3717
|
}
|