@flowengage/react-chatbot 8.0.113 → 8.0.115

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.
@@ -42,17 +42,17 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
42
42
  if (j) try {
43
43
  window.localStorage.removeItem(A.chatId);
44
44
  } catch {}
45
- }, N = () => j ? typeof crypto < "u" && crypto.randomUUID ? crypto.randomUUID() : `${Date.now()}-${Math.random().toString(16).slice(2)}` : "server-chat-id", ae = (e) => e ? `flowengage.entrySeen.${e}` : null, P = (e) => {
45
+ }, ae = () => j ? typeof crypto < "u" && crypto.randomUUID ? crypto.randomUUID() : `${Date.now()}-${Math.random().toString(16).slice(2)}` : "server-chat-id", N = (e) => e ? `flowengage.entrySeen.${e}` : null, P = (e) => {
46
46
  if (!j || !e) return !1;
47
47
  try {
48
- let t = ae(e);
48
+ let t = N(e);
49
49
  return t ? window.localStorage.getItem(t) === "1" : !1;
50
50
  } catch {
51
51
  return !1;
52
52
  }
53
53
  }, oe = (e) => {
54
54
  if (!(!j || !e)) try {
55
- let t = ae(e);
55
+ let t = N(e);
56
56
  t && window.localStorage.setItem(t, "1");
57
57
  } catch {}
58
58
  }, F = (e) => e ? `flowengage.navPreference.${e}` : null, se = (e) => e ? `flowengage.navPreferencePromptShown.${e}` : null, ce = (e) => {
@@ -142,23 +142,23 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
142
142
  return;
143
143
  }
144
144
  window.localStorage.setItem(n, r), window.sessionStorage.removeItem(A.visitorEmail);
145
- }, I = (e) => e ? `flowengage.visitorId.${e}` : null, be = () => `v_${Date.now().toString(36)}_${typeof crypto < "u" && crypto.randomUUID ? crypto.randomUUID().replace(/-/g, "").slice(0, 16) : Math.random().toString(36).slice(2, 18)}`, L = (e) => {
145
+ }, be = (e) => e ? `flowengage.visitorId.${e}` : null, xe = () => `v_${Date.now().toString(36)}_${typeof crypto < "u" && crypto.randomUUID ? crypto.randomUUID().replace(/-/g, "").slice(0, 16) : Math.random().toString(36).slice(2, 18)}`, I = (e) => {
146
146
  if (!j || !e) return null;
147
147
  try {
148
- let t = I(e), n = t ? window.localStorage.getItem(t) : null;
148
+ let t = be(e), n = t ? window.localStorage.getItem(t) : null;
149
149
  return n && String(n).trim() ? String(n).trim() : null;
150
150
  } catch {
151
151
  return null;
152
152
  }
153
- }, xe = (e) => {
153
+ }, L = (e) => {
154
154
  if (!j || !e) return null;
155
155
  try {
156
- let t = L(e);
156
+ let t = I(e);
157
157
  if (t) return t;
158
- let n = be(), r = I(e);
158
+ let n = xe(), r = be(e);
159
159
  return r && window.localStorage.setItem(r, n), n;
160
160
  } catch {
161
- return be();
161
+ return xe();
162
162
  }
163
163
  }, Se = "flowengage.tabId", Ce = () => {
164
164
  if (!j) return "default";
@@ -257,7 +257,7 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
257
257
  throw n.status = e.status, n;
258
258
  }
259
259
  return t;
260
- }, z = async (e, t = {}) => {
260
+ }, ze = async (e, t = {}) => {
261
261
  try {
262
262
  return await fetch(e, {
263
263
  mode: "cors",
@@ -267,9 +267,9 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
267
267
  let n = /* @__PURE__ */ Error(`Network error reaching ${e}. Check: (1) backend is running, (2) CORS allows this origin, (3) siteId is correct. Original: ${t.message}`);
268
268
  throw n.status = 0, n.cause = t, n;
269
269
  }
270
- }, ze = async ({ apiBaseUrl: e, userId: t, siteId: n, priorChatId: r = null, forceNew: i = !1, resumeChatId: a = null, visitorId: o = null }) => {
270
+ }, Be = async ({ apiBaseUrl: e, userId: t, siteId: n, priorChatId: r = null, forceNew: i = !1, resumeChatId: a = null, visitorId: o = null }) => {
271
271
  let s = `${e}/api/visitors/resolve-session`, c = { siteId: n };
272
- return r && String(r).trim() && (c.priorChatId = String(r).trim()), i && (c.forceNew = !0), a && (c.resumeChatId = a), o && (c.visitorId = o), R(await z(s, {
272
+ return r && String(r).trim() && (c.priorChatId = String(r).trim()), i && (c.forceNew = !0), a && (c.resumeChatId = a), o && (c.visitorId = o), R(await ze(s, {
273
273
  method: "POST",
274
274
  mode: "cors",
275
275
  headers: {
@@ -280,13 +280,13 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
280
280
  },
281
281
  body: JSON.stringify(c)
282
282
  }));
283
- }, Be = async ({ apiBaseUrl: e, siteId: t }) => {
283
+ }, Ve = async ({ apiBaseUrl: e, siteId: t }) => {
284
284
  let n = typeof window < "u" ? window.location.origin : "http://localhost";
285
- return (await R(await z(`${e}/api/widget/chatbot-loader?${new URLSearchParams({
285
+ return (await R(await ze(`${e}/api/widget/chatbot-loader?${new URLSearchParams({
286
286
  siteId: t,
287
287
  origin: n
288
288
  }).toString()}`, { method: "GET" }))).data;
289
- }, Ve = ({ apiBaseUrl: e, userId: t, siteId: n, visitorId: r = null }) => {
289
+ }, He = ({ apiBaseUrl: e, userId: t, siteId: n, visitorId: r = null }) => {
290
290
  let i = (t, n) => {
291
291
  let r = `${e}${t}`, i = JSON.stringify(n);
292
292
  if (typeof navigator < "u" && navigator.sendBeacon) try {
@@ -300,7 +300,7 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
300
300
  headers: { "Content-Type": "application/json" },
301
301
  body: i
302
302
  }).catch(() => {}), !0) : !1;
303
- }, a = async (i, a = {}) => R(await z(`${e}${i}`, {
303
+ }, a = async (i, a = {}) => R(await ze(`${e}${i}`, {
304
304
  ...a,
305
305
  headers: {
306
306
  "Content-Type": "application/json",
@@ -315,7 +315,7 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
315
315
  ...n ? { "x-site-id": n } : {},
316
316
  ...a.headers || {}
317
317
  };
318
- return R(await z(`${e}${r}`, {
318
+ return R(await ze(`${e}${r}`, {
319
319
  ...a,
320
320
  body: i,
321
321
  headers: o
@@ -346,7 +346,7 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
346
346
  method: "POST",
347
347
  body: JSON.stringify(f)
348
348
  });
349
- let p = await z(`${e}/api/ai/chat`, {
349
+ let p = await ze(`${e}/api/ai/chat`, {
350
350
  method: "POST",
351
351
  headers: {
352
352
  "Content-Type": "application/json",
@@ -475,7 +475,7 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
475
475
  });
476
476
  },
477
477
  async getIceServersConfig() {
478
- return R(await z(`${e}/api/calls/ice-config`, {
478
+ return R(await ze(`${e}/api/calls/ice-config`, {
479
479
  method: "GET",
480
480
  headers: {
481
481
  "x-user-id": t,
@@ -530,31 +530,31 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
530
530
  return i.append("chatId", r), i.append("type", "widget_closed"), t && i.append("userId", String(t)), n && i.append("siteId", String(n)), navigator.sendBeacon(`${e}/api/chat/status`, i);
531
531
  }
532
532
  };
533
- }, B = Object.create(null);
534
- B.open = "0", B.close = "1", B.ping = "2", B.pong = "3", B.message = "4", B.upgrade = "5", B.noop = "6";
535
- var He = Object.create(null);
536
- Object.keys(B).forEach((e) => {
537
- He[B[e]] = e;
533
+ }, z = Object.create(null);
534
+ z.open = "0", z.close = "1", z.ping = "2", z.pong = "3", z.message = "4", z.upgrade = "5", z.noop = "6";
535
+ var Ue = Object.create(null);
536
+ Object.keys(z).forEach((e) => {
537
+ Ue[z[e]] = e;
538
538
  });
539
- var Ue = {
539
+ var We = {
540
540
  type: "error",
541
541
  data: "parser error"
542
- }, We = typeof Blob == "function" || typeof Blob < "u" && Object.prototype.toString.call(Blob) === "[object BlobConstructor]", Ge = typeof ArrayBuffer == "function", Ke = (e) => typeof ArrayBuffer.isView == "function" ? ArrayBuffer.isView(e) : e && e.buffer instanceof ArrayBuffer, qe = ({ type: e, data: t }, n, r) => We && t instanceof Blob ? n ? r(t) : Je(t, r) : Ge && (t instanceof ArrayBuffer || Ke(t)) ? n ? r(t) : Je(new Blob([t]), r) : r(B[e] + (t || "")), Je = (e, t) => {
542
+ }, Ge = typeof Blob == "function" || typeof Blob < "u" && Object.prototype.toString.call(Blob) === "[object BlobConstructor]", Ke = typeof ArrayBuffer == "function", qe = (e) => typeof ArrayBuffer.isView == "function" ? ArrayBuffer.isView(e) : e && e.buffer instanceof ArrayBuffer, Je = ({ type: e, data: t }, n, r) => Ge && t instanceof Blob ? n ? r(t) : Ye(t, r) : Ke && (t instanceof ArrayBuffer || qe(t)) ? n ? r(t) : Ye(new Blob([t]), r) : r(z[e] + (t || "")), Ye = (e, t) => {
543
543
  let n = new FileReader();
544
544
  return n.onload = function() {
545
545
  let e = n.result.split(",")[1];
546
546
  t("b" + (e || ""));
547
547
  }, n.readAsDataURL(e);
548
548
  };
549
- function Ye(e) {
549
+ function Xe(e) {
550
550
  return e instanceof Uint8Array ? e : e instanceof ArrayBuffer ? new Uint8Array(e) : new Uint8Array(e.buffer, e.byteOffset, e.byteLength);
551
551
  }
552
- var Xe;
552
+ var B;
553
553
  function Ze(e, t) {
554
- if (We && e.data instanceof Blob) return e.data.arrayBuffer().then(Ye).then(t);
555
- if (Ge && (e.data instanceof ArrayBuffer || Ke(e.data))) return t(Ye(e.data));
556
- qe(e, !1, (e) => {
557
- Xe ||= new TextEncoder(), t(Xe.encode(e));
554
+ if (Ge && e.data instanceof Blob) return e.data.arrayBuffer().then(Xe).then(t);
555
+ if (Ke && (e.data instanceof ArrayBuffer || qe(e.data))) return t(Xe(e.data));
556
+ Je(e, !1, (e) => {
557
+ B ||= new TextEncoder(), t(B.encode(e));
558
558
  });
559
559
  }
560
560
  //#endregion
@@ -567,43 +567,43 @@ var H = (e) => {
567
567
  let l = new ArrayBuffer(t), u = new Uint8Array(l);
568
568
  for (r = 0; r < n; r += 4) a = V[e.charCodeAt(r)], o = V[e.charCodeAt(r + 1)], s = V[e.charCodeAt(r + 2)], c = V[e.charCodeAt(r + 3)], u[i++] = a << 2 | o >> 4, u[i++] = (o & 15) << 4 | s >> 2, u[i++] = (s & 3) << 6 | c & 63;
569
569
  return l;
570
- }, $e = typeof ArrayBuffer == "function", U = (e, t) => {
570
+ }, $e = typeof ArrayBuffer == "function", et = (e, t) => {
571
571
  if (typeof e != "string") return {
572
572
  type: "message",
573
- data: tt(e, t)
573
+ data: W(e, t)
574
574
  };
575
575
  let n = e.charAt(0);
576
576
  return n === "b" ? {
577
577
  type: "message",
578
- data: et(e.substring(1), t)
579
- } : He[n] ? e.length > 1 ? {
580
- type: He[n],
578
+ data: U(e.substring(1), t)
579
+ } : Ue[n] ? e.length > 1 ? {
580
+ type: Ue[n],
581
581
  data: e.substring(1)
582
- } : { type: He[n] } : Ue;
583
- }, et = (e, t) => $e ? tt(H(e), t) : {
582
+ } : { type: Ue[n] } : We;
583
+ }, U = (e, t) => $e ? W(H(e), t) : {
584
584
  base64: !0,
585
585
  data: e
586
- }, tt = (e, t) => {
586
+ }, W = (e, t) => {
587
587
  switch (t) {
588
588
  case "blob": return e instanceof Blob ? e : new Blob([e]);
589
589
  default: return e instanceof ArrayBuffer ? e : e.buffer;
590
590
  }
591
- }, nt = "", rt = (e, t) => {
591
+ }, tt = "", nt = (e, t) => {
592
592
  let n = e.length, r = Array(n), i = 0;
593
593
  e.forEach((e, a) => {
594
- qe(e, !1, (e) => {
595
- r[a] = e, ++i === n && t(r.join(nt));
594
+ Je(e, !1, (e) => {
595
+ r[a] = e, ++i === n && t(r.join(tt));
596
596
  });
597
597
  });
598
- }, it = (e, t) => {
599
- let n = e.split(nt), r = [];
598
+ }, rt = (e, t) => {
599
+ let n = e.split(tt), r = [];
600
600
  for (let e = 0; e < n.length; e++) {
601
- let i = U(n[e], t);
601
+ let i = et(n[e], t);
602
602
  if (r.push(i), i.type === "error") break;
603
603
  }
604
604
  return r;
605
605
  };
606
- function at() {
606
+ function it() {
607
607
  return new TransformStream({ transform(e, t) {
608
608
  Ze(e, (n) => {
609
609
  let r = n.length, i;
@@ -621,44 +621,44 @@ function at() {
621
621
  });
622
622
  } });
623
623
  }
624
- var ot;
625
- function st(e) {
624
+ var at;
625
+ function ot(e) {
626
626
  return e.reduce((e, t) => e + t.length, 0);
627
627
  }
628
- function ct(e, t) {
628
+ function st(e, t) {
629
629
  if (e[0].length === t) return e.shift();
630
630
  let n = new Uint8Array(t), r = 0;
631
631
  for (let i = 0; i < t; i++) n[i] = e[0][r++], r === e[0].length && (e.shift(), r = 0);
632
632
  return e.length && r < e[0].length && (e[0] = e[0].slice(r)), n;
633
633
  }
634
- function lt(e, t) {
635
- ot ||= new TextDecoder();
634
+ function ct(e, t) {
635
+ at ||= new TextDecoder();
636
636
  let n = [], r = 0, i = -1, a = !1;
637
637
  return new TransformStream({ transform(o, s) {
638
638
  for (n.push(o);;) {
639
639
  if (r === 0) {
640
- if (st(n) < 1) break;
641
- let e = ct(n, 1);
640
+ if (ot(n) < 1) break;
641
+ let e = st(n, 1);
642
642
  a = (e[0] & 128) == 128, i = e[0] & 127, r = i < 126 ? 3 : i === 126 ? 1 : 2;
643
643
  } else if (r === 1) {
644
- if (st(n) < 2) break;
645
- let e = ct(n, 2);
644
+ if (ot(n) < 2) break;
645
+ let e = st(n, 2);
646
646
  i = new DataView(e.buffer, e.byteOffset, e.length).getUint16(0), r = 3;
647
647
  } else if (r === 2) {
648
- if (st(n) < 8) break;
649
- let e = ct(n, 8), t = new DataView(e.buffer, e.byteOffset, e.length), a = t.getUint32(0);
648
+ if (ot(n) < 8) break;
649
+ let e = st(n, 8), t = new DataView(e.buffer, e.byteOffset, e.length), a = t.getUint32(0);
650
650
  if (a > 2 ** 21 - 1) {
651
- s.enqueue(Ue);
651
+ s.enqueue(We);
652
652
  break;
653
653
  }
654
654
  i = a * 2 ** 32 + t.getUint32(4), r = 3;
655
655
  } else {
656
- if (st(n) < i) break;
657
- let e = ct(n, i);
658
- s.enqueue(U(a ? e : ot.decode(e), t)), r = 0;
656
+ if (ot(n) < i) break;
657
+ let e = st(n, i);
658
+ s.enqueue(et(a ? e : at.decode(e), t)), r = 0;
659
659
  }
660
660
  if (i === 0 || i > e) {
661
- s.enqueue(Ue);
661
+ s.enqueue(We);
662
662
  break;
663
663
  }
664
664
  }
@@ -666,21 +666,21 @@ function lt(e, t) {
666
666
  }
667
667
  //#endregion
668
668
  //#region node_modules/@socket.io/component-emitter/lib/esm/index.js
669
- function W(e) {
670
- if (e) return ut(e);
669
+ function G(e) {
670
+ if (e) return lt(e);
671
671
  }
672
- function ut(e) {
673
- for (var t in W.prototype) e[t] = W.prototype[t];
672
+ function lt(e) {
673
+ for (var t in G.prototype) e[t] = G.prototype[t];
674
674
  return e;
675
675
  }
676
- W.prototype.on = W.prototype.addEventListener = function(e, t) {
676
+ G.prototype.on = G.prototype.addEventListener = function(e, t) {
677
677
  return this._callbacks = this._callbacks || {}, (this._callbacks["$" + e] = this._callbacks["$" + e] || []).push(t), this;
678
- }, W.prototype.once = function(e, t) {
678
+ }, G.prototype.once = function(e, t) {
679
679
  function n() {
680
680
  this.off(e, n), t.apply(this, arguments);
681
681
  }
682
682
  return n.fn = t, this.on(e, n), this;
683
- }, W.prototype.off = W.prototype.removeListener = W.prototype.removeAllListeners = W.prototype.removeEventListener = function(e, t) {
683
+ }, G.prototype.off = G.prototype.removeListener = G.prototype.removeAllListeners = G.prototype.removeEventListener = function(e, t) {
684
684
  if (this._callbacks = this._callbacks || {}, arguments.length == 0) return this._callbacks = {}, this;
685
685
  var n = this._callbacks["$" + e];
686
686
  if (!n) return this;
@@ -690,7 +690,7 @@ W.prototype.on = W.prototype.addEventListener = function(e, t) {
690
690
  break;
691
691
  }
692
692
  return n.length === 0 && delete this._callbacks["$" + e], this;
693
- }, W.prototype.emit = function(e) {
693
+ }, G.prototype.emit = function(e) {
694
694
  this._callbacks = this._callbacks || {};
695
695
  for (var t = Array(arguments.length - 1), n = this._callbacks["$" + e], r = 1; r < arguments.length; r++) t[r - 1] = arguments[r];
696
696
  if (n) {
@@ -698,43 +698,43 @@ W.prototype.on = W.prototype.addEventListener = function(e, t) {
698
698
  for (var r = 0, i = n.length; r < i; ++r) n[r].apply(this, t);
699
699
  }
700
700
  return this;
701
- }, W.prototype.emitReserved = W.prototype.emit, W.prototype.listeners = function(e) {
701
+ }, G.prototype.emitReserved = G.prototype.emit, G.prototype.listeners = function(e) {
702
702
  return this._callbacks = this._callbacks || {}, this._callbacks["$" + e] || [];
703
- }, W.prototype.hasListeners = function(e) {
703
+ }, G.prototype.hasListeners = function(e) {
704
704
  return !!this.listeners(e).length;
705
705
  };
706
706
  //#endregion
707
707
  //#region node_modules/engine.io-client/build/esm/globals.js
708
- var dt = typeof Promise == "function" && typeof Promise.resolve == "function" ? (e) => Promise.resolve().then(e) : (e, t) => t(e, 0), ft = typeof self < "u" ? self : typeof window < "u" ? window : Function("return this")(), pt = "arraybuffer";
708
+ var ut = typeof Promise == "function" && typeof Promise.resolve == "function" ? (e) => Promise.resolve().then(e) : (e, t) => t(e, 0), dt = typeof self < "u" ? self : typeof window < "u" ? window : Function("return this")(), ft = "arraybuffer";
709
709
  //#endregion
710
710
  //#region node_modules/engine.io-client/build/esm/util.js
711
- function mt(e, ...t) {
711
+ function pt(e, ...t) {
712
712
  return t.reduce((t, n) => (e.hasOwnProperty(n) && (t[n] = e[n]), t), {});
713
713
  }
714
- var ht = ft.setTimeout, gt = ft.clearTimeout;
715
- function _t(e, t) {
716
- t.useNativeTimers ? (e.setTimeoutFn = ht.bind(ft), e.clearTimeoutFn = gt.bind(ft)) : (e.setTimeoutFn = ft.setTimeout.bind(ft), e.clearTimeoutFn = ft.clearTimeout.bind(ft));
714
+ var mt = dt.setTimeout, ht = dt.clearTimeout;
715
+ function gt(e, t) {
716
+ t.useNativeTimers ? (e.setTimeoutFn = mt.bind(dt), e.clearTimeoutFn = ht.bind(dt)) : (e.setTimeoutFn = dt.setTimeout.bind(dt), e.clearTimeoutFn = dt.clearTimeout.bind(dt));
717
717
  }
718
- var vt = 1.33;
719
- function yt(e) {
720
- return typeof e == "string" ? bt(e) : Math.ceil((e.byteLength || e.size) * vt);
718
+ var _t = 1.33;
719
+ function vt(e) {
720
+ return typeof e == "string" ? yt(e) : Math.ceil((e.byteLength || e.size) * _t);
721
721
  }
722
- function bt(e) {
722
+ function yt(e) {
723
723
  let t = 0, n = 0;
724
724
  for (let r = 0, i = e.length; r < i; r++) t = e.charCodeAt(r), t < 128 ? n += 1 : t < 2048 ? n += 2 : t < 55296 || t >= 57344 ? n += 3 : (r++, n += 4);
725
725
  return n;
726
726
  }
727
- function xt() {
727
+ function bt() {
728
728
  return Date.now().toString(36).substring(3) + Math.random().toString(36).substring(2, 5);
729
729
  }
730
730
  //#endregion
731
731
  //#region node_modules/engine.io-client/build/esm/contrib/parseqs.js
732
- function St(e) {
732
+ function xt(e) {
733
733
  let t = "";
734
734
  for (let n in e) e.hasOwnProperty(n) && (t.length && (t += "&"), t += encodeURIComponent(n) + "=" + encodeURIComponent(e[n]));
735
735
  return t;
736
736
  }
737
- function Ct(e) {
737
+ function St(e) {
738
738
  let t = {}, n = e.split("&");
739
739
  for (let e = 0, r = n.length; e < r; e++) {
740
740
  let r = n[e].split("=");
@@ -744,16 +744,16 @@ function Ct(e) {
744
744
  }
745
745
  //#endregion
746
746
  //#region node_modules/engine.io-client/build/esm/transport.js
747
- var wt = class extends Error {
747
+ var Ct = class extends Error {
748
748
  constructor(e, t, n) {
749
749
  super(e), this.description = t, this.context = n, this.type = "TransportError";
750
750
  }
751
- }, Tt = class extends W {
751
+ }, wt = class extends G {
752
752
  constructor(e) {
753
- super(), this.writable = !1, _t(this, e), this.opts = e, this.query = e.query, this.socket = e.socket, this.supportsBinary = !e.forceBase64;
753
+ super(), this.writable = !1, gt(this, e), this.opts = e, this.query = e.query, this.socket = e.socket, this.supportsBinary = !e.forceBase64;
754
754
  }
755
755
  onError(e, t, n) {
756
- return super.emitReserved("error", new wt(e, t, n)), this;
756
+ return super.emitReserved("error", new Ct(e, t, n)), this;
757
757
  }
758
758
  open() {
759
759
  return this.readyState = "opening", this.doOpen(), this;
@@ -768,7 +768,7 @@ var wt = class extends Error {
768
768
  this.readyState = "open", this.writable = !0, super.emitReserved("open");
769
769
  }
770
770
  onData(e) {
771
- let t = U(e, this.socket.binaryType);
771
+ let t = et(e, this.socket.binaryType);
772
772
  this.onPacket(t);
773
773
  }
774
774
  onPacket(e) {
@@ -789,10 +789,10 @@ var wt = class extends Error {
789
789
  return this.opts.port && (this.opts.secure && Number(this.opts.port) !== 443 || !this.opts.secure && Number(this.opts.port) !== 80) ? ":" + this.opts.port : "";
790
790
  }
791
791
  _query(e) {
792
- let t = St(e);
792
+ let t = xt(e);
793
793
  return t.length ? "?" + t : "";
794
794
  }
795
- }, Et = class extends Tt {
795
+ }, Tt = class extends wt {
796
796
  constructor() {
797
797
  super(...arguments), this._polling = !1;
798
798
  }
@@ -820,7 +820,7 @@ var wt = class extends Error {
820
820
  this._polling = !0, this.doPoll(), this.emitReserved("poll");
821
821
  }
822
822
  onData(e) {
823
- it(e, this.socket.binaryType).forEach((e) => {
823
+ rt(e, this.socket.binaryType).forEach((e) => {
824
824
  if (this.readyState === "opening" && e.type === "open" && this.onOpen(), e.type === "close") return this.onClose({ description: "transport closed by the server" }), !1;
825
825
  this.onPacket(e);
826
826
  }), this.readyState !== "closed" && (this._polling = !1, this.emitReserved("pollComplete"), this.readyState === "open" && this._poll());
@@ -832,7 +832,7 @@ var wt = class extends Error {
832
832
  this.readyState === "open" ? e() : this.once("open", e);
833
833
  }
834
834
  write(e) {
835
- this.writable = !1, rt(e, (e) => {
835
+ this.writable = !1, nt(e, (e) => {
836
836
  this.doWrite(e, () => {
837
837
  this.writable = !0, this.emitReserved("drain");
838
838
  });
@@ -840,17 +840,17 @@ var wt = class extends Error {
840
840
  }
841
841
  uri() {
842
842
  let e = this.opts.secure ? "https" : "http", t = this.query || {};
843
- return !1 !== this.opts.timestampRequests && (t[this.opts.timestampParam] = xt()), !this.supportsBinary && !t.sid && (t.b64 = 1), this.createUri(e, t);
843
+ return !1 !== this.opts.timestampRequests && (t[this.opts.timestampParam] = bt()), !this.supportsBinary && !t.sid && (t.b64 = 1), this.createUri(e, t);
844
844
  }
845
- }, Dt = !1;
845
+ }, Et = !1;
846
846
  try {
847
- Dt = typeof XMLHttpRequest < "u" && "withCredentials" in new XMLHttpRequest();
847
+ Et = typeof XMLHttpRequest < "u" && "withCredentials" in new XMLHttpRequest();
848
848
  } catch {}
849
- var Ot = Dt;
849
+ var Dt = Et;
850
850
  //#endregion
851
851
  //#region node_modules/engine.io-client/build/esm/transports/polling-xhr.js
852
- function kt() {}
853
- var At = class extends Et {
852
+ function Ot() {}
853
+ var kt = class extends Tt {
854
854
  constructor(e) {
855
855
  if (super(e), typeof location < "u") {
856
856
  let t = location.protocol === "https:", n = location.port;
@@ -872,13 +872,13 @@ var At = class extends Et {
872
872
  this.onError("xhr poll error", e, t);
873
873
  }), this.pollXhr = e;
874
874
  }
875
- }, G = class e extends W {
875
+ }, At = class e extends G {
876
876
  constructor(e, t, n) {
877
- super(), this.createRequest = e, _t(this, n), this._opts = n, this._method = n.method || "GET", this._uri = t, this._data = n.data === void 0 ? null : n.data, this._create();
877
+ super(), this.createRequest = e, gt(this, n), this._opts = n, this._method = n.method || "GET", this._uri = t, this._data = n.data === void 0 ? null : n.data, this._create();
878
878
  }
879
879
  _create() {
880
880
  var t;
881
- let n = mt(this._opts, "agent", "pfx", "key", "passphrase", "cert", "ca", "ciphers", "rejectUnauthorized", "autoUnref");
881
+ let n = pt(this._opts, "agent", "pfx", "key", "passphrase", "cert", "ca", "ciphers", "rejectUnauthorized", "autoUnref");
882
882
  n.xdomain = !!this._opts.xd;
883
883
  let r = this._xhr = this.createRequest(n);
884
884
  try {
@@ -914,7 +914,7 @@ var At = class extends Et {
914
914
  }
915
915
  _cleanup(t) {
916
916
  if (!(this._xhr === void 0 || this._xhr === null)) {
917
- if (this._xhr.onreadystatechange = kt, t) try {
917
+ if (this._xhr.onreadystatechange = Ot, t) try {
918
918
  this._xhr.abort();
919
919
  } catch {}
920
920
  typeof document < "u" && delete e.requests[this._index], this._xhr = null;
@@ -928,46 +928,46 @@ var At = class extends Et {
928
928
  this._cleanup();
929
929
  }
930
930
  };
931
- if (G.requestsCount = 0, G.requests = {}, typeof document < "u") {
931
+ if (At.requestsCount = 0, At.requests = {}, typeof document < "u") {
932
932
  if (typeof attachEvent == "function") attachEvent("onunload", jt);
933
933
  else if (typeof addEventListener == "function") {
934
- let e = "onpagehide" in ft ? "pagehide" : "unload";
934
+ let e = "onpagehide" in dt ? "pagehide" : "unload";
935
935
  addEventListener(e, jt, !1);
936
936
  }
937
937
  }
938
938
  function jt() {
939
- for (let e in G.requests) G.requests.hasOwnProperty(e) && G.requests[e].abort();
939
+ for (let e in At.requests) At.requests.hasOwnProperty(e) && At.requests[e].abort();
940
940
  }
941
941
  var Mt = (function() {
942
942
  let e = Pt({ xdomain: !1 });
943
943
  return e && e.responseType !== null;
944
- })(), Nt = class extends At {
944
+ })(), Nt = class extends kt {
945
945
  constructor(e) {
946
946
  super(e);
947
947
  let t = e && e.forceBase64;
948
948
  this.supportsBinary = Mt && !t;
949
949
  }
950
950
  request(e = {}) {
951
- return Object.assign(e, { xd: this.xd }, this.opts), new G(Pt, this.uri(), e);
951
+ return Object.assign(e, { xd: this.xd }, this.opts), new At(Pt, this.uri(), e);
952
952
  }
953
953
  };
954
954
  function Pt(e) {
955
955
  let t = e.xdomain;
956
956
  try {
957
- if (typeof XMLHttpRequest < "u" && (!t || Ot)) return new XMLHttpRequest();
957
+ if (typeof XMLHttpRequest < "u" && (!t || Dt)) return new XMLHttpRequest();
958
958
  } catch {}
959
959
  if (!t) try {
960
- return new ft[["Active", "Object"].join("X")]("Microsoft.XMLHTTP");
960
+ return new dt[["Active", "Object"].join("X")]("Microsoft.XMLHTTP");
961
961
  } catch {}
962
962
  }
963
963
  //#endregion
964
964
  //#region node_modules/engine.io-client/build/esm/transports/websocket.js
965
- var Ft = typeof navigator < "u" && typeof navigator.product == "string" && navigator.product.toLowerCase() === "reactnative", It = class extends Tt {
965
+ var Ft = typeof navigator < "u" && typeof navigator.product == "string" && navigator.product.toLowerCase() === "reactnative", It = class extends wt {
966
966
  get name() {
967
967
  return "websocket";
968
968
  }
969
969
  doOpen() {
970
- let e = this.uri(), t = this.opts.protocols, n = Ft ? {} : mt(this.opts, "agent", "perMessageDeflate", "pfx", "key", "passphrase", "cert", "ca", "ciphers", "rejectUnauthorized", "localAddress", "protocolVersion", "origin", "maxPayload", "family", "checkServerIdentity");
970
+ let e = this.uri(), t = this.opts.protocols, n = Ft ? {} : pt(this.opts, "agent", "perMessageDeflate", "pfx", "key", "passphrase", "cert", "ca", "ciphers", "rejectUnauthorized", "localAddress", "protocolVersion", "origin", "maxPayload", "family", "checkServerIdentity");
971
971
  this.opts.extraHeaders && (n.headers = this.opts.extraHeaders);
972
972
  try {
973
973
  this.ws = this.createSocket(e, t, n);
@@ -988,11 +988,11 @@ var Ft = typeof navigator < "u" && typeof navigator.product == "string" && navig
988
988
  this.writable = !1;
989
989
  for (let t = 0; t < e.length; t++) {
990
990
  let n = e[t], r = t === e.length - 1;
991
- qe(n, this.supportsBinary, (e) => {
991
+ Je(n, this.supportsBinary, (e) => {
992
992
  try {
993
993
  this.doWrite(n, e);
994
994
  } catch {}
995
- r && dt(() => {
995
+ r && ut(() => {
996
996
  this.writable = !0, this.emitReserved("drain");
997
997
  }, this.setTimeoutFn);
998
998
  });
@@ -1003,9 +1003,9 @@ var Ft = typeof navigator < "u" && typeof navigator.product == "string" && navig
1003
1003
  }
1004
1004
  uri() {
1005
1005
  let e = this.opts.secure ? "wss" : "ws", t = this.query || {};
1006
- return this.opts.timestampRequests && (t[this.opts.timestampParam] = xt()), this.supportsBinary || (t.b64 = 1), this.createUri(e, t);
1006
+ return this.opts.timestampRequests && (t[this.opts.timestampParam] = bt()), this.supportsBinary || (t.b64 = 1), this.createUri(e, t);
1007
1007
  }
1008
- }, Lt = ft.WebSocket || ft.MozWebSocket, Rt = {
1008
+ }, Lt = dt.WebSocket || dt.MozWebSocket, Rt = {
1009
1009
  websocket: class extends It {
1010
1010
  createSocket(e, t, n) {
1011
1011
  return Ft ? new Lt(e, t, n) : t ? new Lt(e, t) : new Lt(e);
@@ -1014,7 +1014,7 @@ var Ft = typeof navigator < "u" && typeof navigator.product == "string" && navig
1014
1014
  this.ws.send(t);
1015
1015
  }
1016
1016
  },
1017
- webtransport: class extends Tt {
1017
+ webtransport: class extends wt {
1018
1018
  get name() {
1019
1019
  return "webtransport";
1020
1020
  }
@@ -1030,7 +1030,7 @@ var Ft = typeof navigator < "u" && typeof navigator.product == "string" && navig
1030
1030
  this.onError("webtransport error", e);
1031
1031
  }), this._transport.ready.then(() => {
1032
1032
  this._transport.createBidirectionalStream().then((e) => {
1033
- let t = lt(2 ** 53 - 1, this.socket.binaryType), n = e.readable.pipeThrough(t).getReader(), r = at();
1033
+ let t = ct(2 ** 53 - 1, this.socket.binaryType), n = e.readable.pipeThrough(t).getReader(), r = it();
1034
1034
  r.readable.pipeTo(e.writable), this._writer = r.writable.getWriter();
1035
1035
  let i = () => {
1036
1036
  n.read().then(({ done: e, value: t }) => {
@@ -1048,7 +1048,7 @@ var Ft = typeof navigator < "u" && typeof navigator.product == "string" && navig
1048
1048
  for (let t = 0; t < e.length; t++) {
1049
1049
  let n = e[t], r = t === e.length - 1;
1050
1050
  this._writer.write(n).then(() => {
1051
- r && dt(() => {
1051
+ r && ut(() => {
1052
1052
  this.writable = !0, this.emitReserved("drain");
1053
1053
  }, this.setTimeoutFn);
1054
1054
  });
@@ -1100,13 +1100,13 @@ var Wt = typeof addEventListener == "function" && typeof removeEventListener ==
1100
1100
  Wt && addEventListener("offline", () => {
1101
1101
  Gt.forEach((e) => e());
1102
1102
  }, !1);
1103
- var Kt = class e extends W {
1103
+ var Kt = class e extends G {
1104
1104
  constructor(e, t) {
1105
- if (super(), this.binaryType = pt, this.writeBuffer = [], this._prevBufferLen = 0, this._pingInterval = -1, this._pingTimeout = -1, this._maxPayload = -1, this._pingTimeoutTime = Infinity, e && typeof e == "object" && (t = e, e = null), e) {
1105
+ if (super(), this.binaryType = ft, this.writeBuffer = [], this._prevBufferLen = 0, this._pingInterval = -1, this._pingTimeout = -1, this._maxPayload = -1, this._pingTimeoutTime = Infinity, e && typeof e == "object" && (t = e, e = null), e) {
1106
1106
  let n = Vt(e);
1107
1107
  t.hostname = n.host, t.secure = n.protocol === "https" || n.protocol === "wss", t.port = n.port, n.query && (t.query = n.query);
1108
1108
  } else t.host && (t.hostname = Vt(t.host).host);
1109
- _t(this, t), this.secure = t.secure == null ? typeof location < "u" && location.protocol === "https:" : t.secure, t.hostname && !t.port && (t.port = this.secure ? "443" : "80"), this.hostname = t.hostname || (typeof location < "u" ? location.hostname : "localhost"), this.port = t.port || (typeof location < "u" && location.port ? location.port : this.secure ? "443" : "80"), this.transports = [], this._transportsByName = {}, t.transports.forEach((e) => {
1109
+ gt(this, t), this.secure = t.secure == null ? typeof location < "u" && location.protocol === "https:" : t.secure, t.hostname && !t.port && (t.port = this.secure ? "443" : "80"), this.hostname = t.hostname || (typeof location < "u" ? location.hostname : "localhost"), this.port = t.port || (typeof location < "u" && location.port ? location.port : this.secure ? "443" : "80"), this.transports = [], this._transportsByName = {}, t.transports.forEach((e) => {
1110
1110
  let t = e.prototype.name;
1111
1111
  this.transports.push(t), this._transportsByName[t] = e;
1112
1112
  }), this.opts = Object.assign({
@@ -1121,7 +1121,7 @@ var Kt = class e extends W {
1121
1121
  perMessageDeflate: { threshold: 1024 },
1122
1122
  transportOptions: {},
1123
1123
  closeOnBeforeunload: !1
1124
- }, t), this.opts.path = this.opts.path.replace(/\/$/, "") + (this.opts.addTrailingSlash ? "/" : ""), typeof this.opts.query == "string" && (this.opts.query = Ct(this.opts.query)), Wt && (this.opts.closeOnBeforeunload && (this._beforeunloadEventListener = () => {
1124
+ }, t), this.opts.path = this.opts.path.replace(/\/$/, "") + (this.opts.addTrailingSlash ? "/" : ""), typeof this.opts.query == "string" && (this.opts.query = St(this.opts.query)), Wt && (this.opts.closeOnBeforeunload && (this._beforeunloadEventListener = () => {
1125
1125
  this.transport && (this.transport.removeAllListeners(), this.transport.close());
1126
1126
  }, addEventListener("beforeunload", this._beforeunloadEventListener, !1)), this.hostname !== "localhost" && (this._offlineEventListener = () => {
1127
1127
  this._onClose("transport close", { description: "network connection lost" });
@@ -1198,7 +1198,7 @@ var Kt = class e extends W {
1198
1198
  let e = 1;
1199
1199
  for (let t = 0; t < this.writeBuffer.length; t++) {
1200
1200
  let n = this.writeBuffer[t].data;
1201
- if (n && (e += yt(n)), t > 0 && e > this._maxPayload) return this.writeBuffer.slice(0, t);
1201
+ if (n && (e += vt(n)), t > 0 && e > this._maxPayload) return this.writeBuffer.slice(0, t);
1202
1202
  e += 2;
1203
1203
  }
1204
1204
  return this.writeBuffer;
@@ -1206,7 +1206,7 @@ var Kt = class e extends W {
1206
1206
  _hasPingExpired() {
1207
1207
  if (!this._pingTimeoutTime) return !0;
1208
1208
  let e = Date.now() > this._pingTimeoutTime;
1209
- return e && (this._pingTimeoutTime = 0, dt(() => {
1209
+ return e && (this._pingTimeoutTime = 0, ut(() => {
1210
1210
  this._onClose("ping timeout");
1211
1211
  }, this.setTimeoutFn)), e;
1212
1212
  }
@@ -1425,7 +1425,7 @@ var un = class {
1425
1425
  let t = rn(e), n = this.encodeAsString(t.packet), r = t.buffers;
1426
1426
  return r.unshift(n), r;
1427
1427
  }
1428
- }, dn = class e extends W {
1428
+ }, dn = class e extends G {
1429
1429
  constructor(e) {
1430
1430
  super(), this.opts = Object.assign({
1431
1431
  reviver: void 0,
@@ -1558,7 +1558,7 @@ var bn = Object.freeze({
1558
1558
  disconnecting: 1,
1559
1559
  newListener: 1,
1560
1560
  removeListener: 1
1561
- }), xn = class extends W {
1561
+ }), xn = class extends G {
1562
1562
  constructor(e, t, n) {
1563
1563
  super(), this.connected = !1, this.recovered = !1, this.receiveBuffer = [], this.sendBuffer = [], this._queue = [], this._queueSeq = 0, this.ids = 0, this.acks = {}, this.flags = {}, this.io = e, this.nsp = t, n && n.auth && (this.auth = n.auth), this._opts = Object.assign({}, n), this.io._autoConnect && this.open();
1564
1564
  }
@@ -1811,9 +1811,9 @@ Sn.prototype.duration = function() {
1811
1811
  };
1812
1812
  //#endregion
1813
1813
  //#region node_modules/socket.io-client/build/esm/manager.js
1814
- var Cn = class extends W {
1814
+ var Cn = class extends G {
1815
1815
  constructor(e, t) {
1816
- super(), this.nsps = {}, this.subs = [], e && typeof e == "object" && (t = e, e = void 0), t ||= {}, t.path = t.path || "/socket.io", this.opts = t, _t(this, t), this.reconnection(t.reconnection !== !1), this.reconnectionAttempts(t.reconnectionAttempts || Infinity), this.reconnectionDelay(t.reconnectionDelay || 1e3), this.reconnectionDelayMax(t.reconnectionDelayMax || 5e3), this.randomizationFactor(t.randomizationFactor ?? .5), this.backoff = new Sn({
1816
+ super(), this.nsps = {}, this.subs = [], e && typeof e == "object" && (t = e, e = void 0), t ||= {}, t.path = t.path || "/socket.io", this.opts = t, gt(this, t), this.reconnection(t.reconnection !== !1), this.reconnectionAttempts(t.reconnectionAttempts || Infinity), this.reconnectionDelay(t.reconnectionDelay || 1e3), this.reconnectionDelayMax(t.reconnectionDelayMax || 5e3), this.randomizationFactor(t.randomizationFactor ?? .5), this.backoff = new Sn({
1817
1817
  min: this.reconnectionDelay(),
1818
1818
  max: this.reconnectionDelayMax(),
1819
1819
  jitter: this.randomizationFactor()
@@ -1884,7 +1884,7 @@ var Cn = class extends W {
1884
1884
  }
1885
1885
  }
1886
1886
  ondecoded(e) {
1887
- dt(() => {
1887
+ ut(() => {
1888
1888
  this.emitReserved("packet", e);
1889
1889
  }, this.setTimeoutFn);
1890
1890
  }
@@ -3322,47 +3322,47 @@ function yi({ siteId: e, config: t, children: n, language: r = "en" }) {
3322
3322
  message: "Looks like you're already on this page!",
3323
3323
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
3324
3324
  }]);
3325
- }, []), [D, O] = m(ge().isOpen), [k, A] = m(ge().activeScreen), [j, M] = m(ge().isHumanHandled), [ae, P] = m(ge().agentName), [oe, F] = m(ge().agentHeadshot), [se, le] = m(() => ve(i?.siteId)), [fe, I] = m(!1), [be, L] = m(!1), [Se, Ce] = m("idle"), [we, Te] = m(!1), [Ee, De] = m(!1), [Oe, ke] = m(""), [je, Me] = m(!1), [Ne, Pe] = m(0), [Fe, Ie] = m(0), [Le, Re] = m(!1), [R, z] = m(null), [B, He] = m(null), [Ue, We] = m("idle"), [Ge, Ke] = m(null), [qe, Je] = m(!1), [Ye, Xe] = m(""), [Ze, Qe] = m(!1), V = p(null), H = p(null), $e = p(""), U = p(!1), et = p(null), tt = p(null), nt = p(null), rt = p(null), it = p(null), at = p(null), ot = p(null), st = p(!1), ct = p({
3325
+ }, []), [D, O] = m(ge().isOpen), [k, A] = m(ge().activeScreen), [j, M] = m(ge().isHumanHandled), [N, P] = m(ge().agentName), [oe, F] = m(ge().agentHeadshot), [se, le] = m(() => ve(i?.siteId)), [fe, be] = m(!1), [xe, I] = m(!1), [Se, Ce] = m("idle"), [we, Te] = m(!1), [Ee, De] = m(!1), [Oe, ke] = m(""), [je, Me] = m(!1), [Ne, Pe] = m(0), [Fe, Ie] = m(0), [Le, Re] = m(!1), [R, ze] = m(null), [z, Ue] = m(null), [We, Ge] = m("idle"), [Ke, qe] = m(null), [Je, Ye] = m(!1), [Xe, B] = m(""), [Ze, Qe] = m(!1), V = p(null), H = p(null), $e = p(""), et = p(!1), U = p(null), W = p(null), tt = p(null), nt = p(null), rt = p(null), it = p(null), at = p(null), ot = p(!1), st = p({
3326
3326
  url: null,
3327
3327
  at: 0
3328
- }), lt = o((e, t) => {
3328
+ }), ct = o((e, t) => {
3329
3329
  Wn(6e3);
3330
3330
  let n = e;
3331
3331
  try {
3332
3332
  n = new URL(e, window.location.origin).href;
3333
3333
  } catch {}
3334
- let r = ct.current;
3334
+ let r = st.current;
3335
3335
  return r.url === n && Date.now() - r.at < 4e3 ? Promise.resolve({
3336
3336
  navigated: !0,
3337
3337
  deduped: !0
3338
- }) : (ct.current = {
3338
+ }) : (st.current = {
3339
3339
  url: n,
3340
3340
  at: Date.now()
3341
3341
  }, Ar(e, t));
3342
- }, []), W = p([]), ut = p(null), dt = p(null), ft = p(null), pt = p(!1), mt = p(!1), ht = p(""), gt = p(null), _t = p(null), vt = p([]), yt = p(0), bt = p(ae), xt = p([]), St = p(!1), Ct = p(!1), wt = p(i), Tt = p({
3342
+ }, []), G = p([]), lt = p(null), ut = p(null), dt = p(null), ft = p(!1), pt = p(!1), mt = p(""), ht = p(null), gt = p(null), _t = p([]), vt = p(0), yt = p(N), bt = p([]), xt = p(!1), St = p(!1), Ct = p(i), wt = p({
3343
3343
  notifyRouteChange: () => {},
3344
3344
  cleanup: () => {}
3345
- }), Et = o((e = {}) => {
3345
+ }), Tt = o((e = {}) => {
3346
3346
  let t = !!e.is_human_handled;
3347
3347
  return M(t), t ? (A("agent"), e.agent_info?.name && P(e.agent_info.name), e.agent_info?.headshot && F(e.agent_info.headshot), t) : (A("ai"), t);
3348
- }, []), Dt = f(() => {
3348
+ }, []), Et = f(() => {
3349
3349
  let e = _?.widgetSettings?.call?.maxDurationSeconds ?? i?.widgetSettings?.call?.maxDurationSeconds ?? i?.callMaxDurationSeconds, t = Number(e);
3350
3350
  return Number.isFinite(t) && t > 0 ? t : te;
3351
3351
  }, [i, _]);
3352
3352
  c(() => {
3353
- tt.current = R;
3353
+ W.current = R;
3354
3354
  }, [R]), c(() => {
3355
- bt.current = ae;
3356
- }, [ae]), c(() => {
3357
- Ct.current = je;
3355
+ yt.current = N;
3356
+ }, [N]), c(() => {
3357
+ St.current = je;
3358
3358
  }, [je]), c(() => {
3359
- wt.current = i;
3359
+ Ct.current = i;
3360
3360
  }, [i]);
3361
- let Ot = () => {
3362
- Xe("");
3363
- }, kt = o(() => {
3364
- ft.current &&= (window.clearTimeout(ft.current), null);
3365
- }, []), At = (e) => {
3361
+ let Dt = () => {
3362
+ B("");
3363
+ }, Ot = o(() => {
3364
+ dt.current &&= (window.clearTimeout(dt.current), null);
3365
+ }, []), kt = (e) => {
3366
3366
  let t = typeof e == "string" ? e.trim().toLowerCase() : "";
3367
3367
  return le(t), ye(t, i?.siteId), t;
3368
3368
  };
@@ -3376,12 +3376,12 @@ function yi({ siteId: e, config: t, children: n, language: r = "en" }) {
3376
3376
  }
3377
3377
  le((t) => (t && ye(t, e), t));
3378
3378
  }, [i?.siteId]);
3379
- let G = (e = "unspecified") => {
3380
- let t = ut.current || at.current?.callId, n = yt.current, r = gt.current;
3381
- if (gt.current = null, yt.current = 0, r && r.state !== "inactive") {
3379
+ let At = (e = "unspecified") => {
3380
+ let t = lt.current || it.current?.callId, n = vt.current, r = ht.current;
3381
+ if (ht.current = null, vt.current = 0, r && r.state !== "inactive") {
3382
3382
  r.onstop = () => {
3383
- let e = vt.current;
3384
- if (vt.current = [], e.length > 0 && t && H.current) {
3383
+ let e = _t.current;
3384
+ if (_t.current = [], e.length > 0 && t && H.current) {
3385
3385
  let r = new Blob(e, { type: e[0].type }), i = n > 0 ? Math.round((Date.now() - n) / 1e3) : 0;
3386
3386
  H.current.uploadRecording(t, r, i).then((e) => console.log("[FlowEngageCall] recording upload success", e)).catch((e) => console.warn("[FlowEngageCall] recording upload failed", e));
3387
3387
  }
@@ -3389,42 +3389,42 @@ function yi({ siteId: e, config: t, children: n, language: r = "en" }) {
3389
3389
  try {
3390
3390
  r.stop();
3391
3391
  } catch {
3392
- r.onstop = null, vt.current = [];
3392
+ r.onstop = null, _t.current = [];
3393
3393
  }
3394
3394
  } else if (r && r.state === "inactive") {
3395
- let e = vt.current;
3396
- if (vt.current = [], e.length > 0 && t && H.current) {
3395
+ let e = _t.current;
3396
+ if (_t.current = [], e.length > 0 && t && H.current) {
3397
3397
  let r = new Blob(e, { type: e[0].type }), i = n > 0 ? Math.round((Date.now() - n) / 1e3) : 0;
3398
3398
  H.current.uploadRecording(t, r, i).then((e) => console.log("[FlowEngageCall] recording upload success", e)).catch((e) => console.warn("[FlowEngageCall] recording upload failed", e));
3399
3399
  }
3400
- } else vt.current = [];
3401
- if (_t.current) {
3400
+ } else _t.current = [];
3401
+ if (gt.current) {
3402
3402
  try {
3403
- _t.current.close();
3403
+ gt.current.close();
3404
3404
  } catch {}
3405
- _t.current = null;
3405
+ gt.current = null;
3406
3406
  }
3407
- nt.current &&= (nt.current.close(), null), rt.current &&= (rt.current.getTracks().forEach((e) => e.stop()), null), it.current &&= (it.current.srcObject = null, it.current.remove(), null), kt(), at.current = null, W.current = [], ut.current = null, dt.current = null, pt.current = !1, Je(!1), z(null), He(null), We("idle"), Ke(null);
3407
+ tt.current &&= (tt.current.close(), null), nt.current &&= (nt.current.getTracks().forEach((e) => e.stop()), null), rt.current &&= (rt.current.srcObject = null, rt.current.remove(), null), Ot(), it.current = null, G.current = [], lt.current = null, ut.current = null, ft.current = !1, Ye(!1), ze(null), Ue(null), Ge("idle"), qe(null);
3408
3408
  }, jt = (e = (/* @__PURE__ */ new Date()).toISOString()) => {
3409
- let t = V.current, n = ut.current || at.current?.callId;
3410
- if (!(!t?.connected || !n || pt.current)) {
3411
- pt.current = !0, t.emit("call:connected", {
3409
+ let t = V.current, n = lt.current || it.current?.callId;
3410
+ if (!(!t?.connected || !n || ft.current)) {
3411
+ ft.current = !0, t.emit("call:connected", {
3412
3412
  callId: n,
3413
3413
  chatId: $e.current,
3414
3414
  connectedAt: e
3415
3415
  });
3416
3416
  try {
3417
- let e = rt.current, t = it.current?.srcObject;
3418
- if (e && t && !gt.current) {
3419
- vt.current = [];
3417
+ let e = nt.current, t = rt.current?.srcObject;
3418
+ if (e && t && !ht.current) {
3419
+ _t.current = [];
3420
3420
  let n = new (window.AudioContext || window.webkitAudioContext)();
3421
- _t.current = n;
3421
+ gt.current = n;
3422
3422
  let r = n.createMediaStreamDestination();
3423
3423
  n.createMediaStreamSource(e).connect(r), n.createMediaStreamSource(t).connect(r);
3424
3424
  let i = window.MediaRecorder.isTypeSupported("audio/webm") ? "audio/webm" : "audio/mp4", a = new window.MediaRecorder(r.stream, { mimeType: i });
3425
3425
  a.ondataavailable = (e) => {
3426
- e.data && e.data.size > 0 && vt.current.push(e.data);
3427
- }, gt.current = a, yt.current = Date.now(), a.start(1e3), setTimeout(() => {
3426
+ e.data && e.data.size > 0 && _t.current.push(e.data);
3427
+ }, ht.current = a, vt.current = Date.now(), a.start(1e3), setTimeout(() => {
3428
3428
  try {
3429
3429
  if (!window.speechSynthesis) return;
3430
3430
  let e = new SpeechSynthesisUtterance("This call is being recorded for quality and training purposes.");
@@ -3454,26 +3454,26 @@ function yi({ siteId: e, config: t, children: n, language: r = "en" }) {
3454
3454
  }
3455
3455
  }, Mt = (e = {}) => {
3456
3456
  if (!e.callId) return;
3457
- let t = dt.current === e.callId, n = ut.current === e.callId, r = tt.current?.callId === e.callId;
3457
+ let t = ut.current === e.callId, n = lt.current === e.callId, r = W.current?.callId === e.callId;
3458
3458
  if (!(!t && !n && !r)) {
3459
- if (kt(), z(null), t || n) {
3460
- ut.current = e.callId, He(e.callId), We((e) => e === "connected" ? e : "connecting"), O(!0);
3459
+ if (Ot(), ze(null), t || n) {
3460
+ lt.current = e.callId, Ue(e.callId), Ge((e) => e === "connected" ? e : "connecting"), O(!0);
3461
3461
  return;
3462
3462
  }
3463
- We("idle");
3463
+ Ge("idle");
3464
3464
  }
3465
3465
  }, Nt = (e = {}) => {
3466
3466
  if (!e.callId) return;
3467
- let t = dt.current === e.callId, n = ut.current === e.callId, r = tt.current?.callId === e.callId;
3467
+ let t = ut.current === e.callId, n = lt.current === e.callId, r = W.current?.callId === e.callId;
3468
3468
  if (!(!t && !n && !r)) {
3469
- if (kt(), n) {
3470
- G();
3469
+ if (Ot(), n) {
3470
+ At();
3471
3471
  return;
3472
3472
  }
3473
- dt.current = null, at.current = null, W.current = [], z(null), We("idle");
3473
+ ut.current = null, it.current = null, G.current = [], ze(null), Ge("idle");
3474
3474
  }
3475
3475
  }, Pt = async (e = {}) => {
3476
- let t = nt.current, n = V.current, r = e.sdpOffer || e.offer?.sdp;
3476
+ let t = tt.current, n = V.current, r = e.sdpOffer || e.offer?.sdp;
3477
3477
  if (!t || !n?.connected || !r || !e.callId) {
3478
3478
  console.log("[FlowEngageProvider] deferring remote offer until peer/socket ready", {
3479
3479
  callId: e.callId,
@@ -3481,20 +3481,20 @@ function yi({ siteId: e, config: t, children: n, language: r = "en" }) {
3481
3481
  hasPeerConnection: !!t,
3482
3482
  socketConnected: !!n?.connected,
3483
3483
  hasOffer: !!r
3484
- }), at.current = e;
3484
+ }), it.current = e;
3485
3485
  return;
3486
3486
  }
3487
3487
  if (await t.setRemoteDescription(new RTCSessionDescription({
3488
3488
  type: "offer",
3489
3489
  sdp: r
3490
- })), W.current.length > 0) {
3490
+ })), G.current.length > 0) {
3491
3491
  console.log("[FlowEngageProvider] flushing queued agent ICE candidates after remote offer", {
3492
3492
  callId: e.callId,
3493
3493
  chatId: $e.current,
3494
- queuedCount: W.current.length
3494
+ queuedCount: G.current.length
3495
3495
  });
3496
- for (let e of W.current) await t.addIceCandidate(new RTCIceCandidate(e));
3497
- W.current = [];
3496
+ for (let e of G.current) await t.addIceCandidate(new RTCIceCandidate(e));
3497
+ G.current = [];
3498
3498
  }
3499
3499
  let i = await t.createAnswer();
3500
3500
  await t.setLocalDescription(i), n.emit("call:answer", {
@@ -3508,26 +3508,26 @@ function yi({ siteId: e, config: t, children: n, language: r = "en" }) {
3508
3508
  isOpen: D,
3509
3509
  activeScreen: k,
3510
3510
  isHumanHandled: j,
3511
- agentName: ae,
3511
+ agentName: N,
3512
3512
  agentHeadshot: oe
3513
3513
  });
3514
3514
  }, [
3515
3515
  D,
3516
3516
  k,
3517
3517
  j,
3518
- ae,
3518
+ N,
3519
3519
  oe
3520
3520
  ]), c(() => {
3521
3521
  let e = !0;
3522
3522
  return (async () => {
3523
3523
  Qe(!0);
3524
3524
  try {
3525
- let t = E(i), n = await Be(t);
3525
+ let t = E(i), n = await Ve(t);
3526
3526
  if (!e) return;
3527
- let a = t.siteId, o = pe(a), s = xe(a), c = "";
3527
+ let a = t.siteId, o = pe(a), s = L(a), c = "";
3528
3528
  try {
3529
- let e = U.current, r = et.current;
3530
- if (U.current = !1, et.current = null, c = (await ze({
3529
+ let e = et.current, r = U.current;
3530
+ if (et.current = !1, U.current = null, c = (await Be({
3531
3531
  apiBaseUrl: t.apiBaseUrl,
3532
3532
  userId: n.userId,
3533
3533
  siteId: a,
@@ -3538,10 +3538,10 @@ function yi({ siteId: e, config: t, children: n, language: r = "en" }) {
3538
3538
  }))?.data?.chatId, !c) throw Error("resolve-session returned no chatId");
3539
3539
  ie(), he(a, c);
3540
3540
  } catch (e) {
3541
- console.warn("[FlowEngageProvider] resolve-session failed, reusing persisted or ephemeral chat id", e?.message || e), c = o || N(), he(a, c);
3541
+ console.warn("[FlowEngageProvider] resolve-session failed, reusing persisted or ephemeral chat id", e?.message || e), c = o || ae(), he(a, c);
3542
3542
  }
3543
3543
  $e.current = c;
3544
- let l = Ve({
3544
+ let l = He({
3545
3545
  apiBaseUrl: t.apiBaseUrl,
3546
3546
  userId: n.userId,
3547
3547
  siteId: t.siteId,
@@ -3561,20 +3561,20 @@ function yi({ siteId: e, config: t, children: n, language: r = "en" }) {
3561
3561
  Ce("connected");
3562
3562
  let e = $e.current;
3563
3563
  if (e && H.current) try {
3564
- Et(await H.current.checkHumanHandled(e));
3564
+ Tt(await H.current.checkHumanHandled(e));
3565
3565
  } catch {}
3566
3566
  }), f.on("disconnect", () => {
3567
3567
  Ce("disconnected");
3568
3568
  }), f.on("aiTyping", () => {
3569
- L(!0);
3569
+ I(!0);
3570
3570
  }), f.on("ai:typing", () => {
3571
- L(!0);
3571
+ I(!0);
3572
3572
  }), f.on("messageReceived", (e) => {
3573
3573
  let t = e.message || e, n = {
3574
3574
  ...t,
3575
3575
  message: fi(t.message)
3576
3576
  };
3577
- L(!1), I(!1), !(n.type === "call_recording" || typeof n.message == "string" && n.message.includes("AI chat recording")) && S((e) => [...e.filter((e) => !e.isPending), {
3577
+ I(!1), be(!1), !(n.type === "call_recording" || typeof n.message == "string" && n.message.includes("AI chat recording")) && S((e) => [...e.filter((e) => !e.isPending), {
3578
3578
  ...n,
3579
3579
  isPending: !1,
3580
3580
  id: n.messageId || `${n.sender}-${Date.now()}-${Math.random()}`
@@ -3592,7 +3592,7 @@ function yi({ siteId: e, config: t, children: n, language: r = "en" }) {
3592
3592
  ...t,
3593
3593
  message: fi(t.message)
3594
3594
  };
3595
- L(!1), !(n.type === "call_recording" || typeof n.message == "string" && n.message.includes("AI chat recording")) && ((n.sender === "agent" || n.agent_name || n.sender === "ai" || n.sender === "bot") && I(!1), S((e) => n.sender === "bot" || n.sender === "ai" ? [...e, {
3595
+ I(!1), !(n.type === "call_recording" || typeof n.message == "string" && n.message.includes("AI chat recording")) && ((n.sender === "agent" || n.agent_name || n.sender === "ai" || n.sender === "bot") && be(!1), S((e) => n.sender === "bot" || n.sender === "ai" ? [...e, {
3596
3596
  ...n,
3597
3597
  isPending: !1,
3598
3598
  id: n.messageId || `${n.sender}-${Date.now()}-${Math.random()}`
@@ -3615,7 +3615,7 @@ function yi({ siteId: e, config: t, children: n, language: r = "en" }) {
3615
3615
  e.agent?.name,
3616
3616
  e.agentName,
3617
3617
  e.agent_name,
3618
- bt.current
3618
+ yt.current
3619
3619
  ], d);
3620
3620
  M(!0), A("agent"), P(t), F(e.agent?.headshot || null), O(!0), Pe((e) => e + 1), S((e) => vi(e, {
3621
3621
  id: `agent-joined-${Date.now()}`,
@@ -3629,7 +3629,7 @@ function yi({ siteId: e, config: t, children: n, language: r = "en" }) {
3629
3629
  e.agent?.name,
3630
3630
  e.agentName,
3631
3631
  e.agent_name,
3632
- bt.current
3632
+ yt.current
3633
3633
  ], d);
3634
3634
  M(!1), A("ai"), S((e) => vi(e, {
3635
3635
  id: `agent-left-${Date.now()}`,
@@ -3651,30 +3651,30 @@ function yi({ siteId: e, config: t, children: n, language: r = "en" }) {
3651
3651
  }]);
3652
3652
  }), f.on("chat:history_update", (e) => {
3653
3653
  let t = pi(e.chat_history || []);
3654
- S(t), t.length === 0 && (Re(!1), M(!1), A("ai"), L(!1), I(!1));
3654
+ S(t), t.length === 0 && (Re(!1), M(!1), A("ai"), I(!1), be(!1));
3655
3655
  }), f.on("conversation:reset", () => {
3656
- S([]), Re(!1), M(!1), A("ai"), L(!1), I(!1);
3656
+ S([]), Re(!1), M(!1), A("ai"), I(!1), be(!1);
3657
3657
  }), f.on("voice:end_session", (e = {}) => {
3658
3658
  console.log("[FlowEngageProvider] voice:end_session received — ending voice session"), Ie((e) => e + 1), O(!0), Pe((e) => e + 1);
3659
3659
  }), f.on("typing:start", (e) => {
3660
- e.sender === "agent" && I(!0);
3660
+ e.sender === "agent" && be(!0);
3661
3661
  }), f.on("typing:stop", (e) => {
3662
- e.sender === "agent" && I(!1);
3662
+ e.sender === "agent" && be(!1);
3663
3663
  }), f.on("call:incoming", (e = {}) => {
3664
3664
  let t = _i([
3665
3665
  e.agentName,
3666
3666
  e.ownerName,
3667
3667
  e.agent?.name,
3668
- bt.current
3668
+ yt.current
3669
3669
  ], "Agent");
3670
- Ot(), kt(), pt.current = !1, z({
3670
+ Dt(), Ot(), ft.current = !1, ze({
3671
3671
  callId: e.callId,
3672
3672
  from: e.from || "owner",
3673
3673
  agentId: e.agentId || null,
3674
3674
  agentName: t
3675
- }), P((e) => _i([t, e], "Agent")), We("incoming"), Ke(null), O(!0);
3675
+ }), P((e) => _i([t, e], "Agent")), Ge("incoming"), qe(null), O(!0);
3676
3676
  }), f.on("call:offer", async (e = {}) => {
3677
- at.current = e;
3677
+ it.current = e;
3678
3678
  try {
3679
3679
  await Pt(e);
3680
3680
  } catch (e) {
@@ -3687,20 +3687,20 @@ function yi({ siteId: e, config: t, children: n, language: r = "en" }) {
3687
3687
  console.warn("[FlowEngageProvider] ignoring invalid ICE candidate payload", e);
3688
3688
  return;
3689
3689
  }
3690
- if (!nt.current || !nt.current.remoteDescription) {
3690
+ if (!tt.current || !tt.current.remoteDescription) {
3691
3691
  console.log("[FlowEngageProvider] queueing agent ICE candidate until peer/remote description is ready", {
3692
3692
  callId: e.callId,
3693
3693
  chatId: e.chatId || $e.current,
3694
- queueSize: W.current.length + 1
3695
- }), W.current.push(t);
3694
+ queueSize: G.current.length + 1
3695
+ }), G.current.push(t);
3696
3696
  return;
3697
3697
  }
3698
- await nt.current.addIceCandidate(new RTCIceCandidate(t));
3698
+ await tt.current.addIceCandidate(new RTCIceCandidate(t));
3699
3699
  } catch (e) {
3700
3700
  console.error("[FlowEngageProvider] failed to add ICE candidate", e);
3701
3701
  }
3702
3702
  }), f.on("call:ended", () => {
3703
- Ot(), G("socket:call_ended");
3703
+ Dt(), At("socket:call_ended");
3704
3704
  }), f.on("call:accepted", (e = {}) => {
3705
3705
  Mt(e);
3706
3706
  }), f.on("call:accepted_by_other", (e = {}) => {
@@ -3713,18 +3713,18 @@ function yi({ siteId: e, config: t, children: n, language: r = "en" }) {
3713
3713
  Nt(e);
3714
3714
  }), f.on("call:connected", (e = {}) => {
3715
3715
  if (!e.callId) return;
3716
- let t = dt.current === e.callId, n = ut.current === e.callId, r = at.current?.callId === e.callId, i = tt.current?.callId === e.callId;
3716
+ let t = ut.current === e.callId, n = lt.current === e.callId, r = it.current?.callId === e.callId, i = W.current?.callId === e.callId;
3717
3717
  if (!t && !n && !r) {
3718
- i && (z(null), We("idle"));
3718
+ i && (ze(null), Ge("idle"));
3719
3719
  return;
3720
3720
  }
3721
- pt.current = !0, dt.current = null, ut.current = e.callId, He(e.callId), z(null), We("connected"), Ke(e.connectedAt || (/* @__PURE__ */ new Date()).toISOString()), O(!0);
3721
+ ft.current = !0, ut.current = null, lt.current = e.callId, Ue(e.callId), ze(null), Ge("connected"), qe(e.connectedAt || (/* @__PURE__ */ new Date()).toISOString()), O(!0);
3722
3722
  }), f.on("call:unavailable", (e = {}) => {
3723
- G("socket:call_unavailable"), Xe(hi(e, "This visitor is not available for a call right now.")), O(!0);
3723
+ At("socket:call_unavailable"), B(hi(e, "This visitor is not available for a call right now.")), O(!0);
3724
3724
  }), f.on("call:error", (e = {}) => {
3725
- G("socket:call_error"), Xe(hi(e, "We couldn't connect the call right now.")), O(!0);
3725
+ At("socket:call_error"), B(hi(e, "We couldn't connect the call right now.")), O(!0);
3726
3726
  }), f.on("visitor:navigate", async ({ url: e, section: t, highlight: n } = {}) => {
3727
- e && lt(e, { voiceActive: Ct.current }).then(({ navigated: e, reason: r }) => {
3727
+ e && ct(e, { voiceActive: St.current }).then(({ navigated: e, reason: r }) => {
3728
3728
  if (!e) {
3729
3729
  r === "not-found" ? C() : r === "already-on-page" && T();
3730
3730
  return;
@@ -3741,7 +3741,7 @@ function yi({ siteId: e, config: t, children: n, language: r = "en" }) {
3741
3741
  n && hr(n);
3742
3742
  }), f.on("visitor:clear_highlight", () => {
3743
3743
  gr();
3744
- }), Tt.current = Dn({
3744
+ }), wt.current = Dn({
3745
3745
  socket: f,
3746
3746
  chatId: c
3747
3747
  });
@@ -3749,7 +3749,7 @@ function yi({ siteId: e, config: t, children: n, language: r = "en" }) {
3749
3749
  if (!e) return;
3750
3750
  S(pi(h.chat_history || [])), M(!!h.is_human_handled), A(h.is_human_handled ? "agent" : k);
3751
3751
  let g = h?.visitor_email || h?.visitorEmail;
3752
- if (g && String(g).trim() && At(String(g).trim()), await new Promise((e) => setTimeout(e, 500)), !e) return;
3752
+ if (g && String(g).trim() && kt(String(g).trim()), await new Promise((e) => setTimeout(e, 500)), !e) return;
3753
3753
  u("ready");
3754
3754
  } catch (t) {
3755
3755
  if (!e) return;
@@ -3758,16 +3758,16 @@ function yi({ siteId: e, config: t, children: n, language: r = "en" }) {
3758
3758
  e && Qe(!1);
3759
3759
  }
3760
3760
  })(), () => {
3761
- e = !1, Tt.current?.cleanup?.(), G(), V.current?.disconnect();
3761
+ e = !1, wt.current?.cleanup?.(), At(), V.current?.disconnect();
3762
3762
  };
3763
3763
  }, [
3764
3764
  i,
3765
3765
  r,
3766
3766
  a
3767
3767
  ]), c(() => () => {
3768
- if (je && !St.current && xt.current.length > 0) {
3769
- let e = $e.current, t = xt.current, n = H.current;
3770
- n && e && t.length > 0 && (console.log("[FlowEngageProvider] safety-net: syncing voice transcript on unmount"), n.beaconSyncVoice(e, t) || n.syncVoice(e, t).catch(() => {}), St.current = !0);
3768
+ if (je && !xt.current && bt.current.length > 0) {
3769
+ let e = $e.current, t = bt.current, n = H.current;
3770
+ n && e && t.length > 0 && (console.log("[FlowEngageProvider] safety-net: syncing voice transcript on unmount"), n.beaconSyncVoice(e, t) || n.syncVoice(e, t).catch(() => {}), xt.current = !0);
3771
3771
  }
3772
3772
  }, [je, _]);
3773
3773
  let Ft = p(null);
@@ -3783,10 +3783,10 @@ function yi({ siteId: e, config: t, children: n, language: r = "en" }) {
3783
3783
  }, []);
3784
3784
  let It = async () => {
3785
3785
  if (!(!R?.callId || !H.current || !V.current || !y)) {
3786
- Ot(), dt.current = R.callId, kt();
3786
+ Dt(), ut.current = R.callId, Ot();
3787
3787
  try {
3788
3788
  let e = await navigator.mediaDevices.getUserMedia({ audio: !0 });
3789
- rt.current = e;
3789
+ nt.current = e;
3790
3790
  let t = [{ urls: "stun:stun.l.google.com:19302" }];
3791
3791
  try {
3792
3792
  let e = await H.current.getIceServersConfig();
@@ -3795,30 +3795,30 @@ function yi({ siteId: e, config: t, children: n, language: r = "en" }) {
3795
3795
  console.warn("[FlowEngageProvider] ice-config fetch failed, using STUN default", e);
3796
3796
  }
3797
3797
  let n = new RTCPeerConnection({ iceServers: t });
3798
- nt.current = n, n.onconnectionstatechange = () => {
3798
+ tt.current = n, n.onconnectionstatechange = () => {
3799
3799
  let e = n.connectionState;
3800
3800
  if (e === "connected") {
3801
3801
  let e = (/* @__PURE__ */ new Date()).toISOString();
3802
- We("connected"), Ke((t) => t || e), jt(e);
3802
+ Ge("connected"), qe((t) => t || e), jt(e);
3803
3803
  return;
3804
3804
  }
3805
3805
  if (e === "connecting") {
3806
- We((e) => e === "connected" ? e : "connecting");
3806
+ Ge((e) => e === "connected" ? e : "connecting");
3807
3807
  return;
3808
3808
  }
3809
- (e === "failed" || e === "closed") && G(`peer:connection_${e}`);
3809
+ (e === "failed" || e === "closed") && At(`peer:connection_${e}`);
3810
3810
  }, n.oniceconnectionstatechange = () => {
3811
3811
  let e = n.iceConnectionState;
3812
3812
  if (e === "connected" || e === "completed") {
3813
3813
  let e = (/* @__PURE__ */ new Date()).toISOString();
3814
- We("connected"), Ke((t) => t || e), jt(e);
3814
+ Ge("connected"), qe((t) => t || e), jt(e);
3815
3815
  return;
3816
3816
  }
3817
3817
  if (e === "checking" || e === "new") {
3818
- We((e) => e === "connected" ? e : "connecting");
3818
+ Ge((e) => e === "connected" ? e : "connecting");
3819
3819
  return;
3820
3820
  }
3821
- (e === "failed" || e === "closed") && G(`peer:ice_${e}`);
3821
+ (e === "failed" || e === "closed") && At(`peer:ice_${e}`);
3822
3822
  }, n.onsignalingstatechange = () => {}, n.onicegatheringstatechange = () => {}, e.getTracks().forEach((t) => {
3823
3823
  n.addTrack(t, e);
3824
3824
  }), n.onicecandidate = (e) => {
@@ -3834,21 +3834,21 @@ function yi({ siteId: e, config: t, children: n, language: r = "en" }) {
3834
3834
  });
3835
3835
  }, n.ontrack = (e) => {
3836
3836
  let [t] = e.streams || [], [n] = t?.getAudioTracks?.() || [];
3837
- if (!it.current) {
3837
+ if (!rt.current) {
3838
3838
  let e = document.createElement("audio");
3839
- e.id = "flowengage-remote-audio", e.autoplay = !0, e.playsInline = !0, e.onplay = () => {}, e.onpause = () => {}, e.onended = () => {}, e.onerror = (e) => {}, it.current = e, document.body.appendChild(e);
3839
+ e.id = "flowengage-remote-audio", e.autoplay = !0, e.playsInline = !0, e.onplay = () => {}, e.onpause = () => {}, e.onended = () => {}, e.onerror = (e) => {}, rt.current = e, document.body.appendChild(e);
3840
3840
  }
3841
- it.current.srcObject = e.streams[0];
3842
- let r = R?.callId, i = r && (dt.current === r || ut.current === r);
3843
- if (!pt.current && i) {
3841
+ rt.current.srcObject = e.streams[0];
3842
+ let r = R?.callId, i = r && (ut.current === r || lt.current === r);
3843
+ if (!ft.current && i) {
3844
3844
  let e = (/* @__PURE__ */ new Date()).toISOString();
3845
- We("connected"), Ke((t) => t || e), ut.current = r, He(r), jt(e);
3845
+ Ge("connected"), qe((t) => t || e), lt.current = r, Ue(r), jt(e);
3846
3846
  }
3847
- it.current.srcObject = t || null;
3848
- let a = it.current.play?.();
3847
+ rt.current.srcObject = t || null;
3848
+ let a = rt.current.play?.();
3849
3849
  a?.catch && a.catch((e) => {});
3850
3850
  };
3851
- let r = at.current;
3851
+ let r = it.current;
3852
3852
  r && (console.log("[FlowEngageProvider] found pending remote offer during accept", {
3853
3853
  callId: r.callId || R.callId,
3854
3854
  chatId: y
@@ -3858,10 +3858,10 @@ function yi({ siteId: e, config: t, children: n, language: r = "en" }) {
3858
3858
  })), await H.current.acceptCall(R.callId, y), V.current?.emit("call:accepted", {
3859
3859
  callId: R.callId,
3860
3860
  chatId: y
3861
- }), ut.current = R.callId, He(R.callId), We((e) => e === "connected" || pt.current ? "connected" : "connecting"), z(null), O(!0);
3861
+ }), lt.current = R.callId, Ue(R.callId), Ge((e) => e === "connected" || ft.current ? "connected" : "connecting"), ze(null), O(!0);
3862
3862
  } catch (e) {
3863
- if (dt.current = null, G("accept_call_failed"), e?.status === 404 || e?.status === 409 || e?.status === 422) {
3864
- Xe(hi(e, "This visitor call is no longer available."));
3863
+ if (ut.current = null, At("accept_call_failed"), e?.status === 404 || e?.status === 409 || e?.status === 422) {
3864
+ B(hi(e, "This visitor call is no longer available."));
3865
3865
  return;
3866
3866
  }
3867
3867
  if (e?.name === "NotAllowedError" || e?.name === "PermissionDeniedError") {
@@ -3870,19 +3870,19 @@ function yi({ siteId: e, config: t, children: n, language: r = "en" }) {
3870
3870
  } catch (e) {
3871
3871
  console.error("[FlowEngageProvider] failed to reject call after microphone denial", e);
3872
3872
  }
3873
- Xe("Microphone access was denied. Please allow microphone access to accept the call.");
3873
+ B("Microphone access was denied. Please allow microphone access to accept the call.");
3874
3874
  return;
3875
3875
  }
3876
- Xe("We couldn't connect the call right now. Please try again.");
3876
+ B("We couldn't connect the call right now. Please try again.");
3877
3877
  }
3878
3878
  }
3879
3879
  }, Lt = async () => {
3880
3880
  if (!R?.callId || !H.current || !y) {
3881
- G("reject_call_without_server_context");
3881
+ At("reject_call_without_server_context");
3882
3882
  return;
3883
3883
  }
3884
3884
  let e = R.callId;
3885
- kt(), Ot(), V.current?.emit("call:rejected", {
3885
+ Ot(), Dt(), V.current?.emit("call:rejected", {
3886
3886
  callId: e,
3887
3887
  chatId: y,
3888
3888
  reason: "visitor_declined"
@@ -3890,47 +3890,47 @@ function yi({ siteId: e, config: t, children: n, language: r = "en" }) {
3890
3890
  try {
3891
3891
  await H.current.rejectCall(e, y);
3892
3892
  } catch (e) {
3893
- Xe(hi(e, "We couldn't decline the call cleanly."));
3893
+ B(hi(e, "We couldn't decline the call cleanly."));
3894
3894
  } finally {
3895
- G("reject_call_finally");
3895
+ At("reject_call_finally");
3896
3896
  }
3897
3897
  }, Rt = p(Lt);
3898
3898
  Rt.current = Lt, c(() => {
3899
- if (!R?.callId || B) {
3900
- kt();
3899
+ if (!R?.callId || z) {
3900
+ Ot();
3901
3901
  return;
3902
3902
  }
3903
3903
  let e = R.callId;
3904
- return kt(), ft.current = window.setTimeout(() => {
3905
- tt.current?.callId === e && dt.current !== e && ut.current !== e && Rt.current();
3904
+ return Ot(), dt.current = window.setTimeout(() => {
3905
+ W.current?.callId === e && ut.current !== e && lt.current !== e && Rt.current();
3906
3906
  }, ne), () => {
3907
- ft.current &&= (window.clearTimeout(ft.current), null);
3907
+ dt.current &&= (window.clearTimeout(dt.current), null);
3908
3908
  };
3909
3909
  }, [
3910
- B,
3911
- kt,
3910
+ z,
3911
+ Ot,
3912
3912
  R?.callId
3913
3913
  ]);
3914
3914
  let zt = async () => {
3915
- if (!B || !H.current || !y) {
3916
- G("end_call_without_server_context");
3915
+ if (!z || !H.current || !y) {
3916
+ At("end_call_without_server_context");
3917
3917
  return;
3918
3918
  }
3919
- Ot();
3919
+ Dt();
3920
3920
  try {
3921
- await H.current.endWebRTCCall(B, y);
3921
+ await H.current.endWebRTCCall(z, y);
3922
3922
  } catch (e) {
3923
- Xe(hi(e, "The call ended locally, but the server could not be updated."));
3923
+ B(hi(e, "The call ended locally, but the server could not be updated."));
3924
3924
  } finally {
3925
- G("end_call_finally");
3925
+ At("end_call_finally");
3926
3926
  }
3927
3927
  }, Bt = () => {
3928
- let e = rt.current?.getAudioTracks?.() || [], t = nt.current?.getSenders?.().map((e) => e.track).filter((e) => e?.kind === "audio") || [], n = [...e, ...t].filter(Boolean);
3928
+ let e = nt.current?.getAudioTracks?.() || [], t = tt.current?.getSenders?.().map((e) => e.track).filter((e) => e?.kind === "audio") || [], n = [...e, ...t].filter(Boolean);
3929
3929
  if (n.length === 0) return;
3930
- let r = !qe;
3930
+ let r = !Je;
3931
3931
  n.forEach((e) => {
3932
3932
  e.enabled = !r;
3933
- }), Je(r);
3933
+ }), Ye(r);
3934
3934
  }, Vt = async (e = {}) => {
3935
3935
  let t = e.notifyChatInitiated === !0;
3936
3936
  if (O(!0), !(!t || !H.current || !y || typeof window > "u")) {
@@ -3945,7 +3945,7 @@ function yi({ siteId: e, config: t, children: n, language: r = "en" }) {
3945
3945
  } catch {}
3946
3946
  }
3947
3947
  }, Ht = async (e) => {
3948
- let t = At(e);
3948
+ let t = kt(e);
3949
3949
  if (!t || !H.current || !$e.current) return t;
3950
3950
  try {
3951
3951
  await H.current.trackVisitor({
@@ -3958,18 +3958,18 @@ function yi({ siteId: e, config: t, children: n, language: r = "en" }) {
3958
3958
  }
3959
3959
  return t;
3960
3960
  }, Ut = () => {
3961
- !y || !V.current?.connected || mt.current || (mt.current = !0, V.current.emit("typing:start", {
3961
+ !y || !V.current?.connected || pt.current || (pt.current = !0, V.current.emit("typing:start", {
3962
3962
  chatId: y,
3963
3963
  sender: "user"
3964
3964
  }));
3965
3965
  }, Wt = () => {
3966
- !y || !V.current?.connected || !mt.current || (mt.current = !1, V.current.emit("typing:stop", {
3966
+ !y || !V.current?.connected || !pt.current || (pt.current = !1, V.current.emit("typing:stop", {
3967
3967
  chatId: y,
3968
3968
  sender: "user"
3969
3969
  }));
3970
3970
  }, Gt = (e = "") => {
3971
3971
  let t = typeof e == "string" ? e : "";
3972
- !y || !V.current?.connected || t !== "" && ht.current === t || (ht.current = t, V.current.emit("typing:update", {
3972
+ !y || !V.current?.connected || t !== "" && mt.current === t || (mt.current = t, V.current.emit("typing:update", {
3973
3973
  chatId: y,
3974
3974
  sender: "user",
3975
3975
  text: t
@@ -3989,21 +3989,21 @@ function yi({ siteId: e, config: t, children: n, language: r = "en" }) {
3989
3989
  let qt = async (e, t = "", n = null, a = {}) => {
3990
3990
  let o = typeof e == "string" ? e.trim() : "";
3991
3991
  if (!o || !H.current || !y || l !== "ready" || Le) return;
3992
- Wt(), st.current = !1;
3992
+ Wt(), ot.current = !1;
3993
3993
  let s = /^\s*(yes|yeah|sure|ok|okay|go ahead|take me(?: there)?(?!\s+\w)|navigate(?!\s+(?:me\s+)?to\s+\w)|yep|absolutely|please do|do it|let'?s go|go there|show me(?!\s+(?:the|a|an)\s+\w)|go to it|bring me there|navigate me there)\b/i, c = /^\s*(?:yes|yeah|sure|ok|okay|yep|absolutely)\s+(?!(?:please|do\s+it|let'?s|that|this|there|it|thanks|go|cool|great|perfect|sounds|alright|proceed)\b)\w/i, u = /\b(take me|navigate|go to|show me|bring me|open|go there|navigate to|take me to|let'?s go to)\b/i;
3994
- if (ot.current && s.test(o) && !c.test(o)) {
3995
- let { url: e, section: t } = ot.current;
3996
- ot.current = null, st.current = !0, console.log("[FWH Nav] Client-side nav firing →", e), lt(e, { voiceActive: Ct.current }).then(({ navigated: e, reason: n }) => {
3994
+ if (at.current && s.test(o) && !c.test(o)) {
3995
+ let { url: e, section: t } = at.current;
3996
+ at.current = null, ot.current = !0, console.log("[FWH Nav] Client-side nav firing →", e), ct(e, { voiceActive: St.current }).then(({ navigated: e, reason: n }) => {
3997
3997
  if (!e) {
3998
3998
  n === "not-found" ? C() : n === "already-on-page" && T();
3999
3999
  return;
4000
4000
  }
4001
- !t || !Ct.current || setTimeout(() => {
4001
+ !t || !St.current || setTimeout(() => {
4002
4002
  let e = mr(null, t);
4003
4003
  e && hr(e);
4004
4004
  }, 300);
4005
4005
  });
4006
- } else s.test(o) || (ot.current = null);
4006
+ } else s.test(o) || (at.current = null);
4007
4007
  let d = `pending-user-${Date.now()}`, f = {
4008
4008
  id: d,
4009
4009
  sender: "user",
@@ -4017,7 +4017,7 @@ function yi({ siteId: e, config: t, children: n, language: r = "en" }) {
4017
4017
  S((e) => [...e, f]);
4018
4018
  let p = j;
4019
4019
  if (p) try {
4020
- p = Et(await H.current.checkHumanHandled(y));
4020
+ p = Tt(await H.current.checkHumanHandled(y));
4021
4021
  } catch {}
4022
4022
  if (p && V.current?.connected) {
4023
4023
  V.current.emit("customer:message", {
@@ -4034,7 +4034,7 @@ function yi({ siteId: e, config: t, children: n, language: r = "en" }) {
4034
4034
  Te(!0);
4035
4035
  try {
4036
4036
  let s = await Ur(), c = Vr(), l = `stream-preview-${Date.now().toString(36)}`, d = (e) => {
4037
- L(!1), S((t) => {
4037
+ I(!1), S((t) => {
4038
4038
  let n = t.findIndex((e) => e.id === l);
4039
4039
  if (n === -1) return [...t, {
4040
4040
  id: l,
@@ -4073,7 +4073,7 @@ function yi({ siteId: e, config: t, children: n, language: r = "en" }) {
4073
4073
  url: f.pending_navigate.url,
4074
4074
  section: f.pending_navigate.section || null
4075
4075
  };
4076
- u.test(o) ? (console.log("[FWH Nav] Auto-navigating (intent detected) →", e.url), lt(e.url, { voiceActive: Ct.current }).then(({ navigated: t, reason: n }) => {
4076
+ u.test(o) ? (console.log("[FWH Nav] Auto-navigating (intent detected) →", e.url), ct(e.url, { voiceActive: St.current }).then(({ navigated: t, reason: n }) => {
4077
4077
  if (!t) {
4078
4078
  n === "not-found" ? C() : n === "already-on-page" && T();
4079
4079
  return;
@@ -4082,7 +4082,7 @@ function yi({ siteId: e, config: t, children: n, language: r = "en" }) {
4082
4082
  let t = mr(null, e.section);
4083
4083
  t && hr(t);
4084
4084
  }, 300);
4085
- })) : (ot.current = e, console.log("[FWH Nav] Stored pending nav →", ot.current));
4085
+ })) : (at.current = e, console.log("[FWH Nav] Stored pending nav →", at.current));
4086
4086
  let t = i?.siteId;
4087
4087
  t && !ue(t) && (de(t), S((e) => [...e, {
4088
4088
  id: `nav-pref-${Date.now()}`,
@@ -4092,10 +4092,10 @@ function yi({ siteId: e, config: t, children: n, language: r = "en" }) {
4092
4092
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
4093
4093
  }]));
4094
4094
  }
4095
- if (f.navigate?.url) if (st.current) st.current = !1;
4095
+ if (f.navigate?.url) if (ot.current) ot.current = !1;
4096
4096
  else {
4097
4097
  let { url: e, section: t } = f.navigate;
4098
- lt(e, { voiceActive: Ct.current }).then(({ navigated: e, reason: n }) => {
4098
+ ct(e, { voiceActive: St.current }).then(({ navigated: e, reason: n }) => {
4099
4099
  if (!e) {
4100
4100
  n === "not-found" ? C() : n === "already-on-page" && T();
4101
4101
  return;
@@ -4117,19 +4117,19 @@ function yi({ siteId: e, config: t, children: n, language: r = "en" }) {
4117
4117
  if (e?.message) {
4118
4118
  let t = mi(e.message);
4119
4119
  t && yr(t.url, {
4120
- siteId: wt.current?.siteId,
4121
- apiBaseUrl: wt.current?.apiBaseUrl
4120
+ siteId: Ct.current?.siteId,
4121
+ apiBaseUrl: Ct.current?.apiBaseUrl
4122
4122
  }).then(({ allowed: e, correctedUrl: n }) => {
4123
4123
  if (!e) {
4124
4124
  C();
4125
4125
  return;
4126
4126
  }
4127
- lt(n || t.url, { voiceActive: Ct.current }).then(({ navigated: e, reason: n }) => {
4127
+ ct(n || t.url, { voiceActive: St.current }).then(({ navigated: e, reason: n }) => {
4128
4128
  if (!e) {
4129
4129
  n === "not-found" ? C() : n === "already-on-page" && T();
4130
4130
  return;
4131
4131
  }
4132
- !t.section || !Ct.current || setTimeout(() => {
4132
+ !t.section || !St.current || setTimeout(() => {
4133
4133
  let e = mr(null, t.section);
4134
4134
  e && hr(e);
4135
4135
  }, 300);
@@ -4137,9 +4137,9 @@ function yi({ siteId: e, config: t, children: n, language: r = "en" }) {
4137
4137
  });
4138
4138
  }
4139
4139
  }
4140
- S(pi(p)), Array.isArray(f.cart_actions) && f.cart_actions.length && w(f.cart_actions), M(!!f.is_human_handled), A(f.is_human_handled ? "agent" : "ai"), L(!1), Te(!1), await H.current.updateChatStatus(y, "messageSent");
4140
+ S(pi(p)), Array.isArray(f.cart_actions) && f.cart_actions.length && w(f.cart_actions), M(!!f.is_human_handled), A(f.is_human_handled ? "agent" : "ai"), I(!1), Te(!1), await H.current.updateChatStatus(y, "messageSent");
4141
4141
  } catch (e) {
4142
- S((e) => e.filter((e) => e.id !== d && !e.isStreaming)), L(!1), Te(!1), e.status === 429 ? (De(!0), ke(e.message), window.setTimeout(() => {
4142
+ S((e) => e.filter((e) => e.id !== d && !e.isStreaming)), I(!1), Te(!1), e.status === 429 ? (De(!0), ke(e.message), window.setTimeout(() => {
4143
4143
  De(!1), ke("");
4144
4144
  }, ee)) : h(e);
4145
4145
  }
@@ -4152,11 +4152,11 @@ function yi({ siteId: e, config: t, children: n, language: r = "en" }) {
4152
4152
  let t = e ? "voice" : "text";
4153
4153
  await H.current.setChatMode(y, t);
4154
4154
  } catch {}
4155
- Me(e), e && (St.current = !1);
4155
+ Me(e), e && (xt.current = !1);
4156
4156
  }
4157
4157
  }, Xt = async (e) => {
4158
- if (St.current) return;
4159
- if (St.current = !0, !H.current || !y || !e?.length) {
4158
+ if (xt.current) return;
4159
+ if (xt.current = !0, !H.current || !y || !e?.length) {
4160
4160
  Me(!1);
4161
4161
  return;
4162
4162
  }
@@ -4185,7 +4185,7 @@ function yi({ siteId: e, config: t, children: n, language: r = "en" }) {
4185
4185
  }
4186
4186
  }, Zt = async () => {
4187
4187
  if (!(!H.current || !y)) {
4188
- je && !St.current && xt.current.length > 0 && await Xt(xt.current);
4188
+ je && !xt.current && bt.current.length > 0 && await Xt(bt.current);
4189
4189
  try {
4190
4190
  await H.current.endConversation(y);
4191
4191
  } catch {
@@ -4203,27 +4203,27 @@ function yi({ siteId: e, config: t, children: n, language: r = "en" }) {
4203
4203
  }
4204
4204
  };
4205
4205
  c(() => {
4206
- if (Ue !== "connected" || !B || !y || !Ge || !Dt) return;
4207
- let e = new Date(Ge).getTime(), t = Number.isFinite(e) ? Date.now() - e : 0, n = Math.max(0, Dt * 1e3 - t), r = window.setTimeout(() => {
4208
- Xe("The call ended because it reached the time limit."), zt();
4206
+ if (We !== "connected" || !z || !y || !Ke || !Et) return;
4207
+ let e = new Date(Ke).getTime(), t = Number.isFinite(e) ? Date.now() - e : 0, n = Math.max(0, Et * 1e3 - t), r = window.setTimeout(() => {
4208
+ B("The call ended because it reached the time limit."), zt();
4209
4209
  }, n);
4210
4210
  return () => window.clearTimeout(r);
4211
4211
  }, [
4212
- B,
4213
- Ge,
4214
- Ue,
4212
+ z,
4213
+ Ke,
4214
+ We,
4215
4215
  y,
4216
4216
  zt,
4217
- Dt
4217
+ Et
4218
4218
  ]), c(() => {
4219
4219
  let e = () => {
4220
4220
  let e = $e.current, t = H.current;
4221
4221
  if (!t || !e) return;
4222
- if (Ct.current && xt.current.length > 0 && Ae(), !St.current && xt.current.length > 0 && (t.beaconSyncVoice(e, xt.current) || t.syncVoice(e, xt.current).catch(() => {}), St.current = !0), ut.current) {
4223
- t.beaconEndWebRTCCall(ut.current, e);
4222
+ if (St.current && bt.current.length > 0 && Ae(), !xt.current && bt.current.length > 0 && (t.beaconSyncVoice(e, bt.current) || t.syncVoice(e, bt.current).catch(() => {}), xt.current = !0), lt.current) {
4223
+ t.beaconEndWebRTCCall(lt.current, e);
4224
4224
  return;
4225
4225
  }
4226
- let n = dt.current || tt.current?.callId;
4226
+ let n = ut.current || W.current?.callId;
4227
4227
  n && t.beaconCustomerUnavailable(n, e);
4228
4228
  };
4229
4229
  return window.addEventListener("pagehide", e), window.addEventListener("beforeunload", e), () => {
@@ -4232,9 +4232,9 @@ function yi({ siteId: e, config: t, children: n, language: r = "en" }) {
4232
4232
  }, []);
4233
4233
  let Qt = o(() => {
4234
4234
  let e = i?.siteId;
4235
- me(e), U.current = !0, et.current = null, V.current?.disconnect(), S([]), b(""), $e.current = "", Re(!1), M(!1), P(null), F(null), Qe(!0), s((e) => e + 1);
4235
+ me(e), et.current = !0, U.current = null, V.current?.disconnect(), S([]), b(""), $e.current = "", Re(!1), M(!1), P(null), F(null), Qe(!0), s((e) => e + 1);
4236
4236
  }, [i?.siteId]), $t = o((e) => {
4237
- i?.siteId, U.current = !1, et.current = e, V.current?.disconnect(), S([]), b(""), $e.current = "", Re(!1), M(!1), P(null), F(null), Qe(!0), s((e) => e + 1);
4237
+ i?.siteId, et.current = !1, U.current = e, V.current?.disconnect(), S([]), b(""), $e.current = "", Re(!1), M(!1), P(null), F(null), Qe(!0), s((e) => e + 1);
4238
4238
  }, [i?.siteId]), en = f(() => ({
4239
4239
  status: l,
4240
4240
  error: d,
@@ -4245,11 +4245,11 @@ function yi({ siteId: e, config: t, children: n, language: r = "en" }) {
4245
4245
  isOpen: D,
4246
4246
  activeScreen: k,
4247
4247
  isHumanHandled: j,
4248
- agentName: ae,
4248
+ agentName: N,
4249
4249
  agentHeadshot: oe,
4250
4250
  visitorEmail: se,
4251
4251
  isAgentTyping: fe,
4252
- isAiTyping: be,
4252
+ isAiTyping: xe,
4253
4253
  connectionStatus: Se,
4254
4254
  isLoading: we,
4255
4255
  isVoiceMode: je,
@@ -4260,20 +4260,20 @@ function yi({ siteId: e, config: t, children: n, language: r = "en" }) {
4260
4260
  openToChatCounter: Ne,
4261
4261
  voiceEndCounter: Fe,
4262
4262
  incomingCall: R,
4263
- activeCallId: B,
4264
- callConnectionState: Ue,
4265
- callConnectedAt: Ge,
4266
- isCallMuted: qe,
4267
- webRTCError: Ye,
4263
+ activeCallId: z,
4264
+ callConnectionState: We,
4265
+ callConnectedAt: Ke,
4266
+ isCallMuted: Je,
4267
+ webRTCError: Xe,
4268
4268
  language: r,
4269
- historyRef: xt,
4270
- hasSyncedRef: St,
4271
- dismissCallError: Ot,
4269
+ historyRef: bt,
4270
+ hasSyncedRef: xt,
4271
+ dismissCallError: Dt,
4272
4272
  captureVisitorEmail: Ht,
4273
4273
  startTyping: Ut,
4274
4274
  stopTyping: Wt,
4275
4275
  updateTypingDraft: Gt,
4276
- notifyRouteChange: () => Tt.current?.notifyRouteChange?.(),
4276
+ notifyRouteChange: () => wt.current?.notifyRouteChange?.(),
4277
4277
  openWidget: Vt,
4278
4278
  closeWidget: () => O(!1),
4279
4279
  toggleWidget: () => {
@@ -4287,6 +4287,10 @@ function yi({ siteId: e, config: t, children: n, language: r = "en" }) {
4287
4287
  uploadChatFile: Jt,
4288
4288
  setVoiceMode: Yt,
4289
4289
  onMessageSync: Xt,
4290
+ beaconSyncVoiceTranscript: (e) => {
4291
+ let t = H.current, n = $e.current;
4292
+ return !t || !n || !Array.isArray(e) || !e.length ? !1 : (t.beaconSyncVoice(n, e) || t.syncVoice(n, e).catch(() => {}), !0);
4293
+ },
4290
4294
  endConversation: Zt,
4291
4295
  startNewChat: Qt,
4292
4296
  resumeChat: $t,
@@ -4306,11 +4310,11 @@ function yi({ siteId: e, config: t, children: n, language: r = "en" }) {
4306
4310
  D,
4307
4311
  k,
4308
4312
  j,
4309
- ae,
4313
+ N,
4310
4314
  oe,
4311
4315
  se,
4312
4316
  fe,
4313
- be,
4317
+ xe,
4314
4318
  Se,
4315
4319
  we,
4316
4320
  je,
@@ -4321,11 +4325,11 @@ function yi({ siteId: e, config: t, children: n, language: r = "en" }) {
4321
4325
  Ne,
4322
4326
  Fe,
4323
4327
  R,
4324
- B,
4325
- Ue,
4326
- Ge,
4327
- qe,
4328
- Ye,
4328
+ z,
4329
+ We,
4330
+ Ke,
4331
+ Je,
4332
+ Xe,
4329
4333
  r,
4330
4334
  Ht,
4331
4335
  Ut,
@@ -4342,7 +4346,7 @@ function yi({ siteId: e, config: t, children: n, language: r = "en" }) {
4342
4346
  Xt,
4343
4347
  Zt,
4344
4348
  Qt,
4345
- Ot
4349
+ Dt
4346
4350
  ]);
4347
4351
  return /* @__PURE__ */ g(On.Provider, {
4348
4352
  value: en,
@@ -9394,7 +9398,7 @@ async function Oh(e) {
9394
9398
  }
9395
9399
  }, O = (e, t, n) => {
9396
9400
  t && (T.role && T.role !== e && D(), T.role = e, T.text = T.text ? `${T.text} ${t}`.replace(/\s+/g, " ") : t, n && (T.debug = n), T.timer && clearTimeout(T.timer), T.timer = setTimeout(D, lh));
9397
- }, k = !1, A = !1, ee = !1, te = !1, ne = !1, j = !0, M = 0, re = 0, ie = !1, N = !1, ae = uh, P = null, oe = !1, F = !1, se = () => {
9401
+ }, k = !1, A = !1, ee = !1, te = !1, ne = !1, j = !0, M = 0, re = 0, ie = !1, ae = !1, N = uh, P = null, oe = !1, F = !1, se = () => {
9398
9402
  P && clearTimeout(P);
9399
9403
  let e = () => {
9400
9404
  if (!k) {
@@ -9424,11 +9428,11 @@ async function Oh(e) {
9424
9428
  ee || (ee = !0, console.debug("[FlowEngage] mic held — streaming silence to keep socket alive")), de = !1, M = 0, re = 0, n();
9425
9429
  return;
9426
9430
  }
9427
- let r = vh(t), i = _h(t), a = ce.isPlaying() || N, o = a ? ae * gh : ae, s = a ? hh : ph;
9431
+ let r = vh(t), i = _h(t), a = ce.isPlaying() || ae, o = a ? N * gh : N, s = a ? hh : ph;
9428
9432
  if (r >= o && i >= dh && i <= fh ? (re = 0, M += 1) : ++re >= mh && (M = 0), a ? de = !1 : !de && M >= ph ? (de = !0, c?.({ mode: "user-speaking" })) : de && M === 0 && (de = !1), a && !ie && M >= s) {
9429
9433
  ie = !0, ne = !1, M = 0;
9430
9434
  let e = ce.playedMs();
9431
- ce.stop(), j = !1, N = !1, P && !oe && (clearTimeout(P), P = null), F = !1, C.send(JSON.stringify({
9435
+ ce.stop(), j = !1, ae = !1, P && !oe && (clearTimeout(P), P = null), F = !1, C.send(JSON.stringify({
9432
9436
  type: "VisitorInterrupted",
9433
9437
  played_ms: Math.round(e)
9434
9438
  })), console.debug("[FlowEngage] barge-in — visitor spoke over the agent");
@@ -9478,7 +9482,7 @@ async function Oh(e) {
9478
9482
  }, he = (e) => {
9479
9483
  switch (e.type) {
9480
9484
  case "Welcome":
9481
- Number.isFinite(e.barge_in_rms) && e.barge_in_rms > 0 && (ae = e.barge_in_rms), Number.isFinite(e.barge_in_frames) && e.barge_in_frames > 0 && e.barge_in_frames, S = e.session_id || r || n || null, a?.({ conversationId: S });
9485
+ Number.isFinite(e.barge_in_rms) && e.barge_in_rms > 0 && (N = e.barge_in_rms), Number.isFinite(e.barge_in_frames) && e.barge_in_frames > 0 && e.barge_in_frames, S = e.session_id || r || n || null, a?.({ conversationId: S });
9482
9486
  break;
9483
9487
  case "ConversationText": {
9484
9488
  let t = String(e.content || "");
@@ -9497,19 +9501,19 @@ async function Oh(e) {
9497
9501
  break;
9498
9502
  }
9499
9503
  case "UserStartedSpeaking":
9500
- D(), ce.stop(), N = !1, j = !1, te = !1, ne = !1, P && !oe && (clearTimeout(P), P = null), F = !1, c?.({ mode: "listening" });
9504
+ D(), ce.stop(), ae = !1, j = !1, te = !1, ne = !1, P && !oe && (clearTimeout(P), P = null), F = !1, c?.({ mode: "listening" });
9501
9505
  break;
9502
9506
  case "AgentStartedSpeaking":
9503
9507
  j = !0, te = !0, ie = !1, M = 0, c?.({ mode: "speaking" });
9504
9508
  break;
9505
9509
  case "AgentAudioDone":
9506
- N = !1, D(), se(), ce.isPlaying() || (te = !1, c?.({ mode: ne ? "thinking" : "listening" }));
9510
+ ae = !1, D(), se(), ce.isPlaying() || (te = !1, c?.({ mode: ne ? "thinking" : "listening" }));
9507
9511
  break;
9508
9512
  case "FunctionCallRequest":
9509
9513
  me(e);
9510
9514
  break;
9511
9515
  case "AgentPreparing":
9512
- N = !0;
9516
+ ae = !0;
9513
9517
  break;
9514
9518
  case "AgentTurnComplete":
9515
9519
  ne = !1, F = !0, se();
@@ -12587,50 +12591,53 @@ function f_(e) {
12587
12591
  }).join("\n").replace(/\n{3,}/g, "\n\n").trim();
12588
12592
  }
12589
12593
  function p_(e) {
12590
- let t = e.siteId || null, n = (e.apiBaseUrl || "").replace(/\/$/, ""), r = typeof e.getLastUserVoiceText == "function" ? e.getLastUserVoiceText : null, i = [], a = {
12594
+ let t = e.siteId || null, n = (e.apiBaseUrl || "").replace(/\/$/, ""), r = typeof e.getLastUserVoiceText == "function" ? e.getLastUserVoiceText : null, i = typeof e.beaconSyncFullVoiceHistory == "function" ? e.beaconSyncFullVoiceHistory : null, a = [], o = {
12591
12595
  "fwh-navigate-mvp": async (n) => {
12592
12596
  if ($("fwh-navigate-mvp ▶ raw parameters:", n), e?.isWalkthroughActive?.()) return $("fwh-navigate-mvp ✖ blocked — walkthrough in progress"), "NAVIGATION_BLOCKED_DURING_WALKTHROUGH. A walkthrough of the current page is in progress, so navigation is not allowed. Do NOT tell the visitor you navigated or offer to. Describe the requested section using the CURRENT page's own content (fwh-read-content-mvp), then stop.";
12593
- let i = c_(n), a = l_(i), o = i.section_text ?? i.sectionText ?? i.section, s = Array.isArray(i.expected_landmarks) ? i.expected_landmarks : Array.isArray(i.expectedLandmarks) ? i.expectedLandmarks : [];
12597
+ let a = c_(n), o = l_(a), s = a.section_text ?? a.sectionText ?? a.section, c = Array.isArray(a.expected_landmarks) ? a.expected_landmarks : Array.isArray(a.expectedLandmarks) ? a.expectedLandmarks : [];
12594
12598
  if ($("fwh-navigate-mvp · coerced:", {
12595
- url: a,
12596
- sectionText: o,
12597
- expectedLandmarks: s
12598
- }), !a) {
12599
+ url: o,
12600
+ sectionText: s,
12601
+ expectedLandmarks: c
12602
+ }), !o) {
12599
12603
  let e = "Missing url: pass a string url, path like /pricing, or JSON with a url field.";
12600
12604
  return $("fwh-navigate-mvp ✖", e), e;
12601
12605
  }
12602
12606
  if (typeof window < "u") try {
12603
- let e = new URL(a, window.location.href);
12604
- if (e.hostname === window.location.hostname && e.origin !== window.location.origin) a = e.pathname + e.search + e.hash, $("fwh-navigate-mvp · cross-protocol same-host URL normalized →", a);
12607
+ let e = new URL(o, window.location.href);
12608
+ if (e.hostname === window.location.hostname && e.origin !== window.location.origin) o = e.pathname + e.search + e.hash, $("fwh-navigate-mvp · cross-protocol same-host URL normalized →", o);
12605
12609
  else if (e.origin !== window.location.origin && /^https?:$/i.test(e.protocol)) {
12606
12610
  let t = e.hostname;
12607
- return $("fwh-navigate-mvp ✖ external URL blocked:", e.href), `EXTERNAL_LINK_BLOCKED: The URL "${a}" points to an external site (${t}) that opens in a new tab. I cannot open new tabs or navigate to external sites. Tell the visitor exactly this: "That link opens an external app — I'm not able to open it for you, but you can click the link directly in the navigation header."`;
12611
+ return $("fwh-navigate-mvp ✖ external URL blocked:", e.href), `EXTERNAL_LINK_BLOCKED: The URL "${o}" points to an external site (${t}) that opens in a new tab. I cannot open new tabs or navigate to external sites. Tell the visitor exactly this: "That link opens an external app — I'm not able to open it for you, but you can click the link directly in the navigation header."`;
12608
12612
  }
12609
12613
  } catch {}
12610
12614
  if (typeof window < "u") {
12611
12615
  try {
12612
- let e = new URL(a, window.location.href);
12616
+ let e = new URL(o, window.location.href);
12613
12617
  if (e.pathname === window.location.pathname && e.search === window.location.search) return $("fwh-navigate-mvp ✖ already on page, skipping"), "OK_ALREADY_ON_PAGE. The visitor is already on this page. Do not navigate. Proceed directly with highlights, answering the question, or reading page content.";
12614
12618
  } catch {}
12615
12619
  let e = window.__fe_user_nav_during_speech;
12616
12620
  if (e && Date.now() - e.ts < 3e4) try {
12617
- if (new URL(a, window.location.href).pathname === e.fromPath) return $("flowengage_navigate ✖ blocked — would navigate back to page visitor just left", e), `NAV_BLOCKED: The visitor just left "${e.fromPageName}" and is now on "${e.toPageName}". Do NOT navigate them back. If they said "continue", resume verbally from where you left off — no navigation needed. If they want to return, they will navigate themselves.`;
12621
+ if (new URL(o, window.location.href).pathname === e.fromPath) return $("flowengage_navigate ✖ blocked — would navigate back to page visitor just left", e), `NAV_BLOCKED: The visitor just left "${e.fromPageName}" and is now on "${e.toPageName}". Do NOT navigate them back. If they said "continue", resume verbally from where you left off — no navigation needed. If they want to return, they will navigate themselves.`;
12618
12622
  } catch {}
12619
12623
  }
12620
- let { allowed: c, correctedUrl: l } = await yr(a, {
12624
+ let { allowed: l, correctedUrl: u } = await yr(o, {
12621
12625
  siteId: t,
12622
12626
  apiBaseUrl: e.apiBaseUrl
12623
12627
  });
12624
- if (!c) {
12625
- let e = `PAGE_NOT_IN_SITE: "${a}" is NOT a real page on this site — do NOT guess or invent URL paths. Do NOT tell the visitor you are taking them there. Instead, find the REAL page: look at your Popular Pages / Site Pages list for the closest actual match, or call fwh-list-nav-links-mvp (to read the site's real menu links) or fwh-search-mvp (to find the right page). If a close match exists (e.g. the visitor said "support" and the site has "Technical Support"), tell them the ACTUAL page name and ask "we don't have a page called that, but we do have [real page] — would you like me to take you there?" Then navigate only to that verified URL.`;
12628
+ if (!l) {
12629
+ let e = `PAGE_NOT_IN_SITE: "${o}" is NOT a real page on this site — do NOT guess or invent URL paths. Do NOT tell the visitor you are taking them there. Instead, find the REAL page: look at your Popular Pages / Site Pages list for the closest actual match, or call fwh-list-nav-links-mvp (to read the site's real menu links) or fwh-search-mvp (to find the right page). If a close match exists (e.g. the visitor said "support" and the site has "Technical Support"), tell them the ACTUAL page name and ask "we don't have a page called that, but we do have [real page] — would you like me to take you there?" Then navigate only to that verified URL.`;
12626
12630
  return $("fwh-navigate-mvp ✖ blocked", e), e;
12627
12631
  }
12628
- l && l !== a && ($("fwh-navigate-mvp · corrected url:", {
12629
- requested: a,
12630
- correctedUrl: l
12631
- }), a = l);
12632
+ u && u !== o && ($("fwh-navigate-mvp · corrected url:", {
12633
+ requested: o,
12634
+ correctedUrl: u
12635
+ }), o = u);
12632
12636
  try {
12633
- Mg(`Navigating to ${a}...`, { spinner: !0 }), Lg(), Pn();
12637
+ Mg(`Navigating to ${o}...`, { spinner: !0 }), Lg(), Pn();
12638
+ try {
12639
+ i?.();
12640
+ } catch {}
12634
12641
  try {
12635
12642
  let e = r ? r() : "";
12636
12643
  if (e && t) {
@@ -12642,13 +12649,13 @@ function p_(e) {
12642
12649
  }
12643
12650
  } catch {}
12644
12651
  Ae();
12645
- let e = a;
12652
+ let e = o;
12646
12653
  try {
12647
- e = new URL(a, typeof window < "u" ? window.location.href : "").href;
12654
+ e = new URL(o, typeof window < "u" ? window.location.href : "").href;
12648
12655
  } catch {}
12649
12656
  let n = "this";
12650
12657
  try {
12651
- let e = new URL(a, window.location.href).pathname.split("/").filter(Boolean).pop() || "";
12658
+ let e = new URL(o, window.location.href).pathname.split("/").filter(Boolean).pop() || "";
12652
12659
  n = e ? e.replace(/[-_]/g, " ").replace(/\b\w/g, (e) => e.toUpperCase()) : "Home";
12653
12660
  } catch {}
12654
12661
  t && typeof window < "u" && Le(t, window.location.href, e, n), Sr(e);
@@ -12658,23 +12665,23 @@ function p_(e) {
12658
12665
  ts: Date.now()
12659
12666
  };
12660
12667
  } catch {}
12661
- $("fwh-navigate-mvp → real navigation", a);
12662
- let i = typeof window < "u" && !window.Shopify && !!$n();
12663
- if (typeof window < "u" && window.__fe_triggerVoiceNavHooks && window.__fe_triggerVoiceNavHooks(), i && Wn(12e3), Ar(a, { voiceActive: !0 }).catch(() => {}), i) try {
12664
- let e = new URL(a, window.location.origin).pathname, t = window.location.pathname, n = Date.now() + 2e3;
12668
+ $("fwh-navigate-mvp → real navigation", o);
12669
+ let a = typeof window < "u" && !window.Shopify && !!$n();
12670
+ if (typeof window < "u" && window.__fe_triggerVoiceNavHooks && window.__fe_triggerVoiceNavHooks(), a && Wn(12e3), Ar(o, { voiceActive: !0 }).catch(() => {}), a) try {
12671
+ let e = new URL(o, window.location.origin).pathname, t = window.location.pathname, n = Date.now() + 2e3;
12665
12672
  for (; Date.now() < n && !(typeof window < "u" && window.location.pathname === e);) await new Promise((e) => setTimeout(e, 80));
12666
- let r = typeof window < "u" ? window.location.pathname : e, i = typeof window < "u" ? window.location.href : a;
12673
+ let r = typeof window < "u" ? window.location.pathname : e, i = typeof window < "u" ? window.location.href : o;
12667
12674
  (r.split("/").filter(Boolean).pop() || "").replace(/[-_]/g, " ").replace(/\b\w/g, (e) => e.toUpperCase()), $("fwh-navigate-mvp → SPA nav complete. target:", e, "actual:", r);
12668
12675
  try {
12669
12676
  typeof window < "u" && window.scrollTo(0, 0);
12670
12677
  } catch {}
12671
- let o = [], s = null, c = "", l = Date.now() + 12e3;
12672
- for (; Date.now() < l && (await new Promise((e) => setTimeout(e, 300)), {headings: o, pageTitleHeading: s, introText: c} = d_(), !(o.length >= 1)););
12673
- u_(), $("fwh-navigate-mvp → page headings collected:", o, "titleHeading:", s);
12674
- let u = o.length ? o.join(" | ") : "none", d = o.length ? "Use ONLY these exact heading strings for fwh-highlight-mvp — never invent or abbreviate." : "No headings collected yet — call fwh-get-current-page-mvp immediately (no speech) to get the live headings before speaking or highlighting.", f = s ? ` "${s}" is the PAGE TITLE, not a content section — do not fwh-highlight-mvp it separately; if doing a walkthrough, just fold this intro into your opening line: "${c || "(no intro text found)"}"` : c ? ` No separate page-title heading detected, but this intro text precedes the first section — mention it briefly before covering sections: "${c}"` : "", p = "";
12678
+ let a = [], s = null, c = "", l = Date.now() + 12e3;
12679
+ for (; Date.now() < l && (await new Promise((e) => setTimeout(e, 300)), {headings: a, pageTitleHeading: s, introText: c} = d_(), !(a.length >= 1)););
12680
+ u_(), $("fwh-navigate-mvp → page headings collected:", a, "titleHeading:", s);
12681
+ let u = a.length ? a.join(" | ") : "none", d = a.length ? "Use ONLY these exact heading strings for fwh-highlight-mvp — never invent or abbreviate." : "No headings collected yet — call fwh-get-current-page-mvp immediately (no speech) to get the live headings before speaking or highlighting.", f = s ? ` "${s}" is the PAGE TITLE, not a content section — do not fwh-highlight-mvp it separately; if doing a walkthrough, just fold this intro into your opening line: "${c || "(no intro text found)"}"` : c ? ` No separate page-title heading detected, but this intro text precedes the first section — mention it briefly before covering sections: "${c}"` : "", p = "";
12675
12682
  try {
12676
- if (o.length > 0) {
12677
- let e = o.slice(0, 3), t = [];
12683
+ if (a.length > 0) {
12684
+ let e = a.slice(0, 3), t = [];
12678
12685
  for (let n of e) {
12679
12686
  let e = mr(null, n);
12680
12687
  if (e) {
@@ -12890,20 +12897,20 @@ function p_(e) {
12890
12897
  "fwh-click-button-mvp": async (e) => {
12891
12898
  let t = c_(e), n = (t.button_text ?? t.buttonText ?? t.text ?? "").trim(), r = (t.card_context ?? t.cardContext ?? "").trim();
12892
12899
  if ($("fwh-click-button-mvp ▶", n, r ? `(card_context: ${r})` : ""), !n) return "Missing button_text: pass the visible label, e.g. Conduct Audit.";
12893
- let a = s_(n, i, r);
12894
- if (!a) return $("fwh-click-button-mvp ✖ no match"), `Could not find a button matching "${n}". Call fwh-list-forms-mvp to see button texts.`;
12900
+ let i = s_(n, a, r);
12901
+ if (!i) return $("fwh-click-button-mvp ✖ no match"), `Could not find a button matching "${n}". Call fwh-list-forms-mvp to see button texts.`;
12895
12902
  try {
12896
12903
  Mg(`Clicking ${n}...`, { spinner: !0 });
12897
12904
  try {
12898
- a.scrollIntoView({
12905
+ i.scrollIntoView({
12899
12906
  block: "center",
12900
12907
  inline: "nearest"
12901
12908
  });
12902
12909
  } catch {
12903
- a.scrollIntoView(!0);
12910
+ i.scrollIntoView(!0);
12904
12911
  }
12905
- await Ug(a), a.focus?.(), await Gg(a), Kg(a), a.click();
12906
- let e = (a.textContent || a.value || a.getAttribute("aria-label") || "").trim().slice(0, 80) || "button", t = `OK_CLICK ${e}`;
12912
+ await Ug(i), i.focus?.(), await Gg(i), Kg(i), i.click();
12913
+ let e = (i.textContent || i.value || i.getAttribute("aria-label") || "").trim().slice(0, 80) || "button", t = `OK_CLICK ${e}`;
12907
12914
  return $("fwh-click-button-mvp ✓", t), Mg(`Clicked ${e}`, {
12908
12915
  spinner: !1,
12909
12916
  icon: "✅",
@@ -12956,7 +12963,7 @@ function p_(e) {
12956
12963
  try {
12957
12964
  let { variant: e, product: t } = await Wr(n, r);
12958
12965
  await Gr(e.id, i);
12959
- let a = await Br(), s = await o(a), c = e.title && e.title !== "Default Title" ? ` (${e.title})` : "", l = `ADDED ${i} × ${t.title}${c}. Cart now has ${a.item_count} item(s), subtotal ${Hr(a.items_subtotal_price)}${a.currency ? ` ${a.currency}` : ""}.${s}`;
12966
+ let a = await Br(), o = await s(a), c = e.title && e.title !== "Default Title" ? ` (${e.title})` : "", l = `ADDED ${i} × ${t.title}${c}. Cart now has ${a.item_count} item(s), subtotal ${Hr(a.items_subtotal_price)}${a.currency ? ` ${a.currency}` : ""}.${o}`;
12960
12967
  return $("fwh-cart-add-mvp ✓", l), l;
12961
12968
  } catch (e) {
12962
12969
  return $("fwh-cart-add-mvp ✖", e), `ADD_FAILED: ${e?.userMessage || e?.message || "could not add the item"}. Relay this reason to the visitor.`;
@@ -12972,8 +12979,8 @@ function p_(e) {
12972
12979
  try {
12973
12980
  let e = await Br(), t = e.items?.[n - 1];
12974
12981
  if (!t) return `NO_SUCH_LINE: the cart has ${e.items?.length || 0} item(s). Call fwh-cart-get-mvp for the current list.`;
12975
- let i = await Kr(n, r), a = await o(i), s = `UPDATED ${t.product_title || t.title} to qty ${r}. Cart now has ${i.item_count} item(s), subtotal ${Hr(i.items_subtotal_price)}${i.currency ? ` ${i.currency}` : ""}.${a}`;
12976
- return $("fwh-cart-update-mvp ✓", s), s;
12982
+ let i = await Kr(n, r), a = await s(i), o = `UPDATED ${t.product_title || t.title} to qty ${r}. Cart now has ${i.item_count} item(s), subtotal ${Hr(i.items_subtotal_price)}${i.currency ? ` ${i.currency}` : ""}.${a}`;
12983
+ return $("fwh-cart-update-mvp ✓", o), o;
12977
12984
  } catch (e) {
12978
12985
  return $("fwh-cart-update-mvp ✖", e), `UPDATE_FAILED: ${e?.userMessage || e?.message || "could not update the item"}`;
12979
12986
  }
@@ -12984,33 +12991,33 @@ function p_(e) {
12984
12991
  try {
12985
12992
  let e = await Br(), n = e.items?.[t - 1];
12986
12993
  if (!n) return `NO_SUCH_LINE: the cart has ${e.items?.length || 0} item(s). Call fwh-cart-get-mvp for the current list.`;
12987
- let r = await Kr(t, 0), i = await o(r), a = `REMOVED ${n.product_title || n.title}. Cart now has ${r.item_count} item(s), subtotal ${Hr(r.items_subtotal_price)}${r.currency ? ` ${r.currency}` : ""}.${i}`;
12994
+ let r = await Kr(t, 0), i = await s(r), a = `REMOVED ${n.product_title || n.title}. Cart now has ${r.item_count} item(s), subtotal ${Hr(r.items_subtotal_price)}${r.currency ? ` ${r.currency}` : ""}.${i}`;
12988
12995
  return $("fwh-cart-remove-mvp ✓", a), a;
12989
12996
  } catch (e) {
12990
12997
  return $("fwh-cart-remove-mvp ✖", e), `REMOVE_FAILED: ${e?.userMessage || e?.message || "could not remove the item"}`;
12991
12998
  }
12992
12999
  },
12993
- "fwh-cart-open-mvp": async () => ($("fwh-cart-open-mvp ▶"), s(qr(), "Cart")),
13000
+ "fwh-cart-open-mvp": async () => ($("fwh-cart-open-mvp ▶"), c(qr(), "Cart")),
12994
13001
  "fwh-checkout-mvp": async () => {
12995
13002
  $("fwh-checkout-mvp ▶");
12996
13003
  try {
12997
13004
  if (!(await Br()).item_count) return "CART_EMPTY: do not go to checkout. Tell the visitor their cart is empty and offer to help find products.";
12998
13005
  } catch {}
12999
- return s(Jr(), "Checkout");
13006
+ return c(Jr(), "Checkout");
13000
13007
  },
13001
13008
  "fwh-view-product-mvp": async (e) => {
13002
13009
  let t = e || {}, n = String(t.product_handle || t.productHandle || "").trim().toLowerCase();
13003
- return $("fwh-view-product-mvp ▶", { handle: n }), n ? s(Yr(n), n.replace(/[-_]/g, " ")) : "Missing product_handle: search the product first with fwh-shop-search-mvp.";
13010
+ return $("fwh-view-product-mvp ▶", { handle: n }), n ? c(Yr(n), n.replace(/[-_]/g, " ")) : "Missing product_handle: search the product first with fwh-shop-search-mvp.";
13004
13011
  }
13005
13012
  };
13006
- async function o(e) {
13013
+ async function s(e) {
13007
13014
  try {
13008
13015
  let { sectionsSwapped: t } = await ii(e);
13009
13016
  if (!t && Zr()) return " NOTE: the cart list on this page could not be re-rendered — briefly tell the visitor the page may need a quick refresh to show the change.";
13010
13017
  } catch {}
13011
13018
  return "";
13012
13019
  }
13013
- function s(e, n) {
13020
+ function c(e, n) {
13014
13021
  if (typeof window > "u") return "NAV_FAILED: no browser context.";
13015
13022
  let r = e;
13016
13023
  try {
@@ -13021,13 +13028,13 @@ function p_(e) {
13021
13028
  }), `OK_NAVIGATING to ${n}. The page is loading — say one short phrase like "Here you go." and nothing more.`;
13022
13029
  }
13023
13030
  return {
13024
- ...a,
13025
- highlightOnPage: a["fwh-highlight-mvp"],
13026
- getPageContent: a["fwh-page-content-mvp"],
13027
- endVoiceSession: a["fwh-end-session-mvp"],
13028
- listPageForms: a["fwh-list-forms-mvp"],
13029
- fillFormFields: a["fwh-fill-form-mvp"],
13030
- clickPageButton: a["fwh-click-button-mvp"]
13031
+ ...o,
13032
+ highlightOnPage: o["fwh-highlight-mvp"],
13033
+ getPageContent: o["fwh-page-content-mvp"],
13034
+ endVoiceSession: o["fwh-end-session-mvp"],
13035
+ listPageForms: o["fwh-list-forms-mvp"],
13036
+ fillFormFields: o["fwh-fill-form-mvp"],
13037
+ clickPageButton: o["fwh-click-button-mvp"]
13031
13038
  };
13032
13039
  }
13033
13040
  var m_ = /^(get in touch|contact us|let'?s (talk|connect)|subscribe|newsletter|follow us|quick links|company|solutions|what we do|resources|legal|sitemap|share this)/i;
@@ -13472,30 +13479,30 @@ function O_({ copy: e, orbColors: t, primaryColor: n, onVoice: r, onText: i, onC
13472
13479
  ]
13473
13480
  });
13474
13481
  }
13475
- function k_({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i, apiBaseUrl: a, chatId: s, historyRef: l, onMessageSync: u, voiceEndCounter: d, websiteName: f, voiceFirstMessage: h, captureVisitorEmail: v, emailRequired: y, emailCaptureEnabled: b = !0, listeningLabel: x = "Listening...", thinkingLabel: S = "Thinking...", enterChatModeLabel: C = "Enter Chat Mode", endConversationLabel: w = "End Conversation" }) {
13482
+ function k_({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i, apiBaseUrl: a, chatId: s, historyRef: l, onMessageSync: u, beaconSyncVoiceTranscript: d, voiceEndCounter: f, websiteName: h, voiceFirstMessage: v, captureVisitorEmail: y, emailRequired: b, emailCaptureEnabled: x = !0, listeningLabel: S = "Listening...", thinkingLabel: C = "Thinking...", enterChatModeLabel: w = "Enter Chat Mode", endConversationLabel: T = "End Conversation" }) {
13476
13483
  c(() => (console.log("[FlowEngage:VoiceDebug] 🔵 VoiceMode MOUNTED"), () => console.log("[FlowEngage:VoiceDebug] 🔴 VoiceMode UNMOUNTED")), []);
13477
- let [T, E] = m("idle"), [D, O] = m(!1), [k, A] = m(!1), [ee, te] = m(() => ce(i) === "auto"), ne = () => {
13478
- let e = ee ? "ask" : "auto";
13479
- le(i, e), te(e === "auto");
13480
- }, [j, M] = m(!1), [re, ie] = m(""), [N, ae] = m(""), P = p(!1), oe = p(!1), F = p(null), se = p(0), ue = p(""), de = p(!1), fe = p(0), pe = p(!1), me = p(!1), he = p(!1), ge = p([]), _e = p(null), ve = p(""), ye = p(null), I = (e) => {
13481
- pe.current = e, e || (me.current = !1), L.current?.setWalkthroughActive?.(e);
13484
+ let [E, D] = m("idle"), [O, k] = m(!1), [A, ee] = m(!1), [te, ne] = m(() => ce(i) === "auto"), j = () => {
13485
+ let e = te ? "ask" : "auto";
13486
+ le(i, e), ne(e === "auto");
13487
+ }, [M, re] = m(!1), [ie, ae] = m(""), [N, P] = m(""), oe = p(!1), F = p(!1), se = p(null), ue = p(0), de = p(""), fe = p(!1), pe = p(0), me = p(!1), he = p(!1), ge = p(!1), _e = p([]), ve = p(null), ye = p(""), be = p(null), xe = (e) => {
13488
+ me.current = e, e || (he.current = !1), L.current?.setWalkthroughActive?.(e);
13482
13489
  };
13483
- ye.current = async () => {
13484
- if (me.current) return;
13490
+ be.current = async () => {
13491
+ if (he.current) return;
13485
13492
  let e = typeof window < "u" ? window.location.pathname : null;
13486
- if (e && _e.current && e !== _e.current) {
13487
- console.log("[FlowEngage] walkthrough ended — visitor left " + _e.current), _e.current = null, ge.current = [], I(!1);
13493
+ if (e && ve.current && e !== ve.current) {
13494
+ console.log("[FlowEngage] walkthrough ended — visitor left " + ve.current), ve.current = null, _e.current = [], xe(!1);
13488
13495
  return;
13489
13496
  }
13490
- let t = ge.current;
13491
- be.current += 1;
13492
- let n = be.current, r = t[n];
13497
+ let t = _e.current;
13498
+ I.current += 1;
13499
+ let n = I.current, r = t[n];
13493
13500
  if (!r) {
13494
- if (I(!1), t.length) L.current?.sendUserMessage?.("That was the last section. Say so in one short sentence and ask if they want to explore any section further.");
13501
+ if (xe(!1), t.length) L.current?.sendUserMessage?.("That was the last section. Say so in one short sentence and ask if they want to explore any section further.");
13495
13502
  else if (n === 0) {
13496
13503
  let e = "";
13497
13504
  try {
13498
- let t = await xe.current?.["fwh-read-content-mvp"]?.({});
13505
+ let t = await Se.current?.["fwh-read-content-mvp"]?.({});
13499
13506
  typeof t == "string" && t && !/^Could not/i.test(t) && (e = t.slice(0, 2800));
13500
13507
  } catch {}
13501
13508
  L.current?.sendUserMessage?.(e ? `Give the visitor a complete spoken overview of this page in 4-6 sentences, based ONLY on this page content:\n"""${e}"""\nThen ask which part they'd like to hear more about. Do not call any tool.` : "Give the visitor a complete spoken overview of this page in 4-6 sentences based on what you know about it, then ask which part they'd like to hear more about. Do not call any tool.", { suppressQuestion: !0 });
@@ -13503,58 +13510,58 @@ function k_({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13503
13510
  return;
13504
13511
  }
13505
13512
  try {
13506
- await xe.current?.highlightOnPage?.({ section_text: r });
13513
+ await Se.current?.highlightOnPage?.({ section_text: r });
13507
13514
  } catch (e) {
13508
13515
  console.warn("[FlowEngage] walkthrough highlight failed:", e?.message || e);
13509
13516
  }
13510
13517
  console.debug(`[FlowEngage] walkthrough step ${n + 1}/${t.length}: ${r}`);
13511
13518
  let i = "";
13512
13519
  try {
13513
- let e = await xe.current?.["fwh-read-content-mvp"]?.({ section_text: r });
13520
+ let e = await Se.current?.["fwh-read-content-mvp"]?.({ section_text: r });
13514
13521
  typeof e == "string" && e && !/^Could not/i.test(e) && (i = e.slice(0, 2500));
13515
13522
  } catch {}
13516
13523
  let a = i ? `Here is this section's full content — describe it from THIS text only, and do not call any tool:\n"""${i}"""\n` : "read the section's content silently first (fwh-read-content-mvp) if you don't already have it. ";
13517
13524
  L.current?.sendUserMessage?.(`Describe the section titled "${r}" in 3-4 sentences, starting with ${n === 0 ? "Starting with" : "Next —"} ${r}. Describe ONLY this section. If this section contains named sub-items (steps, checklist entries, cards, plans, FAQs, team members), name EVERY one of them in order with a short phrase each — never skip or collapse them into a summary; ` + a + "This section is ON THE PAGE THE VISITOR IS ALREADY ON — do NOT call fwh-navigate-mvp, do not go to a product/detail page, and do not offer to, even if this section's name also matches a page name. Do not mention any other section, do not ask whether to continue, then stop.", { suppressQuestion: !0 });
13518
13525
  };
13519
- let be = p(0), L = p(null), xe = p(null), Se = p(""), Ce = p(async () => {}), we = p(!1), Te = p(!1), ke = p(!1), je = p(!1), Me = p("minimized"), Ne = p(null), Pe = p(null), Ie = p(null), Le = p(0), R = p(!1), z = p("idle"), ze = p(null), Be = p(!1), Ve = p(null), B = o((e = "minimized") => {
13526
+ let I = p(0), L = p(null), Se = p(null), Ce = p(""), we = p(async () => {}), Te = p(!1), ke = p(!1), je = p(!1), Me = p(!1), Ne = p("minimized"), Pe = p(null), Ie = p(null), Le = p(null), R = p(0), ze = p(!1), Be = p("idle"), Ve = p(null), He = p(!1), z = p(null), Ue = o((e = "minimized") => {
13520
13527
  console.warn("[FlowEngage:VoiceDebug] 🛑 requestSessionShutdown called", {
13521
13528
  destination: e,
13522
13529
  stack: (/* @__PURE__ */ Error()).stack?.split("\n").slice(1, 4).join(" | ")
13523
- }), Me.current = e, je.current = !0, queueMicrotask(() => {
13524
- we.current || (we.current = !0, Ce.current?.());
13530
+ }), Ne.current = e, Me.current = !0, queueMicrotask(() => {
13531
+ Te.current || (Te.current = !0, we.current?.());
13525
13532
  });
13526
- }, [l]), He = o(() => {
13527
- F.current &&= (clearTimeout(F.current), null);
13533
+ }, [l]), We = o(() => {
13534
+ se.current &&= (clearTimeout(se.current), null);
13528
13535
  }, []);
13529
13536
  c(() => {
13530
- if (y) {
13531
- P.current = !1;
13537
+ if (b) {
13538
+ oe.current = !1;
13532
13539
  return;
13533
13540
  }
13534
- if (P.current = !0, oe.current = !1, M(!1), He(), de.current) {
13535
- de.current = !1, L.current?.setMicMuted?.(!1);
13536
- let e = ue.current;
13537
- ue.current = "", L.current?.injectAgentSpeech?.("Thanks — I already have your email on file.", "interrupt"), e && L.current?.sendUserMessage?.(`The visitor's email is already on file — do not ask for it. Answer their question now: "${e}"`);
13541
+ if (oe.current = !0, F.current = !1, re(!1), We(), fe.current) {
13542
+ fe.current = !1, L.current?.setMicMuted?.(!1);
13543
+ let e = de.current;
13544
+ de.current = "", L.current?.injectAgentSpeech?.("Thanks — I already have your email on file.", "interrupt"), e && L.current?.sendUserMessage?.(`The visitor's email is already on file — do not ask for it. Answer their question now: "${e}"`);
13538
13545
  }
13539
13546
  L.current?.sendContextualUpdate?.("EMAIL REQUIREMENT SATISFIED — the visitor's email is already on file. All earlier instructions about requiring or asking for an email are VOID. Never ask for it again.");
13540
- }, [y, He]);
13541
- let Ue = /(walk\s*(me\s*)?through|walkthrough|take me through|(complete|full|detailed) (overview|understanding|walkthrough|picture|breakdown|explanation)|give me (a|an|the) (overview|tour|walk)|tell me about (each|all)|go through (it|them|each|all)|overview of|one by one|tell me everything|explain (me )?(this|the) (whole |entire |full )?page|everything (about|on) this page|show me (each|all|around))/i, We = /(that covers everything|that was all|covered everything|that(?:'|’)?s everything)/i, Ge = /^((uh+|um+|so|well|okay|ok|yeah)[,.\s]+)*(yes|yeah|yep|yup|sure|ok(ay)?|please|continue|go on|next|keep going|carry on|go ahead|resume|back to the tour)[\s.!,]*$/i, Ke = /(would you like (me )?to take you|shall i take you|want me to take you|would you like to (go|explore|visit|see)|take you there)/i, qe = /^((uh+|um+|oh|ah|so|well)[,.\s]+)*(cool|nice|great|awesome|wow|lovely|perfect|got it|gotcha|i see|understood|makes sense|interesting|right|alright|sounds good|mm+-?hmm+|hmm+|k)[\s.!,]*$/i, Je = (e) => String(e || "").replace(/[\s.,!?]*((uh+|um+|er+|hmm+|mm+)[\s.,!?]*)+$/i, "").trim(), Ye = o(() => {
13542
- He(), F.current = setTimeout(() => {
13543
- if (!(!oe.current || P.current)) if (se.current < 3) {
13544
- se.current += 1;
13547
+ }, [b, We]);
13548
+ let Ge = /(walk\s*(me\s*)?through|walkthrough|take me through|(complete|full|detailed) (overview|understanding|walkthrough|picture|breakdown|explanation)|give me (a|an|the) (overview|tour|walk)|tell me about (each|all)|go through (it|them|each|all)|overview of|one by one|tell me everything|explain (me )?(this|the) (whole |entire |full )?page|everything (about|on) this page|show me (each|all|around))/i, Ke = /(that covers everything|that was all|covered everything|that(?:'|’)?s everything)/i, qe = /^((uh+|um+|so|well|okay|ok|yeah)[,.\s]+)*(yes|yeah|yep|yup|sure|ok(ay)?|please|continue|go on|next|keep going|carry on|go ahead|resume|back to the tour)[\s.!,]*$/i, Je = /(would you like (me )?to take you|shall i take you|want me to take you|would you like to (go|explore|visit|see)|take you there)/i, Ye = /^((uh+|um+|oh|ah|so|well)[,.\s]+)*(cool|nice|great|awesome|wow|lovely|perfect|got it|gotcha|i see|understood|makes sense|interesting|right|alright|sounds good|mm+-?hmm+|hmm+|k)[\s.!,]*$/i, Xe = (e) => String(e || "").replace(/[\s.,!?]*((uh+|um+|er+|hmm+|mm+)[\s.,!?]*)+$/i, "").trim(), B = o(() => {
13549
+ We(), se.current = setTimeout(() => {
13550
+ if (!(!F.current || oe.current)) if (ue.current < 3) {
13551
+ ue.current += 1;
13545
13552
  try {
13546
13553
  L.current?.injectAgentSpeech?.("I still need your email in the box below to continue — could you enter it, please?", "queue");
13547
13554
  } catch {}
13548
- Ye();
13555
+ B();
13549
13556
  } else {
13550
13557
  try {
13551
13558
  L.current?.injectAgentSpeech?.("Since I haven't received your email, I'll close this session for now. Feel free to come back anytime — take care!", "queue");
13552
13559
  } catch {}
13553
- oe.current = !1, M(!1), He(), R.current = !0;
13560
+ F.current = !1, re(!1), We(), ze.current = !0;
13554
13561
  }
13555
13562
  }, 1e4);
13556
- }, [He]), Xe = o(async (e) => {
13557
- je.current = !0;
13563
+ }, [We]), Ze = o(async (e) => {
13564
+ Me.current = !0;
13558
13565
  try {
13559
13566
  Pn();
13560
13567
  } catch {}
@@ -13564,7 +13571,7 @@ function k_({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13564
13571
  try {
13565
13572
  await L.current?.endSession?.();
13566
13573
  } catch {}
13567
- let t = Ne.current, n = Pe.current;
13574
+ let t = Pe.current, n = Ie.current;
13568
13575
  if (t && s && a) {
13569
13576
  let e = n ? Math.round((Date.now() - n) / 1e3) : 0;
13570
13577
  fetch(`${a}/api/voice/save-chat-recording`, {
@@ -13578,7 +13585,7 @@ function k_({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13578
13585
  })
13579
13586
  }).catch((e) => console.warn("[FlowEngage] save-chat-recording failed:", e.message));
13580
13587
  }
13581
- if (Ne.current = null, Pe.current = null, L.current = null, E("idle"), O(!1), we.current = !1, Pr(), i) try {
13588
+ if (Pe.current = null, Ie.current = null, L.current = null, D("idle"), k(!1), Te.current = !1, Pr(), i) try {
13582
13589
  Oe(i);
13583
13590
  } catch {}
13584
13591
  typeof u == "function" && await u(l.current), e?.();
@@ -13589,26 +13596,26 @@ function k_({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13589
13596
  s,
13590
13597
  a
13591
13598
  ]);
13592
- Ce.current = () => Xe(Me.current === "chat" ? t : n), c(() => {
13593
- Te.current = D;
13594
- }, [D]), c(() => {
13595
- d && B("chat");
13596
- }, [d]), c(() => {
13597
- let e = !1, o = null, c = null, d = null;
13599
+ we.current = () => Ze(Ne.current === "chat" ? t : n), c(() => {
13600
+ ke.current = O;
13601
+ }, [O]), c(() => {
13602
+ f && Ue("chat");
13603
+ }, [f]), c(() => {
13604
+ let e = !1, o = null, c = null, f = null;
13598
13605
  return (async () => {
13599
13606
  if (!i) {
13600
- E("error");
13607
+ D("error");
13601
13608
  return;
13602
13609
  }
13603
13610
  try {
13604
13611
  if ((await navigator.mediaDevices.getUserMedia({ audio: !0 })).getTracks().forEach((e) => e.stop()), e) return;
13605
- l.current = [], Se.current = "", we.current = !1, ke.current = !1, je.current = !1, Me.current = "minimized", Nr({ onBeforeNavigate: () => {
13612
+ l.current = [], Ce.current = "", Te.current = !1, je.current = !1, Me.current = !1, Ne.current = "minimized", Nr({ onBeforeNavigate: () => {
13606
13613
  if (i && l.current.length > 0) try {
13607
13614
  let e = Dg(l.current);
13608
13615
  e && Ee(i, e);
13609
13616
  } catch {}
13610
13617
  if (!$n()) {
13611
- let e = Ne.current, t = Pe.current;
13618
+ let e = Pe.current, t = Ie.current;
13612
13619
  if (e && s && a) try {
13613
13620
  let n = t ? Math.round((Date.now() - t) / 1e3) : 0, r = JSON.stringify({
13614
13621
  chatId: s,
@@ -13621,7 +13628,7 @@ function k_({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13621
13628
  headers: { "Content-Type": "application/json" },
13622
13629
  body: r,
13623
13630
  keepalive: !0
13624
- }).catch(() => {}), Ne.current = null, Pe.current = null;
13631
+ }).catch(() => {}), Pe.current = null, Ie.current = null;
13625
13632
  } catch {}
13626
13633
  }
13627
13634
  Ae();
@@ -13630,31 +13637,32 @@ function k_({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13630
13637
  siteId: i || null,
13631
13638
  apiBaseUrl: a || null,
13632
13639
  chatId: s || null,
13633
- getLastUserVoiceText: () => Se.current,
13634
- isWalkthroughActive: () => pe.current && !me.current,
13640
+ getLastUserVoiceText: () => Ce.current,
13641
+ beaconSyncFullVoiceHistory: () => d?.(l.current),
13642
+ isWalkthroughActive: () => me.current && !he.current,
13635
13643
  requestEndSession: () => {
13636
- R.current = !0;
13644
+ ze.current = !0;
13637
13645
  },
13638
13646
  requestEmailCollection: () => {
13639
- b && (P.current || oe.current || (oe.current = !0, se.current = 0, M(!0), Ye()));
13647
+ x && (oe.current || F.current || (F.current = !0, ue.current = 0, re(!0), B()));
13640
13648
  }
13641
- })), n = i ? De(i) : null, r = !!n?.transcript, u = i ? Re(i) : null, p = !!u, m = typeof window < "u" ? window.location.pathname : "/", g = typeof document < "u" ? document.title : "", _ = m.replace(/^\/[a-z]{2}(?:-[a-z]{2})?(?=\/|$)/i, "") || "/", v = _ === "/" || _ === "", x = {
13649
+ })), n = i ? De(i) : null, r = !!n?.transcript, u = i ? Re(i) : null, p = !!u, m = typeof window < "u" ? window.location.pathname : "/", g = typeof document < "u" ? document.title : "", _ = m.replace(/^\/[a-z]{2}(?:-[a-z]{2})?(?=\/|$)/i, "") || "/", y = _ === "/" || _ === "", S = {
13642
13650
  apiBaseUrl: a,
13643
13651
  siteId: i,
13644
13652
  chatId: s,
13645
13653
  clientTools: t
13646
13654
  };
13647
- xe.current = t;
13648
- let S = (m.split("/").filter(Boolean).pop() || "").replace(/[-_]/g, " ").replace(/\b\w/g, (e) => e.toUpperCase()), C = "";
13649
- g && g.includes("|") && (C = g.split("|").map((e) => e.trim()).filter(Boolean).reduce((e, t) => e.length <= t.length ? e : t));
13650
- let w = C || S || "", T = w ? `the ${w} page` : "this page", D = (() => {
13655
+ Se.current = t;
13656
+ let C = (m.split("/").filter(Boolean).pop() || "").replace(/[-_]/g, " ").replace(/\b\w/g, (e) => e.toUpperCase()), w = "";
13657
+ g && g.includes("|") && (w = g.split("|").map((e) => e.trim()).filter(Boolean).reduce((e, t) => e.length <= t.length ? e : t));
13658
+ let T = w || C || "", E = T ? `the ${T} page` : "this page", O = (() => {
13651
13659
  if (!u?.targetUrl) return !0;
13652
13660
  try {
13653
13661
  return new URL(u.targetUrl, window.location.href).pathname.replace(/\/$/, "") === window.location.pathname.replace(/\/$/, "");
13654
13662
  } catch {
13655
13663
  return !0;
13656
13664
  }
13657
- })(), k = (() => {
13665
+ })(), A = (() => {
13658
13666
  if (!u?.targetUrl) return null;
13659
13667
  try {
13660
13668
  return new URL(u.targetUrl, window.location.href).pathname;
@@ -13662,99 +13670,99 @@ function k_({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13662
13670
  return null;
13663
13671
  }
13664
13672
  })();
13665
- if (p && !D) x.greeting = `You're on ${T}. What would you like to know?`, console.warn(`[FlowEngage] nav target "${u?.pageName}" not reached — on "${w}" instead; not claiming navigation`);
13673
+ if (p && !O) S.greeting = `You're on ${E}. What would you like to know?`, console.warn(`[FlowEngage] nav target "${u?.pageName}" not reached — on "${T}" instead; not claiming navigation`);
13666
13674
  else if (p) {
13667
- let e = u?.pageName ? `the ${u.pageName} page` : T;
13668
- x.greeting = `I have navigated you to ${e}. Do you want to know about any specific section or want a complete overview?`, console.log(`[FlowEngage] 🔄 Agent-nav resume: greeting set for "${e}" (${m})`);
13669
- } else if (r) x.greeting = `Welcome back! I see you're now on ${T}. Would you like me to continue what I was explaining before, or would you like to know about this page instead?`;
13675
+ let e = u?.pageName ? `the ${u.pageName} page` : E;
13676
+ S.greeting = `I have navigated you to ${e}. Do you want to know about any specific section or want a complete overview?`, console.log(`[FlowEngage] 🔄 Agent-nav resume: greeting set for "${e}" (${m})`);
13677
+ } else if (r) S.greeting = `Welcome back! I see you're now on ${E}. Would you like me to continue what I was explaining before, or would you like to know about this page instead?`;
13670
13678
  else {
13671
- let e = f || "";
13672
- x.greeting = h || (v ? e ? `Hi, welcome to ${e}! How may I help you?` : "Hi, welcome! How may I help you?" : `Welcome to ${T}! How may I help you?`), v || console.log(`[FlowEngage] 🏠 Page-context greeting: "${w}" for ${m}`);
13679
+ let e = h || "";
13680
+ S.greeting = v || (y ? e ? `Hi, welcome to ${e}! How may I help you?` : "Hi, welcome! How may I help you?" : `Welcome to ${E}! How may I help you?`), y || console.log(`[FlowEngage] 🏠 Page-context greeting: "${T}" for ${m}`);
13673
13681
  }
13674
- let A = !1, ee = p ? `NAVIGATION COMPLETE — The exact phrase "I have navigated you to the [page] page. Do you want to know about any specific section or want a complete overview?" has already been spoken as your firstMessage. DO NOT repeat it. PRIOR CONVERSATION CONTEXT:\n${n?.transcript ? `Prior transcript:\n${n.transcript}\n` : "(no prior transcript)"}\nNow STOP — wait silently for the visitor's reply. Do NOT speak, do NOT call any tool until the visitor responds. When they reply: if they name a specific section → call fwh-get-current-page-mvp then answer immediately; if they say "overview" or anything non-specific → call fwh-get-current-page-mvp (zero speech) then do a full highlighted walkthrough.` : null, te = !1, ne = !p && !r ? "Your greeting has been spoken. Wait for the visitor to ask a question or tell you what they need. Do NOT auto-start a walkthrough or highlight any sections — let the visitor lead." : null, j = r && !p, re = !1, ie = j ? `The question "Would you like me to continue what I was explaining before, or would you like to know about this page instead?" has already been spoken as your firstMessage. DO NOT repeat it. PRIOR CONVERSATION CONTEXT:\n${n?.transcript ? `Prior transcript:\n${n.transcript}\n` : "(no prior transcript, or the visitor navigated before saying much)"}\nNow STOP — wait silently for the visitor's reply. Do NOT speak, do NOT call any tool until they respond. When they reply: if they want you to CONTINUE the previous topic → resume verbally from the prior transcript above, do NOT call fwh-get-current-page-mvp or describe the new page unless they ask. If they want to know about THIS page → call fwh-get-current-page-mvp (zero speech) then proceed as a normal fresh-page walkthrough/description. If their reply is ambiguous, ask them to clarify which they'd prefer rather than guessing.` : null, N = !1, ae = !1, F = b && !!y && !he.current, ce = await kh.startSession({
13675
- ...x,
13682
+ let ee = !1, te = p ? `NAVIGATION COMPLETE — The exact phrase "I have navigated you to the [page] page. Do you want to know about any specific section or want a complete overview?" has already been spoken as your firstMessage. DO NOT repeat it. PRIOR CONVERSATION CONTEXT:\n${n?.transcript ? `Prior transcript:\n${n.transcript}\n` : "(no prior transcript)"}\nNow STOP — wait silently for the visitor's reply. Do NOT speak, do NOT call any tool until the visitor responds. When they reply: if they name a specific section → call fwh-get-current-page-mvp then answer immediately; if they say "overview" or anything non-specific → call fwh-get-current-page-mvp (zero speech) then do a full highlighted walkthrough.` : null, ne = !1, j = !p && !r ? "Your greeting has been spoken. Wait for the visitor to ask a question or tell you what they need. Do NOT auto-start a walkthrough or highlight any sections — let the visitor lead." : null, M = r && !p, ie = !1, ae = M ? `The question "Would you like me to continue what I was explaining before, or would you like to know about this page instead?" has already been spoken as your firstMessage. DO NOT repeat it. PRIOR CONVERSATION CONTEXT:\n${n?.transcript ? `Prior transcript:\n${n.transcript}\n` : "(no prior transcript, or the visitor navigated before saying much)"}\nNow STOP — wait silently for the visitor's reply. Do NOT speak, do NOT call any tool until they respond. When they reply: if they want you to CONTINUE the previous topic → resume verbally from the prior transcript above, do NOT call fwh-get-current-page-mvp or describe the new page unless they ask. If they want to know about THIS page → call fwh-get-current-page-mvp (zero speech) then proceed as a normal fresh-page walkthrough/description. If their reply is ambiguous, ask them to clarify which they'd prefer rather than guessing.` : null, N = !1, P = !1, se = x && !!b && !ge.current, ce = await kh.startSession({
13683
+ ...S,
13676
13684
  onConnect: ({ conversationId: e }) => {
13677
- Ne.current = e, Pe.current = Date.now(), console.log("[FlowEngage] 🎙️ AI chat session connected:", e);
13685
+ Pe.current = e, Ie.current = Date.now(), console.log("[FlowEngage] 🎙️ AI chat session connected:", e);
13678
13686
  },
13679
13687
  onUnhandledClientToolCall: (e) => console.error("[FlowEngage] Unhandled tool:", e?.tool_name),
13680
13688
  onSessionInfo: ({ emailOnFile: e }) => {
13681
- he.current = !!e, e && (P.current = !0, oe.current = !1, M(!1), He(), console.log("[FlowEngage] email already on file per server — gate disabled"));
13689
+ ge.current = !!e, e && (oe.current = !0, F.current = !1, re(!1), We(), console.log("[FlowEngage] email already on file per server — gate disabled"));
13682
13690
  },
13683
13691
  onAgentTurnEnd: () => {
13684
- e || pe.current && (me.current || de.current || setTimeout(() => ye.current?.(), 250));
13692
+ e || me.current && (he.current || fe.current || setTimeout(() => be.current?.(), 250));
13685
13693
  },
13686
13694
  onSessionEnding: () => {
13687
- e || B("minimized");
13695
+ e || Ue("minimized");
13688
13696
  },
13689
13697
  onModeChange: ({ mode: t, tentative: n }) => {
13690
13698
  if (!e) {
13691
13699
  if (t === "speaking") {
13692
- ze.current &&= (clearTimeout(ze.current), null), Ve.current &&= (clearTimeout(Ve.current), null), E("speaking"), z.current = "speaking", Be.current = !1;
13700
+ Ve.current &&= (clearTimeout(Ve.current), null), z.current &&= (clearTimeout(z.current), null), D("speaking"), Be.current = "speaking", He.current = !1;
13693
13701
  return;
13694
13702
  }
13695
13703
  if (t === "user-speaking") {
13696
- if (oe.current && !P.current && Ye(), Ve.current &&= (clearTimeout(Ve.current), null), z.current === "speaking") return;
13704
+ if (F.current && !oe.current && B(), z.current &&= (clearTimeout(z.current), null), Be.current === "speaking") return;
13697
13705
  try {
13698
13706
  Pn();
13699
13707
  } catch {}
13700
- ze.current &&= (clearTimeout(ze.current), null), z.current !== "listening" && (E("listening"), z.current = "listening");
13708
+ Ve.current &&= (clearTimeout(Ve.current), null), Be.current !== "listening" && (D("listening"), Be.current = "listening");
13701
13709
  return;
13702
13710
  }
13703
13711
  if (t === "thinking") {
13704
- if (ze.current &&= (clearTimeout(ze.current), null), Ve.current &&= (clearTimeout(Ve.current), null), z.current === "speaking") return;
13705
- E("thinking"), z.current = "thinking", n && (Ve.current = setTimeout(() => {
13706
- Ve.current = null, !(e || z.current !== "thinking") && (z.current = "listening", E("listening"));
13712
+ if (Ve.current &&= (clearTimeout(Ve.current), null), z.current &&= (clearTimeout(z.current), null), Be.current === "speaking") return;
13713
+ D("thinking"), Be.current = "thinking", n && (z.current = setTimeout(() => {
13714
+ z.current = null, !(e || Be.current !== "thinking") && (Be.current = "listening", D("listening"));
13707
13715
  }, 4e3));
13708
13716
  return;
13709
13717
  }
13710
- if (z.current = "listening", R.current) {
13711
- R.current = !1, B();
13718
+ if (Be.current = "listening", ze.current) {
13719
+ ze.current = !1, Ue();
13712
13720
  return;
13713
13721
  }
13714
- if (F && !ae && !P.current && !he.current) {
13715
- ae = !0, A = !0, te = !0;
13722
+ if (se && !P && !oe.current && !ge.current) {
13723
+ P = !0, ee = !0, ne = !0;
13716
13724
  try {
13717
13725
  L.current?.sendContextualUpdate?.("CRITICAL — EMAIL REQUIRED BEFORE ANYTHING ELSE. The visitor has not provided their email. The app itself speaks the email request out loud — you must NOT say it, and you must NOT answer. Stay completely silent from now until you receive an EMAIL_SAVED message: produce no speech and call no tools, no matter what the visitor says. Remember their question. On EMAIL_SAVED, thank them briefly and answer that remembered question in full.");
13718
13726
  } catch {}
13719
13727
  }
13720
- if (ee && !A) {
13721
- A = !0;
13728
+ if (te && !ee) {
13729
+ ee = !0;
13722
13730
  try {
13723
- L.current?.sendContextualUpdate?.(ee);
13731
+ L.current?.sendContextualUpdate?.(te);
13724
13732
  } catch {}
13725
13733
  }
13726
- if (ie && !re) {
13727
- re = !0;
13734
+ if (ae && !ie) {
13735
+ ie = !0;
13728
13736
  try {
13729
- L.current?.sendContextualUpdate?.(ie);
13737
+ L.current?.sendContextualUpdate?.(ae);
13730
13738
  } catch {}
13731
13739
  }
13732
- if (ne && !te) {
13733
- te = !0;
13740
+ if (j && !ne) {
13741
+ ne = !0;
13734
13742
  try {
13735
- L.current?.sendContextualUpdate?.(ne);
13743
+ L.current?.sendContextualUpdate?.(j);
13736
13744
  } catch {}
13737
13745
  }
13738
- ze.current && clearTimeout(ze.current), ze.current = setTimeout(() => {
13739
- e || z.current !== "speaking" && (Be.current || (ze.current = null, z.current = "listening", E("listening")));
13746
+ Ve.current && clearTimeout(Ve.current), Ve.current = setTimeout(() => {
13747
+ e || Be.current !== "speaking" && (He.current || (Ve.current = null, Be.current = "listening", D("listening")));
13740
13748
  }, 1200);
13741
13749
  }
13742
13750
  },
13743
13751
  onMessage: (t) => {
13744
- if (e || de.current && t.role !== "user" && !/email/i.test(String(t.message || ""))) return;
13752
+ if (e || fe.current && t.role !== "user" && !/email/i.test(String(t.message || ""))) return;
13745
13753
  let n = t.role === "user" && /^(Describe the section titled "|\[SYSTEM:|Give the visitor a complete spoken overview|That was the last section)/.test(String(t.message || "").trim()), r = /\b(?:this|that|the)\s+(?:case\s*stud(?:y|ies)|product|article|blog|post|item|service)\b/i.test(String(t.message || ""));
13746
- if (!n && !r && t.role === "user" && Ue.test(String(t.message || ""))) typeof window < "u" && (window.__fe_user_nav_during_speech = null), I(!0), me.current = !1, fe.current = 0, be.current = -1, ge.current = h_(), _e.current = typeof window < "u" ? window.location.pathname : null, setTimeout(() => ye.current?.(), 400), console.log(`[FlowEngage] walkthrough armed — ${ge.current.length} sections on this page`);
13747
- else if (!n && t.role === "user" && pe.current) {
13748
- let e = String(t.message || "").trim(), n = Je(e), r = (e) => !!e && (Ge.test(e) || qe.test(e));
13749
- Ke.test(ve.current || "") ? (console.log("[FlowEngage] walkthrough ended — visitor accepted a navigation offer"), _e.current = null, ge.current = [], I(!1)) : !n || r(e) || r(n) ? me.current && (me.current = !1, console.debug("[FlowEngage] walkthrough resumed by visitor"), setTimeout(() => ye.current?.(), 300)) : (console.log("[FlowEngage] walkthrough ended — visitor moved to a new topic"), _e.current = null, ge.current = [], I(!1));
13754
+ if (!n && !r && t.role === "user" && Ge.test(String(t.message || ""))) typeof window < "u" && (window.__fe_user_nav_during_speech = null), xe(!0), he.current = !1, pe.current = 0, I.current = -1, _e.current = h_(), ve.current = typeof window < "u" ? window.location.pathname : null, setTimeout(() => be.current?.(), 400), console.log(`[FlowEngage] walkthrough armed — ${_e.current.length} sections on this page`);
13755
+ else if (!n && t.role === "user" && me.current) {
13756
+ let e = String(t.message || "").trim(), n = Xe(e), r = (e) => !!e && (qe.test(e) || Ye.test(e));
13757
+ Je.test(ye.current || "") ? (console.log("[FlowEngage] walkthrough ended — visitor accepted a navigation offer"), ve.current = null, _e.current = [], xe(!1)) : !n || r(e) || r(n) ? he.current && (he.current = !1, console.debug("[FlowEngage] walkthrough resumed by visitor"), setTimeout(() => be.current?.(), 300)) : (console.log("[FlowEngage] walkthrough ended — visitor moved to a new topic"), ve.current = null, _e.current = [], xe(!1));
13750
13758
  }
13751
- if (t.role !== "user" && !n && (ve.current = String(t.message || "")), t.role !== "user" && We.test(String(t.message || ""))) {
13752
- let e = ge.current.length;
13753
- !e || be.current >= e - 1 ? I(!1) : console.debug(`[FlowEngage] agent claimed completion at step ${be.current + 1}/${e} — ignoring, tour continues`);
13759
+ if (t.role !== "user" && !n && (ye.current = String(t.message || "")), t.role !== "user" && Ke.test(String(t.message || ""))) {
13760
+ let e = _e.current.length;
13761
+ !e || I.current >= e - 1 ? xe(!1) : console.debug(`[FlowEngage] agent claimed completion at step ${I.current + 1}/${e} — ignoring, tour continues`);
13754
13762
  }
13755
13763
  let a = t.role === "user" ? "user" : "bot", o = t.message || t.text || t.content || "";
13756
13764
  if (o) {
13757
- if (a === "user" && (Se.current = o, typeof window < "u" && (window.__fe_user_nav_during_speech = null), Be.current = !0, ze.current &&= (clearTimeout(ze.current), null), z.current !== "speaking" && (E("thinking"), z.current = "thinking"), F && !N && !P.current && !he.current && (N = !0, ue.current = o, de.current = !0, L.current?.injectAgentSpeech?.("Before I answer that, could you please enter your email in the text box below?", "interrupt"), L.current?.setMicMuted?.(!0), oe.current || (oe.current = !0, se.current = 0, M(!0), Ye()))), l.current = [...l.current, {
13765
+ if (a === "user" && (Ce.current = o, typeof window < "u" && (window.__fe_user_nav_during_speech = null), He.current = !0, Ve.current &&= (clearTimeout(Ve.current), null), Be.current !== "speaking" && (D("thinking"), Be.current = "thinking"), se && !N && !oe.current && !ge.current && (N = !0, de.current = o, fe.current = !0, L.current?.injectAgentSpeech?.("Before I answer that, could you please enter your email in the text box below?", "interrupt"), L.current?.setMicMuted?.(!0), F.current || (F.current = !0, ue.current = 0, re(!0), B()))), l.current = [...l.current, {
13758
13766
  sender: a,
13759
13767
  message: o,
13760
13768
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
@@ -13764,18 +13772,18 @@ function k_({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13764
13772
  e && Ee(i, e);
13765
13773
  } catch {}
13766
13774
  if (T_(a, o)) {
13767
- R.current = !0;
13775
+ ze.current = !0;
13768
13776
  return;
13769
13777
  }
13770
- if (Te.current && a === "bot" && /are you still there|still there\??|hello\?|anyone there|checking in|you there|are you available|is anyone|did you step away/i.test(o)) if (Le.current += 1, Le.current === 2) try {
13778
+ if (ke.current && a === "bot" && /are you still there|still there\??|hello\?|anyone there|checking in|you there|are you available|is anyone|did you step away/i.test(o)) if (R.current += 1, R.current === 2) try {
13771
13779
  L.current?.sendContextualUpdate?.("IMPORTANT: The visitor is muted and has not responded to your last 2 checks. Make exactly ONE more check. If there is still no response, say: 'I feel like you are not active, so I'm ending this session. You can connect with me anytime.' then immediately call the fwh-end-session-mvp tool to end the voice session. Do NOT ask again after that.");
13772
13780
  } catch {}
13773
- else Le.current >= 5 && B("minimized");
13781
+ else R.current >= 5 && Ue("minimized");
13774
13782
  }
13775
13783
  },
13776
13784
  onError: (t) => {
13777
- if (!e && !je.current && !ke.current && !Fe()) {
13778
- ke.current = !0, console.error("[FlowEngageVoiceCall] session:error", {
13785
+ if (!e && !Me.current && !je.current && !Fe()) {
13786
+ je.current = !0, console.error("[FlowEngageVoiceCall] session:error", {
13779
13787
  message: t?.message,
13780
13788
  name: t?.name,
13781
13789
  raw: t
@@ -13783,31 +13791,31 @@ function k_({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13783
13791
  try {
13784
13792
  L.current?.setMicMuted?.(!0);
13785
13793
  } catch {}
13786
- O(!0), E("error"), B("chat");
13794
+ k(!0), D("error"), Ue("chat");
13787
13795
  }
13788
13796
  },
13789
13797
  onDisconnect: (t) => {
13790
- if (e || je.current || ke.current || Fe()) return;
13798
+ if (e || Me.current || je.current || Fe()) return;
13791
13799
  let n = l.current?.length || 0;
13792
13800
  console.warn("[FlowEngageVoiceCall] session:disconnected", {
13793
13801
  historyCount: n,
13794
13802
  reason: t?.reason,
13795
13803
  closeCode: t?.context?.code,
13796
13804
  closeReason: t?.context?.reason || t?.message,
13797
- lastUserText: Se.current || "",
13798
- wasMuted: Te.current
13799
- }), ke.current = !0;
13805
+ lastUserText: Ce.current || "",
13806
+ wasMuted: ke.current
13807
+ }), je.current = !0;
13800
13808
  try {
13801
13809
  L.current?.setMicMuted?.(!0);
13802
13810
  } catch {}
13803
- O(!0), B("chat");
13811
+ k(!0), Ue("chat");
13804
13812
  }
13805
13813
  });
13806
13814
  if (e) {
13807
13815
  console.warn("[FlowEngage:VoiceDebug] ❌ cancelled=true after startSession resolved — killing session immediately"), ce.endSession().catch(() => {});
13808
13816
  return;
13809
13817
  }
13810
- o = ce, L.current = ce, E("listening");
13818
+ o = ce, L.current = ce, D("listening");
13811
13819
  try {
13812
13820
  sessionStorage.setItem(`el_conv_${i}`, ce.getId());
13813
13821
  } catch {}
@@ -13823,7 +13831,7 @@ function k_({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13823
13831
  n.length || (n = Array.from(document.body.querySelectorAll("h1, h2, h3")).filter((t) => !t.closest(e)).map((e) => e.textContent.replace(/\s+/g, " ").trim()).filter((e) => e.length > 2 && e.length < 200)), n.length && (o = [...new Set(n)].slice(0, 15).join(" | "));
13824
13832
  } catch {}
13825
13833
  let s = r && !p ? `RESUMING PRIOR SESSION — DO NOT GREET. The visitor is continuing the same conversation after a page reload. Do not introduce yourself or re-state your capabilities. Wait silently until the visitor speaks; if you must speak first, briefly acknowledge where you left off in one short sentence.\nPrior transcript:\n${n?.transcript || ""}\n\n` : "";
13826
- ce.sendContextualUpdate(`${s}SiteId: ${i || "unknown"}. ${y ? "" : "Visitor's email is already on file from a prior session — do NOT ask for it again. "}WALKTHROUGH RULE: When the visitor asks for a walkthrough or overview of this page, you MUST IMMEDIATELY call fwh-get-current-page-mvp (zero speech — call it silently with NO words before it) to get the exact highlightable headings. Do NOT skip fwh-get-current-page-mvp. Voice: call end_voice_session or say you are ending the session to stop.`), ce.sendContextualUpdate(v_(e, o, a));
13834
+ ce.sendContextualUpdate(`${s}SiteId: ${i || "unknown"}. ${b ? "" : "Visitor's email is already on file from a prior session — do NOT ask for it again. "}WALKTHROUGH RULE: When the visitor asks for a walkthrough or overview of this page, you MUST IMMEDIATELY call fwh-get-current-page-mvp (zero speech — call it silently with NO words before it) to get the exact highlightable headings. Do NOT skip fwh-get-current-page-mvp. Voice: call end_voice_session or say you are ending the session to stop.`), ce.sendContextualUpdate(v_(e, o, a));
13827
13835
  } catch {}
13828
13836
  if (typeof window < "u") {
13829
13837
  let t = window.location.pathname, n = Date.now(), r = (e) => {
@@ -13843,7 +13851,7 @@ function k_({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13843
13851
  t = i;
13844
13852
  return;
13845
13853
  }
13846
- let a = typeof window < "u" && window.__fe_agent_nav || null, o = k && r(i) === r(k) || Gn() || a && Date.now() - a.ts < 15e3 && r(a.path) === r(i), s = t;
13854
+ let a = typeof window < "u" && window.__fe_agent_nav || null, o = A && r(i) === r(A) || Gn() || a && Date.now() - a.ts < 15e3 && r(a.path) === r(i), s = t;
13847
13855
  t = i;
13848
13856
  let c = window.location.href, l = typeof document < "u" ? document.title : "", u = typeof document < "u" ? Array.from(document.querySelectorAll("h1, h2, h3, h4")).filter((e) => !e.closest("#flowengage-root, .flowengage-shell")).map((e) => ({
13849
13857
  tag: e.tagName,
@@ -13869,7 +13877,7 @@ function k_({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13869
13877
  fromPageName: p,
13870
13878
  toPageName: m,
13871
13879
  ts: Date.now()
13872
- }), console.log(`[FlowEngage] visitor navigation detected: "${s}" → "${i}" (agent target: ${k || "none"})`);
13880
+ }), console.log(`[FlowEngage] visitor navigation detected: "${s}" → "${i}" (agent target: ${A || "none"})`);
13873
13881
  try {
13874
13882
  L.current?.sendUserMessage?.(`[SYSTEM: I navigated away mid-walkthrough — I am now on the "${m}" page (${c}). Page title: "${l}". Sections: ${JSON.stringify(u)}. STOP everything. Do NOT describe the new page. Say EXACTLY: "I see you've navigated to the ${m} page — would you like me to continue what I was explaining, or shall I walk you through this page?" Then wait for my answer. IF I say continue/yes/carry on: resume speaking verbally from where you left off — do NOT call fwh-navigate-mvp, do NOT call fwh-highlight-mvp, the visitor will navigate themselves if needed. IF I want to hear about this page: call fwh-highlight-mvp for sections of "${m}" only.]`);
13875
13883
  } catch {}
@@ -13879,10 +13887,10 @@ function k_({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13879
13887
  };
13880
13888
  c = window.history.pushState.bind(window.history), window.history.pushState = (...e) => {
13881
13889
  c(...e), setTimeout(i, 50);
13882
- }, d = () => setTimeout(i, 50), window.addEventListener("popstate", d);
13890
+ }, f = () => setTimeout(i, 50), window.addEventListener("popstate", f);
13883
13891
  }
13884
13892
  } catch (r) {
13885
- e || (console.error("[FlowEngage] startSession failed", r), r.message && r.message.includes("Too many voice sessions") ? (alert(r.message), n && n("minimized")) : (E("error"), Me.current = "chat", window.setTimeout(() => {
13893
+ e || (console.error("[FlowEngage] startSession failed", r), r.message && r.message.includes("Too many voice sessions") ? (alert(r.message), n && n("minimized")) : (D("error"), Ne.current = "chat", window.setTimeout(() => {
13886
13894
  e || t?.();
13887
13895
  }, 0)));
13888
13896
  }
@@ -13891,17 +13899,17 @@ function k_({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13891
13899
  agentId: r,
13892
13900
  siteId: i,
13893
13901
  apiBaseUrl: a
13894
- }), e = !0, je.current = !0;
13902
+ }), e = !0, Me.current = !0;
13895
13903
  try {
13896
13904
  Pn();
13897
13905
  } catch {}
13898
13906
  if (i) try {
13899
13907
  Re(i);
13900
13908
  } catch {}
13901
- typeof window < "u" && (window.__fe_user_nav_during_speech = null), Pr(), ze.current &&= (clearTimeout(ze.current), null), Ve.current &&= (clearTimeout(Ve.current), null), F.current &&= (clearTimeout(F.current), null), Be.current = !1, z.current = "idle", c && typeof window < "u" && (window.history.pushState = c), d && typeof window < "u" && window.removeEventListener("popstate", d);
13902
- let t = o || L.current, n = Ne.current, f = Pe.current;
13909
+ typeof window < "u" && (window.__fe_user_nav_during_speech = null), Pr(), Ve.current &&= (clearTimeout(Ve.current), null), z.current &&= (clearTimeout(z.current), null), se.current &&= (clearTimeout(se.current), null), He.current = !1, Be.current = "idle", c && typeof window < "u" && (window.history.pushState = c), f && typeof window < "u" && window.removeEventListener("popstate", f);
13910
+ let t = o || L.current, n = Pe.current, d = Ie.current;
13903
13911
  if (t?.endSession?.().catch(() => {}), n && s && a) {
13904
- let e = f ? Math.round((Date.now() - f) / 1e3) : 0, t = JSON.stringify({
13912
+ let e = d ? Math.round((Date.now() - d) / 1e3) : 0, t = JSON.stringify({
13905
13913
  chatId: s,
13906
13914
  voiceSessionId: n,
13907
13915
  duration: e,
@@ -13912,7 +13920,7 @@ function k_({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13912
13920
  headers: { "Content-Type": "application/json" },
13913
13921
  body: t,
13914
13922
  keepalive: !0
13915
- }).catch(() => {}), Ne.current = null, Pe.current = null;
13923
+ }).catch(() => {}), Pe.current = null, Ie.current = null;
13916
13924
  }
13917
13925
  typeof u == "function" && l.current.length > 0 && u(l.current).catch?.(() => {});
13918
13926
  };
@@ -13920,53 +13928,53 @@ function k_({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13920
13928
  r,
13921
13929
  i,
13922
13930
  a,
13923
- B
13931
+ Ue
13924
13932
  ]), c(() => {
13925
- if (!k) return;
13933
+ if (!A) return;
13926
13934
  let e = (e) => {
13927
13935
  let t = e.composedPath?.()?.[0] || e.target;
13928
- Ie.current && !Ie.current.contains(t) && A(!1);
13936
+ Le.current && !Le.current.contains(t) && ee(!1);
13929
13937
  };
13930
13938
  return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
13931
- }, [k]);
13932
- let Ze = async () => {
13939
+ }, [A]);
13940
+ let Qe = async () => {
13933
13941
  if (L.current) try {
13934
- if (D) {
13935
- Le.current = 0, await L.current.setMicMuted?.(!1), O(!1);
13942
+ if (O) {
13943
+ R.current = 0, await L.current.setMicMuted?.(!1), k(!1);
13936
13944
  try {
13937
13945
  L.current.sendContextualUpdate?.("The visitor has unmuted. Resume normal interaction and wait for them to speak.");
13938
13946
  } catch {}
13939
13947
  } else {
13940
- Le.current = 0, await L.current.setMicMuted?.(!0), O(!0);
13948
+ R.current = 0, await L.current.setMicMuted?.(!0), k(!0);
13941
13949
  try {
13942
13950
  L.current.sendContextualUpdate?.("The visitor has muted their microphone. Do NOT speak, ask if they are there, or prompt them in any way. Stay completely silent until they unmute.");
13943
13951
  } catch {}
13944
13952
  }
13945
13953
  } catch {}
13946
- }, Qe = o(async (e) => {
13954
+ }, V = o(async (e) => {
13947
13955
  e?.preventDefault?.();
13948
- let t = re.trim().toLowerCase();
13956
+ let t = ie.trim().toLowerCase();
13949
13957
  if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t)) {
13950
- ae("Please enter a valid email address.");
13958
+ P("Please enter a valid email address.");
13951
13959
  return;
13952
13960
  }
13953
- ae(""), P.current = !0, oe.current = !1, He(), M(!1), ie(""), de.current = !1;
13961
+ P(""), oe.current = !0, F.current = !1, We(), re(!1), ae(""), fe.current = !1;
13954
13962
  try {
13955
- typeof v == "function" && await v(t);
13963
+ typeof y == "function" && await y(t);
13956
13964
  } catch {}
13957
13965
  L.current?.setMicMuted?.(!1);
13958
- let n = ue.current;
13959
- ue.current = "";
13966
+ let n = de.current;
13967
+ de.current = "";
13960
13968
  try {
13961
13969
  L.current?.injectAgentSpeech?.("Thank you for submitting your email."), L.current?.sendUserMessage?.(n || "The visitor's email is on file. Carry on helping them and never ask for it again.");
13962
13970
  } catch {}
13963
13971
  }, [
13964
- re,
13965
- v,
13966
- He
13967
- ]), V = Array.isArray(e) && e[0] || "#3B82F6";
13972
+ ie,
13973
+ y,
13974
+ We
13975
+ ]), H = Array.isArray(e) && e[0] || "#3B82F6";
13968
13976
  return /* @__PURE__ */ _("div", {
13969
- ref: Ie,
13977
+ ref: Le,
13970
13978
  style: {
13971
13979
  position: "relative",
13972
13980
  display: "flex",
@@ -13976,8 +13984,8 @@ function k_({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13976
13984
  animation: "fe-orb-slide-up 0.42s cubic-bezier(0.16,1,0.3,1)"
13977
13985
  },
13978
13986
  children: [
13979
- j && /* @__PURE__ */ _("form", {
13980
- onSubmit: Qe,
13987
+ M && /* @__PURE__ */ _("form", {
13988
+ onSubmit: V,
13981
13989
  style: {
13982
13990
  width: "270px",
13983
13991
  maxWidth: "calc(100vw - 40px)",
@@ -14008,9 +14016,9 @@ function k_({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
14008
14016
  inputMode: "email",
14009
14017
  autoComplete: "email",
14010
14018
  autoFocus: !0,
14011
- value: re,
14019
+ value: ie,
14012
14020
  onChange: (e) => {
14013
- ie(e.target.value), N && ae("");
14021
+ ae(e.target.value), N && P("");
14014
14022
  },
14015
14023
  placeholder: "you@example.com",
14016
14024
  style: {
@@ -14034,17 +14042,17 @@ function k_({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
14034
14042
  }),
14035
14043
  /* @__PURE__ */ g("button", {
14036
14044
  type: "submit",
14037
- disabled: !re.trim(),
14045
+ disabled: !ie.trim(),
14038
14046
  style: {
14039
14047
  width: "100%",
14040
14048
  padding: "10px 12px",
14041
14049
  borderRadius: "10px",
14042
14050
  border: "none",
14043
- background: re.trim() ? V : "#374151",
14051
+ background: ie.trim() ? H : "#374151",
14044
14052
  color: "white",
14045
14053
  fontSize: "14px",
14046
14054
  fontWeight: 600,
14047
- cursor: re.trim() ? "pointer" : "default",
14055
+ cursor: ie.trim() ? "pointer" : "default",
14048
14056
  transition: "background 0.2s ease"
14049
14057
  },
14050
14058
  children: "Submit"
@@ -14054,7 +14062,7 @@ function k_({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
14054
14062
  /* @__PURE__ */ _("div", {
14055
14063
  style: { position: "relative" },
14056
14064
  children: [
14057
- (T === "listening" || T === "thinking") && !D && /* @__PURE__ */ g("span", {
14065
+ (E === "listening" || E === "thinking") && !O && /* @__PURE__ */ g("span", {
14058
14066
  style: {
14059
14067
  position: "absolute",
14060
14068
  right: "100%",
@@ -14068,9 +14076,9 @@ function k_({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
14068
14076
  textShadow: "0 2px 4px rgba(0,0,0,0.4)",
14069
14077
  whiteSpace: "nowrap"
14070
14078
  },
14071
- children: T === "thinking" ? S : x
14079
+ children: E === "thinking" ? C : S
14072
14080
  }),
14073
- D && /* @__PURE__ */ g("span", {
14081
+ O && /* @__PURE__ */ g("span", {
14074
14082
  style: {
14075
14083
  position: "absolute",
14076
14084
  right: "100%",
@@ -14088,13 +14096,13 @@ function k_({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
14088
14096
  }),
14089
14097
  /* @__PURE__ */ g(E_, {
14090
14098
  size: 72,
14091
- voiceState: T,
14092
- isMuted: D,
14099
+ voiceState: E,
14100
+ isMuted: O,
14093
14101
  orbColors: e
14094
14102
  })
14095
14103
  ]
14096
14104
  }),
14097
- T === "error" && /* @__PURE__ */ g("span", {
14105
+ E === "error" && /* @__PURE__ */ g("span", {
14098
14106
  style: {
14099
14107
  color: "#f87171",
14100
14108
  fontSize: "13px",
@@ -14109,25 +14117,25 @@ function k_({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
14109
14117
  alignItems: "center"
14110
14118
  },
14111
14119
  children: [/* @__PURE__ */ g("button", {
14112
- onClick: Ze,
14113
- title: D ? "Unmute" : "Mute",
14120
+ onClick: Qe,
14121
+ title: O ? "Unmute" : "Mute",
14114
14122
  style: {
14115
14123
  width: "24px",
14116
14124
  height: "24px",
14117
14125
  borderRadius: "50%",
14118
- background: D ? "#7f1d1d" : "#1f2937",
14119
- border: D ? "1.5px solid #ef4444" : "1.5px solid #4b5563",
14126
+ background: O ? "#7f1d1d" : "#1f2937",
14127
+ border: O ? "1.5px solid #ef4444" : "1.5px solid #4b5563",
14120
14128
  display: "flex",
14121
14129
  alignItems: "center",
14122
14130
  justifyContent: "center",
14123
14131
  cursor: "pointer",
14124
- color: D ? "#f87171" : "white",
14132
+ color: O ? "#f87171" : "white",
14125
14133
  transition: "all 0.2s ease",
14126
14134
  boxShadow: "0 2px 8px rgba(0,0,0,0.4)",
14127
14135
  padding: 0,
14128
14136
  flexShrink: 0
14129
14137
  },
14130
- children: D ? /* @__PURE__ */ _("svg", {
14138
+ children: O ? /* @__PURE__ */ _("svg", {
14131
14139
  width: "16",
14132
14140
  height: "16",
14133
14141
  viewBox: "0 0 24 24",
@@ -14163,7 +14171,7 @@ function k_({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
14163
14171
  color: "currentColor"
14164
14172
  })
14165
14173
  }), /* @__PURE__ */ g("button", {
14166
- onClick: () => A((e) => !e),
14174
+ onClick: () => ee((e) => !e),
14167
14175
  style: {
14168
14176
  width: "24px",
14169
14177
  height: "24px",
@@ -14186,7 +14194,7 @@ function k_({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
14186
14194
  })
14187
14195
  })]
14188
14196
  }),
14189
- k && /* @__PURE__ */ _("div", {
14197
+ A && /* @__PURE__ */ _("div", {
14190
14198
  style: {
14191
14199
  position: "absolute",
14192
14200
  bottom: 0,
@@ -14204,7 +14212,7 @@ function k_({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
14204
14212
  children: [
14205
14213
  /* @__PURE__ */ _("button", {
14206
14214
  onClick: () => {
14207
- A(!1), Me.current = "chat", Xe(t);
14215
+ ee(!1), Ne.current = "chat", Ze(t);
14208
14216
  },
14209
14217
  style: {
14210
14218
  display: "flex",
@@ -14229,15 +14237,15 @@ function k_({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
14229
14237
  onMouseLeave: (e) => {
14230
14238
  e.currentTarget.style.background = "none";
14231
14239
  },
14232
- children: [/* @__PURE__ */ g(zh, {}), C]
14240
+ children: [/* @__PURE__ */ g(zh, {}), w]
14233
14241
  }),
14234
14242
  i && /* @__PURE__ */ _("button", {
14235
- onClick: () => ne(),
14243
+ onClick: () => j(),
14236
14244
  style: {
14237
14245
  display: "flex",
14238
14246
  alignItems: "center",
14239
14247
  justifyContent: "space-between",
14240
- gap: "12px",
14248
+ gap: "8px",
14241
14249
  width: "100%",
14242
14250
  padding: "12px 16px",
14243
14251
  background: "none",
@@ -14248,8 +14256,7 @@ function k_({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
14248
14256
  cursor: "pointer",
14249
14257
  textAlign: "left",
14250
14258
  transition: "background 0.15s ease",
14251
- borderRadius: "8px",
14252
- whiteSpace: "nowrap"
14259
+ borderRadius: "8px"
14253
14260
  },
14254
14261
  onMouseEnter: (e) => {
14255
14262
  e.currentTarget.style.background = "rgba(255,255,255,0.08)";
@@ -14261,7 +14268,9 @@ function k_({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
14261
14268
  style: {
14262
14269
  display: "flex",
14263
14270
  alignItems: "center",
14264
- gap: "12px"
14271
+ gap: "12px",
14272
+ minWidth: 0,
14273
+ overflow: "hidden"
14265
14274
  },
14266
14275
  children: [/* @__PURE__ */ g("svg", {
14267
14276
  width: "16",
@@ -14272,15 +14281,23 @@ function k_({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
14272
14281
  strokeWidth: "2",
14273
14282
  strokeLinecap: "round",
14274
14283
  strokeLinejoin: "round",
14284
+ style: { flexShrink: 0 },
14275
14285
  children: /* @__PURE__ */ g("polygon", { points: "3 11 22 2 13 21 11 13 3 11" })
14276
- }), "Navigate automatically"]
14286
+ }), /* @__PURE__ */ g("span", {
14287
+ style: {
14288
+ overflow: "hidden",
14289
+ textOverflow: "ellipsis",
14290
+ whiteSpace: "nowrap"
14291
+ },
14292
+ children: "Auto-navigate"
14293
+ })]
14277
14294
  }), /* @__PURE__ */ g("span", {
14278
14295
  "aria-hidden": !0,
14279
14296
  style: {
14280
14297
  width: "34px",
14281
14298
  height: "19px",
14282
14299
  borderRadius: "999px",
14283
- background: ee ? "#22c55e" : "rgba(255,255,255,0.2)",
14300
+ background: te ? "#22c55e" : "rgba(255,255,255,0.2)",
14284
14301
  position: "relative",
14285
14302
  flexShrink: 0,
14286
14303
  transition: "background 0.15s ease"
@@ -14288,7 +14305,7 @@ function k_({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
14288
14305
  children: /* @__PURE__ */ g("span", { style: {
14289
14306
  position: "absolute",
14290
14307
  top: "2px",
14291
- left: ee ? "17px" : "2px",
14308
+ left: te ? "17px" : "2px",
14292
14309
  width: "15px",
14293
14310
  height: "15px",
14294
14311
  borderRadius: "50%",
@@ -14299,7 +14316,7 @@ function k_({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
14299
14316
  }),
14300
14317
  /* @__PURE__ */ _("button", {
14301
14318
  onClick: () => {
14302
- A(!1), Me.current = "minimized", Xe(n);
14319
+ ee(!1), Ne.current = "minimized", Ze(n);
14303
14320
  },
14304
14321
  style: {
14305
14322
  display: "flex",
@@ -14324,10 +14341,10 @@ function k_({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
14324
14341
  onMouseLeave: (e) => {
14325
14342
  e.currentTarget.style.background = "none";
14326
14343
  },
14327
- children: [/* @__PURE__ */ g(Bh, {}), w]
14344
+ children: [/* @__PURE__ */ g(Bh, {}), T]
14328
14345
  }),
14329
14346
  /* @__PURE__ */ g("button", {
14330
- onClick: () => A(!1),
14347
+ onClick: () => ee(!1),
14331
14348
  style: {
14332
14349
  position: "absolute",
14333
14350
  bottom: "8px",
@@ -14425,40 +14442,40 @@ var j_ = () => /* @__PURE__ */ g("div", {
14425
14442
  } }, e))
14426
14443
  })
14427
14444
  });
14428
- function M_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i, quickChatOptions: a, onQuickChatSelect: o, isMobile: s, chatHistory: l, isAiTyping: u, isAgentTyping: d, activeScreen: f, agentName: v, agentHeadshot: y, fallbackAgentName: b, input: x, setInput: S, onSubmit: C, isConversationEnded: w, isLoading: T, isRateLimited: E, rateLimitMessage: D, selectedFile: O, onFileSelect: k, onRemoveSelectedFile: A, attachmentError: ee, isUploadingAttachment: te, requiresEmail: ne, emailInput: j, setEmailInput: M, emailError: re, emailCaptureSuccess: ie, replyContext: N, setReplyContext: ae, webRTCError: P, micError: oe, setMicError: F, dismissCallError: se, activeCallId: ue, isCallMuted: de, toggleCallMute: fe, endWebRTCCall: pe, formatCallDuration: me, callDurationSeconds: he, isCallMinimized: ge, onExpand: _e, onCollapse: ve, onStartVoice: ye, voiceEnabled: I, headerBgColor: be, onNewChat: L, showPoweredBy: xe, privacyPolicyUrl: Se, getVisitorChatHistory: Ce, resumeChat: we, isSessionRestoring: Te, isClosing: Ee }) {
14445
+ function M_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i, quickChatOptions: a, onQuickChatSelect: o, isMobile: s, chatHistory: l, isAiTyping: u, isAgentTyping: d, activeScreen: f, agentName: v, agentHeadshot: y, fallbackAgentName: b, input: x, setInput: S, onSubmit: C, isConversationEnded: w, isLoading: T, isRateLimited: E, rateLimitMessage: D, selectedFile: O, onFileSelect: k, onRemoveSelectedFile: A, attachmentError: ee, isUploadingAttachment: te, requiresEmail: ne, emailInput: j, setEmailInput: M, emailError: re, emailCaptureSuccess: ie, replyContext: ae, setReplyContext: N, webRTCError: P, micError: oe, setMicError: F, dismissCallError: se, activeCallId: ue, isCallMuted: de, toggleCallMute: fe, endWebRTCCall: pe, formatCallDuration: me, callDurationSeconds: he, isCallMinimized: ge, onExpand: _e, onCollapse: ve, onStartVoice: ye, voiceEnabled: be, headerBgColor: xe, onNewChat: I, showPoweredBy: L, privacyPolicyUrl: Se, getVisitorChatHistory: Ce, resumeChat: we, isSessionRestoring: Te, isClosing: Ee }) {
14429
14446
  let De = l.length > 0, Oe = T || E || w, ke = !!ue, [Ae, je] = m(!1), { resolvedConfig: Me } = kn(), Ne = Me?.siteId || null, [Pe, Fe] = m(() => ce(Ne) === "auto"), Ie = () => {
14430
14447
  let e = Pe ? "ask" : "auto";
14431
14448
  le(Ne, e), Fe(e === "auto");
14432
- }, [Le, Re] = m(!1), [R, z] = m([]), [ze, Be] = m(!1), Ve = p(null), [B, He] = m(() => typeof window < "u" ? window.visualViewport?.height ?? window.innerHeight : 600), [Ue, We] = m(0);
14449
+ }, [Le, Re] = m(!1), [R, ze] = m([]), [Be, Ve] = m(!1), He = p(null), [z, Ue] = m(() => typeof window < "u" ? window.visualViewport?.height ?? window.innerHeight : 600), [We, Ge] = m(0);
14433
14450
  c(() => {
14434
14451
  if (!s) return;
14435
14452
  let e = window.visualViewport;
14436
14453
  if (!e) return;
14437
14454
  let t = () => {
14438
- He(e.height), We(Math.max(0, window.innerHeight - e.offsetTop - e.height));
14455
+ Ue(e.height), Ge(Math.max(0, window.innerHeight - e.offsetTop - e.height));
14439
14456
  };
14440
14457
  return e.addEventListener("resize", t), e.addEventListener("scroll", t), t(), () => {
14441
14458
  e.removeEventListener("resize", t), e.removeEventListener("scroll", t);
14442
14459
  };
14443
14460
  }, [s]);
14444
- let Ge = s && window.innerHeight - B > 150, Ke = async () => {
14445
- je(!1), Re(!0), Be(!0);
14461
+ let Ke = s && window.innerHeight - z > 150, qe = async () => {
14462
+ je(!1), Re(!0), Ve(!0);
14446
14463
  try {
14447
14464
  let e = await Ce();
14448
- e?.data && z(e.data);
14465
+ e?.data && ze(e.data);
14449
14466
  } catch (e) {
14450
14467
  console.error(e);
14451
14468
  } finally {
14452
- Be(!1);
14469
+ Ve(!1);
14453
14470
  }
14454
- }, qe = async (e) => {
14471
+ }, Je = async (e) => {
14455
14472
  Re(!1), we?.(e.chatId);
14456
14473
  };
14457
14474
  return c(() => {
14458
14475
  if (!Ae) return;
14459
14476
  let e = (e) => {
14460
14477
  let t = e.composedPath?.()?.[0] || e.target;
14461
- Ve.current && !Ve.current.contains(t) && je(!1);
14478
+ He.current && !He.current.contains(t) && je(!1);
14462
14479
  };
14463
14480
  return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
14464
14481
  }, [Ae]), /* @__PURE__ */ _("div", {
@@ -14468,8 +14485,8 @@ function M_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
14468
14485
  position: "fixed",
14469
14486
  left: "0",
14470
14487
  right: "0",
14471
- bottom: `${Ue}px`,
14472
- height: B > 0 ? `${Math.round(B * (Ge ? 1 : .92))}px` : "90dvh",
14488
+ bottom: `${We}px`,
14489
+ height: z > 0 ? `${Math.round(z * (Ke ? 1 : .92))}px` : "90dvh",
14473
14490
  background: r,
14474
14491
  borderRadius: "16px 16px 0 0",
14475
14492
  display: "flex",
@@ -14498,7 +14515,7 @@ function M_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
14498
14515
  alignItems: "center",
14499
14516
  columnGap: "14px",
14500
14517
  padding: "16px 10px 14px",
14501
- background: be || "transparent",
14518
+ background: xe || "transparent",
14502
14519
  flexShrink: 0,
14503
14520
  position: "relative",
14504
14521
  zIndex: 30
@@ -14613,7 +14630,7 @@ function M_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
14613
14630
  isolation: "isolate",
14614
14631
  zIndex: 10
14615
14632
  },
14616
- ref: Ve,
14633
+ ref: He,
14617
14634
  children: [/* @__PURE__ */ g("button", {
14618
14635
  type: "button",
14619
14636
  onClick: () => je((e) => !e),
@@ -14678,7 +14695,7 @@ function M_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
14678
14695
  animation: "fe-orb-fade-in 0.18s ease"
14679
14696
  },
14680
14697
  children: [
14681
- I && /* @__PURE__ */ _(h, { children: [/* @__PURE__ */ _("button", {
14698
+ be && /* @__PURE__ */ _(h, { children: [/* @__PURE__ */ _("button", {
14682
14699
  type: "button",
14683
14700
  onClick: () => {
14684
14701
  je(!1), ye?.();
@@ -14723,7 +14740,7 @@ function M_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
14723
14740
  /* @__PURE__ */ _("button", {
14724
14741
  type: "button",
14725
14742
  onClick: () => {
14726
- je(!1), L?.();
14743
+ je(!1), I?.();
14727
14744
  },
14728
14745
  style: {
14729
14746
  display: "flex",
@@ -14764,7 +14781,7 @@ function M_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
14764
14781
  margin: "0 14px"
14765
14782
  } }), /* @__PURE__ */ _("button", {
14766
14783
  type: "button",
14767
- onClick: Ke,
14784
+ onClick: qe,
14768
14785
  style: {
14769
14786
  display: "flex",
14770
14787
  alignItems: "center",
@@ -14811,7 +14828,7 @@ function M_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
14811
14828
  display: "flex",
14812
14829
  alignItems: "center",
14813
14830
  justifyContent: "space-between",
14814
- gap: "12px",
14831
+ gap: "8px",
14815
14832
  width: "100%",
14816
14833
  padding: "14px 18px",
14817
14834
  background: "none",
@@ -14833,7 +14850,9 @@ function M_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
14833
14850
  style: {
14834
14851
  display: "flex",
14835
14852
  alignItems: "center",
14836
- gap: "12px"
14853
+ gap: "12px",
14854
+ minWidth: 0,
14855
+ overflow: "hidden"
14837
14856
  },
14838
14857
  children: [/* @__PURE__ */ g("svg", {
14839
14858
  width: "16",
@@ -14844,8 +14863,16 @@ function M_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
14844
14863
  strokeWidth: "2",
14845
14864
  strokeLinecap: "round",
14846
14865
  strokeLinejoin: "round",
14866
+ style: { flexShrink: 0 },
14847
14867
  children: /* @__PURE__ */ g("polygon", { points: "3 11 22 2 13 21 11 13 3 11" })
14848
- }), "Navigate automatically"]
14868
+ }), /* @__PURE__ */ g("span", {
14869
+ style: {
14870
+ overflow: "hidden",
14871
+ textOverflow: "ellipsis",
14872
+ whiteSpace: "nowrap"
14873
+ },
14874
+ children: "Auto-navigate"
14875
+ })]
14849
14876
  }), /* @__PURE__ */ g("span", {
14850
14877
  "aria-hidden": !0,
14851
14878
  style: {
@@ -15017,7 +15044,7 @@ function M_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
15017
15044
  overflowY: "auto",
15018
15045
  position: "relative"
15019
15046
  },
15020
- children: ze ? /* @__PURE__ */ g("div", {
15047
+ children: Be ? /* @__PURE__ */ g("div", {
15021
15048
  style: {
15022
15049
  padding: "40px 20px",
15023
15050
  textAlign: "center",
@@ -15026,7 +15053,7 @@ function M_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
15026
15053
  },
15027
15054
  children: "Loading past conversations..."
15028
15055
  }) : R.length > 0 ? /* @__PURE__ */ g("div", { children: R.map((e) => /* @__PURE__ */ _("div", {
15029
- onClick: () => qe(e),
15056
+ onClick: () => Je(e),
15030
15057
  style: {
15031
15058
  padding: "16px 20px",
15032
15059
  borderBottom: "1px solid #f3f4f6",
@@ -15082,7 +15109,7 @@ function M_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
15082
15109
  isAiTyping: u,
15083
15110
  isLoading: T,
15084
15111
  isAgentTyping: d,
15085
- setReplyContext: ae,
15112
+ setReplyContext: N,
15086
15113
  TypingDots: j_,
15087
15114
  primaryColor: n,
15088
15115
  agentHeadshot: y,
@@ -15229,8 +15256,8 @@ function M_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
15229
15256
  showVoiceToggle: f === "agent",
15230
15257
  activeScreen: f,
15231
15258
  inputDisabled: Oe,
15232
- replyContext: N,
15233
- clearReplyContext: () => ae(null),
15259
+ replyContext: ae,
15260
+ clearReplyContext: () => N(null),
15234
15261
  onFileSelect: k,
15235
15262
  selectedFile: O,
15236
15263
  onRemoveSelectedFile: A,
@@ -15243,7 +15270,7 @@ function M_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
15243
15270
  inputPlaceholder: e.inputPlaceholder
15244
15271
  })
15245
15272
  }),
15246
- !Ge && /* @__PURE__ */ _("div", {
15273
+ !Ke && /* @__PURE__ */ _("div", {
15247
15274
  style: {
15248
15275
  flexShrink: 0,
15249
15276
  textAlign: "center",
@@ -15274,7 +15301,7 @@ function M_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
15274
15301
  children: "See our privacy policy"
15275
15302
  })
15276
15303
  ]
15277
- }), xe && /* @__PURE__ */ _("span", {
15304
+ }), L && /* @__PURE__ */ _("span", {
15278
15305
  style: {
15279
15306
  fontSize: "11px",
15280
15307
  color: "#9ca3af",
@@ -15294,49 +15321,49 @@ function M_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
15294
15321
  });
15295
15322
  }
15296
15323
  function N_() {
15297
- let { status: e, runtimeConfig: t, resolvedConfig: n, chatHistory: r, isOpen: i, activeScreen: a, isHumanHandled: s, agentName: l, agentHeadshot: u, visitorEmail: h, isAgentTyping: v, isAiTyping: y, isLoading: b, isRateLimited: x, rateLimitMessage: S, isConversationEnded: C, incomingCall: w, activeCallId: T, callConnectionState: E, callConnectedAt: D, isCallMuted: O, webRTCError: k, language: A, chatId: ee, historyRef: te, onMessageSync: ne, sendMessage: j, uploadChatFile: M, openWidget: re, captureVisitorEmail: ie, setVoiceMode: N, endConversation: ae, startNewChat: F, acceptCall: se, rejectCall: ce, endWebRTCCall: le, toggleCallMute: ue, dismissCallError: de, startTyping: fe, stopTyping: pe, updateTypingDraft: me, getVisitorChatHistory: he, resumeChat: ge, isSessionRestoring: _e, openToChatCounter: ve, voiceEndCounter: ye } = kn();
15324
+ let { status: e, runtimeConfig: t, resolvedConfig: n, chatHistory: r, isOpen: i, activeScreen: a, isHumanHandled: s, agentName: l, agentHeadshot: u, visitorEmail: h, isAgentTyping: v, isAiTyping: y, isLoading: b, isRateLimited: x, rateLimitMessage: S, isConversationEnded: C, incomingCall: w, activeCallId: T, callConnectionState: E, callConnectedAt: D, isCallMuted: O, webRTCError: k, language: A, chatId: ee, historyRef: te, onMessageSync: ne, beaconSyncVoiceTranscript: j, sendMessage: M, uploadChatFile: re, openWidget: ie, captureVisitorEmail: ae, setVoiceMode: N, endConversation: F, startNewChat: se, acceptCall: ce, rejectCall: le, endWebRTCCall: ue, toggleCallMute: de, dismissCallError: fe, startTyping: pe, stopTyping: me, updateTypingDraft: he, getVisitorChatHistory: ge, resumeChat: _e, isSessionRestoring: ve, openToChatCounter: ye, voiceEndCounter: be } = kn();
15298
15325
  c(() => {
15299
15326
  try {
15300
15327
  fr();
15301
15328
  } catch {}
15302
15329
  }, []), c(() => {
15303
- ve && U !== "voice_mode" && U !== "text_chat" && U !== "call_screen" && (N?.(!1), et("text_chat"));
15304
- }, [ve]);
15305
- let I = t?.widgetSettings || {}, be = n?.widgetSettings || {}, L = {
15306
- ...I.branding || {},
15307
- ...be.branding || {}
15308
- }, xe = {
15309
- ...I.theme || {},
15310
- ...be.theme || {}
15330
+ ye && U !== "voice_mode" && U !== "text_chat" && U !== "call_screen" && (N?.(!1), W("text_chat"));
15331
+ }, [ye]);
15332
+ let xe = t?.widgetSettings || {}, I = n?.widgetSettings || {}, L = {
15333
+ ...xe.branding || {},
15334
+ ...I.branding || {}
15311
15335
  }, Se = {
15312
- ...I.features || {},
15313
- ...be.features || {}
15314
- }, Ce = Se.voice !== !1, we = Array.isArray(xe.orbColors) && xe.orbColors.length > 0 ? xe.orbColors : null, Te = xe.buttonColor || xe.primaryColor || we?.[0] || "#3B82F6", Ee = {
15336
+ ...xe.theme || {},
15337
+ ...I.theme || {}
15338
+ }, Ce = {
15339
+ ...xe.features || {},
15340
+ ...I.features || {}
15341
+ }, we = Ce.voice !== !1, Te = Array.isArray(Se.orbColors) && Se.orbColors.length > 0 ? Se.orbColors : null, Ee = Se.buttonColor || Se.primaryColor || Te?.[0] || "#3B82F6", ke = {
15315
15342
  small: 50,
15316
15343
  medium: 64,
15317
15344
  large: 80
15318
- }, ke = Ee[xe.orbSize] || Ee.small, Ae = xe.position || "bottom-right", Me = L.fallbackAgentName || "Agent", Ne = b_(we ?? xe.chatBgColors), Fe = L.logo || L.logoUrl || null, Ie = A || "en", Le = I.recommendations?.[Ie] || [], Re = (be.recommendations?.[Ie] ?? Le).filter((e) => String(e?.label ?? "").trim()).map((e, t) => ({
15345
+ }, Ae = ke[Se.orbSize] || ke.small, Me = Se.position || "bottom-right", Ne = L.fallbackAgentName || "Agent", Fe = b_(Te ?? Se.chatBgColors), Ie = L.logo || L.logoUrl || null, Le = A || "en", Re = xe.recommendations?.[Le] || [], R = (I.recommendations?.[Le] ?? Re).filter((e) => String(e?.label ?? "").trim()).map((e, t) => ({
15319
15346
  id: e.key || `qr-${t}`,
15320
15347
  label: e.label,
15321
15348
  message: e.label,
15322
15349
  text: e.label
15323
- })), R = Array.isArray(L.quickChatOptions) && L.quickChatOptions.length > 0 ? L.quickChatOptions : Re, z = L.hideWatermark === !0 ? !1 : L.showPoweredBy !== !1, ze = L.headerBgColor || null, Be = xe.bottomPosition == null ? "1.5rem" : `${xe.bottomPosition}px`, Ve = L.privacyPolicyUrl || null, B = L.chatbotEnabled !== !1 && xe.chatbotEnabled !== !1, [He, Ue] = m(() => typeof window < "u" ? window.location.pathname : "/");
15350
+ })), ze = Array.isArray(L.quickChatOptions) && L.quickChatOptions.length > 0 ? L.quickChatOptions : R, Be = L.hideWatermark === !0 ? !1 : L.showPoweredBy !== !1, Ve = L.headerBgColor || null, He = Se.bottomPosition == null ? "1.5rem" : `${Se.bottomPosition}px`, z = L.privacyPolicyUrl || null, Ue = L.chatbotEnabled !== !1 && Se.chatbotEnabled !== !1, [We, Ge] = m(() => typeof window < "u" ? window.location.pathname : "/");
15324
15351
  c(() => {
15325
15352
  if (typeof window > "u") return;
15326
- let e = () => Ue(window.location.pathname), t = window.history.pushState.bind(window.history);
15353
+ let e = () => Ge(window.location.pathname), t = window.history.pushState.bind(window.history);
15327
15354
  return window.history.pushState = (...n) => {
15328
15355
  t(...n), setTimeout(e, 50);
15329
15356
  }, window.addEventListener("popstate", e), () => {
15330
15357
  window.history.pushState = t, window.removeEventListener("popstate", e);
15331
15358
  };
15332
15359
  }, []);
15333
- let We = (() => {
15360
+ let Ke = (() => {
15334
15361
  let e = {
15335
- ...I.pageVisibility || {},
15336
- ...be.pageVisibility || {}
15362
+ ...xe.pageVisibility || {},
15363
+ ...I.pageVisibility || {}
15337
15364
  };
15338
15365
  return Array.isArray(e.allowedPaths) ? e.allowedPaths.filter(Boolean) : [];
15339
- })(), Ge = We.length === 0 || We.some((e) => e === "*" || e === "/*" ? !0 : e.endsWith("/*") ? He.startsWith(e.slice(0, -1)) : He.replace(/\/$/, "") === e.replace(/\/$/, "")), Ke = I.greetings?.[A] || be.greetings?.[A] || L.introGreeting || "Hello, I'm here to help you know more about OpenSense Labs.", qe = {
15366
+ })(), qe = Ke.length === 0 || Ke.some((e) => e === "*" || e === "/*" ? !0 : e.endsWith("/*") ? We.startsWith(e.slice(0, -1)) : We.replace(/\/$/, "") === e.replace(/\/$/, "")), Je = xe.greetings?.[A] || I.greetings?.[A] || L.introGreeting || "Hello, I'm here to help you know more about OpenSense Labs.", Ye = {
15340
15367
  entryPrompt: L.entryPrompt || "Do you want to explore in a new way?",
15341
15368
  yesLabel: L.yesLabel || "Yes",
15342
15369
  laterLabel: L.laterLabel || "Later",
@@ -15346,53 +15373,53 @@ function N_() {
15346
15373
  textLabel: L.textLabel || "Text",
15347
15374
  chatTitle: L.headerName || "Chat with FlowEngage",
15348
15375
  hasCustomTitle: !!(L.headerName && String(L.headerName).trim()),
15349
- introGreeting: Ke,
15376
+ introGreeting: Je,
15350
15377
  inputPlaceholder: L.inputPlaceholder || "Type your message",
15351
15378
  analysingLabel: L.analysingLabel || "analysing..."
15352
- }, Je = be.elevenLabsAgentId || t?.elevenLabsAgentId || null, Ye = t?.siteId || n?.siteId || null, Xe = t?.apiBaseUrl || "";
15379
+ }, Xe = I.elevenLabsAgentId || t?.elevenLabsAgentId || null, B = t?.siteId || n?.siteId || null, Ze = t?.apiBaseUrl || "";
15353
15380
  c(() => {
15354
15381
  Qn(t?.siteType || null);
15355
15382
  }, [t?.siteType]);
15356
- let Ze = f(() => l && String(l).trim() || t?.ownerName && String(t.ownerName).trim() || t?.websiteName && String(t.websiteName).trim() || "Agent", [
15383
+ let Qe = f(() => l && String(l).trim() || t?.ownerName && String(t.ownerName).trim() || t?.websiteName && String(t.websiteName).trim() || "Agent", [
15357
15384
  l,
15358
15385
  t?.ownerName,
15359
15386
  t?.websiteName
15360
- ]), Qe = u && String(u).trim() || t?.ownerProfileImageUrl && String(t.ownerProfileImageUrl).trim() || null, V = r.some((e) => e.sender === "user"), H = f(() => {
15387
+ ]), V = u && String(u).trim() || t?.ownerProfileImageUrl && String(t.ownerProfileImageUrl).trim() || null, H = r.some((e) => e.sender === "user"), $e = f(() => {
15361
15388
  let e = r.findIndex((e) => e.sender === "user");
15362
15389
  return e === -1 ? !1 : r.slice(e + 1).some((e) => e.sender === "bot" || e.sender === "ai" || e.sender === "agent");
15363
- }, [r]), $e = !!(be._dashboardLivePreview || I._dashboardLivePreview), [U, et] = m(() => $e ? "text_chat" : "entry_prompt"), [tt, nt] = m(""), [rt, it] = m(null), [at, ot] = m(h || ""), [st, ct] = m(""), [lt, W] = m(!1), [ut, dt] = m(0), [ft, pt] = m(null), [mt, ht] = m(null), [gt, _t] = m(""), [vt, yt] = m(!1), [bt, xt] = m(!1), [St, Ct] = m(!1), wt = p(null), Tt = p(!1), Et = !h && V && H && U !== "voice_mode";
15390
+ }, [r]), et = !!(I._dashboardLivePreview || xe._dashboardLivePreview), [U, W] = m(() => et ? "text_chat" : "entry_prompt"), [tt, nt] = m(""), [rt, it] = m(null), [at, ot] = m(h || ""), [st, ct] = m(""), [G, lt] = m(!1), [ut, dt] = m(0), [ft, pt] = m(null), [mt, ht] = m(null), [gt, _t] = m(""), [vt, yt] = m(!1), [bt, xt] = m(!1), [St, Ct] = m(!1), wt = p(null), Tt = p(!1), Et = !h && H && $e && U !== "voice_mode";
15364
15391
  d(() => {
15365
15392
  if (e !== "ready" || Tt.current) return;
15366
- if (Tt.current = !0, !Ce) {
15367
- et("minimized_orb");
15393
+ if (Tt.current = !0, !we) {
15394
+ W("minimized_orb");
15368
15395
  return;
15369
15396
  }
15370
15397
  let t = !1;
15371
15398
  try {
15372
15399
  t = wr().shouldResumeVoice;
15373
15400
  } catch {}
15374
- let n = je(), r = Ye ? De(Ye) : null, i = n || !!r?.transcript;
15401
+ let n = je(), r = B ? De(B) : null, i = n || !!r?.transcript;
15375
15402
  if (t) {
15376
- re?.({ notifyChatInitiated: !0 }), N?.(!0), et("voice_mode");
15403
+ ie?.({ notifyChatInitiated: !0 }), N?.(!0), W("voice_mode");
15377
15404
  return;
15378
15405
  }
15379
15406
  if (Pe()) {
15380
- re?.({ notifyChatInitiated: !1 }), et("text_chat");
15407
+ ie?.({ notifyChatInitiated: !1 }), W("text_chat");
15381
15408
  return;
15382
15409
  }
15383
15410
  if (i) {
15384
15411
  if ((typeof performance < "u" ? performance.getEntriesByType?.("navigation")?.[0]?.type ?? "navigate" : "navigate") === "reload") {
15385
- et("minimized_orb");
15412
+ W("minimized_orb");
15386
15413
  return;
15387
15414
  }
15388
- re?.({ notifyChatInitiated: !0 }), N?.(!0), et("voice_mode");
15415
+ ie?.({ notifyChatInitiated: !0 }), N?.(!0), W("voice_mode");
15389
15416
  return;
15390
15417
  }
15391
- if (Ye) try {
15392
- Oe(Ye);
15418
+ if (B) try {
15419
+ Oe(B);
15393
15420
  } catch {}
15394
- if (P(Ye)) {
15395
- et("minimized_orb");
15421
+ if (P(B)) {
15422
+ W("minimized_orb");
15396
15423
  return;
15397
15424
  }
15398
15425
  }, [e, r]);
@@ -15426,10 +15453,10 @@ function N_() {
15426
15453
  let t = window.setInterval(e, 1e3);
15427
15454
  return () => window.clearInterval(t);
15428
15455
  }, [D, E]);
15429
- let G = o(() => {
15430
- et("call_screen"), xt(!1);
15431
- }, []), jt = o(() => {
15432
- et("text_chat"), xt(!0);
15456
+ let jt = o(() => {
15457
+ W("call_screen"), xt(!1);
15458
+ }, []), Mt = o(() => {
15459
+ W("text_chat"), xt(!0);
15433
15460
  }, []);
15434
15461
  c(() => {
15435
15462
  let e = w?.callId || T || null;
@@ -15449,19 +15476,19 @@ function N_() {
15449
15476
  hasIncomingCall: !!w?.callId,
15450
15477
  activeCallId: T,
15451
15478
  callConnectionState: E
15452
- }), wt.current = e, U === "voice_mode" && N?.(!1), re?.(), G());
15479
+ }), wt.current = e, U === "voice_mode" && N?.(!1), ie?.(), jt());
15453
15480
  }
15454
15481
  }, [
15455
15482
  T,
15456
15483
  E,
15457
- G,
15484
+ jt,
15458
15485
  w?.callId,
15459
15486
  i,
15460
- re,
15487
+ ie,
15461
15488
  N,
15462
15489
  U
15463
15490
  ]), c(() => {
15464
- !w && !T && U === "call_screen" && et("text_chat");
15491
+ !w && !T && U === "call_screen" && W("text_chat");
15465
15492
  }, [
15466
15493
  w,
15467
15494
  T,
@@ -15470,16 +15497,16 @@ function N_() {
15470
15497
  !T && bt && xt(!1);
15471
15498
  }, [T, bt]), c(() => {
15472
15499
  if (!s || C) {
15473
- me?.(""), pe?.();
15500
+ he?.(""), me?.();
15474
15501
  return;
15475
15502
  }
15476
15503
  if (!tt.trim() || mt) {
15477
- me?.("");
15478
- let e = window.setTimeout(() => pe?.(), 100);
15504
+ he?.("");
15505
+ let e = window.setTimeout(() => me?.(), 100);
15479
15506
  return () => window.clearTimeout(e);
15480
15507
  }
15481
- fe?.();
15482
- let e = window.setTimeout(() => me?.(tt), 120), t = window.setTimeout(() => pe?.(), 1200);
15508
+ pe?.();
15509
+ let e = window.setTimeout(() => he?.(tt), 120), t = window.setTimeout(() => me?.(), 1200);
15483
15510
  return () => {
15484
15511
  window.clearTimeout(e), window.clearTimeout(t);
15485
15512
  };
@@ -15488,15 +15515,15 @@ function N_() {
15488
15515
  mt,
15489
15516
  s,
15490
15517
  C,
15491
- fe,
15492
15518
  pe,
15493
- me
15519
+ me,
15520
+ he
15494
15521
  ]);
15495
- let Mt = (e) => e ? {
15522
+ let Nt = (e) => e ? {
15496
15523
  replyTo: e.messageId || e.id || null,
15497
15524
  replyToContent: (e.replyToContent || e.message || "").replace(/<[^>]+>/g, "").trim().slice(0, 200),
15498
15525
  replyToSender: e.sender || null
15499
- } : null, Nt = async (e) => {
15526
+ } : null, Pt = async (e) => {
15500
15527
  if (e.preventDefault(), C) return;
15501
15528
  if (Et) {
15502
15529
  let e = at.trim().toLowerCase();
@@ -15504,16 +15531,16 @@ function N_() {
15504
15531
  ct("Please enter a valid email so we can continue helping you.");
15505
15532
  return;
15506
15533
  }
15507
- await ie(e), ct(""), W(!0), setTimeout(() => W(!1), 3e3);
15534
+ await ae(e), ct(""), lt(!0), setTimeout(() => lt(!1), 3e3);
15508
15535
  return;
15509
15536
  }
15510
- let t = Mt(rt);
15537
+ let t = Nt(rt);
15511
15538
  if (!tt.trim() && !mt) return;
15512
15539
  if (mt) {
15513
15540
  try {
15514
15541
  yt(!0), _t("");
15515
- let e = await M(mt), n = e?.data || e, r = tt.trim() || `Shared file: ${ng(mt)}`;
15516
- nt(""), it(null), kt(), await j(r, "", t, {
15542
+ let e = await re(mt), n = e?.data || e, r = tt.trim() || `Shared file: ${ng(mt)}`;
15543
+ nt(""), it(null), kt(), await M(r, "", t, {
15517
15544
  type: "file",
15518
15545
  metadata: {
15519
15546
  fileUrl: n?.fileUrl,
@@ -15530,21 +15557,21 @@ function N_() {
15530
15557
  return;
15531
15558
  }
15532
15559
  let n = tt.trim();
15533
- nt(""), it(null), await j(n, "", t);
15534
- }, Pt = o(() => {
15535
- r.length !== 0 && F?.();
15536
- }, [r.length, F]), Ft = (e) => {
15560
+ nt(""), it(null), await M(n, "", t);
15561
+ }, Ft = o(() => {
15562
+ r.length !== 0 && se?.();
15563
+ }, [r.length, se]), It = (e) => {
15537
15564
  let t = Math.floor(e / 60);
15538
15565
  return `${String(t).padStart(2, "0")}:${String(e % 60).padStart(2, "0")}`;
15539
- }, It = o(async (e) => {
15566
+ }, Lt = o(async (e) => {
15540
15567
  if (C || b) return;
15541
15568
  let t = e.message || e.label || e.text || "";
15542
- t.trim() && await j(t.trim(), "");
15569
+ t.trim() && await M(t.trim(), "");
15543
15570
  }, [
15544
15571
  C,
15545
15572
  b,
15546
- j
15547
- ]), Lt = Dt && U === "entry_prompt" ? { inset: 0 } : Dt && U === "text_chat" ? {
15573
+ M
15574
+ ]), Rt = Dt && U === "entry_prompt" ? { inset: 0 } : Dt && U === "text_chat" ? {
15548
15575
  left: 0,
15549
15576
  right: 0,
15550
15577
  bottom: 0
@@ -15564,24 +15591,24 @@ function N_() {
15564
15591
  height: "min(640px, calc(100vh - 120px))",
15565
15592
  borderRadius: "22px",
15566
15593
  overflow: "hidden",
15567
- ...Ae === "bottom-left" ? {
15594
+ ...Me === "bottom-left" ? {
15568
15595
  left: "1.5rem",
15569
- bottom: Be
15596
+ bottom: He
15570
15597
  } : {
15571
15598
  right: "1.5rem",
15572
- bottom: Be
15599
+ bottom: He
15573
15600
  }
15574
- } : Ae === "bottom-left" ? {
15601
+ } : Me === "bottom-left" ? {
15575
15602
  left: "1.5rem",
15576
- bottom: Be
15603
+ bottom: He
15577
15604
  } : {
15578
15605
  right: "1.5rem",
15579
- bottom: Be
15580
- }, Rt = o(() => {
15606
+ bottom: He
15607
+ }, zt = o(() => {
15581
15608
  U !== "minimized_orb" && (Ct(!0), setTimeout(() => {
15582
- et("minimized_orb"), Ct(!1), T && xt(!0);
15609
+ W("minimized_orb"), Ct(!1), T && xt(!0);
15583
15610
  }, 280));
15584
- }, [T, U]), zt = () => et("connection_modal"), Bt = () => {
15611
+ }, [T, U]), Bt = () => W("connection_modal"), Vt = () => {
15585
15612
  try {
15586
15613
  let e = window.AudioContext || window.webkitAudioContext;
15587
15614
  if (e) {
@@ -15589,31 +15616,31 @@ function N_() {
15589
15616
  t.resume().catch(() => {}), setTimeout(() => t.close().catch(() => {}), 3e3);
15590
15617
  }
15591
15618
  } catch {}
15592
- re({ notifyChatInitiated: !0 }), N?.(!0), et("voice_mode");
15593
- }, Vt = () => {
15594
- re({ notifyChatInitiated: !0 }), N?.(!1), et("text_chat");
15619
+ ie({ notifyChatInitiated: !0 }), N?.(!0), W("voice_mode");
15595
15620
  }, Ht = () => {
15596
- N?.(!1), Rt();
15621
+ ie({ notifyChatInitiated: !0 }), N?.(!1), W("text_chat");
15622
+ }, Ut = () => {
15623
+ N?.(!1), zt();
15597
15624
  };
15598
- return e !== "ready" || !B || Se.chat === !1 || !Ge ? null : /* @__PURE__ */ _("div", {
15625
+ return e !== "ready" || !Ue || Ce.chat === !1 || !qe ? null : /* @__PURE__ */ _("div", {
15599
15626
  className: "flowengage-widget-root",
15600
15627
  style: {
15601
15628
  position: "fixed",
15602
15629
  zIndex: 999999,
15603
- ...Lt
15630
+ ...Rt
15604
15631
  },
15605
15632
  onWheel: (e) => e.stopPropagation(),
15606
15633
  onTouchMove: (e) => e.stopPropagation(),
15607
15634
  children: [
15608
15635
  U === "entry_prompt" && /* @__PURE__ */ g(D_, {
15609
- copy: qe,
15610
- orbColors: we,
15611
- primaryColor: Te,
15636
+ copy: Ye,
15637
+ orbColors: Te,
15638
+ primaryColor: Ee,
15612
15639
  onYes: () => {
15613
- oe(Ye), Bt();
15640
+ oe(B), Vt();
15614
15641
  },
15615
15642
  onLater: () => {
15616
- oe(Ye), Rt();
15643
+ oe(B), zt();
15617
15644
  },
15618
15645
  isMobile: Dt,
15619
15646
  isClosing: St
@@ -15637,12 +15664,12 @@ function N_() {
15637
15664
  transformOrigin: "bottom right",
15638
15665
  display: "inline-flex",
15639
15666
  flexDirection: "column",
15640
- alignItems: Ae === "bottom-left" ? "flex-start" : "flex-end",
15667
+ alignItems: Me === "bottom-left" ? "flex-start" : "flex-end",
15641
15668
  gap: "10px"
15642
15669
  },
15643
15670
  children: [T && /* @__PURE__ */ _("button", {
15644
15671
  type: "button",
15645
- onClick: G,
15672
+ onClick: jt,
15646
15673
  style: {
15647
15674
  maxWidth: Dt ? "220px" : "240px",
15648
15675
  padding: "10px 14px",
@@ -15685,41 +15712,42 @@ function N_() {
15685
15712
  marginTop: "2px",
15686
15713
  whiteSpace: "nowrap"
15687
15714
  },
15688
- children: E === "connected" ? `${Ft(ut)} with ${Ze}` : `Tap to return to ${Ze}`
15715
+ children: E === "connected" ? `${It(ut)} with ${Qe}` : `Tap to return to ${Qe}`
15689
15716
  })]
15690
15717
  })]
15691
15718
  }), /* @__PURE__ */ g(E_, {
15692
- size: ke,
15693
- orbColors: we,
15694
- onClick: T ? G : Ce ? zt : Vt
15719
+ size: Ae,
15720
+ orbColors: Te,
15721
+ onClick: T ? jt : we ? Bt : Ht
15695
15722
  })]
15696
15723
  }),
15697
15724
  U === "connection_modal" && /* @__PURE__ */ g(O_, {
15698
- copy: qe,
15699
- orbColors: we,
15700
- primaryColor: Te,
15701
- onVoice: Bt,
15702
- onText: Vt,
15703
- onClose: Rt,
15725
+ copy: Ye,
15726
+ orbColors: Te,
15727
+ primaryColor: Ee,
15728
+ onVoice: Vt,
15729
+ onText: Ht,
15730
+ onClose: zt,
15704
15731
  isMobile: Dt,
15705
15732
  isClosing: St
15706
15733
  }),
15707
15734
  U === "voice_mode" && /* @__PURE__ */ g(k_, {
15708
- orbColors: we,
15709
- onEnterChat: Vt,
15710
- onEndChat: Ht,
15711
- agentId: Je,
15712
- siteId: Ye,
15713
- apiBaseUrl: Xe,
15735
+ orbColors: Te,
15736
+ onEnterChat: Ht,
15737
+ onEndChat: Ut,
15738
+ agentId: Xe,
15739
+ siteId: B,
15740
+ apiBaseUrl: Ze,
15714
15741
  chatId: ee,
15715
15742
  historyRef: te,
15716
15743
  onMessageSync: ne,
15717
- voiceEndCounter: ye,
15744
+ beaconSyncVoiceTranscript: j,
15745
+ voiceEndCounter: be,
15718
15746
  websiteName: t?.websiteName,
15719
- voiceFirstMessage: I.voiceFirstMessage || null,
15720
- captureVisitorEmail: ie,
15747
+ voiceFirstMessage: xe.voiceFirstMessage || null,
15748
+ captureVisitorEmail: ae,
15721
15749
  emailRequired: !h,
15722
- emailCaptureEnabled: Se.emailCapture !== !1 && L.disableEmailCapture !== !0,
15750
+ emailCaptureEnabled: Ce.emailCapture !== !1 && L.disableEmailCapture !== !0,
15723
15751
  listeningLabel: L.voiceListeningLabel || "Listening...",
15724
15752
  thinkingLabel: L.voiceThinkingLabel || "Thinking...",
15725
15753
  enterChatModeLabel: L.voiceEnterChatLabel || "Enter Chat Mode",
@@ -15731,39 +15759,39 @@ function N_() {
15731
15759
  callConnectionState: E,
15732
15760
  callDurationSeconds: ut,
15733
15761
  isCallMuted: O,
15734
- agentName: Ze,
15735
- agentHeadshot: Qe,
15736
- fallbackAgentName: Me,
15737
- acceptCall: se,
15738
- rejectCall: ce,
15739
- endWebRTCCall: le,
15740
- toggleCallMute: ue,
15741
- formatCallDuration: Ft,
15742
- onMinimize: jt,
15743
- primaryColor: Te,
15744
- orbColors: we,
15762
+ agentName: Qe,
15763
+ agentHeadshot: V,
15764
+ fallbackAgentName: Ne,
15765
+ acceptCall: ce,
15766
+ rejectCall: le,
15767
+ endWebRTCCall: ue,
15768
+ toggleCallMute: de,
15769
+ formatCallDuration: It,
15770
+ onMinimize: Mt,
15771
+ primaryColor: Ee,
15772
+ orbColors: Te,
15745
15773
  chatHistory: r
15746
15774
  }),
15747
15775
  U === "text_chat" && /* @__PURE__ */ g(M_, {
15748
15776
  isClosing: St,
15749
- copy: qe,
15750
- orbColors: we,
15751
- primaryColor: Te,
15752
- chatBgGradient: Ne,
15753
- logo: Fe,
15754
- quickChatOptions: R,
15755
- onQuickChatSelect: It,
15777
+ copy: Ye,
15778
+ orbColors: Te,
15779
+ primaryColor: Ee,
15780
+ chatBgGradient: Fe,
15781
+ logo: Ie,
15782
+ quickChatOptions: ze,
15783
+ onQuickChatSelect: Lt,
15756
15784
  isMobile: Dt,
15757
15785
  chatHistory: r,
15758
15786
  isAiTyping: y,
15759
15787
  isAgentTyping: v,
15760
15788
  activeScreen: a,
15761
- agentName: Ze,
15762
- agentHeadshot: Qe,
15763
- fallbackAgentName: Me,
15789
+ agentName: Qe,
15790
+ agentHeadshot: V,
15791
+ fallbackAgentName: Ne,
15764
15792
  input: tt,
15765
15793
  setInput: nt,
15766
- onSubmit: Nt,
15794
+ onSubmit: Pt,
15767
15795
  isConversationEnded: C,
15768
15796
  isLoading: b,
15769
15797
  isRateLimited: x,
@@ -15777,32 +15805,32 @@ function N_() {
15777
15805
  emailInput: at,
15778
15806
  setEmailInput: ot,
15779
15807
  emailError: st,
15780
- emailCaptureSuccess: lt,
15808
+ emailCaptureSuccess: G,
15781
15809
  replyContext: rt,
15782
15810
  setReplyContext: it,
15783
15811
  webRTCError: k,
15784
15812
  micError: ft,
15785
15813
  setMicError: pt,
15786
- dismissCallError: de,
15814
+ dismissCallError: fe,
15787
15815
  activeCallId: T,
15788
15816
  isCallMuted: O,
15789
- toggleCallMute: ue,
15790
- endWebRTCCall: le,
15791
- formatCallDuration: Ft,
15817
+ toggleCallMute: de,
15818
+ endWebRTCCall: ue,
15819
+ formatCallDuration: It,
15792
15820
  callDurationSeconds: ut,
15793
- onCollapse: Rt,
15794
- onStartVoice: Bt,
15795
- voiceEnabled: Ce,
15796
- onNewChat: Pt,
15797
- onMinimize: jt,
15798
- onExpand: G,
15821
+ onCollapse: zt,
15822
+ onStartVoice: Vt,
15823
+ voiceEnabled: we,
15824
+ onNewChat: Ft,
15825
+ onMinimize: Mt,
15826
+ onExpand: jt,
15799
15827
  isCallMinimized: !!T,
15800
- showPoweredBy: z,
15801
- privacyPolicyUrl: Ve,
15802
- headerBgColor: ze,
15803
- getVisitorChatHistory: he,
15804
- resumeChat: ge,
15805
- isSessionRestoring: _e
15828
+ showPoweredBy: Be,
15829
+ privacyPolicyUrl: z,
15830
+ headerBgColor: Ve,
15831
+ getVisitorChatHistory: ge,
15832
+ resumeChat: _e,
15833
+ isSessionRestoring: ve
15806
15834
  }),
15807
15835
  /* @__PURE__ */ g("style", { children: "\n /* Force any SVG (or img) inside LogoSlot to fill the container height\n regardless of whether the component forwards its style prop. */\n .fe-logo-slot svg,\n .fe-logo-slot img { height: 100%; width: auto; display: block; }\n\n @keyframes fe-orb-breathe { 0%,100%{transform:scale(1)} 50%{transform:scale(1.04)} }\n @keyframes fe-orb-breathe-subtle { 0%,100%{transform:scale(1)} 50%{transform:scale(1.025)} }\n @keyframes fe-orb-pulse { 0%{transform:scale(1);opacity:.65} 50%{transform:scale(1.28);opacity:.1} 100%{transform:scale(1);opacity:.65} }\n @keyframes fe-orb-glow { from{opacity:.35} to{opacity:.75} }\n @keyframes fe-orb-fade-in { from{opacity:0} to{opacity:1} }\n @keyframes fe-orb-slide-up { from{opacity:0;transform:translateY(18px)} to{opacity:1;transform:translateY(0)} }\n @keyframes fe-orb-slide-down { from{opacity:1;transform:translateY(0)} to{opacity:0;transform:translateY(24px)} }\n @keyframes fe-orb-bar-0 { from{height:6px} to{height:18px} }\n @keyframes fe-orb-bar-1 { from{height:10px} to{height:22px} }\n @keyframes fe-orb-bar-2 { from{height:14px} to{height:26px} }\n @keyframes fe-orb-bar-3 { from{height:8px} to{height:20px} }\n @keyframes fe-orb-bar-4 { from{height:6px} to{height:16px} }\n @keyframes fe-dot-bounce { 0%,80%,100%{transform:translateY(0);opacity:.5} 40%{transform:translateY(-5px);opacity:1} }\n " })
15808
15836
  ]