@flowengage/react-chatbot 1.0.8 → 1.0.9

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.
@@ -22146,13 +22146,41 @@ function rg(e) {
22146
22146
  }
22147
22147
  }
22148
22148
  function ig(e) {
22149
+ if (!e) return null;
22150
+ try {
22151
+ return e.closest("form");
22152
+ } catch {
22153
+ let t = e.parentElement;
22154
+ for (; t;) {
22155
+ if (t.tagName === "FORM") return t;
22156
+ t = t.parentElement;
22157
+ }
22158
+ return null;
22159
+ }
22160
+ }
22161
+ function ag(e) {
22162
+ if (!e) return null;
22163
+ let t = e.querySelector("h1, h2, h3, h4, h5, legend");
22164
+ if (t) return t.textContent.replace(/\s+/g, " ").trim().slice(0, 60);
22165
+ let n = e.getAttribute("aria-label");
22166
+ if (n) return n.trim().slice(0, 60);
22167
+ let r = e.getAttribute("title");
22168
+ if (r) return r.trim().slice(0, 60);
22169
+ let i = e.previousElementSibling;
22170
+ for (let e = 0; e < 3 && i; e++) {
22171
+ if (/^H[1-5]$/.test(i.tagName)) return i.textContent.replace(/\s+/g, " ").trim().slice(0, 60);
22172
+ i = i.previousElementSibling;
22173
+ }
22174
+ return null;
22175
+ }
22176
+ function og(e) {
22149
22177
  try {
22150
22178
  let t = e.ownerDocument?.defaultView;
22151
22179
  if (t) return t.getComputedStyle(e);
22152
22180
  } catch {}
22153
22181
  return window.getComputedStyle(e);
22154
22182
  }
22155
- function ag(e) {
22183
+ function sg(e) {
22156
22184
  let t = /* @__PURE__ */ new Set();
22157
22185
  function n(r) {
22158
22186
  if (!r || t.has(r)) return;
@@ -22165,10 +22193,10 @@ function ag(e) {
22165
22193
  }
22166
22194
  typeof document < "u" && n(document);
22167
22195
  }
22168
- function og(e) {
22196
+ function cg(e) {
22169
22197
  return e == null ? null : String(e).replace(/\u00a0/g, " ").replace(/\s*\*+\s*$/u, "").replace(/\s+/g, " ").trim();
22170
22198
  }
22171
- function sg(e) {
22199
+ function lg(e) {
22172
22200
  let t = e.ownerDocument || document, n = e.getAttribute("aria-labelledby");
22173
22201
  if (n) {
22174
22202
  let e = n.trim().split(/\s+/).filter(Boolean), r = [];
@@ -22176,40 +22204,40 @@ function sg(e) {
22176
22204
  let e = t.getElementById(n);
22177
22205
  e?.textContent && r.push(e.textContent.trim());
22178
22206
  } catch {}
22179
- if (r.length) return og(r.join(" "));
22207
+ if (r.length) return cg(r.join(" "));
22180
22208
  }
22181
- if (e.labels && e.labels.length) return og(e.labels[0].textContent);
22209
+ if (e.labels && e.labels.length) return cg(e.labels[0].textContent);
22182
22210
  let r = e.id;
22183
22211
  if (r) try {
22184
22212
  let e = t.querySelector(`label[for="${CSS.escape(r)}"]`);
22185
- if (e) return og(e.textContent);
22213
+ if (e) return cg(e.textContent);
22186
22214
  } catch {
22187
22215
  let e = t.querySelector(`label[for="${r.replace(/"/g, "\\\"")}"]`);
22188
- if (e) return og(e.textContent);
22216
+ if (e) return cg(e.textContent);
22189
22217
  }
22190
22218
  let i = e.previousElementSibling;
22191
22219
  for (let e = 0; e < 6 && i; e += 1) {
22192
- if (i.tagName === "LABEL") return og(i.textContent);
22220
+ if (i.tagName === "LABEL") return cg(i.textContent);
22193
22221
  let e = (i.className || "").toString().toLowerCase();
22194
22222
  if (/chakra-form__label|formlabel|field-label|form-label|mui-form-label/.test(e)) {
22195
- let e = og(i.textContent);
22223
+ let e = cg(i.textContent);
22196
22224
  if (e) return e;
22197
22225
  }
22198
22226
  i = i.previousElementSibling;
22199
22227
  }
22200
22228
  let a = e.parentElement;
22201
22229
  for (let e = 0; e < 5 && a; e += 1) {
22202
- if (a.tagName === "LABEL") return og(a.textContent);
22230
+ if (a.tagName === "LABEL") return cg(a.textContent);
22203
22231
  let e = a.querySelector?.(":scope > label, :scope > [class*='FormLabel'], :scope > [class*='form__label']");
22204
- if (e?.textContent) return og(e.textContent);
22232
+ if (e?.textContent) return cg(e.textContent);
22205
22233
  a = a.parentElement;
22206
22234
  }
22207
22235
  let o = e.getAttribute("aria-label");
22208
- return o ? og(o) : null;
22236
+ return o ? cg(o) : null;
22209
22237
  }
22210
- function cg() {
22238
+ function ug() {
22211
22239
  let e = [];
22212
- return ag((t) => {
22240
+ return sg((t) => {
22213
22241
  e.push(...Array.from(t.querySelectorAll("input, select, textarea")).filter((e) => {
22214
22242
  if (rg(e)) return !1;
22215
22243
  let t = (e.type || "").toLowerCase();
@@ -22220,7 +22248,7 @@ function cg() {
22220
22248
  "image"
22221
22249
  ].includes(t) || e.disabled || e.readOnly) return !1;
22222
22250
  try {
22223
- let t = ig(e);
22251
+ let t = og(e);
22224
22252
  if (t.display === "none" || t.visibility === "hidden" || parseFloat(t.opacity) === 0) return !1;
22225
22253
  } catch {}
22226
22254
  try {
@@ -22230,25 +22258,32 @@ function cg() {
22230
22258
  }));
22231
22259
  }), e;
22232
22260
  }
22233
- function lg() {
22234
- return cg().map((e, t) => ({
22235
- formIndex: 0,
22236
- fieldIndex: t,
22237
- tag: e.tagName,
22238
- type: e.type || "text",
22239
- name: e.name || null,
22240
- id: e.id || null,
22241
- label: sg(e),
22242
- placeholder: e.placeholder || null
22243
- }));
22261
+ function dg() {
22262
+ let e = ug(), t = /* @__PURE__ */ new Map(), n = 0;
22263
+ return e.map((e, r) => {
22264
+ let i = ig(e), a = i || "__orphan__";
22265
+ t.has(a) || t.set(a, n++);
22266
+ let o = t.get(a);
22267
+ return {
22268
+ formIndex: o,
22269
+ formName: (i ? ag(i) : null) || `Form ${o}`,
22270
+ fieldIndex: r,
22271
+ tag: e.tagName,
22272
+ type: e.type || "text",
22273
+ name: e.name || null,
22274
+ id: e.id || null,
22275
+ label: lg(e),
22276
+ placeholder: e.placeholder || null
22277
+ };
22278
+ });
22244
22279
  }
22245
- function ug() {
22280
+ function fg() {
22246
22281
  let e = [];
22247
- return ag((t) => {
22282
+ return sg((t) => {
22248
22283
  e.push(...Array.from(t.querySelectorAll("button, [role=\"button\"], input[type=\"submit\"], input[type=\"button\"]")).filter((e) => {
22249
22284
  if (rg(e) || e.disabled) return !1;
22250
22285
  try {
22251
- let t = ig(e);
22286
+ let t = og(e);
22252
22287
  if (t.display === "none" || t.visibility === "hidden" || parseFloat(t.opacity) === 0) return !1;
22253
22288
  } catch {}
22254
22289
  return !0;
@@ -22260,15 +22295,15 @@ function ug() {
22260
22295
  type: e.type || e.tagName
22261
22296
  }));
22262
22297
  }
22263
- function dg(e) {
22298
+ function pg(e) {
22264
22299
  return String(e || "").toLowerCase().replace(/\u00a0/g, " ").replace(/\*/g, "").replace(/\s+/g, " ").trim();
22265
22300
  }
22266
- function fg(e) {
22267
- let t = dg(e);
22301
+ function mg(e) {
22302
+ let t = pg(e);
22268
22303
  return t = t.replace(/\s+field\s*$/i, "").trim(), t;
22269
22304
  }
22270
- function pg(e, t) {
22271
- let n = fg(t);
22305
+ function hg(e, t) {
22306
+ let n = mg(t);
22272
22307
  if (!n) return 0;
22273
22308
  let r = (e.name || "").toLowerCase(), i = (e.id || "").toLowerCase();
22274
22309
  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;
@@ -22280,12 +22315,12 @@ function pg(e, t) {
22280
22315
  e.name,
22281
22316
  e.id,
22282
22317
  e.placeholder,
22283
- sg(e),
22318
+ lg(e),
22284
22319
  e.getAttribute("aria-label"),
22285
22320
  e.getAttribute("title"),
22286
22321
  e.getAttribute("data-testid"),
22287
22322
  e.getAttribute("autocomplete")
22288
- ].filter(Boolean).map((e) => dg(e)), s = 0;
22323
+ ].filter(Boolean).map((e) => pg(e)), s = 0;
22289
22324
  for (let e of o) {
22290
22325
  if (!e) continue;
22291
22326
  if (e === n) {
@@ -22305,16 +22340,16 @@ function pg(e, t) {
22305
22340
  }
22306
22341
  return s;
22307
22342
  }
22308
- var mg = 22;
22309
- function hg(e, t) {
22343
+ var gg = 22;
22344
+ function _g(e, t) {
22310
22345
  let n = null, r = 0;
22311
22346
  for (let i of e) {
22312
- let e = pg(i, t);
22347
+ let e = hg(i, t);
22313
22348
  e > r && (r = e, n = i);
22314
22349
  }
22315
- return !n || r < mg ? null : n;
22350
+ return !n || r < gg ? null : n;
22316
22351
  }
22317
- function gg(e, t, n) {
22352
+ function vg(e, t, n) {
22318
22353
  let r = String(t || "").toLowerCase().trim(), i = String(n || "").trim();
22319
22354
  if (!(/^https?:\/\//i.test(i) || /\.\w{2,}(\/|\s|$)/.test(i) || r.includes("url") || r.includes("website") || r.includes("domain") || r.includes("site"))) return null;
22320
22355
  let a = null, o = 0;
@@ -22334,7 +22369,7 @@ function gg(e, t, n) {
22334
22369
  t.name,
22335
22370
  t.id,
22336
22371
  t.placeholder,
22337
- sg(t),
22372
+ lg(t),
22338
22373
  t.getAttribute("aria-label"),
22339
22374
  t.getAttribute("autocomplete")
22340
22375
  ].filter(Boolean).join(" ").toLowerCase();
@@ -22342,15 +22377,15 @@ function gg(e, t, n) {
22342
22377
  }
22343
22378
  return !a || o < 42 ? null : a;
22344
22379
  }
22345
- function _g(e) {
22380
+ function yg(e) {
22346
22381
  let t = String(e ?? "").trim();
22347
22382
  return t ? /^https?:\/\//i.test(t) ? !0 : /\.\w{2,}(\/|\s|$)/.test(t) : !1;
22348
22383
  }
22349
- function vg(e) {
22384
+ function bg(e) {
22350
22385
  let t = String(e ?? "").toLowerCase().trim();
22351
22386
  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;
22352
22387
  }
22353
- function yg(e) {
22388
+ function xg(e) {
22354
22389
  if (!e || e.tagName !== "INPUT" && e.tagName !== "TEXTAREA") return !1;
22355
22390
  let t = (e.type || "").toLowerCase();
22356
22391
  return ![
@@ -22362,22 +22397,22 @@ function yg(e) {
22362
22397
  "file"
22363
22398
  ].includes(t);
22364
22399
  }
22365
- function bg(e) {
22366
- if (!yg(e)) return !1;
22400
+ function Sg(e) {
22401
+ if (!xg(e)) return !1;
22367
22402
  let t = (e.name || "").toLowerCase(), n = (e.id || "").toLowerCase(), r = [
22368
22403
  e.name,
22369
22404
  e.id,
22370
22405
  e.placeholder,
22371
- sg(e),
22406
+ lg(e),
22372
22407
  e.getAttribute("aria-label")
22373
22408
  ].filter(Boolean).join(" ").toLowerCase();
22374
22409
  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);
22375
22410
  }
22376
- function xg(e, t, n) {
22377
- let r = String(t ?? ""), i = String(n ?? ""), a = wg(e, r) || hg(e, r) || gg(e, r, i);
22411
+ function Cg(e, t, n) {
22412
+ let r = String(t ?? ""), i = String(n ?? ""), a = Eg(e, r) || _g(e, r) || vg(e, r, i);
22378
22413
  if (!a) return [];
22379
22414
  let o = new Set([a]);
22380
- if (_g(i) && vg(r)) for (let t of e) t !== a && bg(t) && o.add(t);
22415
+ if (yg(i) && bg(r)) for (let t of e) t !== a && Sg(t) && o.add(t);
22381
22416
  let s = Array.from(o);
22382
22417
  return s.sort((e, t) => {
22383
22418
  if (e === t) return 0;
@@ -22385,7 +22420,7 @@ function xg(e, t, n) {
22385
22420
  return n & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : n & Node.DOCUMENT_POSITION_PRECEDING ? 1 : 0;
22386
22421
  }), s;
22387
22422
  }
22388
- function Sg(e, t) {
22423
+ function wg(e, t) {
22389
22424
  try {
22390
22425
  if (!e?.getBoundingClientRect || !t?.getBoundingClientRect) return Infinity;
22391
22426
  let n = e.getBoundingClientRect(), r = t.getBoundingClientRect(), i = {
@@ -22400,17 +22435,17 @@ function Sg(e, t) {
22400
22435
  return Infinity;
22401
22436
  }
22402
22437
  }
22403
- function Cg(e) {
22438
+ function Tg(e) {
22404
22439
  if (!e || typeof e != "string") return null;
22405
22440
  let t = null;
22406
- return ag((n) => {
22441
+ return sg((n) => {
22407
22442
  try {
22408
22443
  let r = n.getElementById(e);
22409
22444
  r && !rg(r) && r.matches?.("input, select, textarea") && (t = r);
22410
22445
  } catch {}
22411
22446
  }), t;
22412
22447
  }
22413
- function wg(e, t) {
22448
+ function Eg(e, t) {
22414
22449
  let n = String(t ?? "").trim();
22415
22450
  if (!n) return null;
22416
22451
  let r = n.match(/^name:\s*([\w.-]+)$/i);
@@ -22420,12 +22455,12 @@ function wg(e, t) {
22420
22455
  }
22421
22456
  let i = n.match(/^id:\s*([\w.-]+)$/i);
22422
22457
  if (i) {
22423
- let e = Cg(i[1]);
22458
+ let e = Tg(i[1]);
22424
22459
  if (e) return e;
22425
22460
  }
22426
22461
  let a = n.startsWith("#") ? n.slice(1) : n;
22427
22462
  if (/^[\w-]+$/.test(a)) {
22428
- let e = Cg(a);
22463
+ let e = Tg(a);
22429
22464
  if (e) return e;
22430
22465
  }
22431
22466
  let o = n.toLowerCase().replace(/\s+/g, " ");
@@ -22435,7 +22470,7 @@ function wg(e, t) {
22435
22470
  }
22436
22471
  return null;
22437
22472
  }
22438
- function Tg(e, t) {
22473
+ function Dg(e, t) {
22439
22474
  let n = String(t || "").toLowerCase().trim();
22440
22475
  if (!n) return 0;
22441
22476
  let r = [
@@ -22452,13 +22487,13 @@ function Tg(e, t) {
22452
22487
  for (let e of i) r.includes(e) && (a += 1);
22453
22488
  return a / i.length * 92;
22454
22489
  }
22455
- function Eg(e, t) {
22490
+ function Og(e, t) {
22456
22491
  let n = [];
22457
- ag((e) => {
22492
+ sg((e) => {
22458
22493
  n.push(...Array.from(e.querySelectorAll("button, [role=\"button\"], input[type=\"submit\"], input[type=\"button\"]")).filter((e) => {
22459
22494
  if (rg(e) || e.disabled) return !1;
22460
22495
  try {
22461
- let t = ig(e);
22496
+ let t = og(e);
22462
22497
  if (t.display === "none" || t.visibility === "hidden" || parseFloat(t.opacity) === 0) return !1;
22463
22498
  } catch {}
22464
22499
  return !0;
@@ -22466,7 +22501,7 @@ function Eg(e, t) {
22466
22501
  });
22467
22502
  let r = 0, i = n.map((t) => ({
22468
22503
  el: t,
22469
- s: Tg(t, e)
22504
+ s: Dg(t, e)
22470
22505
  }));
22471
22506
  for (let { s: e } of i) e > r && (r = e);
22472
22507
  if (r < 36) return null;
@@ -22476,14 +22511,14 @@ function Eg(e, t) {
22476
22511
  if (o.length) {
22477
22512
  let e = a[0], t = Infinity;
22478
22513
  for (let n of a) for (let r of o) {
22479
- let i = Sg(n, r);
22514
+ let i = wg(n, r);
22480
22515
  i < t && (t = i, e = n);
22481
22516
  }
22482
22517
  return e;
22483
22518
  }
22484
22519
  return a[0];
22485
22520
  }
22486
- function Dg(e) {
22521
+ function kg(e) {
22487
22522
  if (e == null) return {};
22488
22523
  if (typeof e == "string") {
22489
22524
  let t = e.trim();
@@ -22496,8 +22531,8 @@ function Dg(e) {
22496
22531
  }
22497
22532
  return e;
22498
22533
  }
22499
- function Og(e) {
22500
- let t = Dg(e);
22534
+ function Ag(e) {
22535
+ let t = kg(e);
22501
22536
  if (Array.isArray(t) && t.length > 0) {
22502
22537
  let e = t[0];
22503
22538
  if (e?.field_key != null || e?.fieldKey != null) return t.map((e) => ({
@@ -22525,12 +22560,12 @@ function Og(e) {
22525
22560
  value: e?.value ?? e?.Value
22526
22561
  })) : [];
22527
22562
  }
22528
- function kg(e) {
22563
+ function jg(e) {
22529
22564
  if (!e || typeof e != "string") return e;
22530
22565
  let t = e.trim();
22531
22566
  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);
22532
22567
  }
22533
- function Ag(e) {
22568
+ function Mg(e) {
22534
22569
  if (!e || typeof e != "string") return e;
22535
22570
  let t = {
22536
22571
  zero: "0",
@@ -22549,7 +22584,7 @@ function Ag(e) {
22549
22584
  for (let [e, r] of Object.entries(t)) n = n.replace(RegExp(`\\b${e}\\b`, "g"), r);
22550
22585
  return n = n.replace(/[^\d+]/g, ""), n;
22551
22586
  }
22552
- function jg(e) {
22587
+ function Ng(e) {
22553
22588
  if (!e || typeof e != "string") return [];
22554
22589
  let t = e.trim();
22555
22590
  if (!t || /\b[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,}\b/i.test(t)) return [];
@@ -22568,7 +22603,7 @@ function jg(e) {
22568
22603
  }
22569
22604
  return [];
22570
22605
  }
22571
- function Mg(e) {
22606
+ function Pg(e) {
22572
22607
  if (!e || typeof e != "string") return [];
22573
22608
  let t = e.trim();
22574
22609
  if (!t) return [];
@@ -22580,7 +22615,7 @@ function Mg(e) {
22580
22615
  field_key: e,
22581
22616
  value: i
22582
22617
  }));
22583
- }, o = kg(t), s = i.test(o), c = o.match(/^\s*([a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,})\s*$/i);
22618
+ }, o = jg(t), s = i.test(o), c = o.match(/^\s*([a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,})\s*$/i);
22584
22619
  if (c) return a("Email Address", c[1]), n;
22585
22620
  if (!i.test(t) && s) {
22586
22621
  let e = o.match(i);
@@ -22608,17 +22643,17 @@ function Mg(e) {
22608
22643
  }
22609
22644
  return n;
22610
22645
  }
22611
- function Ng(e) {
22646
+ function Fg(e) {
22612
22647
  if (!e || typeof e != "object") return null;
22613
22648
  let t = e.url ?? e.target_url ?? e.page_url ?? e.pageUrl ?? e.link ?? e.href ?? e.path;
22614
22649
  return t == null ? null : String(t).trim() || null;
22615
22650
  }
22616
- function Pg(e) {
22651
+ function Ig(e) {
22617
22652
  if (!e || typeof e != "object") return null;
22618
22653
  let t = e.query ?? e.q ?? e.search ?? e.text ?? e.keywords;
22619
22654
  return t == null ? null : String(t).trim() || null;
22620
22655
  }
22621
- function Fg(e) {
22656
+ function Lg(e) {
22622
22657
  let t = e.ownerDocument?.defaultView || window, n = e.tagName === "TEXTAREA" ? t.HTMLTextAreaElement.prototype : t.HTMLInputElement.prototype, r = Object.getOwnPropertyDescriptor(n, "value");
22623
22658
  return (e, t) => {
22624
22659
  try {
@@ -22627,7 +22662,7 @@ function Fg(e) {
22627
22662
  r?.set ? r.set.call(e, t) : e.value = t;
22628
22663
  };
22629
22664
  }
22630
- async function Ig(e, t, n) {
22665
+ async function Rg(e, t, n) {
22631
22666
  if (!n?.skipScroll) try {
22632
22667
  e.scrollIntoView({
22633
22668
  behavior: "smooth",
@@ -22666,7 +22701,7 @@ async function Ig(e, t, n) {
22666
22701
  "on"
22667
22702
  ].includes(String(t).toLowerCase().trim()), e.dispatchEvent(new Event("input", a)), e.dispatchEvent(new Event("change", a)), Gh(e), !0;
22668
22703
  let o = String(t);
22669
- r === "INPUT" || r === "TEXTAREA" ? await eg(e, o, Fg(e)) : (e.value = o, e.dispatchEvent(new Event("input", a)), e.dispatchEvent(new Event("change", a))), e.dispatchEvent(new Event("change", a)), e.dispatchEvent(new Event("blur", a));
22704
+ r === "INPUT" || r === "TEXTAREA" ? await eg(e, o, Lg(e)) : (e.value = o, e.dispatchEvent(new Event("input", a)), e.dispatchEvent(new Event("change", a))), e.dispatchEvent(new Event("change", a)), e.dispatchEvent(new Event("blur", a));
22670
22705
  try {
22671
22706
  e.focus({ preventScroll: !0 });
22672
22707
  } catch {}
@@ -22682,11 +22717,11 @@ async function Ig(e, t, n) {
22682
22717
  } catch {}
22683
22718
  return !0;
22684
22719
  }
22685
- function Lg(e) {
22686
- let t = e.siteId || null, n = (e.apiBaseUrl || "").replace(/\/$/, ""), r = typeof e.getLastUserVoiceText == "function" ? e.getLastUserVoiceText : null, i = [], a = {
22720
+ function zg(e) {
22721
+ let t = e.siteId || null, n = (e.apiBaseUrl || "").replace(/\/$/, ""), r = typeof e.getLastUserVoiceText == "function" ? e.getLastUserVoiceText : null, i = [], a = null, o = {
22687
22722
  navigate_to_page: async (n) => {
22688
22723
  $("navigate_to_page ▶ raw parameters:", n);
22689
- let r = Dg(n), i = Ng(r), a = r.section_text ?? r.sectionText ?? r.section;
22724
+ let r = kg(n), i = Fg(r), a = r.section_text ?? r.sectionText ?? r.section;
22690
22725
  if ($("navigate_to_page · coerced:", {
22691
22726
  url: i,
22692
22727
  sectionText: a
@@ -22712,7 +22747,7 @@ function Lg(e) {
22712
22747
  }
22713
22748
  let e = "";
22714
22749
  try {
22715
- let t = lg(), n = ug();
22750
+ let t = dg(), n = fg();
22716
22751
  if (t.length > 0) {
22717
22752
  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(", ");
22718
22753
  e = ` This page has a form with fields: [${r}]` + (i ? ` and buttons: [${i}].` : ".") + " Call list_page_forms then start filling.";
@@ -22728,12 +22763,12 @@ function Lg(e) {
22728
22763
  },
22729
22764
  highlight_on_page: async (e) => {
22730
22765
  $("highlight_on_page ▶", e);
22731
- let t = Dg(e), n = t?.section_id || t?.sectionId, r = t?.section_text || t?.sectionText, i = rn(n || null, r || null);
22766
+ let t = kg(e), n = t?.section_id || t?.sectionId, r = t?.section_text || t?.sectionText, i = rn(n || null, r || null);
22732
22767
  return i ? (an(i), $("highlight_on_page ✓"), "Highlighted the section.") : ($("highlight_on_page ✖ no element"), "Could not find that section on the page.");
22733
22768
  },
22734
22769
  search_site_content: async (e) => {
22735
22770
  $("search_site_content ▶", e);
22736
- let r = Pg(Dg(e));
22771
+ let r = Ig(kg(e));
22737
22772
  if ($("search_site_content · query:", r, "siteId:", t, "apiBase:", n || "(empty)"), Ih("Searching site content…", { spinner: !0 }), !r) return Lh(), $("search_site_content ✖ missing query"), "Missing query parameter.";
22738
22773
  if (!t) return Lh(), $("search_site_content ✖ no siteId"), "Site is not configured for search.";
22739
22774
  if (!n) return Lh(), $("search_site_content ✖ no api base"), "API base URL is missing; cannot search.";
@@ -22767,20 +22802,20 @@ function Lg(e) {
22767
22802
  duration: 2e3
22768
22803
  }), Zh(!0), Uh(), typeof e.requestEndSession == "function" && e.requestEndSession(), "Voice session is ending."),
22769
22804
  list_page_forms: async () => {
22770
- let e = lg(), t = ug();
22771
- return $("list_page_forms ✓", `${e.length} field(s)`, `${t.length} button(s)`), JSON.stringify({
22805
+ let e = dg(), t = fg();
22806
+ return $("list_page_forms ✓", `${e.length} field(s)`, `${t.length} button(s)`), a = null, JSON.stringify({
22772
22807
  fields: e,
22773
22808
  buttons: t,
22774
- hint: "field_key: placeholder/label, name (e.g. url), id (e.g. url-input). If the page has two URL boxes, fill_form_fields sets all matching URL inputs. click_page_button picks the Conduct Audit nearest the filled field when labels duplicate."
22809
+ 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. field_key: use placeholder, label, name, or id from this list. click_page_button picks the button nearest the filled fields."
22775
22810
  });
22776
22811
  },
22777
22812
  fill_form_fields: async (e) => {
22778
22813
  try {
22779
22814
  $("fill_form_fields ▶ raw:", e);
22780
- let t = Og(e);
22815
+ let t = Ag(e);
22781
22816
  if (!t.length && r) {
22782
- let e = r(), n = jg(e);
22783
- n.length ? $("fill_form_fields · inferred URL from last user utterance (model omitted usable fields):", n) : (n = Mg(e), n.length && $("fill_form_fields · inferred contact fields from last user utterance (empty tool params):", n)), n.length && (t = n);
22817
+ let e = r(), n = Ng(e);
22818
+ n.length ? $("fill_form_fields · inferred URL from last user utterance (model omitted usable fields):", n) : (n = Pg(e), n.length && $("fill_form_fields · inferred contact fields from last user utterance (empty tool params):", n)), n.length && (t = n);
22784
22819
  }
22785
22820
  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.";
22786
22821
  t.length > 1 && Ih(`Filling ${t.length} fields…`);
@@ -22788,26 +22823,37 @@ function Lg(e) {
22788
22823
  for (let e of t) {
22789
22824
  let t = e?.field_key ?? e?.fieldKey, r = e?.value;
22790
22825
  if (t == null || r == null) continue;
22791
- let a = String(t).toLowerCase();
22792
- /email|e-mail|mail/.test(a) ? r = kg(r) : /phone|mobile|tel|cell/.test(a) && (r = Ag(r)), Ih(`Filling ${t}…`), $("fill_form_fields · processing field:", t, "=", r);
22793
- let o = cg();
22794
- $("fill_form_fields · visible inputs count:", o.length);
22795
- let s = xg(o, String(t), r);
22796
- if (s.length) {
22797
- for (let e = 0; e < s.length; e++) await Ig(s[e], r, { skipScroll: e > 0 }), await new Promise((e) => setTimeout(e, 80));
22798
- i = s, n.push(String(t));
22799
- continue;
22826
+ let o = String(t).toLowerCase();
22827
+ /email|e-mail|mail/.test(o) ? r = jg(r) : /phone|mobile|tel|cell/.test(o) && (r = Mg(r)), Ih(`Filling ${t}…`), $("fill_form_fields · processing field:", t, "=", r);
22828
+ let s = ug(), c = s;
22829
+ if (a) {
22830
+ let e = s.filter((e) => ig(e) === a);
22831
+ e.length > 0 && (c = e, $("fill_form_fields · scoped to active form, inputs:", e.length));
22800
22832
  }
22801
- let c = wg(o, String(t));
22802
- c ||= hg(o, String(t)), c ||= gg(o, String(t), r), c ? (await Ig(c, r), i = [c], n.push(String(t))) : $("fill_form_fields · no match for field:", t);
22833
+ $("fill_form_fields · visible inputs count:", s.length, "scoped:", c.length);
22834
+ let l = !1;
22835
+ for (let e of [c, ...c === s ? [] : [s]]) {
22836
+ let o = Cg(e, String(t), r);
22837
+ if (o.length) {
22838
+ for (let e = 0; e < o.length; e++) await Rg(o[e], r, { skipScroll: e > 0 }), await new Promise((e) => setTimeout(e, 80));
22839
+ i = o, a = ig(o[0]) || a, n.push(String(t)), l = !0;
22840
+ break;
22841
+ }
22842
+ let s = Eg(e, String(t));
22843
+ if (s ||= _g(e, String(t)), s ||= vg(e, String(t), r), s) {
22844
+ await Rg(s, r), i = [s], a = ig(s) || a, n.push(String(t)), l = !0;
22845
+ break;
22846
+ }
22847
+ }
22848
+ l || $("fill_form_fields · no match for field:", t);
22803
22849
  }
22804
22850
  Lh(400);
22805
22851
  try {
22806
22852
  Zh();
22807
22853
  } catch {}
22808
22854
  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.";
22809
- let a = `OK_FILLED: ${n.join(", ")}`;
22810
- return $("fill_form_fields ✓", a), a;
22855
+ let o = `OK_FILLED: ${n.join(", ")}`;
22856
+ return $("fill_form_fields ✓", o), o;
22811
22857
  } catch (e) {
22812
22858
  Lh(), Uh(), Zh(!0);
22813
22859
  let t = `fill_form_fields error: ${e?.message || String(e)}`;
@@ -22815,10 +22861,10 @@ function Lg(e) {
22815
22861
  }
22816
22862
  },
22817
22863
  click_page_button: async (e) => {
22818
- let t = Dg(e), n = (t.button_text ?? t.buttonText ?? t.text ?? "").trim();
22864
+ let t = kg(e), n = (t.button_text ?? t.buttonText ?? t.text ?? "").trim();
22819
22865
  if ($("click_page_button ▶", n), !n) return "Missing button_text: pass the visible label, e.g. Conduct Audit.";
22820
22866
  Ih(`Clicking "${n}"…`);
22821
- let r = Eg(n, i);
22867
+ let r = Og(n, i);
22822
22868
  if (!r) return Lh(200), $("click_page_button ✖ no match"), `Could not find a button matching "${n}". Call list_page_forms to see button texts.`;
22823
22869
  try {
22824
22870
  try {
@@ -22839,15 +22885,31 @@ function Lg(e) {
22839
22885
  try {
22840
22886
  await Qh(r);
22841
22887
  } catch {}
22888
+ let e = ig(r) || a, t = [];
22889
+ if (e) {
22890
+ let n = Array.from(e.querySelectorAll("input[required], textarea[required], select[required]")).filter((e) => !rg(e));
22891
+ for (let e of n) if (!(e.value || "").trim()) {
22892
+ let n = lg(e) || e.placeholder || e.name || e.type;
22893
+ t.push(n);
22894
+ }
22895
+ }
22896
+ if (t.length > 0) {
22897
+ Lh(200);
22898
+ try {
22899
+ Zh();
22900
+ } catch {}
22901
+ let e = `Cannot submit — these required fields are still empty: ${t.join(", ")}. Fill them first with fill_form_fields, then click again.`;
22902
+ return $("click_page_button ✖ empty required fields:", t), e;
22903
+ }
22842
22904
  r.focus?.(), r.click();
22843
- let e = (r.textContent || r.value || r.getAttribute("aria-label") || "").trim().slice(0, 80) || "button";
22905
+ let n = (r.textContent || r.value || r.getAttribute("aria-label") || "").trim().slice(0, 80) || "button";
22844
22906
  Lh(600);
22845
22907
  try {
22846
22908
  Zh();
22847
22909
  } catch {}
22848
- Uh();
22849
- let t = `OK_CLICK ${e}`;
22850
- return $("click_page_button ✓", t), t;
22910
+ Uh(), a = null, i = [];
22911
+ let o = `OK_CLICK ${n}`;
22912
+ return $("click_page_button ✓", o), o;
22851
22913
  } catch (e) {
22852
22914
  Lh(200), Zh(!0);
22853
22915
  let t = `Click failed: ${e?.message || String(e)}`;
@@ -22856,19 +22918,19 @@ function Lg(e) {
22856
22918
  }
22857
22919
  };
22858
22920
  return {
22859
- ...a,
22860
- navigateToPage: a.navigate_to_page,
22861
- highlightOnPage: a.highlight_on_page,
22862
- searchSiteContent: a.search_site_content,
22863
- endVoiceSession: a.end_voice_session,
22864
- listPageForms: a.list_page_forms,
22865
- fillFormFields: a.fill_form_fields,
22866
- clickPageButton: a.click_page_button
22921
+ ...o,
22922
+ navigateToPage: o.navigate_to_page,
22923
+ highlightOnPage: o.highlight_on_page,
22924
+ searchSiteContent: o.search_site_content,
22925
+ endVoiceSession: o.end_voice_session,
22926
+ listPageForms: o.list_page_forms,
22927
+ fillFormFields: o.fill_form_fields,
22928
+ clickPageButton: o.click_page_button
22867
22929
  };
22868
22930
  }
22869
22931
  //#endregion
22870
22932
  //#region src/utils/wrapVoiceToolsForLogging.js
22871
- function Rg(e) {
22933
+ function Bg(e) {
22872
22934
  return !e || typeof e != "object" ? e : Object.fromEntries(Object.entries(e).map(([e, t]) => [e, async (n) => {
22873
22935
  let r = Zt();
22874
22936
  r ? console.log("[FlowEngage:voice-tool] ▶", e, n) : console.info(`[FlowEngage] voice tool » ${e}`);
@@ -22878,22 +22940,22 @@ function Rg(e) {
22878
22940
  }
22879
22941
  //#endregion
22880
22942
  //#region src/components/VoiceInterface.jsx
22881
- var zg = {
22943
+ var Vg = {
22882
22944
  idle: "rgba(99,102,241,0.18)",
22883
22945
  listening: "rgba(16,185,129,0.25)",
22884
22946
  speaking: "rgba(245,158,11,0.25)",
22885
22947
  error: "rgba(239,68,68,0.2)"
22886
- }, Bg = {
22948
+ }, Hg = {
22887
22949
  idle: "#6366f1",
22888
22950
  listening: "#10b981",
22889
22951
  speaking: "#f59e0b",
22890
22952
  error: "#ef4444"
22891
22953
  };
22892
- function Vg(e, t) {
22954
+ function Ug(e, t) {
22893
22955
  let n = (t || "").trim();
22894
22956
  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;
22895
22957
  }
22896
- function Hg({ agentId: e, chatId: t, siteId: r, apiBaseUrl: a, onEnd: c, historyRef: d, hasSyncedRef: f, onMessageSync: p, onStartSync: m }) {
22958
+ function Wg({ agentId: e, chatId: t, siteId: r, apiBaseUrl: a, onEnd: c, historyRef: d, hasSyncedRef: f, onMessageSync: p, onStartSync: m }) {
22897
22959
  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 () => {
22898
22960
  try {
22899
22961
  await re.current?.endSession?.();
@@ -22910,7 +22972,7 @@ function Hg({ agentId: e, chatId: t, siteId: r, apiBaseUrl: a, onEnd: c, history
22910
22972
  try {
22911
22973
  if (await navigator.mediaDevices.getUserMedia({ audio: !0 }), t) return;
22912
22974
  d.current = [], ae.current = "", se.current = !1;
22913
- let i = Rg(Lg({
22975
+ let i = Bg(zg({
22914
22976
  siteId: r || null,
22915
22977
  apiBaseUrl: a || null,
22916
22978
  getLastUserVoiceText: () => ae.current,
@@ -22937,7 +22999,7 @@ function Hg({ agentId: e, chatId: t, siteId: r, apiBaseUrl: a, onEnd: c, history
22937
22999
  message: r,
22938
23000
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
22939
23001
  };
22940
- n === "user" && (ae.current = r), d.current = [...d.current, i], Vg(n, r) && queueMicrotask(() => {
23002
+ n === "user" && (ae.current = r), d.current = [...d.current, i], Ug(n, r) && queueMicrotask(() => {
22941
23003
  se.current || (se.current = !0, oe.current?.());
22942
23004
  });
22943
23005
  },
@@ -22981,7 +23043,7 @@ function Hg({ agentId: e, chatId: t, siteId: r, apiBaseUrl: a, onEnd: c, history
22981
23043
  d,
22982
23044
  m
22983
23045
  ]);
22984
- let ce = h === "listening" || h === "speaking", le = Bg[h] || Bg.idle, ue = zg[h] || zg.idle;
23046
+ let ce = h === "listening" || h === "speaking", le = Hg[h] || Hg.idle, ue = Vg[h] || Vg.idle;
22985
23047
  return /* @__PURE__ */ u("div", {
22986
23048
  ref: ie,
22987
23049
  style: {
@@ -23087,7 +23149,7 @@ function Hg({ agentId: e, chatId: t, siteId: r, apiBaseUrl: a, onEnd: c, history
23087
23149
  }
23088
23150
  //#endregion
23089
23151
  //#region src/components/FlowEngageWidget.jsx
23090
- var Ug = [
23152
+ var Gg = [
23091
23153
  {
23092
23154
  key: "become_client",
23093
23155
  label: "Become a Client"
@@ -23108,7 +23170,7 @@ var Ug = [
23108
23170
  key: "looking_for_job",
23109
23171
  label: "Looking for a Job"
23110
23172
  }
23111
- ], Wg = () => /* @__PURE__ */ l("div", {
23173
+ ], Kg = () => /* @__PURE__ */ l("div", {
23112
23174
  style: {
23113
23175
  display: "flex",
23114
23176
  marginBottom: "12px",
@@ -23139,7 +23201,7 @@ var Ug = [
23139
23201
  } }, 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 " })]
23140
23202
  })
23141
23203
  });
23142
- function Gg() {
23204
+ function qg() {
23143
23205
  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("");
23144
23206
  i(() => {
23145
23207
  try {
@@ -23167,7 +23229,7 @@ function Gg() {
23167
23229
  outline: "none",
23168
23230
  fontFamily: "ui-sans-serif, system-ui, sans-serif",
23169
23231
  ...c ? {} : Ue
23170
- }, Ge = S.recommendations?.[ue] || Re.recommendations?.[ue] || Ug, 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(() => {
23232
+ }, Ge = S.recommendations?.[ue] || Re.recommendations?.[ue] || Gg, 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(() => {
23171
23233
  let e = o.findIndex((e) => e.sender === "user");
23172
23234
  return e === -1 ? !1 : o.slice(e + 1).some((e) => e.sender === "bot" || e.sender === "ai" || e.sender === "agent");
23173
23235
  }, [o]), rt = !h && tt && nt;
@@ -23295,7 +23357,7 @@ function Gg() {
23295
23357
  flexDirection: "column"
23296
23358
  },
23297
23359
  className: "fe-screen-fade-in",
23298
- children: /* @__PURE__ */ l(Hg, {
23360
+ children: /* @__PURE__ */ l(Wg, {
23299
23361
  agentId: T,
23300
23362
  chatId: r,
23301
23363
  siteId: Ye,
@@ -23328,7 +23390,7 @@ function Gg() {
23328
23390
  isAiTyping: ee,
23329
23391
  isAgentTyping: g,
23330
23392
  setReplyContext: Me,
23331
- TypingDots: Wg,
23393
+ TypingDots: Kg,
23332
23394
  primaryColor: Ve,
23333
23395
  agentHeadshot: $e,
23334
23396
  agentDisplayName: p || Ze
@@ -23407,4 +23469,4 @@ function Gg() {
23407
23469
  }) : null;
23408
23470
  }
23409
23471
  //#endregion
23410
- export { vn as FlowEngageProvider, Gg as FlowEngageWidget, Xt as useFlowEngage };
23472
+ export { vn as FlowEngageProvider, qg as FlowEngageWidget, Xt as useFlowEngage };