@flowengage/react-chatbot 1.6.4 → 1.6.5

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.
@@ -1948,7 +1948,11 @@ function Tn(e, t) {
1948
1948
  t ||= e.replace(/[-_]+/g, " ").trim();
1949
1949
  }
1950
1950
  if (!t) return null;
1951
- let n = t.toLowerCase().trim(), r = n.split(/\s+/).filter((e) => e.length > 2), i = Array.from(document.querySelectorAll("h1, h2, h3, h4, h5, h6, [data-section]")).filter((e) => !hn(e));
1951
+ let n = t.toLowerCase().trim(), r = n.split(/\s+/).filter((e) => e.length > 2), i = Array.from(document.querySelectorAll((/* @__PURE__ */ "h1.h2.h3.h4.h5.h6.[data-section].section[id].[id].main li.article li.[role='main'] li.[class*='card'].[class*='Card'].[class*='feature'].[class*='Feature'].[class*='tier'].[class*='Tier'].[class*='plan'].[class*='Plan'].[class*='pricing'].[class*='Pricing'].[class*='testimonial'].[class*='Testimonial'].[class*='team'].[class*='Team'].[class*='service'].[class*='Service'].[class*='block'].[role='listitem'].[role='article'].[role='region'].dt.dd".split(".")).join(", "))).filter((e) => {
1952
+ if (hn(e)) return !1;
1953
+ let t = e.textContent.trim();
1954
+ return !(t.length < 3 || t.length > 5e3 || e.closest("nav, footer, header, aside, .nav, .footer, .header"));
1955
+ });
1952
1956
  for (let e of i) if (e.textContent.replace(/\s+/g, " ").toLowerCase().trim() === n) return e;
1953
1957
  for (let e of i) {
1954
1958
  let t = e.textContent.replace(/\s+/g, " ").toLowerCase().trim();
@@ -27390,92 +27394,59 @@ function rD({ size: e = 94, voiceState: t = "idle", isMuted: n = !1, colors: r,
27390
27394
  }
27391
27395
  //#endregion
27392
27396
  //#region src/utils/actionQueue.js
27393
- var iD = 375, aD = 6e3, oD = {
27397
+ var iD = {
27394
27398
  wordsSoFar: 0,
27395
27399
  speechStartTime: 0,
27396
27400
  isSpeaking: !1,
27397
27401
  items: [],
27398
27402
  timers: [],
27399
- textDraining: !1,
27400
27403
  lastHighlightId: null,
27401
27404
  isVoiceMode: !1
27402
27405
  };
27403
- function sD(e, t = 5e3) {
27404
- let n = {
27405
- execute: e,
27406
- wordOffset: oD.wordsSoFar,
27407
- holdMs: t
27408
- };
27409
- if (oD.isVoiceMode) if (oD.speechStartTime > 0) cD(n);
27410
- else {
27411
- oD.items.push(n);
27412
- let e = setTimeout(() => {
27413
- let e = oD.items.indexOf(n);
27414
- e !== -1 && (oD.items.splice(e, 1), n.execute());
27415
- }, aD);
27416
- oD.timers.push(e);
27417
- }
27418
- else oD.items.push(n), oD.textDraining || lD();
27419
- }
27420
- function cD(e) {
27421
- let t = e.wordOffset * iD, n = Date.now() - oD.speechStartTime, r = Math.max(0, t - n), i = setTimeout(e.execute, r);
27422
- oD.timers.push(i);
27423
- }
27424
- function lD() {
27425
- if (oD.items.length === 0) {
27426
- oD.textDraining = !1;
27427
- return;
27428
- }
27429
- oD.textDraining = !0;
27430
- let e = oD.items.shift();
27431
- setTimeout(() => e.execute(), 300);
27432
- let t = setTimeout(lD, e.holdMs);
27433
- oD.timers.push(t);
27434
- }
27435
- function uD() {
27436
- oD.timers.forEach(clearTimeout), oD.wordsSoFar = 0, oD.speechStartTime = 0, oD.isSpeaking = !1, oD.items = [], oD.timers = [], oD.textDraining = !1, oD.lastHighlightId = null;
27406
+ function aD() {
27407
+ iD.timers.forEach(clearTimeout), iD.wordsSoFar = 0, iD.speechStartTime = 0, iD.isSpeaking = !1, iD.items = [], iD.timers = [], iD.lastHighlightId = null;
27437
27408
  }
27438
27409
  //#endregion
27439
27410
  //#region src/utils/highlightEngine.js
27440
- var dD = 80, fD = null;
27441
- function pD(e) {
27411
+ var oD = 80, sD = null;
27412
+ function cD(e) {
27442
27413
  requestAnimationFrame(() => {
27443
- let t = e.getBoundingClientRect(), n = t.top + t.height / 2, r = dD, i = r + (window.innerHeight - r) / 2, a = window.pageYOffset + n - i;
27414
+ let t = e.getBoundingClientRect(), n = t.top + t.height / 2, r = oD, i = r + (window.innerHeight - r) / 2, a = window.pageYOffset + n - i;
27444
27415
  window.scrollTo({
27445
27416
  top: Math.max(0, a),
27446
27417
  behavior: "smooth"
27447
27418
  });
27448
27419
  });
27449
27420
  }
27450
- function mD(e) {
27451
- hD(), fD = document.createElement("div"), fD.id = "fe-spotlight-overlay", fD.style.cssText = "position:fixed;top:0;left:0;right:0;bottom:0;background:rgba(0,0,0,0.35);z-index:9998;pointer-events:none;transition:opacity 0.4s ease;opacity:0;", document.body.appendChild(fD), fD.offsetHeight, fD.style.opacity = "1", e.style.position = "relative", e.style.zIndex = "9999";
27421
+ function lD(e) {
27422
+ uD(), sD = document.createElement("div"), sD.id = "fe-spotlight-overlay", sD.style.cssText = "position:fixed;top:0;left:0;right:0;bottom:0;background:rgba(0,0,0,0.35);z-index:9998;pointer-events:none;transition:opacity 0.4s ease;opacity:0;", document.body.appendChild(sD), sD.offsetHeight, sD.style.opacity = "1", e.style.position = "relative", e.style.zIndex = "9999";
27452
27423
  }
27453
- function hD() {
27454
- if (fD) {
27455
- fD.style.opacity = "0";
27456
- let e = fD;
27424
+ function uD() {
27425
+ if (sD) {
27426
+ sD.style.opacity = "0";
27427
+ let e = sD;
27457
27428
  setTimeout(() => {
27458
27429
  e.parentNode && e.parentNode.removeChild(e);
27459
- }, 400), fD = null;
27430
+ }, 400), sD = null;
27460
27431
  }
27461
27432
  document.querySelectorAll("[data-fe-highlighted]").forEach((e) => {
27462
27433
  e.style.zIndex = "", e.style.position = "";
27463
27434
  });
27464
27435
  }
27465
- function gD(e) {
27436
+ function dD(e) {
27466
27437
  if (!e || e.hasAttribute("data-fe-highlighted")) return;
27467
- _D(), pD(e);
27438
+ fD(), cD(e);
27468
27439
  let t = e.style.cssText;
27469
- e.setAttribute("data-fe-highlighted", "true"), e.setAttribute("data-fe-orig-style", t), e.style.outline = "3px solid #2563eb", e.style.outlineOffset = "8px", e.style.background = "rgba(37, 99, 235, 0.08)", e.style.borderRadius = "8px", e.style.padding = "12px 16px", e.style.transition = "all 0.4s ease", mD(e), setTimeout(() => _D(), 6e4);
27440
+ e.setAttribute("data-fe-highlighted", "true"), e.setAttribute("data-fe-orig-style", t), e.style.outline = "3px solid #2563eb", e.style.outlineOffset = "8px", e.style.background = "rgba(37, 99, 235, 0.08)", e.style.borderRadius = "8px", e.style.padding = "12px 16px", e.style.transition = "all 0.4s ease", lD(e);
27470
27441
  }
27471
- function _D() {
27442
+ function fD() {
27472
27443
  let e = document.querySelector("[data-fe-highlighted]");
27473
- e && (e.style.cssText = e.getAttribute("data-fe-orig-style") || "", e.removeAttribute("data-fe-highlighted"), e.removeAttribute("data-fe-orig-style")), hD();
27444
+ e && (e.style.cssText = e.getAttribute("data-fe-orig-style") || "", e.removeAttribute("data-fe-highlighted"), e.removeAttribute("data-fe-orig-style")), uD();
27474
27445
  }
27475
27446
  //#endregion
27476
27447
  //#region src/utils/voiceActionVisuals.js
27477
27448
  var Q = "fe-vv";
27478
- function vD() {
27449
+ function pD() {
27479
27450
  if (typeof document > "u" || document.getElementById(`${Q}-styles`)) return;
27480
27451
  let e = `
27481
27452
  /* ── Action toast ───────────────────────────────────────────────────────────── */
@@ -27620,14 +27591,14 @@ function vD() {
27620
27591
  `, t = document.createElement("style");
27621
27592
  t.id = `${Q}-styles`, t.textContent = e, (document.head || document.documentElement).appendChild(t);
27622
27593
  }
27623
- var yD = null, bD = null;
27624
- function xD() {
27625
- return (!yD || !yD.isConnected) && (yD = document.createElement("div"), yD.id = `${Q}-toast`, document.body.appendChild(yD)), yD;
27594
+ var mD = null, hD = null;
27595
+ function gD() {
27596
+ return (!mD || !mD.isConnected) && (mD = document.createElement("div"), mD.id = `${Q}-toast`, document.body.appendChild(mD)), mD;
27626
27597
  }
27627
- function SD(e, { spinner: t = !0, icon: n = null, duration: r = 0 } = {}) {
27598
+ function _D(e, { spinner: t = !0, icon: n = null, duration: r = 0 } = {}) {
27628
27599
  if (typeof document > "u") return;
27629
- vD(), bD &&= (clearTimeout(bD), null);
27630
- let i = xD();
27600
+ pD(), hD &&= (clearTimeout(hD), null);
27601
+ let i = gD();
27631
27602
  if (i.innerHTML = "", n) {
27632
27603
  let e = document.createElement("span");
27633
27604
  e.className = `${Q}-icon`, e.textContent = n, i.appendChild(e);
@@ -27636,82 +27607,82 @@ function SD(e, { spinner: t = !0, icon: n = null, duration: r = 0 } = {}) {
27636
27607
  e.className = `${Q}-spin`, i.appendChild(e);
27637
27608
  }
27638
27609
  let a = document.createElement("span");
27639
- a.textContent = e, i.appendChild(a), i.classList.remove(`${Q}-show`), i.offsetHeight, i.classList.add(`${Q}-show`), r > 0 && (bD = setTimeout(() => CD(), r));
27610
+ a.textContent = e, i.appendChild(a), i.classList.remove(`${Q}-show`), i.offsetHeight, i.classList.add(`${Q}-show`), r > 0 && (hD = setTimeout(() => vD(), r));
27640
27611
  }
27641
- function CD(e = 0) {
27642
- yD && (e > 0 ? bD = setTimeout(() => {
27643
- yD && yD.classList.remove(`${Q}-show`);
27644
- }, e) : yD && yD.classList.remove(`${Q}-show`));
27612
+ function vD(e = 0) {
27613
+ mD && (e > 0 ? hD = setTimeout(() => {
27614
+ mD && mD.classList.remove(`${Q}-show`);
27615
+ }, e) : mD && mD.classList.remove(`${Q}-show`));
27645
27616
  }
27646
- var wD = null, TD = [];
27647
- function ED() {
27648
- return (!wD || !wD.isConnected) && (wD = document.createElement("div"), wD.id = `${Q}-bar`, document.body.appendChild(wD)), wD;
27617
+ var yD = null, bD = [];
27618
+ function xD() {
27619
+ return (!yD || !yD.isConnected) && (yD = document.createElement("div"), yD.id = `${Q}-bar`, document.body.appendChild(yD)), yD;
27649
27620
  }
27650
- function DD() {
27621
+ function SD() {
27651
27622
  if (typeof document > "u") return;
27652
- vD(), TD.forEach(clearTimeout), TD = [];
27653
- let e = ED();
27623
+ pD(), bD.forEach(clearTimeout), bD = [];
27624
+ let e = xD();
27654
27625
  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";
27655
27626
  let t = [[80, "width 0.6s ease"], [92, "width 1.2s ease"]], n = 50;
27656
27627
  for (let [e, r] of t) {
27657
27628
  let t = n, i = e, a = r;
27658
- TD.push(setTimeout(() => {
27659
- wD && (wD.style.transition = a, wD.style.width = `${i}%`);
27629
+ bD.push(setTimeout(() => {
27630
+ yD && (yD.style.transition = a, yD.style.width = `${i}%`);
27660
27631
  }, t)), n += 800;
27661
27632
  }
27662
27633
  }
27663
- function OD() {
27664
- wD && (TD.forEach(clearTimeout), TD = [], wD.style.transition = "width 0.2s ease", wD.style.width = "100%", TD.push(setTimeout(() => {
27665
- wD && (wD.style.transition = "opacity 0.35s ease", wD.style.opacity = "0", TD.push(setTimeout(() => {
27666
- wD && (wD.style.width = "0%", wD.classList.remove(`${Q}-bar-active`));
27634
+ function CD() {
27635
+ yD && (bD.forEach(clearTimeout), bD = [], yD.style.transition = "width 0.2s ease", yD.style.width = "100%", bD.push(setTimeout(() => {
27636
+ yD && (yD.style.transition = "opacity 0.35s ease", yD.style.opacity = "0", bD.push(setTimeout(() => {
27637
+ yD && (yD.style.width = "0%", yD.classList.remove(`${Q}-bar-active`));
27667
27638
  }, 380)));
27668
27639
  }, 220)));
27669
27640
  }
27670
- function kD() {
27641
+ function wD() {
27671
27642
  typeof document > "u" || document.querySelectorAll(`.${Q}-field-active, .${Q}-field-filled`).forEach((e) => e.classList.remove(`${Q}-field-active`, `${Q}-field-filled`));
27672
27643
  }
27673
- function AD(e) {
27674
- !e || typeof document > "u" || (vD(), kD(), e.classList.add(`${Q}-field-active`));
27644
+ function TD(e) {
27645
+ !e || typeof document > "u" || (pD(), wD(), e.classList.add(`${Q}-field-active`));
27675
27646
  }
27676
- function jD(e) {
27647
+ function ED(e) {
27677
27648
  e && (e.classList.remove(`${Q}-field-active`), e.classList.add(`${Q}-field-filled`), setTimeout(() => {
27678
27649
  e.isConnected && e.classList.remove(`${Q}-field-filled`);
27679
27650
  }, 1400));
27680
27651
  }
27681
- var MD = `<svg xmlns="http://www.w3.org/2000/svg" width="22" height="22" viewBox="0 0 22 22" fill="none">
27652
+ var DD = `<svg xmlns="http://www.w3.org/2000/svg" width="22" height="22" viewBox="0 0 22 22" fill="none">
27682
27653
  <filter id="${Q}-csh">
27683
27654
  <feDropShadow dx="1" dy="2" stdDeviation="1.5" flood-color="#00000060"/>
27684
27655
  </filter>
27685
27656
  <path d="M4 2L19 10.5L11 12.8L8 20L4 2Z"
27686
27657
  fill="white" stroke="#1e1b4b" stroke-width="1.6" stroke-linejoin="round"
27687
27658
  filter="url(#${Q}-csh)"/>
27688
- </svg>`, ND = null, PD = !1;
27689
- function FD() {
27690
- return (!ND || !ND.isConnected) && (ND = document.createElement("div"), ND.id = `${Q}-cursor`, ND.innerHTML = MD, document.body.appendChild(ND), PD = !1), ND;
27659
+ </svg>`, OD = null, kD = !1;
27660
+ function AD() {
27661
+ return (!OD || !OD.isConnected) && (OD = document.createElement("div"), OD.id = `${Q}-cursor`, OD.innerHTML = DD, document.body.appendChild(OD), kD = !1), OD;
27691
27662
  }
27692
- async function ID(e) {
27663
+ async function jD(e) {
27693
27664
  if (typeof document > "u" || !e) return;
27694
- vD();
27665
+ pD();
27695
27666
  let t;
27696
27667
  try {
27697
27668
  t = e.getBoundingClientRect();
27698
27669
  } catch {
27699
27670
  return;
27700
27671
  }
27701
- let n = t.left + Math.min(16, t.width * .2), r = t.top + Math.min(12, t.height * .25), i = FD();
27702
- PD ||= (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 BD(360);
27672
+ let n = t.left + Math.min(16, t.width * .2), r = t.top + Math.min(12, t.height * .25), i = AD();
27673
+ kD ||= (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 FD(360);
27703
27674
  }
27704
- function LD(e = !1) {
27705
- ND && (e ? (ND.classList.remove(`${Q}-cursor-visible`), PD = !1) : (ND.classList.remove(`${Q}-cursor-visible`), setTimeout(() => {
27706
- PD = !1;
27675
+ function MD(e = !1) {
27676
+ OD && (e ? (OD.classList.remove(`${Q}-cursor-visible`), kD = !1) : (OD.classList.remove(`${Q}-cursor-visible`), setTimeout(() => {
27677
+ kD = !1;
27707
27678
  }, 250)));
27708
27679
  }
27709
- async function RD(e) {
27710
- ND && (ND.classList.add(`${Q}-cursor-click`), await BD(280), ND.classList.remove(`${Q}-cursor-click`));
27680
+ async function ND(e) {
27681
+ OD && (OD.classList.add(`${Q}-cursor-click`), await FD(280), OD.classList.remove(`${Q}-cursor-click`));
27711
27682
  }
27712
- function zD(e) {
27683
+ function PD(e) {
27713
27684
  if (!e || typeof document > "u") return;
27714
- vD();
27685
+ pD();
27715
27686
  let t;
27716
27687
  try {
27717
27688
  t = e.getBoundingClientRect();
@@ -27737,7 +27708,7 @@ function zD(e) {
27737
27708
  a.remove(), e.style.position = n, e.style.overflow = r;
27738
27709
  }, 650);
27739
27710
  }
27740
- function BD(e) {
27711
+ function FD(e) {
27741
27712
  return new Promise((t) => setTimeout(t, e));
27742
27713
  }
27743
27714
  //#endregion
@@ -27745,42 +27716,42 @@ function BD(e) {
27745
27716
  function $(...e) {
27746
27717
  mn() && console.log("[FlowEngage:voice-tools]", ...e);
27747
27718
  }
27748
- function VD(e) {
27719
+ function ID(e) {
27749
27720
  return new Promise((t) => setTimeout(t, e));
27750
27721
  }
27751
- var HD = "#flowengage-root, .flowengage-shell, .flowengage-widget-root";
27752
- function UD(e) {
27722
+ var LD = "#flowengage-root, .flowengage-shell, .flowengage-widget-root";
27723
+ function RD(e) {
27753
27724
  if (!e || typeof e.closest != "function") return !1;
27754
27725
  try {
27755
- return !!e.closest(HD);
27726
+ return !!e.closest(LD);
27756
27727
  } catch {
27757
27728
  return !1;
27758
27729
  }
27759
27730
  }
27760
- function WD(e) {
27731
+ function zD(e) {
27761
27732
  try {
27762
27733
  let t = e.ownerDocument?.defaultView;
27763
27734
  if (t) return t.getComputedStyle(e);
27764
27735
  } catch {}
27765
27736
  return window.getComputedStyle(e);
27766
27737
  }
27767
- function GD(e) {
27738
+ function BD(e) {
27768
27739
  let t = /* @__PURE__ */ new Set();
27769
27740
  function n(r) {
27770
27741
  if (!r || t.has(r)) return;
27771
27742
  t.add(r), e(r);
27772
27743
  let i = r.querySelectorAll("iframe");
27773
- for (let e of i) if (!UD(e)) try {
27744
+ for (let e of i) if (!RD(e)) try {
27774
27745
  let t = e.contentDocument;
27775
27746
  t && n(t);
27776
27747
  } catch {}
27777
27748
  }
27778
27749
  typeof document < "u" && n(document);
27779
27750
  }
27780
- function KD(e) {
27751
+ function VD(e) {
27781
27752
  return e == null ? null : String(e).replace(/\u00a0/g, " ").replace(/\s*\*+\s*$/u, "").replace(/\s+/g, " ").trim();
27782
27753
  }
27783
- function qD(e) {
27754
+ function HD(e) {
27784
27755
  let t = e.ownerDocument || document, n = e.getAttribute("aria-labelledby");
27785
27756
  if (n) {
27786
27757
  let e = n.trim().split(/\s+/).filter(Boolean), r = [];
@@ -27788,42 +27759,42 @@ function qD(e) {
27788
27759
  let e = t.getElementById(n);
27789
27760
  e?.textContent && r.push(e.textContent.trim());
27790
27761
  } catch {}
27791
- if (r.length) return KD(r.join(" "));
27762
+ if (r.length) return VD(r.join(" "));
27792
27763
  }
27793
- if (e.labels && e.labels.length) return KD(e.labels[0].textContent);
27764
+ if (e.labels && e.labels.length) return VD(e.labels[0].textContent);
27794
27765
  let r = e.id;
27795
27766
  if (r) try {
27796
27767
  let e = t.querySelector(`label[for="${CSS.escape(r)}"]`);
27797
- if (e) return KD(e.textContent);
27768
+ if (e) return VD(e.textContent);
27798
27769
  } catch {
27799
27770
  let e = t.querySelector(`label[for="${r.replace(/"/g, "\\\"")}"]`);
27800
- if (e) return KD(e.textContent);
27771
+ if (e) return VD(e.textContent);
27801
27772
  }
27802
27773
  let i = e.previousElementSibling;
27803
27774
  for (let e = 0; e < 6 && i; e += 1) {
27804
- if (i.tagName === "LABEL") return KD(i.textContent);
27775
+ if (i.tagName === "LABEL") return VD(i.textContent);
27805
27776
  let e = (i.className || "").toString().toLowerCase();
27806
27777
  if (/chakra-form__label|formlabel|field-label|form-label|mui-form-label/.test(e)) {
27807
- let e = KD(i.textContent);
27778
+ let e = VD(i.textContent);
27808
27779
  if (e) return e;
27809
27780
  }
27810
27781
  i = i.previousElementSibling;
27811
27782
  }
27812
27783
  let a = e.parentElement;
27813
27784
  for (let e = 0; e < 5 && a; e += 1) {
27814
- if (a.tagName === "LABEL") return KD(a.textContent);
27785
+ if (a.tagName === "LABEL") return VD(a.textContent);
27815
27786
  let e = a.querySelector?.(":scope > label, :scope > [class*='FormLabel'], :scope > [class*='form__label']");
27816
- if (e?.textContent) return KD(e.textContent);
27787
+ if (e?.textContent) return VD(e.textContent);
27817
27788
  a = a.parentElement;
27818
27789
  }
27819
27790
  let o = e.getAttribute("aria-label");
27820
- return o ? KD(o) : null;
27791
+ return o ? VD(o) : null;
27821
27792
  }
27822
- function JD() {
27793
+ function UD() {
27823
27794
  let e = [];
27824
- return GD((t) => {
27795
+ return BD((t) => {
27825
27796
  e.push(...Array.from(t.querySelectorAll("input, select, textarea")).filter((e) => {
27826
- if (UD(e)) return !1;
27797
+ if (RD(e)) return !1;
27827
27798
  let t = (e.type || "").toLowerCase();
27828
27799
  if ([
27829
27800
  "hidden",
@@ -27832,32 +27803,32 @@ function JD() {
27832
27803
  "image"
27833
27804
  ].includes(t) || e.disabled || e.readOnly) return !1;
27834
27805
  try {
27835
- let t = WD(e);
27806
+ let t = zD(e);
27836
27807
  if (t.display === "none" || t.visibility === "hidden") return !1;
27837
27808
  } catch {}
27838
27809
  return !0;
27839
27810
  }));
27840
27811
  }), e;
27841
27812
  }
27842
- function YD() {
27843
- return JD().map((e, t) => ({
27813
+ function WD() {
27814
+ return UD().map((e, t) => ({
27844
27815
  formIndex: 0,
27845
27816
  fieldIndex: t,
27846
27817
  tag: e.tagName,
27847
27818
  type: e.type || "text",
27848
27819
  name: e.name || null,
27849
27820
  id: e.id || null,
27850
- label: qD(e),
27821
+ label: HD(e),
27851
27822
  placeholder: e.placeholder || null
27852
27823
  }));
27853
27824
  }
27854
- function XD() {
27825
+ function GD() {
27855
27826
  let e = [];
27856
- return GD((t) => {
27827
+ return BD((t) => {
27857
27828
  e.push(...Array.from(t.querySelectorAll("button, [role=\"button\"], input[type=\"submit\"], input[type=\"button\"]")).filter((e) => {
27858
- if (UD(e) || e.disabled) return !1;
27829
+ if (RD(e) || e.disabled) return !1;
27859
27830
  try {
27860
- let t = WD(e);
27831
+ let t = zD(e);
27861
27832
  if (t.display === "none" || t.visibility === "hidden") return !1;
27862
27833
  } catch {}
27863
27834
  return !0;
@@ -27869,15 +27840,15 @@ function XD() {
27869
27840
  type: e.type || e.tagName
27870
27841
  }));
27871
27842
  }
27872
- function ZD(e) {
27843
+ function KD(e) {
27873
27844
  return String(e || "").toLowerCase().replace(/\u00a0/g, " ").replace(/\*/g, "").replace(/\s+/g, " ").trim();
27874
27845
  }
27875
- function QD(e) {
27876
- let t = ZD(e);
27846
+ function qD(e) {
27847
+ let t = KD(e);
27877
27848
  return t = t.replace(/\s+field\s*$/i, "").trim(), t;
27878
27849
  }
27879
- function $D(e, t) {
27880
- let n = QD(t);
27850
+ function JD(e, t) {
27851
+ let n = qD(t);
27881
27852
  if (!n) return 0;
27882
27853
  let r = (e.name || "").toLowerCase(), i = (e.id || "").toLowerCase();
27883
27854
  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;
@@ -27885,12 +27856,12 @@ function $D(e, t) {
27885
27856
  e.name,
27886
27857
  e.id,
27887
27858
  e.placeholder,
27888
- qD(e),
27859
+ HD(e),
27889
27860
  e.getAttribute("aria-label"),
27890
27861
  e.getAttribute("title"),
27891
27862
  e.getAttribute("data-testid"),
27892
27863
  e.getAttribute("autocomplete")
27893
- ].filter(Boolean).map((e) => ZD(e)), o = 0;
27864
+ ].filter(Boolean).map((e) => KD(e)), o = 0;
27894
27865
  for (let e of a) {
27895
27866
  if (!e) continue;
27896
27867
  if (e.includes(n) || n.includes(e)) {
@@ -27905,16 +27876,16 @@ function $D(e, t) {
27905
27876
  }
27906
27877
  return o;
27907
27878
  }
27908
- var eO = 28;
27909
- function tO(e, t) {
27879
+ var YD = 28;
27880
+ function XD(e, t) {
27910
27881
  let n = null, r = 0;
27911
27882
  for (let i of e) {
27912
- let e = $D(i, t);
27883
+ let e = JD(i, t);
27913
27884
  e > r && (r = e, n = i);
27914
27885
  }
27915
- return !n || r < eO ? null : n;
27886
+ return !n || r < YD ? null : n;
27916
27887
  }
27917
- function nO(e, t, n) {
27888
+ function ZD(e, t, n) {
27918
27889
  let r = String(t || "").toLowerCase().trim(), i = String(n || "").trim();
27919
27890
  if (!(/^https?:\/\//i.test(i) || /\.\w{2,}(\/|\s|$)/.test(i) || r.includes("url") || r.includes("website") || r.includes("domain") || r.includes("site"))) return null;
27920
27891
  let a = null, o = 0;
@@ -27934,7 +27905,7 @@ function nO(e, t, n) {
27934
27905
  t.name,
27935
27906
  t.id,
27936
27907
  t.placeholder,
27937
- qD(t),
27908
+ HD(t),
27938
27909
  t.getAttribute("aria-label"),
27939
27910
  t.getAttribute("autocomplete")
27940
27911
  ].filter(Boolean).join(" ").toLowerCase();
@@ -27942,15 +27913,15 @@ function nO(e, t, n) {
27942
27913
  }
27943
27914
  return !a || o < 42 ? null : a;
27944
27915
  }
27945
- function rO(e) {
27916
+ function QD(e) {
27946
27917
  let t = String(e ?? "").trim();
27947
27918
  return t ? /^https?:\/\//i.test(t) ? !0 : /\.\w{2,}(\/|\s|$)/.test(t) : !1;
27948
27919
  }
27949
- function iO(e) {
27920
+ function $D(e) {
27950
27921
  let t = String(e ?? "").toLowerCase().trim();
27951
27922
  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;
27952
27923
  }
27953
- function aO(e) {
27924
+ function eO(e) {
27954
27925
  if (!e || e.tagName !== "INPUT" && e.tagName !== "TEXTAREA") return !1;
27955
27926
  let t = (e.type || "").toLowerCase();
27956
27927
  return ![
@@ -27962,22 +27933,22 @@ function aO(e) {
27962
27933
  "file"
27963
27934
  ].includes(t);
27964
27935
  }
27965
- function oO(e) {
27966
- if (!aO(e)) return !1;
27936
+ function tO(e) {
27937
+ if (!eO(e)) return !1;
27967
27938
  let t = (e.name || "").toLowerCase(), n = (e.id || "").toLowerCase(), r = [
27968
27939
  e.name,
27969
27940
  e.id,
27970
27941
  e.placeholder,
27971
- qD(e),
27942
+ HD(e),
27972
27943
  e.getAttribute("aria-label")
27973
27944
  ].filter(Boolean).join(" ").toLowerCase();
27974
27945
  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);
27975
27946
  }
27976
- function sO(e, t, n) {
27977
- let r = String(t ?? ""), i = String(n ?? ""), a = uO(e, r) || tO(e, r) || nO(e, r, i);
27947
+ function nO(e, t, n) {
27948
+ let r = String(t ?? ""), i = String(n ?? ""), a = aO(e, r) || XD(e, r) || ZD(e, r, i);
27978
27949
  if (!a) return [];
27979
27950
  let o = new Set([a]);
27980
- if (rO(i) && iO(r)) for (let t of e) t !== a && oO(t) && o.add(t);
27951
+ if (QD(i) && $D(r)) for (let t of e) t !== a && tO(t) && o.add(t);
27981
27952
  let s = Array.from(o);
27982
27953
  return s.sort((e, t) => {
27983
27954
  if (e === t) return 0;
@@ -27985,7 +27956,7 @@ function sO(e, t, n) {
27985
27956
  return n & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : n & Node.DOCUMENT_POSITION_PRECEDING ? 1 : 0;
27986
27957
  }), s;
27987
27958
  }
27988
- function cO(e, t) {
27959
+ function rO(e, t) {
27989
27960
  try {
27990
27961
  if (!e?.getBoundingClientRect || !t?.getBoundingClientRect) return Infinity;
27991
27962
  let n = e.getBoundingClientRect(), r = t.getBoundingClientRect(), i = {
@@ -28000,17 +27971,17 @@ function cO(e, t) {
28000
27971
  return Infinity;
28001
27972
  }
28002
27973
  }
28003
- function lO(e) {
27974
+ function iO(e) {
28004
27975
  if (!e || typeof e != "string") return null;
28005
27976
  let t = null;
28006
- return GD((n) => {
27977
+ return BD((n) => {
28007
27978
  try {
28008
27979
  let r = n.getElementById(e);
28009
- r && !UD(r) && r.matches?.("input, select, textarea") && (t = r);
27980
+ r && !RD(r) && r.matches?.("input, select, textarea") && (t = r);
28010
27981
  } catch {}
28011
27982
  }), t;
28012
27983
  }
28013
- function uO(e, t) {
27984
+ function aO(e, t) {
28014
27985
  let n = String(t ?? "").trim();
28015
27986
  if (!n) return null;
28016
27987
  let r = n.match(/^name:\s*([\w.-]+)$/i);
@@ -28020,12 +27991,12 @@ function uO(e, t) {
28020
27991
  }
28021
27992
  let i = n.match(/^id:\s*([\w.-]+)$/i);
28022
27993
  if (i) {
28023
- let e = lO(i[1]);
27994
+ let e = iO(i[1]);
28024
27995
  if (e) return e;
28025
27996
  }
28026
27997
  let a = n.startsWith("#") ? n.slice(1) : n;
28027
27998
  if (/^[\w-]+$/.test(a)) {
28028
- let e = lO(a);
27999
+ let e = iO(a);
28029
28000
  if (e) return e;
28030
28001
  }
28031
28002
  let o = n.toLowerCase().replace(/\s+/g, " ");
@@ -28035,7 +28006,7 @@ function uO(e, t) {
28035
28006
  }
28036
28007
  return null;
28037
28008
  }
28038
- function dO(e, t) {
28009
+ function oO(e, t) {
28039
28010
  let n = String(t || "").toLowerCase().trim();
28040
28011
  if (!n) return 0;
28041
28012
  let r = [
@@ -28051,13 +28022,13 @@ function dO(e, t) {
28051
28022
  for (let e of i) r.includes(e) && (a += 1);
28052
28023
  return a / i.length * 92;
28053
28024
  }
28054
- function fO(e, t) {
28025
+ function sO(e, t) {
28055
28026
  let n = [];
28056
- GD((e) => {
28027
+ BD((e) => {
28057
28028
  n.push(...Array.from(e.querySelectorAll("button, [role=\"button\"], input[type=\"submit\"], input[type=\"button\"]")).filter((e) => {
28058
- if (UD(e) || e.disabled) return !1;
28029
+ if (RD(e) || e.disabled) return !1;
28059
28030
  try {
28060
- let t = WD(e);
28031
+ let t = zD(e);
28061
28032
  if (t.display === "none" || t.visibility === "hidden") return !1;
28062
28033
  } catch {}
28063
28034
  return !0;
@@ -28065,7 +28036,7 @@ function fO(e, t) {
28065
28036
  });
28066
28037
  let r = 0, i = n.map((t) => ({
28067
28038
  el: t,
28068
- s: dO(t, e)
28039
+ s: oO(t, e)
28069
28040
  }));
28070
28041
  for (let { s: e } of i) e > r && (r = e);
28071
28042
  if (r < 36) return null;
@@ -28075,14 +28046,14 @@ function fO(e, t) {
28075
28046
  if (o.length) {
28076
28047
  let e = a[0], t = Infinity;
28077
28048
  for (let n of a) for (let r of o) {
28078
- let i = cO(n, r);
28049
+ let i = rO(n, r);
28079
28050
  i < t && (t = i, e = n);
28080
28051
  }
28081
28052
  return e;
28082
28053
  }
28083
28054
  return a[0];
28084
28055
  }
28085
- function pO(e) {
28056
+ function cO(e) {
28086
28057
  if (e == null) return {};
28087
28058
  if (typeof e == "string") {
28088
28059
  let t = e.trim();
@@ -28095,8 +28066,8 @@ function pO(e) {
28095
28066
  }
28096
28067
  return e;
28097
28068
  }
28098
- function mO(e) {
28099
- let t = pO(e);
28069
+ function lO(e) {
28070
+ let t = cO(e);
28100
28071
  if (Array.isArray(t) && t.length > 0) {
28101
28072
  let e = t[0];
28102
28073
  if (e?.field_key != null || e?.fieldKey != null) return t.map((e) => ({
@@ -28124,7 +28095,7 @@ function mO(e) {
28124
28095
  value: e?.value ?? e?.Value
28125
28096
  })) : [];
28126
28097
  }
28127
- function hO(e) {
28098
+ function uO(e) {
28128
28099
  if (!e || typeof e != "string") return [];
28129
28100
  let t = e.trim();
28130
28101
  if (!t || /\b[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,}\b/i.test(t)) return [];
@@ -28143,7 +28114,7 @@ function hO(e) {
28143
28114
  }
28144
28115
  return [];
28145
28116
  }
28146
- function gO(e) {
28117
+ function dO(e) {
28147
28118
  if (!e || typeof e != "string") return [];
28148
28119
  let t = e.trim();
28149
28120
  if (!t) return [];
@@ -28179,17 +28150,17 @@ function gO(e) {
28179
28150
  }
28180
28151
  return n;
28181
28152
  }
28182
- function _O(e) {
28153
+ function fO(e) {
28183
28154
  if (!e || typeof e != "object") return null;
28184
28155
  let t = e.url ?? e.target_url ?? e.page_url ?? e.pageUrl ?? e.link ?? e.href ?? e.path;
28185
28156
  return t == null ? null : String(t).trim() || null;
28186
28157
  }
28187
- function vO(e) {
28158
+ function pO(e) {
28188
28159
  if (!e || typeof e != "object") return null;
28189
28160
  let t = e.query ?? e.q ?? e.search ?? e.text ?? e.keywords;
28190
28161
  return t == null ? null : String(t).trim() || null;
28191
28162
  }
28192
- function yO(e, t, n) {
28163
+ function mO(e, t, n) {
28193
28164
  if (!n?.skipScroll) try {
28194
28165
  e.scrollIntoView({
28195
28166
  block: "center",
@@ -28244,7 +28215,7 @@ function yO(e, t, n) {
28244
28215
  } catch {}
28245
28216
  return !0;
28246
28217
  }
28247
- function bO() {
28218
+ function hO() {
28248
28219
  let e = {};
28249
28220
  document.querySelectorAll("h1, h2, h3, h4, h5, h6").forEach((t) => {
28250
28221
  if (t.id) return;
@@ -28259,11 +28230,11 @@ function bO() {
28259
28230
  e[r] = !0, t.id = r;
28260
28231
  });
28261
28232
  }
28262
- function xO(e) {
28233
+ function gO(e) {
28263
28234
  let t = e.siteId || null, n = (e.apiBaseUrl || "").replace(/\/$/, ""), r = typeof e.getLastUserVoiceText == "function" ? e.getLastUserVoiceText : null, i = [], a = {
28264
28235
  flowengage_navigate: async (n) => {
28265
28236
  $("flowengage_navigate ▶ raw parameters:", n);
28266
- let r = pO(n), i = _O(r), a = r.section_text ?? r.sectionText ?? r.section;
28237
+ let r = cO(n), i = fO(r), a = r.section_text ?? r.sectionText ?? r.section;
28267
28238
  if ($("flowengage_navigate · coerced:", {
28268
28239
  url: i,
28269
28240
  sectionText: a
@@ -28279,41 +28250,41 @@ function xO(e) {
28279
28250
  return $("flowengage_navigate ✖ blocked", e), e;
28280
28251
  }
28281
28252
  try {
28282
- if (SD(`Navigating to ${i}...`, { spinner: !0 }), DD(), uD(), _D(), $("flowengage_navigate → shadowNavigate", i), await In(i, {
28253
+ if (_D(`Navigating to ${i}...`, { spinner: !0 }), SD(), aD(), fD(), $("flowengage_navigate → shadowNavigate", i), await In(i, {
28283
28254
  sectionText: typeof a == "string" ? a : void 0,
28284
28255
  voiceActive: !0
28285
- }), await VD(400), bO(), a && typeof a == "string") {
28256
+ }), await ID(400), hO(), a && typeof a == "string") {
28286
28257
  let e = Tn(null, a);
28287
- e && sD(() => gD(e)), $("flowengage_navigate · highlight", {
28258
+ e && dD(e), $("flowengage_navigate · highlight", {
28288
28259
  sectionText: a,
28289
28260
  found: !!e
28290
28261
  });
28291
28262
  }
28292
28263
  let e = `OK_NAVIGATION ${i}`;
28293
- return $("flowengage_navigate ✓", e), SD("Navigation complete", {
28264
+ return $("flowengage_navigate ✓", e), _D("Navigation complete", {
28294
28265
  spinner: !1,
28295
28266
  icon: "✅",
28296
28267
  duration: 1200
28297
28268
  }), e;
28298
28269
  } catch (e) {
28299
28270
  let t = `Navigation error: ${e?.message || String(e)}`;
28300
- return $("flowengage_navigate ✖", t), SD("Navigation failed", {
28271
+ return $("flowengage_navigate ✖", t), _D("Navigation failed", {
28301
28272
  spinner: !1,
28302
28273
  icon: "⚠️",
28303
28274
  duration: 1800
28304
28275
  }), t;
28305
28276
  } finally {
28306
- OD(), CD(900);
28277
+ CD(), vD(900);
28307
28278
  }
28308
28279
  },
28309
28280
  flowengage_highlight: async (e) => {
28310
28281
  $("flowengage_highlight ▶", e);
28311
- let t = pO(e), n = t?.section_id || t?.sectionId, r = t?.section_text || t?.sectionText, i = Tn(n || null, r || null);
28312
- return i ? (sD(() => gD(i)), $("flowengage_highlight ✓ (enqueued)"), "Highlighted the section.") : ($("flowengage_highlight ✖ no element"), "Could not find that section on the page.");
28282
+ let t = cO(e), n = t?.section_id || t?.sectionId, r = t?.section_text || t?.sectionText, i = Tn(n || null, r || null);
28283
+ return i ? (dD(i), $("flowengage_highlight ✓"), "Highlighted the section.") : ($("flowengage_highlight ✖ no element"), "Could not find that section on the page.");
28313
28284
  },
28314
28285
  flowengage_read_content: async (e) => {
28315
28286
  $("flowengage_read_content ▶", e);
28316
- let t = pO(e), n = t?.section_text || t?.sectionText || "";
28287
+ let t = cO(e), n = t?.section_text || t?.sectionText || "";
28317
28288
  try {
28318
28289
  let e = "";
28319
28290
  if (n) {
@@ -28336,7 +28307,7 @@ function xO(e) {
28336
28307
  },
28337
28308
  flowengage_search: async (e) => {
28338
28309
  $("flowengage_search ▶", e);
28339
- let r = vO(pO(e));
28310
+ let r = pO(cO(e));
28340
28311
  if ($("flowengage_search · query:", r, "siteId:", t, "apiBase:", n || "(empty)"), !r) return $("flowengage_search ✖ missing query"), "Missing query parameter.";
28341
28312
  if (!t) return $("flowengage_search ✖ no siteId"), "Site is not configured for search.";
28342
28313
  if (!n) return $("flowengage_search ✖ no api base"), "API base URL is missing; cannot search.";
@@ -28365,7 +28336,7 @@ function xO(e) {
28365
28336
  },
28366
28337
  flowengage_page_content: async (e) => {
28367
28338
  $("flowengage_page_content ▶", e);
28368
- let r = pO(e), i = r?.url || r?.page_url || "";
28339
+ let r = cO(e), i = r?.url || r?.page_url || "";
28369
28340
  if ($("flowengage_page_content · url:", i, "siteId:", t, "apiBase:", n || "(empty)"), !i) return $("flowengage_page_content ✖ missing url"), "Missing url parameter.";
28370
28341
  if (!t) return $("flowengage_page_content ✖ no siteId"), "Site is not configured.";
28371
28342
  if (!n) return $("flowengage_page_content ✖ no api base"), "API base URL is missing; cannot fetch page content.";
@@ -28397,7 +28368,7 @@ function xO(e) {
28397
28368
  },
28398
28369
  flowengage_end_session: async () => ($("flowengage_end_session ▶"), typeof e.requestEndSession == "function" && e.requestEndSession(), "Voice session is ending."),
28399
28370
  flowengage_list_forms: async () => {
28400
- let e = YD(), t = XD();
28371
+ let e = WD(), t = GD();
28401
28372
  return $("flowengage_list_forms ✓", `${e.length} field(s)`, `${t.length} button(s)`), JSON.stringify({
28402
28373
  fields: e,
28403
28374
  buttons: t,
@@ -28406,52 +28377,52 @@ function xO(e) {
28406
28377
  },
28407
28378
  flowengage_fill_form: async (e) => {
28408
28379
  try {
28409
- $("flowengage_fill_form ▶ raw:", e), kD();
28410
- let t = mO(e);
28380
+ $("flowengage_fill_form ▶ raw:", e), wD();
28381
+ let t = lO(e);
28411
28382
  if (!t.length && r) {
28412
- let e = r(), n = hO(e);
28413
- n.length ? $("flowengage_fill_form · inferred URL from last user utterance (model omitted usable fields):", n) : (n = gO(e), n.length && $("flowengage_fill_form · inferred contact fields from last user utterance (empty tool params):", n)), n.length && (t = n);
28383
+ let e = r(), n = uO(e);
28384
+ n.length ? $("flowengage_fill_form · inferred URL from last user utterance (model omitted usable fields):", n) : (n = dO(e), n.length && $("flowengage_fill_form · inferred contact fields from last user utterance (empty tool params):", n)), n.length && (t = n);
28414
28385
  }
28415
28386
  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.";
28416
28387
  let n = [];
28417
28388
  for (let e of t) {
28418
28389
  let t = e?.field_key ?? e?.fieldKey, r = e?.value;
28419
28390
  if (t == null || r == null) continue;
28420
- SD(`Filling ${String(t)}...`, { spinner: !0 });
28421
- let a = JD(), o = sO(a, String(t), r);
28391
+ _D(`Filling ${String(t)}...`, { spinner: !0 });
28392
+ let a = UD(), o = nO(a, String(t), r);
28422
28393
  if (o.length) {
28423
- for (let [e, t] of o.entries()) AD(t), await ID(t), yO(t, r, { skipScroll: e > 0 }), jD(t), await VD(120);
28394
+ for (let [e, t] of o.entries()) TD(t), await jD(t), mO(t, r, { skipScroll: e > 0 }), ED(t), await ID(120);
28424
28395
  i = o, n.push(String(t));
28425
28396
  continue;
28426
28397
  }
28427
- let s = uO(a, String(t));
28428
- s ||= tO(a, String(t)), s ||= nO(a, String(t), r), s && (AD(s), await ID(s), yO(s, r), jD(s), await VD(120), i = [s], n.push(String(t)));
28398
+ let s = aO(a, String(t));
28399
+ s ||= XD(a, String(t)), s ||= ZD(a, String(t), r), s && (TD(s), await jD(s), mO(s, r), ED(s), await ID(120), i = [s], n.push(String(t)));
28429
28400
  }
28430
28401
  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.";
28431
28402
  let a = `OK_FILLED: ${n.join(", ")}`;
28432
- return $("flowengage_fill_form ✓", a), SD("Form filled", {
28403
+ return $("flowengage_fill_form ✓", a), _D("Form filled", {
28433
28404
  spinner: !1,
28434
28405
  icon: "✅",
28435
28406
  duration: 1100
28436
28407
  }), a;
28437
28408
  } catch (e) {
28438
28409
  let t = `flowengage_fill_form error: ${e?.message || String(e)}`;
28439
- return $("flowengage_fill_form ✖", t), SD("Failed to fill form", {
28410
+ return $("flowengage_fill_form ✖", t), _D("Failed to fill form", {
28440
28411
  spinner: !1,
28441
28412
  icon: "⚠️",
28442
28413
  duration: 1800
28443
28414
  }), t;
28444
28415
  } finally {
28445
- LD(), kD(), CD(700);
28416
+ MD(), wD(), vD(700);
28446
28417
  }
28447
28418
  },
28448
28419
  flowengage_click_button: async (e) => {
28449
- let t = pO(e), n = (t.button_text ?? t.buttonText ?? t.text ?? "").trim();
28420
+ let t = cO(e), n = (t.button_text ?? t.buttonText ?? t.text ?? "").trim();
28450
28421
  if ($("flowengage_click_button ▶", n), !n) return "Missing button_text: pass the visible label, e.g. Conduct Audit.";
28451
- let r = fO(n, i);
28422
+ let r = sO(n, i);
28452
28423
  if (!r) return $("flowengage_click_button ✖ no match"), `Could not find a button matching "${n}". Call flowengage_list_forms to see button texts.`;
28453
28424
  try {
28454
- SD(`Clicking ${n}...`, { spinner: !0 });
28425
+ _D(`Clicking ${n}...`, { spinner: !0 });
28455
28426
  try {
28456
28427
  r.scrollIntoView({
28457
28428
  block: "center",
@@ -28460,22 +28431,22 @@ function xO(e) {
28460
28431
  } catch {
28461
28432
  r.scrollIntoView(!0);
28462
28433
  }
28463
- await ID(r), r.focus?.(), await RD(r), zD(r), r.click();
28434
+ await jD(r), r.focus?.(), await ND(r), PD(r), r.click();
28464
28435
  let e = (r.textContent || r.value || r.getAttribute("aria-label") || "").trim().slice(0, 80) || "button", t = `OK_CLICK ${e}`;
28465
- return $("flowengage_click_button ✓", t), SD(`Clicked ${e}`, {
28436
+ return $("flowengage_click_button ✓", t), _D(`Clicked ${e}`, {
28466
28437
  spinner: !1,
28467
28438
  icon: "✅",
28468
28439
  duration: 1200
28469
28440
  }), t;
28470
28441
  } catch (e) {
28471
28442
  let t = `Click failed: ${e?.message || String(e)}`;
28472
- return $("flowengage_click_button ✖", t), SD("Click failed", {
28443
+ return $("flowengage_click_button ✖", t), _D("Click failed", {
28473
28444
  spinner: !1,
28474
28445
  icon: "⚠️",
28475
28446
  duration: 1800
28476
28447
  }), t;
28477
28448
  } finally {
28478
- LD(), CD(700);
28449
+ MD(), vD(700);
28479
28450
  }
28480
28451
  }
28481
28452
  };
@@ -28493,7 +28464,7 @@ function xO(e) {
28493
28464
  }
28494
28465
  //#endregion
28495
28466
  //#region src/utils/wrapVoiceToolsForLogging.js
28496
- function SO(e) {
28467
+ function _O(e) {
28497
28468
  return !e || typeof e != "object" ? e : Object.fromEntries(Object.entries(e).map(([e, t]) => [e, async (n) => {
28498
28469
  let r = mn();
28499
28470
  r ? console.log("[FlowEngage:voice-tool] ▶", e, n) : console.info(`[FlowEngage] voice tool » ${e}`);
@@ -28510,7 +28481,7 @@ function SO(e) {
28510
28481
  }
28511
28482
  //#endregion
28512
28483
  //#region src/components/FlowEngageWidget.jsx
28513
- var CO = {
28484
+ var vO = {
28514
28485
  blue: "#135bd8",
28515
28486
  red: "#ef334b",
28516
28487
  yellow: "#ffbd2e",
@@ -28518,7 +28489,7 @@ var CO = {
28518
28489
  highlight: "rgba(255,255,255,0.9)",
28519
28490
  green: "#10b981"
28520
28491
  };
28521
- function wO(e) {
28492
+ function yO(e) {
28522
28493
  if (!Array.isArray(e) || e.length < 2) return "linear-gradient(145deg, #dce8f022 0%, #e8dff522 45%, #f5e0e022 100%), #f7f8fa";
28523
28494
  let [t, n, r] = e;
28524
28495
  return e.length >= 3 && r ? [
@@ -28532,12 +28503,12 @@ function wO(e) {
28532
28503
  "#f7f8fa"
28533
28504
  ].join(", ");
28534
28505
  }
28535
- function TO(e) {
28506
+ function bO(e) {
28536
28507
  if (!e || typeof e != "string") return "#1a1a1a";
28537
28508
  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;
28538
28509
  return .2126 * o(r) + .7152 * o(i) + .0722 * o(a) > .179 ? "#1a1a1a" : "#ffffff";
28539
28510
  }
28540
- function EO({ logo: t, style: n }) {
28511
+ function xO({ logo: t, style: n }) {
28541
28512
  if (!t) return null;
28542
28513
  if (typeof t == "string") return /* @__PURE__ */ g("img", {
28543
28514
  src: t,
@@ -28562,7 +28533,7 @@ function EO({ logo: t, style: n }) {
28562
28533
  children: r
28563
28534
  }) : null;
28564
28535
  }
28565
- function DO({ title: e }) {
28536
+ function SO({ title: e }) {
28566
28537
  return /* @__PURE__ */ g("div", {
28567
28538
  style: {
28568
28539
  width: "100%",
@@ -28580,18 +28551,18 @@ function DO({ title: e }) {
28580
28551
  children: String(e || "FE").split(/\s+/).filter(Boolean).slice(0, 2).map((e) => e[0]?.toUpperCase() || "").join("") || "FE"
28581
28552
  });
28582
28553
  }
28583
- function OO(e, t) {
28554
+ function CO(e, t) {
28584
28555
  let n = (t || "").trim();
28585
28556
  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;
28586
28557
  }
28587
- function kO({ orbColors: e, ...t }) {
28558
+ function wO({ orbColors: e, ...t }) {
28588
28559
  return /* @__PURE__ */ g(rD, {
28589
28560
  colors: e,
28590
28561
  ...t
28591
28562
  });
28592
28563
  }
28593
- function AO({ copy: e, orbColors: t, primaryColor: n, onYes: r, onLater: i, isMobile: a }) {
28594
- let o = n || CO.green, s = TO(o), c = a ? 72 : 94, l = /* @__PURE__ */ _("div", {
28564
+ function TO({ copy: e, orbColors: t, primaryColor: n, onYes: r, onLater: i, isMobile: a }) {
28565
+ let o = n || vO.green, s = bO(o), c = a ? 72 : 94, l = /* @__PURE__ */ _("div", {
28595
28566
  style: {
28596
28567
  display: "flex",
28597
28568
  alignItems: "center",
@@ -28708,7 +28679,7 @@ function AO({ copy: e, orbColors: t, primaryColor: n, onYes: r, onLater: i, isMo
28708
28679
  delay: 0
28709
28680
  },
28710
28681
  style: { flexShrink: 0 },
28711
- children: /* @__PURE__ */ g(kO, {
28682
+ children: /* @__PURE__ */ g(wO, {
28712
28683
  size: c,
28713
28684
  orbColors: t
28714
28685
  })
@@ -28736,8 +28707,8 @@ function AO({ copy: e, orbColors: t, primaryColor: n, onYes: r, onLater: i, isMo
28736
28707
  children: l
28737
28708
  }) : l] });
28738
28709
  }
28739
- function jO({ copy: e, orbColors: t, primaryColor: n, onVoice: r, onText: i, onClose: a }) {
28740
- let o = n || CO.green, s = TO(o);
28710
+ function EO({ copy: e, orbColors: t, primaryColor: n, onVoice: r, onText: i, onClose: a }) {
28711
+ let o = n || vO.green, s = bO(o);
28741
28712
  return /* @__PURE__ */ _(Np.div, {
28742
28713
  initial: {
28743
28714
  scale: 50 / 300,
@@ -28801,7 +28772,7 @@ function jO({ copy: e, orbColors: t, primaryColor: n, onVoice: r, onText: i, onC
28801
28772
  children: /* @__PURE__ */ g("polyline", { points: "6 9 12 15 18 9" })
28802
28773
  })
28803
28774
  }),
28804
- /* @__PURE__ */ g(kO, {
28775
+ /* @__PURE__ */ g(wO, {
28805
28776
  size: 82,
28806
28777
  orbColors: t
28807
28778
  }),
@@ -28870,7 +28841,7 @@ function jO({ copy: e, orbColors: t, primaryColor: n, onVoice: r, onText: i, onC
28870
28841
  ]
28871
28842
  });
28872
28843
  }
28873
- function MO({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i, apiBaseUrl: a, historyRef: s, onMessageSync: l }) {
28844
+ function DO({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i, apiBaseUrl: a, historyRef: s, onMessageSync: l }) {
28874
28845
  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 = o((e = "minimized") => {
28875
28846
  ne.current = e, te.current = !0, queueMicrotask(() => {
28876
28847
  w.current || (w.current = !0, C.current?.());
@@ -28894,7 +28865,7 @@ function MO({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
28894
28865
  try {
28895
28866
  if ((await navigator.mediaDevices.getUserMedia({ audio: !0 })).getTracks().forEach((e) => e.stop()), e) return;
28896
28867
  s.current = [], S.current = "", w.current = !1, ee.current = !1, te.current = !1, ne.current = "minimized";
28897
- let t = SO(xO({
28868
+ let t = _O(gO({
28898
28869
  siteId: i || null,
28899
28870
  apiBaseUrl: a || null,
28900
28871
  getLastUserVoiceText: () => S.current,
@@ -28915,7 +28886,7 @@ function MO({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
28915
28886
  sender: n,
28916
28887
  message: r,
28917
28888
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
28918
- }], OO(n, r) && E("minimized"));
28889
+ }], CO(n, r) && E("minimized"));
28919
28890
  },
28920
28891
  onError: (t) => {
28921
28892
  if (!e && !te.current && !ee.current) {
@@ -29002,7 +28973,7 @@ function MO({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
29002
28973
  whiteSpace: "nowrap"
29003
28974
  },
29004
28975
  children: "Listening..."
29005
- }), /* @__PURE__ */ g(kO, {
28976
+ }), /* @__PURE__ */ g(wO, {
29006
28977
  size: 94,
29007
28978
  voiceState: u,
29008
28979
  isMuted: f,
@@ -29244,7 +29215,7 @@ function MO({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
29244
29215
  ]
29245
29216
  }) });
29246
29217
  }
29247
- function NO({ orbColors: e }) {
29218
+ function OO({ orbColors: e }) {
29248
29219
  return /* @__PURE__ */ g("div", {
29249
29220
  style: {
29250
29221
  flexShrink: 0,
@@ -29254,13 +29225,13 @@ function NO({ orbColors: e }) {
29254
29225
  alignItems: "center",
29255
29226
  justifyContent: "center"
29256
29227
  },
29257
- children: /* @__PURE__ */ g(kO, {
29228
+ children: /* @__PURE__ */ g(wO, {
29258
29229
  size: 36,
29259
29230
  orbColors: e
29260
29231
  })
29261
29232
  });
29262
29233
  }
29263
- var PO = () => /* @__PURE__ */ g("div", {
29234
+ var kO = () => /* @__PURE__ */ g("div", {
29264
29235
  style: {
29265
29236
  display: "flex",
29266
29237
  marginBottom: "12px",
@@ -29290,7 +29261,7 @@ var PO = () => /* @__PURE__ */ g("div", {
29290
29261
  } }, e))
29291
29262
  })
29292
29263
  });
29293
- function FO({ 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 }) {
29264
+ function AO({ 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 }) {
29294
29265
  let Oe = l.length > 0, ke = w || T || C, Ae = !!(he || ve), [je, Me] = m(!1), Ne = p(null);
29295
29266
  return c(() => {
29296
29267
  if (!je) return;
@@ -29392,7 +29363,7 @@ function FO({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
29392
29363
  justifyContent: "center",
29393
29364
  height: "40px"
29394
29365
  },
29395
- children: i ? /* @__PURE__ */ g(EO, {
29366
+ children: i ? /* @__PURE__ */ g(xO, {
29396
29367
  logo: i,
29397
29368
  style: {
29398
29369
  height: "34px",
@@ -29405,7 +29376,7 @@ function FO({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
29405
29376
  height: "40px",
29406
29377
  flexShrink: 0
29407
29378
  },
29408
- children: /* @__PURE__ */ g(DO, { title: e.chatTitle })
29379
+ children: /* @__PURE__ */ g(SO, { title: e.chatTitle })
29409
29380
  })
29410
29381
  }), /* @__PURE__ */ g("div", {
29411
29382
  style: {
@@ -29624,11 +29595,11 @@ function FO({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
29624
29595
  isAiTyping: u,
29625
29596
  isAgentTyping: d,
29626
29597
  setReplyContext: ue,
29627
- TypingDots: PO,
29598
+ TypingDots: kO,
29628
29599
  primaryColor: n,
29629
29600
  agentHeadshot: v,
29630
29601
  agentDisplayName: h || y,
29631
- botAvatarNode: /* @__PURE__ */ g(NO, { orbColors: t })
29602
+ botAvatarNode: /* @__PURE__ */ g(OO, { orbColors: t })
29632
29603
  }) : /* @__PURE__ */ _("div", {
29633
29604
  style: {
29634
29605
  flex: 1,
@@ -29641,7 +29612,7 @@ function FO({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
29641
29612
  padding: "28px 24px"
29642
29613
  },
29643
29614
  children: [
29644
- /* @__PURE__ */ g(kO, {
29615
+ /* @__PURE__ */ g(wO, {
29645
29616
  size: 94,
29646
29617
  orbColors: t
29647
29618
  }),
@@ -29749,7 +29720,7 @@ function FO({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
29749
29720
  ]
29750
29721
  });
29751
29722
  }
29752
- function IO() {
29723
+ function jO() {
29753
29724
  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();
29754
29725
  c(() => {
29755
29726
  try {
@@ -29762,7 +29733,7 @@ function IO() {
29762
29733
  }, Ce = {
29763
29734
  ...be.theme || {},
29764
29735
  ...xe.theme || {}
29765
- }, 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 = wO(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) => ({
29736
+ }, 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 = yO(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) => ({
29766
29737
  id: e.key || `qr-${t}`,
29767
29738
  label: e.label,
29768
29739
  message: e.label,
@@ -29943,7 +29914,7 @@ function IO() {
29943
29914
  ...yt
29944
29915
  },
29945
29916
  children: [
29946
- Ke === "entry_prompt" && /* @__PURE__ */ g(AO, {
29917
+ Ke === "entry_prompt" && /* @__PURE__ */ g(TO, {
29947
29918
  copy: Le,
29948
29919
  orbColors: we,
29949
29920
  primaryColor: Te,
@@ -29964,13 +29935,13 @@ function IO() {
29964
29935
  transformOrigin: "bottom right",
29965
29936
  display: "inline-block"
29966
29937
  },
29967
- children: /* @__PURE__ */ g(kO, {
29938
+ children: /* @__PURE__ */ g(wO, {
29968
29939
  size: 50,
29969
29940
  orbColors: we,
29970
29941
  onClick: xt
29971
29942
  })
29972
29943
  }),
29973
- Ke === "connection_modal" && /* @__PURE__ */ g(jO, {
29944
+ Ke === "connection_modal" && /* @__PURE__ */ g(EO, {
29974
29945
  copy: Le,
29975
29946
  orbColors: we,
29976
29947
  primaryColor: Te,
@@ -29978,7 +29949,7 @@ function IO() {
29978
29949
  onText: Ct,
29979
29950
  onClose: bt
29980
29951
  }),
29981
- Ke === "voice_mode" && /* @__PURE__ */ g(MO, {
29952
+ Ke === "voice_mode" && /* @__PURE__ */ g(DO, {
29982
29953
  orbColors: we,
29983
29954
  onEnterChat: Ct,
29984
29955
  onEndChat: wt,
@@ -29988,7 +29959,7 @@ function IO() {
29988
29959
  historyRef: ie,
29989
29960
  onMessageSync: ae
29990
29961
  }, "voice"),
29991
- Ke === "text_chat" && /* @__PURE__ */ g(FO, {
29962
+ Ke === "text_chat" && /* @__PURE__ */ g(AO, {
29992
29963
  copy: Le,
29993
29964
  orbColors: we,
29994
29965
  primaryColor: Te,
@@ -30046,4 +30017,4 @@ function IO() {
30046
30017
  });
30047
30018
  }
30048
30019
  //#endregion
30049
- export { rD as AnimatedOrb, Wn as FlowEngageProvider, IO as FlowEngageWidget, pn as useFlowEngage };
30020
+ export { rD as AnimatedOrb, Wn as FlowEngageProvider, jO as FlowEngageWidget, pn as useFlowEngage };