@flowengage/react-chatbot 1.1.2 → 1.1.4
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.
- package/dist/flowengage-embed.js +28 -6
- package/dist/flowengage-react-chatbot.cjs +35 -13
- package/dist/flowengage-react-chatbot.mjs +267 -152
- package/package.json +1 -1
|
@@ -1838,7 +1838,7 @@ function tn() {
|
|
|
1838
1838
|
var nn = () => {
|
|
1839
1839
|
if (typeof document > "u" || document.getElementById("fe-highlight-styles")) return;
|
|
1840
1840
|
let e = document.createElement("style");
|
|
1841
|
-
e.id = "fe-highlight-styles", e.textContent = "\n .fe-highlight-section {\n outline: 3px solid #7c3aed !important;\n box-shadow: 0 0 15px rgba(124, 58, 237, 0.6) !important;\n transition:
|
|
1841
|
+
e.id = "fe-highlight-styles", e.textContent = "\n .fe-highlight-section {\n outline: 3px solid #7c3aed !important;\n box-shadow: 0 0 15px rgba(124, 58, 237, 0.6) !important;\n transition: outline-color 0.3s ease, box-shadow 0.3s ease !important;\n border-radius: 8px !important;\n position: relative;\n }\n /* Smooth fade-in for the speaking highlight */\n .fe-highlight-section.fe-highlight-speaking {\n outline-color: #6366f1 !important;\n box-shadow: 0 0 20px rgba(99, 102, 241, 0.45), 0 0 4px rgba(99, 102, 241, 0.3) !important;\n animation: fe-hl-pulse 2s ease-in-out infinite !important;\n }\n @keyframes fe-hl-pulse {\n 0%, 100% { box-shadow: 0 0 15px rgba(99, 102, 241, 0.40), 0 0 4px rgba(99, 102, 241, 0.25); }\n 50% { box-shadow: 0 0 25px rgba(99, 102, 241, 0.55), 0 0 8px rgba(99, 102, 241, 0.35); }\n }\n /* Exit transition — the old highlight fades out */\n .fe-highlight-exiting {\n outline: 3px solid transparent !important;\n box-shadow: none !important;\n transition: outline-color 0.25s ease, box-shadow 0.25s ease !important;\n }\n ", document.head.appendChild(e);
|
|
1842
1842
|
};
|
|
1843
1843
|
function rn(e, t) {
|
|
1844
1844
|
if (typeof document > "u") return null;
|
|
@@ -1848,39 +1848,75 @@ function rn(e, t) {
|
|
|
1848
1848
|
t ||= e.replace(/[-_]+/g, " ").trim();
|
|
1849
1849
|
}
|
|
1850
1850
|
if (!t) return null;
|
|
1851
|
-
let n = t.toLowerCase().trim(), r = document.querySelectorAll("h1, h2, h3, h4, h5, h6, [data-section]");
|
|
1852
|
-
for (let e of r) if (e.textContent.toLowerCase().
|
|
1853
|
-
|
|
1854
|
-
|
|
1851
|
+
let n = t.toLowerCase().trim(), r = Array.from(document.querySelectorAll("h1, h2, h3, h4, h5, h6, [data-section]"));
|
|
1852
|
+
for (let e of r) if (e.textContent.replace(/\s+/g, " ").toLowerCase().trim() === n) return e;
|
|
1853
|
+
for (let e of r) {
|
|
1854
|
+
let t = e.textContent.replace(/\s+/g, " ").toLowerCase().trim();
|
|
1855
|
+
if (t.startsWith(n) || t.endsWith(n)) return e;
|
|
1856
|
+
}
|
|
1857
|
+
let i = [];
|
|
1858
|
+
for (let e of r) {
|
|
1859
|
+
let t = e.textContent.replace(/\s+/g, " ").toLowerCase().trim();
|
|
1860
|
+
t.includes(n) && i.push({
|
|
1861
|
+
el: e,
|
|
1862
|
+
len: t.length
|
|
1863
|
+
});
|
|
1864
|
+
}
|
|
1865
|
+
if (i.length) return i.sort((e, t) => e.len - t.len), i[0].el;
|
|
1866
|
+
for (let e of r) {
|
|
1867
|
+
let t = e.textContent.replace(/\s+/g, " ").toLowerCase().trim();
|
|
1868
|
+
if (t.length > 3 && n.includes(t)) return e;
|
|
1869
|
+
}
|
|
1870
|
+
let a = n.split(/\s+/).filter((e) => e.length > 2);
|
|
1871
|
+
if (a.length > 0) {
|
|
1855
1872
|
let e = null, t = 0;
|
|
1856
1873
|
for (let n of r) {
|
|
1857
|
-
let r = n.textContent.toLowerCase(),
|
|
1858
|
-
for (let e of
|
|
1859
|
-
let o =
|
|
1874
|
+
let r = n.textContent.replace(/\s+/g, " ").toLowerCase(), i = 0;
|
|
1875
|
+
for (let e of a) r.includes(e) && i++;
|
|
1876
|
+
let o = i / a.length;
|
|
1860
1877
|
o > t && o >= .6 && (t = o, e = n);
|
|
1861
1878
|
}
|
|
1862
1879
|
if (e) return e;
|
|
1863
1880
|
}
|
|
1864
|
-
let
|
|
1865
|
-
for (let e of
|
|
1866
|
-
let t = e.
|
|
1881
|
+
let o = document.querySelectorAll("section, article, .card, [class*='feature'], [class*='service']");
|
|
1882
|
+
for (let e of o) {
|
|
1883
|
+
let t = e.querySelector("h1, h2, h3, h4, h5, h6");
|
|
1884
|
+
if (t) {
|
|
1885
|
+
let r = t.textContent.replace(/\s+/g, " ").toLowerCase().trim();
|
|
1886
|
+
if (r.includes(n) || n.includes(r)) return e;
|
|
1887
|
+
}
|
|
1888
|
+
}
|
|
1889
|
+
let s = document.querySelectorAll("li, strong, blockquote, dt, a");
|
|
1890
|
+
for (let e of s) {
|
|
1891
|
+
let t = e.textContent.replace(/\s+/g, " ").toLowerCase().trim();
|
|
1867
1892
|
if (t.includes(n) && t.length < 500) return e.tagName === "STRONG" && e.parentElement?.tagName === "LI" ? e.parentElement : e;
|
|
1868
1893
|
}
|
|
1869
|
-
let
|
|
1870
|
-
for (let e of
|
|
1871
|
-
let t = e.textContent.toLowerCase();
|
|
1894
|
+
let c = document.querySelectorAll("p");
|
|
1895
|
+
for (let e of c) {
|
|
1896
|
+
let t = e.textContent.replace(/\s+/g, " ").toLowerCase().trim();
|
|
1872
1897
|
if (t.includes(n) && t.length < 800) return e;
|
|
1873
1898
|
}
|
|
1874
1899
|
return null;
|
|
1875
1900
|
}
|
|
1876
|
-
function an(e) {
|
|
1877
|
-
!e || typeof document > "u"
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1901
|
+
function an(e, { speaking: t = !1 } = {}) {
|
|
1902
|
+
if (!e || typeof document > "u") return;
|
|
1903
|
+
nn();
|
|
1904
|
+
let n = document.querySelectorAll(".fe-highlight-section");
|
|
1905
|
+
for (let t of n) t !== e && (t.classList.remove("fe-highlight-section", "fe-highlight-speaking"), t.classList.add("fe-highlight-exiting"), setTimeout(() => t.classList.remove("fe-highlight-exiting"), 300));
|
|
1906
|
+
e.classList.remove("fe-highlight-exiting"), e.classList.add("fe-highlight-section"), t ? e.classList.add("fe-highlight-speaking") : e.classList.remove("fe-highlight-speaking");
|
|
1907
|
+
try {
|
|
1908
|
+
e.scrollIntoView({
|
|
1909
|
+
behavior: "smooth",
|
|
1910
|
+
block: "center"
|
|
1911
|
+
});
|
|
1912
|
+
} catch {
|
|
1913
|
+
try {
|
|
1914
|
+
e.scrollIntoView(!0);
|
|
1915
|
+
} catch {}
|
|
1916
|
+
}
|
|
1881
1917
|
}
|
|
1882
1918
|
function on() {
|
|
1883
|
-
typeof document > "u" || document.querySelectorAll(".fe-highlight-section").forEach((e) => e.classList.remove("fe-highlight-section"));
|
|
1919
|
+
typeof document > "u" || document.querySelectorAll(".fe-highlight-section, .fe-highlight-exiting").forEach((e) => e.classList.remove("fe-highlight-section", "fe-highlight-speaking", "fe-highlight-exiting"));
|
|
1884
1920
|
}
|
|
1885
1921
|
function sn(e) {
|
|
1886
1922
|
if (typeof window > "u") return e;
|
|
@@ -22160,7 +22196,65 @@ function hg(e) {
|
|
|
22160
22196
|
return !1;
|
|
22161
22197
|
}
|
|
22162
22198
|
}
|
|
22163
|
-
|
|
22199
|
+
var gg = new Set([
|
|
22200
|
+
"SCRIPT",
|
|
22201
|
+
"STYLE",
|
|
22202
|
+
"NOSCRIPT",
|
|
22203
|
+
"SVG",
|
|
22204
|
+
"CANVAS",
|
|
22205
|
+
"VIDEO",
|
|
22206
|
+
"AUDIO",
|
|
22207
|
+
"IFRAME",
|
|
22208
|
+
"OBJECT",
|
|
22209
|
+
"EMBED",
|
|
22210
|
+
"NAV",
|
|
22211
|
+
"FOOTER"
|
|
22212
|
+
]);
|
|
22213
|
+
function _g(e, t = 3e3) {
|
|
22214
|
+
if (!e) return "";
|
|
22215
|
+
let n = [], r = 0;
|
|
22216
|
+
function i(e) {
|
|
22217
|
+
if (r >= t) return;
|
|
22218
|
+
if (e.nodeType === Node.TEXT_NODE) {
|
|
22219
|
+
let t = e.textContent.replace(/\s+/g, " ").trim();
|
|
22220
|
+
t && (n.push(t), r += t.length);
|
|
22221
|
+
return;
|
|
22222
|
+
}
|
|
22223
|
+
if (e.nodeType !== Node.ELEMENT_NODE || gg.has(e.tagName) || hg(e)) return;
|
|
22224
|
+
try {
|
|
22225
|
+
let t = xg(e);
|
|
22226
|
+
if (t.display === "none" || t.visibility === "hidden") return;
|
|
22227
|
+
} catch {}
|
|
22228
|
+
let a = /^(P|H[1-6]|DIV|SECTION|ARTICLE|LI|TR|BLOCKQUOTE|PRE|HEADER|DT|DD|FIGCAPTION)$/.test(e.tagName);
|
|
22229
|
+
a && n.length > 0 && n.push("\n");
|
|
22230
|
+
for (let n of e.childNodes) if (i(n), r >= t) break;
|
|
22231
|
+
a && n.push("\n");
|
|
22232
|
+
}
|
|
22233
|
+
i(e);
|
|
22234
|
+
let a = n.join(" ").replace(/[ \t]+/g, " ").replace(/\n /g, "\n").replace(/\n{3,}/g, "\n\n").trim();
|
|
22235
|
+
return a.length > t && (a = a.slice(0, t).replace(/\s\S*$/, "") + "…"), a;
|
|
22236
|
+
}
|
|
22237
|
+
function vg() {
|
|
22238
|
+
if (typeof document > "u") return null;
|
|
22239
|
+
for (let e of [
|
|
22240
|
+
"main",
|
|
22241
|
+
"article",
|
|
22242
|
+
"[role=\"main\"]",
|
|
22243
|
+
"#content",
|
|
22244
|
+
"#main-content",
|
|
22245
|
+
"#main",
|
|
22246
|
+
".main-content",
|
|
22247
|
+
".content",
|
|
22248
|
+
".post-content",
|
|
22249
|
+
".article-content",
|
|
22250
|
+
".entry-content"
|
|
22251
|
+
]) {
|
|
22252
|
+
let t = document.querySelector(e);
|
|
22253
|
+
if (t && !hg(t)) return t;
|
|
22254
|
+
}
|
|
22255
|
+
return document.body;
|
|
22256
|
+
}
|
|
22257
|
+
function yg(e) {
|
|
22164
22258
|
if (!e) return null;
|
|
22165
22259
|
try {
|
|
22166
22260
|
return e.closest("form");
|
|
@@ -22173,7 +22267,7 @@ function gg(e) {
|
|
|
22173
22267
|
return null;
|
|
22174
22268
|
}
|
|
22175
22269
|
}
|
|
22176
|
-
function
|
|
22270
|
+
function bg(e) {
|
|
22177
22271
|
if (!e) return null;
|
|
22178
22272
|
let t = e.querySelector("h1, h2, h3, h4, h5, legend");
|
|
22179
22273
|
if (t) return t.textContent.replace(/\s+/g, " ").trim().slice(0, 60);
|
|
@@ -22188,14 +22282,14 @@ function _g(e) {
|
|
|
22188
22282
|
}
|
|
22189
22283
|
return null;
|
|
22190
22284
|
}
|
|
22191
|
-
function
|
|
22285
|
+
function xg(e) {
|
|
22192
22286
|
try {
|
|
22193
22287
|
let t = e.ownerDocument?.defaultView;
|
|
22194
22288
|
if (t) return t.getComputedStyle(e);
|
|
22195
22289
|
} catch {}
|
|
22196
22290
|
return window.getComputedStyle(e);
|
|
22197
22291
|
}
|
|
22198
|
-
function
|
|
22292
|
+
function Sg(e) {
|
|
22199
22293
|
let t = /* @__PURE__ */ new Set();
|
|
22200
22294
|
function n(r) {
|
|
22201
22295
|
if (!r || t.has(r)) return;
|
|
@@ -22208,10 +22302,10 @@ function yg(e) {
|
|
|
22208
22302
|
}
|
|
22209
22303
|
typeof document < "u" && n(document);
|
|
22210
22304
|
}
|
|
22211
|
-
function
|
|
22305
|
+
function Cg(e) {
|
|
22212
22306
|
return e == null ? null : String(e).replace(/\u00a0/g, " ").replace(/\s*\*+\s*$/u, "").replace(/\s+/g, " ").trim();
|
|
22213
22307
|
}
|
|
22214
|
-
function
|
|
22308
|
+
function wg(e) {
|
|
22215
22309
|
let t = e.ownerDocument || document, n = e.getAttribute("aria-labelledby");
|
|
22216
22310
|
if (n) {
|
|
22217
22311
|
let e = n.trim().split(/\s+/).filter(Boolean), r = [];
|
|
@@ -22219,40 +22313,40 @@ function xg(e) {
|
|
|
22219
22313
|
let e = t.getElementById(n);
|
|
22220
22314
|
e?.textContent && r.push(e.textContent.trim());
|
|
22221
22315
|
} catch {}
|
|
22222
|
-
if (r.length) return
|
|
22316
|
+
if (r.length) return Cg(r.join(" "));
|
|
22223
22317
|
}
|
|
22224
|
-
if (e.labels && e.labels.length) return
|
|
22318
|
+
if (e.labels && e.labels.length) return Cg(e.labels[0].textContent);
|
|
22225
22319
|
let r = e.id;
|
|
22226
22320
|
if (r) try {
|
|
22227
22321
|
let e = t.querySelector(`label[for="${CSS.escape(r)}"]`);
|
|
22228
|
-
if (e) return
|
|
22322
|
+
if (e) return Cg(e.textContent);
|
|
22229
22323
|
} catch {
|
|
22230
22324
|
let e = t.querySelector(`label[for="${r.replace(/"/g, "\\\"")}"]`);
|
|
22231
|
-
if (e) return
|
|
22325
|
+
if (e) return Cg(e.textContent);
|
|
22232
22326
|
}
|
|
22233
22327
|
let i = e.previousElementSibling;
|
|
22234
22328
|
for (let e = 0; e < 6 && i; e += 1) {
|
|
22235
|
-
if (i.tagName === "LABEL") return
|
|
22329
|
+
if (i.tagName === "LABEL") return Cg(i.textContent);
|
|
22236
22330
|
let e = (i.className || "").toString().toLowerCase();
|
|
22237
22331
|
if (/chakra-form__label|formlabel|field-label|form-label|mui-form-label/.test(e)) {
|
|
22238
|
-
let e =
|
|
22332
|
+
let e = Cg(i.textContent);
|
|
22239
22333
|
if (e) return e;
|
|
22240
22334
|
}
|
|
22241
22335
|
i = i.previousElementSibling;
|
|
22242
22336
|
}
|
|
22243
22337
|
let a = e.parentElement;
|
|
22244
22338
|
for (let e = 0; e < 5 && a; e += 1) {
|
|
22245
|
-
if (a.tagName === "LABEL") return
|
|
22339
|
+
if (a.tagName === "LABEL") return Cg(a.textContent);
|
|
22246
22340
|
let e = a.querySelector?.(":scope > label, :scope > [class*='FormLabel'], :scope > [class*='form__label']");
|
|
22247
|
-
if (e?.textContent) return
|
|
22341
|
+
if (e?.textContent) return Cg(e.textContent);
|
|
22248
22342
|
a = a.parentElement;
|
|
22249
22343
|
}
|
|
22250
22344
|
let o = e.getAttribute("aria-label");
|
|
22251
|
-
return o ?
|
|
22345
|
+
return o ? Cg(o) : null;
|
|
22252
22346
|
}
|
|
22253
|
-
function
|
|
22347
|
+
function Tg() {
|
|
22254
22348
|
let e = [];
|
|
22255
|
-
return
|
|
22349
|
+
return Sg((t) => {
|
|
22256
22350
|
e.push(...Array.from(t.querySelectorAll("input, select, textarea")).filter((e) => {
|
|
22257
22351
|
if (hg(e)) return !1;
|
|
22258
22352
|
let t = (e.type || "").toLowerCase();
|
|
@@ -22263,7 +22357,7 @@ function Sg() {
|
|
|
22263
22357
|
"image"
|
|
22264
22358
|
].includes(t) || e.disabled || e.readOnly) return !1;
|
|
22265
22359
|
try {
|
|
22266
|
-
let t =
|
|
22360
|
+
let t = xg(e);
|
|
22267
22361
|
if (t.display === "none" || t.visibility === "hidden" || parseFloat(t.opacity) === 0) return !1;
|
|
22268
22362
|
} catch {}
|
|
22269
22363
|
try {
|
|
@@ -22273,7 +22367,7 @@ function Sg() {
|
|
|
22273
22367
|
}));
|
|
22274
22368
|
}), e;
|
|
22275
22369
|
}
|
|
22276
|
-
function
|
|
22370
|
+
function Eg(e) {
|
|
22277
22371
|
if (!e || typeof e.closest != "function") return !1;
|
|
22278
22372
|
try {
|
|
22279
22373
|
return !!e.closest("footer, [role=\"contentinfo\"], #footer, .site-footer, [class*=\"footer\"], [id*=\"footer\"]");
|
|
@@ -22281,44 +22375,49 @@ function Cg(e) {
|
|
|
22281
22375
|
return !1;
|
|
22282
22376
|
}
|
|
22283
22377
|
}
|
|
22284
|
-
function
|
|
22285
|
-
let e =
|
|
22378
|
+
function Dg() {
|
|
22379
|
+
let e = Tg();
|
|
22286
22380
|
for (let t of e) {
|
|
22287
|
-
if ((t.type || "").toLowerCase() !== "email" ||
|
|
22288
|
-
let e =
|
|
22381
|
+
if ((t.type || "").toLowerCase() !== "email" || Eg(t)) continue;
|
|
22382
|
+
let e = yg(t);
|
|
22289
22383
|
if (e) return e;
|
|
22290
22384
|
}
|
|
22291
22385
|
return null;
|
|
22292
22386
|
}
|
|
22293
|
-
function
|
|
22294
|
-
let e =
|
|
22387
|
+
function Og() {
|
|
22388
|
+
let e = Tg(), t = /* @__PURE__ */ new Map(), n = 0;
|
|
22295
22389
|
return e.map((e, r) => {
|
|
22296
|
-
let i =
|
|
22390
|
+
let i = yg(e), a = i || "__orphan__";
|
|
22297
22391
|
t.has(a) || t.set(a, n++);
|
|
22298
22392
|
let o = t.get(a);
|
|
22299
22393
|
return {
|
|
22300
22394
|
formIndex: o,
|
|
22301
|
-
formName: (i ?
|
|
22395
|
+
formName: (i ? bg(i) : null) || `Form ${o}`,
|
|
22302
22396
|
fieldIndex: r,
|
|
22303
22397
|
tag: e.tagName,
|
|
22304
22398
|
type: e.type || "text",
|
|
22305
22399
|
name: e.name || null,
|
|
22306
22400
|
id: e.id || null,
|
|
22307
|
-
label:
|
|
22401
|
+
label: wg(e),
|
|
22308
22402
|
placeholder: e.placeholder || null
|
|
22309
22403
|
};
|
|
22310
22404
|
});
|
|
22311
22405
|
}
|
|
22312
|
-
function
|
|
22406
|
+
function kg(e) {
|
|
22407
|
+
if (hg(e) || e.disabled) return !1;
|
|
22408
|
+
try {
|
|
22409
|
+
let t = xg(e);
|
|
22410
|
+
if (t.display === "none" || t.visibility === "hidden" || parseFloat(t.opacity) === 0) return !1;
|
|
22411
|
+
} catch {}
|
|
22412
|
+
return !0;
|
|
22413
|
+
}
|
|
22414
|
+
function Ag() {
|
|
22313
22415
|
let e = [];
|
|
22314
|
-
return
|
|
22315
|
-
e.push(...Array.from(t.querySelectorAll("button, [role=\"button\"], input[type=\"submit\"], input[type=\"button\"]")).filter((e) => {
|
|
22316
|
-
if (
|
|
22317
|
-
|
|
22318
|
-
|
|
22319
|
-
if (t.display === "none" || t.visibility === "hidden" || parseFloat(t.opacity) === 0) return !1;
|
|
22320
|
-
} catch {}
|
|
22321
|
-
return !0;
|
|
22416
|
+
return Sg((t) => {
|
|
22417
|
+
e.push(...Array.from(t.querySelectorAll("button, [role=\"button\"], input[type=\"submit\"], input[type=\"button\"]")).filter(kg)), e.push(...Array.from(t.querySelectorAll("a[href]")).filter((e) => {
|
|
22418
|
+
if (!kg(e)) return !1;
|
|
22419
|
+
let t = (e.textContent || "").replace(/\s+/g, " ").trim();
|
|
22420
|
+
return !(!t || t.length < 2 || t.length > 150);
|
|
22322
22421
|
}));
|
|
22323
22422
|
}), e.slice(0, 60).map((e, t) => ({
|
|
22324
22423
|
index: t,
|
|
@@ -22327,15 +22426,15 @@ function Eg() {
|
|
|
22327
22426
|
type: e.type || e.tagName
|
|
22328
22427
|
}));
|
|
22329
22428
|
}
|
|
22330
|
-
function
|
|
22429
|
+
function jg(e) {
|
|
22331
22430
|
return String(e || "").toLowerCase().replace(/\u00a0/g, " ").replace(/\*/g, "").replace(/\s+/g, " ").trim();
|
|
22332
22431
|
}
|
|
22333
|
-
function
|
|
22334
|
-
let t =
|
|
22432
|
+
function Mg(e) {
|
|
22433
|
+
let t = jg(e);
|
|
22335
22434
|
return t = t.replace(/\s+field\s*$/i, "").trim(), t;
|
|
22336
22435
|
}
|
|
22337
|
-
function
|
|
22338
|
-
let n =
|
|
22436
|
+
function Ng(e, t) {
|
|
22437
|
+
let n = Mg(t);
|
|
22339
22438
|
if (!n) return 0;
|
|
22340
22439
|
let r = (e.name || "").toLowerCase(), i = (e.id || "").toLowerCase();
|
|
22341
22440
|
if (r === "url" && /url|website|domain|audit|conduct|site(\s|$)|page(\s|$)/.test(n) && !/email|e-mail|mail|name|message|phone/.test(n) || (i === "url-input" || i.endsWith("-url-input")) && /url|website|domain|audit|conduct/.test(n) && !/email|e-mail|mail|name|message|phone/.test(n)) return 100;
|
|
@@ -22347,12 +22446,12 @@ function kg(e, t) {
|
|
|
22347
22446
|
e.name,
|
|
22348
22447
|
e.id,
|
|
22349
22448
|
e.placeholder,
|
|
22350
|
-
|
|
22449
|
+
wg(e),
|
|
22351
22450
|
e.getAttribute("aria-label"),
|
|
22352
22451
|
e.getAttribute("title"),
|
|
22353
22452
|
e.getAttribute("data-testid"),
|
|
22354
22453
|
e.getAttribute("autocomplete")
|
|
22355
|
-
].filter(Boolean).map((e) =>
|
|
22454
|
+
].filter(Boolean).map((e) => jg(e)), s = 0;
|
|
22356
22455
|
for (let e of o) {
|
|
22357
22456
|
if (!e) continue;
|
|
22358
22457
|
if (e === n) {
|
|
@@ -22372,16 +22471,16 @@ function kg(e, t) {
|
|
|
22372
22471
|
}
|
|
22373
22472
|
return s;
|
|
22374
22473
|
}
|
|
22375
|
-
var
|
|
22376
|
-
function
|
|
22474
|
+
var Pg = 22;
|
|
22475
|
+
function Fg(e, t) {
|
|
22377
22476
|
let n = null, r = 0;
|
|
22378
22477
|
for (let i of e) {
|
|
22379
|
-
let e =
|
|
22478
|
+
let e = Ng(i, t);
|
|
22380
22479
|
e > r && (r = e, n = i);
|
|
22381
22480
|
}
|
|
22382
|
-
return !n || r <
|
|
22481
|
+
return !n || r < Pg ? null : n;
|
|
22383
22482
|
}
|
|
22384
|
-
function
|
|
22483
|
+
function Ig(e, t, n) {
|
|
22385
22484
|
let r = String(t || "").toLowerCase().trim(), i = String(n || "").trim();
|
|
22386
22485
|
if (/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(i) || !(/^https?:\/\//i.test(i) || /\.\w{2,}(\/|\s|$)/.test(i) || r.includes("url") || r.includes("website") || r.includes("domain") || r.includes("site"))) return null;
|
|
22387
22486
|
let a = null, o = 0;
|
|
@@ -22401,7 +22500,7 @@ function Mg(e, t, n) {
|
|
|
22401
22500
|
t.name,
|
|
22402
22501
|
t.id,
|
|
22403
22502
|
t.placeholder,
|
|
22404
|
-
|
|
22503
|
+
wg(t),
|
|
22405
22504
|
t.getAttribute("aria-label"),
|
|
22406
22505
|
t.getAttribute("autocomplete")
|
|
22407
22506
|
].filter(Boolean).join(" ").toLowerCase();
|
|
@@ -22409,15 +22508,15 @@ function Mg(e, t, n) {
|
|
|
22409
22508
|
}
|
|
22410
22509
|
return !a || o < 42 ? null : a;
|
|
22411
22510
|
}
|
|
22412
|
-
function
|
|
22511
|
+
function Lg(e) {
|
|
22413
22512
|
let t = String(e ?? "").trim();
|
|
22414
22513
|
return !t || /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t) ? !1 : /^https?:\/\//i.test(t) ? !0 : /\.\w{2,}(\/|\s|$)/.test(t);
|
|
22415
22514
|
}
|
|
22416
|
-
function
|
|
22515
|
+
function Rg(e) {
|
|
22417
22516
|
let t = String(e ?? "").toLowerCase().trim();
|
|
22418
22517
|
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;
|
|
22419
22518
|
}
|
|
22420
|
-
function
|
|
22519
|
+
function zg(e) {
|
|
22421
22520
|
if (!e || e.tagName !== "INPUT" && e.tagName !== "TEXTAREA") return !1;
|
|
22422
22521
|
let t = (e.type || "").toLowerCase();
|
|
22423
22522
|
return ![
|
|
@@ -22429,22 +22528,22 @@ function Fg(e) {
|
|
|
22429
22528
|
"file"
|
|
22430
22529
|
].includes(t);
|
|
22431
22530
|
}
|
|
22432
|
-
function
|
|
22433
|
-
if (!
|
|
22531
|
+
function Bg(e) {
|
|
22532
|
+
if (!zg(e)) return !1;
|
|
22434
22533
|
let t = (e.name || "").toLowerCase(), n = (e.id || "").toLowerCase(), r = [
|
|
22435
22534
|
e.name,
|
|
22436
22535
|
e.id,
|
|
22437
22536
|
e.placeholder,
|
|
22438
|
-
|
|
22537
|
+
wg(e),
|
|
22439
22538
|
e.getAttribute("aria-label")
|
|
22440
22539
|
].filter(Boolean).join(" ").toLowerCase();
|
|
22441
22540
|
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);
|
|
22442
22541
|
}
|
|
22443
|
-
function
|
|
22444
|
-
let r = String(t ?? ""), i = String(n ?? ""), a =
|
|
22542
|
+
function Vg(e, t, n) {
|
|
22543
|
+
let r = String(t ?? ""), i = String(n ?? ""), a = Wg(e, r) || Fg(e, r) || Ig(e, r, i);
|
|
22445
22544
|
if (!a) return [];
|
|
22446
22545
|
let o = new Set([a]);
|
|
22447
|
-
if (
|
|
22546
|
+
if (Lg(i) && Rg(r)) for (let t of e) t !== a && Bg(t) && o.add(t);
|
|
22448
22547
|
let s = Array.from(o);
|
|
22449
22548
|
return s.sort((e, t) => {
|
|
22450
22549
|
if (e === t) return 0;
|
|
@@ -22452,7 +22551,7 @@ function Lg(e, t, n) {
|
|
|
22452
22551
|
return n & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : n & Node.DOCUMENT_POSITION_PRECEDING ? 1 : 0;
|
|
22453
22552
|
}), s;
|
|
22454
22553
|
}
|
|
22455
|
-
function
|
|
22554
|
+
function Hg(e, t) {
|
|
22456
22555
|
try {
|
|
22457
22556
|
if (!e?.getBoundingClientRect || !t?.getBoundingClientRect) return Infinity;
|
|
22458
22557
|
let n = e.getBoundingClientRect(), r = t.getBoundingClientRect(), i = {
|
|
@@ -22467,17 +22566,17 @@ function Rg(e, t) {
|
|
|
22467
22566
|
return Infinity;
|
|
22468
22567
|
}
|
|
22469
22568
|
}
|
|
22470
|
-
function
|
|
22569
|
+
function Ug(e) {
|
|
22471
22570
|
if (!e || typeof e != "string") return null;
|
|
22472
22571
|
let t = null;
|
|
22473
|
-
return
|
|
22572
|
+
return Sg((n) => {
|
|
22474
22573
|
try {
|
|
22475
22574
|
let r = n.getElementById(e);
|
|
22476
22575
|
r && !hg(r) && r.matches?.("input, select, textarea") && (t = r);
|
|
22477
22576
|
} catch {}
|
|
22478
22577
|
}), t;
|
|
22479
22578
|
}
|
|
22480
|
-
function
|
|
22579
|
+
function Wg(e, t) {
|
|
22481
22580
|
let n = String(t ?? "").trim();
|
|
22482
22581
|
if (!n) return null;
|
|
22483
22582
|
let r = n.match(/^name:\s*([\w.-]+)$/i);
|
|
@@ -22487,12 +22586,12 @@ function Bg(e, t) {
|
|
|
22487
22586
|
}
|
|
22488
22587
|
let i = n.match(/^id:\s*([\w.-]+)$/i);
|
|
22489
22588
|
if (i) {
|
|
22490
|
-
let e =
|
|
22589
|
+
let e = Ug(i[1]);
|
|
22491
22590
|
if (e) return e;
|
|
22492
22591
|
}
|
|
22493
22592
|
let a = n.startsWith("#") ? n.slice(1) : n;
|
|
22494
22593
|
if (/^[\w-]+$/.test(a)) {
|
|
22495
|
-
let e =
|
|
22594
|
+
let e = Ug(a);
|
|
22496
22595
|
if (e) return e;
|
|
22497
22596
|
}
|
|
22498
22597
|
let o = n.toLowerCase().replace(/\s+/g, " ");
|
|
@@ -22502,7 +22601,7 @@ function Bg(e, t) {
|
|
|
22502
22601
|
}
|
|
22503
22602
|
return null;
|
|
22504
22603
|
}
|
|
22505
|
-
function
|
|
22604
|
+
function Gg(e, t) {
|
|
22506
22605
|
let n = String(t || "").toLowerCase().trim();
|
|
22507
22606
|
if (!n) return 0;
|
|
22508
22607
|
let r = [
|
|
@@ -22519,21 +22618,18 @@ function Vg(e, t) {
|
|
|
22519
22618
|
for (let e of i) r.includes(e) && (a += 1);
|
|
22520
22619
|
return a / i.length * 92;
|
|
22521
22620
|
}
|
|
22522
|
-
function
|
|
22621
|
+
function Kg(e, t) {
|
|
22523
22622
|
let n = [];
|
|
22524
|
-
|
|
22525
|
-
n.push(...Array.from(e.querySelectorAll("button, [role=\"button\"], input[type=\"submit\"], input[type=\"button\"]")).filter((e) => {
|
|
22526
|
-
if (
|
|
22527
|
-
|
|
22528
|
-
|
|
22529
|
-
if (t.display === "none" || t.visibility === "hidden" || parseFloat(t.opacity) === 0) return !1;
|
|
22530
|
-
} catch {}
|
|
22531
|
-
return !0;
|
|
22623
|
+
Sg((e) => {
|
|
22624
|
+
n.push(...Array.from(e.querySelectorAll("button, [role=\"button\"], input[type=\"submit\"], input[type=\"button\"]")).filter(kg)), n.push(...Array.from(e.querySelectorAll("a[href]")).filter((e) => {
|
|
22625
|
+
if (!kg(e)) return !1;
|
|
22626
|
+
let t = (e.textContent || "").replace(/\s+/g, " ").trim();
|
|
22627
|
+
return !(!t || t.length < 2 || t.length > 150);
|
|
22532
22628
|
}));
|
|
22533
22629
|
});
|
|
22534
22630
|
let r = 0, i = n.map((t) => ({
|
|
22535
22631
|
el: t,
|
|
22536
|
-
s:
|
|
22632
|
+
s: Gg(t, e)
|
|
22537
22633
|
}));
|
|
22538
22634
|
for (let { s: e } of i) e > r && (r = e);
|
|
22539
22635
|
if (r < 36) return null;
|
|
@@ -22543,14 +22639,14 @@ function Hg(e, t) {
|
|
|
22543
22639
|
if (o.length) {
|
|
22544
22640
|
let e = a[0], t = Infinity;
|
|
22545
22641
|
for (let n of a) for (let r of o) {
|
|
22546
|
-
let i =
|
|
22642
|
+
let i = Hg(n, r);
|
|
22547
22643
|
i < t && (t = i, e = n);
|
|
22548
22644
|
}
|
|
22549
22645
|
return e;
|
|
22550
22646
|
}
|
|
22551
22647
|
return a[0];
|
|
22552
22648
|
}
|
|
22553
|
-
function
|
|
22649
|
+
function qg(e) {
|
|
22554
22650
|
if (e == null) return {};
|
|
22555
22651
|
if (typeof e == "string") {
|
|
22556
22652
|
let t = e.trim();
|
|
@@ -22563,8 +22659,8 @@ function Ug(e) {
|
|
|
22563
22659
|
}
|
|
22564
22660
|
return e;
|
|
22565
22661
|
}
|
|
22566
|
-
function
|
|
22567
|
-
let t =
|
|
22662
|
+
function Jg(e) {
|
|
22663
|
+
let t = qg(e);
|
|
22568
22664
|
if (Array.isArray(t) && t.length > 0) {
|
|
22569
22665
|
let e = t[0];
|
|
22570
22666
|
if (e?.field_key != null || e?.fieldKey != null) return t.map((e) => ({
|
|
@@ -22592,12 +22688,12 @@ function Wg(e) {
|
|
|
22592
22688
|
value: e?.value ?? e?.Value
|
|
22593
22689
|
})) : [];
|
|
22594
22690
|
}
|
|
22595
|
-
function
|
|
22691
|
+
function Yg(e) {
|
|
22596
22692
|
if (!e || typeof e != "string") return e;
|
|
22597
22693
|
let t = e.trim();
|
|
22598
22694
|
return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t) ? t : (t = t.replace(/\s+at\s+the\s+rate\s*(of)?\s+/gi, "@"), t = t.replace(/\s+at\s+/gi, "@"), t = t.replace(/\s+dot\s+/gi, "."), t = t.replace(/\s+/g, ""), t = t.replace(/\.{2,}/g, ".").replace(/\.$/, ""), t);
|
|
22599
22695
|
}
|
|
22600
|
-
function
|
|
22696
|
+
function Xg(e) {
|
|
22601
22697
|
if (!e || typeof e != "string") return e;
|
|
22602
22698
|
let t = {
|
|
22603
22699
|
zero: "0",
|
|
@@ -22616,7 +22712,7 @@ function Kg(e) {
|
|
|
22616
22712
|
for (let [e, r] of Object.entries(t)) n = n.replace(RegExp(`\\b${e}\\b`, "g"), r);
|
|
22617
22713
|
return n = n.replace(/[^\d+]/g, ""), n;
|
|
22618
22714
|
}
|
|
22619
|
-
function
|
|
22715
|
+
function Zg(e) {
|
|
22620
22716
|
if (!e || typeof e != "string") return [];
|
|
22621
22717
|
let t = e.trim();
|
|
22622
22718
|
if (!t || /\b[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,}\b/i.test(t)) return [];
|
|
@@ -22635,7 +22731,7 @@ function qg(e) {
|
|
|
22635
22731
|
}
|
|
22636
22732
|
return [];
|
|
22637
22733
|
}
|
|
22638
|
-
function
|
|
22734
|
+
function Qg(e) {
|
|
22639
22735
|
if (!e || typeof e != "string") return [];
|
|
22640
22736
|
let t = e.trim();
|
|
22641
22737
|
if (!t) return [];
|
|
@@ -22647,7 +22743,7 @@ function Jg(e) {
|
|
|
22647
22743
|
field_key: e,
|
|
22648
22744
|
value: i
|
|
22649
22745
|
}));
|
|
22650
|
-
}, o =
|
|
22746
|
+
}, o = Yg(t), s = i.test(o), c = o.match(/^\s*([a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,})\s*$/i);
|
|
22651
22747
|
if (c) return a("Email Address", c[1]), n;
|
|
22652
22748
|
if (!i.test(t) && s) {
|
|
22653
22749
|
let e = o.match(i);
|
|
@@ -22675,17 +22771,17 @@ function Jg(e) {
|
|
|
22675
22771
|
}
|
|
22676
22772
|
return n;
|
|
22677
22773
|
}
|
|
22678
|
-
function
|
|
22774
|
+
function $g(e) {
|
|
22679
22775
|
if (!e || typeof e != "object") return null;
|
|
22680
22776
|
let t = e.url ?? e.target_url ?? e.page_url ?? e.pageUrl ?? e.link ?? e.href ?? e.path;
|
|
22681
22777
|
return t == null ? null : String(t).trim() || null;
|
|
22682
22778
|
}
|
|
22683
|
-
function
|
|
22779
|
+
function e_(e) {
|
|
22684
22780
|
if (!e || typeof e != "object") return null;
|
|
22685
22781
|
let t = e.query ?? e.q ?? e.search ?? e.text ?? e.keywords ?? e.search_query ?? e.searchQuery ?? e.question ?? e.prompt ?? e.topic ?? e.intent;
|
|
22686
22782
|
return t == null ? null : String(t).trim() || null;
|
|
22687
22783
|
}
|
|
22688
|
-
function
|
|
22784
|
+
function t_(e) {
|
|
22689
22785
|
let t = e.ownerDocument?.defaultView || window, n = e.tagName === "TEXTAREA" ? t.HTMLTextAreaElement.prototype : t.HTMLInputElement.prototype, r = Object.getOwnPropertyDescriptor(n, "value");
|
|
22690
22786
|
return (e, t) => {
|
|
22691
22787
|
try {
|
|
@@ -22694,7 +22790,7 @@ function Zg(e) {
|
|
|
22694
22790
|
r?.set ? r.set.call(e, t) : e.value = t;
|
|
22695
22791
|
};
|
|
22696
22792
|
}
|
|
22697
|
-
async function
|
|
22793
|
+
async function n_(e, t, n) {
|
|
22698
22794
|
if (!n?.skipScroll) try {
|
|
22699
22795
|
e.scrollIntoView({
|
|
22700
22796
|
behavior: "smooth",
|
|
@@ -22734,7 +22830,7 @@ async function Qg(e, t, n) {
|
|
|
22734
22830
|
].includes(String(t).toLowerCase().trim()), e.dispatchEvent(new Event("input", a)), e.dispatchEvent(new Event("change", a)), cg(e), !0;
|
|
22735
22831
|
let o = String(t);
|
|
22736
22832
|
if (r === "INPUT" || r === "TEXTAREA") {
|
|
22737
|
-
let t =
|
|
22833
|
+
let t = t_(e);
|
|
22738
22834
|
try {
|
|
22739
22835
|
await eg(e, o, t);
|
|
22740
22836
|
} catch {
|
|
@@ -22764,11 +22860,11 @@ async function Qg(e, t, n) {
|
|
|
22764
22860
|
} catch {}
|
|
22765
22861
|
return cg(e), !0;
|
|
22766
22862
|
}
|
|
22767
|
-
function
|
|
22863
|
+
function r_(e) {
|
|
22768
22864
|
let t = e.siteId || null, n = (e.apiBaseUrl || "").replace(/\/$/, ""), r = typeof e.getLastUserVoiceText == "function" ? e.getLastUserVoiceText : null, i = [], a = null, o = {
|
|
22769
22865
|
navigate_to_page: async (n) => {
|
|
22770
22866
|
$("navigate_to_page ▶ raw parameters:", n);
|
|
22771
|
-
let r =
|
|
22867
|
+
let r = qg(n), i = $g(r), a = r.section_text ?? r.sectionText ?? r.section;
|
|
22772
22868
|
if ($("navigate_to_page · coerced:", {
|
|
22773
22869
|
url: i,
|
|
22774
22870
|
sectionText: a
|
|
@@ -22795,7 +22891,7 @@ function $g(e) {
|
|
|
22795
22891
|
}
|
|
22796
22892
|
let e = "";
|
|
22797
22893
|
try {
|
|
22798
|
-
let t =
|
|
22894
|
+
let t = Og(), n = Ag();
|
|
22799
22895
|
if (t.length > 0) {
|
|
22800
22896
|
let r = t.map((e) => e.label || e.placeholder || e.name || e.id).filter(Boolean).join(", "), i = n.map((e) => e.text).filter(Boolean).join(", ");
|
|
22801
22897
|
e = ` This page has a form with fields: [${r}]` + (i ? ` and buttons: [${i}].` : ".") + " Call list_page_forms then start filling.";
|
|
@@ -22811,12 +22907,12 @@ function $g(e) {
|
|
|
22811
22907
|
},
|
|
22812
22908
|
highlight_on_page: async (e) => {
|
|
22813
22909
|
$("highlight_on_page ▶", e);
|
|
22814
|
-
let t =
|
|
22815
|
-
return i ? (an(i), $("highlight_on_page ✓"), "
|
|
22910
|
+
let t = qg(e), n = t?.section_id || t?.sectionId, r = t?.section_text || t?.sectionText, i = rn(n || null, r || null);
|
|
22911
|
+
return i ? (an(i, { speaking: !0 }), $("highlight_on_page ✓ (speaking)"), "OK_HIGHLIGHT section is now highlighted and scrolled into view.") : ($("highlight_on_page ✖ no element"), "Could not find that section on the page.");
|
|
22816
22912
|
},
|
|
22817
22913
|
search_site_content: async (e) => {
|
|
22818
22914
|
$("search_site_content ▶", e);
|
|
22819
|
-
let r =
|
|
22915
|
+
let r = e_(qg(e));
|
|
22820
22916
|
if ($("search_site_content · query:", r, "siteId:", t, "apiBase:", n || "(empty)"), rg("Searching site content…", { spinner: !0 }), !r) return ig(), $("search_site_content ✖ missing query"), "Missing query parameter.";
|
|
22821
22917
|
if (!t) return ig(), $("search_site_content ✖ no siteId"), "Site is not configured for search.";
|
|
22822
22918
|
if (!n) return ig(), $("search_site_content ✖ no api base"), "API base URL is missing; cannot search.";
|
|
@@ -22844,14 +22940,33 @@ function $g(e) {
|
|
|
22844
22940
|
return $("search_site_content ✖", t), t;
|
|
22845
22941
|
}
|
|
22846
22942
|
},
|
|
22943
|
+
read_page_content: async (e) => {
|
|
22944
|
+
$("read_page_content ▶", e);
|
|
22945
|
+
let t = qg(e), n = t?.section_text || t?.sectionText, r = 3e3;
|
|
22946
|
+
try {
|
|
22947
|
+
if (n) {
|
|
22948
|
+
let e = rn(null, n);
|
|
22949
|
+
if (!e) return `Could not find a section matching "${n}" on this page.`;
|
|
22950
|
+
an(e, { speaking: !0 });
|
|
22951
|
+
let t = _g(e, r);
|
|
22952
|
+
return t ? ($("read_page_content ✓ section:", t.length, "chars"), `OK_READ: ${t}`) : "Found the section but it appears to be empty.";
|
|
22953
|
+
}
|
|
22954
|
+
let e = vg();
|
|
22955
|
+
if (!e) return "Could not determine the main content area of this page.";
|
|
22956
|
+
let t = _g(e, r);
|
|
22957
|
+
return t ? ($("read_page_content ✓ page:", t.length, "chars"), `OK_READ: ${t}`) : "The page appears to have no readable text content.";
|
|
22958
|
+
} catch (e) {
|
|
22959
|
+
return $("read_page_content ✖", e?.message), `Error reading page content: ${e?.message || "unknown error"}`;
|
|
22960
|
+
}
|
|
22961
|
+
},
|
|
22847
22962
|
end_voice_session: async () => ($("end_voice_session ▶"), rg("Ending voice session…", {
|
|
22848
22963
|
icon: "👋",
|
|
22849
22964
|
spinner: !1,
|
|
22850
22965
|
duration: 2e3
|
|
22851
22966
|
}), dg(!0), lg(), typeof e.requestEndSession == "function" && e.requestEndSession(), "Voice session is ending."),
|
|
22852
22967
|
list_page_forms: async () => {
|
|
22853
|
-
let e =
|
|
22854
|
-
return $("list_page_forms ✓", `${e.length} field(s)`, `${t.length} button(s)`), a =
|
|
22968
|
+
let e = Og(), t = Ag();
|
|
22969
|
+
return $("list_page_forms ✓", `${e.length} field(s)`, `${t.length} button(s)`), a = Dg(), $("list_page_forms · activeFormAncestor", a ? "contact-preferring" : "none"), JSON.stringify({
|
|
22855
22970
|
fields: e,
|
|
22856
22971
|
buttons: t,
|
|
22857
22972
|
hint: "Fields are grouped by formIndex/formName. Work with ONE form at a time — only fill fields from the same formIndex. Do not jump to fields in a different form. On pages with a contact form AND a footer 'Conduct Audit' / website URL field: only use the contact form unless the visitor explicitly asks to run an audit. Contact forms: fill in order Full Name → Email Address → Message. Message must be a short note the visitor wants to send (one or two sentences), never a recap of the whole chat or assistant replies. field_key: use placeholder, label, name, or id from this list. click_page_button picks the button nearest the filled fields (e.g. Send Message on the same form)."
|
|
@@ -22860,10 +22975,10 @@ function $g(e) {
|
|
|
22860
22975
|
fill_form_fields: async (e) => {
|
|
22861
22976
|
try {
|
|
22862
22977
|
$("fill_form_fields ▶ raw:", e);
|
|
22863
|
-
let t =
|
|
22978
|
+
let t = Jg(e);
|
|
22864
22979
|
if (!t.length && r) {
|
|
22865
|
-
let e = r(), n =
|
|
22866
|
-
n.length ? $("fill_form_fields · inferred URL from last user utterance (model omitted usable fields):", n) : (n =
|
|
22980
|
+
let e = r(), n = Zg(e);
|
|
22981
|
+
n.length ? $("fill_form_fields · inferred URL from last user utterance (model omitted usable fields):", n) : (n = Qg(e), n.length && $("fill_form_fields · inferred contact fields from last user utterance (empty tool params):", n)), n.length && (t = n);
|
|
22867
22982
|
}
|
|
22868
22983
|
if ($("fill_form_fields · normalized fields:", t), !t.length) return "No fields provided. Call list_page_forms for field_key strings, then fill_form_fields 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.";
|
|
22869
22984
|
t.length > 1 && rg(`Filling ${t.length} fields…`);
|
|
@@ -22872,33 +22987,33 @@ function $g(e) {
|
|
|
22872
22987
|
let t = e?.field_key ?? e?.fieldKey, r = e?.value;
|
|
22873
22988
|
if (t == null || r == null) continue;
|
|
22874
22989
|
let o = String(t).toLowerCase();
|
|
22875
|
-
if (/email|e-mail|mail/.test(o)) r =
|
|
22876
|
-
else if (/phone|mobile|tel|cell/.test(o)) r =
|
|
22877
|
-
else if (
|
|
22990
|
+
if (/email|e-mail|mail/.test(o)) r = Yg(r);
|
|
22991
|
+
else if (/phone|mobile|tel|cell/.test(o)) r = Xg(r);
|
|
22992
|
+
else if (Rg(t) || o === "url") {
|
|
22878
22993
|
let e = String(r ?? "").trim();
|
|
22879
22994
|
if (/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e) || /\bat\b/i.test(e) && /\bdot\b/i.test(e)) {
|
|
22880
|
-
let n =
|
|
22995
|
+
let n = Yg(e);
|
|
22881
22996
|
/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(n.trim()) && ($("fill_form_fields · remapping url/website intent to Email Address (value is an email)"), t = "Email Address", o = "email address", r = n.trim());
|
|
22882
22997
|
}
|
|
22883
22998
|
}
|
|
22884
22999
|
rg(`Filling ${t}…`), $("fill_form_fields · processing field:", t, "=", r);
|
|
22885
|
-
let s =
|
|
23000
|
+
let s = Tg(), c = s;
|
|
22886
23001
|
if (a) {
|
|
22887
|
-
let e = s.filter((e) =>
|
|
23002
|
+
let e = s.filter((e) => yg(e) === a);
|
|
22888
23003
|
e.length > 0 && (c = e, $("fill_form_fields · scoped to active form, inputs:", e.length));
|
|
22889
23004
|
}
|
|
22890
23005
|
$("fill_form_fields · visible inputs count:", s.length, "scoped:", c.length);
|
|
22891
23006
|
let l = !1;
|
|
22892
23007
|
for (let e of [c, ...c === s ? [] : [s]]) {
|
|
22893
|
-
let o =
|
|
23008
|
+
let o = Vg(e, String(t), r);
|
|
22894
23009
|
if (o.length) {
|
|
22895
|
-
for (let e = 0; e < o.length; e++) await
|
|
22896
|
-
i = o, a =
|
|
23010
|
+
for (let e = 0; e < o.length; e++) await n_(o[e], r, { skipScroll: e > 0 }), await new Promise((e) => setTimeout(e, 80));
|
|
23011
|
+
i = o, a = yg(o[0]) || a, n.push(String(t)), l = !0;
|
|
22897
23012
|
break;
|
|
22898
23013
|
}
|
|
22899
|
-
let s =
|
|
22900
|
-
if (s ||=
|
|
22901
|
-
await
|
|
23014
|
+
let s = Wg(e, String(t));
|
|
23015
|
+
if (s ||= Fg(e, String(t)), s ||= Ig(e, String(t), r), s) {
|
|
23016
|
+
await n_(s, r), i = [s], a = yg(s) || a, n.push(String(t)), l = !0;
|
|
22902
23017
|
break;
|
|
22903
23018
|
}
|
|
22904
23019
|
}
|
|
@@ -22918,10 +23033,10 @@ function $g(e) {
|
|
|
22918
23033
|
}
|
|
22919
23034
|
},
|
|
22920
23035
|
click_page_button: async (e) => {
|
|
22921
|
-
let t =
|
|
23036
|
+
let t = qg(e), n = (t.button_text ?? t.buttonText ?? t.text ?? "").trim();
|
|
22922
23037
|
if ($("click_page_button ▶", n), !n) return "Missing button_text: pass the visible label, e.g. Conduct Audit.";
|
|
22923
23038
|
rg(`Clicking "${n}"…`);
|
|
22924
|
-
let r =
|
|
23039
|
+
let r = Kg(n, i);
|
|
22925
23040
|
if (!r) return ig(200), $("click_page_button ✖ no match"), `Could not find a button matching "${n}". Call list_page_forms to see button texts.`;
|
|
22926
23041
|
try {
|
|
22927
23042
|
try {
|
|
@@ -22942,11 +23057,11 @@ function $g(e) {
|
|
|
22942
23057
|
try {
|
|
22943
23058
|
await fg(r);
|
|
22944
23059
|
} catch {}
|
|
22945
|
-
let e =
|
|
23060
|
+
let e = yg(r) || a, t = [];
|
|
22946
23061
|
if (e) {
|
|
22947
23062
|
let n = Array.from(e.querySelectorAll("input[required], textarea[required], select[required]")).filter((e) => !hg(e));
|
|
22948
23063
|
for (let e of n) if (!(e.value || "").trim()) {
|
|
22949
|
-
let n =
|
|
23064
|
+
let n = wg(e) || e.placeholder || e.name || e.type;
|
|
22950
23065
|
t.push(n);
|
|
22951
23066
|
}
|
|
22952
23067
|
}
|
|
@@ -22987,7 +23102,7 @@ function $g(e) {
|
|
|
22987
23102
|
}
|
|
22988
23103
|
//#endregion
|
|
22989
23104
|
//#region src/utils/wrapVoiceToolsForLogging.js
|
|
22990
|
-
function
|
|
23105
|
+
function i_(e) {
|
|
22991
23106
|
return !e || typeof e != "object" ? e : Object.fromEntries(Object.entries(e).map(([e, t]) => [e, async (n) => {
|
|
22992
23107
|
let r = Zt();
|
|
22993
23108
|
r ? console.log("[FlowEngage:voice-tool] ▶", e, n) : console.info(`[FlowEngage] voice tool » ${e}`);
|
|
@@ -23004,22 +23119,22 @@ function e_(e) {
|
|
|
23004
23119
|
}
|
|
23005
23120
|
//#endregion
|
|
23006
23121
|
//#region src/components/VoiceInterface.jsx
|
|
23007
|
-
var
|
|
23122
|
+
var a_ = {
|
|
23008
23123
|
idle: "rgba(99,102,241,0.18)",
|
|
23009
23124
|
listening: "rgba(16,185,129,0.25)",
|
|
23010
23125
|
speaking: "rgba(245,158,11,0.25)",
|
|
23011
23126
|
error: "rgba(239,68,68,0.2)"
|
|
23012
|
-
},
|
|
23127
|
+
}, o_ = {
|
|
23013
23128
|
idle: "#6366f1",
|
|
23014
23129
|
listening: "#10b981",
|
|
23015
23130
|
speaking: "#f59e0b",
|
|
23016
23131
|
error: "#ef4444"
|
|
23017
23132
|
};
|
|
23018
|
-
function
|
|
23133
|
+
function s_(e, t) {
|
|
23019
23134
|
let n = (t || "").trim();
|
|
23020
23135
|
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;
|
|
23021
23136
|
}
|
|
23022
|
-
function
|
|
23137
|
+
function c_({ agentId: e, chatId: t, siteId: r, apiBaseUrl: a, onEnd: c, historyRef: d, hasSyncedRef: f, onMessageSync: p, onStartSync: m }) {
|
|
23023
23138
|
let [h, g] = s("idle"), [ee, te] = s(null), [_, ne] = s(!1), re = o(null), ie = o(null), ae = o(""), oe = o(async () => {}), se = o(!1), v = n(async () => {
|
|
23024
23139
|
try {
|
|
23025
23140
|
await re.current?.endSession?.();
|
|
@@ -23036,7 +23151,7 @@ function i_({ agentId: e, chatId: t, siteId: r, apiBaseUrl: a, onEnd: c, history
|
|
|
23036
23151
|
try {
|
|
23037
23152
|
if (await navigator.mediaDevices.getUserMedia({ audio: !0 }), t) return;
|
|
23038
23153
|
d.current = [], ae.current = "", se.current = !1;
|
|
23039
|
-
let i =
|
|
23154
|
+
let i = i_(r_({
|
|
23040
23155
|
siteId: r || null,
|
|
23041
23156
|
apiBaseUrl: a || null,
|
|
23042
23157
|
getLastUserVoiceText: () => ae.current,
|
|
@@ -23063,7 +23178,7 @@ function i_({ agentId: e, chatId: t, siteId: r, apiBaseUrl: a, onEnd: c, history
|
|
|
23063
23178
|
message: r,
|
|
23064
23179
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
23065
23180
|
};
|
|
23066
|
-
n === "user" && (ae.current = r), d.current = [...d.current, i],
|
|
23181
|
+
n === "user" && (ae.current = r), d.current = [...d.current, i], s_(n, r) && queueMicrotask(() => {
|
|
23067
23182
|
se.current || (se.current = !0, oe.current?.());
|
|
23068
23183
|
});
|
|
23069
23184
|
},
|
|
@@ -23102,7 +23217,7 @@ function i_({ agentId: e, chatId: t, siteId: r, apiBaseUrl: a, onEnd: c, history
|
|
|
23102
23217
|
d,
|
|
23103
23218
|
m
|
|
23104
23219
|
]);
|
|
23105
|
-
let ce = h === "listening" || h === "speaking", le =
|
|
23220
|
+
let ce = h === "listening" || h === "speaking", le = o_[h] || o_.idle, ue = a_[h] || a_.idle;
|
|
23106
23221
|
return /* @__PURE__ */ u("div", {
|
|
23107
23222
|
ref: ie,
|
|
23108
23223
|
style: {
|
|
@@ -23208,7 +23323,7 @@ function i_({ agentId: e, chatId: t, siteId: r, apiBaseUrl: a, onEnd: c, history
|
|
|
23208
23323
|
}
|
|
23209
23324
|
//#endregion
|
|
23210
23325
|
//#region src/components/FlowEngageWidget.jsx
|
|
23211
|
-
var
|
|
23326
|
+
var l_ = [
|
|
23212
23327
|
{
|
|
23213
23328
|
key: "become_client",
|
|
23214
23329
|
label: "Become a Client"
|
|
@@ -23229,7 +23344,7 @@ var a_ = [
|
|
|
23229
23344
|
key: "looking_for_job",
|
|
23230
23345
|
label: "Looking for a Job"
|
|
23231
23346
|
}
|
|
23232
|
-
],
|
|
23347
|
+
], u_ = () => /* @__PURE__ */ l("div", {
|
|
23233
23348
|
style: {
|
|
23234
23349
|
display: "flex",
|
|
23235
23350
|
marginBottom: "12px",
|
|
@@ -23260,7 +23375,7 @@ var a_ = [
|
|
|
23260
23375
|
} }, e)), /* @__PURE__ */ l("style", { children: "\n @keyframes fe-dot-bounce {\n 0%, 80%, 100% { transform: translateY(0); opacity: 0.5; }\n 40% { transform: translateY(-5px); opacity: 1; }\n }\n " })]
|
|
23261
23376
|
})
|
|
23262
23377
|
});
|
|
23263
|
-
function
|
|
23378
|
+
function d_() {
|
|
23264
23379
|
let { status: e, runtimeConfig: t, resolvedConfig: n, chatId: r, chatHistory: o, isOpen: c, activeScreen: d, isHumanHandled: f, agentName: p, agentHeadshot: m, visitorEmail: h, isAgentTyping: g, isAiTyping: ee, isLoading: te, isVoiceMode: _, isRateLimited: ne, rateLimitMessage: re, isConversationEnded: ie, incomingCall: ae, activeCallId: oe, callConnectionState: se, callConnectedAt: v, isCallMuted: ce, webRTCError: le, language: ue, historyRef: y, onMessageSync: b, endConversation: de, acceptCall: fe, rejectCall: pe, endWebRTCCall: me, toggleCallMute: he, dismissCallError: ge, captureVisitorEmail: _e, openWidget: ve, closeWidget: ye, sendMessage: be, setVoiceMode: xe, startTyping: Se, stopTyping: Ce, updateTypingDraft: we } = Xt(), [Te, Ee] = s(""), [De, Oe] = s(null), [ke, Ae] = s(null), [je, Me] = s(null), [Ne, Pe] = s(0), [x, Fe] = s(h || ""), [Ie, Le] = s("");
|
|
23265
23380
|
i(() => {
|
|
23266
23381
|
try {
|
|
@@ -23288,7 +23403,7 @@ function s_() {
|
|
|
23288
23403
|
outline: "none",
|
|
23289
23404
|
fontFamily: "ui-sans-serif, system-ui, sans-serif",
|
|
23290
23405
|
...c ? {} : Ue
|
|
23291
|
-
}, Ge = S.recommendations?.[ue] || Re.recommendations?.[ue] ||
|
|
23406
|
+
}, Ge = S.recommendations?.[ue] || Re.recommendations?.[ue] || l_, Ke = S.greetings?.[ue] || Re.greetings?.[ue], qe = ze.chatButtonText || "Chat with us", Je = ze.headerName || t?.websiteName || "OpenSense Labs", C = ze.logoUrl || null, w = ze.hideWatermark || !1, T = Re.elevenLabsAgentId || t?.elevenLabsAgentId || null, Ye = t?.siteId || n?.siteId || null, Xe = t?.apiBaseUrl || "", Ze = ze.fallbackAgentName || "Agent", Qe = ze.botLabel || "AI", $e = m && String(m).trim() || t?.ownerProfileImageUrl && String(t.ownerProfileImageUrl).trim() || null, et = ae?.agentName || p || Ze, tt = o.some((e) => e.sender === "user"), nt = a(() => {
|
|
23292
23407
|
let e = o.findIndex((e) => e.sender === "user");
|
|
23293
23408
|
return e === -1 ? !1 : o.slice(e + 1).some((e) => e.sender === "bot" || e.sender === "ai" || e.sender === "agent");
|
|
23294
23409
|
}, [o]), rt = !h && tt && nt;
|
|
@@ -23416,7 +23531,7 @@ function s_() {
|
|
|
23416
23531
|
flexDirection: "column"
|
|
23417
23532
|
},
|
|
23418
23533
|
className: "fe-screen-fade-in",
|
|
23419
|
-
children: /* @__PURE__ */ l(
|
|
23534
|
+
children: /* @__PURE__ */ l(c_, {
|
|
23420
23535
|
agentId: T,
|
|
23421
23536
|
chatId: r,
|
|
23422
23537
|
siteId: Ye,
|
|
@@ -23449,7 +23564,7 @@ function s_() {
|
|
|
23449
23564
|
isAiTyping: ee,
|
|
23450
23565
|
isAgentTyping: g,
|
|
23451
23566
|
setReplyContext: Me,
|
|
23452
|
-
TypingDots:
|
|
23567
|
+
TypingDots: u_,
|
|
23453
23568
|
primaryColor: Ve,
|
|
23454
23569
|
agentHeadshot: $e,
|
|
23455
23570
|
agentDisplayName: p || Ze
|
|
@@ -23528,4 +23643,4 @@ function s_() {
|
|
|
23528
23643
|
}) : null;
|
|
23529
23644
|
}
|
|
23530
23645
|
//#endregion
|
|
23531
|
-
export { vn as FlowEngageProvider,
|
|
23646
|
+
export { vn as FlowEngageProvider, d_ as FlowEngageWidget, Xt as useFlowEngage };
|