@flowengage/react-chatbot 6.0.13 → 6.0.15

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.
@@ -506,7 +506,7 @@ var k = (e) => {
506
506
  let l = new ArrayBuffer(t), u = new Uint8Array(l);
507
507
  for (r = 0; r < n; r += 4) a = at[e.charCodeAt(r)], o = at[e.charCodeAt(r + 1)], s = at[e.charCodeAt(r + 2)], c = at[e.charCodeAt(r + 3)], u[i++] = a << 2 | o >> 4, u[i++] = (o & 15) << 4 | s >> 2, u[i++] = (s & 3) << 6 | c & 63;
508
508
  return l;
509
- }, A = typeof ArrayBuffer == "function", ot = (e, t) => {
509
+ }, ot = typeof ArrayBuffer == "function", A = (e, t) => {
510
510
  if (typeof e != "string") return {
511
511
  type: "message",
512
512
  data: ct(e, t)
@@ -519,7 +519,7 @@ var k = (e) => {
519
519
  type: Je[n],
520
520
  data: e.substring(1)
521
521
  } : { type: Je[n] } : Ye;
522
- }, st = (e, t) => A ? ct(k(e), t) : {
522
+ }, st = (e, t) => ot ? ct(k(e), t) : {
523
523
  base64: !0,
524
524
  data: e
525
525
  }, ct = (e, t) => {
@@ -537,7 +537,7 @@ var k = (e) => {
537
537
  }, dt = (e, t) => {
538
538
  let n = e.split(lt), r = [];
539
539
  for (let e = 0; e < n.length; e++) {
540
- let i = ot(n[e], t);
540
+ let i = A(n[e], t);
541
541
  if (r.push(i), i.type === "error") break;
542
542
  }
543
543
  return r;
@@ -594,7 +594,7 @@ function gt(e, t) {
594
594
  } else {
595
595
  if (mt(n) < i) break;
596
596
  let e = ht(n, i);
597
- s.enqueue(ot(a ? e : pt.decode(e), t)), r = 0;
597
+ s.enqueue(A(a ? e : pt.decode(e), t)), r = 0;
598
598
  }
599
599
  if (i === 0 || i > e) {
600
600
  s.enqueue(Ye);
@@ -707,7 +707,7 @@ var jt = class extends Error {
707
707
  this.readyState = "open", this.writable = !0, super.emitReserved("open");
708
708
  }
709
709
  onData(e) {
710
- let t = ot(e, this.socket.binaryType);
710
+ let t = A(e, this.socket.binaryType);
711
711
  this.onPacket(t);
712
712
  }
713
713
  onPacket(e) {
@@ -2836,7 +2836,7 @@ function Rr({ siteId: e, config: t, children: n, language: r = "en" }) {
2836
2836
  let i = f(() => e ? {
2837
2837
  ...t || {},
2838
2838
  siteId: e
2839
- } : t || null, [e, t]), [a, s] = m(0), [l, u] = m("booting"), [d, h] = m(null), [_, v] = m(null), [y, b] = m(""), [x, S] = m([]), [C, w] = m(ve().isOpen), [T, te] = m(ve().activeScreen), [ne, re] = m(ve().isHumanHandled), [E, D] = m(ve().agentName), [se, de] = m(ve().agentHeadshot), [fe, pe] = m(() => be(i?.siteId)), [me, Se] = m(!1), [Ce, we] = m(!1), [Ee, De] = m("idle"), [Oe, ke] = m(!1), [Ae, je] = m(!1), [Me, Ne] = m(""), [Fe, Ie] = m(!1), [Le, Re] = m(0), [ze, Be] = m(0), [Ve, He] = m(!1), [O, Ue] = m(null), [qe, Je] = m(null), [Ye, Xe] = m("idle"), [Ze, Qe] = m(null), [$e, et] = m(!1), [tt, nt] = m(""), [rt, it] = m(!1), at = p(null), k = p(null), A = p(""), ot = p(!1), st = p(null), ct = p(null), lt = p(null), ut = p(null), dt = p(null), ft = p(null), pt = p([]), mt = p(null), ht = p(null), gt = p(null), j = p(!1), _t = p(!1), vt = p(""), yt = p(null), bt = p(null), xt = p([]), St = p(0), Ct = p(E), wt = p([]), Tt = p(!1), Et = p(!1), Dt = p(i), Ot = p({
2839
+ } : t || null, [e, t]), [a, s] = m(0), [l, u] = m("booting"), [d, h] = m(null), [_, v] = m(null), [y, b] = m(""), [x, S] = m([]), [C, w] = m(ve().isOpen), [T, te] = m(ve().activeScreen), [ne, re] = m(ve().isHumanHandled), [E, D] = m(ve().agentName), [se, de] = m(ve().agentHeadshot), [fe, pe] = m(() => be(i?.siteId)), [me, Se] = m(!1), [Ce, we] = m(!1), [Ee, De] = m("idle"), [Oe, ke] = m(!1), [Ae, je] = m(!1), [Me, Ne] = m(""), [Fe, Ie] = m(!1), [Le, Re] = m(0), [ze, Be] = m(0), [Ve, He] = m(!1), [O, Ue] = m(null), [qe, Je] = m(null), [Ye, Xe] = m("idle"), [Ze, Qe] = m(null), [$e, et] = m(!1), [tt, nt] = m(""), [rt, it] = m(!1), at = p(null), k = p(null), ot = p(""), A = p(!1), st = p(null), ct = p(null), lt = p(null), ut = p(null), dt = p(null), ft = p(null), pt = p([]), mt = p(null), ht = p(null), gt = p(null), j = p(!1), _t = p(!1), vt = p(""), yt = p(null), bt = p(null), xt = p([]), St = p(0), Ct = p(E), wt = p([]), Tt = p(!1), Et = p(!1), Dt = p(i), Ot = p({
2840
2840
  notifyRouteChange: () => {},
2841
2841
  cleanup: () => {}
2842
2842
  }), kt = o((e = {}) => {
@@ -2901,7 +2901,7 @@ function Rr({ siteId: e, config: t, children: n, language: r = "en" }) {
2901
2901
  if (!(!t?.connected || !n || j.current)) {
2902
2902
  j.current = !0, t.emit("call:connected", {
2903
2903
  callId: n,
2904
- chatId: A.current,
2904
+ chatId: ot.current,
2905
2905
  connectedAt: e
2906
2906
  });
2907
2907
  try {
@@ -2968,7 +2968,7 @@ function Rr({ siteId: e, config: t, children: n, language: r = "en" }) {
2968
2968
  if (!t || !n?.connected || !r || !e.callId) {
2969
2969
  console.log("[FlowEngageProvider] deferring remote offer until peer/socket ready", {
2970
2970
  callId: e.callId,
2971
- chatId: A.current,
2971
+ chatId: ot.current,
2972
2972
  hasPeerConnection: !!t,
2973
2973
  socketConnected: !!n?.connected,
2974
2974
  hasOffer: !!r
@@ -2981,7 +2981,7 @@ function Rr({ siteId: e, config: t, children: n, language: r = "en" }) {
2981
2981
  })), pt.current.length > 0) {
2982
2982
  console.log("[FlowEngageProvider] flushing queued agent ICE candidates after remote offer", {
2983
2983
  callId: e.callId,
2984
- chatId: A.current,
2984
+ chatId: ot.current,
2985
2985
  queuedCount: pt.current.length
2986
2986
  });
2987
2987
  for (let e of pt.current) await t.addIceCandidate(new RTCIceCandidate(e));
@@ -2991,7 +2991,7 @@ function Rr({ siteId: e, config: t, children: n, language: r = "en" }) {
2991
2991
  await t.setLocalDescription(i), n.emit("call:answer", {
2992
2992
  callId: e.callId,
2993
2993
  sdpAnswer: i.sdp,
2994
- chatId: A.current
2994
+ chatId: ot.current
2995
2995
  });
2996
2996
  };
2997
2997
  c(() => {
@@ -3017,8 +3017,8 @@ function Rr({ siteId: e, config: t, children: n, language: r = "en" }) {
3017
3017
  if (!e) return;
3018
3018
  let a = t.siteId, o = he(a), s = Te(a), c = "";
3019
3019
  try {
3020
- let e = ot.current, r = st.current;
3021
- if (ot.current = !1, st.current = null, c = (await We({
3020
+ let e = A.current, r = st.current;
3021
+ if (A.current = !1, st.current = null, c = (await We({
3022
3022
  apiBaseUrl: t.apiBaseUrl,
3023
3023
  userId: n.userId,
3024
3024
  siteId: a,
@@ -3031,7 +3031,7 @@ function Rr({ siteId: e, config: t, children: n, language: r = "en" }) {
3031
3031
  } catch (e) {
3032
3032
  console.warn("[FlowEngageProvider] resolve-session failed, reusing persisted or ephemeral chat id", e?.message || e), c = o || ue(), _e(a, c);
3033
3033
  }
3034
- A.current = c;
3034
+ ot.current = c;
3035
3035
  let l = Ke({
3036
3036
  apiBaseUrl: t.apiBaseUrl,
3037
3037
  userId: n.userId,
@@ -3177,7 +3177,7 @@ function Rr({ siteId: e, config: t, children: n, language: r = "en" }) {
3177
3177
  if (!lt.current || !lt.current.remoteDescription) {
3178
3178
  console.log("[FlowEngageProvider] queueing agent ICE candidate until peer/remote description is ready", {
3179
3179
  callId: e.callId,
3180
- chatId: e.chatId || A.current,
3180
+ chatId: e.chatId || ot.current,
3181
3181
  queueSize: pt.current.length + 1
3182
3182
  }), pt.current.push(t);
3183
3183
  return;
@@ -3252,7 +3252,7 @@ function Rr({ siteId: e, config: t, children: n, language: r = "en" }) {
3252
3252
  a
3253
3253
  ]), c(() => () => {
3254
3254
  if (Fe && !Tt.current && wt.current.length > 0) {
3255
- let e = A.current, t = wt.current, n = k.current;
3255
+ let e = ot.current, t = wt.current, n = k.current;
3256
3256
  n && e && t.length > 0 && (console.log("[FlowEngageProvider] safety-net: syncing voice transcript on unmount"), n.beaconSyncVoice(e, t) || n.syncVoice(e, t).catch(() => {}), Tt.current = !0);
3257
3257
  }
3258
3258
  }, [Fe, _]);
@@ -3262,7 +3262,7 @@ function Rr({ siteId: e, config: t, children: n, language: r = "en" }) {
3262
3262
  !e || !y || zt.current !== C && (C && zt.current !== null ? (e.updateChatStatus(y, "open").catch(() => {}), Bt.current = !0) : zt.current === !0 && e.updateChatStatus(y, "widget_closed").catch(() => {}), zt.current = C);
3263
3263
  }, [C, y]), c(() => {
3264
3264
  let e = () => {
3265
- let e = A.current, t = k.current;
3265
+ let e = ot.current, t = k.current;
3266
3266
  !e || !t || typeof navigator > "u" || t.beaconWidgetClosed?.(e) || t.updateChatStatus(e, "widget_closed").catch(() => {});
3267
3267
  };
3268
3268
  return window.addEventListener("pagehide", e), () => window.removeEventListener("pagehide", e);
@@ -3435,10 +3435,10 @@ function Rr({ siteId: e, config: t, children: n, language: r = "en" }) {
3435
3435
  }
3436
3436
  }, qt = async (e) => {
3437
3437
  let t = Nt(e);
3438
- if (!t || !k.current || !A.current) return t;
3438
+ if (!t || !k.current || !ot.current) return t;
3439
3439
  try {
3440
3440
  await k.current.trackVisitor({
3441
- chatId: A.current,
3441
+ chatId: ot.current,
3442
3442
  currentPagePath: typeof window < "u" && window.location.pathname || "/",
3443
3443
  email: t
3444
3444
  });
@@ -3598,7 +3598,7 @@ function Rr({ siteId: e, config: t, children: n, language: r = "en" }) {
3598
3598
  At
3599
3599
  ]), c(() => {
3600
3600
  let e = () => {
3601
- let e = A.current, t = k.current;
3601
+ let e = ot.current, t = k.current;
3602
3602
  if (!t || !e) return;
3603
3603
  if (Et.current && wt.current.length > 0 && Pe(), !Tt.current && wt.current.length > 0 && (t.beaconSyncVoice(e, wt.current) || t.syncVoice(e, wt.current).catch(() => {}), Tt.current = !0), mt.current) {
3604
3604
  t.beaconEndWebRTCCall(mt.current, e);
@@ -3613,9 +3613,9 @@ function Rr({ siteId: e, config: t, children: n, language: r = "en" }) {
3613
3613
  }, []);
3614
3614
  let nn = o(() => {
3615
3615
  let e = i?.siteId;
3616
- ge(e), ot.current = !0, st.current = null, at.current?.disconnect(), S([]), b(""), A.current = "", He(!1), re(!1), D(null), de(null), it(!0), s((e) => e + 1);
3616
+ ge(e), A.current = !0, st.current = null, at.current?.disconnect(), S([]), b(""), ot.current = "", He(!1), re(!1), D(null), de(null), it(!0), s((e) => e + 1);
3617
3617
  }, [i?.siteId]), rn = o((e) => {
3618
- i?.siteId, ot.current = !1, st.current = e, at.current?.disconnect(), S([]), b(""), A.current = "", He(!1), re(!1), D(null), de(null), it(!0), s((e) => e + 1);
3618
+ i?.siteId, A.current = !1, st.current = e, at.current?.disconnect(), S([]), b(""), ot.current = "", He(!1), re(!1), D(null), de(null), it(!0), s((e) => e + 1);
3619
3619
  }, [i?.siteId]), an = f(() => ({
3620
3620
  status: l,
3621
3621
  error: d,
@@ -29384,9 +29384,9 @@ function Ck(e) {
29384
29384
  $("flowengage_navigate → SPA nav complete. target:", e, "actual:", n);
29385
29385
  let s = [], c = Date.now() + 8e3;
29386
29386
  for (; Date.now() < c && (await new Promise((e) => setTimeout(e, 250)), s = Sk(), !(s.length >= 1)););
29387
- $("flowengage_navigate → page headings collected:", s);
29387
+ xk(), $("flowengage_navigate → page headings collected:", s);
29388
29388
  let l = s.length ? s.join(" | ") : "none", u = s.length ? "Use ONLY these exact heading strings for flowengage_highlight." : "No headings were collected from the live DOM — use your knowledge base heading strings for this page to call flowengage_highlight. Follow RULE 1: call each highlight BEFORE describing its section (transition → highlight → content).";
29389
- return i ? (wr(), `OK_NAVIGATE_SPA. Visitor is now on: ${r} (page: "${o}") | Section headings: ${l}. ${u} Do NOT say "I have navigated you" or "I've taken you to" — start immediately with highlights and content about THIS page.`) : (wr(), `OK_NAVIGATE_SPA. CURRENT PAGE IS: ${r} (page: "${o}") | Section headings: ${l}. ${u} Describe THIS page only — do not mention the page you tried to navigate to.`);
29389
+ return i ? (wr(), `OK_NAVIGATE_SPA. Visitor is now on: ${r} (page: "${o}") | Section headings: ${l}. ${u} MANDATORY: call flowengage_highlight for EVERY section before describing it — never give a plain summary. Do NOT say "I have navigated you" or "I've taken you to" — start the highlighted walkthrough immediately.`) : (wr(), `OK_NAVIGATE_SPA. CURRENT PAGE IS: ${r} (page: "${o}") | Section headings: ${l}. ${u} MANDATORY: call flowengage_highlight for EVERY section before describing it — never give a plain summary. Describe THIS page only — do not mention the page you tried to navigate to.`);
29390
29390
  } catch {}
29391
29391
  return "OK_NAVIGATE_RELOADING. Navigating to the page now; the voice session will resume automatically on the new page. When the session resumes, immediately introduce the new page and continue guiding the visitor — do not wait for the user to speak first.";
29392
29392
  } catch (e) {
@@ -29405,7 +29405,11 @@ function Ck(e) {
29405
29405
  let t = mk(e), n = t?.section_id || t?.sectionId, r = t?.section_text || t?.sectionText;
29406
29406
  xk();
29407
29407
  let i = hr(n || null, r || null);
29408
- if (!i && r && (await new Promise((e) => setTimeout(e, 500)), xk(), i = hr(null, r)), !i) {
29408
+ if (!i && r) {
29409
+ let e = Date.now() + 600;
29410
+ for (; !i && Date.now() < e;) await new Promise((e) => setTimeout(e, 50)), xk(), i = hr(null, r);
29411
+ }
29412
+ if (!i) {
29409
29413
  $("flowengage_highlight ✖ no element for:", r || n);
29410
29414
  let e = Sk(), t = e.length ? `Page headings: ${e.join(" | ")}. Use one of these exact strings for section_text.` : "No headings found — skip highlight and continue.";
29411
29415
  return `HIGHLIGHT_NOT_FOUND: "${r || n}" on the current page. ${t}`;
@@ -30100,6 +30104,7 @@ function Pk({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
30100
30104
  let v = {
30101
30105
  clientTools: t,
30102
30106
  connectionType: "websocket",
30107
+ minSpeechDurationMs: 100,
30103
30108
  ..._ ? { signedUrl: _ } : { agentId: r }
30104
30109
  }, b = (p.split("/").filter(Boolean).pop() || "").replace(/[-_]/g, " ").replace(/\b\w/g, (e) => e.toUpperCase()), x = "";
30105
30110
  m && m.includes("|") && (x = m.split("|").map((e) => e.trim()).filter(Boolean).reduce((e, t) => e.length <= t.length ? e : t));
@@ -31357,7 +31362,7 @@ function Rk() {
31357
31362
  pr();
31358
31363
  } catch {}
31359
31364
  }, []), c(() => {
31360
- Ee && k !== "text_chat" && k !== "call_screen" && (ue?.(!1), A("text_chat"));
31365
+ Ee && A !== "text_chat" && A !== "call_screen" && (ue?.(!1), st("text_chat"));
31361
31366
  }, [Ee]);
31362
31367
  let Oe = t?.widgetSettings || {}, ke = n?.widgetSettings || {}, Ae = {
31363
31368
  ...Oe.branding || {},
@@ -31368,12 +31373,16 @@ function Rk() {
31368
31373
  }, Pe = {
31369
31374
  ...Oe.features || {},
31370
31375
  ...ke.features || {}
31371
- }, Ie = Pe.voice !== !1, Le = Array.isArray(Ne.orbColors) && Ne.orbColors.length > 0 ? Ne.orbColors : null, ze = Ne.buttonColor || Ne.primaryColor || Le?.[0] || "#3B82F6", Be = Ne.position || "bottom-right", Ve = Ae.fallbackAgentName || "Agent", He = Ek(Le ?? Ne.chatBgColors), O = Ae.logo || Ae.logoUrl || null, Ue = E || "en", We = Oe.recommendations?.[Ue] || [], Ge = (ke.recommendations?.[Ue] ?? We).filter((e) => String(e?.label ?? "").trim()).map((e, t) => ({
31376
+ }, Ie = Pe.voice !== !1, Le = Array.isArray(Ne.orbColors) && Ne.orbColors.length > 0 ? Ne.orbColors : null, ze = Ne.buttonColor || Ne.primaryColor || Le?.[0] || "#3B82F6", Be = {
31377
+ small: 50,
31378
+ medium: 64,
31379
+ large: 80
31380
+ }, Ve = Be[Ne.orbSize] || Be.small, He = Ne.position || "bottom-right", O = Ae.fallbackAgentName || "Agent", Ue = Ek(Le ?? Ne.chatBgColors), We = Ae.logo || Ae.logoUrl || null, Ge = E || "en", Ke = Oe.recommendations?.[Ge] || [], qe = (ke.recommendations?.[Ge] ?? Ke).filter((e) => String(e?.label ?? "").trim()).map((e, t) => ({
31372
31381
  id: e.key || `qr-${t}`,
31373
31382
  label: e.label,
31374
31383
  message: e.label,
31375
31384
  text: e.label
31376
- })), Ke = Array.isArray(Ae.quickChatOptions) && Ae.quickChatOptions.length > 0 ? Ae.quickChatOptions : Ge, qe = Ae.hideWatermark === !0 ? !1 : Ae.showPoweredBy !== !1, Je = Ae.chatbotEnabled !== !1 && Ne.chatbotEnabled !== !1, Ye = Oe.greetings?.[E] || ke.greetings?.[E] || Ae.introGreeting || "Hello, I'm here to help you know more about OpenSense Labs.", Xe = {
31385
+ })), Je = Array.isArray(Ae.quickChatOptions) && Ae.quickChatOptions.length > 0 ? Ae.quickChatOptions : qe, Ye = Ae.hideWatermark === !0 ? !1 : Ae.showPoweredBy !== !1, Xe = Ae.chatbotEnabled !== !1 && Ne.chatbotEnabled !== !1, Ze = Oe.greetings?.[E] || ke.greetings?.[E] || Ae.introGreeting || "Hello, I'm here to help you know more about OpenSense Labs.", Qe = {
31377
31386
  entryPrompt: Ae.entryPrompt || "Do you want to explore in a new way?",
31378
31387
  yesLabel: Ae.yesLabel || "Yes",
31379
31388
  laterLabel: Ae.laterLabel || "Later",
@@ -31381,189 +31390,189 @@ function Rk() {
31381
31390
  voiceLabel: Ae.voiceLabel || "Voice",
31382
31391
  textLabel: Ae.textLabel || "Text",
31383
31392
  chatTitle: Ae.headerName || "Chat with FlowEngage",
31384
- introGreeting: Ye,
31393
+ introGreeting: Ze,
31385
31394
  inputPlaceholder: Ae.inputPlaceholder || "Type your message",
31386
31395
  analysingLabel: Ae.analysingLabel || "analysing..."
31387
- }, Ze = ke.elevenLabsAgentId || t?.elevenLabsAgentId || null, Qe = t?.siteId || n?.siteId || null, $e = t?.apiBaseUrl || "", et = f(() => l && String(l).trim() || t?.ownerName && String(t.ownerName).trim() || t?.websiteName && String(t.websiteName).trim() || "Agent", [
31396
+ }, $e = ke.elevenLabsAgentId || t?.elevenLabsAgentId || null, et = t?.siteId || n?.siteId || null, tt = t?.apiBaseUrl || "", nt = f(() => l && String(l).trim() || t?.ownerName && String(t.ownerName).trim() || t?.websiteName && String(t.websiteName).trim() || "Agent", [
31388
31397
  l,
31389
31398
  t?.ownerName,
31390
31399
  t?.websiteName
31391
- ]), tt = u && String(u).trim() || t?.ownerProfileImageUrl && String(t.ownerProfileImageUrl).trim() || null, nt = r.some((e) => e.sender === "user"), rt = f(() => {
31400
+ ]), rt = u && String(u).trim() || t?.ownerProfileImageUrl && String(t.ownerProfileImageUrl).trim() || null, it = r.some((e) => e.sender === "user"), at = f(() => {
31392
31401
  let e = r.findIndex((e) => e.sender === "user");
31393
31402
  return e === -1 ? !1 : r.slice(e + 1).some((e) => e.sender === "bot" || e.sender === "ai" || e.sender === "agent");
31394
- }, [r]), it = !h && nt && rt, at = !!(ke._dashboardLivePreview || Oe._dashboardLivePreview), [k, A] = m(() => at ? "text_chat" : "entry_prompt"), [ot, st] = m(""), [ct, lt] = m(null), [ut, dt] = m(h || ""), [ft, pt] = m(""), [mt, ht] = m(!1), [gt, j] = m(0), [_t, vt] = m(null), [yt, bt] = m(null), [xt, St] = m(""), [Ct, wt] = m(!1), [Tt, Et] = m(!1), [Dt, Ot] = m(!1), kt = p(null), At = p(!1);
31403
+ }, [r]), k = !h && it && at, ot = !!(ke._dashboardLivePreview || Oe._dashboardLivePreview), [A, st] = m(() => ot ? "text_chat" : "entry_prompt"), [ct, lt] = m(""), [ut, dt] = m(null), [ft, pt] = m(h || ""), [mt, ht] = m(""), [gt, j] = m(!1), [_t, vt] = m(0), [yt, bt] = m(null), [xt, St] = m(null), [Ct, wt] = m(""), [Tt, Et] = m(!1), [Dt, Ot] = m(!1), [kt, At] = m(!1), jt = p(null), Mt = p(!1);
31395
31404
  d(() => {
31396
- if (e !== "ready" || At.current) return;
31397
- if (At.current = !0, !Ie) {
31398
- A("minimized_orb");
31405
+ if (e !== "ready" || Mt.current) return;
31406
+ if (Mt.current = !0, !Ie) {
31407
+ st("minimized_orb");
31399
31408
  return;
31400
31409
  }
31401
31410
  let t = !1;
31402
31411
  try {
31403
31412
  t = Tr().shouldResumeVoice;
31404
31413
  } catch {}
31405
- let n = Fe(), r = Qe ? je(Qe) : null, i = n || !!r?.transcript;
31414
+ let n = Fe(), r = et ? je(et) : null, i = n || !!r?.transcript;
31406
31415
  if (t) {
31407
- ce?.({ notifyChatInitiated: !0 }), ue?.(!0), A("voice_mode");
31416
+ ce?.({ notifyChatInitiated: !0 }), ue?.(!0), st("voice_mode");
31408
31417
  return;
31409
31418
  }
31410
31419
  if (Re()) {
31411
- ce?.({ notifyChatInitiated: !1 }), A("text_chat");
31420
+ ce?.({ notifyChatInitiated: !1 }), st("text_chat");
31412
31421
  return;
31413
31422
  }
31414
- if (Qe) try {
31415
- Me(Qe);
31423
+ if (et) try {
31424
+ Me(et);
31416
31425
  } catch {}
31417
31426
  if (i) {
31418
- A("minimized_orb");
31427
+ st("minimized_orb");
31419
31428
  return;
31420
31429
  }
31421
- if (fe(Qe)) {
31422
- A("minimized_orb");
31430
+ if (fe(et)) {
31431
+ st("minimized_orb");
31423
31432
  return;
31424
31433
  }
31425
31434
  }, [e, r]);
31426
- let [jt, Mt] = m(() => typeof window < "u" && window.matchMedia("(max-width: 640px)").matches);
31435
+ let [Nt, Pt] = m(() => typeof window < "u" && window.matchMedia("(max-width: 640px)").matches);
31427
31436
  c(() => {
31428
- let e = window.matchMedia("(max-width: 640px)"), t = (e) => Mt(e.matches);
31437
+ let e = window.matchMedia("(max-width: 640px)"), t = (e) => Pt(e.matches);
31429
31438
  return e.addEventListener("change", t), () => e.removeEventListener("change", t);
31430
31439
  }, []), c(() => {
31431
- dt(h || ""), h && pt("");
31440
+ pt(h || ""), h && ht("");
31432
31441
  }, [h]);
31433
- let Nt = o(() => {
31434
- bt(null), St("");
31435
- }, []), Pt = o((e) => {
31442
+ let Ft = o(() => {
31443
+ St(null), wt("");
31444
+ }, []), It = o((e) => {
31436
31445
  let t = qD(e);
31437
31446
  if (t) {
31438
- bt(null), St(t);
31447
+ St(null), wt(t);
31439
31448
  return;
31440
31449
  }
31441
- bt(e), St("");
31450
+ St(e), wt("");
31442
31451
  }, []);
31443
31452
  c(() => {
31444
31453
  if (!te || ee !== "connected") {
31445
- j(0);
31454
+ vt(0);
31446
31455
  return;
31447
31456
  }
31448
31457
  let e = () => {
31449
31458
  let e = new Date(te).getTime();
31450
- isNaN(e) || j(Math.max(0, Math.floor((Date.now() - e) / 1e3)));
31459
+ isNaN(e) || vt(Math.max(0, Math.floor((Date.now() - e) / 1e3)));
31451
31460
  };
31452
31461
  e();
31453
31462
  let t = window.setInterval(e, 1e3);
31454
31463
  return () => window.clearInterval(t);
31455
31464
  }, [te, ee]);
31456
- let Ft = o(() => {
31457
- A("call_screen"), Et(!1);
31458
- }, []), It = o(() => {
31459
- A("text_chat"), Et(!0);
31465
+ let Lt = o(() => {
31466
+ st("call_screen"), Ot(!1);
31467
+ }, []), Rt = o(() => {
31468
+ st("text_chat"), Ot(!0);
31460
31469
  }, []);
31461
31470
  c(() => {
31462
31471
  let e = w?.callId || T || null;
31463
31472
  if (!e) {
31464
- kt.current = null;
31473
+ jt.current = null;
31465
31474
  return;
31466
31475
  }
31467
31476
  if (w?.callId || ee === "connecting" || ee === "connected") {
31468
- if (k === "minimized_orb" && Tt && T && !w?.callId) {
31469
- kt.current = e;
31477
+ if (A === "minimized_orb" && Dt && T && !w?.callId) {
31478
+ jt.current = e;
31470
31479
  return;
31471
31480
  }
31472
- !(!i || k === "minimized_orb" || k === "voice_mode") && kt.current === e || (console.log("[FlowEngageWidget] forcing call UI to front", {
31481
+ !(!i || A === "minimized_orb" || A === "voice_mode") && jt.current === e || (console.log("[FlowEngageWidget] forcing call UI to front", {
31473
31482
  forcedKey: e,
31474
31483
  isOpen: i,
31475
- surface: k,
31484
+ surface: A,
31476
31485
  hasIncomingCall: !!w?.callId,
31477
31486
  activeCallId: T,
31478
31487
  callConnectionState: ee
31479
- }), kt.current = e, k === "voice_mode" && ue?.(!1), ce?.(), Ft());
31488
+ }), jt.current = e, A === "voice_mode" && ue?.(!1), ce?.(), Lt());
31480
31489
  }
31481
31490
  }, [
31482
31491
  T,
31483
31492
  ee,
31484
- Ft,
31493
+ Lt,
31485
31494
  w?.callId,
31486
31495
  i,
31487
31496
  ce,
31488
31497
  ue,
31489
- k
31498
+ A
31490
31499
  ]), c(() => {
31491
- !w && !T && k === "call_screen" && A("text_chat");
31500
+ !w && !T && A === "call_screen" && st("text_chat");
31492
31501
  }, [
31493
31502
  w,
31494
31503
  T,
31495
- k
31504
+ A
31496
31505
  ]), c(() => {
31497
- !T && Tt && Et(!1);
31498
- }, [T, Tt]), c(() => {
31506
+ !T && Dt && Ot(!1);
31507
+ }, [T, Dt]), c(() => {
31499
31508
  if (!s || C) {
31500
31509
  Se?.(""), xe?.();
31501
31510
  return;
31502
31511
  }
31503
- if (!ot.trim() || yt) {
31512
+ if (!ct.trim() || xt) {
31504
31513
  Se?.("");
31505
31514
  let e = window.setTimeout(() => xe?.(), 100);
31506
31515
  return () => window.clearTimeout(e);
31507
31516
  }
31508
31517
  be?.();
31509
- let e = window.setTimeout(() => Se?.(ot), 120), t = window.setTimeout(() => xe?.(), 1200);
31518
+ let e = window.setTimeout(() => Se?.(ct), 120), t = window.setTimeout(() => xe?.(), 1200);
31510
31519
  return () => {
31511
31520
  window.clearTimeout(e), window.clearTimeout(t);
31512
31521
  };
31513
31522
  }, [
31514
- ot,
31515
- yt,
31523
+ ct,
31524
+ xt,
31516
31525
  s,
31517
31526
  C,
31518
31527
  be,
31519
31528
  xe,
31520
31529
  Se
31521
31530
  ]);
31522
- let Lt = (e) => e ? {
31531
+ let zt = (e) => e ? {
31523
31532
  replyTo: e.messageId || e.id || null,
31524
31533
  replyToContent: (e.replyToContent || e.message || "").replace(/<[^>]+>/g, "").trim().slice(0, 200),
31525
31534
  replyToSender: e.sender || null
31526
- } : null, Rt = async (e) => {
31535
+ } : null, Bt = async (e) => {
31527
31536
  if (e.preventDefault(), C) return;
31528
- if (it) {
31529
- let e = ut.trim().toLowerCase();
31537
+ if (k) {
31538
+ let e = ft.trim().toLowerCase();
31530
31539
  if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e)) {
31531
- pt("Please enter a valid email so we can continue helping you.");
31540
+ ht("Please enter a valid email so we can continue helping you.");
31532
31541
  return;
31533
31542
  }
31534
- await le(e), pt(""), ht(!0), setTimeout(() => ht(!1), 3e3);
31543
+ await le(e), ht(""), j(!0), setTimeout(() => j(!1), 3e3);
31535
31544
  return;
31536
31545
  }
31537
- let t = Lt(ct);
31538
- if (!ot.trim() && !yt) return;
31539
- if (yt) {
31546
+ let t = zt(ut);
31547
+ if (!ct.trim() && !xt) return;
31548
+ if (xt) {
31540
31549
  try {
31541
- wt(!0), St("");
31542
- let e = await se(yt), n = e?.data || e, r = ot.trim() || `Shared file: ${YD(yt)}`;
31543
- st(""), lt(null), Nt(), await D(r, "", t, {
31550
+ Et(!0), wt("");
31551
+ let e = await se(xt), n = e?.data || e, r = ct.trim() || `Shared file: ${YD(xt)}`;
31552
+ lt(""), dt(null), Ft(), await D(r, "", t, {
31544
31553
  type: "file",
31545
31554
  metadata: {
31546
31555
  fileUrl: n?.fileUrl,
31547
- fileName: n?.fileName || yt.name,
31548
- fileType: n?.fileType || yt.type,
31549
- fileSize: n?.fileSize || yt.size
31556
+ fileName: n?.fileName || xt.name,
31557
+ fileType: n?.fileType || xt.type,
31558
+ fileSize: n?.fileSize || xt.size
31550
31559
  }
31551
31560
  });
31552
31561
  } catch (e) {
31553
- St(e?.message || "Failed to upload the selected file.");
31562
+ wt(e?.message || "Failed to upload the selected file.");
31554
31563
  } finally {
31555
- wt(!1);
31564
+ Et(!1);
31556
31565
  }
31557
31566
  return;
31558
31567
  }
31559
- let n = ot.trim();
31560
- st(""), lt(null), await D(n, "", t);
31561
- }, zt = o(() => {
31568
+ let n = ct.trim();
31569
+ lt(""), dt(null), await D(n, "", t);
31570
+ }, Vt = o(() => {
31562
31571
  r.length !== 0 && me?.();
31563
- }, [r.length, me]), Bt = (e) => {
31572
+ }, [r.length, me]), Ht = (e) => {
31564
31573
  let t = Math.floor(e / 60);
31565
31574
  return `${String(t).padStart(2, "0")}:${String(e % 60).padStart(2, "0")}`;
31566
- }, Vt = o(async (e) => {
31575
+ }, Ut = o(async (e) => {
31567
31576
  if (C || b) return;
31568
31577
  let t = e.message || e.label || e.text || "";
31569
31578
  t.trim() && await D(t.trim(), "");
@@ -31571,44 +31580,44 @@ function Rk() {
31571
31580
  C,
31572
31581
  b,
31573
31582
  D
31574
- ]), Ht = jt && k === "entry_prompt" ? { inset: 0 } : jt && k === "text_chat" ? {
31583
+ ]), Wt = Nt && A === "entry_prompt" ? { inset: 0 } : Nt && A === "text_chat" ? {
31575
31584
  left: 0,
31576
31585
  right: 0,
31577
31586
  bottom: 0
31578
- } : jt && k === "call_screen" ? {
31587
+ } : Nt && A === "call_screen" ? {
31579
31588
  left: 0,
31580
31589
  right: 0,
31581
31590
  bottom: 0,
31582
31591
  height: "90dvh",
31583
31592
  overflow: "hidden",
31584
31593
  borderRadius: "16px 16px 0 0"
31585
- } : jt && k === "connection_modal" ? {
31594
+ } : Nt && A === "connection_modal" ? {
31586
31595
  left: "28px",
31587
31596
  right: "12px",
31588
31597
  bottom: "12px"
31589
- } : k === "call_screen" ? {
31598
+ } : A === "call_screen" ? {
31590
31599
  width: "min(350px, calc(100vw - 40px))",
31591
31600
  height: "min(640px, calc(100vh - 120px))",
31592
31601
  borderRadius: "22px",
31593
31602
  overflow: "hidden",
31594
- ...Be === "bottom-left" ? {
31603
+ ...He === "bottom-left" ? {
31595
31604
  left: "1.5rem",
31596
31605
  bottom: "1.5rem"
31597
31606
  } : {
31598
31607
  right: "1.5rem",
31599
31608
  bottom: "1.5rem"
31600
31609
  }
31601
- } : Be === "bottom-left" ? {
31610
+ } : He === "bottom-left" ? {
31602
31611
  left: "1.5rem",
31603
31612
  bottom: "1.5rem"
31604
31613
  } : {
31605
31614
  right: "1.5rem",
31606
31615
  bottom: "1.5rem"
31607
- }, Ut = o(() => {
31608
- k !== "minimized_orb" && (Ot(!0), setTimeout(() => {
31609
- A("minimized_orb"), Ot(!1);
31616
+ }, Gt = o(() => {
31617
+ A !== "minimized_orb" && (At(!0), setTimeout(() => {
31618
+ st("minimized_orb"), At(!1);
31610
31619
  }, 280));
31611
- }, [k]), Wt = () => A("connection_modal"), Gt = () => {
31620
+ }, [A]), Kt = () => st("connection_modal"), qt = () => {
31612
31621
  try {
31613
31622
  let e = window.AudioContext || window.webkitAudioContext;
31614
31623
  if (e) {
@@ -31616,36 +31625,36 @@ function Rk() {
31616
31625
  t.resume().catch(() => {}), setTimeout(() => t.close().catch(() => {}), 3e3);
31617
31626
  }
31618
31627
  } catch {}
31619
- ce({ notifyChatInitiated: !0 }), ue?.(!0), A("voice_mode");
31620
- }, Kt = () => {
31621
- ce({ notifyChatInitiated: !0 }), ue?.(!1), A("text_chat");
31622
- }, qt = () => {
31623
- ue?.(!1), Ut();
31628
+ ce({ notifyChatInitiated: !0 }), ue?.(!0), st("voice_mode");
31629
+ }, Jt = () => {
31630
+ ce({ notifyChatInitiated: !0 }), ue?.(!1), st("text_chat");
31631
+ }, Yt = () => {
31632
+ ue?.(!1), Gt();
31624
31633
  };
31625
- return e !== "ready" || !Je || Pe.chat === !1 ? null : /* @__PURE__ */ _("div", {
31634
+ return e !== "ready" || !Xe || Pe.chat === !1 ? null : /* @__PURE__ */ _("div", {
31626
31635
  className: "flowengage-widget-root",
31627
31636
  style: {
31628
31637
  position: "fixed",
31629
31638
  zIndex: 999999,
31630
- ...Ht
31639
+ ...Wt
31631
31640
  },
31632
31641
  onWheel: (e) => e.stopPropagation(),
31633
31642
  onTouchMove: (e) => e.stopPropagation(),
31634
31643
  children: [
31635
- k === "entry_prompt" && /* @__PURE__ */ g(Mk, {
31636
- copy: Xe,
31644
+ A === "entry_prompt" && /* @__PURE__ */ g(Mk, {
31645
+ copy: Qe,
31637
31646
  orbColors: Le,
31638
31647
  primaryColor: ze,
31639
31648
  onYes: () => {
31640
- pe(Qe), Gt();
31649
+ pe(et), qt();
31641
31650
  },
31642
31651
  onLater: () => {
31643
- pe(Qe), Ut();
31652
+ pe(et), Gt();
31644
31653
  },
31645
- isMobile: jt,
31646
- isClosing: Dt
31654
+ isMobile: Nt,
31655
+ isClosing: kt
31647
31656
  }),
31648
- k === "minimized_orb" && /* @__PURE__ */ _(Dm.div, {
31657
+ A === "minimized_orb" && /* @__PURE__ */ _(Dm.div, {
31649
31658
  layoutId: "fe-main-orb",
31650
31659
  initial: {
31651
31660
  scale: .4,
@@ -31664,14 +31673,14 @@ function Rk() {
31664
31673
  transformOrigin: "bottom right",
31665
31674
  display: "inline-flex",
31666
31675
  flexDirection: "column",
31667
- alignItems: Be === "bottom-left" ? "flex-start" : "flex-end",
31676
+ alignItems: He === "bottom-left" ? "flex-start" : "flex-end",
31668
31677
  gap: "10px"
31669
31678
  },
31670
- children: [T && Tt && /* @__PURE__ */ _("button", {
31679
+ children: [T && Dt && /* @__PURE__ */ _("button", {
31671
31680
  type: "button",
31672
- onClick: Ft,
31681
+ onClick: Lt,
31673
31682
  style: {
31674
- maxWidth: jt ? "220px" : "240px",
31683
+ maxWidth: Nt ? "220px" : "240px",
31675
31684
  padding: "10px 14px",
31676
31685
  borderRadius: "18px",
31677
31686
  border: "1px solid rgba(255,255,255,0.7)",
@@ -31712,109 +31721,109 @@ function Rk() {
31712
31721
  marginTop: "2px",
31713
31722
  whiteSpace: "nowrap"
31714
31723
  },
31715
- children: ee === "connected" ? `${Bt(gt)} with ${et}` : `Tap to return to ${et}`
31724
+ children: ee === "connected" ? `${Ht(_t)} with ${nt}` : `Tap to return to ${nt}`
31716
31725
  })]
31717
31726
  })]
31718
31727
  }), /* @__PURE__ */ g(jk, {
31719
- size: 50,
31728
+ size: Ve,
31720
31729
  orbColors: Le,
31721
- onClick: T && Tt ? Ft : Ie ? Wt : Kt
31730
+ onClick: T && Dt ? Lt : Ie ? Kt : Jt
31722
31731
  })]
31723
31732
  }),
31724
- k === "connection_modal" && /* @__PURE__ */ g(Nk, {
31725
- copy: Xe,
31733
+ A === "connection_modal" && /* @__PURE__ */ g(Nk, {
31734
+ copy: Qe,
31726
31735
  orbColors: Le,
31727
31736
  primaryColor: ze,
31728
- onVoice: Gt,
31729
- onText: Kt,
31730
- onClose: Ut,
31731
- isMobile: jt,
31732
- isClosing: Dt
31737
+ onVoice: qt,
31738
+ onText: Jt,
31739
+ onClose: Gt,
31740
+ isMobile: Nt,
31741
+ isClosing: kt
31733
31742
  }),
31734
- k === "voice_mode" && /* @__PURE__ */ g(Pk, {
31743
+ A === "voice_mode" && /* @__PURE__ */ g(Pk, {
31735
31744
  orbColors: Le,
31736
- onEnterChat: Kt,
31737
- onEndChat: qt,
31738
- agentId: Ze,
31739
- siteId: Qe,
31740
- apiBaseUrl: $e,
31745
+ onEnterChat: Jt,
31746
+ onEndChat: Yt,
31747
+ agentId: $e,
31748
+ siteId: et,
31749
+ apiBaseUrl: tt,
31741
31750
  chatId: ie,
31742
31751
  historyRef: ae,
31743
31752
  onMessageSync: oe,
31744
31753
  voiceEndCounter: De
31745
31754
  }, "voice"),
31746
- k === "call_screen" && /* @__PURE__ */ g(gO, {
31755
+ A === "call_screen" && /* @__PURE__ */ g(gO, {
31747
31756
  incomingCall: w,
31748
31757
  activeCallId: T,
31749
31758
  callConnectionState: ee,
31750
- callDurationSeconds: gt,
31759
+ callDurationSeconds: _t,
31751
31760
  isCallMuted: ne,
31752
- agentName: et,
31753
- agentHeadshot: tt,
31754
- fallbackAgentName: Ve,
31761
+ agentName: nt,
31762
+ agentHeadshot: rt,
31763
+ fallbackAgentName: O,
31755
31764
  acceptCall: he,
31756
31765
  rejectCall: ge,
31757
31766
  endWebRTCCall: _e,
31758
31767
  toggleCallMute: ve,
31759
- formatCallDuration: Bt,
31760
- onMinimize: It,
31768
+ formatCallDuration: Ht,
31769
+ onMinimize: Rt,
31761
31770
  primaryColor: ze,
31762
31771
  orbColors: Le,
31763
31772
  chatHistory: r
31764
31773
  }),
31765
- k === "text_chat" && /* @__PURE__ */ g(Lk, {
31766
- isClosing: Dt,
31767
- copy: Xe,
31774
+ A === "text_chat" && /* @__PURE__ */ g(Lk, {
31775
+ isClosing: kt,
31776
+ copy: Qe,
31768
31777
  orbColors: Le,
31769
31778
  primaryColor: ze,
31770
- chatBgGradient: He,
31771
- logo: O,
31772
- quickChatOptions: Ke,
31773
- onQuickChatSelect: Vt,
31774
- isMobile: jt,
31779
+ chatBgGradient: Ue,
31780
+ logo: We,
31781
+ quickChatOptions: Je,
31782
+ onQuickChatSelect: Ut,
31783
+ isMobile: Nt,
31775
31784
  chatHistory: r,
31776
31785
  isAiTyping: y,
31777
31786
  isAgentTyping: v,
31778
31787
  activeScreen: a,
31779
- agentName: et,
31780
- agentHeadshot: tt,
31781
- fallbackAgentName: Ve,
31782
- input: ot,
31783
- setInput: st,
31784
- onSubmit: Rt,
31788
+ agentName: nt,
31789
+ agentHeadshot: rt,
31790
+ fallbackAgentName: O,
31791
+ input: ct,
31792
+ setInput: lt,
31793
+ onSubmit: Bt,
31785
31794
  isConversationEnded: C,
31786
31795
  isLoading: b,
31787
31796
  isRateLimited: x,
31788
31797
  rateLimitMessage: S,
31789
- selectedFile: yt,
31790
- onFileSelect: Pt,
31791
- onRemoveSelectedFile: Nt,
31792
- attachmentError: xt,
31793
- isUploadingAttachment: Ct,
31794
- requiresEmail: it,
31795
- emailInput: ut,
31796
- setEmailInput: dt,
31797
- emailError: ft,
31798
- emailCaptureSuccess: mt,
31799
- replyContext: ct,
31800
- setReplyContext: lt,
31798
+ selectedFile: xt,
31799
+ onFileSelect: It,
31800
+ onRemoveSelectedFile: Ft,
31801
+ attachmentError: Ct,
31802
+ isUploadingAttachment: Tt,
31803
+ requiresEmail: k,
31804
+ emailInput: ft,
31805
+ setEmailInput: pt,
31806
+ emailError: mt,
31807
+ emailCaptureSuccess: gt,
31808
+ replyContext: ut,
31809
+ setReplyContext: dt,
31801
31810
  webRTCError: re,
31802
- micError: _t,
31803
- setMicError: vt,
31811
+ micError: yt,
31812
+ setMicError: bt,
31804
31813
  dismissCallError: ye,
31805
31814
  activeCallId: T,
31806
31815
  isCallMuted: ne,
31807
31816
  toggleCallMute: ve,
31808
31817
  endWebRTCCall: _e,
31809
- formatCallDuration: Bt,
31810
- callDurationSeconds: gt,
31811
- onCollapse: Ut,
31812
- onStartVoice: Gt,
31813
- onNewChat: zt,
31814
- onMinimize: It,
31815
- onExpand: Ft,
31816
- isCallMinimized: Tt && !!T,
31817
- showPoweredBy: qe,
31818
+ formatCallDuration: Ht,
31819
+ callDurationSeconds: _t,
31820
+ onCollapse: Gt,
31821
+ onStartVoice: qt,
31822
+ onNewChat: Vt,
31823
+ onMinimize: Rt,
31824
+ onExpand: Lt,
31825
+ isCallMinimized: Dt && !!T,
31826
+ showPoweredBy: Ye,
31818
31827
  getVisitorChatHistory: Ce,
31819
31828
  resumeChat: we,
31820
31829
  isSessionRestoring: Te