@flowengage/react-chatbot 1.0.9 → 1.1.0
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.
|
@@ -22133,19 +22133,30 @@ function tg(e) {
|
|
|
22133
22133
|
}
|
|
22134
22134
|
//#endregion
|
|
22135
22135
|
//#region src/utils/voiceClientTools.js
|
|
22136
|
+
function ng(e) {
|
|
22137
|
+
return (...t) => {
|
|
22138
|
+
try {
|
|
22139
|
+
let n = e(...t);
|
|
22140
|
+
return n instanceof Promise ? n.catch(() => {}) : n;
|
|
22141
|
+
} catch {
|
|
22142
|
+
return;
|
|
22143
|
+
}
|
|
22144
|
+
};
|
|
22145
|
+
}
|
|
22146
|
+
var rg = ng(Ih), ig = ng(Lh), ag = ng(Vh), og = ng(Hh), sg = ng(Wh), cg = ng(Gh), lg = ng(Uh), ug = ng(Xh), dg = ng(Zh), fg = ng(Qh), pg = ng($h);
|
|
22136
22147
|
function $(...e) {
|
|
22137
22148
|
Zt() && console.log("[FlowEngage:voice-tools]", ...e);
|
|
22138
22149
|
}
|
|
22139
|
-
var
|
|
22140
|
-
function
|
|
22150
|
+
var mg = "#flowengage-root, .flowengage-shell";
|
|
22151
|
+
function hg(e) {
|
|
22141
22152
|
if (!e || typeof e.closest != "function") return !1;
|
|
22142
22153
|
try {
|
|
22143
|
-
return !!e.closest(
|
|
22154
|
+
return !!e.closest(mg);
|
|
22144
22155
|
} catch {
|
|
22145
22156
|
return !1;
|
|
22146
22157
|
}
|
|
22147
22158
|
}
|
|
22148
|
-
function
|
|
22159
|
+
function gg(e) {
|
|
22149
22160
|
if (!e) return null;
|
|
22150
22161
|
try {
|
|
22151
22162
|
return e.closest("form");
|
|
@@ -22158,7 +22169,7 @@ function ig(e) {
|
|
|
22158
22169
|
return null;
|
|
22159
22170
|
}
|
|
22160
22171
|
}
|
|
22161
|
-
function
|
|
22172
|
+
function _g(e) {
|
|
22162
22173
|
if (!e) return null;
|
|
22163
22174
|
let t = e.querySelector("h1, h2, h3, h4, h5, legend");
|
|
22164
22175
|
if (t) return t.textContent.replace(/\s+/g, " ").trim().slice(0, 60);
|
|
@@ -22173,30 +22184,30 @@ function ag(e) {
|
|
|
22173
22184
|
}
|
|
22174
22185
|
return null;
|
|
22175
22186
|
}
|
|
22176
|
-
function
|
|
22187
|
+
function vg(e) {
|
|
22177
22188
|
try {
|
|
22178
22189
|
let t = e.ownerDocument?.defaultView;
|
|
22179
22190
|
if (t) return t.getComputedStyle(e);
|
|
22180
22191
|
} catch {}
|
|
22181
22192
|
return window.getComputedStyle(e);
|
|
22182
22193
|
}
|
|
22183
|
-
function
|
|
22194
|
+
function yg(e) {
|
|
22184
22195
|
let t = /* @__PURE__ */ new Set();
|
|
22185
22196
|
function n(r) {
|
|
22186
22197
|
if (!r || t.has(r)) return;
|
|
22187
22198
|
t.add(r), e(r);
|
|
22188
22199
|
let i = r.querySelectorAll("iframe");
|
|
22189
|
-
for (let e of i) if (!
|
|
22200
|
+
for (let e of i) if (!hg(e)) try {
|
|
22190
22201
|
let t = e.contentDocument;
|
|
22191
22202
|
t && n(t);
|
|
22192
22203
|
} catch {}
|
|
22193
22204
|
}
|
|
22194
22205
|
typeof document < "u" && n(document);
|
|
22195
22206
|
}
|
|
22196
|
-
function
|
|
22207
|
+
function bg(e) {
|
|
22197
22208
|
return e == null ? null : String(e).replace(/\u00a0/g, " ").replace(/\s*\*+\s*$/u, "").replace(/\s+/g, " ").trim();
|
|
22198
22209
|
}
|
|
22199
|
-
function
|
|
22210
|
+
function xg(e) {
|
|
22200
22211
|
let t = e.ownerDocument || document, n = e.getAttribute("aria-labelledby");
|
|
22201
22212
|
if (n) {
|
|
22202
22213
|
let e = n.trim().split(/\s+/).filter(Boolean), r = [];
|
|
@@ -22204,42 +22215,42 @@ function lg(e) {
|
|
|
22204
22215
|
let e = t.getElementById(n);
|
|
22205
22216
|
e?.textContent && r.push(e.textContent.trim());
|
|
22206
22217
|
} catch {}
|
|
22207
|
-
if (r.length) return
|
|
22218
|
+
if (r.length) return bg(r.join(" "));
|
|
22208
22219
|
}
|
|
22209
|
-
if (e.labels && e.labels.length) return
|
|
22220
|
+
if (e.labels && e.labels.length) return bg(e.labels[0].textContent);
|
|
22210
22221
|
let r = e.id;
|
|
22211
22222
|
if (r) try {
|
|
22212
22223
|
let e = t.querySelector(`label[for="${CSS.escape(r)}"]`);
|
|
22213
|
-
if (e) return
|
|
22224
|
+
if (e) return bg(e.textContent);
|
|
22214
22225
|
} catch {
|
|
22215
22226
|
let e = t.querySelector(`label[for="${r.replace(/"/g, "\\\"")}"]`);
|
|
22216
|
-
if (e) return
|
|
22227
|
+
if (e) return bg(e.textContent);
|
|
22217
22228
|
}
|
|
22218
22229
|
let i = e.previousElementSibling;
|
|
22219
22230
|
for (let e = 0; e < 6 && i; e += 1) {
|
|
22220
|
-
if (i.tagName === "LABEL") return
|
|
22231
|
+
if (i.tagName === "LABEL") return bg(i.textContent);
|
|
22221
22232
|
let e = (i.className || "").toString().toLowerCase();
|
|
22222
22233
|
if (/chakra-form__label|formlabel|field-label|form-label|mui-form-label/.test(e)) {
|
|
22223
|
-
let e =
|
|
22234
|
+
let e = bg(i.textContent);
|
|
22224
22235
|
if (e) return e;
|
|
22225
22236
|
}
|
|
22226
22237
|
i = i.previousElementSibling;
|
|
22227
22238
|
}
|
|
22228
22239
|
let a = e.parentElement;
|
|
22229
22240
|
for (let e = 0; e < 5 && a; e += 1) {
|
|
22230
|
-
if (a.tagName === "LABEL") return
|
|
22241
|
+
if (a.tagName === "LABEL") return bg(a.textContent);
|
|
22231
22242
|
let e = a.querySelector?.(":scope > label, :scope > [class*='FormLabel'], :scope > [class*='form__label']");
|
|
22232
|
-
if (e?.textContent) return
|
|
22243
|
+
if (e?.textContent) return bg(e.textContent);
|
|
22233
22244
|
a = a.parentElement;
|
|
22234
22245
|
}
|
|
22235
22246
|
let o = e.getAttribute("aria-label");
|
|
22236
|
-
return o ?
|
|
22247
|
+
return o ? bg(o) : null;
|
|
22237
22248
|
}
|
|
22238
|
-
function
|
|
22249
|
+
function Sg() {
|
|
22239
22250
|
let e = [];
|
|
22240
|
-
return
|
|
22251
|
+
return yg((t) => {
|
|
22241
22252
|
e.push(...Array.from(t.querySelectorAll("input, select, textarea")).filter((e) => {
|
|
22242
|
-
if (
|
|
22253
|
+
if (hg(e)) return !1;
|
|
22243
22254
|
let t = (e.type || "").toLowerCase();
|
|
22244
22255
|
if ([
|
|
22245
22256
|
"hidden",
|
|
@@ -22248,7 +22259,7 @@ function ug() {
|
|
|
22248
22259
|
"image"
|
|
22249
22260
|
].includes(t) || e.disabled || e.readOnly) return !1;
|
|
22250
22261
|
try {
|
|
22251
|
-
let t =
|
|
22262
|
+
let t = vg(e);
|
|
22252
22263
|
if (t.display === "none" || t.visibility === "hidden" || parseFloat(t.opacity) === 0) return !1;
|
|
22253
22264
|
} catch {}
|
|
22254
22265
|
try {
|
|
@@ -22258,32 +22269,32 @@ function ug() {
|
|
|
22258
22269
|
}));
|
|
22259
22270
|
}), e;
|
|
22260
22271
|
}
|
|
22261
|
-
function
|
|
22262
|
-
let e =
|
|
22272
|
+
function Cg() {
|
|
22273
|
+
let e = Sg(), t = /* @__PURE__ */ new Map(), n = 0;
|
|
22263
22274
|
return e.map((e, r) => {
|
|
22264
|
-
let i =
|
|
22275
|
+
let i = gg(e), a = i || "__orphan__";
|
|
22265
22276
|
t.has(a) || t.set(a, n++);
|
|
22266
22277
|
let o = t.get(a);
|
|
22267
22278
|
return {
|
|
22268
22279
|
formIndex: o,
|
|
22269
|
-
formName: (i ?
|
|
22280
|
+
formName: (i ? _g(i) : null) || `Form ${o}`,
|
|
22270
22281
|
fieldIndex: r,
|
|
22271
22282
|
tag: e.tagName,
|
|
22272
22283
|
type: e.type || "text",
|
|
22273
22284
|
name: e.name || null,
|
|
22274
22285
|
id: e.id || null,
|
|
22275
|
-
label:
|
|
22286
|
+
label: xg(e),
|
|
22276
22287
|
placeholder: e.placeholder || null
|
|
22277
22288
|
};
|
|
22278
22289
|
});
|
|
22279
22290
|
}
|
|
22280
|
-
function
|
|
22291
|
+
function wg() {
|
|
22281
22292
|
let e = [];
|
|
22282
|
-
return
|
|
22293
|
+
return yg((t) => {
|
|
22283
22294
|
e.push(...Array.from(t.querySelectorAll("button, [role=\"button\"], input[type=\"submit\"], input[type=\"button\"]")).filter((e) => {
|
|
22284
|
-
if (
|
|
22295
|
+
if (hg(e) || e.disabled) return !1;
|
|
22285
22296
|
try {
|
|
22286
|
-
let t =
|
|
22297
|
+
let t = vg(e);
|
|
22287
22298
|
if (t.display === "none" || t.visibility === "hidden" || parseFloat(t.opacity) === 0) return !1;
|
|
22288
22299
|
} catch {}
|
|
22289
22300
|
return !0;
|
|
@@ -22295,15 +22306,15 @@ function fg() {
|
|
|
22295
22306
|
type: e.type || e.tagName
|
|
22296
22307
|
}));
|
|
22297
22308
|
}
|
|
22298
|
-
function
|
|
22309
|
+
function Tg(e) {
|
|
22299
22310
|
return String(e || "").toLowerCase().replace(/\u00a0/g, " ").replace(/\*/g, "").replace(/\s+/g, " ").trim();
|
|
22300
22311
|
}
|
|
22301
|
-
function
|
|
22302
|
-
let t =
|
|
22312
|
+
function Eg(e) {
|
|
22313
|
+
let t = Tg(e);
|
|
22303
22314
|
return t = t.replace(/\s+field\s*$/i, "").trim(), t;
|
|
22304
22315
|
}
|
|
22305
|
-
function
|
|
22306
|
-
let n =
|
|
22316
|
+
function Dg(e, t) {
|
|
22317
|
+
let n = Eg(t);
|
|
22307
22318
|
if (!n) return 0;
|
|
22308
22319
|
let r = (e.name || "").toLowerCase(), i = (e.id || "").toLowerCase();
|
|
22309
22320
|
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;
|
|
@@ -22315,12 +22326,12 @@ function hg(e, t) {
|
|
|
22315
22326
|
e.name,
|
|
22316
22327
|
e.id,
|
|
22317
22328
|
e.placeholder,
|
|
22318
|
-
|
|
22329
|
+
xg(e),
|
|
22319
22330
|
e.getAttribute("aria-label"),
|
|
22320
22331
|
e.getAttribute("title"),
|
|
22321
22332
|
e.getAttribute("data-testid"),
|
|
22322
22333
|
e.getAttribute("autocomplete")
|
|
22323
|
-
].filter(Boolean).map((e) =>
|
|
22334
|
+
].filter(Boolean).map((e) => Tg(e)), s = 0;
|
|
22324
22335
|
for (let e of o) {
|
|
22325
22336
|
if (!e) continue;
|
|
22326
22337
|
if (e === n) {
|
|
@@ -22340,16 +22351,16 @@ function hg(e, t) {
|
|
|
22340
22351
|
}
|
|
22341
22352
|
return s;
|
|
22342
22353
|
}
|
|
22343
|
-
var
|
|
22344
|
-
function
|
|
22354
|
+
var Og = 22;
|
|
22355
|
+
function kg(e, t) {
|
|
22345
22356
|
let n = null, r = 0;
|
|
22346
22357
|
for (let i of e) {
|
|
22347
|
-
let e =
|
|
22358
|
+
let e = Dg(i, t);
|
|
22348
22359
|
e > r && (r = e, n = i);
|
|
22349
22360
|
}
|
|
22350
|
-
return !n || r <
|
|
22361
|
+
return !n || r < Og ? null : n;
|
|
22351
22362
|
}
|
|
22352
|
-
function
|
|
22363
|
+
function Ag(e, t, n) {
|
|
22353
22364
|
let r = String(t || "").toLowerCase().trim(), i = String(n || "").trim();
|
|
22354
22365
|
if (!(/^https?:\/\//i.test(i) || /\.\w{2,}(\/|\s|$)/.test(i) || r.includes("url") || r.includes("website") || r.includes("domain") || r.includes("site"))) return null;
|
|
22355
22366
|
let a = null, o = 0;
|
|
@@ -22369,7 +22380,7 @@ function vg(e, t, n) {
|
|
|
22369
22380
|
t.name,
|
|
22370
22381
|
t.id,
|
|
22371
22382
|
t.placeholder,
|
|
22372
|
-
|
|
22383
|
+
xg(t),
|
|
22373
22384
|
t.getAttribute("aria-label"),
|
|
22374
22385
|
t.getAttribute("autocomplete")
|
|
22375
22386
|
].filter(Boolean).join(" ").toLowerCase();
|
|
@@ -22377,15 +22388,15 @@ function vg(e, t, n) {
|
|
|
22377
22388
|
}
|
|
22378
22389
|
return !a || o < 42 ? null : a;
|
|
22379
22390
|
}
|
|
22380
|
-
function
|
|
22391
|
+
function jg(e) {
|
|
22381
22392
|
let t = String(e ?? "").trim();
|
|
22382
22393
|
return t ? /^https?:\/\//i.test(t) ? !0 : /\.\w{2,}(\/|\s|$)/.test(t) : !1;
|
|
22383
22394
|
}
|
|
22384
|
-
function
|
|
22395
|
+
function Mg(e) {
|
|
22385
22396
|
let t = String(e ?? "").toLowerCase().trim();
|
|
22386
22397
|
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;
|
|
22387
22398
|
}
|
|
22388
|
-
function
|
|
22399
|
+
function Ng(e) {
|
|
22389
22400
|
if (!e || e.tagName !== "INPUT" && e.tagName !== "TEXTAREA") return !1;
|
|
22390
22401
|
let t = (e.type || "").toLowerCase();
|
|
22391
22402
|
return ![
|
|
@@ -22397,22 +22408,22 @@ function xg(e) {
|
|
|
22397
22408
|
"file"
|
|
22398
22409
|
].includes(t);
|
|
22399
22410
|
}
|
|
22400
|
-
function
|
|
22401
|
-
if (!
|
|
22411
|
+
function Pg(e) {
|
|
22412
|
+
if (!Ng(e)) return !1;
|
|
22402
22413
|
let t = (e.name || "").toLowerCase(), n = (e.id || "").toLowerCase(), r = [
|
|
22403
22414
|
e.name,
|
|
22404
22415
|
e.id,
|
|
22405
22416
|
e.placeholder,
|
|
22406
|
-
|
|
22417
|
+
xg(e),
|
|
22407
22418
|
e.getAttribute("aria-label")
|
|
22408
22419
|
].filter(Boolean).join(" ").toLowerCase();
|
|
22409
22420
|
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);
|
|
22410
22421
|
}
|
|
22411
|
-
function
|
|
22412
|
-
let r = String(t ?? ""), i = String(n ?? ""), a =
|
|
22422
|
+
function Fg(e, t, n) {
|
|
22423
|
+
let r = String(t ?? ""), i = String(n ?? ""), a = Rg(e, r) || kg(e, r) || Ag(e, r, i);
|
|
22413
22424
|
if (!a) return [];
|
|
22414
22425
|
let o = new Set([a]);
|
|
22415
|
-
if (
|
|
22426
|
+
if (jg(i) && Mg(r)) for (let t of e) t !== a && Pg(t) && o.add(t);
|
|
22416
22427
|
let s = Array.from(o);
|
|
22417
22428
|
return s.sort((e, t) => {
|
|
22418
22429
|
if (e === t) return 0;
|
|
@@ -22420,7 +22431,7 @@ function Cg(e, t, n) {
|
|
|
22420
22431
|
return n & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : n & Node.DOCUMENT_POSITION_PRECEDING ? 1 : 0;
|
|
22421
22432
|
}), s;
|
|
22422
22433
|
}
|
|
22423
|
-
function
|
|
22434
|
+
function Ig(e, t) {
|
|
22424
22435
|
try {
|
|
22425
22436
|
if (!e?.getBoundingClientRect || !t?.getBoundingClientRect) return Infinity;
|
|
22426
22437
|
let n = e.getBoundingClientRect(), r = t.getBoundingClientRect(), i = {
|
|
@@ -22435,17 +22446,17 @@ function wg(e, t) {
|
|
|
22435
22446
|
return Infinity;
|
|
22436
22447
|
}
|
|
22437
22448
|
}
|
|
22438
|
-
function
|
|
22449
|
+
function Lg(e) {
|
|
22439
22450
|
if (!e || typeof e != "string") return null;
|
|
22440
22451
|
let t = null;
|
|
22441
|
-
return
|
|
22452
|
+
return yg((n) => {
|
|
22442
22453
|
try {
|
|
22443
22454
|
let r = n.getElementById(e);
|
|
22444
|
-
r && !
|
|
22455
|
+
r && !hg(r) && r.matches?.("input, select, textarea") && (t = r);
|
|
22445
22456
|
} catch {}
|
|
22446
22457
|
}), t;
|
|
22447
22458
|
}
|
|
22448
|
-
function
|
|
22459
|
+
function Rg(e, t) {
|
|
22449
22460
|
let n = String(t ?? "").trim();
|
|
22450
22461
|
if (!n) return null;
|
|
22451
22462
|
let r = n.match(/^name:\s*([\w.-]+)$/i);
|
|
@@ -22455,12 +22466,12 @@ function Eg(e, t) {
|
|
|
22455
22466
|
}
|
|
22456
22467
|
let i = n.match(/^id:\s*([\w.-]+)$/i);
|
|
22457
22468
|
if (i) {
|
|
22458
|
-
let e =
|
|
22469
|
+
let e = Lg(i[1]);
|
|
22459
22470
|
if (e) return e;
|
|
22460
22471
|
}
|
|
22461
22472
|
let a = n.startsWith("#") ? n.slice(1) : n;
|
|
22462
22473
|
if (/^[\w-]+$/.test(a)) {
|
|
22463
|
-
let e =
|
|
22474
|
+
let e = Lg(a);
|
|
22464
22475
|
if (e) return e;
|
|
22465
22476
|
}
|
|
22466
22477
|
let o = n.toLowerCase().replace(/\s+/g, " ");
|
|
@@ -22470,7 +22481,7 @@ function Eg(e, t) {
|
|
|
22470
22481
|
}
|
|
22471
22482
|
return null;
|
|
22472
22483
|
}
|
|
22473
|
-
function
|
|
22484
|
+
function zg(e, t) {
|
|
22474
22485
|
let n = String(t || "").toLowerCase().trim();
|
|
22475
22486
|
if (!n) return 0;
|
|
22476
22487
|
let r = [
|
|
@@ -22487,13 +22498,13 @@ function Dg(e, t) {
|
|
|
22487
22498
|
for (let e of i) r.includes(e) && (a += 1);
|
|
22488
22499
|
return a / i.length * 92;
|
|
22489
22500
|
}
|
|
22490
|
-
function
|
|
22501
|
+
function Bg(e, t) {
|
|
22491
22502
|
let n = [];
|
|
22492
|
-
|
|
22503
|
+
yg((e) => {
|
|
22493
22504
|
n.push(...Array.from(e.querySelectorAll("button, [role=\"button\"], input[type=\"submit\"], input[type=\"button\"]")).filter((e) => {
|
|
22494
|
-
if (
|
|
22505
|
+
if (hg(e) || e.disabled) return !1;
|
|
22495
22506
|
try {
|
|
22496
|
-
let t =
|
|
22507
|
+
let t = vg(e);
|
|
22497
22508
|
if (t.display === "none" || t.visibility === "hidden" || parseFloat(t.opacity) === 0) return !1;
|
|
22498
22509
|
} catch {}
|
|
22499
22510
|
return !0;
|
|
@@ -22501,7 +22512,7 @@ function Og(e, t) {
|
|
|
22501
22512
|
});
|
|
22502
22513
|
let r = 0, i = n.map((t) => ({
|
|
22503
22514
|
el: t,
|
|
22504
|
-
s:
|
|
22515
|
+
s: zg(t, e)
|
|
22505
22516
|
}));
|
|
22506
22517
|
for (let { s: e } of i) e > r && (r = e);
|
|
22507
22518
|
if (r < 36) return null;
|
|
@@ -22511,14 +22522,14 @@ function Og(e, t) {
|
|
|
22511
22522
|
if (o.length) {
|
|
22512
22523
|
let e = a[0], t = Infinity;
|
|
22513
22524
|
for (let n of a) for (let r of o) {
|
|
22514
|
-
let i =
|
|
22525
|
+
let i = Ig(n, r);
|
|
22515
22526
|
i < t && (t = i, e = n);
|
|
22516
22527
|
}
|
|
22517
22528
|
return e;
|
|
22518
22529
|
}
|
|
22519
22530
|
return a[0];
|
|
22520
22531
|
}
|
|
22521
|
-
function
|
|
22532
|
+
function Vg(e) {
|
|
22522
22533
|
if (e == null) return {};
|
|
22523
22534
|
if (typeof e == "string") {
|
|
22524
22535
|
let t = e.trim();
|
|
@@ -22531,8 +22542,8 @@ function kg(e) {
|
|
|
22531
22542
|
}
|
|
22532
22543
|
return e;
|
|
22533
22544
|
}
|
|
22534
|
-
function
|
|
22535
|
-
let t =
|
|
22545
|
+
function Hg(e) {
|
|
22546
|
+
let t = Vg(e);
|
|
22536
22547
|
if (Array.isArray(t) && t.length > 0) {
|
|
22537
22548
|
let e = t[0];
|
|
22538
22549
|
if (e?.field_key != null || e?.fieldKey != null) return t.map((e) => ({
|
|
@@ -22560,12 +22571,12 @@ function Ag(e) {
|
|
|
22560
22571
|
value: e?.value ?? e?.Value
|
|
22561
22572
|
})) : [];
|
|
22562
22573
|
}
|
|
22563
|
-
function
|
|
22574
|
+
function Ug(e) {
|
|
22564
22575
|
if (!e || typeof e != "string") return e;
|
|
22565
22576
|
let t = e.trim();
|
|
22566
22577
|
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);
|
|
22567
22578
|
}
|
|
22568
|
-
function
|
|
22579
|
+
function Wg(e) {
|
|
22569
22580
|
if (!e || typeof e != "string") return e;
|
|
22570
22581
|
let t = {
|
|
22571
22582
|
zero: "0",
|
|
@@ -22584,7 +22595,7 @@ function Mg(e) {
|
|
|
22584
22595
|
for (let [e, r] of Object.entries(t)) n = n.replace(RegExp(`\\b${e}\\b`, "g"), r);
|
|
22585
22596
|
return n = n.replace(/[^\d+]/g, ""), n;
|
|
22586
22597
|
}
|
|
22587
|
-
function
|
|
22598
|
+
function Gg(e) {
|
|
22588
22599
|
if (!e || typeof e != "string") return [];
|
|
22589
22600
|
let t = e.trim();
|
|
22590
22601
|
if (!t || /\b[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,}\b/i.test(t)) return [];
|
|
@@ -22603,7 +22614,7 @@ function Ng(e) {
|
|
|
22603
22614
|
}
|
|
22604
22615
|
return [];
|
|
22605
22616
|
}
|
|
22606
|
-
function
|
|
22617
|
+
function Kg(e) {
|
|
22607
22618
|
if (!e || typeof e != "string") return [];
|
|
22608
22619
|
let t = e.trim();
|
|
22609
22620
|
if (!t) return [];
|
|
@@ -22615,7 +22626,7 @@ function Pg(e) {
|
|
|
22615
22626
|
field_key: e,
|
|
22616
22627
|
value: i
|
|
22617
22628
|
}));
|
|
22618
|
-
}, o =
|
|
22629
|
+
}, o = Ug(t), s = i.test(o), c = o.match(/^\s*([a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,})\s*$/i);
|
|
22619
22630
|
if (c) return a("Email Address", c[1]), n;
|
|
22620
22631
|
if (!i.test(t) && s) {
|
|
22621
22632
|
let e = o.match(i);
|
|
@@ -22643,17 +22654,17 @@ function Pg(e) {
|
|
|
22643
22654
|
}
|
|
22644
22655
|
return n;
|
|
22645
22656
|
}
|
|
22646
|
-
function
|
|
22657
|
+
function qg(e) {
|
|
22647
22658
|
if (!e || typeof e != "object") return null;
|
|
22648
22659
|
let t = e.url ?? e.target_url ?? e.page_url ?? e.pageUrl ?? e.link ?? e.href ?? e.path;
|
|
22649
22660
|
return t == null ? null : String(t).trim() || null;
|
|
22650
22661
|
}
|
|
22651
|
-
function
|
|
22662
|
+
function Jg(e) {
|
|
22652
22663
|
if (!e || typeof e != "object") return null;
|
|
22653
22664
|
let t = e.query ?? e.q ?? e.search ?? e.text ?? e.keywords;
|
|
22654
22665
|
return t == null ? null : String(t).trim() || null;
|
|
22655
22666
|
}
|
|
22656
|
-
function
|
|
22667
|
+
function Yg(e) {
|
|
22657
22668
|
let t = e.ownerDocument?.defaultView || window, n = e.tagName === "TEXTAREA" ? t.HTMLTextAreaElement.prototype : t.HTMLInputElement.prototype, r = Object.getOwnPropertyDescriptor(n, "value");
|
|
22658
22669
|
return (e, t) => {
|
|
22659
22670
|
try {
|
|
@@ -22662,7 +22673,7 @@ function Lg(e) {
|
|
|
22662
22673
|
r?.set ? r.set.call(e, t) : e.value = t;
|
|
22663
22674
|
};
|
|
22664
22675
|
}
|
|
22665
|
-
async function
|
|
22676
|
+
async function Xg(e, t, n) {
|
|
22666
22677
|
if (!n?.skipScroll) try {
|
|
22667
22678
|
e.scrollIntoView({
|
|
22668
22679
|
behavior: "smooth",
|
|
@@ -22675,10 +22686,10 @@ async function Rg(e, t, n) {
|
|
|
22675
22686
|
} catch {}
|
|
22676
22687
|
}
|
|
22677
22688
|
try {
|
|
22678
|
-
await
|
|
22689
|
+
await ug(e);
|
|
22679
22690
|
} catch {}
|
|
22680
22691
|
try {
|
|
22681
|
-
|
|
22692
|
+
sg(e);
|
|
22682
22693
|
} catch {}
|
|
22683
22694
|
await new Promise((e) => setTimeout(e, 180));
|
|
22684
22695
|
try {
|
|
@@ -22693,15 +22704,33 @@ async function Rg(e, t, n) {
|
|
|
22693
22704
|
cancelable: !0,
|
|
22694
22705
|
composed: !0
|
|
22695
22706
|
};
|
|
22696
|
-
if (r === "SELECT") return e.value = String(t), e.dispatchEvent(new Event("input", a)), e.dispatchEvent(new Event("change", a)), e.dispatchEvent(new Event("blur", a)),
|
|
22707
|
+
if (r === "SELECT") return e.value = String(t), e.dispatchEvent(new Event("input", a)), e.dispatchEvent(new Event("change", a)), e.dispatchEvent(new Event("blur", a)), cg(e), !0;
|
|
22697
22708
|
if (i === "checkbox" || i === "radio") return e.checked = [
|
|
22698
22709
|
"1",
|
|
22699
22710
|
"true",
|
|
22700
22711
|
"yes",
|
|
22701
22712
|
"on"
|
|
22702
|
-
].includes(String(t).toLowerCase().trim()), e.dispatchEvent(new Event("input", a)), e.dispatchEvent(new Event("change", a)),
|
|
22713
|
+
].includes(String(t).toLowerCase().trim()), e.dispatchEvent(new Event("input", a)), e.dispatchEvent(new Event("change", a)), cg(e), !0;
|
|
22703
22714
|
let o = String(t);
|
|
22704
|
-
r === "INPUT" || r === "TEXTAREA"
|
|
22715
|
+
if (r === "INPUT" || r === "TEXTAREA") {
|
|
22716
|
+
let t = Yg(e);
|
|
22717
|
+
try {
|
|
22718
|
+
await eg(e, o, t);
|
|
22719
|
+
} catch {
|
|
22720
|
+
t(e, o);
|
|
22721
|
+
}
|
|
22722
|
+
e.value !== o && t(e, o);
|
|
22723
|
+
} else e.value = o;
|
|
22724
|
+
try {
|
|
22725
|
+
e.dispatchEvent(new InputEvent("input", {
|
|
22726
|
+
...a,
|
|
22727
|
+
inputType: "insertText",
|
|
22728
|
+
data: o
|
|
22729
|
+
}));
|
|
22730
|
+
} catch {
|
|
22731
|
+
e.dispatchEvent(new Event("input", a));
|
|
22732
|
+
}
|
|
22733
|
+
e.dispatchEvent(new Event("change", a)), e.dispatchEvent(new Event("blur", a));
|
|
22705
22734
|
try {
|
|
22706
22735
|
e.focus({ preventScroll: !0 });
|
|
22707
22736
|
} catch {}
|
|
@@ -22712,16 +22741,13 @@ async function Rg(e, t, n) {
|
|
|
22712
22741
|
} catch {}
|
|
22713
22742
|
});
|
|
22714
22743
|
} catch {}
|
|
22715
|
-
|
|
22716
|
-
Gh(e);
|
|
22717
|
-
} catch {}
|
|
22718
|
-
return !0;
|
|
22744
|
+
return cg(e), !0;
|
|
22719
22745
|
}
|
|
22720
|
-
function
|
|
22746
|
+
function Zg(e) {
|
|
22721
22747
|
let t = e.siteId || null, n = (e.apiBaseUrl || "").replace(/\/$/, ""), r = typeof e.getLastUserVoiceText == "function" ? e.getLastUserVoiceText : null, i = [], a = null, o = {
|
|
22722
22748
|
navigate_to_page: async (n) => {
|
|
22723
22749
|
$("navigate_to_page ▶ raw parameters:", n);
|
|
22724
|
-
let r =
|
|
22750
|
+
let r = Vg(n), i = qg(r), a = r.section_text ?? r.sectionText ?? r.section;
|
|
22725
22751
|
if ($("navigate_to_page · coerced:", {
|
|
22726
22752
|
url: i,
|
|
22727
22753
|
sectionText: a
|
|
@@ -22729,16 +22755,16 @@ function zg(e) {
|
|
|
22729
22755
|
let e = "Missing url: pass a string url, path like /pricing, or JSON with a url field.";
|
|
22730
22756
|
return $("navigate_to_page ✖", e), e;
|
|
22731
22757
|
}
|
|
22732
|
-
if (
|
|
22758
|
+
if (rg(`Navigating to ${i.replace(/^https?:\/\/[^/]+/, "") || "/"}…`), ag(), !await ln(i, {
|
|
22733
22759
|
siteId: t,
|
|
22734
22760
|
apiBaseUrl: e.apiBaseUrl
|
|
22735
22761
|
})) {
|
|
22736
|
-
|
|
22762
|
+
og(), ig(200);
|
|
22737
22763
|
let e = "That page is not available in the site index; answer without navigating.";
|
|
22738
22764
|
return $("navigate_to_page ✖ blocked", e), e;
|
|
22739
22765
|
}
|
|
22740
22766
|
try {
|
|
22741
|
-
if ($("navigate_to_page → shadowNavigate", i), await dn(i, { sectionText: a || void 0 }), await new Promise((e) => setTimeout(e, 600)),
|
|
22767
|
+
if ($("navigate_to_page → shadowNavigate", i), await dn(i, { sectionText: a || void 0 }), await new Promise((e) => setTimeout(e, 600)), og(), ig(300), a && typeof a == "string") {
|
|
22742
22768
|
let e = rn(null, a);
|
|
22743
22769
|
e && an(e), $("navigate_to_page · highlight", {
|
|
22744
22770
|
sectionText: a,
|
|
@@ -22747,7 +22773,7 @@ function zg(e) {
|
|
|
22747
22773
|
}
|
|
22748
22774
|
let e = "";
|
|
22749
22775
|
try {
|
|
22750
|
-
let t =
|
|
22776
|
+
let t = Cg(), n = wg();
|
|
22751
22777
|
if (t.length > 0) {
|
|
22752
22778
|
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(", ");
|
|
22753
22779
|
e = ` This page has a form with fields: [${r}]` + (i ? ` and buttons: [${i}].` : ".") + " Call list_page_forms then start filling.";
|
|
@@ -22756,22 +22782,22 @@ function zg(e) {
|
|
|
22756
22782
|
let t = `OK_NAVIGATION ${i}${e}`;
|
|
22757
22783
|
return $("navigate_to_page ✓", t), t;
|
|
22758
22784
|
} catch (e) {
|
|
22759
|
-
|
|
22785
|
+
og(), ig(200);
|
|
22760
22786
|
let t = `Navigation error: ${e?.message || String(e)}`;
|
|
22761
22787
|
return $("navigate_to_page ✖", t), t;
|
|
22762
22788
|
}
|
|
22763
22789
|
},
|
|
22764
22790
|
highlight_on_page: async (e) => {
|
|
22765
22791
|
$("highlight_on_page ▶", e);
|
|
22766
|
-
let t =
|
|
22792
|
+
let t = Vg(e), n = t?.section_id || t?.sectionId, r = t?.section_text || t?.sectionText, i = rn(n || null, r || null);
|
|
22767
22793
|
return i ? (an(i), $("highlight_on_page ✓"), "Highlighted the section.") : ($("highlight_on_page ✖ no element"), "Could not find that section on the page.");
|
|
22768
22794
|
},
|
|
22769
22795
|
search_site_content: async (e) => {
|
|
22770
22796
|
$("search_site_content ▶", e);
|
|
22771
|
-
let r =
|
|
22772
|
-
if ($("search_site_content · query:", r, "siteId:", t, "apiBase:", n || "(empty)"),
|
|
22773
|
-
if (!t) return
|
|
22774
|
-
if (!n) return
|
|
22797
|
+
let r = Jg(Vg(e));
|
|
22798
|
+
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.";
|
|
22799
|
+
if (!t) return ig(), $("search_site_content ✖ no siteId"), "Site is not configured for search.";
|
|
22800
|
+
if (!n) return ig(), $("search_site_content ✖ no api base"), "API base URL is missing; cannot search.";
|
|
22775
22801
|
try {
|
|
22776
22802
|
let e = `${n}/api/site-tools/search`;
|
|
22777
22803
|
$("search_site_content → POST", e);
|
|
@@ -22784,25 +22810,25 @@ function zg(e) {
|
|
|
22784
22810
|
currentUrl: typeof window < "u" ? window.location.href : ""
|
|
22785
22811
|
})
|
|
22786
22812
|
}), a = await i.json();
|
|
22787
|
-
if ($("search_site_content · HTTP", i.status, "success:", a.success),
|
|
22813
|
+
if ($("search_site_content · HTTP", i.status, "success:", a.success), ig(200), !a.success) {
|
|
22788
22814
|
let e = a.error || "Search failed.";
|
|
22789
22815
|
return $("search_site_content ✖", e), e;
|
|
22790
22816
|
}
|
|
22791
22817
|
let o = a.results || [];
|
|
22792
22818
|
return $("search_site_content ✓", `${o.length} result(s)`, o.slice(0, 3).map((e) => e?.url || e)), JSON.stringify(o);
|
|
22793
22819
|
} catch (e) {
|
|
22794
|
-
|
|
22820
|
+
ig();
|
|
22795
22821
|
let t = `Search error: ${e.message || "network"}`;
|
|
22796
22822
|
return $("search_site_content ✖", t), t;
|
|
22797
22823
|
}
|
|
22798
22824
|
},
|
|
22799
|
-
end_voice_session: async () => ($("end_voice_session ▶"),
|
|
22825
|
+
end_voice_session: async () => ($("end_voice_session ▶"), rg("Ending voice session…", {
|
|
22800
22826
|
icon: "👋",
|
|
22801
22827
|
spinner: !1,
|
|
22802
22828
|
duration: 2e3
|
|
22803
|
-
}),
|
|
22829
|
+
}), dg(!0), lg(), typeof e.requestEndSession == "function" && e.requestEndSession(), "Voice session is ending."),
|
|
22804
22830
|
list_page_forms: async () => {
|
|
22805
|
-
let e =
|
|
22831
|
+
let e = Cg(), t = wg();
|
|
22806
22832
|
return $("list_page_forms ✓", `${e.length} field(s)`, `${t.length} button(s)`), a = null, JSON.stringify({
|
|
22807
22833
|
fields: e,
|
|
22808
22834
|
buttons: t,
|
|
@@ -22812,60 +22838,60 @@ function zg(e) {
|
|
|
22812
22838
|
fill_form_fields: async (e) => {
|
|
22813
22839
|
try {
|
|
22814
22840
|
$("fill_form_fields ▶ raw:", e);
|
|
22815
|
-
let t =
|
|
22841
|
+
let t = Hg(e);
|
|
22816
22842
|
if (!t.length && r) {
|
|
22817
|
-
let e = r(), n =
|
|
22818
|
-
n.length ? $("fill_form_fields · inferred URL from last user utterance (model omitted usable fields):", n) : (n =
|
|
22843
|
+
let e = r(), n = Gg(e);
|
|
22844
|
+
n.length ? $("fill_form_fields · inferred URL from last user utterance (model omitted usable fields):", n) : (n = Kg(e), n.length && $("fill_form_fields · inferred contact fields from last user utterance (empty tool params):", n)), n.length && (t = n);
|
|
22819
22845
|
}
|
|
22820
22846
|
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.";
|
|
22821
|
-
t.length > 1 &&
|
|
22847
|
+
t.length > 1 && rg(`Filling ${t.length} fields…`);
|
|
22822
22848
|
let n = [];
|
|
22823
22849
|
for (let e of t) {
|
|
22824
22850
|
let t = e?.field_key ?? e?.fieldKey, r = e?.value;
|
|
22825
22851
|
if (t == null || r == null) continue;
|
|
22826
22852
|
let o = String(t).toLowerCase();
|
|
22827
|
-
/email|e-mail|mail/.test(o) ? r =
|
|
22828
|
-
let s =
|
|
22853
|
+
/email|e-mail|mail/.test(o) ? r = Ug(r) : /phone|mobile|tel|cell/.test(o) && (r = Wg(r)), rg(`Filling ${t}…`), $("fill_form_fields · processing field:", t, "=", r);
|
|
22854
|
+
let s = Sg(), c = s;
|
|
22829
22855
|
if (a) {
|
|
22830
|
-
let e = s.filter((e) =>
|
|
22856
|
+
let e = s.filter((e) => gg(e) === a);
|
|
22831
22857
|
e.length > 0 && (c = e, $("fill_form_fields · scoped to active form, inputs:", e.length));
|
|
22832
22858
|
}
|
|
22833
22859
|
$("fill_form_fields · visible inputs count:", s.length, "scoped:", c.length);
|
|
22834
22860
|
let l = !1;
|
|
22835
22861
|
for (let e of [c, ...c === s ? [] : [s]]) {
|
|
22836
|
-
let o =
|
|
22862
|
+
let o = Fg(e, String(t), r);
|
|
22837
22863
|
if (o.length) {
|
|
22838
|
-
for (let e = 0; e < o.length; e++) await
|
|
22839
|
-
i = o, a =
|
|
22864
|
+
for (let e = 0; e < o.length; e++) await Xg(o[e], r, { skipScroll: e > 0 }), await new Promise((e) => setTimeout(e, 80));
|
|
22865
|
+
i = o, a = gg(o[0]) || a, n.push(String(t)), l = !0;
|
|
22840
22866
|
break;
|
|
22841
22867
|
}
|
|
22842
|
-
let s =
|
|
22843
|
-
if (s ||=
|
|
22844
|
-
await
|
|
22868
|
+
let s = Rg(e, String(t));
|
|
22869
|
+
if (s ||= kg(e, String(t)), s ||= Ag(e, String(t), r), s) {
|
|
22870
|
+
await Xg(s, r), i = [s], a = gg(s) || a, n.push(String(t)), l = !0;
|
|
22845
22871
|
break;
|
|
22846
22872
|
}
|
|
22847
22873
|
}
|
|
22848
22874
|
l || $("fill_form_fields · no match for field:", t);
|
|
22849
22875
|
}
|
|
22850
|
-
|
|
22876
|
+
ig(400);
|
|
22851
22877
|
try {
|
|
22852
|
-
|
|
22878
|
+
dg();
|
|
22853
22879
|
} catch {}
|
|
22854
22880
|
if (!n.length) return $("fill_form_fields ✖ no matches"), "Could not match any fields. Call list_page_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.";
|
|
22855
22881
|
let o = `OK_FILLED: ${n.join(", ")}`;
|
|
22856
22882
|
return $("fill_form_fields ✓", o), o;
|
|
22857
22883
|
} catch (e) {
|
|
22858
|
-
|
|
22884
|
+
ig(), lg(), dg(!0);
|
|
22859
22885
|
let t = `fill_form_fields error: ${e?.message || String(e)}`;
|
|
22860
22886
|
return $("fill_form_fields ✖", t), t;
|
|
22861
22887
|
}
|
|
22862
22888
|
},
|
|
22863
22889
|
click_page_button: async (e) => {
|
|
22864
|
-
let t =
|
|
22890
|
+
let t = Vg(e), n = (t.button_text ?? t.buttonText ?? t.text ?? "").trim();
|
|
22865
22891
|
if ($("click_page_button ▶", n), !n) return "Missing button_text: pass the visible label, e.g. Conduct Audit.";
|
|
22866
|
-
|
|
22867
|
-
let r =
|
|
22868
|
-
if (!r) return
|
|
22892
|
+
rg(`Clicking "${n}"…`);
|
|
22893
|
+
let r = Bg(n, i);
|
|
22894
|
+
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.`;
|
|
22869
22895
|
try {
|
|
22870
22896
|
try {
|
|
22871
22897
|
r.scrollIntoView({
|
|
@@ -22877,41 +22903,41 @@ function zg(e) {
|
|
|
22877
22903
|
r.scrollIntoView(!0);
|
|
22878
22904
|
}
|
|
22879
22905
|
try {
|
|
22880
|
-
await
|
|
22906
|
+
await ug(r);
|
|
22881
22907
|
} catch {}
|
|
22882
22908
|
try {
|
|
22883
|
-
|
|
22909
|
+
pg(r);
|
|
22884
22910
|
} catch {}
|
|
22885
22911
|
try {
|
|
22886
|
-
await
|
|
22912
|
+
await fg(r);
|
|
22887
22913
|
} catch {}
|
|
22888
|
-
let e =
|
|
22914
|
+
let e = gg(r) || a, t = [];
|
|
22889
22915
|
if (e) {
|
|
22890
|
-
let n = Array.from(e.querySelectorAll("input[required], textarea[required], select[required]")).filter((e) => !
|
|
22916
|
+
let n = Array.from(e.querySelectorAll("input[required], textarea[required], select[required]")).filter((e) => !hg(e));
|
|
22891
22917
|
for (let e of n) if (!(e.value || "").trim()) {
|
|
22892
|
-
let n =
|
|
22918
|
+
let n = xg(e) || e.placeholder || e.name || e.type;
|
|
22893
22919
|
t.push(n);
|
|
22894
22920
|
}
|
|
22895
22921
|
}
|
|
22896
22922
|
if (t.length > 0) {
|
|
22897
|
-
|
|
22923
|
+
ig(200);
|
|
22898
22924
|
try {
|
|
22899
|
-
|
|
22925
|
+
dg();
|
|
22900
22926
|
} catch {}
|
|
22901
22927
|
let e = `Cannot submit — these required fields are still empty: ${t.join(", ")}. Fill them first with fill_form_fields, then click again.`;
|
|
22902
22928
|
return $("click_page_button ✖ empty required fields:", t), e;
|
|
22903
22929
|
}
|
|
22904
22930
|
r.focus?.(), r.click();
|
|
22905
22931
|
let n = (r.textContent || r.value || r.getAttribute("aria-label") || "").trim().slice(0, 80) || "button";
|
|
22906
|
-
|
|
22932
|
+
ig(600);
|
|
22907
22933
|
try {
|
|
22908
|
-
|
|
22934
|
+
dg();
|
|
22909
22935
|
} catch {}
|
|
22910
|
-
|
|
22936
|
+
lg(), a = null, i = [];
|
|
22911
22937
|
let o = `OK_CLICK ${n}`;
|
|
22912
22938
|
return $("click_page_button ✓", o), o;
|
|
22913
22939
|
} catch (e) {
|
|
22914
|
-
|
|
22940
|
+
ig(200), dg(!0);
|
|
22915
22941
|
let t = `Click failed: ${e?.message || String(e)}`;
|
|
22916
22942
|
return $("click_page_button ✖", t), t;
|
|
22917
22943
|
}
|
|
@@ -22930,7 +22956,7 @@ function zg(e) {
|
|
|
22930
22956
|
}
|
|
22931
22957
|
//#endregion
|
|
22932
22958
|
//#region src/utils/wrapVoiceToolsForLogging.js
|
|
22933
|
-
function
|
|
22959
|
+
function Qg(e) {
|
|
22934
22960
|
return !e || typeof e != "object" ? e : Object.fromEntries(Object.entries(e).map(([e, t]) => [e, async (n) => {
|
|
22935
22961
|
let r = Zt();
|
|
22936
22962
|
r ? console.log("[FlowEngage:voice-tool] ▶", e, n) : console.info(`[FlowEngage] voice tool » ${e}`);
|
|
@@ -22940,22 +22966,22 @@ function Bg(e) {
|
|
|
22940
22966
|
}
|
|
22941
22967
|
//#endregion
|
|
22942
22968
|
//#region src/components/VoiceInterface.jsx
|
|
22943
|
-
var
|
|
22969
|
+
var $g = {
|
|
22944
22970
|
idle: "rgba(99,102,241,0.18)",
|
|
22945
22971
|
listening: "rgba(16,185,129,0.25)",
|
|
22946
22972
|
speaking: "rgba(245,158,11,0.25)",
|
|
22947
22973
|
error: "rgba(239,68,68,0.2)"
|
|
22948
|
-
},
|
|
22974
|
+
}, e_ = {
|
|
22949
22975
|
idle: "#6366f1",
|
|
22950
22976
|
listening: "#10b981",
|
|
22951
22977
|
speaking: "#f59e0b",
|
|
22952
22978
|
error: "#ef4444"
|
|
22953
22979
|
};
|
|
22954
|
-
function
|
|
22980
|
+
function t_(e, t) {
|
|
22955
22981
|
let n = (t || "").trim();
|
|
22956
22982
|
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;
|
|
22957
22983
|
}
|
|
22958
|
-
function
|
|
22984
|
+
function n_({ agentId: e, chatId: t, siteId: r, apiBaseUrl: a, onEnd: c, historyRef: d, hasSyncedRef: f, onMessageSync: p, onStartSync: m }) {
|
|
22959
22985
|
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 () => {
|
|
22960
22986
|
try {
|
|
22961
22987
|
await re.current?.endSession?.();
|
|
@@ -22972,7 +22998,7 @@ function Wg({ agentId: e, chatId: t, siteId: r, apiBaseUrl: a, onEnd: c, history
|
|
|
22972
22998
|
try {
|
|
22973
22999
|
if (await navigator.mediaDevices.getUserMedia({ audio: !0 }), t) return;
|
|
22974
23000
|
d.current = [], ae.current = "", se.current = !1;
|
|
22975
|
-
let i =
|
|
23001
|
+
let i = Qg(Zg({
|
|
22976
23002
|
siteId: r || null,
|
|
22977
23003
|
apiBaseUrl: a || null,
|
|
22978
23004
|
getLastUserVoiceText: () => ae.current,
|
|
@@ -22999,7 +23025,7 @@ function Wg({ agentId: e, chatId: t, siteId: r, apiBaseUrl: a, onEnd: c, history
|
|
|
22999
23025
|
message: r,
|
|
23000
23026
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
23001
23027
|
};
|
|
23002
|
-
n === "user" && (ae.current = r), d.current = [...d.current, i],
|
|
23028
|
+
n === "user" && (ae.current = r), d.current = [...d.current, i], t_(n, r) && queueMicrotask(() => {
|
|
23003
23029
|
se.current || (se.current = !0, oe.current?.());
|
|
23004
23030
|
});
|
|
23005
23031
|
},
|
|
@@ -23022,12 +23048,7 @@ function Wg({ agentId: e, chatId: t, siteId: r, apiBaseUrl: a, onEnd: c, history
|
|
|
23022
23048
|
} catch {
|
|
23023
23049
|
t = "[]";
|
|
23024
23050
|
}
|
|
23025
|
-
|
|
23026
|
-
try {
|
|
23027
|
-
let e = await i.search_site_content({ query: "pages" }), t = typeof e == "string" ? JSON.parse(e) : e;
|
|
23028
|
-
Array.isArray(t) && t.length && (n = ` Site pages available: ${t.map((e) => `${e.title || ""} (${e.url || ""})`).join(", ")}.`);
|
|
23029
|
-
} catch {}
|
|
23030
|
-
o.sendContextualUpdate(`Current page URL: ${e}. Site ID: ${r || "unknown"}. Page fields/buttons JSON: ${t}.${n} Navigation: when the user wants to go to any page (contact, pricing, about, services, etc.), call search_site_content then navigate_to_page immediately — never ask permission. After navigating to a page with a form, call list_page_forms and proactively start helping the user fill it. Forms: use fill_form_fields then click_page_button (e.g. Conduct Audit, Send Message) when the user wants to submit. Fill each field immediately after the user answers — never skip ahead. Voice: if the user wants to end the voice session, call end_voice_session or confirm and end.`);
|
|
23051
|
+
o.sendContextualUpdate(`Current page URL: ${e}. Site ID: ${r || "unknown"}. Page fields/buttons JSON: ${t}. Navigation: when the user wants to go to any page (contact, pricing, about, services, etc.), call search_site_content then navigate_to_page immediately — never ask permission. After navigating to a page with a form, call list_page_forms and proactively start helping the user fill it. Forms: use fill_form_fields then click_page_button (e.g. Conduct Audit, Send Message) when the user wants to submit. Fill each field immediately after the user answers — never skip ahead. Voice: if the user wants to end the voice session, call end_voice_session or confirm and end.`);
|
|
23031
23052
|
} catch {}
|
|
23032
23053
|
typeof m == "function" && m();
|
|
23033
23054
|
} catch (e) {
|
|
@@ -23043,7 +23064,7 @@ function Wg({ agentId: e, chatId: t, siteId: r, apiBaseUrl: a, onEnd: c, history
|
|
|
23043
23064
|
d,
|
|
23044
23065
|
m
|
|
23045
23066
|
]);
|
|
23046
|
-
let ce = h === "listening" || h === "speaking", le =
|
|
23067
|
+
let ce = h === "listening" || h === "speaking", le = e_[h] || e_.idle, ue = $g[h] || $g.idle;
|
|
23047
23068
|
return /* @__PURE__ */ u("div", {
|
|
23048
23069
|
ref: ie,
|
|
23049
23070
|
style: {
|
|
@@ -23149,7 +23170,7 @@ function Wg({ agentId: e, chatId: t, siteId: r, apiBaseUrl: a, onEnd: c, history
|
|
|
23149
23170
|
}
|
|
23150
23171
|
//#endregion
|
|
23151
23172
|
//#region src/components/FlowEngageWidget.jsx
|
|
23152
|
-
var
|
|
23173
|
+
var r_ = [
|
|
23153
23174
|
{
|
|
23154
23175
|
key: "become_client",
|
|
23155
23176
|
label: "Become a Client"
|
|
@@ -23170,7 +23191,7 @@ var Gg = [
|
|
|
23170
23191
|
key: "looking_for_job",
|
|
23171
23192
|
label: "Looking for a Job"
|
|
23172
23193
|
}
|
|
23173
|
-
],
|
|
23194
|
+
], i_ = () => /* @__PURE__ */ l("div", {
|
|
23174
23195
|
style: {
|
|
23175
23196
|
display: "flex",
|
|
23176
23197
|
marginBottom: "12px",
|
|
@@ -23201,7 +23222,7 @@ var Gg = [
|
|
|
23201
23222
|
} }, 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 " })]
|
|
23202
23223
|
})
|
|
23203
23224
|
});
|
|
23204
|
-
function
|
|
23225
|
+
function a_() {
|
|
23205
23226
|
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("");
|
|
23206
23227
|
i(() => {
|
|
23207
23228
|
try {
|
|
@@ -23229,7 +23250,7 @@ function qg() {
|
|
|
23229
23250
|
outline: "none",
|
|
23230
23251
|
fontFamily: "ui-sans-serif, system-ui, sans-serif",
|
|
23231
23252
|
...c ? {} : Ue
|
|
23232
|
-
}, Ge = S.recommendations?.[ue] || Re.recommendations?.[ue] ||
|
|
23253
|
+
}, Ge = S.recommendations?.[ue] || Re.recommendations?.[ue] || r_, 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(() => {
|
|
23233
23254
|
let e = o.findIndex((e) => e.sender === "user");
|
|
23234
23255
|
return e === -1 ? !1 : o.slice(e + 1).some((e) => e.sender === "bot" || e.sender === "ai" || e.sender === "agent");
|
|
23235
23256
|
}, [o]), rt = !h && tt && nt;
|
|
@@ -23357,7 +23378,7 @@ function qg() {
|
|
|
23357
23378
|
flexDirection: "column"
|
|
23358
23379
|
},
|
|
23359
23380
|
className: "fe-screen-fade-in",
|
|
23360
|
-
children: /* @__PURE__ */ l(
|
|
23381
|
+
children: /* @__PURE__ */ l(n_, {
|
|
23361
23382
|
agentId: T,
|
|
23362
23383
|
chatId: r,
|
|
23363
23384
|
siteId: Ye,
|
|
@@ -23390,7 +23411,7 @@ function qg() {
|
|
|
23390
23411
|
isAiTyping: ee,
|
|
23391
23412
|
isAgentTyping: g,
|
|
23392
23413
|
setReplyContext: Me,
|
|
23393
|
-
TypingDots:
|
|
23414
|
+
TypingDots: i_,
|
|
23394
23415
|
primaryColor: Ve,
|
|
23395
23416
|
agentHeadshot: $e,
|
|
23396
23417
|
agentDisplayName: p || Ze
|
|
@@ -23469,4 +23490,4 @@ function qg() {
|
|
|
23469
23490
|
}) : null;
|
|
23470
23491
|
}
|
|
23471
23492
|
//#endregion
|
|
23472
|
-
export { vn as FlowEngageProvider,
|
|
23493
|
+
export { vn as FlowEngageProvider, a_ as FlowEngageWidget, Xt as useFlowEngage };
|