@flowengage/react-chatbot 5.0.19 → 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.
@@ -3241,14 +3241,11 @@ 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(() => {}), Et.current = !0);
3242
3242
  }
3243
3243
  }, [Fe, _]);
3244
- let Bt = p(null);
3244
+ let Bt = p(null), Vt = A.current;
3245
3245
  c(() => {
3246
- if (Bt.current === !0 && !C) {
3247
- let e = A.current, t = k.current;
3248
- t && e && t.updateChatStatus(e, "widget_closed").catch(() => {});
3249
- }
3250
- Bt.current = C;
3251
- }, [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(() => {
3252
3249
  let e = () => {
3253
3250
  let e = A.current, t = k.current;
3254
3251
  !e || !t || typeof navigator > "u" || t.beaconWidgetClosed?.(e) || t.updateChatStatus(e, "widget_closed").catch(() => {});
@@ -3268,7 +3265,7 @@ function Nr({ siteId: e, config: t, children: n, language: r = "en" }) {
3268
3265
  l,
3269
3266
  At
3270
3267
  ]);
3271
- let Vt = async () => {
3268
+ let Ht = async () => {
3272
3269
  if (!(!O?.callId || !k.current || !ot.current || !y)) {
3273
3270
  Mt(), gt.current = O.callId, Nt();
3274
3271
  try {
@@ -3358,7 +3355,7 @@ function Nr({ siteId: e, config: t, children: n, language: r = "en" }) {
3358
3355
  rt("We couldn't connect the call right now. Please try again.");
3359
3356
  }
3360
3357
  }
3361
- }, Ht = async () => {
3358
+ }, Ut = async () => {
3362
3359
  if (!O?.callId || !k.current || !y) {
3363
3360
  Ft("reject_call_without_server_context");
3364
3361
  return;
@@ -3371,15 +3368,15 @@ function Nr({ siteId: e, config: t, children: n, language: r = "en" }) {
3371
3368
  } finally {
3372
3369
  Ft("reject_call_finally");
3373
3370
  }
3374
- }, Ut = p(Ht);
3375
- Ut.current = Ht, c(() => {
3371
+ }, Wt = p(Ut);
3372
+ Wt.current = Ut, c(() => {
3376
3373
  if (!O?.callId || Je) {
3377
3374
  Nt();
3378
3375
  return;
3379
3376
  }
3380
3377
  let e = O.callId;
3381
3378
  return Nt(), j.current = window.setTimeout(() => {
3382
- lt.current?.callId === e && gt.current !== e && ht.current !== e && Ut.current();
3379
+ lt.current?.callId === e && gt.current !== e && ht.current !== e && Wt.current();
3383
3380
  }, oe), () => {
3384
3381
  j.current &&= (window.clearTimeout(j.current), null);
3385
3382
  };
@@ -3388,7 +3385,7 @@ function Nr({ siteId: e, config: t, children: n, language: r = "en" }) {
3388
3385
  Nt,
3389
3386
  O?.callId
3390
3387
  ]);
3391
- let Wt = async () => {
3388
+ let Gt = async () => {
3392
3389
  if (!Je || !k.current || !y) {
3393
3390
  Ft("end_call_without_server_context");
3394
3391
  return;
@@ -3401,14 +3398,14 @@ function Nr({ siteId: e, config: t, children: n, language: r = "en" }) {
3401
3398
  } finally {
3402
3399
  Ft("end_call_finally");
3403
3400
  }
3404
- }, Gt = () => {
3401
+ }, Kt = () => {
3405
3402
  let e = dt.current?.getAudioTracks?.() || [], t = ut.current?.getSenders?.().map((e) => e.track).filter((e) => e?.kind === "audio") || [], n = [...e, ...t].filter(Boolean);
3406
3403
  if (n.length === 0) return;
3407
3404
  let r = !et;
3408
3405
  n.forEach((e) => {
3409
3406
  e.enabled = !r;
3410
3407
  }), tt(r);
3411
- }, Kt = async (e = {}) => {
3408
+ }, qt = async (e = {}) => {
3412
3409
  let t = e.notifyChatInitiated === !0;
3413
3410
  if (w(!0), !(!t || !k.current || !y || typeof window > "u")) {
3414
3411
  try {
@@ -3421,7 +3418,7 @@ function Nr({ siteId: e, config: t, children: n, language: r = "en" }) {
3421
3418
  await k.current.updateChatStatus(y, "open");
3422
3419
  } catch {}
3423
3420
  }
3424
- }, qt = async (e) => {
3421
+ }, Jt = async (e) => {
3425
3422
  let t = Pt(e);
3426
3423
  if (!t || !k.current || !A.current) return t;
3427
3424
  try {
@@ -3434,26 +3431,26 @@ function Nr({ siteId: e, config: t, children: n, language: r = "en" }) {
3434
3431
  console.error("[FlowEngageProvider] failed to persist visitor email", e);
3435
3432
  }
3436
3433
  return t;
3437
- }, Jt = () => {
3434
+ }, Yt = () => {
3438
3435
  !y || !ot.current?.connected || vt.current || (vt.current = !0, ot.current.emit("typing:start", {
3439
3436
  chatId: y,
3440
3437
  sender: "user"
3441
3438
  }));
3442
- }, Yt = () => {
3439
+ }, Xt = () => {
3443
3440
  !y || !ot.current?.connected || !vt.current || (vt.current = !1, ot.current.emit("typing:stop", {
3444
3441
  chatId: y,
3445
3442
  sender: "user"
3446
3443
  }));
3447
- }, Xt = (e = "") => {
3444
+ }, Zt = (e = "") => {
3448
3445
  let t = typeof e == "string" ? e : "";
3449
3446
  !y || !ot.current?.connected || t !== "" && yt.current === t || (yt.current = t, ot.current.emit("typing:update", {
3450
3447
  chatId: y,
3451
3448
  sender: "user",
3452
3449
  text: t
3453
3450
  }));
3454
- }, Zt = async (e, t = "", n = null, a = {}) => {
3451
+ }, Qt = async (e, t = "", n = null, a = {}) => {
3455
3452
  if (!(typeof e == "string" && e.trim()) || !k.current || !y || l !== "ready" || He) return;
3456
- Yt();
3453
+ Xt();
3457
3454
  let o = `pending-user-${Date.now()}`, s = {
3458
3455
  id: o,
3459
3456
  sender: "user",
@@ -3512,10 +3509,10 @@ function Nr({ siteId: e, config: t, children: n, language: r = "en" }) {
3512
3509
  je(!1), Ne("");
3513
3510
  }, ie)) : h(e);
3514
3511
  }
3515
- }, Qt = async (e) => {
3512
+ }, $t = async (e) => {
3516
3513
  if (!k.current || !e) throw Error("Upload is unavailable right now.");
3517
3514
  return k.current.uploadChatFile(e);
3518
- }, $t = async (e) => {
3515
+ }, en = async (e) => {
3519
3516
  if (!(!k.current || !y)) {
3520
3517
  try {
3521
3518
  let t = e ? "voice" : "text";
@@ -3523,7 +3520,7 @@ function Nr({ siteId: e, config: t, children: n, language: r = "en" }) {
3523
3520
  } catch {}
3524
3521
  Ie(e), e && (Et.current = !1);
3525
3522
  }
3526
- }, en = async (e) => {
3523
+ }, tn = async (e) => {
3527
3524
  if (Et.current) return;
3528
3525
  if (Et.current = !0, !k.current || !y || !e?.length) {
3529
3526
  Ie(!1);
@@ -3552,9 +3549,9 @@ function Nr({ siteId: e, config: t, children: n, language: r = "en" }) {
3552
3549
  } finally {
3553
3550
  Ie(!1);
3554
3551
  }
3555
- }, tn = async () => {
3552
+ }, nn = async () => {
3556
3553
  if (!(!k.current || !y)) {
3557
- Fe && !Et.current && Tt.current.length > 0 && await en(Tt.current);
3554
+ Fe && !Et.current && Tt.current.length > 0 && await tn(Tt.current);
3558
3555
  try {
3559
3556
  await k.current.endConversation(y);
3560
3557
  } catch {
@@ -3574,7 +3571,7 @@ function Nr({ siteId: e, config: t, children: n, language: r = "en" }) {
3574
3571
  c(() => {
3575
3572
  if (Xe !== "connected" || !Je || !y || !Qe || !jt) return;
3576
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(() => {
3577
- rt("The call ended because it reached the time limit."), Wt();
3574
+ rt("The call ended because it reached the time limit."), Gt();
3578
3575
  }, n);
3579
3576
  return () => window.clearTimeout(r);
3580
3577
  }, [
@@ -3582,7 +3579,7 @@ function Nr({ siteId: e, config: t, children: n, language: r = "en" }) {
3582
3579
  Qe,
3583
3580
  Xe,
3584
3581
  y,
3585
- Wt,
3582
+ Gt,
3586
3583
  jt
3587
3584
  ]), c(() => {
3588
3585
  let e = () => {
@@ -3603,12 +3600,12 @@ function Nr({ siteId: e, config: t, children: n, language: r = "en" }) {
3603
3600
  window.removeEventListener("pagehide", e), window.removeEventListener("beforeunload", e);
3604
3601
  };
3605
3602
  }, []);
3606
- let nn = o(() => {
3603
+ let rn = o(() => {
3607
3604
  let e = i?.siteId;
3608
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);
3609
- }, [i?.siteId]), rn = o((e) => {
3606
+ }, [i?.siteId]), an = o((e) => {
3610
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);
3611
- }, [i?.siteId]), an = f(() => ({
3608
+ }, [i?.siteId]), on = f(() => ({
3612
3609
  status: l,
3613
3610
  error: d,
3614
3611
  runtimeConfig: _,
@@ -3642,33 +3639,33 @@ function Nr({ siteId: e, config: t, children: n, language: r = "en" }) {
3642
3639
  historyRef: Tt,
3643
3640
  hasSyncedRef: Et,
3644
3641
  dismissCallError: Mt,
3645
- captureVisitorEmail: qt,
3646
- startTyping: Jt,
3647
- stopTyping: Yt,
3648
- updateTypingDraft: Xt,
3642
+ captureVisitorEmail: Jt,
3643
+ startTyping: Yt,
3644
+ stopTyping: Xt,
3645
+ updateTypingDraft: Zt,
3649
3646
  notifyRouteChange: () => kt.current?.notifyRouteChange?.(),
3650
- openWidget: Kt,
3647
+ openWidget: qt,
3651
3648
  closeWidget: () => w(!1),
3652
3649
  toggleWidget: () => {
3653
3650
  if (C) {
3654
3651
  w(!1);
3655
3652
  return;
3656
3653
  }
3657
- Kt({ notifyChatInitiated: !0 });
3654
+ qt({ notifyChatInitiated: !0 });
3658
3655
  },
3659
- sendMessage: Zt,
3660
- uploadChatFile: Qt,
3661
- setVoiceMode: $t,
3662
- onMessageSync: en,
3663
- endConversation: tn,
3664
- startNewChat: nn,
3665
- resumeChat: rn,
3656
+ sendMessage: Qt,
3657
+ uploadChatFile: $t,
3658
+ setVoiceMode: en,
3659
+ onMessageSync: tn,
3660
+ endConversation: nn,
3661
+ startNewChat: rn,
3662
+ resumeChat: an,
3666
3663
  getVisitorChatHistory: () => k.current?.getVisitorChatHistory?.(),
3667
3664
  getVisitorChatThread: (e) => k.current?.getVisitorChatThread?.(e),
3668
- acceptCall: Vt,
3669
- rejectCall: Ht,
3670
- endWebRTCCall: Wt,
3671
- toggleCallMute: Gt
3665
+ acceptCall: Ht,
3666
+ rejectCall: Ut,
3667
+ endWebRTCCall: Gt,
3668
+ toggleCallMute: Kt
3672
3669
  }), [
3673
3670
  l,
3674
3671
  d,
@@ -3700,25 +3697,25 @@ function Nr({ siteId: e, config: t, children: n, language: r = "en" }) {
3700
3697
  et,
3701
3698
  nt,
3702
3699
  r,
3703
- qt,
3704
3700
  Jt,
3705
3701
  Yt,
3706
3702
  Xt,
3707
- Vt,
3703
+ Zt,
3708
3704
  Ht,
3709
- Wt,
3705
+ Ut,
3710
3706
  Gt,
3711
3707
  Kt,
3712
- Zt,
3708
+ qt,
3713
3709
  Qt,
3714
3710
  $t,
3715
3711
  en,
3716
3712
  tn,
3717
3713
  nn,
3714
+ rn,
3718
3715
  Mt
3719
3716
  ]);
3720
3717
  return /* @__PURE__ */ g(In.Provider, {
3721
- value: an,
3718
+ value: on,
3722
3719
  children: n
3723
3720
  });
3724
3721
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flowengage/react-chatbot",
3
- "version": "5.0.19",
3
+ "version": "5.0.20",
4
4
  "description": "Embeddable AI chat widget for React — powered by FlowEngage. Drop it in with a single siteId.",
5
5
  "keywords": [
6
6
  "chatbot",