@flowengage/react-chatbot 8.0.11 → 8.0.12

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.
@@ -3505,7 +3505,19 @@ function Wr({ siteId: e, config: t, children: n, language: r = "en" }) {
3505
3505
  sender: "user",
3506
3506
  text: t
3507
3507
  }));
3508
- }, Zt = async (e, t = "", n = null, a = {}) => {
3508
+ };
3509
+ function Zt() {
3510
+ if (typeof document > "u") return null;
3511
+ try {
3512
+ let e = (document.querySelector("main") || document.querySelector("[role='main']") || document.querySelector("article") || document.querySelector("#content") || document.querySelector(".content") || document.body).cloneNode(!0);
3513
+ e.querySelectorAll("nav, footer, header, aside, script, style, noscript, #flowengage-root, .flowengage-shell, .flowengage-widget-root, [id*='flowengage'], [class*='flowengage']").forEach((e) => e.remove());
3514
+ let t = e.textContent.replace(/\s+/g, " ").trim();
3515
+ return t.length > 0 ? t.substring(0, 3e3) : null;
3516
+ } catch {
3517
+ return null;
3518
+ }
3519
+ }
3520
+ let Qt = async (e, t = "", n = null, a = {}) => {
3509
3521
  let o = typeof e == "string" ? e.trim() : "";
3510
3522
  if (!o || !j.current || !y || l !== "ready" || Be) return;
3511
3523
  Yt();
@@ -3555,7 +3567,8 @@ function Wr({ siteId: e, config: t, children: n, language: r = "en" }) {
3555
3567
  ...a,
3556
3568
  currentPageUrl: typeof window < "u" ? window.location.href : void 0,
3557
3569
  currentPageTitle: typeof window < "u" ? document.title : void 0,
3558
- currentPagePath: typeof window < "u" ? window.location.pathname : void 0
3570
+ currentPagePath: typeof window < "u" ? window.location.pathname : void 0,
3571
+ currentPageContent: Zt() || void 0
3559
3572
  }), c = s.chat_history || [];
3560
3573
  if (console.log("[FWH Nav Debug] API response fields:", {
3561
3574
  has_navigate: !!s.navigate,
@@ -3613,10 +3626,10 @@ function Wr({ siteId: e, config: t, children: n, language: r = "en" }) {
3613
3626
  Ae(!1), Me("");
3614
3627
  }, ie)) : h(e);
3615
3628
  }
3616
- }, Qt = async (e) => {
3629
+ }, $t = async (e) => {
3617
3630
  if (!j.current || !e) throw Error("Upload is unavailable right now.");
3618
3631
  return j.current.uploadChatFile(e);
3619
- }, $t = async (e) => {
3632
+ }, en = async (e) => {
3620
3633
  if (!(!j.current || !y)) {
3621
3634
  try {
3622
3635
  let t = e ? "voice" : "text";
@@ -3624,7 +3637,7 @@ function Wr({ siteId: e, config: t, children: n, language: r = "en" }) {
3624
3637
  } catch {}
3625
3638
  Fe(e), e && (Tt.current = !1);
3626
3639
  }
3627
- }, en = async (e) => {
3640
+ }, tn = async (e) => {
3628
3641
  if (Tt.current) return;
3629
3642
  if (Tt.current = !0, !j.current || !y || !e?.length) {
3630
3643
  Fe(!1);
@@ -3653,9 +3666,9 @@ function Wr({ siteId: e, config: t, children: n, language: r = "en" }) {
3653
3666
  } finally {
3654
3667
  Fe(!1);
3655
3668
  }
3656
- }, tn = async () => {
3669
+ }, nn = async () => {
3657
3670
  if (!(!j.current || !y)) {
3658
- Pe && !Tt.current && wt.current.length > 0 && await en(wt.current);
3671
+ Pe && !Tt.current && wt.current.length > 0 && await tn(wt.current);
3659
3672
  try {
3660
3673
  await j.current.endConversation(y);
3661
3674
  } catch {
@@ -3700,12 +3713,12 @@ function Wr({ siteId: e, config: t, children: n, language: r = "en" }) {
3700
3713
  window.removeEventListener("pagehide", e), window.removeEventListener("beforeunload", e);
3701
3714
  };
3702
3715
  }, []);
3703
- let nn = o(() => {
3716
+ let rn = o(() => {
3704
3717
  let e = i?.siteId;
3705
3718
  ge(e), at.current = !0, ot.current = null, A.current?.disconnect(), S([]), b(""), it.current = "", Ve(!1), re(!1), D(null), de(null), rt(!0), s((e) => e + 1);
3706
- }, [i?.siteId]), rn = o((e) => {
3719
+ }, [i?.siteId]), an = o((e) => {
3707
3720
  i?.siteId, at.current = !1, ot.current = e, A.current?.disconnect(), S([]), b(""), it.current = "", Ve(!1), re(!1), D(null), de(null), rt(!0), s((e) => e + 1);
3708
- }, [i?.siteId]), an = f(() => ({
3721
+ }, [i?.siteId]), on = f(() => ({
3709
3722
  status: l,
3710
3723
  error: d,
3711
3724
  runtimeConfig: _,
@@ -3753,13 +3766,13 @@ function Wr({ siteId: e, config: t, children: n, language: r = "en" }) {
3753
3766
  }
3754
3767
  Kt({ notifyChatInitiated: !0 });
3755
3768
  },
3756
- sendMessage: Zt,
3757
- uploadChatFile: Qt,
3758
- setVoiceMode: $t,
3759
- onMessageSync: en,
3760
- endConversation: tn,
3761
- startNewChat: nn,
3762
- resumeChat: rn,
3769
+ sendMessage: Qt,
3770
+ uploadChatFile: $t,
3771
+ setVoiceMode: en,
3772
+ onMessageSync: tn,
3773
+ endConversation: nn,
3774
+ startNewChat: rn,
3775
+ resumeChat: an,
3763
3776
  getVisitorChatHistory: () => j.current?.getVisitorChatHistory?.(),
3764
3777
  getVisitorChatThread: (e) => j.current?.getVisitorChatThread?.(e),
3765
3778
  acceptCall: Vt,
@@ -3806,16 +3819,16 @@ function Wr({ siteId: e, config: t, children: n, language: r = "en" }) {
3806
3819
  Wt,
3807
3820
  Gt,
3808
3821
  Kt,
3809
- Zt,
3810
3822
  Qt,
3811
3823
  $t,
3812
3824
  en,
3813
3825
  tn,
3814
3826
  nn,
3827
+ rn,
3815
3828
  jt
3816
3829
  ]);
3817
3830
  return /* @__PURE__ */ g(Pn.Provider, {
3818
- value: an,
3831
+ value: on,
3819
3832
  children: n
3820
3833
  });
3821
3834
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flowengage/react-chatbot",
3
- "version": "8.0.11",
3
+ "version": "8.0.12",
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",