@flowengage/react-chatbot 1.9.5 → 1.9.7

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.
@@ -27386,9 +27386,45 @@ function bD({ size: e = 94, voiceState: t = "idle", isMuted: n = !1, colors: r,
27386
27386
  });
27387
27387
  }
27388
27388
  //#endregion
27389
+ //#region src/utils/domProxy.js
27390
+ var xD = (() => {
27391
+ try {
27392
+ return window.top !== window.self;
27393
+ } catch {
27394
+ return !0;
27395
+ }
27396
+ })(), SD = xD, CD = 0, wD = /* @__PURE__ */ new Map();
27397
+ xD && typeof window < "u" && window.addEventListener("message", (e) => {
27398
+ if (e.data?.type !== "FE_DOM_RESPONSE") return;
27399
+ let t = wD.get(e.data.id);
27400
+ t && (wD.delete(e.data.id), e.data.error ? t.reject(Error(e.data.error)) : t.resolve(e.data.result));
27401
+ });
27402
+ function TD(e, t = {}) {
27403
+ return xD ? new Promise((n, r) => {
27404
+ let i = ++CD;
27405
+ wD.set(i, {
27406
+ resolve: n,
27407
+ reject: r
27408
+ }), window.parent.postMessage({
27409
+ type: e,
27410
+ id: i,
27411
+ ...t
27412
+ }, "*"), setTimeout(() => {
27413
+ wD.has(i) && (wD.delete(i), r(/* @__PURE__ */ Error(`DOM proxy timeout: ${e}`)));
27414
+ }, 8e3);
27415
+ }) : Promise.resolve(null);
27416
+ }
27417
+ var ED = typeof window < "u" ? window.location.href : "";
27418
+ xD && typeof window < "u" && window.addEventListener("message", (e) => {
27419
+ e.data?.type === "PARENT_URL_CHANGE" && typeof e.data.url == "string" && (ED = e.data.url);
27420
+ });
27421
+ function DD() {
27422
+ return ED;
27423
+ }
27424
+ //#endregion
27389
27425
  //#region src/utils/voiceActionVisuals.js
27390
27426
  var Q = "fe-vv";
27391
- function xD() {
27427
+ function OD() {
27392
27428
  if (typeof document > "u" || document.getElementById(`${Q}-styles`)) return;
27393
27429
  let e = `
27394
27430
  /* ── Action toast ───────────────────────────────────────────────────────────── */
@@ -27533,14 +27569,14 @@ function xD() {
27533
27569
  `, t = document.createElement("style");
27534
27570
  t.id = `${Q}-styles`, t.textContent = e, (document.head || document.documentElement).appendChild(t);
27535
27571
  }
27536
- var SD = null, CD = null;
27537
- function wD() {
27538
- return (!SD || !SD.isConnected) && (SD = document.createElement("div"), SD.id = `${Q}-toast`, document.body.appendChild(SD)), SD;
27572
+ var kD = null, AD = null;
27573
+ function jD() {
27574
+ return (!kD || !kD.isConnected) && (kD = document.createElement("div"), kD.id = `${Q}-toast`, document.body.appendChild(kD)), kD;
27539
27575
  }
27540
- function TD(e, { spinner: t = !0, icon: n = null, duration: r = 0 } = {}) {
27576
+ function MD(e, { spinner: t = !0, icon: n = null, duration: r = 0 } = {}) {
27541
27577
  if (typeof document > "u") return;
27542
- xD(), CD &&= (clearTimeout(CD), null);
27543
- let i = wD();
27578
+ OD(), AD &&= (clearTimeout(AD), null);
27579
+ let i = jD();
27544
27580
  if (i.innerHTML = "", n) {
27545
27581
  let e = document.createElement("span");
27546
27582
  e.className = `${Q}-icon`, e.textContent = n, i.appendChild(e);
@@ -27549,82 +27585,82 @@ function TD(e, { spinner: t = !0, icon: n = null, duration: r = 0 } = {}) {
27549
27585
  e.className = `${Q}-spin`, i.appendChild(e);
27550
27586
  }
27551
27587
  let a = document.createElement("span");
27552
- a.textContent = e, i.appendChild(a), i.classList.remove(`${Q}-show`), i.offsetHeight, i.classList.add(`${Q}-show`), r > 0 && (CD = setTimeout(() => ED(), r));
27588
+ a.textContent = e, i.appendChild(a), i.classList.remove(`${Q}-show`), i.offsetHeight, i.classList.add(`${Q}-show`), r > 0 && (AD = setTimeout(() => ND(), r));
27553
27589
  }
27554
- function ED(e = 0) {
27555
- SD && (e > 0 ? CD = setTimeout(() => {
27556
- SD && SD.classList.remove(`${Q}-show`);
27557
- }, e) : SD && SD.classList.remove(`${Q}-show`));
27590
+ function ND(e = 0) {
27591
+ kD && (e > 0 ? AD = setTimeout(() => {
27592
+ kD && kD.classList.remove(`${Q}-show`);
27593
+ }, e) : kD && kD.classList.remove(`${Q}-show`));
27558
27594
  }
27559
- var DD = null, OD = [];
27560
- function kD() {
27561
- return (!DD || !DD.isConnected) && (DD = document.createElement("div"), DD.id = `${Q}-bar`, document.body.appendChild(DD)), DD;
27595
+ var PD = null, FD = [];
27596
+ function ID() {
27597
+ return (!PD || !PD.isConnected) && (PD = document.createElement("div"), PD.id = `${Q}-bar`, document.body.appendChild(PD)), PD;
27562
27598
  }
27563
- function AD() {
27599
+ function LD() {
27564
27600
  if (typeof document > "u") return;
27565
- xD(), OD.forEach(clearTimeout), OD = [];
27566
- let e = kD();
27601
+ OD(), FD.forEach(clearTimeout), FD = [];
27602
+ let e = ID();
27567
27603
  e.style.transition = "none", e.style.width = "0%", e.classList.add(`${Q}-bar-active`), e.offsetHeight, e.style.transition = "width 0.35s ease, opacity 0.25s ease";
27568
27604
  let t = [[80, "width 0.6s ease"], [92, "width 1.2s ease"]], n = 50;
27569
27605
  for (let [e, r] of t) {
27570
27606
  let t = n, i = e, a = r;
27571
- OD.push(setTimeout(() => {
27572
- DD && (DD.style.transition = a, DD.style.width = `${i}%`);
27607
+ FD.push(setTimeout(() => {
27608
+ PD && (PD.style.transition = a, PD.style.width = `${i}%`);
27573
27609
  }, t)), n += 800;
27574
27610
  }
27575
27611
  }
27576
- function jD() {
27577
- DD && (OD.forEach(clearTimeout), OD = [], DD.style.transition = "width 0.2s ease", DD.style.width = "100%", OD.push(setTimeout(() => {
27578
- DD && (DD.style.transition = "opacity 0.35s ease", DD.style.opacity = "0", OD.push(setTimeout(() => {
27579
- DD && (DD.style.width = "0%", DD.classList.remove(`${Q}-bar-active`));
27612
+ function RD() {
27613
+ PD && (FD.forEach(clearTimeout), FD = [], PD.style.transition = "width 0.2s ease", PD.style.width = "100%", FD.push(setTimeout(() => {
27614
+ PD && (PD.style.transition = "opacity 0.35s ease", PD.style.opacity = "0", FD.push(setTimeout(() => {
27615
+ PD && (PD.style.width = "0%", PD.classList.remove(`${Q}-bar-active`));
27580
27616
  }, 380)));
27581
27617
  }, 220)));
27582
27618
  }
27583
- function MD() {
27619
+ function zD() {
27584
27620
  typeof document > "u" || document.querySelectorAll(`.${Q}-field-active, .${Q}-field-filled`).forEach((e) => e.classList.remove(`${Q}-field-active`, `${Q}-field-filled`));
27585
27621
  }
27586
- function ND(e) {
27587
- !e || typeof document > "u" || (xD(), MD(), e.classList.add(`${Q}-field-active`));
27622
+ function BD(e) {
27623
+ !e || typeof document > "u" || (OD(), zD(), e.classList.add(`${Q}-field-active`));
27588
27624
  }
27589
- function PD(e) {
27625
+ function VD(e) {
27590
27626
  e && (e.classList.remove(`${Q}-field-active`), e.classList.add(`${Q}-field-filled`), setTimeout(() => {
27591
27627
  e.isConnected && e.classList.remove(`${Q}-field-filled`);
27592
27628
  }, 1400));
27593
27629
  }
27594
- var FD = `<svg xmlns="http://www.w3.org/2000/svg" width="22" height="22" viewBox="0 0 22 22" fill="none">
27630
+ var HD = `<svg xmlns="http://www.w3.org/2000/svg" width="22" height="22" viewBox="0 0 22 22" fill="none">
27595
27631
  <filter id="${Q}-csh">
27596
27632
  <feDropShadow dx="1" dy="2" stdDeviation="1.5" flood-color="#00000060"/>
27597
27633
  </filter>
27598
27634
  <path d="M4 2L19 10.5L11 12.8L8 20L4 2Z"
27599
27635
  fill="white" stroke="#1e1b4b" stroke-width="1.6" stroke-linejoin="round"
27600
27636
  filter="url(#${Q}-csh)"/>
27601
- </svg>`, ID = null, LD = !1;
27602
- function RD() {
27603
- return (!ID || !ID.isConnected) && (ID = document.createElement("div"), ID.id = `${Q}-cursor`, ID.innerHTML = FD, document.body.appendChild(ID), LD = !1), ID;
27637
+ </svg>`, UD = null, WD = !1;
27638
+ function GD() {
27639
+ return (!UD || !UD.isConnected) && (UD = document.createElement("div"), UD.id = `${Q}-cursor`, UD.innerHTML = HD, document.body.appendChild(UD), WD = !1), UD;
27604
27640
  }
27605
- async function zD(e) {
27641
+ async function KD(e) {
27606
27642
  if (typeof document > "u" || !e) return;
27607
- xD();
27643
+ OD();
27608
27644
  let t;
27609
27645
  try {
27610
27646
  t = e.getBoundingClientRect();
27611
27647
  } catch {
27612
27648
  return;
27613
27649
  }
27614
- let n = t.left + Math.min(16, t.width * .2), r = t.top + Math.min(12, t.height * .25), i = RD();
27615
- LD ||= (i.style.transition = "none", i.style.left = `${window.innerWidth / 2}px`, i.style.top = `${window.innerHeight * .4}px`, i.classList.add(`${Q}-cursor-visible`), i.offsetHeight, i.style.transition = "left 0.32s cubic-bezier(0.25,0.46,0.45,0.94), top 0.32s cubic-bezier(0.25,0.46,0.45,0.94), opacity 0.2s ease", !0), i.style.left = `${n}px`, i.style.top = `${r}px`, await UD(360);
27650
+ let n = t.left + Math.min(16, t.width * .2), r = t.top + Math.min(12, t.height * .25), i = GD();
27651
+ WD ||= (i.style.transition = "none", i.style.left = `${window.innerWidth / 2}px`, i.style.top = `${window.innerHeight * .4}px`, i.classList.add(`${Q}-cursor-visible`), i.offsetHeight, i.style.transition = "left 0.32s cubic-bezier(0.25,0.46,0.45,0.94), top 0.32s cubic-bezier(0.25,0.46,0.45,0.94), opacity 0.2s ease", !0), i.style.left = `${n}px`, i.style.top = `${r}px`, await XD(360);
27616
27652
  }
27617
- function BD(e = !1) {
27618
- ID && (e ? (ID.classList.remove(`${Q}-cursor-visible`), LD = !1) : (ID.classList.remove(`${Q}-cursor-visible`), setTimeout(() => {
27619
- LD = !1;
27653
+ function qD(e = !1) {
27654
+ UD && (e ? (UD.classList.remove(`${Q}-cursor-visible`), WD = !1) : (UD.classList.remove(`${Q}-cursor-visible`), setTimeout(() => {
27655
+ WD = !1;
27620
27656
  }, 250)));
27621
27657
  }
27622
- async function VD(e) {
27623
- ID && (ID.classList.add(`${Q}-cursor-click`), await UD(280), ID.classList.remove(`${Q}-cursor-click`));
27658
+ async function JD(e) {
27659
+ UD && (UD.classList.add(`${Q}-cursor-click`), await XD(280), UD.classList.remove(`${Q}-cursor-click`));
27624
27660
  }
27625
- function HD(e) {
27661
+ function YD(e) {
27626
27662
  if (!e || typeof document > "u") return;
27627
- xD();
27663
+ OD();
27628
27664
  let t;
27629
27665
  try {
27630
27666
  t = e.getBoundingClientRect();
@@ -27650,7 +27686,7 @@ function HD(e) {
27650
27686
  a.remove(), e.style.position = n, e.style.overflow = r;
27651
27687
  }, 650);
27652
27688
  }
27653
- function UD(e) {
27689
+ function XD(e) {
27654
27690
  return new Promise((t) => setTimeout(t, e));
27655
27691
  }
27656
27692
  //#endregion
@@ -27658,42 +27694,42 @@ function UD(e) {
27658
27694
  function $(...e) {
27659
27695
  mn() && console.log("[FlowEngage:voice-tools]", ...e);
27660
27696
  }
27661
- function WD(e) {
27697
+ function ZD(e) {
27662
27698
  return new Promise((t) => setTimeout(t, e));
27663
27699
  }
27664
- var GD = "#flowengage-root, .flowengage-shell, .flowengage-widget-root";
27665
- function KD(e) {
27700
+ var QD = "#flowengage-root, .flowengage-shell, .flowengage-widget-root";
27701
+ function $D(e) {
27666
27702
  if (!e || typeof e.closest != "function") return !1;
27667
27703
  try {
27668
- return !!e.closest(GD);
27704
+ return !!e.closest(QD);
27669
27705
  } catch {
27670
27706
  return !1;
27671
27707
  }
27672
27708
  }
27673
- function qD(e) {
27709
+ function eO(e) {
27674
27710
  try {
27675
27711
  let t = e.ownerDocument?.defaultView;
27676
27712
  if (t) return t.getComputedStyle(e);
27677
27713
  } catch {}
27678
27714
  return window.getComputedStyle(e);
27679
27715
  }
27680
- function JD(e) {
27716
+ function tO(e) {
27681
27717
  let t = /* @__PURE__ */ new Set();
27682
27718
  function n(r) {
27683
27719
  if (!r || t.has(r)) return;
27684
27720
  t.add(r), e(r);
27685
27721
  let i = r.querySelectorAll("iframe");
27686
- for (let e of i) if (!KD(e)) try {
27722
+ for (let e of i) if (!$D(e)) try {
27687
27723
  let t = e.contentDocument;
27688
27724
  t && n(t);
27689
27725
  } catch {}
27690
27726
  }
27691
27727
  typeof document < "u" && n(document);
27692
27728
  }
27693
- function YD(e) {
27729
+ function nO(e) {
27694
27730
  return e == null ? null : String(e).replace(/\u00a0/g, " ").replace(/\s*\*+\s*$/u, "").replace(/\s+/g, " ").trim();
27695
27731
  }
27696
- function XD(e) {
27732
+ function rO(e) {
27697
27733
  let t = e.ownerDocument || document, n = e.getAttribute("aria-labelledby");
27698
27734
  if (n) {
27699
27735
  let e = n.trim().split(/\s+/).filter(Boolean), r = [];
@@ -27701,42 +27737,42 @@ function XD(e) {
27701
27737
  let e = t.getElementById(n);
27702
27738
  e?.textContent && r.push(e.textContent.trim());
27703
27739
  } catch {}
27704
- if (r.length) return YD(r.join(" "));
27740
+ if (r.length) return nO(r.join(" "));
27705
27741
  }
27706
- if (e.labels && e.labels.length) return YD(e.labels[0].textContent);
27742
+ if (e.labels && e.labels.length) return nO(e.labels[0].textContent);
27707
27743
  let r = e.id;
27708
27744
  if (r) try {
27709
27745
  let e = t.querySelector(`label[for="${CSS.escape(r)}"]`);
27710
- if (e) return YD(e.textContent);
27746
+ if (e) return nO(e.textContent);
27711
27747
  } catch {
27712
27748
  let e = t.querySelector(`label[for="${r.replace(/"/g, "\\\"")}"]`);
27713
- if (e) return YD(e.textContent);
27749
+ if (e) return nO(e.textContent);
27714
27750
  }
27715
27751
  let i = e.previousElementSibling;
27716
27752
  for (let e = 0; e < 6 && i; e += 1) {
27717
- if (i.tagName === "LABEL") return YD(i.textContent);
27753
+ if (i.tagName === "LABEL") return nO(i.textContent);
27718
27754
  let e = (i.className || "").toString().toLowerCase();
27719
27755
  if (/chakra-form__label|formlabel|field-label|form-label|mui-form-label/.test(e)) {
27720
- let e = YD(i.textContent);
27756
+ let e = nO(i.textContent);
27721
27757
  if (e) return e;
27722
27758
  }
27723
27759
  i = i.previousElementSibling;
27724
27760
  }
27725
27761
  let a = e.parentElement;
27726
27762
  for (let e = 0; e < 5 && a; e += 1) {
27727
- if (a.tagName === "LABEL") return YD(a.textContent);
27763
+ if (a.tagName === "LABEL") return nO(a.textContent);
27728
27764
  let e = a.querySelector?.(":scope > label, :scope > [class*='FormLabel'], :scope > [class*='form__label']");
27729
- if (e?.textContent) return YD(e.textContent);
27765
+ if (e?.textContent) return nO(e.textContent);
27730
27766
  a = a.parentElement;
27731
27767
  }
27732
27768
  let o = e.getAttribute("aria-label");
27733
- return o ? YD(o) : null;
27769
+ return o ? nO(o) : null;
27734
27770
  }
27735
- function ZD() {
27771
+ function iO() {
27736
27772
  let e = [];
27737
- return JD((t) => {
27773
+ return tO((t) => {
27738
27774
  e.push(...Array.from(t.querySelectorAll("input, select, textarea")).filter((e) => {
27739
- if (KD(e)) return !1;
27775
+ if ($D(e)) return !1;
27740
27776
  let t = (e.type || "").toLowerCase();
27741
27777
  if ([
27742
27778
  "hidden",
@@ -27745,32 +27781,32 @@ function ZD() {
27745
27781
  "image"
27746
27782
  ].includes(t) || e.disabled || e.readOnly) return !1;
27747
27783
  try {
27748
- let t = qD(e);
27784
+ let t = eO(e);
27749
27785
  if (t.display === "none" || t.visibility === "hidden") return !1;
27750
27786
  } catch {}
27751
27787
  return !0;
27752
27788
  }));
27753
27789
  }), e;
27754
27790
  }
27755
- function QD() {
27756
- return ZD().map((e, t) => ({
27791
+ function aO() {
27792
+ return iO().map((e, t) => ({
27757
27793
  formIndex: 0,
27758
27794
  fieldIndex: t,
27759
27795
  tag: e.tagName,
27760
27796
  type: e.type || "text",
27761
27797
  name: e.name || null,
27762
27798
  id: e.id || null,
27763
- label: XD(e),
27799
+ label: rO(e),
27764
27800
  placeholder: e.placeholder || null
27765
27801
  }));
27766
27802
  }
27767
- function $D() {
27803
+ function oO() {
27768
27804
  let e = [];
27769
- return JD((t) => {
27805
+ return tO((t) => {
27770
27806
  e.push(...Array.from(t.querySelectorAll("button, [role=\"button\"], input[type=\"submit\"], input[type=\"button\"]")).filter((e) => {
27771
- if (KD(e) || e.disabled) return !1;
27807
+ if ($D(e) || e.disabled) return !1;
27772
27808
  try {
27773
- let t = qD(e);
27809
+ let t = eO(e);
27774
27810
  if (t.display === "none" || t.visibility === "hidden") return !1;
27775
27811
  } catch {}
27776
27812
  return !0;
@@ -27782,15 +27818,15 @@ function $D() {
27782
27818
  type: e.type || e.tagName
27783
27819
  }));
27784
27820
  }
27785
- function eO(e) {
27821
+ function sO(e) {
27786
27822
  return String(e || "").toLowerCase().replace(/\u00a0/g, " ").replace(/\*/g, "").replace(/\s+/g, " ").trim();
27787
27823
  }
27788
- function tO(e) {
27789
- let t = eO(e);
27824
+ function cO(e) {
27825
+ let t = sO(e);
27790
27826
  return t = t.replace(/\s+field\s*$/i, "").trim(), t;
27791
27827
  }
27792
- function nO(e, t) {
27793
- let n = tO(t);
27828
+ function lO(e, t) {
27829
+ let n = cO(t);
27794
27830
  if (!n) return 0;
27795
27831
  let r = (e.name || "").toLowerCase(), i = (e.id || "").toLowerCase();
27796
27832
  if (r === "url" && /url|website|domain|site|audit/.test(n) || (i === "url-input" || i.endsWith("-url-input")) && /url|website|domain|site|audit/.test(n)) return 100;
@@ -27798,12 +27834,12 @@ function nO(e, t) {
27798
27834
  e.name,
27799
27835
  e.id,
27800
27836
  e.placeholder,
27801
- XD(e),
27837
+ rO(e),
27802
27838
  e.getAttribute("aria-label"),
27803
27839
  e.getAttribute("title"),
27804
27840
  e.getAttribute("data-testid"),
27805
27841
  e.getAttribute("autocomplete")
27806
- ].filter(Boolean).map((e) => eO(e)), o = 0;
27842
+ ].filter(Boolean).map((e) => sO(e)), o = 0;
27807
27843
  for (let e of a) {
27808
27844
  if (!e) continue;
27809
27845
  if (e.includes(n) || n.includes(e)) {
@@ -27818,16 +27854,16 @@ function nO(e, t) {
27818
27854
  }
27819
27855
  return o;
27820
27856
  }
27821
- var rO = 28;
27822
- function iO(e, t) {
27857
+ var uO = 28;
27858
+ function dO(e, t) {
27823
27859
  let n = null, r = 0;
27824
27860
  for (let i of e) {
27825
- let e = nO(i, t);
27861
+ let e = lO(i, t);
27826
27862
  e > r && (r = e, n = i);
27827
27863
  }
27828
- return !n || r < rO ? null : n;
27864
+ return !n || r < uO ? null : n;
27829
27865
  }
27830
- function aO(e, t, n) {
27866
+ function fO(e, t, n) {
27831
27867
  let r = String(t || "").toLowerCase().trim(), i = String(n || "").trim();
27832
27868
  if (!(/^https?:\/\//i.test(i) || /\.\w{2,}(\/|\s|$)/.test(i) || r.includes("url") || r.includes("website") || r.includes("domain") || r.includes("site"))) return null;
27833
27869
  let a = null, o = 0;
@@ -27847,7 +27883,7 @@ function aO(e, t, n) {
27847
27883
  t.name,
27848
27884
  t.id,
27849
27885
  t.placeholder,
27850
- XD(t),
27886
+ rO(t),
27851
27887
  t.getAttribute("aria-label"),
27852
27888
  t.getAttribute("autocomplete")
27853
27889
  ].filter(Boolean).join(" ").toLowerCase();
@@ -27855,15 +27891,15 @@ function aO(e, t, n) {
27855
27891
  }
27856
27892
  return !a || o < 42 ? null : a;
27857
27893
  }
27858
- function oO(e) {
27894
+ function pO(e) {
27859
27895
  let t = String(e ?? "").trim();
27860
27896
  return t ? /^https?:\/\//i.test(t) ? !0 : /\.\w{2,}(\/|\s|$)/.test(t) : !1;
27861
27897
  }
27862
- function sO(e) {
27898
+ function mO(e) {
27863
27899
  let t = String(e ?? "").toLowerCase().trim();
27864
27900
  return t ? !!(t === "url" || t === "website" || t === "website url" || t === "website_url" || t === "enter website url" || t.includes("website") || t.includes("domain") || /(enter\s+website|site\s*url|page\s*url)/.test(t)) : !1;
27865
27901
  }
27866
- function cO(e) {
27902
+ function hO(e) {
27867
27903
  if (!e || e.tagName !== "INPUT" && e.tagName !== "TEXTAREA") return !1;
27868
27904
  let t = (e.type || "").toLowerCase();
27869
27905
  return ![
@@ -27875,22 +27911,22 @@ function cO(e) {
27875
27911
  "file"
27876
27912
  ].includes(t);
27877
27913
  }
27878
- function lO(e) {
27879
- if (!cO(e)) return !1;
27914
+ function gO(e) {
27915
+ if (!hO(e)) return !1;
27880
27916
  let t = (e.name || "").toLowerCase(), n = (e.id || "").toLowerCase(), r = [
27881
27917
  e.name,
27882
27918
  e.id,
27883
27919
  e.placeholder,
27884
- XD(e),
27920
+ rO(e),
27885
27921
  e.getAttribute("aria-label")
27886
27922
  ].filter(Boolean).join(" ").toLowerCase();
27887
27923
  return t === "url" || n === "url-input" || n.endsWith("-url-input") || /(website\s*url|enter\s+website|site\s*url)/.test(r) || /(website|domain)/.test(r) && /(url|site)/.test(r);
27888
27924
  }
27889
- function uO(e, t, n) {
27890
- let r = String(t ?? ""), i = String(n ?? ""), a = pO(e, r) || iO(e, r) || aO(e, r, i);
27925
+ function _O(e, t, n) {
27926
+ let r = String(t ?? ""), i = String(n ?? ""), a = bO(e, r) || dO(e, r) || fO(e, r, i);
27891
27927
  if (!a) return [];
27892
27928
  let o = new Set([a]);
27893
- if (oO(i) && sO(r)) for (let t of e) t !== a && lO(t) && o.add(t);
27929
+ if (pO(i) && mO(r)) for (let t of e) t !== a && gO(t) && o.add(t);
27894
27930
  let s = Array.from(o);
27895
27931
  return s.sort((e, t) => {
27896
27932
  if (e === t) return 0;
@@ -27898,7 +27934,7 @@ function uO(e, t, n) {
27898
27934
  return n & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : n & Node.DOCUMENT_POSITION_PRECEDING ? 1 : 0;
27899
27935
  }), s;
27900
27936
  }
27901
- function dO(e, t) {
27937
+ function vO(e, t) {
27902
27938
  try {
27903
27939
  if (!e?.getBoundingClientRect || !t?.getBoundingClientRect) return Infinity;
27904
27940
  let n = e.getBoundingClientRect(), r = t.getBoundingClientRect(), i = {
@@ -27913,17 +27949,17 @@ function dO(e, t) {
27913
27949
  return Infinity;
27914
27950
  }
27915
27951
  }
27916
- function fO(e) {
27952
+ function yO(e) {
27917
27953
  if (!e || typeof e != "string") return null;
27918
27954
  let t = null;
27919
- return JD((n) => {
27955
+ return tO((n) => {
27920
27956
  try {
27921
27957
  let r = n.getElementById(e);
27922
- r && !KD(r) && r.matches?.("input, select, textarea") && (t = r);
27958
+ r && !$D(r) && r.matches?.("input, select, textarea") && (t = r);
27923
27959
  } catch {}
27924
27960
  }), t;
27925
27961
  }
27926
- function pO(e, t) {
27962
+ function bO(e, t) {
27927
27963
  let n = String(t ?? "").trim();
27928
27964
  if (!n) return null;
27929
27965
  let r = n.match(/^name:\s*([\w.-]+)$/i);
@@ -27933,12 +27969,12 @@ function pO(e, t) {
27933
27969
  }
27934
27970
  let i = n.match(/^id:\s*([\w.-]+)$/i);
27935
27971
  if (i) {
27936
- let e = fO(i[1]);
27972
+ let e = yO(i[1]);
27937
27973
  if (e) return e;
27938
27974
  }
27939
27975
  let a = n.startsWith("#") ? n.slice(1) : n;
27940
27976
  if (/^[\w-]+$/.test(a)) {
27941
- let e = fO(a);
27977
+ let e = yO(a);
27942
27978
  if (e) return e;
27943
27979
  }
27944
27980
  let o = n.toLowerCase().replace(/\s+/g, " ");
@@ -27948,7 +27984,7 @@ function pO(e, t) {
27948
27984
  }
27949
27985
  return null;
27950
27986
  }
27951
- function mO(e, t) {
27987
+ function xO(e, t) {
27952
27988
  let n = String(t || "").toLowerCase().trim();
27953
27989
  if (!n) return 0;
27954
27990
  let r = [
@@ -27964,13 +28000,13 @@ function mO(e, t) {
27964
28000
  for (let e of i) r.includes(e) && (a += 1);
27965
28001
  return a / i.length * 92;
27966
28002
  }
27967
- function hO(e, t) {
28003
+ function SO(e, t) {
27968
28004
  let n = [];
27969
- JD((e) => {
28005
+ tO((e) => {
27970
28006
  n.push(...Array.from(e.querySelectorAll("button, [role=\"button\"], input[type=\"submit\"], input[type=\"button\"]")).filter((e) => {
27971
- if (KD(e) || e.disabled) return !1;
28007
+ if ($D(e) || e.disabled) return !1;
27972
28008
  try {
27973
- let t = qD(e);
28009
+ let t = eO(e);
27974
28010
  if (t.display === "none" || t.visibility === "hidden") return !1;
27975
28011
  } catch {}
27976
28012
  return !0;
@@ -27978,7 +28014,7 @@ function hO(e, t) {
27978
28014
  });
27979
28015
  let r = 0, i = n.map((t) => ({
27980
28016
  el: t,
27981
- s: mO(t, e)
28017
+ s: xO(t, e)
27982
28018
  }));
27983
28019
  for (let { s: e } of i) e > r && (r = e);
27984
28020
  if (r < 36) return null;
@@ -27988,14 +28024,14 @@ function hO(e, t) {
27988
28024
  if (o.length) {
27989
28025
  let e = a[0], t = Infinity;
27990
28026
  for (let n of a) for (let r of o) {
27991
- let i = dO(n, r);
28027
+ let i = vO(n, r);
27992
28028
  i < t && (t = i, e = n);
27993
28029
  }
27994
28030
  return e;
27995
28031
  }
27996
28032
  return a[0];
27997
28033
  }
27998
- function gO(e) {
28034
+ function CO(e) {
27999
28035
  if (e == null) return {};
28000
28036
  if (typeof e == "string") {
28001
28037
  let t = e.trim();
@@ -28008,8 +28044,8 @@ function gO(e) {
28008
28044
  }
28009
28045
  return e;
28010
28046
  }
28011
- function _O(e) {
28012
- let t = gO(e);
28047
+ function wO(e) {
28048
+ let t = CO(e);
28013
28049
  if (Array.isArray(t) && t.length > 0) {
28014
28050
  let e = t[0];
28015
28051
  if (e?.field_key != null || e?.fieldKey != null) return t.map((e) => ({
@@ -28037,7 +28073,7 @@ function _O(e) {
28037
28073
  value: e?.value ?? e?.Value
28038
28074
  })) : [];
28039
28075
  }
28040
- function vO(e) {
28076
+ function TO(e) {
28041
28077
  if (!e || typeof e != "string") return [];
28042
28078
  let t = e.trim();
28043
28079
  if (!t || /\b[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,}\b/i.test(t)) return [];
@@ -28056,7 +28092,7 @@ function vO(e) {
28056
28092
  }
28057
28093
  return [];
28058
28094
  }
28059
- function yO(e) {
28095
+ function EO(e) {
28060
28096
  if (!e || typeof e != "string") return [];
28061
28097
  let t = e.trim();
28062
28098
  if (!t) return [];
@@ -28092,17 +28128,17 @@ function yO(e) {
28092
28128
  }
28093
28129
  return n;
28094
28130
  }
28095
- function bO(e) {
28131
+ function DO(e) {
28096
28132
  if (!e || typeof e != "object") return null;
28097
28133
  let t = e.url ?? e.target_url ?? e.page_url ?? e.pageUrl ?? e.link ?? e.href ?? e.path;
28098
28134
  return t == null ? null : String(t).trim() || null;
28099
28135
  }
28100
- function xO(e) {
28136
+ function OO(e) {
28101
28137
  if (!e || typeof e != "object") return null;
28102
28138
  let t = e.query ?? e.q ?? e.search ?? e.text ?? e.keywords;
28103
28139
  return t == null ? null : String(t).trim() || null;
28104
28140
  }
28105
- function SO(e, t, n) {
28141
+ function kO(e, t, n) {
28106
28142
  if (!n?.skipScroll) try {
28107
28143
  e.scrollIntoView({
28108
28144
  block: "center",
@@ -28157,7 +28193,7 @@ function SO(e, t, n) {
28157
28193
  } catch {}
28158
28194
  return !0;
28159
28195
  }
28160
- function CO() {
28196
+ function AO() {
28161
28197
  let e = {};
28162
28198
  document.querySelectorAll("h1, h2, h3, h4, h5, h6").forEach((t) => {
28163
28199
  if (t.id) return;
@@ -28172,11 +28208,11 @@ function CO() {
28172
28208
  e[r] = !0, t.id = r;
28173
28209
  });
28174
28210
  }
28175
- function wO(e) {
28211
+ function jO(e) {
28176
28212
  let t = e.siteId || null, n = (e.apiBaseUrl || "").replace(/\/$/, ""), r = typeof e.getLastUserVoiceText == "function" ? e.getLastUserVoiceText : null, i = [], a = {
28177
28213
  flowengage_navigate: async (n) => {
28178
28214
  $("flowengage_navigate ▶ raw parameters:", n);
28179
- let r = gO(n), i = bO(r), a = r.section_text ?? r.sectionText ?? r.section;
28215
+ let r = CO(n), i = DO(r), a = r.section_text ?? r.sectionText ?? r.section;
28180
28216
  if ($("flowengage_navigate · coerced:", {
28181
28217
  url: i,
28182
28218
  sectionText: a
@@ -28191,8 +28227,26 @@ function wO(e) {
28191
28227
  let e = "That page is not available in the site index; answer without navigating.";
28192
28228
  return $("flowengage_navigate ✖ blocked", e), e;
28193
28229
  }
28230
+ if (SD) try {
28231
+ MD(`Navigating to ${i}...`, { spinner: !0 }), LD(), ME(), $("flowengage_navigate → proxy FE_DOM_NAVIGATE", i), await TD("FE_DOM_NAVIGATE", { url: i }), await ZD(600), a && typeof a == "string" && ($("flowengage_navigate · proxy FE_DOM_HIGHLIGHT", a), await TD("FE_DOM_HIGHLIGHT", { sectionText: a }));
28232
+ let e = `OK_NAVIGATION ${i}`;
28233
+ return $("flowengage_navigate ✓ (iframe proxy)", e), MD("Navigation complete", {
28234
+ spinner: !1,
28235
+ icon: "✅",
28236
+ duration: 1200
28237
+ }), e;
28238
+ } catch (e) {
28239
+ let t = `Navigation error: ${e?.message || String(e)}`;
28240
+ return $("flowengage_navigate ✖", t), MD("Navigation failed", {
28241
+ spinner: !1,
28242
+ icon: "⚠️",
28243
+ duration: 1800
28244
+ }), t;
28245
+ } finally {
28246
+ RD(), ND(900);
28247
+ }
28194
28248
  try {
28195
- if (TD(`Navigating to ${i}...`, { spinner: !0 }), AD(), ME(), RE(), $("flowengage_navigate → shadowNavigate", i), await On(i), await WD(400), CO(), a && typeof a == "string") {
28249
+ if (MD(`Navigating to ${i}...`, { spinner: !0 }), LD(), ME(), RE(), $("flowengage_navigate → shadowNavigate", i), await On(i), await ZD(400), AO(), a && typeof a == "string") {
28196
28250
  let e = xn(null, a);
28197
28251
  e && CE(() => LE(e)), $("flowengage_navigate · highlight", {
28198
28252
  sectionText: a,
@@ -28200,30 +28254,43 @@ function wO(e) {
28200
28254
  });
28201
28255
  }
28202
28256
  let e = `OK_NAVIGATION ${i}`;
28203
- return $("flowengage_navigate ✓", e), TD("Navigation complete", {
28257
+ return $("flowengage_navigate ✓", e), MD("Navigation complete", {
28204
28258
  spinner: !1,
28205
28259
  icon: "✅",
28206
28260
  duration: 1200
28207
28261
  }), e;
28208
28262
  } catch (e) {
28209
28263
  let t = `Navigation error: ${e?.message || String(e)}`;
28210
- return $("flowengage_navigate ✖", t), TD("Navigation failed", {
28264
+ return $("flowengage_navigate ✖", t), MD("Navigation failed", {
28211
28265
  spinner: !1,
28212
28266
  icon: "⚠️",
28213
28267
  duration: 1800
28214
28268
  }), t;
28215
28269
  } finally {
28216
- jD(), ED(900);
28270
+ RD(), ND(900);
28217
28271
  }
28218
28272
  },
28219
28273
  flowengage_highlight: async (e) => {
28220
28274
  $("flowengage_highlight ▶", e);
28221
- let t = gO(e), n = t?.section_id || t?.sectionId, r = t?.section_text || t?.sectionText, i = xn(n || null, r || null);
28275
+ let t = CO(e), n = t?.section_id || t?.sectionId, r = t?.section_text || t?.sectionText;
28276
+ if (SD) {
28277
+ let e = r || n || null;
28278
+ if (!e) return $("flowengage_highlight ✖ no text"), "Could not find that section on the page.";
28279
+ $("flowengage_highlight → proxy FE_DOM_HIGHLIGHT", e);
28280
+ let t = await TD("FE_DOM_HIGHLIGHT", { sectionText: e });
28281
+ return $("flowengage_highlight ✓ (iframe proxy)", t), t || "Highlighted the section.";
28282
+ }
28283
+ let i = xn(n || null, r || null);
28222
28284
  return i ? (LE(i), $("flowengage_highlight ✓"), "Highlighted the section.") : ($("flowengage_highlight ✖ no element"), "Could not find that section on the page.");
28223
28285
  },
28224
28286
  flowengage_read_content: async (e) => {
28225
28287
  $("flowengage_read_content ▶", e);
28226
- let t = gO(e), n = t?.section_text || t?.sectionText || "";
28288
+ let t = CO(e), n = t?.section_text || t?.sectionText || "";
28289
+ if (SD) {
28290
+ $("flowengage_read_content → proxy FE_DOM_READ_CONTENT", n);
28291
+ let e = await TD("FE_DOM_READ_CONTENT", { sectionText: n });
28292
+ return $("flowengage_read_content ✓ (iframe proxy)", `${String(e || "").length} chars`), e || "No readable content found on this page.";
28293
+ }
28227
28294
  try {
28228
28295
  let e = "";
28229
28296
  if (n) {
@@ -28246,7 +28313,7 @@ function wO(e) {
28246
28313
  },
28247
28314
  flowengage_search: async (e) => {
28248
28315
  $("flowengage_search ▶", e);
28249
- let r = xO(gO(e));
28316
+ let r = OO(CO(e));
28250
28317
  if ($("flowengage_search · query:", r, "siteId:", t, "apiBase:", n || "(empty)"), !r) return $("flowengage_search ✖ missing query"), "Missing query parameter.";
28251
28318
  if (!t) return $("flowengage_search ✖ no siteId"), "Site is not configured for search.";
28252
28319
  if (!n) return $("flowengage_search ✖ no api base"), "API base URL is missing; cannot search.";
@@ -28259,7 +28326,7 @@ function wO(e) {
28259
28326
  body: JSON.stringify({
28260
28327
  siteId: t,
28261
28328
  query: r,
28262
- currentUrl: typeof window < "u" ? window.location.href : ""
28329
+ currentUrl: SD ? DD() : typeof window < "u" ? window.location.href : ""
28263
28330
  })
28264
28331
  }), a = await i.json();
28265
28332
  if ($("flowengage_search · HTTP", i.status, "success:", a.success), !a.success) {
@@ -28275,7 +28342,7 @@ function wO(e) {
28275
28342
  },
28276
28343
  flowengage_page_content: async (e) => {
28277
28344
  $("flowengage_page_content ▶", e);
28278
- let r = gO(e), i = r?.url || r?.page_url || "";
28345
+ let r = CO(e), i = r?.url || r?.page_url || "";
28279
28346
  if ($("flowengage_page_content · url:", i, "siteId:", t, "apiBase:", n || "(empty)"), !i) return $("flowengage_page_content ✖ missing url"), "Missing url parameter.";
28280
28347
  if (!t) return $("flowengage_page_content ✖ no siteId"), "Site is not configured.";
28281
28348
  if (!n) return $("flowengage_page_content ✖ no api base"), "API base URL is missing; cannot fetch page content.";
@@ -28307,7 +28374,12 @@ function wO(e) {
28307
28374
  },
28308
28375
  flowengage_end_session: async () => ($("flowengage_end_session ▶"), typeof e.requestEndSession == "function" && e.requestEndSession(), "Voice session is ending."),
28309
28376
  flowengage_list_forms: async () => {
28310
- let e = QD(), t = $D();
28377
+ if (SD) {
28378
+ $("flowengage_list_forms → proxy FE_DOM_LIST_FORMS");
28379
+ let e = await TD("FE_DOM_LIST_FORMS");
28380
+ return $("flowengage_list_forms ✓ (iframe proxy)"), e;
28381
+ }
28382
+ let e = aO(), t = oO();
28311
28383
  return $("flowengage_list_forms ✓", `${e.length} field(s)`, `${t.length} button(s)`), JSON.stringify({
28312
28384
  fields: e,
28313
28385
  buttons: t,
@@ -28315,53 +28387,98 @@ function wO(e) {
28315
28387
  });
28316
28388
  },
28317
28389
  flowengage_fill_form: async (e) => {
28390
+ if (SD) try {
28391
+ $("flowengage_fill_form ▶ (iframe proxy) raw:", e), zD();
28392
+ let t = wO(e);
28393
+ if (!t.length && r) {
28394
+ let e = r(), n = TO(e);
28395
+ n.length || (n = EO(e)), n.length && ($("flowengage_fill_form · inferred from utterance:", n), t = n);
28396
+ }
28397
+ if ($("flowengage_fill_form · normalized fields:", t), !t.length) return "No fields provided. Call flowengage_list_forms for field_key strings, then flowengage_fill_form with { \"fields\": [ { \"field_key\": \"<label or placeholder from list>\", \"value\": \"<user value>\" } ] }. Never use empty {}.";
28398
+ MD("Filling form...", { spinner: !0 });
28399
+ let n = await TD("FE_DOM_FILL_FORM", { fields: t });
28400
+ return $("flowengage_fill_form ✓ (iframe proxy)", n), MD("Form filled", {
28401
+ spinner: !1,
28402
+ icon: "✅",
28403
+ duration: 1100
28404
+ }), n;
28405
+ } catch (e) {
28406
+ let t = `flowengage_fill_form error: ${e?.message || String(e)}`;
28407
+ return $("flowengage_fill_form ✖", t), MD("Failed to fill form", {
28408
+ spinner: !1,
28409
+ icon: "⚠️",
28410
+ duration: 1800
28411
+ }), t;
28412
+ } finally {
28413
+ qD(), zD(), ND(700);
28414
+ }
28318
28415
  try {
28319
- $("flowengage_fill_form ▶ raw:", e), MD();
28320
- let t = _O(e);
28416
+ $("flowengage_fill_form ▶ raw:", e), zD();
28417
+ let t = wO(e);
28321
28418
  if (!t.length && r) {
28322
- let e = r(), n = vO(e);
28323
- n.length ? $("flowengage_fill_form · inferred URL from last user utterance (model omitted usable fields):", n) : (n = yO(e), n.length && $("flowengage_fill_form · inferred contact fields from last user utterance (empty tool params):", n)), n.length && (t = n);
28419
+ let e = r(), n = TO(e);
28420
+ n.length ? $("flowengage_fill_form · inferred URL from last user utterance (model omitted usable fields):", n) : (n = EO(e), n.length && $("flowengage_fill_form · inferred contact fields from last user utterance (empty tool params):", n)), n.length && (t = n);
28324
28421
  }
28325
28422
  if ($("flowengage_fill_form · normalized fields:", t), !t.length) return "No fields provided. Call flowengage_list_forms for field_key strings, then flowengage_fill_form with { \"fields\": [ { \"field_key\": \"<label or placeholder from list>\", \"value\": \"<user value>\" } ] }. Never use empty {}. Pass the value the user just said (email, message, name, URL) in fields.";
28326
28423
  let n = [];
28327
28424
  for (let e of t) {
28328
28425
  let t = e?.field_key ?? e?.fieldKey, r = e?.value;
28329
28426
  if (t == null || r == null) continue;
28330
- TD(`Filling ${String(t)}...`, { spinner: !0 });
28331
- let a = ZD(), o = uO(a, String(t), r);
28427
+ MD(`Filling ${String(t)}...`, { spinner: !0 });
28428
+ let a = iO(), o = _O(a, String(t), r);
28332
28429
  if (o.length) {
28333
- for (let [e, t] of o.entries()) ND(t), await zD(t), SO(t, r, { skipScroll: e > 0 }), PD(t), await WD(120);
28430
+ for (let [e, t] of o.entries()) BD(t), await KD(t), kO(t, r, { skipScroll: e > 0 }), VD(t), await ZD(120);
28334
28431
  i = o, n.push(String(t));
28335
28432
  continue;
28336
28433
  }
28337
- let s = pO(a, String(t));
28338
- s ||= iO(a, String(t)), s ||= aO(a, String(t), r), s && (ND(s), await zD(s), SO(s, r), PD(s), await WD(120), i = [s], n.push(String(t)));
28434
+ let s = bO(a, String(t));
28435
+ s ||= dO(a, String(t)), s ||= fO(a, String(t), r), s && (BD(s), await KD(s), kO(s, r), VD(s), await ZD(120), i = [s], n.push(String(t)));
28339
28436
  }
28340
28437
  if (!n.length) return $("flowengage_fill_form ✖ no matches"), "Could not match any fields. Call flowengage_list_forms and use field_key values that match placeholder, label, name, or id (e.g. Enter Website URL). Ensure the form is on the page, not the chat panel.";
28341
28438
  let a = `OK_FILLED: ${n.join(", ")}`;
28342
- return $("flowengage_fill_form ✓", a), TD("Form filled", {
28439
+ return $("flowengage_fill_form ✓", a), MD("Form filled", {
28343
28440
  spinner: !1,
28344
28441
  icon: "✅",
28345
28442
  duration: 1100
28346
28443
  }), a;
28347
28444
  } catch (e) {
28348
28445
  let t = `flowengage_fill_form error: ${e?.message || String(e)}`;
28349
- return $("flowengage_fill_form ✖", t), TD("Failed to fill form", {
28446
+ return $("flowengage_fill_form ✖", t), MD("Failed to fill form", {
28350
28447
  spinner: !1,
28351
28448
  icon: "⚠️",
28352
28449
  duration: 1800
28353
28450
  }), t;
28354
28451
  } finally {
28355
- BD(), MD(), ED(700);
28452
+ qD(), zD(), ND(700);
28356
28453
  }
28357
28454
  },
28358
28455
  flowengage_click_button: async (e) => {
28359
- let t = gO(e), n = (t.button_text ?? t.buttonText ?? t.text ?? "").trim();
28456
+ let t = CO(e), n = (t.button_text ?? t.buttonText ?? t.text ?? "").trim();
28360
28457
  if ($("flowengage_click_button ▶", n), !n) return "Missing button_text: pass the visible label, e.g. Conduct Audit.";
28361
- let r = hO(n, i);
28458
+ if (SD) {
28459
+ MD(`Clicking ${n}...`, { spinner: !0 });
28460
+ try {
28461
+ let e = await TD("FE_DOM_CLICK_BUTTON", { text: n });
28462
+ return $("flowengage_click_button ✓ (iframe proxy)", e), MD("Clicked", {
28463
+ spinner: !1,
28464
+ icon: "✅",
28465
+ duration: 1200
28466
+ }), e;
28467
+ } catch (e) {
28468
+ let t = `Click failed: ${e?.message || String(e)}`;
28469
+ return $("flowengage_click_button ✖", t), MD("Click failed", {
28470
+ spinner: !1,
28471
+ icon: "⚠️",
28472
+ duration: 1800
28473
+ }), t;
28474
+ } finally {
28475
+ qD(), ND(700);
28476
+ }
28477
+ }
28478
+ let r = SO(n, i);
28362
28479
  if (!r) return $("flowengage_click_button ✖ no match"), `Could not find a button matching "${n}". Call flowengage_list_forms to see button texts.`;
28363
28480
  try {
28364
- TD(`Clicking ${n}...`, { spinner: !0 });
28481
+ MD(`Clicking ${n}...`, { spinner: !0 });
28365
28482
  try {
28366
28483
  r.scrollIntoView({
28367
28484
  block: "center",
@@ -28370,22 +28487,22 @@ function wO(e) {
28370
28487
  } catch {
28371
28488
  r.scrollIntoView(!0);
28372
28489
  }
28373
- await zD(r), r.focus?.(), await VD(r), HD(r), r.click();
28490
+ await KD(r), r.focus?.(), await JD(r), YD(r), r.click();
28374
28491
  let e = (r.textContent || r.value || r.getAttribute("aria-label") || "").trim().slice(0, 80) || "button", t = `OK_CLICK ${e}`;
28375
- return $("flowengage_click_button ✓", t), TD(`Clicked ${e}`, {
28492
+ return $("flowengage_click_button ✓", t), MD(`Clicked ${e}`, {
28376
28493
  spinner: !1,
28377
28494
  icon: "✅",
28378
28495
  duration: 1200
28379
28496
  }), t;
28380
28497
  } catch (e) {
28381
28498
  let t = `Click failed: ${e?.message || String(e)}`;
28382
- return $("flowengage_click_button ✖", t), TD("Click failed", {
28499
+ return $("flowengage_click_button ✖", t), MD("Click failed", {
28383
28500
  spinner: !1,
28384
28501
  icon: "⚠️",
28385
28502
  duration: 1800
28386
28503
  }), t;
28387
28504
  } finally {
28388
- BD(), ED(700);
28505
+ qD(), ND(700);
28389
28506
  }
28390
28507
  }
28391
28508
  };
@@ -28403,7 +28520,7 @@ function wO(e) {
28403
28520
  }
28404
28521
  //#endregion
28405
28522
  //#region src/utils/wrapVoiceToolsForLogging.js
28406
- function TO(e) {
28523
+ function MO(e) {
28407
28524
  return !e || typeof e != "object" ? e : Object.fromEntries(Object.entries(e).map(([e, t]) => [e, async (n) => {
28408
28525
  let r = mn();
28409
28526
  r ? console.log("[FlowEngage:voice-tool] ▶", e, n) : console.info(`[FlowEngage] voice tool » ${e}`);
@@ -28420,7 +28537,7 @@ function TO(e) {
28420
28537
  }
28421
28538
  //#endregion
28422
28539
  //#region src/components/FlowEngageWidget.jsx
28423
- var EO = {
28540
+ var NO = {
28424
28541
  blue: "#135bd8",
28425
28542
  red: "#ef334b",
28426
28543
  yellow: "#ffbd2e",
@@ -28428,7 +28545,7 @@ var EO = {
28428
28545
  highlight: "rgba(255,255,255,0.9)",
28429
28546
  green: "#10b981"
28430
28547
  };
28431
- function DO(e) {
28548
+ function PO(e) {
28432
28549
  if (!Array.isArray(e) || e.length < 2) return "linear-gradient(145deg, #dce8f022 0%, #e8dff522 45%, #f5e0e022 100%), #f7f8fa";
28433
28550
  let [t, n, r] = e;
28434
28551
  return e.length >= 3 && r ? [
@@ -28442,12 +28559,12 @@ function DO(e) {
28442
28559
  "#f7f8fa"
28443
28560
  ].join(", ");
28444
28561
  }
28445
- function OO(e) {
28562
+ function FO(e) {
28446
28563
  if (!e || typeof e != "string") return "#1a1a1a";
28447
28564
  let t = e.replace("#", ""), n = t.length === 3 ? t.split("").map((e) => e + e).join("") : t, r = parseInt(n.slice(0, 2), 16) / 255, i = parseInt(n.slice(2, 4), 16) / 255, a = parseInt(n.slice(4, 6), 16) / 255, o = (e) => e <= .04045 ? e / 12.92 : ((e + .055) / 1.055) ** 2.4;
28448
28565
  return .2126 * o(r) + .7152 * o(i) + .0722 * o(a) > .179 ? "#1a1a1a" : "#ffffff";
28449
28566
  }
28450
- function kO({ logo: t, style: n }) {
28567
+ function IO({ logo: t, style: n }) {
28451
28568
  if (!t) return null;
28452
28569
  if (typeof t == "string") return /* @__PURE__ */ g("img", {
28453
28570
  src: t,
@@ -28472,7 +28589,7 @@ function kO({ logo: t, style: n }) {
28472
28589
  children: r
28473
28590
  }) : null;
28474
28591
  }
28475
- function AO({ title: e }) {
28592
+ function LO({ title: e }) {
28476
28593
  return /* @__PURE__ */ g("div", {
28477
28594
  style: {
28478
28595
  width: "100%",
@@ -28490,18 +28607,18 @@ function AO({ title: e }) {
28490
28607
  children: String(e || "FE").split(/\s+/).filter(Boolean).slice(0, 2).map((e) => e[0]?.toUpperCase() || "").join("") || "FE"
28491
28608
  });
28492
28609
  }
28493
- function jO(e, t) {
28610
+ function RO(e, t) {
28494
28611
  let n = (t || "").trim();
28495
28612
  return n ? !!(/\b(let'?s|let us)\s+(end|stop|finish|wrap up|close)\s+(the\s+)?(voice\s+)?(session|call|chat)\b/i.test(n) || /\bend\s+(this\s+)?(the\s+)?(voice\s+)?(session|call|chat)\b/i.test(n) || /\b(hang\s+up|disconnect)\b/i.test(n) || /\b(that'?s all|we'?re done)\b/i.test(n) || e === "bot" && (/\b(I'?ll|I will|Let me|I can|I'?m going to)\s+(end|close)\s+(the\s+)?(voice\s+)?(session|call)\b/i.test(n) || /\b(ending|closing)\s+(the\s+)?(voice\s+)?session\b|\bvoice\s+session\s+(is\s+)?(now\s+)?(ended|over|closing)\b/i.test(n) || /\b(session|call)\s+(is\s+)?(now\s+)?(ended|over)\b/i.test(n) || /\bwe\s+can\s+end\s+(the\s+)?(session|call)?\s*(here|now)\b/i.test(n) || /\b(wrapping\s+up|signing\s+off)\b/i.test(n)) || /^(goodbye|bye|that'?s all|we'?re done|hang up|disconnect)\b/i.test(n)) : !1;
28496
28613
  }
28497
- function MO({ orbColors: e, ...t }) {
28614
+ function zO({ orbColors: e, ...t }) {
28498
28615
  return /* @__PURE__ */ g(bD, {
28499
28616
  colors: e,
28500
28617
  ...t
28501
28618
  });
28502
28619
  }
28503
- function NO({ copy: e, orbColors: t, primaryColor: n, onYes: r, onLater: i, isMobile: a }) {
28504
- let o = n || EO.green, s = OO(o), c = a ? 72 : 94, l = /* @__PURE__ */ _("div", {
28620
+ function BO({ copy: e, orbColors: t, primaryColor: n, onYes: r, onLater: i, isMobile: a }) {
28621
+ let o = n || NO.green, s = FO(o), c = a ? 72 : 94, l = /* @__PURE__ */ _("div", {
28505
28622
  style: {
28506
28623
  display: "flex",
28507
28624
  alignItems: "center",
@@ -28618,7 +28735,7 @@ function NO({ copy: e, orbColors: t, primaryColor: n, onYes: r, onLater: i, isMo
28618
28735
  delay: 0
28619
28736
  },
28620
28737
  style: { flexShrink: 0 },
28621
- children: /* @__PURE__ */ g(MO, {
28738
+ children: /* @__PURE__ */ g(zO, {
28622
28739
  size: c,
28623
28740
  orbColors: t
28624
28741
  })
@@ -28646,8 +28763,8 @@ function NO({ copy: e, orbColors: t, primaryColor: n, onYes: r, onLater: i, isMo
28646
28763
  children: l
28647
28764
  }) : l] });
28648
28765
  }
28649
- function PO({ copy: e, orbColors: t, primaryColor: n, onVoice: r, onText: i, onClose: a }) {
28650
- let o = n || EO.green, s = OO(o);
28766
+ function VO({ copy: e, orbColors: t, primaryColor: n, onVoice: r, onText: i, onClose: a }) {
28767
+ let o = n || NO.green, s = FO(o);
28651
28768
  return /* @__PURE__ */ _(Tp.div, {
28652
28769
  initial: {
28653
28770
  scale: 50 / 300,
@@ -28711,7 +28828,7 @@ function PO({ copy: e, orbColors: t, primaryColor: n, onVoice: r, onText: i, onC
28711
28828
  children: /* @__PURE__ */ g("polyline", { points: "6 9 12 15 18 9" })
28712
28829
  })
28713
28830
  }),
28714
- /* @__PURE__ */ g(MO, {
28831
+ /* @__PURE__ */ g(zO, {
28715
28832
  size: 82,
28716
28833
  orbColors: t
28717
28834
  }),
@@ -28780,7 +28897,7 @@ function PO({ copy: e, orbColors: t, primaryColor: n, onVoice: r, onText: i, onC
28780
28897
  ]
28781
28898
  });
28782
28899
  }
28783
- function FO({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i, apiBaseUrl: a, historyRef: s, onMessageSync: l }) {
28900
+ function HO({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i, apiBaseUrl: a, historyRef: s, onMessageSync: l }) {
28784
28901
  let [u, d] = m("idle"), [f, v] = m(!1), [y, b] = m(!1), x = p(null), S = p(""), C = p(async () => {}), w = p(!1), T = p(!1), ee = p(!1), te = p(!1), ne = p("minimized"), re = p(null), E = p(null), ie = p(!1), ae = o((e = "minimized") => {
28785
28902
  ne.current = e, te.current = !0, queueMicrotask(() => {
28786
28903
  w.current || (w.current = !0, C.current?.());
@@ -28811,7 +28928,7 @@ function FO({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
28811
28928
  try {
28812
28929
  if ((await navigator.mediaDevices.getUserMedia({ audio: !0 })).getTracks().forEach((e) => e.stop()), e) return;
28813
28930
  s.current = [], S.current = "", w.current = !1, ee.current = !1, te.current = !1, ne.current = "minimized", AE(!0), ME();
28814
- let t = TO(wO({
28931
+ let t = MO(jO({
28815
28932
  siteId: i || null,
28816
28933
  apiBaseUrl: a || null,
28817
28934
  getLastUserVoiceText: () => S.current,
@@ -28835,7 +28952,7 @@ function FO({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
28835
28952
  sender: n,
28836
28953
  message: r,
28837
28954
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
28838
- }], jO(n, r) && ae("minimized"));
28955
+ }], RO(n, r) && ae("minimized"));
28839
28956
  },
28840
28957
  onError: (t) => {
28841
28958
  if (!e && !te.current && !ee.current) if (ee.current = !0, console.error("[FlowEngageVoiceCall] session:error", {
@@ -28943,7 +29060,7 @@ function FO({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
28943
29060
  whiteSpace: "nowrap"
28944
29061
  },
28945
29062
  children: "Listening..."
28946
- }), /* @__PURE__ */ g(MO, {
29063
+ }), /* @__PURE__ */ g(zO, {
28947
29064
  size: 94,
28948
29065
  voiceState: u,
28949
29066
  isMuted: f,
@@ -29185,7 +29302,7 @@ function FO({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
29185
29302
  ]
29186
29303
  }) });
29187
29304
  }
29188
- function IO({ orbColors: e }) {
29305
+ function UO({ orbColors: e }) {
29189
29306
  return /* @__PURE__ */ g("div", {
29190
29307
  style: {
29191
29308
  flexShrink: 0,
@@ -29195,13 +29312,13 @@ function IO({ orbColors: e }) {
29195
29312
  alignItems: "center",
29196
29313
  justifyContent: "center"
29197
29314
  },
29198
- children: /* @__PURE__ */ g(MO, {
29315
+ children: /* @__PURE__ */ g(zO, {
29199
29316
  size: 36,
29200
29317
  orbColors: e
29201
29318
  })
29202
29319
  });
29203
29320
  }
29204
- var LO = () => /* @__PURE__ */ g("div", {
29321
+ var WO = () => /* @__PURE__ */ g("div", {
29205
29322
  style: {
29206
29323
  display: "flex",
29207
29324
  marginBottom: "12px",
@@ -29231,7 +29348,7 @@ var LO = () => /* @__PURE__ */ g("div", {
29231
29348
  } }, e))
29232
29349
  })
29233
29350
  });
29234
- function RO({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i, quickChatOptions: a, onQuickChatSelect: o, isMobile: s, chatHistory: l, isAiTyping: u, isAgentTyping: d, activeScreen: f, agentName: h, agentHeadshot: v, fallbackAgentName: y, input: b, setInput: x, onSubmit: S, isConversationEnded: C, isLoading: w, isRateLimited: T, rateLimitMessage: ee, selectedFile: te, onFileSelect: ne, onRemoveSelectedFile: re, attachmentError: E, isUploadingAttachment: ie, requiresEmail: ae, emailInput: oe, setEmailInput: se, emailError: ce, replyContext: le, setReplyContext: ue, webRTCError: de, micError: fe, setMicError: pe, dismissCallError: me, incomingCall: he, rejectCall: ge, acceptCall: _e, activeCallId: ve, callConnectionState: ye, isCallMuted: be, toggleCallMute: xe, endWebRTCCall: Se, formatCallDuration: Ce, callDurationSeconds: we, onCollapse: Te, onStartVoice: Ee, showPoweredBy: De }) {
29351
+ function GO({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i, quickChatOptions: a, onQuickChatSelect: o, isMobile: s, chatHistory: l, isAiTyping: u, isAgentTyping: d, activeScreen: f, agentName: h, agentHeadshot: v, fallbackAgentName: y, input: b, setInput: x, onSubmit: S, isConversationEnded: C, isLoading: w, isRateLimited: T, rateLimitMessage: ee, selectedFile: te, onFileSelect: ne, onRemoveSelectedFile: re, attachmentError: E, isUploadingAttachment: ie, requiresEmail: ae, emailInput: oe, setEmailInput: se, emailError: ce, replyContext: le, setReplyContext: ue, webRTCError: de, micError: fe, setMicError: pe, dismissCallError: me, incomingCall: he, rejectCall: ge, acceptCall: _e, activeCallId: ve, callConnectionState: ye, isCallMuted: be, toggleCallMute: xe, endWebRTCCall: Se, formatCallDuration: Ce, callDurationSeconds: we, onCollapse: Te, onStartVoice: Ee, showPoweredBy: De }) {
29235
29352
  let Oe = l.length > 0, ke = w || T || C, Ae = !!(he || ve), [je, Me] = m(!1), Ne = p(null);
29236
29353
  return c(() => {
29237
29354
  if (!je) return;
@@ -29333,7 +29450,7 @@ function RO({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
29333
29450
  justifyContent: "center",
29334
29451
  height: "40px"
29335
29452
  },
29336
- children: i ? /* @__PURE__ */ g(kO, {
29453
+ children: i ? /* @__PURE__ */ g(IO, {
29337
29454
  logo: i,
29338
29455
  style: {
29339
29456
  height: "34px",
@@ -29346,7 +29463,7 @@ function RO({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
29346
29463
  height: "40px",
29347
29464
  flexShrink: 0
29348
29465
  },
29349
- children: /* @__PURE__ */ g(AO, { title: e.chatTitle })
29466
+ children: /* @__PURE__ */ g(LO, { title: e.chatTitle })
29350
29467
  })
29351
29468
  }), /* @__PURE__ */ g("div", {
29352
29469
  style: {
@@ -29565,11 +29682,11 @@ function RO({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
29565
29682
  isAiTyping: u,
29566
29683
  isAgentTyping: d,
29567
29684
  setReplyContext: ue,
29568
- TypingDots: LO,
29685
+ TypingDots: WO,
29569
29686
  primaryColor: n,
29570
29687
  agentHeadshot: v,
29571
29688
  agentDisplayName: h || y,
29572
- botAvatarNode: /* @__PURE__ */ g(IO, { orbColors: t })
29689
+ botAvatarNode: /* @__PURE__ */ g(UO, { orbColors: t })
29573
29690
  }) : /* @__PURE__ */ _("div", {
29574
29691
  style: {
29575
29692
  flex: 1,
@@ -29582,7 +29699,7 @@ function RO({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
29582
29699
  padding: "28px 24px"
29583
29700
  },
29584
29701
  children: [
29585
- /* @__PURE__ */ g(MO, {
29702
+ /* @__PURE__ */ g(zO, {
29586
29703
  size: 94,
29587
29704
  orbColors: t
29588
29705
  }),
@@ -29690,7 +29807,7 @@ function RO({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
29690
29807
  ]
29691
29808
  });
29692
29809
  }
29693
- function zO() {
29810
+ function KO() {
29694
29811
  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, historyRef: ie, onMessageSync: ae, sendMessage: oe, uploadChatFile: se, openWidget: ce, captureVisitorEmail: le, setVoiceMode: ue, endConversation: de, acceptCall: fe, rejectCall: pe, endWebRTCCall: me, toggleCallMute: he, dismissCallError: ge, startTyping: _e, stopTyping: ve, updateTypingDraft: ye } = pn();
29695
29812
  c(() => {
29696
29813
  try {
@@ -29703,7 +29820,7 @@ function zO() {
29703
29820
  }, Ce = {
29704
29821
  ...be.theme || {},
29705
29822
  ...xe.theme || {}
29706
- }, we = Array.isArray(Ce.orbColors) && Ce.orbColors.length > 0 ? Ce.orbColors : null, Te = we?.[0] || Ce.primaryColor || "#3B82F6", Ee = Ce.position || "bottom-right", De = Se.fallbackAgentName || "Agent", Oe = DO(we ?? Ce.chatBgColors), ke = Se.logo || Se.logoUrl || null, Ae = E || "en", je = be.recommendations?.[Ae] || [], Me = (xe.recommendations?.[Ae] ?? je).filter((e) => String(e?.label ?? "").trim()).map((e, t) => ({
29823
+ }, we = Array.isArray(Ce.orbColors) && Ce.orbColors.length > 0 ? Ce.orbColors : null, Te = we?.[0] || Ce.primaryColor || "#3B82F6", Ee = Ce.position || "bottom-right", De = Se.fallbackAgentName || "Agent", Oe = PO(we ?? Ce.chatBgColors), ke = Se.logo || Se.logoUrl || null, Ae = E || "en", je = be.recommendations?.[Ae] || [], Me = (xe.recommendations?.[Ae] ?? je).filter((e) => String(e?.label ?? "").trim()).map((e, t) => ({
29707
29824
  id: e.key || `qr-${t}`,
29708
29825
  label: e.label,
29709
29826
  message: e.label,
@@ -29877,7 +29994,7 @@ function zO() {
29877
29994
  ...yt
29878
29995
  },
29879
29996
  children: [
29880
- Ke === "entry_prompt" && /* @__PURE__ */ g(NO, {
29997
+ Ke === "entry_prompt" && /* @__PURE__ */ g(BO, {
29881
29998
  copy: Le,
29882
29999
  orbColors: we,
29883
30000
  primaryColor: Te,
@@ -29898,13 +30015,13 @@ function zO() {
29898
30015
  transformOrigin: "bottom right",
29899
30016
  display: "inline-block"
29900
30017
  },
29901
- children: /* @__PURE__ */ g(MO, {
30018
+ children: /* @__PURE__ */ g(zO, {
29902
30019
  size: 50,
29903
30020
  orbColors: we,
29904
30021
  onClick: xt
29905
30022
  })
29906
30023
  }),
29907
- Ke === "connection_modal" && /* @__PURE__ */ g(PO, {
30024
+ Ke === "connection_modal" && /* @__PURE__ */ g(VO, {
29908
30025
  copy: Le,
29909
30026
  orbColors: we,
29910
30027
  primaryColor: Te,
@@ -29912,7 +30029,7 @@ function zO() {
29912
30029
  onText: Ct,
29913
30030
  onClose: bt
29914
30031
  }),
29915
- Ke === "voice_mode" && /* @__PURE__ */ g(FO, {
30032
+ Ke === "voice_mode" && /* @__PURE__ */ g(HO, {
29916
30033
  orbColors: we,
29917
30034
  onEnterChat: Ct,
29918
30035
  onEndChat: wt,
@@ -29922,7 +30039,7 @@ function zO() {
29922
30039
  historyRef: ie,
29923
30040
  onMessageSync: ae
29924
30041
  }, "voice"),
29925
- Ke === "text_chat" && /* @__PURE__ */ g(RO, {
30042
+ Ke === "text_chat" && /* @__PURE__ */ g(GO, {
29926
30043
  copy: Le,
29927
30044
  orbColors: we,
29928
30045
  primaryColor: Te,
@@ -29980,4 +30097,4 @@ function zO() {
29980
30097
  });
29981
30098
  }
29982
30099
  //#endregion
29983
- export { bD as AnimatedOrb, In as FlowEngageProvider, zO as FlowEngageWidget, pn as useFlowEngage };
30100
+ export { bD as AnimatedOrb, In as FlowEngageProvider, KO as FlowEngageWidget, pn as useFlowEngage };