@flowengage/react-chatbot 8.0.109 → 8.0.111

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.
@@ -34,25 +34,25 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
34
34
  agentName: "flowengage.agentName",
35
35
  agentHeadshot: "flowengage.agentHeadshot",
36
36
  visitorEmail: "flowengage.visitorEmail"
37
- }, ee = 6e4, te = 480 * 60, ne = 3e4, j = typeof window < "u", M = (e) => e ? `flowengage.visitorEmail.${e}` : null, re = () => {
37
+ }, ee = 6e4, te = 480 * 60, ne = 3e4, j = typeof window < "u", M = (e) => e ? `flowengage.visitorEmail.${e}` : null, N = () => {
38
38
  if (!j) return null;
39
39
  let e = window.localStorage.getItem(A.chatId);
40
40
  return e && String(e).trim() ? String(e).trim() : null;
41
- }, ie = () => {
41
+ }, re = () => {
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", P = (e) => e ? `flowengage.entrySeen.${e}` : null, ae = (e) => {
45
+ }, P = () => j ? typeof crypto < "u" && crypto.randomUUID ? crypto.randomUUID() : `${Date.now()}-${Math.random().toString(16).slice(2)}` : "server-chat-id", ie = (e) => e ? `flowengage.entrySeen.${e}` : null, ae = (e) => {
46
46
  if (!j || !e) return !1;
47
47
  try {
48
- let t = P(e);
48
+ let t = ie(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 = P(e);
55
+ let t = ie(e);
56
56
  t && window.localStorage.setItem(t, "1");
57
57
  } catch {}
58
58
  }, se = (e) => e ? `flowengage.persistedChatId.${e}` : null, ce = (e) => {
@@ -3296,7 +3296,7 @@ function pi({ siteId: e, config: t, children: n, language: r = "en" }) {
3296
3296
  message: "Looks like you're already on this page!",
3297
3297
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
3298
3298
  }]);
3299
- }, []), [D, O] = m(de().isOpen), [k, A] = m(de().activeScreen), [j, M] = m(de().isHumanHandled), [P, ae] = m(de().agentName), [oe, se] = m(de().agentHeadshot), [he, ge] = m(() => pe(i?.siteId)), [F, ve] = m(!1), [ye, I] = m(!1), [be, L] = m("idle"), [xe, Se] = m(!1), [R, we] = m(!1), [Te, Ee] = m(""), [De, Oe] = m(!1), [ke, Ae] = m(0), [je, Me] = m(0), [z, B] = m(!1), [V, Ie] = m(null), [Le, Re] = m(null), [ze, Be] = m("idle"), [Ve, He] = m(null), [Ue, We] = m(!1), [Ge, Ke] = m(""), [qe, Je] = m(!1), H = p(null), U = p(null), Ye = p(""), Xe = p(!1), Ze = p(null), Qe = p(null), W = p(null), $e = p(null), et = p(null), tt = p(null), nt = p(null), G = p(!1), rt = p({
3299
+ }, []), [D, O] = m(de().isOpen), [k, A] = m(de().activeScreen), [j, M] = m(de().isHumanHandled), [ie, ae] = m(de().agentName), [oe, se] = m(de().agentHeadshot), [he, ge] = m(() => pe(i?.siteId)), [F, ve] = m(!1), [ye, I] = m(!1), [be, L] = m("idle"), [xe, Se] = m(!1), [R, we] = m(!1), [Te, Ee] = m(""), [De, Oe] = m(!1), [ke, Ae] = m(0), [je, Me] = m(0), [z, B] = m(!1), [V, Ie] = m(null), [Le, Re] = m(null), [ze, Be] = m("idle"), [Ve, He] = m(null), [Ue, We] = m(!1), [Ge, Ke] = m(""), [qe, Je] = m(!1), H = p(null), U = p(null), Ye = p(""), Xe = p(!1), Ze = p(null), Qe = p(null), W = p(null), $e = p(null), et = p(null), tt = p(null), nt = p(null), G = p(!1), rt = p({
3300
3300
  url: null,
3301
3301
  at: 0
3302
3302
  }), it = o((e, t) => {
@@ -3313,7 +3313,7 @@ function pi({ siteId: e, config: t, children: n, language: r = "en" }) {
3313
3313
  url: n,
3314
3314
  at: Date.now()
3315
3315
  }, wr(e, t));
3316
- }, []), at = p([]), ot = p(null), st = p(null), ct = p(null), lt = p(!1), ut = p(!1), dt = p(""), ft = p(null), pt = p(null), mt = p([]), ht = p(0), gt = p(P), _t = p([]), vt = p(!1), yt = p(!1), bt = p(i), xt = p({
3316
+ }, []), at = p([]), ot = p(null), st = p(null), ct = p(null), lt = p(!1), ut = p(!1), dt = p(""), ft = p(null), pt = p(null), mt = p([]), ht = p(0), gt = p(ie), _t = p([]), vt = p(!1), yt = p(!1), bt = p(i), xt = p({
3317
3317
  notifyRouteChange: () => {},
3318
3318
  cleanup: () => {}
3319
3319
  }), St = o((e = {}) => {
@@ -3326,8 +3326,8 @@ function pi({ siteId: e, config: t, children: n, language: r = "en" }) {
3326
3326
  c(() => {
3327
3327
  Qe.current = V;
3328
3328
  }, [V]), c(() => {
3329
- gt.current = P;
3330
- }, [P]), c(() => {
3329
+ gt.current = ie;
3330
+ }, [ie]), c(() => {
3331
3331
  yt.current = De;
3332
3332
  }, [De]), c(() => {
3333
3333
  bt.current = i;
@@ -3482,14 +3482,14 @@ function pi({ siteId: e, config: t, children: n, language: r = "en" }) {
3482
3482
  isOpen: D,
3483
3483
  activeScreen: k,
3484
3484
  isHumanHandled: j,
3485
- agentName: P,
3485
+ agentName: ie,
3486
3486
  agentHeadshot: oe
3487
3487
  });
3488
3488
  }, [
3489
3489
  D,
3490
3490
  k,
3491
3491
  j,
3492
- P,
3492
+ ie,
3493
3493
  oe
3494
3494
  ]), c(() => {
3495
3495
  let e = !0;
@@ -3505,14 +3505,14 @@ function pi({ siteId: e, config: t, children: n, language: r = "en" }) {
3505
3505
  apiBaseUrl: t.apiBaseUrl,
3506
3506
  userId: n.userId,
3507
3507
  siteId: a,
3508
- priorChatId: e || r ? null : o || re(),
3508
+ priorChatId: e || r ? null : o || N(),
3509
3509
  forceNew: e,
3510
3510
  resumeChatId: r,
3511
3511
  visitorId: s
3512
3512
  }))?.data?.chatId, !c) throw Error("resolve-session returned no chatId");
3513
- ie(), ue(a, c);
3513
+ re(), ue(a, c);
3514
3514
  } catch (e) {
3515
- console.warn("[FlowEngageProvider] resolve-session failed, reusing persisted or ephemeral chat id", e?.message || e), c = o || N(), ue(a, c);
3515
+ console.warn("[FlowEngageProvider] resolve-session failed, reusing persisted or ephemeral chat id", e?.message || e), c = o || P(), ue(a, c);
3516
3516
  }
3517
3517
  Ye.current = c;
3518
3518
  let l = Fe({
@@ -4210,7 +4210,7 @@ function pi({ siteId: e, config: t, children: n, language: r = "en" }) {
4210
4210
  isOpen: D,
4211
4211
  activeScreen: k,
4212
4212
  isHumanHandled: j,
4213
- agentName: P,
4213
+ agentName: ie,
4214
4214
  agentHeadshot: oe,
4215
4215
  visitorEmail: he,
4216
4216
  isAgentTyping: F,
@@ -4271,7 +4271,7 @@ function pi({ siteId: e, config: t, children: n, language: r = "en" }) {
4271
4271
  D,
4272
4272
  k,
4273
4273
  j,
4274
- P,
4274
+ ie,
4275
4275
  oe,
4276
4276
  he,
4277
4277
  F,
@@ -9228,13 +9228,13 @@ var Qm = {
9228
9228
  ...Qm,
9229
9229
  ...Lm,
9230
9230
  ...$m
9231
- }, Xp), th = 24e3, nh = 2048, rh = 1200, ih = .05, ah = 4, oh = .03, sh = 2, ch = 11;
9232
- function lh(e) {
9231
+ }, Xp), th = 24e3, nh = 2048, rh = 1200, ih = .03, ah = 2, oh = 11;
9232
+ function sh(e) {
9233
9233
  let t = 0;
9234
9234
  for (let n = 0; n < e.length; n++) t += e[n] * e[n];
9235
9235
  return Math.sqrt(t / e.length);
9236
9236
  }
9237
- function uh(e) {
9237
+ function ch(e) {
9238
9238
  let t = new Int16Array(e.length);
9239
9239
  for (let n = 0; n < e.length; n++) {
9240
9240
  let r = Math.max(-1, Math.min(1, e[n]));
@@ -9242,16 +9242,16 @@ function uh(e) {
9242
9242
  }
9243
9243
  return t;
9244
9244
  }
9245
- function dh(e) {
9245
+ function lh(e) {
9246
9246
  let t = new Float32Array(e.length);
9247
9247
  for (let n = 0; n < e.length; n++) t[n] = e[n] / 32768;
9248
9248
  return t;
9249
9249
  }
9250
- var fh = .13, ph = ["audio/webm", "audio/mp4"];
9251
- function mh() {
9252
- return typeof window > "u" || window.MediaRecorder === void 0 ? null : ph.find((e) => window.MediaRecorder.isTypeSupported(e)) || null;
9250
+ var uh = .13, dh = ["audio/webm", "audio/mp4"];
9251
+ function fh() {
9252
+ return typeof window > "u" || window.MediaRecorder === void 0 ? null : dh.find((e) => window.MediaRecorder.isTypeSupported(e)) || null;
9253
9253
  }
9254
- function hh(e, t, n, r, i) {
9254
+ function ph(e, t, n, r, i) {
9255
9255
  if (!r.length || !n || !e) return;
9256
9256
  let a = new Blob(r, { type: i }), o = new FormData();
9257
9257
  o.append("audio", a, `aichat-${n}.webm`), o.append("voiceSessionId", n), o.append("siteId", t || ""), fetch(`${e}/api/voice/upload-chat-recording`, {
@@ -9261,25 +9261,25 @@ function hh(e, t, n, r, i) {
9261
9261
  if (!e.ok) throw Error(`HTTP ${e.status}`);
9262
9262
  }).catch((e) => console.warn("[FlowEngage] voice recording upload failed:", e.message));
9263
9263
  }
9264
- var gh = .02;
9265
- function _h(e, t, n) {
9264
+ var mh = .02;
9265
+ function hh(e, t, n) {
9266
9266
  let r = 0, i = 0, a = [], o = () => {
9267
9267
  let t = e.currentTime;
9268
9268
  a.forEach(({ source: e, gain: n }) => {
9269
9269
  try {
9270
- n.gain.cancelScheduledValues(t), n.gain.setValueAtTime(n.gain.value, t), n.gain.linearRampToValueAtTime(0, t + gh), e.stop(t + gh);
9270
+ n.gain.cancelScheduledValues(t), n.gain.setValueAtTime(n.gain.value, t), n.gain.linearRampToValueAtTime(0, t + mh), e.stop(t + mh);
9271
9271
  } catch {}
9272
9272
  }), a = [], r = 0, i = 0;
9273
9273
  }, s = () => r > e.currentTime;
9274
9274
  return {
9275
9275
  enqueue: (o) => {
9276
- let c = dh(o), l = e.createBuffer(1, c.length, th);
9276
+ let c = lh(o), l = e.createBuffer(1, c.length, th);
9277
9277
  l.copyToChannel(c, 0);
9278
9278
  let u = e.createBufferSource();
9279
9279
  u.buffer = l;
9280
9280
  let d = e.createGain();
9281
9281
  u.connect(d), d.connect(e.destination), n && d.connect(n);
9282
- let f = s() ? r : e.currentTime + fh;
9282
+ let f = s() ? r : e.currentTime + uh;
9283
9283
  i ||= f, u.start(f), r = f + l.duration;
9284
9284
  let p = {
9285
9285
  source: u,
@@ -9294,7 +9294,7 @@ function _h(e, t, n) {
9294
9294
  playedMs: () => Math.max(0, (e.currentTime - i) * 1e3)
9295
9295
  };
9296
9296
  }
9297
- async function vh(e, t, n) {
9297
+ async function gh(e, t, n) {
9298
9298
  let r = new URLSearchParams({ siteId: t || "" });
9299
9299
  n && r.set("chatId", n);
9300
9300
  let i = Fr();
@@ -9312,8 +9312,8 @@ async function vh(e, t, n) {
9312
9312
  if (!o?.success || !o.wsUrl) throw Error(o?.error || "Voice session was refused.");
9313
9313
  return o;
9314
9314
  }
9315
- async function yh(e) {
9316
- let { apiBaseUrl: t, siteId: n, chatId: r, clientTools: i = {}, onConnect: a, onDisconnect: o, onMessage: s, onModeChange: c, onError: l, onUnhandledClientToolCall: u, onAgentTurnEnd: d, onSessionInfo: f, onSessionEnding: p } = e, m = await vh(t, n, r);
9315
+ async function _h(e) {
9316
+ let { apiBaseUrl: t, siteId: n, chatId: r, clientTools: i = {}, onConnect: a, onDisconnect: o, onMessage: s, onModeChange: c, onError: l, onUnhandledClientToolCall: u, onAgentTurnEnd: d, onSessionInfo: f, onSessionEnding: p } = e, m = await gh(t, n, r);
9317
9317
  f?.({ emailOnFile: !!m.emailOnFile });
9318
9318
  let h = { type: "Start" };
9319
9319
  e.greeting !== void 0 && (h.greeting = e.greeting || null);
@@ -9324,7 +9324,7 @@ async function yh(e) {
9324
9324
  autoGainControl: !0
9325
9325
  } }), _ = new (window.AudioContext || window.webkitAudioContext)({ sampleRate: th });
9326
9326
  _.state === "suspended" && await _.resume();
9327
- let v = _.createMediaStreamDestination(), y = mh(), b = [], x = null, S = r || n || null;
9327
+ let v = _.createMediaStreamDestination(), y = fh(), b = [], x = null, S = r || n || null;
9328
9328
  y && (x = new window.MediaRecorder(v.stream, { mimeType: y }), x.ondataavailable = (e) => {
9329
9329
  e.data && e.data.size > 0 && b.push(e.data);
9330
9330
  }, x.start());
@@ -9354,70 +9354,56 @@ async function yh(e) {
9354
9354
  }
9355
9355
  }, O = (e, t, n) => {
9356
9356
  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, rh));
9357
- }, k = !1, A = !1, ee = !1, te = !1, ne = !0, j = 0, M = !1, re = !1, ie = ih, N = ah, P = null, ae = !1, oe = !1, se = () => {
9358
- P && clearTimeout(P);
9357
+ }, k = !1, A = !1, ee = !1, te = !1, ne = !1, j = !0, M = !1, N = null, re = !1, P = !1, ie = () => {
9358
+ N && clearTimeout(N);
9359
9359
  let e = () => {
9360
9360
  if (!k) {
9361
- if (ce.isPlaying()) {
9362
- P = setTimeout(e, 150);
9361
+ if (ae.isPlaying()) {
9362
+ N = setTimeout(e, 150);
9363
9363
  return;
9364
9364
  }
9365
- if (P = null, ae) {
9365
+ if (N = null, re) {
9366
9366
  p?.();
9367
9367
  return;
9368
9368
  }
9369
- !k && C.readyState === WebSocket.OPEN && C.send(JSON.stringify({ type: "PlaybackDrained" })), oe && (oe = !1, d?.());
9369
+ !k && C.readyState === WebSocket.OPEN && C.send(JSON.stringify({ type: "PlaybackDrained" })), P && (P = !1, d?.());
9370
9370
  }
9371
9371
  };
9372
- P = setTimeout(e, 150);
9373
- }, ce = _h(_, () => {
9374
- te && (te = !1, c?.({ mode: "listening" }));
9372
+ N = setTimeout(e, 150);
9373
+ }, ae = hh(_, () => {
9374
+ te && (te = !1, c?.({ mode: ne ? "thinking" : "listening" }));
9375
9375
  }, v);
9376
- typeof window < "u" && (window.__fe_agentAudioPlaying = () => ce.isPlaying());
9377
- let le = _.createMediaStreamSource(g);
9378
- le.connect(v);
9379
- let ue = _.createScriptProcessor(nh, 1, 1), de = !1, fe = 0, pe = 0;
9380
- ue.onaudioprocess = (e) => {
9376
+ typeof window < "u" && (window.__fe_agentAudioPlaying = () => ae.isPlaying());
9377
+ let oe = _.createMediaStreamSource(g);
9378
+ oe.connect(v);
9379
+ let se = _.createScriptProcessor(nh, 1, 1), ce = !1, le = 0, ue = 0;
9380
+ se.onaudioprocess = (e) => {
9381
9381
  if (k || C.readyState !== WebSocket.OPEN) return;
9382
9382
  let t = e.inputBuffer.getChannelData(0), n = () => C.send(new Int16Array(t.length).buffer);
9383
9383
  if (A) {
9384
- ee || (ee = !0, console.debug("[FlowEngage] mic held — streaming silence to keep socket alive")), de = !1, fe = 0, pe = 0, n();
9384
+ ee || (ee = !0, console.debug("[FlowEngage] mic held — streaming silence to keep socket alive")), ce = !1, le = 0, ue = 0, n();
9385
9385
  return;
9386
9386
  }
9387
- let r = lh(t);
9388
- if (ce.isPlaying() || re ? (de = !1, fe = 0, pe = 0) : r >= oh ? (pe = 0, fe += 1, !de && fe >= sh && (de = !0, c?.({ mode: "user-speaking" }))) : (fe = 0, de && ++pe >= ch && (de = !1, pe = 0, c?.({
9389
- mode: "thinking",
9390
- tentative: !0
9391
- }))), (ce.isPlaying() || re) && !M) {
9392
- if (r < ie) j = 0;
9393
- else if (++j >= N) {
9394
- M = !0, j = 0;
9395
- let e = ce.playedMs();
9396
- ce.stop(), ne = !1, re = !1, P && !ae && (clearTimeout(P), P = null), oe = !1, C.send(JSON.stringify({
9397
- type: "VisitorInterrupted",
9398
- played_ms: Math.round(e)
9399
- })), console.debug("[FlowEngage] barge-in — visitor spoke over the agent");
9400
- }
9401
- }
9402
- C.send(uh(t).buffer);
9403
- }, le.connect(ue), ue.connect(_.destination);
9404
- let me = () => {
9387
+ let r = sh(t);
9388
+ ae.isPlaying() || M ? (ce = !1, le = 0, ue = 0) : r >= ih ? (ue = 0, le += 1, !ce && le >= ah && (ce = !0, c?.({ mode: "user-speaking" }))) : (le = 0, ce && ++ue >= oh && (ce = !1, ue = 0)), C.send(ch(t).buffer);
9389
+ }, oe.connect(se), se.connect(_.destination);
9390
+ let de = () => {
9405
9391
  if (!k) {
9406
- k = !0, P &&= (clearTimeout(P), null), D(), ce.stop(), typeof window < "u" && delete window.__fe_agentAudioPlaying;
9392
+ k = !0, N &&= (clearTimeout(N), null), D(), ae.stop(), typeof window < "u" && delete window.__fe_agentAudioPlaying;
9407
9393
  try {
9408
- ue.disconnect(), le.disconnect();
9394
+ se.disconnect(), oe.disconnect();
9409
9395
  } catch {}
9410
9396
  if (g.getTracks().forEach((e) => e.stop()), x && x.state !== "inactive") {
9411
- x.onstop = () => hh(t, n, S, b, y);
9397
+ x.onstop = () => ph(t, n, S, b, y);
9412
9398
  try {
9413
9399
  x.stop();
9414
9400
  } catch {
9415
9401
  x.onstop = null;
9416
9402
  }
9417
- } else b.length && hh(t, n, S, b, y);
9403
+ } else b.length && ph(t, n, S, b, y);
9418
9404
  _.close().catch(() => {}), (C.readyState === WebSocket.OPEN || C.readyState === WebSocket.CONNECTING) && C.close();
9419
9405
  }
9420
- }, he = async (e) => {
9406
+ }, fe = async (e) => {
9421
9407
  let t = i[e.name];
9422
9408
  if (!t) return u?.({ tool_name: e.name }), { error: `Unknown tool ${e.name}` };
9423
9409
  let n = {};
@@ -9429,10 +9415,10 @@ async function yh(e) {
9429
9415
  } catch (e) {
9430
9416
  return { error: e?.message || "Tool execution failed" };
9431
9417
  }
9432
- }, ge = async (e) => {
9418
+ }, pe = async (e) => {
9433
9419
  for (let t of e.functions || []) {
9434
9420
  if (!t.client_side) continue;
9435
- let e = await he(t);
9421
+ let e = await fe(t);
9436
9422
  if (k || C.readyState !== WebSocket.OPEN) return;
9437
9423
  C.send(JSON.stringify({
9438
9424
  type: "FunctionCallResponse",
@@ -9441,10 +9427,10 @@ async function yh(e) {
9441
9427
  content: typeof e == "string" ? e : JSON.stringify(e ?? {})
9442
9428
  }));
9443
9429
  }
9444
- }, F = (e) => {
9430
+ }, me = (e) => {
9445
9431
  switch (e.type) {
9446
9432
  case "Welcome":
9447
- Number.isFinite(e.barge_in_rms) && e.barge_in_rms > 0 && (ie = e.barge_in_rms), Number.isFinite(e.barge_in_frames) && e.barge_in_frames > 0 && (N = e.barge_in_frames), S = e.session_id || r || n || null, a?.({ conversationId: S });
9433
+ Number.isFinite(e.barge_in_rms) && e.barge_in_rms > 0 && 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 });
9448
9434
  break;
9449
9435
  case "ConversationText": {
9450
9436
  let t = String(e.content || "");
@@ -9463,28 +9449,28 @@ async function yh(e) {
9463
9449
  break;
9464
9450
  }
9465
9451
  case "UserStartedSpeaking":
9466
- D(), ce.stop(), re = !1, ne = !1, te = !1, P && !ae && (clearTimeout(P), P = null), oe = !1, c?.({ mode: "listening" });
9452
+ D(), ae.stop(), M = !1, j = !1, te = !1, ne = !1, N && !re && (clearTimeout(N), N = null), P = !1, c?.({ mode: "listening" });
9467
9453
  break;
9468
9454
  case "AgentStartedSpeaking":
9469
- ne = !0, te = !0, M = !1, j = 0, c?.({ mode: "speaking" });
9455
+ j = !0, te = !0, c?.({ mode: "speaking" });
9470
9456
  break;
9471
9457
  case "AgentAudioDone":
9472
- re = !1, D(), se(), ce.isPlaying() || (te = !1, c?.({ mode: "listening" }));
9458
+ M = !1, D(), ie(), ae.isPlaying() || (te = !1, c?.({ mode: ne ? "thinking" : "listening" }));
9473
9459
  break;
9474
9460
  case "FunctionCallRequest":
9475
- ge(e);
9461
+ pe(e);
9476
9462
  break;
9477
9463
  case "AgentPreparing":
9478
- re = !0;
9464
+ M = !0;
9479
9465
  break;
9480
9466
  case "AgentTurnComplete":
9481
- oe = !0, se();
9467
+ ne = !1, P = !0, ie();
9482
9468
  break;
9483
9469
  case "SessionEnding":
9484
- console.debug("[FlowEngage] server is ending the session:", e.reason || "unspecified"), ae = !0;
9470
+ console.debug("[FlowEngage] server is ending the session:", e.reason || "unspecified"), re = !0;
9485
9471
  break;
9486
9472
  case "AgentThinking":
9487
- c?.({ mode: "thinking" });
9473
+ ne = !0, c?.({ mode: "thinking" });
9488
9474
  break;
9489
9475
  case "PromptUpdated": break;
9490
9476
  case "Error":
@@ -9498,16 +9484,16 @@ async function yh(e) {
9498
9484
  };
9499
9485
  return C.onopen = () => C.send(JSON.stringify(h)), C.onmessage = (e) => {
9500
9486
  if (e.data instanceof ArrayBuffer) {
9501
- ne && ce.enqueue(new Int16Array(e.data));
9487
+ j && ae.enqueue(new Int16Array(e.data));
9502
9488
  return;
9503
9489
  }
9504
9490
  try {
9505
- F(JSON.parse(e.data));
9491
+ me(JSON.parse(e.data));
9506
9492
  } catch {}
9507
9493
  }, C.onerror = () => l?.(/* @__PURE__ */ Error("Voice connection failed")), C.onclose = () => {
9508
- me(), o?.();
9494
+ de(), o?.();
9509
9495
  }, {
9510
- endSession: async () => me(),
9496
+ endSession: async () => de(),
9511
9497
  sendContextualUpdate: (e) => {
9512
9498
  k || C.readyState !== WebSocket.OPEN || !e || C.send(JSON.stringify({
9513
9499
  type: "UpdatePrompt",
@@ -9545,7 +9531,7 @@ async function yh(e) {
9545
9531
  }
9546
9532
  };
9547
9533
  }
9548
- var bh = { startSession: yh }, xh = ({ size: e = 18, color: t = "currentColor" }) => /* @__PURE__ */ _("svg", {
9534
+ var vh = { startSession: _h }, yh = ({ size: e = 18, color: t = "currentColor" }) => /* @__PURE__ */ _("svg", {
9549
9535
  width: e,
9550
9536
  height: e,
9551
9537
  viewBox: "0 0 24 24",
@@ -9561,7 +9547,7 @@ var bh = { startSession: yh }, xh = ({ size: e = 18, color: t = "currentColor" }
9561
9547
  strokeLinecap: "round",
9562
9548
  strokeLinejoin: "round"
9563
9549
  })]
9564
- }), Sh = ({ size: e = 20 }) => /* @__PURE__ */ _("svg", {
9550
+ }), bh = ({ size: e = 20 }) => /* @__PURE__ */ _("svg", {
9565
9551
  width: e,
9566
9552
  height: e,
9567
9553
  viewBox: "0 0 24 24",
@@ -9576,7 +9562,7 @@ var bh = { startSession: yh }, xh = ({ size: e = 18, color: t = "currentColor" }
9576
9562
  x2: "1",
9577
9563
  y2: "23"
9578
9564
  })]
9579
- }), Ch = ({ size: e = 18 }) => /* @__PURE__ */ _("svg", {
9565
+ }), xh = ({ size: e = 18 }) => /* @__PURE__ */ _("svg", {
9580
9566
  width: e,
9581
9567
  height: e,
9582
9568
  viewBox: "0 0 24 24",
@@ -9591,7 +9577,7 @@ var bh = { startSession: yh }, xh = ({ size: e = 18, color: t = "currentColor" }
9591
9577
  x2: "12",
9592
9578
  y2: "5"
9593
9579
  }), /* @__PURE__ */ g("polyline", { points: "5 12 12 5 19 12" })]
9594
- }), wh = () => /* @__PURE__ */ _("svg", {
9580
+ }), Sh = () => /* @__PURE__ */ _("svg", {
9595
9581
  width: "14",
9596
9582
  height: "14",
9597
9583
  viewBox: "0 0 24 24",
@@ -9601,7 +9587,7 @@ var bh = { startSession: yh }, xh = ({ size: e = 18, color: t = "currentColor" }
9601
9587
  strokeLinecap: "round",
9602
9588
  strokeLinejoin: "round",
9603
9589
  children: [/* @__PURE__ */ g("polyline", { points: "9 17 4 12 9 7" }), /* @__PURE__ */ g("path", { d: "M20 18v-2a4 4 0 00-4-4H4" })]
9604
- }), Th = () => /* @__PURE__ */ g("svg", {
9590
+ }), Ch = () => /* @__PURE__ */ g("svg", {
9605
9591
  width: "18",
9606
9592
  height: "18",
9607
9593
  viewBox: "0 0 24 24",
@@ -9611,7 +9597,7 @@ var bh = { startSession: yh }, xh = ({ size: e = 18, color: t = "currentColor" }
9611
9597
  strokeLinecap: "round",
9612
9598
  strokeLinejoin: "round",
9613
9599
  children: /* @__PURE__ */ g("path", { d: "M22 16.92v3a2 2 0 01-2.18 2 19.79 19.79 0 01-8.63-3.07 19.42 19.42 0 01-6.12-6.11A19.79 19.79 0 012 4.11 2 2 0 014.11 2h3a2 2 0 012 1.72c.13.96.37 1.91.71 2.81a2 2 0 01-.45 2.11L8.09 9.91a16 16 0 006 6l1.27-1.27a2 2 0 012.11-.45c.9.34 1.85.58 2.81.71A2 2 0 0122 16.92z" })
9614
- }), Eh = ({ className: e = "" }) => /* @__PURE__ */ _("svg", {
9600
+ }), wh = ({ className: e = "" }) => /* @__PURE__ */ _("svg", {
9615
9601
  className: e,
9616
9602
  width: "14",
9617
9603
  height: "14",
@@ -9640,7 +9626,7 @@ var bh = { startSession: yh }, xh = ({ size: e = 18, color: t = "currentColor" }
9640
9626
  y2: "16"
9641
9627
  })
9642
9628
  ]
9643
- }), Dh = ({ size: e = 14 }) => /* @__PURE__ */ _("svg", {
9629
+ }), Th = ({ size: e = 14 }) => /* @__PURE__ */ _("svg", {
9644
9630
  width: e,
9645
9631
  height: e,
9646
9632
  viewBox: "0 0 24 24",
@@ -9663,7 +9649,7 @@ var bh = { startSession: yh }, xh = ({ size: e = 18, color: t = "currentColor" }
9663
9649
  /* @__PURE__ */ g("path", { d: "M15 13v2" }),
9664
9650
  /* @__PURE__ */ g("path", { d: "M9 13v2" })
9665
9651
  ]
9666
- }), Oh = ({ size: e = 20, strokeWidth: t = 2, color: n = "currentColor" }) => /* @__PURE__ */ _("svg", {
9652
+ }), Eh = ({ size: e = 20, strokeWidth: t = 2, color: n = "currentColor" }) => /* @__PURE__ */ _("svg", {
9667
9653
  width: e,
9668
9654
  height: e,
9669
9655
  viewBox: "0 0 24 24",
@@ -9683,7 +9669,7 @@ var bh = { startSession: yh }, xh = ({ size: e = 18, color: t = "currentColor" }
9683
9669
  x2: "19",
9684
9670
  y2: "12"
9685
9671
  })]
9686
- }), kh = ({ size: e = 20, color: t = "currentColor" }) => /* @__PURE__ */ _("svg", {
9672
+ }), Dh = ({ size: e = 20, color: t = "currentColor" }) => /* @__PURE__ */ _("svg", {
9687
9673
  width: e,
9688
9674
  height: e,
9689
9675
  viewBox: "0 0 24 24",
@@ -9709,7 +9695,7 @@ var bh = { startSession: yh }, xh = ({ size: e = 18, color: t = "currentColor" }
9709
9695
  fill: t
9710
9696
  })
9711
9697
  ]
9712
- }), Ah = ({ size: e = 20, color: t = "currentColor" }) => /* @__PURE__ */ _("svg", {
9698
+ }), Oh = ({ size: e = 20, color: t = "currentColor" }) => /* @__PURE__ */ _("svg", {
9713
9699
  width: "24",
9714
9700
  height: "24",
9715
9701
  viewBox: "0 0 24 24",
@@ -9727,7 +9713,7 @@ var bh = { startSession: yh }, xh = ({ size: e = 18, color: t = "currentColor" }
9727
9713
  "stroke-linecap": "round",
9728
9714
  "stroke-linejoin": "round"
9729
9715
  })]
9730
- }), jh = () => /* @__PURE__ */ g("svg", {
9716
+ }), kh = () => /* @__PURE__ */ g("svg", {
9731
9717
  width: "24",
9732
9718
  height: "24",
9733
9719
  viewBox: "0 0 24 24",
@@ -9739,7 +9725,7 @@ var bh = { startSession: yh }, xh = ({ size: e = 18, color: t = "currentColor" }
9739
9725
  "stroke-width": "1.5",
9740
9726
  "stroke-linejoin": "round"
9741
9727
  })
9742
- }), Mh = ({ size: e = 24 }) => /* @__PURE__ */ _("svg", {
9728
+ }), Ah = ({ size: e = 24 }) => /* @__PURE__ */ _("svg", {
9743
9729
  xmlns: "http://www.w3.org/2000/svg",
9744
9730
  width: e,
9745
9731
  height: e,
@@ -9757,7 +9743,7 @@ var bh = { startSession: yh }, xh = ({ size: e = 18, color: t = "currentColor" }
9757
9743
  /* @__PURE__ */ g("path", { d: "m2 2 20 20" }),
9758
9744
  /* @__PURE__ */ g("path", { d: "M9 9v3a3 3 0 0 0 5.12 2.12" })
9759
9745
  ]
9760
- }), Nh = (e = "") => String(e).replace(/<[^>]+>/g, "").replace(/\s+/g, " ").trim(), Ph = (e = "") => String(e).replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;"), Fh = new Set([
9746
+ }), jh = (e = "") => String(e).replace(/<[^>]+>/g, "").replace(/\s+/g, " ").trim(), Mh = (e = "") => String(e).replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;"), Nh = new Set([
9761
9747
  "p",
9762
9748
  "br",
9763
9749
  "ul",
@@ -9768,30 +9754,30 @@ var bh = { startSession: yh }, xh = ({ size: e = 18, color: t = "currentColor" }
9768
9754
  "b",
9769
9755
  "i",
9770
9756
  "a"
9771
- ]), Ih = /^https?:\/\//i;
9772
- function Lh(e) {
9757
+ ]), Ph = /^https?:\/\//i;
9758
+ function Fh(e) {
9773
9759
  let t = Array.from(e.childNodes);
9774
9760
  for (let n of t) if (n.nodeType === Node.ELEMENT_NODE) {
9775
9761
  let t = n.tagName.toLowerCase();
9776
- if (!Fh.has(t)) {
9762
+ if (!Nh.has(t)) {
9777
9763
  e.replaceChild(document.createTextNode(n.textContent), n);
9778
9764
  continue;
9779
9765
  }
9780
9766
  let r = {};
9781
9767
  if (t === "a") {
9782
9768
  let e = n.getAttribute("href") || "";
9783
- Ih.test(e) && (r.href = e), r.target = "_blank", r.rel = "noopener noreferrer";
9769
+ Ph.test(e) && (r.href = e), r.target = "_blank", r.rel = "noopener noreferrer";
9784
9770
  }
9785
9771
  for (; n.attributes.length > 0;) n.removeAttribute(n.attributes[0].name);
9786
9772
  for (let [e, t] of Object.entries(r)) n.setAttribute(e, t);
9787
- Lh(n);
9773
+ Fh(n);
9788
9774
  } else n.nodeType !== Node.TEXT_NODE && e.removeChild(n);
9789
9775
  }
9790
- function Rh(e) {
9776
+ function Ih(e) {
9791
9777
  let t = document.createElement("div");
9792
- return t.innerHTML = e, Lh(t), t.innerHTML;
9778
+ return t.innerHTML = e, Fh(t), t.innerHTML;
9793
9779
  }
9794
- function zh(e) {
9780
+ function Lh(e) {
9795
9781
  let t = String(e || "").trim();
9796
9782
  if (!t) return t;
9797
9783
  let n = /^<p>\s*<strong>([\s\S]*?)<\/strong>\s*<\/p>$/i.exec(t);
@@ -9803,33 +9789,33 @@ function zh(e) {
9803
9789
  }
9804
9790
  return e;
9805
9791
  }
9806
- var Bh = (e = "") => {
9792
+ var Rh = (e = "") => {
9807
9793
  let t = String(e || "").trim();
9808
9794
  if (!t) return "";
9809
- if (/<(p|br|ul|ol|li|strong|em|a)\b/i.test(t)) return zh(Rh(t));
9810
- let n = t.replace(/\r\n/g, "\n").replace(/\n{3,}/g, "\n\n").split(/\n\s*\n/).map((e) => e.trim()).filter(Boolean), r = (e) => Ph(e).replace(/\[([^\]]+)\]\((https?:\/\/[^\s)]+)\)/g, "<a href=\"$2\" target=\"_blank\" rel=\"noopener noreferrer\">$1</a>").replace(/\*\*([^*]+)\*\*/g, "<strong>$1</strong>").replace(/\*([^*\n]+)\*/g, "<em>$1</em>");
9811
- return zh(n.map((e) => {
9795
+ if (/<(p|br|ul|ol|li|strong|em|a)\b/i.test(t)) return Lh(Ih(t));
9796
+ let n = t.replace(/\r\n/g, "\n").replace(/\n{3,}/g, "\n\n").split(/\n\s*\n/).map((e) => e.trim()).filter(Boolean), r = (e) => Mh(e).replace(/\[([^\]]+)\]\((https?:\/\/[^\s)]+)\)/g, "<a href=\"$2\" target=\"_blank\" rel=\"noopener noreferrer\">$1</a>").replace(/\*\*([^*]+)\*\*/g, "<strong>$1</strong>").replace(/\*([^*\n]+)\*/g, "<em>$1</em>");
9797
+ return Lh(n.map((e) => {
9812
9798
  let t = e.split("\n").map((e) => e.trim()).filter(Boolean), n = t.filter((e) => /^[-*]\s+/.test(e));
9813
9799
  if (n.length >= 2 && n.length === t.length) return `<ul>${n.map((e) => `<li>${r(e.replace(/^[-*]\s+/, ""))}</li>`).join("")}</ul>`;
9814
9800
  let i = e.split(/\s+(?=[-*]\s+\*\*?)/).map((e) => e.trim()).filter(Boolean);
9815
9801
  return i.length >= 2 && i.every((e) => /^[-*]\s+/.test(e)) ? `<ul>${i.map((e) => `<li>${r(e.replace(/^[-*]\s+/, ""))}</li>`).join("")}</ul>` : `<p>${r(e).replace(/\n/g, "<br />")}</p>`;
9816
9802
  }).join(""));
9817
- }, Vh = new Set(["application/pdf", "application/vnd.openxmlformats-officedocument.wordprocessingml.document"]), Hh = new Set([
9803
+ }, zh = new Set(["application/pdf", "application/vnd.openxmlformats-officedocument.wordprocessingml.document"]), Bh = new Set([
9818
9804
  ".pdf",
9819
9805
  ".docx",
9820
9806
  ".png",
9821
9807
  ".jpg",
9822
9808
  ".jpeg"
9823
- ]), Uh = "image/png,image/jpeg,.pdf,.docx";
9824
- function Wh(e) {
9809
+ ]), Vh = "image/png,image/jpeg,.pdf,.docx";
9810
+ function Hh(e) {
9825
9811
  if (!e) return !1;
9826
9812
  let t = typeof e.name == "string" ? e.name.toLowerCase() : "", n = t.includes(".") ? `.${t.split(".").pop()}` : "", r = typeof e.type == "string" ? e.type.toLowerCase() : "";
9827
- return r === "image/png" || r === "image/jpeg" || Vh.has(r) || Hh.has(n);
9813
+ return r === "image/png" || r === "image/jpeg" || zh.has(r) || Bh.has(n);
9828
9814
  }
9829
- function Gh(e) {
9830
- return e ? Wh(e) ? e.size > 2097152 ? "File must be 2 MB or smaller." : "" : "Only PNG, JPEG, PDF, and DOCX files are allowed." : "No file selected.";
9815
+ function Uh(e) {
9816
+ return e ? Hh(e) ? e.size > 2097152 ? "File must be 2 MB or smaller." : "" : "Only PNG, JPEG, PDF, and DOCX files are allowed." : "No file selected.";
9831
9817
  }
9832
- function Kh(e = 0) {
9818
+ function Wh(e = 0) {
9833
9819
  if (!Number.isFinite(e) || e <= 0) return "";
9834
9820
  let t = [
9835
9821
  "B",
@@ -9841,12 +9827,12 @@ function Kh(e = 0) {
9841
9827
  let i = n >= 10 || r === 0 ? 0 : 1;
9842
9828
  return `${n.toFixed(i)} ${t[r]}`;
9843
9829
  }
9844
- function qh(e) {
9830
+ function Gh(e) {
9845
9831
  return e ? e.name || "Attachment" : "";
9846
9832
  }
9847
9833
  //#endregion
9848
9834
  //#region src/utils/avatarHelpers.js
9849
- function Jh(e) {
9835
+ function Kh(e) {
9850
9836
  if (!e || typeof e != "string") return "?";
9851
9837
  let t = e.trim();
9852
9838
  if (!t) return "?";
@@ -9855,7 +9841,7 @@ function Jh(e) {
9855
9841
  }
9856
9842
  //#endregion
9857
9843
  //#region src/components/AvatarImageOrInitials.jsx
9858
- function Yh({ src: e, name: t, imgStyle: n, initialsSpanStyle: r }) {
9844
+ function qh({ src: e, name: t, imgStyle: n, initialsSpanStyle: r }) {
9859
9845
  let [i, a] = m(null), o = typeof e == "string" ? e.trim() : "";
9860
9846
  return c(() => {
9861
9847
  if (!o) {
@@ -9878,12 +9864,12 @@ function Yh({ src: e, name: t, imgStyle: n, initialsSpanStyle: r }) {
9878
9864
  onError: () => a(null)
9879
9865
  }) : /* @__PURE__ */ g("span", {
9880
9866
  style: r,
9881
- children: Jh(t)
9867
+ children: Kh(t)
9882
9868
  });
9883
9869
  }
9884
9870
  //#endregion
9885
9871
  //#region src/components/MessageList.jsx
9886
- function Xh({ chatHistory: e, isAiTyping: t, isLoading: n, isAgentTyping: r, setReplyContext: i, primaryColor: a = "#3B82F6", agentHeadshot: s = null, agentDisplayName: l = "Agent", botAvatarNode: u = null }) {
9872
+ function Jh({ chatHistory: e, isAiTyping: t, isLoading: n, isAgentTyping: r, setReplyContext: i, primaryColor: a = "#3B82F6", agentHeadshot: s = null, agentDisplayName: l = "Agent", botAvatarNode: u = null }) {
9887
9873
  let { resolvedConfig: d } = Cn(), f = p(null), [v, y] = m(null), [b, x] = m(null), S = p(e.length), C = p(!0), w = p(null), T = o((e) => {
9888
9874
  let t = e.target.closest("a[href]");
9889
9875
  if (!t) return;
@@ -9938,7 +9924,7 @@ function Xh({ chatHistory: e, isAiTyping: t, isLoading: n, isAgentTyping: r, set
9938
9924
  children: [
9939
9925
  e.map((e) => {
9940
9926
  if (e.type === "call_recording" || typeof e.message == "string" && e.message.includes("AI chat recording")) return null;
9941
- let t = e.sender === "system", n = e.sender === "user", r = e.sender === "ai" || e.sender === "bot", o = e.sender === "agent", c = e.isPending, d = e.type === "file" && e.metadata?.fileUrl, f = e.agent_name || e.agentName || e.metadata?.agentName || l, p = typeof e.sender_headshot == "string" && e.sender_headshot.trim() || typeof s == "string" && s.trim() || null, m = Nh(e.replyToContent || e.replyContext?.message || ""), v = e.replyToSender === "user" ? "You" : e.replyToSender === "agent" ? "Agent" : e.replyToSender === "ai" || e.replyToSender === "bot" ? "AI Assistant" : "Message";
9927
+ let t = e.sender === "system", n = e.sender === "user", r = e.sender === "ai" || e.sender === "bot", o = e.sender === "agent", c = e.isPending, d = e.type === "file" && e.metadata?.fileUrl, f = e.agent_name || e.agentName || e.metadata?.agentName || l, p = typeof e.sender_headshot == "string" && e.sender_headshot.trim() || typeof s == "string" && s.trim() || null, m = jh(e.replyToContent || e.replyContext?.message || ""), v = e.replyToSender === "user" ? "You" : e.replyToSender === "agent" ? "Agent" : e.replyToSender === "ai" || e.replyToSender === "bot" ? "AI Assistant" : "Message";
9942
9928
  return t ? /* @__PURE__ */ g("div", {
9943
9929
  style: {
9944
9930
  display: "flex",
@@ -9983,7 +9969,7 @@ function Xh({ chatHistory: e, isAiTyping: t, isLoading: n, isAgentTyping: r, set
9983
9969
  fontWeight: 800,
9984
9970
  marginTop: !c && (r || o) ? "22px" : "0px"
9985
9971
  },
9986
- children: r ? u || /* @__PURE__ */ g(Dh, { size: 16 }) : /* @__PURE__ */ g(Yh, {
9972
+ children: r ? u || /* @__PURE__ */ g(Th, { size: 16 }) : /* @__PURE__ */ g(qh, {
9987
9973
  src: p || "",
9988
9974
  name: f,
9989
9975
  imgStyle: {
@@ -10025,7 +10011,7 @@ function Xh({ chatHistory: e, isAiTyping: t, isLoading: n, isAgentTyping: r, set
10025
10011
  onMouseLeave: (e) => {
10026
10012
  e.currentTarget.style.color = "#9ca3af";
10027
10013
  },
10028
- children: [/* @__PURE__ */ g(wh, {}), "Reply"]
10014
+ children: [/* @__PURE__ */ g(Sh, {}), "Reply"]
10029
10015
  }),
10030
10016
  /* @__PURE__ */ _("div", {
10031
10017
  style: {
@@ -10069,7 +10055,7 @@ function Xh({ chatHistory: e, isAiTyping: t, isLoading: n, isAgentTyping: r, set
10069
10055
  children: m
10070
10056
  })]
10071
10057
  }), d ? (() => {
10072
- let t = e.metadata.fileType || "", r = e.metadata.fileName || e.message || "File", i = Kh(e.metadata.fileSize), a = t.startsWith("image/"), o = `shared file: ${r}`.toLowerCase(), s = (e.message || "").trim(), c = s && s.toLowerCase() !== o && !s.toLowerCase().startsWith("shared file:"), l = t === "application/pdf" ? {
10058
+ let t = e.metadata.fileType || "", r = e.metadata.fileName || e.message || "File", i = Wh(e.metadata.fileSize), a = t.startsWith("image/"), o = `shared file: ${r}`.toLowerCase(), s = (e.message || "").trim(), c = s && s.toLowerCase() !== o && !s.toLowerCase().startsWith("shared file:"), l = t === "application/pdf" ? {
10073
10059
  color: "#ef4444",
10074
10060
  label: "PDF"
10075
10061
  } : t.includes("word") || t.includes("docx") ? {
@@ -10250,7 +10236,7 @@ function Xh({ chatHistory: e, isAiTyping: t, isLoading: n, isAgentTyping: r, set
10250
10236
  });
10251
10237
  })() : r ? /* @__PURE__ */ g("div", {
10252
10238
  className: "flowengage-message-content fe-bot-message",
10253
- dangerouslySetInnerHTML: { __html: Bh(e.message) },
10239
+ dangerouslySetInnerHTML: { __html: Rh(e.message) },
10254
10240
  onClick: T
10255
10241
  }) : /* @__PURE__ */ g("div", {
10256
10242
  style: { whiteSpace: "pre-wrap" },
@@ -10315,7 +10301,7 @@ function Xh({ chatHistory: e, isAiTyping: t, isLoading: n, isAgentTyping: r, set
10315
10301
  boxShadow: u ? "none" : "0 8px 20px rgba(59,130,246,0.24)",
10316
10302
  overflow: "hidden"
10317
10303
  },
10318
- children: u || /* @__PURE__ */ g(Dh, { size: 16 })
10304
+ children: u || /* @__PURE__ */ g(Th, { size: 16 })
10319
10305
  }), /* @__PURE__ */ _("div", {
10320
10306
  style: {
10321
10307
  display: "flex",
@@ -10357,7 +10343,7 @@ function Xh({ chatHistory: e, isAiTyping: t, isLoading: n, isAgentTyping: r, set
10357
10343
  borderRadius: "50%",
10358
10344
  overflow: "hidden"
10359
10345
  },
10360
- children: /* @__PURE__ */ g(Yh, {
10346
+ children: /* @__PURE__ */ g(qh, {
10361
10347
  src: s || "",
10362
10348
  name: l,
10363
10349
  imgStyle: {
@@ -10451,22 +10437,22 @@ function Xh({ chatHistory: e, isAiTyping: t, isLoading: n, isAgentTyping: r, set
10451
10437
  }
10452
10438
  //#endregion
10453
10439
  //#region src/components/ChatInput.jsx
10454
- var Zh = typeof window < "u" && (window.matchMedia?.("(pointer: coarse)").matches || navigator.maxTouchPoints > 0);
10455
- function Qh({ input: e, setInput: t, onSubmit: n, isConversationEnded: r, callUiActive: i, handleToggleVoice: a, activeScreen: o, inputDisabled: s, replyContext: l, clearReplyContext: u, requiresEmail: d, emailInput: f, setEmailInput: m, emailError: v, showVoiceToggle: y = !1, voiceEnabled: b = !0, onFileSelect: x, selectedFile: S = null, onRemoveSelectedFile: C, attachmentError: w = "", isUploadingAttachment: T = !1, inputPlaceholder: E = "Type your message" }) {
10440
+ var Yh = typeof window < "u" && (window.matchMedia?.("(pointer: coarse)").matches || navigator.maxTouchPoints > 0);
10441
+ function Xh({ input: e, setInput: t, onSubmit: n, isConversationEnded: r, callUiActive: i, handleToggleVoice: a, activeScreen: o, inputDisabled: s, replyContext: l, clearReplyContext: u, requiresEmail: d, emailInput: f, setEmailInput: m, emailError: v, showVoiceToggle: y = !1, voiceEnabled: b = !0, onFileSelect: x, selectedFile: S = null, onRemoveSelectedFile: C, attachmentError: w = "", isUploadingAttachment: T = !1, inputPlaceholder: E = "Type your message" }) {
10456
10442
  let D = p(null), O = p(null), k = (e) => {
10457
10443
  e && (e.style.height = "auto", e.style.height = `${Math.min(e.scrollHeight, 120)}px`);
10458
10444
  };
10459
10445
  c(() => {
10460
10446
  d || k(O.current);
10461
10447
  }, [e, d]), c(() => {
10462
- d || Zh || e || s || O.current?.focus();
10448
+ d || Yh || e || s || O.current?.focus();
10463
10449
  }, [
10464
10450
  e,
10465
10451
  d,
10466
10452
  s
10467
10453
  ]);
10468
10454
  let A = (e) => {
10469
- e.key === "Enter" && (Zh || e.shiftKey || e.altKey || e.ctrlKey || e.metaKey || (e.preventDefault(), e.currentTarget.form?.requestSubmit()));
10455
+ e.key === "Enter" && (Yh || e.shiftKey || e.altKey || e.ctrlKey || e.metaKey || (e.preventDefault(), e.currentTarget.form?.requestSubmit()));
10470
10456
  }, ee = l?.sender === "user" ? "You" : l?.sender === "agent" ? "Agent" : "AI Assistant", te = d ? !!f?.trim() : !!e?.trim() || !!S, ne = s || T || !te, j = !d && b && y;
10471
10457
  return /* @__PURE__ */ _("div", {
10472
10458
  style: {
@@ -10561,7 +10547,7 @@ function Qh({ input: e, setInput: t, onSubmit: n, isConversationEnded: r, callUi
10561
10547
  background: "rgba(59,130,246,0.08)",
10562
10548
  color: "var(--flowengage-primary)"
10563
10549
  },
10564
- children: /* @__PURE__ */ g(Dh, { size: 13 })
10550
+ children: /* @__PURE__ */ g(Th, { size: 13 })
10565
10551
  }), /* @__PURE__ */ g("span", { children: "Please provide your email address so we can help you." })]
10566
10552
  })
10567
10553
  }),
@@ -10601,7 +10587,7 @@ function Qh({ input: e, setInput: t, onSubmit: n, isConversationEnded: r, callUi
10601
10587
  overflow: "hidden",
10602
10588
  textOverflow: "ellipsis"
10603
10589
  },
10604
- children: qh(S)
10590
+ children: Gh(S)
10605
10591
  }),
10606
10592
  /* @__PURE__ */ g("div", {
10607
10593
  style: {
@@ -10609,7 +10595,7 @@ function Qh({ input: e, setInput: t, onSubmit: n, isConversationEnded: r, callUi
10609
10595
  color: "#6b7280",
10610
10596
  marginTop: "2px"
10611
10597
  },
10612
- children: Kh(S.size)
10598
+ children: Wh(S.size)
10613
10599
  })
10614
10600
  ]
10615
10601
  }), /* @__PURE__ */ g("button", {
@@ -10654,7 +10640,7 @@ function Qh({ input: e, setInput: t, onSubmit: n, isConversationEnded: r, callUi
10654
10640
  j ? /* @__PURE__ */ _(h, { children: [/* @__PURE__ */ g("input", {
10655
10641
  ref: D,
10656
10642
  type: "file",
10657
- accept: Uh,
10643
+ accept: Vh,
10658
10644
  style: { display: "none" },
10659
10645
  onChange: (e) => {
10660
10646
  let t = e.target.files?.[0];
@@ -10686,7 +10672,7 @@ function Qh({ input: e, setInput: t, onSubmit: n, isConversationEnded: r, callUi
10686
10672
  onMouseLeave: (e) => {
10687
10673
  e.currentTarget.style.opacity = "1";
10688
10674
  },
10689
- children: /* @__PURE__ */ g(Oh, {
10675
+ children: /* @__PURE__ */ g(Eh, {
10690
10676
  size: 16,
10691
10677
  color: "currentColor"
10692
10678
  })
@@ -10767,7 +10753,7 @@ function Qh({ input: e, setInput: t, onSubmit: n, isConversationEnded: r, callUi
10767
10753
  onMouseLeave: (e) => {
10768
10754
  e.currentTarget.style.opacity = "1";
10769
10755
  },
10770
- children: /* @__PURE__ */ g(Ch, { size: 16 })
10756
+ children: /* @__PURE__ */ g(xh, { size: 16 })
10771
10757
  })
10772
10758
  ]
10773
10759
  }),
@@ -10830,7 +10816,7 @@ function Qh({ input: e, setInput: t, onSubmit: n, isConversationEnded: r, callUi
10830
10816
  }
10831
10817
  //#endregion
10832
10818
  //#region src/components/StatusBanners.jsx
10833
- function $h({ webRTCError: e, micError: t, setMicError: n, dismissCallError: r, isRateLimited: i, rateLimitMessage: a }) {
10819
+ function Zh({ webRTCError: e, micError: t, setMicError: n, dismissCallError: r, isRateLimited: i, rateLimitMessage: a }) {
10834
10820
  return /* @__PURE__ */ _(h, { children: [(e || t) && /* @__PURE__ */ _("div", {
10835
10821
  style: {
10836
10822
  margin: "0 20px 10px",
@@ -10843,7 +10829,7 @@ function $h({ webRTCError: e, micError: t, setMicError: n, dismissCallError: r,
10843
10829
  gap: "10px"
10844
10830
  },
10845
10831
  children: [
10846
- /* @__PURE__ */ g(Eh, { className: "" }),
10832
+ /* @__PURE__ */ g(wh, { className: "" }),
10847
10833
  /* @__PURE__ */ g("span", {
10848
10834
  style: {
10849
10835
  fontSize: "12px",
@@ -10889,13 +10875,13 @@ function $h({ webRTCError: e, micError: t, setMicError: n, dismissCallError: r,
10889
10875
  }
10890
10876
  //#endregion
10891
10877
  //#region src/components/AnimatedOrb.jsx
10892
- var eg = [
10878
+ var Qh = [
10893
10879
  "#135bd8",
10894
10880
  "#ef334b",
10895
10881
  "#ffbd2e"
10896
10882
  ];
10897
- function tg(e) {
10898
- return !Array.isArray(e) || e.length === 0 ? eg : e.length === 1 ? [
10883
+ function $h(e) {
10884
+ return !Array.isArray(e) || e.length === 0 ? Qh : e.length === 1 ? [
10899
10885
  e[0],
10900
10886
  e[0],
10901
10887
  e[0]
@@ -10909,7 +10895,7 @@ function tg(e) {
10909
10895
  e[2]
10910
10896
  ];
10911
10897
  }
10912
- var ng = {
10898
+ var eg = {
10913
10899
  idle: 3,
10914
10900
  listening: .75,
10915
10901
  thinking: 1,
@@ -10917,7 +10903,7 @@ var ng = {
10917
10903
  muted: .75,
10918
10904
  error: .08
10919
10905
  };
10920
- function rg(e) {
10906
+ function tg(e) {
10921
10907
  if (!e || typeof e != "string") return [
10922
10908
  0,
10923
10909
  0,
@@ -10930,14 +10916,14 @@ function rg(e) {
10930
10916
  parseInt(n.slice(4, 6), 16) / 255
10931
10917
  ];
10932
10918
  }
10933
- function ig(e, t) {
10919
+ function ng(e, t) {
10934
10920
  if (!e || typeof e != "string") return `rgba(0,0,0,${t})`;
10935
10921
  if (e.startsWith("rgb")) return e.replace(/[\d.]+\)$/, `${t})`);
10936
10922
  let n = e.replace("#", ""), r = n.length === 3 ? n.split("").map((e) => e + e).join("") : n;
10937
10923
  return `rgba(${parseInt(r.slice(0, 2), 16)},${parseInt(r.slice(2, 4), 16)},${parseInt(r.slice(4, 6), 16)},${t})`;
10938
10924
  }
10939
- var ag = "\n attribute vec2 a_pos;\n varying vec2 v_uv;\n void main() {\n v_uv = a_pos * 0.5 + 0.5;\n gl_Position = vec4(a_pos, 0.0, 1.0);\n }\n", og = "\n precision highp float;\n\n varying vec2 v_uv;\n uniform float u_time;\n uniform float u_speed;\n uniform vec3 u_c1;\n uniform vec3 u_c2;\n uniform vec3 u_c3;\n\n // ── Gradient noise ─────────────────────────────────────────────────────────\n vec2 hash2(vec2 p) {\n p = vec2(dot(p, vec2(127.1, 311.7)), dot(p, vec2(269.5, 183.3)));\n return -1.0 + 2.0 * fract(sin(p) * 43758.5453123);\n }\n float gnoise(vec2 p) {\n vec2 i = floor(p), f = fract(p);\n vec2 u = f*f*f*(f*(f*6.0-15.0)+10.0);\n return mix(\n mix(dot(hash2(i), f),\n dot(hash2(i+vec2(1,0)), f-vec2(1,0)), u.x),\n mix(dot(hash2(i+vec2(0,1)), f-vec2(0,1)),\n dot(hash2(i+vec2(1,1)), f-vec2(1,1)), u.x),\n u.y\n ) * 0.5 + 0.5;\n }\n\n // ── 3-octave FBM normalised to [0,1] — fewer octaves → larger, softer blobs\n float fbm(vec2 p) {\n float v = 0.0, a = 0.5;\n for (int i = 0; i < 3; i++) {\n v += a * gnoise(p);\n p = p * 2.1 + vec2(100.0);\n a *= 0.5;\n }\n return v / 0.875;\n }\n\n // ── Scalar hash for grain ──────────────────────────────────────────────────\n float hash1(vec2 p) {\n return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453);\n }\n\n void main() {\n vec2 uv = v_uv;\n float t = u_time * u_speed + 47.3;\n\n // ── ① Two-level domain warp — deep organic folding and swirling ───────────\n // First pass: large-scale sweep\n vec2 q = vec2(\n fbm(uv * 1.8 + vec2( t * 0.13, t * 0.11)) * 2.0 - 1.0,\n fbm(uv * 1.8 + vec2( t * 0.11 + 3.7, -t * 0.14 + 1.1)) * 2.0 - 1.0\n );\n // Second pass: warp the warp — creates curling, folding sub-currents\n vec2 r = vec2(\n fbm(uv * 1.8 + q * 0.55 + vec2( t * 0.09, t * 0.07)) * 2.0 - 1.0,\n fbm(uv * 1.8 + q * 0.55 + vec2(-t * 0.07 + 5.1, t * 0.10 + 2.3)) * 2.0 - 1.0\n );\n vec2 wp = uv + r * 0.38;\n\n // ── ② Three independent fields — each drifts inward from its source edge ──\n // Asymmetric velocities: dominant axis matches the inflow direction so the\n // noise texture visually streams inward (left→right, right→left, bottom→top).\n float f1 = fbm(wp * 0.85 + vec2(-t * 0.18, t * 0.04)); // LEFT → right\n float f2 = fbm(wp * 0.85 + vec2( t * 0.18 + 5.3, t * 0.04 + 1.7)); // RIGHT → left\n float f3 = fbm(wp * 0.85 + vec2( t * 0.04 - 3.2, -t * 0.18 + 6.4)); // BOTTOM → up\n\n // ── ③ Breathing blobs — sin pulse makes each field expand and contract ────\n float p1 = 0.88 + 0.12 * sin(t * 0.61);\n float p2 = 0.88 + 0.12 * sin(t * 0.47 + 2.09);\n float p3 = 0.88 + 0.12 * sin(t * 0.53 + 4.19);\n\n // Wide smoothstep (0.26 → 0.70) → soft, diffused blob edges that dissolve\n // gradually into each other, like dye spreading through water.\n float b1 = smoothstep(0.26, 0.70, f1 * p1);\n float b2 = smoothstep(0.26, 0.70, f2 * p2);\n float b3 = smoothstep(0.26, 0.70, f3 * p3);\n\n // ── ④ Directional origin gradients.\n // Each color owns its home edge (value = 1.0) and smoothly fades to zero\n // before reaching the opposite side. The transition windows are offset so\n // they overlap only in the center third — that overlap zone is where the\n // three colors meet and blend, while the edges stay uncontaminated.\n float d1 = 1.0 - smoothstep(0.20, 0.74, uv.x); // c1: LEFT → full at x<0.20, zero by x=0.74\n float d2 = 1.0 - smoothstep(0.20, 0.74, 1.0 - uv.x); // c2: RIGHT → full at x>0.80, zero by x=0.26\n float d3 = 1.0 - smoothstep(0.18, 0.68, uv.y); // c3: BOTTOM → full at y<0.18, zero by y=0.68\n\n float w1 = b1 * d1;\n float w2 = b2 * d2;\n float w3 = b3 * d3;\n\n // ── ⑤ Dye-mixing colour blend ──────────────────────────────────────────────\n // dyeColor is the weighted average of all active colours — exactly how dyes\n // mix in water: overlapping streams blend smoothly, no hard edges.\n float total = w1 + w2 + w3;\n vec3 dyeColor = (u_c1 * w1 + u_c2 * w2 + u_c3 * w3) / max(total, 0.001);\n\n // Boost brightness of the dye to make colors pop and seem less dull\n dyeColor *= 1.65;\n\n // Exponential coverage: cores are rich and opaque; edges dissolve into the\n // near-white base. White only shows through where dye concentration is thin.\n float coverage = 1.0 - exp(-total * 5.0);\n vec3 col = mix(vec3(1.0, 1.0, 1.0), dyeColor, coverage);\n col = clamp(col, 0.0, 1.0);\n\n // ── ⑥ Sphere shading — subtle edge vignette only, no specular ─────────────\n vec2 uvc = v_uv * 2.0 - 1.0;\n\n // ── ⑦ Subtle grain — breaks gradient banding, adds filmic texture ──────────\n float grain = hash1(v_uv * 437.3 + fract(t)) * 2.0 - 1.0;\n col += grain * 0.018;\n\n gl_FragColor = vec4(clamp(col, 0.0, 1.0), 1.0);\n }\n";
10940
- function sg(e, t, n) {
10925
+ var rg = "\n attribute vec2 a_pos;\n varying vec2 v_uv;\n void main() {\n v_uv = a_pos * 0.5 + 0.5;\n gl_Position = vec4(a_pos, 0.0, 1.0);\n }\n", ig = "\n precision highp float;\n\n varying vec2 v_uv;\n uniform float u_time;\n uniform float u_speed;\n uniform vec3 u_c1;\n uniform vec3 u_c2;\n uniform vec3 u_c3;\n\n // ── Gradient noise ─────────────────────────────────────────────────────────\n vec2 hash2(vec2 p) {\n p = vec2(dot(p, vec2(127.1, 311.7)), dot(p, vec2(269.5, 183.3)));\n return -1.0 + 2.0 * fract(sin(p) * 43758.5453123);\n }\n float gnoise(vec2 p) {\n vec2 i = floor(p), f = fract(p);\n vec2 u = f*f*f*(f*(f*6.0-15.0)+10.0);\n return mix(\n mix(dot(hash2(i), f),\n dot(hash2(i+vec2(1,0)), f-vec2(1,0)), u.x),\n mix(dot(hash2(i+vec2(0,1)), f-vec2(0,1)),\n dot(hash2(i+vec2(1,1)), f-vec2(1,1)), u.x),\n u.y\n ) * 0.5 + 0.5;\n }\n\n // ── 3-octave FBM normalised to [0,1] — fewer octaves → larger, softer blobs\n float fbm(vec2 p) {\n float v = 0.0, a = 0.5;\n for (int i = 0; i < 3; i++) {\n v += a * gnoise(p);\n p = p * 2.1 + vec2(100.0);\n a *= 0.5;\n }\n return v / 0.875;\n }\n\n // ── Scalar hash for grain ──────────────────────────────────────────────────\n float hash1(vec2 p) {\n return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453);\n }\n\n void main() {\n vec2 uv = v_uv;\n float t = u_time * u_speed + 47.3;\n\n // ── ① Two-level domain warp — deep organic folding and swirling ───────────\n // First pass: large-scale sweep\n vec2 q = vec2(\n fbm(uv * 1.8 + vec2( t * 0.13, t * 0.11)) * 2.0 - 1.0,\n fbm(uv * 1.8 + vec2( t * 0.11 + 3.7, -t * 0.14 + 1.1)) * 2.0 - 1.0\n );\n // Second pass: warp the warp — creates curling, folding sub-currents\n vec2 r = vec2(\n fbm(uv * 1.8 + q * 0.55 + vec2( t * 0.09, t * 0.07)) * 2.0 - 1.0,\n fbm(uv * 1.8 + q * 0.55 + vec2(-t * 0.07 + 5.1, t * 0.10 + 2.3)) * 2.0 - 1.0\n );\n vec2 wp = uv + r * 0.38;\n\n // ── ② Three independent fields — each drifts inward from its source edge ──\n // Asymmetric velocities: dominant axis matches the inflow direction so the\n // noise texture visually streams inward (left→right, right→left, bottom→top).\n float f1 = fbm(wp * 0.85 + vec2(-t * 0.18, t * 0.04)); // LEFT → right\n float f2 = fbm(wp * 0.85 + vec2( t * 0.18 + 5.3, t * 0.04 + 1.7)); // RIGHT → left\n float f3 = fbm(wp * 0.85 + vec2( t * 0.04 - 3.2, -t * 0.18 + 6.4)); // BOTTOM → up\n\n // ── ③ Breathing blobs — sin pulse makes each field expand and contract ────\n float p1 = 0.88 + 0.12 * sin(t * 0.61);\n float p2 = 0.88 + 0.12 * sin(t * 0.47 + 2.09);\n float p3 = 0.88 + 0.12 * sin(t * 0.53 + 4.19);\n\n // Wide smoothstep (0.26 → 0.70) → soft, diffused blob edges that dissolve\n // gradually into each other, like dye spreading through water.\n float b1 = smoothstep(0.26, 0.70, f1 * p1);\n float b2 = smoothstep(0.26, 0.70, f2 * p2);\n float b3 = smoothstep(0.26, 0.70, f3 * p3);\n\n // ── ④ Directional origin gradients.\n // Each color owns its home edge (value = 1.0) and smoothly fades to zero\n // before reaching the opposite side. The transition windows are offset so\n // they overlap only in the center third — that overlap zone is where the\n // three colors meet and blend, while the edges stay uncontaminated.\n float d1 = 1.0 - smoothstep(0.20, 0.74, uv.x); // c1: LEFT → full at x<0.20, zero by x=0.74\n float d2 = 1.0 - smoothstep(0.20, 0.74, 1.0 - uv.x); // c2: RIGHT → full at x>0.80, zero by x=0.26\n float d3 = 1.0 - smoothstep(0.18, 0.68, uv.y); // c3: BOTTOM → full at y<0.18, zero by y=0.68\n\n float w1 = b1 * d1;\n float w2 = b2 * d2;\n float w3 = b3 * d3;\n\n // ── ⑤ Dye-mixing colour blend ──────────────────────────────────────────────\n // dyeColor is the weighted average of all active colours — exactly how dyes\n // mix in water: overlapping streams blend smoothly, no hard edges.\n float total = w1 + w2 + w3;\n vec3 dyeColor = (u_c1 * w1 + u_c2 * w2 + u_c3 * w3) / max(total, 0.001);\n\n // Boost brightness of the dye to make colors pop and seem less dull\n dyeColor *= 1.65;\n\n // Exponential coverage: cores are rich and opaque; edges dissolve into the\n // near-white base. White only shows through where dye concentration is thin.\n float coverage = 1.0 - exp(-total * 5.0);\n vec3 col = mix(vec3(1.0, 1.0, 1.0), dyeColor, coverage);\n col = clamp(col, 0.0, 1.0);\n\n // ── ⑥ Sphere shading — subtle edge vignette only, no specular ─────────────\n vec2 uvc = v_uv * 2.0 - 1.0;\n\n // ── ⑦ Subtle grain — breaks gradient banding, adds filmic texture ──────────\n float grain = hash1(v_uv * 437.3 + fract(t)) * 2.0 - 1.0;\n col += grain * 0.018;\n\n gl_FragColor = vec4(clamp(col, 0.0, 1.0), 1.0);\n }\n";
10926
+ function ag(e, t, n) {
10941
10927
  let r = (t, n) => {
10942
10928
  let r = e.createShader(t);
10943
10929
  return e.shaderSource(r, n), e.compileShader(r), e.getShaderParameter(r, e.COMPILE_STATUS) ? r : (console.error("[AnimatedOrb shader]", e.getShaderInfoLog(r)), null);
@@ -10946,10 +10932,10 @@ function sg(e, t, n) {
10946
10932
  let o = e.createProgram();
10947
10933
  return e.attachShader(o, i), e.attachShader(o, a), e.linkProgram(o), e.getProgramParameter(o, e.LINK_STATUS) ? o : (console.error("[AnimatedOrb link]", e.getProgramInfoLog(o)), null);
10948
10934
  }
10949
- function cg({ size: e = 94, voiceState: t = "idle", isMuted: n = !1, colors: r, onClick: i, style: a, className: o }) {
10950
- let [s, l, u] = tg(r), d = t === "speaking", f = e <= 50, m = p(null), h = p(ng[t] ?? .35);
10935
+ function og({ size: e = 94, voiceState: t = "idle", isMuted: n = !1, colors: r, onClick: i, style: a, className: o }) {
10936
+ let [s, l, u] = $h(r), d = t === "speaking", f = e <= 50, m = p(null), h = p(eg[t] ?? .35);
10951
10937
  c(() => {
10952
- h.current = ng[t] ?? .35;
10938
+ h.current = eg[t] ?? .35;
10953
10939
  }, [t]), c(() => {
10954
10940
  let t = m.current;
10955
10941
  if (!t) return;
@@ -10966,7 +10952,7 @@ function cg({ size: e = 94, voiceState: t = "idle", isMuted: n = !1, colors: r,
10966
10952
  console.warn("[AnimatedOrb] WebGL unavailable.");
10967
10953
  return;
10968
10954
  }
10969
- let i = sg(r, ag, og);
10955
+ let i = ag(r, rg, ig);
10970
10956
  if (!i) {
10971
10957
  console.error("[AnimatedOrb] WebGL program failed to compile/link");
10972
10958
  return;
@@ -10996,7 +10982,7 @@ function cg({ size: e = 94, voiceState: t = "idle", isMuted: n = !1, colors: r,
10996
10982
  c2: r.getUniformLocation(i, "u_c2"),
10997
10983
  c3: r.getUniformLocation(i, "u_c3")
10998
10984
  };
10999
- r.uniform3fv(c.c1, rg(s)), r.uniform3fv(c.c2, rg(l)), r.uniform3fv(c.c3, rg(u)), r.viewport(0, 0, t.width, t.height);
10985
+ r.uniform3fv(c.c1, tg(s)), r.uniform3fv(c.c2, tg(l)), r.uniform3fv(c.c3, tg(u)), r.viewport(0, 0, t.width, t.height);
11000
10986
  let d = performance.now(), f, p = (e) => {
11001
10987
  r.uniform1f(c.time, (e - d) / 1e3), r.uniform1f(c.speed, h.current), r.drawArrays(r.TRIANGLES, 0, 6), f = requestAnimationFrame(p);
11002
10988
  };
@@ -11027,7 +11013,7 @@ function cg({ size: e = 94, voiceState: t = "idle", isMuted: n = !1, colors: r,
11027
11013
  position: "absolute",
11028
11014
  inset: -10,
11029
11015
  borderRadius: "50%",
11030
- background: `radial-gradient(circle, ${ig(s, .18)} 0%, transparent 70%)`,
11016
+ background: `radial-gradient(circle, ${ng(s, .18)} 0%, transparent 70%)`,
11031
11017
  pointerEvents: "none"
11032
11018
  },
11033
11019
  animate: { opacity: [.3, .75] },
@@ -11105,17 +11091,17 @@ function cg({ size: e = 94, voiceState: t = "idle", isMuted: n = !1, colors: r,
11105
11091
  }
11106
11092
  //#endregion
11107
11093
  //#region src/components/CallScreen.jsx
11108
- var lg = "\n @keyframes fe-call-ring-pulse {\n 0% { transform: scale(1); opacity: 0.55; }\n 70% { transform: scale(1.85); opacity: 0; }\n 100% { transform: scale(1.85); opacity: 0; }\n }\n @keyframes fe-call-spin {\n to { transform: rotate(360deg); }\n }\n @keyframes fe-call-slide-up {\n from { opacity: 0; transform: translateY(24px); }\n to { opacity: 1; transform: translateY(0); }\n }\n @keyframes fe-call-fade-in {\n from { opacity: 0; }\n to { opacity: 1; }\n }\n @keyframes fe-call-bar-slide-in {\n from { opacity: 0; transform: translateY(10px) scale(0.97); }\n to { opacity: 1; transform: translateY(0) scale(1); }\n }\n @keyframes fe-call-dot-blink {\n 0%, 100% { opacity: 1; }\n 50% { opacity: 0.35; }\n }\n @keyframes fe-call-avatar-breathe {\n 0%, 100% { opacity: 0.5; transform: scale(1); }\n 50% { opacity: 0.9; transform: scale(1.12); }\n }\n";
11109
- function ug(e) {
11094
+ var sg = "\n @keyframes fe-call-ring-pulse {\n 0% { transform: scale(1); opacity: 0.55; }\n 70% { transform: scale(1.85); opacity: 0; }\n 100% { transform: scale(1.85); opacity: 0; }\n }\n @keyframes fe-call-spin {\n to { transform: rotate(360deg); }\n }\n @keyframes fe-call-slide-up {\n from { opacity: 0; transform: translateY(24px); }\n to { opacity: 1; transform: translateY(0); }\n }\n @keyframes fe-call-fade-in {\n from { opacity: 0; }\n to { opacity: 1; }\n }\n @keyframes fe-call-bar-slide-in {\n from { opacity: 0; transform: translateY(10px) scale(0.97); }\n to { opacity: 1; transform: translateY(0) scale(1); }\n }\n @keyframes fe-call-dot-blink {\n 0%, 100% { opacity: 1; }\n 50% { opacity: 0.35; }\n }\n @keyframes fe-call-avatar-breathe {\n 0%, 100% { opacity: 0.5; transform: scale(1); }\n 50% { opacity: 0.9; transform: scale(1.12); }\n }\n";
11095
+ function cg(e) {
11110
11096
  let t = (e || "").replace("#", ""), n = t.length === 3 ? t.split("").map((e) => e + e).join("") : t;
11111
11097
  return `${parseInt(n.slice(0, 2), 16)},${parseInt(n.slice(2, 4), 16)},${parseInt(n.slice(4, 6), 16)}`;
11112
11098
  }
11113
- function dg(e) {
11099
+ function lg(e) {
11114
11100
  if (!e || typeof e != "string") return "#1a1a1a";
11115
11101
  let t = e.replace("#", ""), n = t.length === 3 ? t.split("").map((e) => e + e).join("") : t, r = parseInt(n.slice(0, 2), 16) / 255, i = parseInt(n.slice(2, 4), 16) / 255, a = parseInt(n.slice(4, 6), 16) / 255, o = (e) => e <= .04045 ? e / 12.92 : ((e + .055) / 1.055) ** 2.4;
11116
11102
  return .2126 * o(r) + .7152 * o(i) + .0722 * o(a) > .179 ? "#1a1a1a" : "#ffffff";
11117
11103
  }
11118
- function fg(e, t) {
11104
+ function ug(e, t) {
11119
11105
  let n = Array.isArray(e) && e.length > 0 ? e : [t || "#3B82F6"], [r, i, a] = n;
11120
11106
  return n.length === 1 ? [
11121
11107
  `radial-gradient(ellipse 110% 65% at 50% -5%, ${r}28 0%, transparent 68%)`,
@@ -11132,8 +11118,8 @@ function fg(e, t) {
11132
11118
  "#f7f8fa"
11133
11119
  ].join(", ");
11134
11120
  }
11135
- function pg({ headshot: e, name: t, size: n = 80, primaryColor: r = "#3B82F6" }) {
11136
- let i = (t || "A")[0].toUpperCase(), a = dg(r), o = n > 48 ? {
11121
+ function dg({ headshot: e, name: t, size: n = 80, primaryColor: r = "#3B82F6" }) {
11122
+ let i = (t || "A")[0].toUpperCase(), a = lg(r), o = n > 48 ? {
11137
11123
  boxShadow: `0 0 0 3px ${r}44`,
11138
11124
  border: "3px solid rgba(255,255,255,0.15)"
11139
11125
  } : { border: `1.5px solid ${r}55` };
@@ -11170,7 +11156,7 @@ function pg({ headshot: e, name: t, size: n = 80, primaryColor: r = "#3B82F6" })
11170
11156
  children: i
11171
11157
  });
11172
11158
  }
11173
- function mg(e) {
11159
+ function fg(e) {
11174
11160
  let t = p(null), n = o(() => {
11175
11161
  if (!t.current) return;
11176
11162
  let { audioContext: e, oscillator: n, interval: r, toneTimeout: i } = t.current;
@@ -11217,8 +11203,8 @@ function mg(e) {
11217
11203
  n
11218
11204
  ]), c(() => () => n(), [n]), n;
11219
11205
  }
11220
- function hg({ incomingCall: e, activeCallId: t, callConnectionState: n, callDurationSeconds: r, isCallMuted: i, agentName: a, agentHeadshot: o, fallbackAgentName: s, acceptCall: c, rejectCall: l, endWebRTCCall: u, toggleCallMute: d, formatCallDuration: f, onMinimize: p, primaryColor: m = "#3B82F6", orbColors: h, chatHistory: v = [] }) {
11221
- let y = a || s || "Agent", b = e ? "incoming" : n === "connecting" ? "connecting" : "ongoing", x = mg(!!e), S = async () => {
11206
+ function pg({ incomingCall: e, activeCallId: t, callConnectionState: n, callDurationSeconds: r, isCallMuted: i, agentName: a, agentHeadshot: o, fallbackAgentName: s, acceptCall: c, rejectCall: l, endWebRTCCall: u, toggleCallMute: d, formatCallDuration: f, onMinimize: p, primaryColor: m = "#3B82F6", orbColors: h, chatHistory: v = [] }) {
11207
+ let y = a || s || "Agent", b = e ? "incoming" : n === "connecting" ? "connecting" : "ongoing", x = fg(!!e), S = async () => {
11222
11208
  x(), await c();
11223
11209
  }, C = async () => {
11224
11210
  x(), await l();
@@ -11230,14 +11216,14 @@ function hg({ incomingCall: e, activeCallId: t, callConnectionState: n, callDura
11230
11216
  flexDirection: "column",
11231
11217
  borderRadius: "inherit",
11232
11218
  overflow: "hidden",
11233
- background: fg(h, m),
11219
+ background: ug(h, m),
11234
11220
  animation: T ? "fe-call-slide-up 0.36s cubic-bezier(0.16,1,0.3,1)" : "fe-call-fade-in 0.32s ease"
11235
11221
  };
11236
11222
  if (b === "incoming") {
11237
11223
  let e = Array.isArray(h) && h.length > 0 ? h : [m];
11238
11224
  return /* @__PURE__ */ _("div", {
11239
11225
  style: E,
11240
- children: [/* @__PURE__ */ g("style", { children: lg }), /* @__PURE__ */ _("div", {
11226
+ children: [/* @__PURE__ */ g("style", { children: sg }), /* @__PURE__ */ _("div", {
11241
11227
  style: {
11242
11228
  flex: 1,
11243
11229
  display: "flex",
@@ -11268,7 +11254,7 @@ function hg({ incomingCall: e, activeCallId: t, callConnectionState: n, callDura
11268
11254
  width: "96px",
11269
11255
  height: "96px",
11270
11256
  borderRadius: "50%",
11271
- background: `radial-gradient(circle, rgba(${ug(e[0])},0.2) 0%, transparent 70%)`,
11257
+ background: `radial-gradient(circle, rgba(${cg(e[0])},0.2) 0%, transparent 70%)`,
11272
11258
  filter: "blur(10px)",
11273
11259
  zIndex: 0
11274
11260
  } }),
@@ -11285,7 +11271,7 @@ function hg({ incomingCall: e, activeCallId: t, callConnectionState: n, callDura
11285
11271
  animation: `fe-call-ring-pulse 2.6s cubic-bezier(0.215,0.61,0.355,1) ${t}s infinite`,
11286
11272
  zIndex: 1
11287
11273
  } }, n)),
11288
- /* @__PURE__ */ g(pg, {
11274
+ /* @__PURE__ */ g(dg, {
11289
11275
  headshot: o,
11290
11276
  name: y,
11291
11277
  size: 82,
@@ -11365,7 +11351,7 @@ function hg({ incomingCall: e, activeCallId: t, callConnectionState: n, callDura
11365
11351
  e.currentTarget.style.transform = "scale(1)", e.currentTarget.style.boxShadow = "0 6px 24px rgba(239,68,68,0.5)";
11366
11352
  },
11367
11353
  "aria-label": "Decline call",
11368
- children: /* @__PURE__ */ g(Sh, { size: 26 })
11354
+ children: /* @__PURE__ */ g(bh, { size: 26 })
11369
11355
  }), /* @__PURE__ */ g("span", {
11370
11356
  style: {
11371
11357
  fontSize: "12px",
@@ -11406,7 +11392,7 @@ function hg({ incomingCall: e, activeCallId: t, callConnectionState: n, callDura
11406
11392
  e.currentTarget.style.transform = "scale(1)", e.currentTarget.style.boxShadow = "0 6px 24px rgba(34,197,94,0.5)";
11407
11393
  },
11408
11394
  "aria-label": "Accept call",
11409
- children: /* @__PURE__ */ g(Th, {})
11395
+ children: /* @__PURE__ */ g(Ch, {})
11410
11396
  }), /* @__PURE__ */ g("span", {
11411
11397
  style: {
11412
11398
  fontSize: "12px",
@@ -11423,7 +11409,7 @@ function hg({ incomingCall: e, activeCallId: t, callConnectionState: n, callDura
11423
11409
  }
11424
11410
  return b === "connecting" ? /* @__PURE__ */ _("div", {
11425
11411
  style: E,
11426
- children: [/* @__PURE__ */ g("style", { children: lg }), /* @__PURE__ */ _("div", {
11412
+ children: [/* @__PURE__ */ g("style", { children: sg }), /* @__PURE__ */ _("div", {
11427
11413
  style: {
11428
11414
  flex: 1,
11429
11415
  display: "flex",
@@ -11433,7 +11419,7 @@ function hg({ incomingCall: e, activeCallId: t, callConnectionState: n, callDura
11433
11419
  gap: "24px"
11434
11420
  },
11435
11421
  children: [
11436
- /* @__PURE__ */ g(pg, {
11422
+ /* @__PURE__ */ g(dg, {
11437
11423
  headshot: o,
11438
11424
  name: y,
11439
11425
  size: 64,
@@ -11460,7 +11446,7 @@ function hg({ incomingCall: e, activeCallId: t, callConnectionState: n, callDura
11460
11446
  }) : /* @__PURE__ */ _("div", {
11461
11447
  style: E,
11462
11448
  children: [
11463
- /* @__PURE__ */ g("style", { children: lg }),
11449
+ /* @__PURE__ */ g("style", { children: sg }),
11464
11450
  /* @__PURE__ */ _("div", {
11465
11451
  style: {
11466
11452
  display: "flex",
@@ -11506,7 +11492,7 @@ function hg({ incomingCall: e, activeCallId: t, callConnectionState: n, callDura
11506
11492
  children: /* @__PURE__ */ g("polyline", { points: "15 18 9 12 15 6" })
11507
11493
  })
11508
11494
  }),
11509
- /* @__PURE__ */ g(cg, {
11495
+ /* @__PURE__ */ g(og, {
11510
11496
  colors: h,
11511
11497
  size: 36,
11512
11498
  voiceState: w
@@ -11557,7 +11543,7 @@ function hg({ incomingCall: e, activeCallId: t, callConnectionState: n, callDura
11557
11543
  gap: "16px",
11558
11544
  padding: "0 24px 16px"
11559
11545
  },
11560
- children: [/* @__PURE__ */ g(pg, {
11546
+ children: [/* @__PURE__ */ g(dg, {
11561
11547
  headshot: o,
11562
11548
  name: y,
11563
11549
  size: 116,
@@ -11612,7 +11598,7 @@ function hg({ incomingCall: e, activeCallId: t, callConnectionState: n, callDura
11612
11598
  transition: "all 0.2s ease"
11613
11599
  },
11614
11600
  "aria-label": i ? "Unmute" : "Mute",
11615
- children: [g(i ? Mh : xh, { size: 18 }), i ? "Unmute" : "Mute"]
11601
+ children: [g(i ? Ah : yh, { size: 18 }), i ? "Unmute" : "Mute"]
11616
11602
  }), /* @__PURE__ */ _("button", {
11617
11603
  type: "button",
11618
11604
  onClick: u,
@@ -11640,15 +11626,15 @@ function hg({ incomingCall: e, activeCallId: t, callConnectionState: n, callDura
11640
11626
  e.currentTarget.style.background = "rgba(239,68,68,0.9)", e.currentTarget.style.transform = "scale(1)";
11641
11627
  },
11642
11628
  "aria-label": "End call",
11643
- children: [/* @__PURE__ */ g(Sh, { size: 18 }), "End Call"]
11629
+ children: [/* @__PURE__ */ g(bh, { size: 18 }), "End Call"]
11644
11630
  })]
11645
11631
  })
11646
11632
  ]
11647
11633
  });
11648
11634
  }
11649
- function gg({ agentName: e, agentHeadshot: t, fallbackAgentName: n, callDurationSeconds: r, isCallMuted: i, formatCallDuration: a, toggleCallMute: o, endWebRTCCall: s, onExpand: c, primaryColor: l = "#3B82F6" }) {
11635
+ function mg({ agentName: e, agentHeadshot: t, fallbackAgentName: n, callDurationSeconds: r, isCallMuted: i, formatCallDuration: a, toggleCallMute: o, endWebRTCCall: s, onExpand: c, primaryColor: l = "#3B82F6" }) {
11650
11636
  let u = e || n || "Agent";
11651
- return /* @__PURE__ */ _(h, { children: [/* @__PURE__ */ g("style", { children: lg }), /* @__PURE__ */ _("div", {
11637
+ return /* @__PURE__ */ _(h, { children: [/* @__PURE__ */ g("style", { children: sg }), /* @__PURE__ */ _("div", {
11652
11638
  role: "button",
11653
11639
  tabIndex: 0,
11654
11640
  onClick: c,
@@ -11705,7 +11691,7 @@ function gg({ agentName: e, agentHeadshot: t, fallbackAgentName: n, callDuration
11705
11691
  borderRadius: "50%",
11706
11692
  border: `1.5px solid ${l}55`
11707
11693
  } }),
11708
- /* @__PURE__ */ g(pg, {
11694
+ /* @__PURE__ */ g(dg, {
11709
11695
  headshot: t,
11710
11696
  name: u,
11711
11697
  size: 38,
@@ -11789,7 +11775,7 @@ function gg({ agentName: e, agentHeadshot: t, fallbackAgentName: n, callDuration
11789
11775
  boxShadow: i ? `0 0 0 3px ${l}12` : "none"
11790
11776
  },
11791
11777
  "aria-label": i ? "Unmute" : "Mute",
11792
- children: g(i ? Mh : xh, { size: 15 })
11778
+ children: g(i ? Ah : yh, { size: 15 })
11793
11779
  }), /* @__PURE__ */ g("button", {
11794
11780
  type: "button",
11795
11781
  onClick: (e) => {
@@ -11817,7 +11803,7 @@ function gg({ agentName: e, agentHeadshot: t, fallbackAgentName: n, callDuration
11817
11803
  transition: "all 0.18s ease"
11818
11804
  },
11819
11805
  "aria-label": "End call",
11820
- children: /* @__PURE__ */ g(Sh, { size: 16 })
11806
+ children: /* @__PURE__ */ g(bh, { size: 16 })
11821
11807
  })]
11822
11808
  })
11823
11809
  ]
@@ -11825,7 +11811,7 @@ function gg({ agentName: e, agentHeadshot: t, fallbackAgentName: n, callDuration
11825
11811
  }
11826
11812
  //#endregion
11827
11813
  //#region src/utils/voicePriorContext.js
11828
- function _g(e, t = {}) {
11814
+ function hg(e, t = {}) {
11829
11815
  let n = t.maxChars ?? 4500;
11830
11816
  if (!Array.isArray(e) || e.length === 0) return "";
11831
11817
  let r = [];
@@ -11843,7 +11829,7 @@ function _g(e, t = {}) {
11843
11829
  //#endregion
11844
11830
  //#region src/utils/voiceActionVisuals.js
11845
11831
  var Q = "fe-vv";
11846
- function vg() {
11832
+ function gg() {
11847
11833
  if (typeof document > "u" || document.getElementById(`${Q}-styles`)) return;
11848
11834
  let e = `
11849
11835
  /* ── Action toast ───────────────────────────────────────────────────────────── */
@@ -11988,14 +11974,14 @@ function vg() {
11988
11974
  `, t = document.createElement("style");
11989
11975
  t.id = `${Q}-styles`, t.textContent = e, (document.head || document.documentElement).appendChild(t);
11990
11976
  }
11991
- var yg = null, bg = null;
11992
- function xg() {
11993
- return (!yg || !yg.isConnected) && (yg = document.createElement("div"), yg.id = `${Q}-toast`, document.body.appendChild(yg)), yg;
11977
+ var _g = null, vg = null;
11978
+ function yg() {
11979
+ return (!_g || !_g.isConnected) && (_g = document.createElement("div"), _g.id = `${Q}-toast`, document.body.appendChild(_g)), _g;
11994
11980
  }
11995
- function Sg(e, { spinner: t = !0, icon: n = null, duration: r = 0 } = {}) {
11981
+ function bg(e, { spinner: t = !0, icon: n = null, duration: r = 0 } = {}) {
11996
11982
  if (typeof document > "u") return;
11997
- vg(), bg &&= (clearTimeout(bg), null);
11998
- let i = xg();
11983
+ gg(), vg &&= (clearTimeout(vg), null);
11984
+ let i = yg();
11999
11985
  if (i.innerHTML = "", n) {
12000
11986
  let e = document.createElement("span");
12001
11987
  e.className = `${Q}-icon`, e.textContent = n, i.appendChild(e);
@@ -12004,71 +11990,71 @@ function Sg(e, { spinner: t = !0, icon: n = null, duration: r = 0 } = {}) {
12004
11990
  e.className = `${Q}-spin`, i.appendChild(e);
12005
11991
  }
12006
11992
  let a = document.createElement("span");
12007
- a.textContent = e, i.appendChild(a), i.classList.remove(`${Q}-show`), i.offsetHeight, i.classList.add(`${Q}-show`), r > 0 && (bg = setTimeout(() => Cg(), r));
11993
+ a.textContent = e, i.appendChild(a), i.classList.remove(`${Q}-show`), i.offsetHeight, i.classList.add(`${Q}-show`), r > 0 && (vg = setTimeout(() => xg(), r));
12008
11994
  }
12009
- function Cg(e = 0) {
12010
- yg && (e > 0 ? bg = setTimeout(() => {
12011
- yg && yg.classList.remove(`${Q}-show`);
12012
- }, e) : yg && yg.classList.remove(`${Q}-show`));
11995
+ function xg(e = 0) {
11996
+ _g && (e > 0 ? vg = setTimeout(() => {
11997
+ _g && _g.classList.remove(`${Q}-show`);
11998
+ }, e) : _g && _g.classList.remove(`${Q}-show`));
12013
11999
  }
12014
- var wg = null, Tg = [];
12015
- function Eg() {
12016
- return (!wg || !wg.isConnected) && (wg = document.createElement("div"), wg.id = `${Q}-bar`, document.body.appendChild(wg)), wg;
12000
+ var Sg = null, Cg = [];
12001
+ function wg() {
12002
+ return (!Sg || !Sg.isConnected) && (Sg = document.createElement("div"), Sg.id = `${Q}-bar`, document.body.appendChild(Sg)), Sg;
12017
12003
  }
12018
- function Dg() {
12004
+ function Tg() {
12019
12005
  if (typeof document > "u") return;
12020
- vg(), Tg.forEach(clearTimeout), Tg = [];
12021
- let e = Eg();
12006
+ gg(), Cg.forEach(clearTimeout), Cg = [];
12007
+ let e = wg();
12022
12008
  e.style.transition = "none", e.style.width = "0%", e.classList.add(`${Q}-bar-active`), e.offsetHeight, e.style.transition = "width 0.35s ease, opacity 0.25s ease";
12023
12009
  let t = [[80, "width 0.6s ease"], [92, "width 1.2s ease"]], n = 50;
12024
12010
  for (let [e, r] of t) {
12025
12011
  let t = n, i = e, a = r;
12026
- Tg.push(setTimeout(() => {
12027
- wg && (wg.style.transition = a, wg.style.width = `${i}%`);
12012
+ Cg.push(setTimeout(() => {
12013
+ Sg && (Sg.style.transition = a, Sg.style.width = `${i}%`);
12028
12014
  }, t)), n += 800;
12029
12015
  }
12030
12016
  }
12031
- function Og() {
12032
- wg && (Tg.forEach(clearTimeout), Tg = [], wg.style.transition = "width 0.2s ease", wg.style.width = "100%", Tg.push(setTimeout(() => {
12033
- wg && (wg.style.transition = "opacity 0.35s ease", wg.style.opacity = "0", Tg.push(setTimeout(() => {
12034
- wg && (wg.style.width = "0%", wg.classList.remove(`${Q}-bar-active`));
12017
+ function Eg() {
12018
+ Sg && (Cg.forEach(clearTimeout), Cg = [], Sg.style.transition = "width 0.2s ease", Sg.style.width = "100%", Cg.push(setTimeout(() => {
12019
+ Sg && (Sg.style.transition = "opacity 0.35s ease", Sg.style.opacity = "0", Cg.push(setTimeout(() => {
12020
+ Sg && (Sg.style.width = "0%", Sg.classList.remove(`${Q}-bar-active`));
12035
12021
  }, 380)));
12036
12022
  }, 220)));
12037
12023
  }
12038
- var kg = `<svg xmlns="http://www.w3.org/2000/svg" width="22" height="22" viewBox="0 0 22 22" fill="none">
12024
+ var Dg = `<svg xmlns="http://www.w3.org/2000/svg" width="22" height="22" viewBox="0 0 22 22" fill="none">
12039
12025
  <filter id="${Q}-csh">
12040
12026
  <feDropShadow dx="1" dy="2" stdDeviation="1.5" flood-color="#00000060"/>
12041
12027
  </filter>
12042
12028
  <path d="M4 2L19 10.5L11 12.8L8 20L4 2Z"
12043
12029
  fill="white" stroke="#1e1b4b" stroke-width="1.6" stroke-linejoin="round"
12044
12030
  filter="url(#${Q}-csh)"/>
12045
- </svg>`, Ag = null, jg = !1;
12046
- function Mg() {
12047
- return (!Ag || !Ag.isConnected) && (Ag = document.createElement("div"), Ag.id = `${Q}-cursor`, Ag.innerHTML = kg, document.body.appendChild(Ag), jg = !1), Ag;
12031
+ </svg>`, Og = null, kg = !1;
12032
+ function Ag() {
12033
+ return (!Og || !Og.isConnected) && (Og = document.createElement("div"), Og.id = `${Q}-cursor`, Og.innerHTML = Dg, document.body.appendChild(Og), kg = !1), Og;
12048
12034
  }
12049
- async function Ng(e) {
12035
+ async function jg(e) {
12050
12036
  if (typeof document > "u" || !e) return;
12051
- vg();
12037
+ gg();
12052
12038
  let t;
12053
12039
  try {
12054
12040
  t = e.getBoundingClientRect();
12055
12041
  } catch {
12056
12042
  return;
12057
12043
  }
12058
- let n = t.left + Math.min(16, t.width * .2), r = t.top + Math.min(12, t.height * .25), i = Mg();
12059
- jg ||= (i.style.transition = "none", i.style.left = `${window.innerWidth / 2}px`, i.style.top = `${window.innerHeight * .4}px`, i.classList.add(`${Q}-cursor-visible`), i.offsetHeight, i.style.transition = "left 0.32s cubic-bezier(0.25,0.46,0.45,0.94), top 0.32s cubic-bezier(0.25,0.46,0.45,0.94), opacity 0.2s ease", !0), i.style.left = `${n}px`, i.style.top = `${r}px`, await Lg(360);
12044
+ let n = t.left + Math.min(16, t.width * .2), r = t.top + Math.min(12, t.height * .25), i = Ag();
12045
+ kg ||= (i.style.transition = "none", i.style.left = `${window.innerWidth / 2}px`, i.style.top = `${window.innerHeight * .4}px`, i.classList.add(`${Q}-cursor-visible`), i.offsetHeight, i.style.transition = "left 0.32s cubic-bezier(0.25,0.46,0.45,0.94), top 0.32s cubic-bezier(0.25,0.46,0.45,0.94), opacity 0.2s ease", !0), i.style.left = `${n}px`, i.style.top = `${r}px`, await Fg(360);
12060
12046
  }
12061
- function Pg(e = !1) {
12062
- Ag && (e ? (Ag.classList.remove(`${Q}-cursor-visible`), jg = !1) : (Ag.classList.remove(`${Q}-cursor-visible`), setTimeout(() => {
12063
- jg = !1;
12047
+ function Mg(e = !1) {
12048
+ Og && (e ? (Og.classList.remove(`${Q}-cursor-visible`), kg = !1) : (Og.classList.remove(`${Q}-cursor-visible`), setTimeout(() => {
12049
+ kg = !1;
12064
12050
  }, 250)));
12065
12051
  }
12066
- async function Fg(e) {
12067
- Ag && (Ag.classList.add(`${Q}-cursor-click`), await Lg(280), Ag.classList.remove(`${Q}-cursor-click`));
12052
+ async function Ng(e) {
12053
+ Og && (Og.classList.add(`${Q}-cursor-click`), await Fg(280), Og.classList.remove(`${Q}-cursor-click`));
12068
12054
  }
12069
- function Ig(e) {
12055
+ function Pg(e) {
12070
12056
  if (!e || typeof document > "u") return;
12071
- vg();
12057
+ gg();
12072
12058
  let t;
12073
12059
  try {
12074
12060
  t = e.getBoundingClientRect();
@@ -12094,29 +12080,29 @@ function Ig(e) {
12094
12080
  a.remove(), e.style.position = n, e.style.overflow = r;
12095
12081
  }, 650);
12096
12082
  }
12097
- function Lg(e) {
12083
+ function Fg(e) {
12098
12084
  return new Promise((t) => setTimeout(t, e));
12099
12085
  }
12100
12086
  //#endregion
12101
12087
  //#region src/utils/voiceClientTools.js
12102
- var Rg = /^\/[a-z]{2}(?:-[a-z]{2})?(?=\/|$)/i;
12103
- function zg(e) {
12104
- return String(e || "").replace(Rg, "").replace(/\/+$/, "").toLowerCase() || "/";
12088
+ var Ig = /^\/[a-z]{2}(?:-[a-z]{2})?(?=\/|$)/i;
12089
+ function Lg(e) {
12090
+ return String(e || "").replace(Ig, "").replace(/\/+$/, "").toLowerCase() || "/";
12105
12091
  }
12106
- function Bg(e, t) {
12107
- return zg(e) === zg(t);
12092
+ function Rg(e, t) {
12093
+ return Lg(e) === Lg(t);
12108
12094
  }
12109
12095
  function $(...e) {
12110
12096
  wn() && console.log("[FlowEngage:voice-tools]", ...e);
12111
12097
  }
12112
- function Vg(e) {
12098
+ function zg(e) {
12113
12099
  try {
12114
12100
  let t = e.ownerDocument?.defaultView;
12115
12101
  if (t) return t.getComputedStyle(e);
12116
12102
  } catch {}
12117
12103
  return window.getComputedStyle(e);
12118
12104
  }
12119
- function Hg(e) {
12105
+ function Bg(e) {
12120
12106
  let t = /* @__PURE__ */ new Set();
12121
12107
  function n(r) {
12122
12108
  if (!r || t.has(r)) return;
@@ -12129,10 +12115,10 @@ function Hg(e) {
12129
12115
  }
12130
12116
  typeof document < "u" && n(document);
12131
12117
  }
12132
- function Ug(e) {
12118
+ function Vg(e) {
12133
12119
  return e == null ? null : String(e).replace(/\u00a0/g, " ").replace(/\s*\*+\s*$/u, "").replace(/\s+/g, " ").trim();
12134
12120
  }
12135
- function Wg(e) {
12121
+ function Hg(e) {
12136
12122
  let t = e.ownerDocument || document, n = e.getAttribute("aria-labelledby");
12137
12123
  if (n) {
12138
12124
  let e = n.trim().split(/\s+/).filter(Boolean), r = [];
@@ -12140,40 +12126,40 @@ function Wg(e) {
12140
12126
  let e = t.getElementById(n);
12141
12127
  e?.textContent && r.push(e.textContent.trim());
12142
12128
  } catch {}
12143
- if (r.length) return Ug(r.join(" "));
12129
+ if (r.length) return Vg(r.join(" "));
12144
12130
  }
12145
- if (e.labels && e.labels.length) return Ug(e.labels[0].textContent);
12131
+ if (e.labels && e.labels.length) return Vg(e.labels[0].textContent);
12146
12132
  let r = e.id;
12147
12133
  if (r) try {
12148
12134
  let e = t.querySelector(`label[for="${CSS.escape(r)}"]`);
12149
- if (e) return Ug(e.textContent);
12135
+ if (e) return Vg(e.textContent);
12150
12136
  } catch {
12151
12137
  let e = t.querySelector(`label[for="${r.replace(/"/g, "\\\"")}"]`);
12152
- if (e) return Ug(e.textContent);
12138
+ if (e) return Vg(e.textContent);
12153
12139
  }
12154
12140
  let i = e.previousElementSibling;
12155
12141
  for (let e = 0; e < 6 && i; e += 1) {
12156
- if (i.tagName === "LABEL") return Ug(i.textContent);
12142
+ if (i.tagName === "LABEL") return Vg(i.textContent);
12157
12143
  let e = (i.className || "").toString().toLowerCase();
12158
12144
  if (/chakra-form__label|formlabel|field-label|form-label|mui-form-label/.test(e)) {
12159
- let e = Ug(i.textContent);
12145
+ let e = Vg(i.textContent);
12160
12146
  if (e) return e;
12161
12147
  }
12162
12148
  i = i.previousElementSibling;
12163
12149
  }
12164
12150
  let a = e.parentElement;
12165
12151
  for (let e = 0; e < 5 && a; e += 1) {
12166
- if (a.tagName === "LABEL") return Ug(a.textContent);
12152
+ if (a.tagName === "LABEL") return Vg(a.textContent);
12167
12153
  let e = a.querySelector?.(":scope > label, :scope > [class*='FormLabel'], :scope > [class*='form__label']");
12168
- if (e?.textContent) return Ug(e.textContent);
12154
+ if (e?.textContent) return Vg(e.textContent);
12169
12155
  a = a.parentElement;
12170
12156
  }
12171
12157
  let o = e.getAttribute("aria-label");
12172
- return o ? Ug(o) : null;
12158
+ return o ? Vg(o) : null;
12173
12159
  }
12174
- function Gg() {
12160
+ function Ug() {
12175
12161
  let e = [];
12176
- return Hg((t) => {
12162
+ return Bg((t) => {
12177
12163
  e.push(...Array.from(t.querySelectorAll("input, select, textarea")).filter((e) => {
12178
12164
  if (An(e)) return !1;
12179
12165
  let t = (e.type || "").toLowerCase();
@@ -12184,15 +12170,15 @@ function Gg() {
12184
12170
  "image"
12185
12171
  ].includes(t) || e.disabled || e.readOnly) return !1;
12186
12172
  try {
12187
- let t = Vg(e);
12173
+ let t = zg(e);
12188
12174
  if (t.display === "none" || t.visibility === "hidden") return !1;
12189
12175
  } catch {}
12190
12176
  return !0;
12191
12177
  }));
12192
12178
  }), e;
12193
12179
  }
12194
- function Kg() {
12195
- return Gg().map((e, t) => {
12180
+ function Wg() {
12181
+ return Ug().map((e, t) => {
12196
12182
  let n = {
12197
12183
  formIndex: 0,
12198
12184
  fieldIndex: t,
@@ -12200,7 +12186,7 @@ function Kg() {
12200
12186
  type: e.type || "text",
12201
12187
  name: e.name || null,
12202
12188
  id: e.id || null,
12203
- label: Wg(e),
12189
+ label: Hg(e),
12204
12190
  placeholder: e.placeholder || null
12205
12191
  };
12206
12192
  return e.tagName === "SELECT" && (n.options = Array.from(e.options).filter((e) => e.value !== "" && !e.disabled).map((e) => ({
@@ -12209,13 +12195,13 @@ function Kg() {
12209
12195
  })), n.currentValue = e.value || null), n;
12210
12196
  });
12211
12197
  }
12212
- function qg() {
12198
+ function Gg() {
12213
12199
  let e = [];
12214
- return Hg((t) => {
12200
+ return Bg((t) => {
12215
12201
  e.push(...Array.from(t.querySelectorAll("button, [role=\"button\"], input[type=\"submit\"], input[type=\"button\"]")).filter((e) => {
12216
12202
  if (An(e) || e.disabled) return !1;
12217
12203
  try {
12218
- let t = Vg(e);
12204
+ let t = zg(e);
12219
12205
  if (t.display === "none" || t.visibility === "hidden") return !1;
12220
12206
  } catch {}
12221
12207
  return !0;
@@ -12227,7 +12213,7 @@ function qg() {
12227
12213
  type: e.type || e.tagName
12228
12214
  }));
12229
12215
  }
12230
- function Jg(e, t) {
12216
+ function Kg(e, t) {
12231
12217
  try {
12232
12218
  if (!e?.getBoundingClientRect || !t?.getBoundingClientRect) return Infinity;
12233
12219
  let n = e.getBoundingClientRect(), r = t.getBoundingClientRect(), i = {
@@ -12242,7 +12228,7 @@ function Jg(e, t) {
12242
12228
  return Infinity;
12243
12229
  }
12244
12230
  }
12245
- function Yg(e, t) {
12231
+ function qg(e, t) {
12246
12232
  let n = String(t || "").toLowerCase().trim();
12247
12233
  if (!n) return 0;
12248
12234
  let r = (e.innerText || e.textContent || "").replace(/\s+/g, " ").trim(), i = [
@@ -12260,21 +12246,21 @@ function Yg(e, t) {
12260
12246
  for (let e of a) i.includes(e) && (o += 1);
12261
12247
  return o / a.length * 92;
12262
12248
  }
12263
- function Xg(e, t, n = 6) {
12249
+ function Jg(e, t, n = 6) {
12264
12250
  let r = String(t || "").toLowerCase().trim();
12265
12251
  if (!r) return !1;
12266
12252
  let i = e;
12267
12253
  for (let e = 0; e < n && i && (i = i.parentElement, i); e++) if ((i.innerText || i.textContent || "").toLowerCase().includes(r)) return !0;
12268
12254
  return !1;
12269
12255
  }
12270
- function Zg(e, t, n) {
12256
+ function Yg(e, t, n) {
12271
12257
  let r = [];
12272
- Hg((e) => {
12258
+ Bg((e) => {
12273
12259
  let t = Array.from(e.querySelectorAll("button, [role=\"button\"], input[type=\"submit\"], input[type=\"button\"], a[href]"));
12274
12260
  r.push(...t.filter((e) => {
12275
12261
  if (An(e) || e.disabled) return !1;
12276
12262
  try {
12277
- let t = Vg(e);
12263
+ let t = zg(e);
12278
12264
  if (t.display === "none" || t.visibility === "hidden" || t.opacity === "0") return !1;
12279
12265
  } catch {}
12280
12266
  return !0;
@@ -12282,14 +12268,14 @@ function Zg(e, t, n) {
12282
12268
  });
12283
12269
  let i = 0, a = r.map((t) => ({
12284
12270
  el: t,
12285
- s: Yg(t, e)
12271
+ s: qg(t, e)
12286
12272
  }));
12287
12273
  for (let { s: e } of a) e > i && (i = e);
12288
12274
  if (i < 28) return null;
12289
12275
  let o = a.filter(({ s: e }) => e === i).map(({ el: e }) => e);
12290
12276
  if (o.length === 1) return o[0];
12291
12277
  if (n) {
12292
- let e = o.filter((e) => Xg(e, n));
12278
+ let e = o.filter((e) => Jg(e, n));
12293
12279
  if (e.length === 1) return e[0];
12294
12280
  e.length > 1 && (o = e);
12295
12281
  }
@@ -12297,14 +12283,14 @@ function Zg(e, t, n) {
12297
12283
  if (s.length) {
12298
12284
  let e = o[0], t = Infinity;
12299
12285
  for (let n of o) for (let r of s) {
12300
- let i = Jg(n, r);
12286
+ let i = Kg(n, r);
12301
12287
  i < t && (t = i, e = n);
12302
12288
  }
12303
12289
  return e;
12304
12290
  }
12305
12291
  return o[0];
12306
12292
  }
12307
- function Qg(e) {
12293
+ function Xg(e) {
12308
12294
  if (e == null) return {};
12309
12295
  if (typeof e == "string") {
12310
12296
  let t = e.trim();
@@ -12317,12 +12303,12 @@ function Qg(e) {
12317
12303
  }
12318
12304
  return e;
12319
12305
  }
12320
- function $g(e) {
12306
+ function Zg(e) {
12321
12307
  if (!e || typeof e != "object") return null;
12322
12308
  let t = e.url ?? e.target_url ?? e.page_url ?? e.pageUrl ?? e.link ?? e.href ?? e.path;
12323
12309
  return t == null ? null : String(t).trim() || null;
12324
12310
  }
12325
- function e_() {
12311
+ function Qg() {
12326
12312
  let e = {};
12327
12313
  document.querySelectorAll("h1, h2, h3, h4, h5, h6").forEach((t) => {
12328
12314
  if (t.id) return;
@@ -12337,7 +12323,7 @@ function e_() {
12337
12323
  e[r] = !0, t.id = r;
12338
12324
  });
12339
12325
  }
12340
- function t_() {
12326
+ function $g() {
12341
12327
  let e = (e) => {
12342
12328
  let t = Array.from(e).filter((e) => !e.closest("#flowengage-root, .flowengage-shell, .flowengage-widget-root") && !e.closest("nav, footer, header, aside, .nav, .footer, .header, .sidebar")), n = [], r = 0;
12343
12329
  for (; r < t.length;) {
@@ -12392,7 +12378,7 @@ function t_() {
12392
12378
  containerHeadings: o
12393
12379
  };
12394
12380
  }
12395
- function n_(e) {
12381
+ function e_(e) {
12396
12382
  if (!e || typeof document > "u") return "";
12397
12383
  let t = new Set([
12398
12384
  "script",
@@ -12478,11 +12464,11 @@ function n_(e) {
12478
12464
  return d.has(t) ? !1 : (d.add(t), !0);
12479
12465
  }).join("\n").replace(/\n{3,}/g, "\n\n").trim();
12480
12466
  }
12481
- function r_(e) {
12467
+ function t_(e) {
12482
12468
  let t = e.siteId || null, n = (e.apiBaseUrl || "").replace(/\/$/, ""), r = typeof e.getLastUserVoiceText == "function" ? e.getLastUserVoiceText : null, i = [], a = {
12483
12469
  "fwh-navigate-mvp": async (n) => {
12484
12470
  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.";
12485
- let i = Qg(n), a = $g(i), o = i.section_text ?? i.sectionText ?? i.section, s = Array.isArray(i.expected_landmarks) ? i.expected_landmarks : Array.isArray(i.expectedLandmarks) ? i.expectedLandmarks : [];
12471
+ let i = Xg(n), a = Zg(i), o = i.section_text ?? i.sectionText ?? i.section, s = Array.isArray(i.expected_landmarks) ? i.expected_landmarks : Array.isArray(i.expectedLandmarks) ? i.expectedLandmarks : [];
12486
12472
  if ($("fwh-navigate-mvp · coerced:", {
12487
12473
  url: a,
12488
12474
  sectionText: o,
@@ -12522,11 +12508,11 @@ function r_(e) {
12522
12508
  correctedUrl: l
12523
12509
  }), a = l);
12524
12510
  try {
12525
- Sg(`Navigating to ${a}...`, { spinner: !0 }), Dg(), On();
12511
+ bg(`Navigating to ${a}...`, { spinner: !0 }), Tg(), On();
12526
12512
  try {
12527
12513
  let e = r ? r() : "";
12528
12514
  if (e && t) {
12529
- let n = _g([{
12515
+ let n = hg([{
12530
12516
  sender: "user",
12531
12517
  message: e
12532
12518
  }]);
@@ -12561,8 +12547,8 @@ function r_(e) {
12561
12547
  typeof window < "u" && window.scrollTo(0, 0);
12562
12548
  } catch {}
12563
12549
  let o = [], s = null, c = "", l = Date.now() + 12e3;
12564
- for (; Date.now() < l && (await new Promise((e) => setTimeout(e, 300)), {headings: o, pageTitleHeading: s, introText: c} = t_(), !(o.length >= 1)););
12565
- e_(), $("fwh-navigate-mvp → page headings collected:", o, "titleHeading:", s);
12550
+ for (; Date.now() < l && (await new Promise((e) => setTimeout(e, 300)), {headings: o, pageTitleHeading: s, introText: c} = $g(), !(o.length >= 1)););
12551
+ Qg(), $("fwh-navigate-mvp → page headings collected:", o, "titleHeading:", s);
12566
12552
  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 = "";
12567
12553
  try {
12568
12554
  if (o.length > 0) {
@@ -12570,7 +12556,7 @@ function r_(e) {
12570
12556
  for (let n of e) {
12571
12557
  let e = cr(null, n);
12572
12558
  if (e) {
12573
- let r = n_(e).substring(0, 800);
12559
+ let r = e_(e).substring(0, 800);
12574
12560
  r && t.push(`[Section: ${n}] ${r}`);
12575
12561
  }
12576
12562
  }
@@ -12579,57 +12565,57 @@ function r_(e) {
12579
12565
  } catch {}
12580
12566
  if (yr()) return _r(), $("fwh-navigate-mvp ✖ landed on a not-found/404 page:", i), `NAVIGATION_PAGE_NOT_FOUND. The page at ${i} does not exist — it shows a "not found"/404 error, not real content. Do NOT offer a page overview, do NOT describe or highlight any sections, do NOT claim the navigation succeeded. Tell the visitor EXACTLY: "It looks like that page doesn't exist — I couldn't find it. Would you like me to take you somewhere else?" Then STOP and wait for their reply.`;
12581
12567
  let m = Date.now() + 4e3, h = typeof window < "u" ? window.location.pathname : r;
12582
- for (; Date.now() < m && !Bg(h, e) && Bg(h, t);) await new Promise((e) => setTimeout(e, 120)), h = window.location.pathname;
12568
+ for (; Date.now() < m && !Rg(h, e) && Rg(h, t);) await new Promise((e) => setTimeout(e, 120)), h = window.location.pathname;
12583
12569
  $("fwh-navigate-mvp route settle:", {
12584
12570
  startPath: t,
12585
12571
  targetPath: e,
12586
12572
  settledPath: h
12587
12573
  });
12588
- let g = typeof window < "u" ? window.location.href : i, _ = (h.split("/").filter(Boolean).pop() || "").replace(/[-_]/g, " ").replace(/\b\w/g, (e) => e.toUpperCase()) || "Home", v = Bg(h, e), y = !Bg(h, t), b = v || y;
12574
+ let g = typeof window < "u" ? window.location.href : i, _ = (h.split("/").filter(Boolean).pop() || "").replace(/[-_]/g, " ").replace(/\b\w/g, (e) => e.toUpperCase()) || "Home", v = Rg(h, e), y = !Rg(h, t), b = v || y;
12589
12575
  return $("fwh-navigate-mvp settled:", h, "target:", e, "match:", b), b ? (_r(), `OK_NAVIGATE_SPA. Visitor is now on: ${g} (page: "${_}") | Section headings: ${u}.${f} ${d}${p} Now confirm the arrival in ONE short sentence phrased for what the visitor actually asked for — mention the page by name and what it lets them do (e.g. for a contact request: "I've taken you to the Contact Us page — filling in this form sends your query straight to our team."). Do NOT use a fixed template. Then, in the same breath, offer either a specific section or a full overview. Then STOP — wait for their reply.`) : (_r(), `NAVIGATION_DID_NOT_HAPPEN. The visitor is STILL on ${g} (page: "${_}") — the navigation did not go through. Do NOT say "I have navigated you". Do NOT claim success. Tell the visitor EXACTLY: "Sorry, I couldn't open that page just now. Would you like me to try again, or is there something else I can help with?" Then STOP and wait for their reply.`);
12590
12576
  } catch {}
12591
12577
  return "OK_NAVIGATE_RELOADING. The page is reloading now and this session is ending. Say NOTHING further — do not confirm the navigation, do not describe the page. The arrival greeting is spoken automatically on the new page; you resume from the visitor's next reply.";
12592
12578
  } catch (e) {
12593
12579
  let t = `Navigation error: ${e?.message || String(e)}`;
12594
- return $("fwh-navigate-mvp ✖", t), Sg("Navigation failed", {
12580
+ return $("fwh-navigate-mvp ✖", t), bg("Navigation failed", {
12595
12581
  spinner: !1,
12596
12582
  icon: "⚠️",
12597
12583
  duration: 1800
12598
12584
  }), t;
12599
12585
  } finally {
12600
- Og(), Cg(900);
12586
+ Eg(), xg(900);
12601
12587
  }
12602
12588
  },
12603
12589
  "fwh-highlight-mvp": async (e) => {
12604
12590
  $("fwh-highlight-mvp ▶", e);
12605
- let t = Qg(e), n = t?.section_id || t?.sectionId, r = t?.section_text || t?.sectionText;
12591
+ let t = Xg(e), n = t?.section_id || t?.sectionId, r = t?.section_text || t?.sectionText;
12606
12592
  if (Rn(3e3), typeof window < "u" && window.__fe_user_nav_during_speech) {
12607
12593
  let e = window.__fe_user_nav_during_speech, t = window.location.pathname;
12608
12594
  if (Date.now() - e.ts >= 3e4) window.__fe_user_nav_during_speech = null;
12609
12595
  else return $("flowengage_highlight ✖ blocked — user navigated during speech", e), `NAV_CHANGED: The visitor navigated from "${e.fromPageName}" to "${e.toPageName}" (current path: ${t}) while you were speaking. STOP the current walkthrough immediately. DO NOT call fwh-highlight-mvp again. Say out loud: "I see you've navigated to the ${e.toPageName} page — do you want me to continue what I was explaining, or shall I guide you through this page?" Wait for the visitor's answer before doing anything else.`;
12610
12596
  }
12611
- e_();
12597
+ Qg();
12612
12598
  let i = ((e) => e && e.replace(/^\d+\.\s*/, "").replace(/^["']|["']$/g, "").trim())(r), a = cr(n || null, i || null);
12613
12599
  if (!a && i) {
12614
12600
  let e = Date.now() + 600;
12615
- for (; !a && Date.now() < e;) await new Promise((e) => setTimeout(e, 50)), e_(), a = cr(null, i);
12601
+ for (; !a && Date.now() < e;) await new Promise((e) => setTimeout(e, 50)), Qg(), a = cr(null, i);
12616
12602
  }
12617
12603
  if (!a) {
12618
12604
  $("fwh-highlight-mvp ✖ no element for:", i || n);
12619
- let { headings: e } = t_(), t = e.length ? `Page headings: ${e.map((e) => `"${e}"`).join(" | ")}. Use one of these EXACT strings for section_text — no numbers, no quotes around them.` : "No headings found — skip highlight and continue speaking.";
12605
+ let { headings: e } = $g(), t = e.length ? `Page headings: ${e.map((e) => `"${e}"`).join(" | ")}. Use one of these EXACT strings for section_text — no numbers, no quotes around them.` : "No headings found — skip highlight and continue speaking.";
12620
12606
  return `HIGHLIGHT_NOT_FOUND: "${i || n}" on the current page. ${t}`;
12621
12607
  }
12622
12608
  return Dn(a), $("fwh-highlight-mvp ✓", i || n), `OK_HIGHLIGHT: "${i || n}". Your NEXT response must be speech only (no tool call) describing THIS section — "${i || n}" — using its own content. Do not ask whether to continue.`;
12623
12609
  },
12624
12610
  "fwh-read-content-mvp": async (e) => {
12625
12611
  $("fwh-read-content-mvp ▶", e);
12626
- let t = Qg(e), n = t?.section_text || t?.sectionText || "";
12612
+ let t = Xg(e), n = t?.section_text || t?.sectionText || "";
12627
12613
  try {
12628
12614
  let e = "";
12629
12615
  if (n) {
12630
12616
  let t = cr(null, n);
12631
12617
  if (!t) return `Could not find section "${n}" on the page.`;
12632
- e = n_(t);
12618
+ e = e_(t);
12633
12619
  } else {
12634
12620
  let t = (document.querySelector("main") || document.querySelector("article") || document.querySelector("[role=\"main\"]") || document.querySelector("#content") || document.querySelector(".content") || document.body).cloneNode(!0);
12635
12621
  t.querySelectorAll("nav, footer, header, aside, script, style, noscript, .nav, .footer, .header, .sidebar, #flowengage-root, .flowengage-shell, .flowengage-widget-root").forEach((e) => e.remove()), e = t.textContent.replace(/\s+/g, " ").trim();
@@ -12641,7 +12627,7 @@ function r_(e) {
12641
12627
  },
12642
12628
  "fwh-page-content-mvp": async (e) => {
12643
12629
  $("fwh-page-content-mvp ▶", e);
12644
- let r = Qg(e), i = r?.url || r?.page_url || "";
12630
+ let r = Xg(e), i = r?.url || r?.page_url || "";
12645
12631
  if ($("fwh-page-content-mvp · url:", i, "siteId:", t, "apiBase:", n || "(empty)"), !i) return $("fwh-page-content-mvp ✖ missing url"), "Missing url parameter.";
12646
12632
  if (!t) return $("fwh-page-content-mvp ✖ no siteId"), "Site is not configured.";
12647
12633
  if (!n) return $("fwh-page-content-mvp ✖ no api base"), "API base URL is missing; cannot fetch page content.";
@@ -12673,7 +12659,7 @@ function r_(e) {
12673
12659
  },
12674
12660
  "fwh-search-mvp": async (e) => {
12675
12661
  $("fwh-search-mvp ▶", e);
12676
- let r = Qg(e).query;
12662
+ let r = Xg(e).query;
12677
12663
  if (!r) return $("fwh-search-mvp ✖ missing query"), "Missing query parameter.";
12678
12664
  if (!t) return $("fwh-search-mvp ✖ no siteId"), "Search unavailable (no siteId configured).";
12679
12665
  if (!n) return $("fwh-search-mvp ✖ no api base"), "Search unavailable (no API base URL).";
@@ -12711,7 +12697,7 @@ function r_(e) {
12711
12697
  "[class*='menu'] a",
12712
12698
  "[class*='header'] a"
12713
12699
  ];
12714
- if (Hg((t) => {
12700
+ if (Bg((t) => {
12715
12701
  for (let r of n) try {
12716
12702
  t.querySelectorAll(r).forEach((t) => {
12717
12703
  if (An(t)) return;
@@ -12719,7 +12705,7 @@ function r_(e) {
12719
12705
  if (!r || !n || n === "#" || n.startsWith("javascript:")) return;
12720
12706
  try {
12721
12707
  let e = t.parentElement;
12722
- if (e && Vg(e).display === "none" && !e.closest("nav, [role='navigation'], header, [class*='nav'], [class*='menu']")) return;
12708
+ if (e && zg(e).display === "none" && !e.closest("nav, [role='navigation'], header, [class*='nav'], [class*='menu']")) return;
12723
12709
  } catch {}
12724
12710
  let i = r.toLowerCase() + "|" + n;
12725
12711
  e.has(i) || e.set(i, {
@@ -12730,7 +12716,7 @@ function r_(e) {
12730
12716
  } catch {}
12731
12717
  t.querySelectorAll("select").forEach((t) => {
12732
12718
  if (An(t)) return;
12733
- let n = Wg(t);
12719
+ let n = Hg(t);
12734
12720
  /nav|menu|page|section|go to/i.test(n || t.name || t.id || "") && Array.from(t.options).forEach((r) => {
12735
12721
  if (!r.value || r.disabled) return;
12736
12722
  let i = r.text.trim();
@@ -12754,7 +12740,7 @@ function r_(e) {
12754
12740
  if ($("fwh-get-current-page-mvp ▶"), typeof window > "u") return "Cannot determine current page (no browser context).";
12755
12741
  let e = window.location.href, t = window.location.pathname, n = document.title || "";
12756
12742
  if (yr()) return $("fwh-get-current-page-mvp ✓ 404 detected", { url: e }), `CURRENT_PAGE_NOT_FOUND. The visitor is currently on a 404 / page-not-found error page (${e}). There is no real content here. Do NOT describe this page, do NOT list sections, do NOT offer a walkthrough, and do NOT describe it from your own knowledge. Tell the visitor plainly that the page they are on doesn't exist, and offer to take them somewhere that does.`;
12757
- let { headings: r, pageTitleHeading: i, introText: a } = t_();
12743
+ let { headings: r, pageTitleHeading: i, introText: a } = $g();
12758
12744
  $("fwh-get-current-page-mvp ✓", {
12759
12745
  url: e,
12760
12746
  path: t,
@@ -12766,7 +12752,7 @@ function r_(e) {
12766
12752
  return `CURRENT_PAGE. URL: ${e} | Title: ${n} | Page sections (${r.length} total): ${s}.${o} *** WALKTHROUGH: do NOT drive it yourself. Do not call fwh-highlight-mvp and do not decide the order — highlighting and section order are handled for you. You will be told which section to describe, one at a time. When told, describe ONLY that section in 3-4 sentences and then stop; never announce another section, never ask whether to continue. ***`;
12767
12753
  },
12768
12754
  "fwh-list-forms-mvp": async () => {
12769
- let e = Kg(), t = qg();
12755
+ let e = Wg(), t = Gg();
12770
12756
  $("fwh-list-forms-mvp ✓", `${e.length} field(s)`, `${t.length} button(s)`);
12771
12757
  let n = e.map((e) => ({
12772
12758
  ...e,
@@ -12780,12 +12766,12 @@ function r_(e) {
12780
12766
  },
12781
12767
  "fwh-fill-form-mvp": async () => "FORM_FILLING_DISABLED: Form filling is not available at this time. Tell the visitor what fields are present (use fwh-list-forms-mvp) and ask them to fill the form themselves.",
12782
12768
  "fwh-click-button-mvp": async (e) => {
12783
- let t = Qg(e), n = (t.button_text ?? t.buttonText ?? t.text ?? "").trim(), r = (t.card_context ?? t.cardContext ?? "").trim();
12769
+ let t = Xg(e), n = (t.button_text ?? t.buttonText ?? t.text ?? "").trim(), r = (t.card_context ?? t.cardContext ?? "").trim();
12784
12770
  if ($("fwh-click-button-mvp ▶", n, r ? `(card_context: ${r})` : ""), !n) return "Missing button_text: pass the visible label, e.g. Conduct Audit.";
12785
- let a = Zg(n, i, r);
12771
+ let a = Yg(n, i, r);
12786
12772
  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.`;
12787
12773
  try {
12788
- Sg(`Clicking ${n}...`, { spinner: !0 });
12774
+ bg(`Clicking ${n}...`, { spinner: !0 });
12789
12775
  try {
12790
12776
  a.scrollIntoView({
12791
12777
  block: "center",
@@ -12794,22 +12780,22 @@ function r_(e) {
12794
12780
  } catch {
12795
12781
  a.scrollIntoView(!0);
12796
12782
  }
12797
- await Ng(a), a.focus?.(), await Fg(a), Ig(a), a.click();
12783
+ await jg(a), a.focus?.(), await Ng(a), Pg(a), a.click();
12798
12784
  let e = (a.textContent || a.value || a.getAttribute("aria-label") || "").trim().slice(0, 80) || "button", t = `OK_CLICK ${e}`;
12799
- return $("fwh-click-button-mvp ✓", t), Sg(`Clicked ${e}`, {
12785
+ return $("fwh-click-button-mvp ✓", t), bg(`Clicked ${e}`, {
12800
12786
  spinner: !1,
12801
12787
  icon: "✅",
12802
12788
  duration: 1200
12803
12789
  }), t;
12804
12790
  } catch (e) {
12805
12791
  let t = `Click failed: ${e?.message || String(e)}`;
12806
- return $("fwh-click-button-mvp ✖", t), Sg("Click failed", {
12792
+ return $("fwh-click-button-mvp ✖", t), bg("Click failed", {
12807
12793
  spinner: !1,
12808
12794
  icon: "⚠️",
12809
12795
  duration: 1800
12810
12796
  }), t;
12811
12797
  } finally {
12812
- Pg(), Cg(700);
12798
+ Mg(), xg(700);
12813
12799
  }
12814
12800
  },
12815
12801
  "fwh-cart-get-mvp": async () => {
@@ -12922,10 +12908,10 @@ function r_(e) {
12922
12908
  clickPageButton: a["fwh-click-button-mvp"]
12923
12909
  };
12924
12910
  }
12925
- var i_ = /^(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;
12926
- function a_() {
12911
+ var n_ = /^(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;
12912
+ function r_() {
12927
12913
  try {
12928
- let { headings: e, pageTitleHeading: t, containerHeadings: n } = t_(), r = new Set((n || []).map((e) => e.trim())), i = (e || []).map((e) => typeof e == "string" ? e : e?.text || "").filter(Boolean).filter((e) => !t || e.trim() !== t.trim()).filter((e) => !i_.test(e.trim())), a = i.filter((e) => !r.has(e.trim()));
12914
+ let { headings: e, pageTitleHeading: t, containerHeadings: n } = $g(), r = new Set((n || []).map((e) => e.trim())), i = (e || []).map((e) => typeof e == "string" ? e : e?.text || "").filter(Boolean).filter((e) => !t || e.trim() !== t.trim()).filter((e) => !n_.test(e.trim())), a = i.filter((e) => !r.has(e.trim()));
12929
12915
  return a.length ? a : i;
12930
12916
  } catch {
12931
12917
  return [];
@@ -12933,7 +12919,7 @@ function a_() {
12933
12919
  }
12934
12920
  //#endregion
12935
12921
  //#region src/utils/wrapVoiceToolsForLogging.js
12936
- function o_(e) {
12922
+ function i_(e) {
12937
12923
  return !e || typeof e != "object" ? e : Object.fromEntries(Object.entries(e).map(([e, t]) => [e, async (n) => {
12938
12924
  let r = wn();
12939
12925
  r ? console.log("[FlowEngage:voice-tool] ▶", e, n) : console.info(`[FlowEngage] voice tool » ${e}`);
@@ -12950,11 +12936,11 @@ function o_(e) {
12950
12936
  }
12951
12937
  //#endregion
12952
12938
  //#region src/components/FlowEngageWidget.jsx
12953
- var s_ = "[PAGE_CONTEXT]";
12954
- function c_(e, t, n) {
12955
- return `${s_} SESSION_CONTEXT (NOT a tool result — do NOT treat as CURRENT_PAGE): Visitor is on: ${e} | Approx headings for awareness only: ${t || ""}. ${n ? `Forms: ${n}. ` : ""}The visitor is ALREADY on this page — do NOT offer to navigate there.`;
12939
+ var a_ = "[PAGE_CONTEXT]";
12940
+ function o_(e, t, n) {
12941
+ return `${a_} SESSION_CONTEXT (NOT a tool result — do NOT treat as CURRENT_PAGE): Visitor is on: ${e} | Approx headings for awareness only: ${t || ""}. ${n ? `Forms: ${n}. ` : ""}The visitor is ALREADY on this page — do NOT offer to navigate there.`;
12956
12942
  }
12957
- var l_ = {
12943
+ var s_ = {
12958
12944
  blue: "#135bd8",
12959
12945
  red: "#ef334b",
12960
12946
  yellow: "#ffbd2e",
@@ -12962,7 +12948,7 @@ var l_ = {
12962
12948
  highlight: "rgba(255,255,255,0.9)",
12963
12949
  green: "#10b981"
12964
12950
  };
12965
- function u_(e) {
12951
+ function c_(e) {
12966
12952
  if (!Array.isArray(e) || e.length < 2) return "linear-gradient(145deg, #dce8f022 0%, #e8dff522 45%, #f5e0e022 100%), #f7f8fa";
12967
12953
  let [t, n, r] = e;
12968
12954
  return e.length >= 3 && r ? [
@@ -12976,12 +12962,12 @@ function u_(e) {
12976
12962
  "#f7f8fa"
12977
12963
  ].join(", ");
12978
12964
  }
12979
- function d_(e) {
12965
+ function l_(e) {
12980
12966
  if (!e || typeof e != "string") return "#1a1a1a";
12981
12967
  let t = e.replace("#", ""), n = t.length === 3 ? t.split("").map((e) => e + e).join("") : t, r = parseInt(n.slice(0, 2), 16) / 255, i = parseInt(n.slice(2, 4), 16) / 255, a = parseInt(n.slice(4, 6), 16) / 255, o = (e) => e <= .04045 ? e / 12.92 : ((e + .055) / 1.055) ** 2.4;
12982
12968
  return .2126 * o(r) + .7152 * o(i) + .0722 * o(a) > .179 ? "#1a1a1a" : "#ffffff";
12983
12969
  }
12984
- function f_(t) {
12970
+ function u_(t) {
12985
12971
  let [n, r] = e.useState(null), i = typeof t == "string" ? t.trim() : "";
12986
12972
  return e.useEffect(() => {
12987
12973
  if (!i) {
@@ -12999,8 +12985,8 @@ function f_(t) {
12999
12985
  };
13000
12986
  }, [i]), n;
13001
12987
  }
13002
- function p_({ logo: t, style: n }) {
13003
- let r = f_(typeof t == "string" ? t : null);
12988
+ function d_({ logo: t, style: n }) {
12989
+ let r = u_(typeof t == "string" ? t : null);
13004
12990
  if (!t) return null;
13005
12991
  if (typeof t == "string") return r ? /* @__PURE__ */ g("img", {
13006
12992
  src: r,
@@ -13025,7 +13011,7 @@ function p_({ logo: t, style: n }) {
13025
13011
  children: i
13026
13012
  }) : null;
13027
13013
  }
13028
- function m_({ title: e }) {
13014
+ function f_({ title: e }) {
13029
13015
  return /* @__PURE__ */ g("div", {
13030
13016
  style: {
13031
13017
  width: "100%",
@@ -13043,18 +13029,18 @@ function m_({ title: e }) {
13043
13029
  children: String(e || "FE").split(/\s+/).filter(Boolean).slice(0, 2).map((e) => e[0]?.toUpperCase() || "").join("") || "FE"
13044
13030
  });
13045
13031
  }
13046
- function h_(e, t) {
13032
+ function p_(e, t) {
13047
13033
  let n = (t || "").trim();
13048
13034
  return n ? !!(/\b(let'?s|let us)\s+(end|stop|finish|wrap up|close)\s+(the\s+)?(voice\s+)?(session|call|chat)\b/i.test(n) || /\bend\s+(this\s+)?(the\s+)?(voice\s+)?(session|call|chat)\b/i.test(n) || /\b(hang\s+up|disconnect)\b/i.test(n) || e === "bot" && (/\b(that'?s all|we'?re done)\b/i.test(n) || /\b(goodbye|bye)\b/i.test(n) || /\b(I'?ll|I will|Let me|I can|I'?m going to)\s+(end|close)\s+(the\s+)?(voice\s+)?(session|call)\b/i.test(n) || /\b(ending|closing)\s+(the\s+)?(voice\s+)?session\b|\bvoice\s+session\s+(is\s+)?(now\s+)?(ended|over|closing)\b/i.test(n) || /\b(session|call)\s+(is\s+)?(now\s+)?(ended|over)\b/i.test(n) || /\bwe\s+can\s+end\s+(the\s+)?(session|call)?\s*(here|now)\b/i.test(n) || /\b(wrapping\s+up|signing\s+off)\b/i.test(n))) : !1;
13049
13035
  }
13050
- function g_({ orbColors: e, ...t }) {
13051
- return /* @__PURE__ */ g(cg, {
13036
+ function m_({ orbColors: e, ...t }) {
13037
+ return /* @__PURE__ */ g(og, {
13052
13038
  colors: e,
13053
13039
  ...t
13054
13040
  });
13055
13041
  }
13056
- function __({ copy: e, orbColors: t, primaryColor: n, onYes: r, onLater: i, isMobile: a, isClosing: o }) {
13057
- let s = n || l_.green, c = d_(s), l = a ? 72 : 94, u = /* @__PURE__ */ _("div", {
13042
+ function h_({ copy: e, orbColors: t, primaryColor: n, onYes: r, onLater: i, isMobile: a, isClosing: o }) {
13043
+ let s = n || s_.green, c = l_(s), l = a ? 72 : 94, u = /* @__PURE__ */ _("div", {
13058
13044
  style: {
13059
13045
  display: "flex",
13060
13046
  alignItems: a ? "flex-end" : "center",
@@ -13180,7 +13166,7 @@ function __({ copy: e, orbColors: t, primaryColor: n, onYes: r, onLater: i, isMo
13180
13166
  delay: 0
13181
13167
  },
13182
13168
  style: { flexShrink: 0 },
13183
- children: /* @__PURE__ */ g(g_, {
13169
+ children: /* @__PURE__ */ g(m_, {
13184
13170
  size: l,
13185
13171
  orbColors: t
13186
13172
  })
@@ -13212,8 +13198,8 @@ function __({ copy: e, orbColors: t, primaryColor: n, onYes: r, onLater: i, isMo
13212
13198
  children: u
13213
13199
  })] });
13214
13200
  }
13215
- function v_({ copy: e, orbColors: t, primaryColor: n, onVoice: r, onText: i, onClose: a, isMobile: o, isClosing: s }) {
13216
- let c = n || l_.green, l = d_(c);
13201
+ function g_({ copy: e, orbColors: t, primaryColor: n, onVoice: r, onText: i, onClose: a, isMobile: o, isClosing: s }) {
13202
+ let c = n || s_.green, l = l_(c);
13217
13203
  return /* @__PURE__ */ _(eh.div, {
13218
13204
  initial: {
13219
13205
  scale: 50 / 350,
@@ -13284,7 +13270,7 @@ function v_({ copy: e, orbColors: t, primaryColor: n, onVoice: r, onText: i, onC
13284
13270
  children: /* @__PURE__ */ g("polyline", { points: "6 9 12 15 18 9" })
13285
13271
  })
13286
13272
  }),
13287
- /* @__PURE__ */ g(g_, {
13273
+ /* @__PURE__ */ g(m_, {
13288
13274
  size: 72,
13289
13275
  orbColors: t
13290
13276
  }),
@@ -13364,9 +13350,9 @@ function v_({ copy: e, orbColors: t, primaryColor: n, onVoice: r, onText: i, onC
13364
13350
  ]
13365
13351
  });
13366
13352
  }
13367
- function y_({ 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" }) {
13353
+ function __({ 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" }) {
13368
13354
  c(() => (console.log("[FlowEngage:VoiceDebug] 🔵 VoiceMode MOUNTED"), () => console.log("[FlowEngage:VoiceDebug] 🔴 VoiceMode UNMOUNTED")), []);
13369
- let [T, E] = m("idle"), [D, O] = m(!1), [k, A] = m(!1), [ee, te] = m(!1), [ne, j] = m(""), [M, re] = m(""), ie = p(!1), N = p(!1), P = p(null), ae = p(0), oe = p(""), se = p(!1), ce = p(0), le = p(!1), ue = p(!1), de = p(!1), fe = p([]), pe = p(null), me = p(null), he = (e) => {
13355
+ let [T, E] = m("idle"), [D, O] = m(!1), [k, A] = m(!1), [ee, te] = m(!1), [ne, j] = m(""), [M, N] = m(""), re = p(!1), P = p(!1), ie = p(null), ae = p(0), oe = p(""), se = p(!1), ce = p(0), le = p(!1), ue = p(!1), de = p(!1), fe = p([]), pe = p(null), me = p(null), he = (e) => {
13370
13356
  le.current = e, e || (ue.current = !1), F.current?.setWalkthroughActive?.(e);
13371
13357
  };
13372
13358
  me.current = async () => {
@@ -13413,14 +13399,14 @@ function y_({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13413
13399
  I.current || (I.current = !0, ye.current?.());
13414
13400
  });
13415
13401
  }, [l]), V = o(() => {
13416
- P.current &&= (clearTimeout(P.current), null);
13402
+ ie.current &&= (clearTimeout(ie.current), null);
13417
13403
  }, []);
13418
13404
  c(() => {
13419
13405
  if (y) {
13420
- ie.current = !1;
13406
+ re.current = !1;
13421
13407
  return;
13422
13408
  }
13423
- if (ie.current = !0, N.current = !1, te(!1), V(), se.current) {
13409
+ if (re.current = !0, P.current = !1, te(!1), V(), se.current) {
13424
13410
  se.current = !1, F.current?.setMicMuted?.(!1);
13425
13411
  let e = oe.current;
13426
13412
  oe.current = "", F.current?.injectAgentSpeech?.("Thanks — I already have your email on file.", "interrupt"), e && F.current?.sendUserMessage?.(`The visitor's email is already on file — do not ask for it. Answer their question now: "${e}"`);
@@ -13428,8 +13414,8 @@ function y_({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13428
13414
  F.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.");
13429
13415
  }, [y, V]);
13430
13416
  let Ie = /(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, Le = /(that covers everything|that was all|covered everything|that(?:'|’)?s everything)/i, Re = /^((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, ze = /^((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, Be = (e) => String(e || "").replace(/[\s.,!?]*((uh+|um+|er+|hmm+|mm+)[\s.,!?]*)+$/i, "").trim(), Ve = o(() => {
13431
- V(), P.current = setTimeout(() => {
13432
- if (!(!N.current || ie.current)) if (ae.current < 3) {
13417
+ V(), ie.current = setTimeout(() => {
13418
+ if (!(!P.current || re.current)) if (ae.current < 3) {
13433
13419
  ae.current += 1;
13434
13420
  try {
13435
13421
  F.current?.injectAgentSpeech?.("I still need your email in the box below to continue — could you enter it, please?", "queue");
@@ -13439,7 +13425,7 @@ function y_({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13439
13425
  try {
13440
13426
  F.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");
13441
13427
  } catch {}
13442
- N.current = !1, te(!1), V(), Me.current = !0;
13428
+ P.current = !1, te(!1), V(), Me.current = !0;
13443
13429
  }
13444
13430
  }, 1e4);
13445
13431
  }, [V]), He = o(async (e) => {
@@ -13493,7 +13479,7 @@ function y_({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13493
13479
  if ((await navigator.mediaDevices.getUserMedia({ audio: !0 })).getTracks().forEach((e) => e.stop()), e) return;
13494
13480
  l.current = [], ve.current = "", I.current = !1, R.current = !1, we.current = !1, Te.current = "minimized", Dr({ onBeforeNavigate: () => {
13495
13481
  if (i && l.current.length > 0) try {
13496
- let e = _g(l.current);
13482
+ let e = hg(l.current);
13497
13483
  e && L(i, e);
13498
13484
  } catch {}
13499
13485
  if (!qn()) {
@@ -13515,7 +13501,7 @@ function y_({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13515
13501
  }
13516
13502
  Ce();
13517
13503
  } });
13518
- let t = o_(r_({
13504
+ let t = i_(t_({
13519
13505
  siteId: i || null,
13520
13506
  apiBaseUrl: a || null,
13521
13507
  chatId: s || null,
@@ -13525,7 +13511,7 @@ function y_({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13525
13511
  Me.current = !0;
13526
13512
  },
13527
13513
  requestEmailCollection: () => {
13528
- b && (ie.current || N.current || (N.current = !0, ae.current = 0, te(!0), Ve()));
13514
+ b && (re.current || P.current || (P.current = !0, ae.current = 0, te(!0), Ve()));
13529
13515
  }
13530
13516
  })), n = i ? xe(i) : null, r = !!n?.transcript, u = i ? je(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 = {
13531
13517
  apiBaseUrl: a,
@@ -13560,14 +13546,14 @@ function y_({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13560
13546
  let e = f || "";
13561
13547
  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}`);
13562
13548
  }
13563
- 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, 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, re = !1, P = 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, ye = !1, Se = !1, ke = b && !!y && !de.current, He = await bh.startSession({
13549
+ 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, 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, N = !1, ie = 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, ye = !1, Se = !1, ke = b && !!y && !de.current, He = await vh.startSession({
13564
13550
  ...x,
13565
13551
  onConnect: ({ conversationId: e }) => {
13566
13552
  Ee.current = e, De.current = Date.now(), console.log("[FlowEngage] 🎙️ AI chat session connected:", e);
13567
13553
  },
13568
13554
  onUnhandledClientToolCall: (e) => console.error("[FlowEngage] Unhandled tool:", e?.tool_name),
13569
13555
  onSessionInfo: ({ emailOnFile: e }) => {
13570
- de.current = !!e, e && (ie.current = !0, N.current = !1, te(!1), V(), console.log("[FlowEngage] email already on file per server — gate disabled"));
13556
+ de.current = !!e, e && (re.current = !0, P.current = !1, te(!1), V(), console.log("[FlowEngage] email already on file per server — gate disabled"));
13571
13557
  },
13572
13558
  onAgentTurnEnd: () => {
13573
13559
  e || le.current && (ue.current || se.current || setTimeout(() => me.current?.(), 250));
@@ -13582,7 +13568,7 @@ function y_({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13582
13568
  return;
13583
13569
  }
13584
13570
  if (t === "user-speaking") {
13585
- if (N.current && !ie.current && Ve(), Fe.current &&= (clearTimeout(Fe.current), null), z.current === "speaking") return;
13571
+ if (P.current && !re.current && Ve(), Fe.current &&= (clearTimeout(Fe.current), null), z.current === "speaking") return;
13586
13572
  try {
13587
13573
  On();
13588
13574
  } catch {}
@@ -13600,7 +13586,7 @@ function y_({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13600
13586
  Me.current = !1, B();
13601
13587
  return;
13602
13588
  }
13603
- if (ke && !Se && !ie.current && !de.current) {
13589
+ if (ke && !Se && !re.current && !de.current) {
13604
13590
  Se = !0, A = !0, ne = !0;
13605
13591
  try {
13606
13592
  F.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.");
@@ -13612,10 +13598,10 @@ function y_({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13612
13598
  F.current?.sendContextualUpdate?.(ee);
13613
13599
  } catch {}
13614
13600
  }
13615
- if (P && !re) {
13616
- re = !0;
13601
+ if (ie && !N) {
13602
+ N = !0;
13617
13603
  try {
13618
- F.current?.sendContextualUpdate?.(P);
13604
+ F.current?.sendContextualUpdate?.(ie);
13619
13605
  } catch {}
13620
13606
  }
13621
13607
  if (j && !ne) {
@@ -13632,7 +13618,7 @@ function y_({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13632
13618
  onMessage: (t) => {
13633
13619
  if (e || se.current && t.role !== "user" && !/email/i.test(String(t.message || ""))) return;
13634
13620
  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 || ""));
13635
- if (!n && !r && t.role === "user" && Ie.test(String(t.message || ""))) typeof window < "u" && (window.__fe_user_nav_during_speech = null), he(!0), ue.current = !1, ce.current = 0, ge.current = -1, fe.current = a_(), pe.current = typeof window < "u" ? window.location.pathname : null, setTimeout(() => me.current?.(), 400), console.log(`[FlowEngage] walkthrough armed — ${fe.current.length} sections on this page`);
13621
+ if (!n && !r && t.role === "user" && Ie.test(String(t.message || ""))) typeof window < "u" && (window.__fe_user_nav_during_speech = null), he(!0), ue.current = !1, ce.current = 0, ge.current = -1, fe.current = r_(), pe.current = typeof window < "u" ? window.location.pathname : null, setTimeout(() => me.current?.(), 400), console.log(`[FlowEngage] walkthrough armed — ${fe.current.length} sections on this page`);
13636
13622
  else if (!n && t.role === "user" && le.current) {
13637
13623
  let e = String(t.message || "").trim(), n = Be(e), r = (e) => !!e && (Re.test(e) || ze.test(e));
13638
13624
  !n || r(e) || r(n) ? ue.current && (ue.current = !1, console.debug("[FlowEngage] walkthrough resumed by visitor"), setTimeout(() => me.current?.(), 300)) : (console.log("[FlowEngage] walkthrough ended — visitor moved to a new topic"), pe.current = null, fe.current = [], he(!1));
@@ -13643,16 +13629,16 @@ function y_({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13643
13629
  }
13644
13630
  let a = t.role === "user" ? "user" : "bot", o = t.message || t.text || t.content || "";
13645
13631
  if (o) {
13646
- if (a === "user" && (ve.current = o, typeof window < "u" && (window.__fe_user_nav_during_speech = null), Pe.current = !0, Ne.current &&= (clearTimeout(Ne.current), null), z.current !== "speaking" && (E("thinking"), z.current = "thinking"), ke && !ye && !ie.current && !de.current && (ye = !0, oe.current = o, se.current = !0, F.current?.injectAgentSpeech?.("Before I answer that, could you please enter your email in the text box below?", "interrupt"), F.current?.setMicMuted?.(!0), N.current || (N.current = !0, ae.current = 0, te(!0), Ve()))), l.current = [...l.current, {
13632
+ if (a === "user" && (ve.current = o, typeof window < "u" && (window.__fe_user_nav_during_speech = null), Pe.current = !0, Ne.current &&= (clearTimeout(Ne.current), null), z.current !== "speaking" && (E("thinking"), z.current = "thinking"), ke && !ye && !re.current && !de.current && (ye = !0, oe.current = o, se.current = !0, F.current?.injectAgentSpeech?.("Before I answer that, could you please enter your email in the text box below?", "interrupt"), F.current?.setMicMuted?.(!0), P.current || (P.current = !0, ae.current = 0, te(!0), Ve()))), l.current = [...l.current, {
13647
13633
  sender: a,
13648
13634
  message: o,
13649
13635
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
13650
13636
  debug: t.debug
13651
13637
  }], i) try {
13652
- let e = _g(l.current);
13638
+ let e = hg(l.current);
13653
13639
  e && L(i, e);
13654
13640
  } catch {}
13655
- if (h_(a, o)) {
13641
+ if (p_(a, o)) {
13656
13642
  Me.current = !0;
13657
13643
  return;
13658
13644
  }
@@ -13712,7 +13698,7 @@ function y_({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13712
13698
  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(" | "));
13713
13699
  } catch {}
13714
13700
  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` : "";
13715
- He.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.`), He.sendContextualUpdate(c_(e, o, a));
13701
+ He.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.`), He.sendContextualUpdate(o_(e, o, a));
13716
13702
  } catch {}
13717
13703
  if (typeof window < "u") {
13718
13704
  let t = window.location.pathname, n = Date.now(), r = (e) => {
@@ -13748,7 +13734,7 @@ function y_({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13748
13734
  F.current?.sendUserMessage?.(`[SYSTEM: YOU just navigated the visitor to the "${m}" page (${c}) at their request — this was YOUR action, not theirs. Page title: "${l}". Sections: ${JSON.stringify(u)}. Say: "Here we are on the ${m} page." Then introduce this page in 2-3 sentences, and finish by asking: "Would you like me to walk you through it section by section?" NEVER say "I see you've navigated" — the visitor did not navigate, you did. Do NOT call fwh-navigate-mvp again. Wait for their answer before describing sections.]`, { suppressQuestion: !0 });
13749
13735
  } catch {}
13750
13736
  try {
13751
- F.current?.sendContextualUpdate?.(c_(c, d));
13737
+ F.current?.sendContextualUpdate?.(o_(c, d));
13752
13738
  } catch {}
13753
13739
  return;
13754
13740
  }
@@ -13763,7 +13749,7 @@ function y_({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13763
13749
  F.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.]`);
13764
13750
  } catch {}
13765
13751
  try {
13766
- F.current?.sendContextualUpdate?.(c_(c, d));
13752
+ F.current?.sendContextualUpdate?.(o_(c, d));
13767
13753
  } catch {}
13768
13754
  };
13769
13755
  c = window.history.pushState.bind(window.history), window.history.pushState = (...e) => {
@@ -13787,7 +13773,7 @@ function y_({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13787
13773
  if (i) try {
13788
13774
  je(i);
13789
13775
  } catch {}
13790
- typeof window < "u" && (window.__fe_user_nav_during_speech = null), Or(), Ne.current &&= (clearTimeout(Ne.current), null), Fe.current &&= (clearTimeout(Fe.current), null), P.current &&= (clearTimeout(P.current), null), Pe.current = !1, z.current = "idle", c && typeof window < "u" && (window.history.pushState = c), d && typeof window < "u" && window.removeEventListener("popstate", d);
13776
+ typeof window < "u" && (window.__fe_user_nav_during_speech = null), Or(), Ne.current &&= (clearTimeout(Ne.current), null), Fe.current &&= (clearTimeout(Fe.current), null), ie.current &&= (clearTimeout(ie.current), null), Pe.current = !1, z.current = "idle", c && typeof window < "u" && (window.history.pushState = c), d && typeof window < "u" && window.removeEventListener("popstate", d);
13791
13777
  let t = o || F.current, n = Ee.current, f = De.current;
13792
13778
  if (t?.endSession?.().catch(() => {}), n && s && a) {
13793
13779
  let e = f ? Math.round((Date.now() - f) / 1e3) : 0, t = JSON.stringify({
@@ -13836,10 +13822,10 @@ function y_({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13836
13822
  e?.preventDefault?.();
13837
13823
  let t = ne.trim().toLowerCase();
13838
13824
  if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t)) {
13839
- re("Please enter a valid email address.");
13825
+ N("Please enter a valid email address.");
13840
13826
  return;
13841
13827
  }
13842
- re(""), ie.current = !0, N.current = !1, V(), te(!1), j(""), se.current = !1;
13828
+ N(""), re.current = !0, P.current = !1, V(), te(!1), j(""), se.current = !1;
13843
13829
  try {
13844
13830
  typeof v == "function" && await v(t);
13845
13831
  } catch {}
@@ -13899,7 +13885,7 @@ function y_({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13899
13885
  autoFocus: !0,
13900
13886
  value: ne,
13901
13887
  onChange: (e) => {
13902
- j(e.target.value), M && re("");
13888
+ j(e.target.value), M && N("");
13903
13889
  },
13904
13890
  placeholder: "you@example.com",
13905
13891
  style: {
@@ -13975,7 +13961,7 @@ function y_({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13975
13961
  },
13976
13962
  children: "Muted"
13977
13963
  }),
13978
- /* @__PURE__ */ g(g_, {
13964
+ /* @__PURE__ */ g(m_, {
13979
13965
  size: 72,
13980
13966
  voiceState: T,
13981
13967
  isMuted: D,
@@ -14047,7 +14033,7 @@ function y_({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
14047
14033
  y2: "23"
14048
14034
  })
14049
14035
  ]
14050
- }) : /* @__PURE__ */ g(xh, {
14036
+ }) : /* @__PURE__ */ g(yh, {
14051
14037
  size: 16,
14052
14038
  color: "currentColor"
14053
14039
  })
@@ -14069,7 +14055,7 @@ function y_({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
14069
14055
  padding: 0,
14070
14056
  flexShrink: 0
14071
14057
  },
14072
- children: /* @__PURE__ */ g(kh, {
14058
+ children: /* @__PURE__ */ g(Dh, {
14073
14059
  size: 16,
14074
14060
  color: "currentColor"
14075
14061
  })
@@ -14118,7 +14104,7 @@ function y_({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
14118
14104
  onMouseLeave: (e) => {
14119
14105
  e.currentTarget.style.background = "none";
14120
14106
  },
14121
- children: [/* @__PURE__ */ g(Ah, {}), C]
14107
+ children: [/* @__PURE__ */ g(Oh, {}), C]
14122
14108
  }),
14123
14109
  /* @__PURE__ */ _("button", {
14124
14110
  onClick: () => {
@@ -14147,7 +14133,7 @@ function y_({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
14147
14133
  onMouseLeave: (e) => {
14148
14134
  e.currentTarget.style.background = "none";
14149
14135
  },
14150
- children: [/* @__PURE__ */ g(jh, {}), w]
14136
+ children: [/* @__PURE__ */ g(kh, {}), w]
14151
14137
  }),
14152
14138
  /* @__PURE__ */ g("button", {
14153
14139
  onClick: () => A(!1),
@@ -14199,7 +14185,7 @@ function y_({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
14199
14185
  ]
14200
14186
  });
14201
14187
  }
14202
- function b_({ orbColors: e }) {
14188
+ function v_({ orbColors: e }) {
14203
14189
  let t = Array.isArray(e) && e.length > 0 ? e : [
14204
14190
  "#135bd8",
14205
14191
  "#ef334b",
@@ -14218,7 +14204,7 @@ function b_({ orbColors: e }) {
14218
14204
  `.replace(/\s+/g, " ").trim()
14219
14205
  } });
14220
14206
  }
14221
- var x_ = () => /* @__PURE__ */ g("div", {
14207
+ var y_ = () => /* @__PURE__ */ g("div", {
14222
14208
  style: {
14223
14209
  display: "flex",
14224
14210
  marginBottom: "12px",
@@ -14248,7 +14234,7 @@ var x_ = () => /* @__PURE__ */ g("div", {
14248
14234
  } }, e))
14249
14235
  })
14250
14236
  });
14251
- function S_({ 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: P, webRTCError: ae, micError: oe, setMicError: se, dismissCallError: ce, activeCallId: le, isCallMuted: ue, toggleCallMute: de, endWebRTCCall: fe, formatCallDuration: pe, callDurationSeconds: me, isCallMinimized: he, onExpand: ge, onCollapse: F, onStartVoice: _e, voiceEnabled: ve, headerBgColor: ye, onNewChat: I, showPoweredBy: be, privacyPolicyUrl: L, getVisitorChatHistory: xe, resumeChat: Se, isSessionRestoring: R, isClosing: Ce }) {
14237
+ function b_({ 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: N, emailCaptureSuccess: re, replyContext: P, setReplyContext: ie, webRTCError: ae, micError: oe, setMicError: se, dismissCallError: ce, activeCallId: le, isCallMuted: ue, toggleCallMute: de, endWebRTCCall: fe, formatCallDuration: pe, callDurationSeconds: me, isCallMinimized: he, onExpand: ge, onCollapse: F, onStartVoice: _e, voiceEnabled: ve, headerBgColor: ye, onNewChat: I, showPoweredBy: be, privacyPolicyUrl: L, getVisitorChatHistory: xe, resumeChat: Se, isSessionRestoring: R, isClosing: Ce }) {
14252
14238
  let we = l.length > 0, Te = T || E || w, Ee = !!le, [De, Oe] = m(!1), [ke, Ae] = m(!1), [je, Me] = m([]), [z, Ne] = m(!1), Pe = p(null), [Fe, B] = m(() => typeof window < "u" ? window.visualViewport?.height ?? window.innerHeight : 600), [V, Ie] = m(0);
14253
14239
  c(() => {
14254
14240
  if (!s) return;
@@ -14388,7 +14374,7 @@ function S_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
14388
14374
  justifyContent: "center",
14389
14375
  height: "40px"
14390
14376
  },
14391
- children: i ? /* @__PURE__ */ g(p_, {
14377
+ children: i ? /* @__PURE__ */ g(d_, {
14392
14378
  logo: i,
14393
14379
  style: {
14394
14380
  height: "34px",
@@ -14401,7 +14387,7 @@ function S_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
14401
14387
  height: "40px",
14402
14388
  flexShrink: 0
14403
14389
  },
14404
- children: /* @__PURE__ */ g(m_, { title: e.chatTitle })
14390
+ children: /* @__PURE__ */ g(f_, { title: e.chatTitle })
14405
14391
  })
14406
14392
  }), o && /* @__PURE__ */ g("div", {
14407
14393
  style: {
@@ -14684,7 +14670,7 @@ function S_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
14684
14670
  })
14685
14671
  ]
14686
14672
  }),
14687
- /* @__PURE__ */ g($h, {
14673
+ /* @__PURE__ */ g(Zh, {
14688
14674
  webRTCError: ae,
14689
14675
  micError: oe,
14690
14676
  setMicError: se,
@@ -14692,7 +14678,7 @@ function S_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
14692
14678
  isRateLimited: E,
14693
14679
  rateLimitMessage: D
14694
14680
  }),
14695
- he && /* @__PURE__ */ g(gg, {
14681
+ he && /* @__PURE__ */ g(mg, {
14696
14682
  agentName: v,
14697
14683
  agentHeadshot: y,
14698
14684
  fallbackAgentName: b,
@@ -14826,17 +14812,17 @@ function S_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
14826
14812
  children: "No previous chats found."
14827
14813
  })
14828
14814
  })]
14829
- }) : null, we ? /* @__PURE__ */ g(Xh, {
14815
+ }) : null, we ? /* @__PURE__ */ g(Jh, {
14830
14816
  chatHistory: l,
14831
14817
  isAiTyping: u,
14832
14818
  isLoading: T,
14833
14819
  isAgentTyping: d,
14834
- setReplyContext: P,
14835
- TypingDots: x_,
14820
+ setReplyContext: ie,
14821
+ TypingDots: y_,
14836
14822
  primaryColor: n,
14837
14823
  agentHeadshot: y,
14838
14824
  agentDisplayName: v || b,
14839
- botAvatarNode: /* @__PURE__ */ g(b_, { orbColors: t })
14825
+ botAvatarNode: /* @__PURE__ */ g(v_, { orbColors: t })
14840
14826
  }) : R ? /* @__PURE__ */ _("div", {
14841
14827
  style: {
14842
14828
  flex: 1,
@@ -14877,7 +14863,7 @@ function S_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
14877
14863
  padding: "28px 24px"
14878
14864
  },
14879
14865
  children: [
14880
- /* @__PURE__ */ g(g_, {
14866
+ /* @__PURE__ */ g(m_, {
14881
14867
  size: 94,
14882
14868
  orbColors: t
14883
14869
  }),
@@ -14927,7 +14913,7 @@ function S_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
14927
14913
  ]
14928
14914
  })]
14929
14915
  }),
14930
- ie && /* @__PURE__ */ _("div", {
14916
+ re && /* @__PURE__ */ _("div", {
14931
14917
  style: {
14932
14918
  margin: "0 16px 8px",
14933
14919
  padding: "9px 14px",
@@ -14968,7 +14954,7 @@ function S_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
14968
14954
  zIndex: 1,
14969
14955
  padding: ne ? "6px 0 0" : "12px 0 0"
14970
14956
  },
14971
- children: /* @__PURE__ */ g(Qh, {
14957
+ children: /* @__PURE__ */ g(Xh, {
14972
14958
  input: x,
14973
14959
  setInput: S,
14974
14960
  onSubmit: C,
@@ -14978,8 +14964,8 @@ function S_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
14978
14964
  showVoiceToggle: f === "agent",
14979
14965
  activeScreen: f,
14980
14966
  inputDisabled: Te,
14981
- replyContext: N,
14982
- clearReplyContext: () => P(null),
14967
+ replyContext: P,
14968
+ clearReplyContext: () => ie(null),
14983
14969
  onFileSelect: k,
14984
14970
  selectedFile: O,
14985
14971
  onRemoveSelectedFile: A,
@@ -14988,7 +14974,7 @@ function S_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
14988
14974
  requiresEmail: ne,
14989
14975
  emailInput: j,
14990
14976
  setEmailInput: M,
14991
- emailError: re,
14977
+ emailError: N,
14992
14978
  inputPlaceholder: e.inputPlaceholder
14993
14979
  })
14994
14980
  }),
@@ -15042,14 +15028,14 @@ function S_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
15042
15028
  ]
15043
15029
  });
15044
15030
  }
15045
- function C_() {
15046
- 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: P, startNewChat: se, acceptCall: ce, rejectCall: le, endWebRTCCall: ue, toggleCallMute: de, dismissCallError: fe, startTyping: pe, stopTyping: me, updateTypingDraft: he, getVisitorChatHistory: ge, resumeChat: F, isSessionRestoring: _e, openToChatCounter: ve, voiceEndCounter: ye } = Cn();
15031
+ function x_() {
15032
+ 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: N, captureVisitorEmail: re, setVoiceMode: P, endConversation: ie, startNewChat: se, acceptCall: ce, rejectCall: le, endWebRTCCall: ue, toggleCallMute: de, dismissCallError: fe, startTyping: pe, stopTyping: me, updateTypingDraft: he, getVisitorChatHistory: ge, resumeChat: F, isSessionRestoring: _e, openToChatCounter: ve, voiceEndCounter: ye } = Cn();
15047
15033
  c(() => {
15048
15034
  try {
15049
15035
  or();
15050
15036
  } catch {}
15051
15037
  }, []), c(() => {
15052
- ve && W !== "voice_mode" && W !== "text_chat" && W !== "call_screen" && (N?.(!1), $e("text_chat"));
15038
+ ve && W !== "voice_mode" && W !== "text_chat" && W !== "call_screen" && (P?.(!1), $e("text_chat"));
15053
15039
  }, [ve]);
15054
15040
  let I = t?.widgetSettings || {}, be = n?.widgetSettings || {}, L = {
15055
15041
  ...I.branding || {},
@@ -15064,7 +15050,7 @@ function C_() {
15064
15050
  small: 50,
15065
15051
  medium: 64,
15066
15052
  large: 80
15067
- }, Ae = ke[R.orbSize] || ke.small, je = R.position || "bottom-right", Me = L.fallbackAgentName || "Agent", z = u_(Ee ?? R.chatBgColors), Ne = L.logo || L.logoUrl || null, Pe = A || "en", Fe = I.recommendations?.[Pe] || [], B = (be.recommendations?.[Pe] ?? Fe).filter((e) => String(e?.label ?? "").trim()).map((e, t) => ({
15053
+ }, Ae = ke[R.orbSize] || ke.small, je = R.position || "bottom-right", Me = L.fallbackAgentName || "Agent", z = c_(Ee ?? R.chatBgColors), Ne = L.logo || L.logoUrl || null, Pe = A || "en", Fe = I.recommendations?.[Pe] || [], B = (be.recommendations?.[Pe] ?? Fe).filter((e) => String(e?.label ?? "").trim()).map((e, t) => ({
15068
15054
  id: e.key || `qr-${t}`,
15069
15055
  label: e.label,
15070
15056
  message: e.label,
@@ -15122,11 +15108,11 @@ function C_() {
15122
15108
  } catch {}
15123
15109
  let n = we(), r = Je ? xe(Je) : null, i = n || !!r?.transcript;
15124
15110
  if (t) {
15125
- re?.({ notifyChatInitiated: !0 }), N?.(!0), $e("voice_mode");
15111
+ N?.({ notifyChatInitiated: !0 }), P?.(!0), $e("voice_mode");
15126
15112
  return;
15127
15113
  }
15128
15114
  if (De()) {
15129
- re?.({ notifyChatInitiated: !1 }), $e("text_chat");
15115
+ N?.({ notifyChatInitiated: !1 }), $e("text_chat");
15130
15116
  return;
15131
15117
  }
15132
15118
  if (i) {
@@ -15134,7 +15120,7 @@ function C_() {
15134
15120
  $e("minimized_orb");
15135
15121
  return;
15136
15122
  }
15137
- re?.({ notifyChatInitiated: !0 }), N?.(!0), $e("voice_mode");
15123
+ N?.({ notifyChatInitiated: !0 }), P?.(!0), $e("voice_mode");
15138
15124
  return;
15139
15125
  }
15140
15126
  if (Je) try {
@@ -15155,7 +15141,7 @@ function C_() {
15155
15141
  let Ot = o(() => {
15156
15142
  mt(null), gt("");
15157
15143
  }, []), kt = o((e) => {
15158
- let t = Gh(e);
15144
+ let t = Uh(e);
15159
15145
  if (t) {
15160
15146
  mt(null), gt(t);
15161
15147
  return;
@@ -15198,7 +15184,7 @@ function C_() {
15198
15184
  hasIncomingCall: !!w?.callId,
15199
15185
  activeCallId: T,
15200
15186
  callConnectionState: E
15201
- }), Ct.current = e, W === "voice_mode" && N?.(!1), re?.(), At());
15187
+ }), Ct.current = e, W === "voice_mode" && P?.(!1), N?.(), At());
15202
15188
  }
15203
15189
  }, [
15204
15190
  T,
@@ -15206,8 +15192,8 @@ function C_() {
15206
15192
  At,
15207
15193
  w?.callId,
15208
15194
  i,
15209
- re,
15210
15195
  N,
15196
+ P,
15211
15197
  W
15212
15198
  ]), c(() => {
15213
15199
  !w && !T && W === "call_screen" && $e("text_chat");
@@ -15253,7 +15239,7 @@ function C_() {
15253
15239
  ot("Please enter a valid email so we can continue helping you.");
15254
15240
  return;
15255
15241
  }
15256
- await ie(e), ot(""), ct(!0), setTimeout(() => ct(!1), 3e3);
15242
+ await re(e), ot(""), ct(!0), setTimeout(() => ct(!1), 3e3);
15257
15243
  return;
15258
15244
  }
15259
15245
  let t = Mt(nt);
@@ -15261,7 +15247,7 @@ function C_() {
15261
15247
  if (pt) {
15262
15248
  try {
15263
15249
  vt(!0), gt("");
15264
- let e = await M(pt), n = e?.data || e, r = et.trim() || `Shared file: ${qh(pt)}`;
15250
+ let e = await M(pt), n = e?.data || e, r = et.trim() || `Shared file: ${Gh(pt)}`;
15265
15251
  tt(""), G(null), Ot(), await j(r, "", t, {
15266
15252
  type: "file",
15267
15253
  metadata: {
@@ -15338,11 +15324,11 @@ function C_() {
15338
15324
  t.resume().catch(() => {}), setTimeout(() => t.close().catch(() => {}), 3e3);
15339
15325
  }
15340
15326
  } catch {}
15341
- re({ notifyChatInitiated: !0 }), N?.(!0), $e("voice_mode");
15327
+ N({ notifyChatInitiated: !0 }), P?.(!0), $e("voice_mode");
15342
15328
  }, Vt = () => {
15343
- re({ notifyChatInitiated: !0 }), N?.(!1), $e("text_chat");
15329
+ N({ notifyChatInitiated: !0 }), P?.(!1), $e("text_chat");
15344
15330
  }, Ht = () => {
15345
- N?.(!1), Rt();
15331
+ P?.(!1), Rt();
15346
15332
  };
15347
15333
  return e !== "ready" || !Be || Ce.chat === !1 || !We ? null : /* @__PURE__ */ _("div", {
15348
15334
  className: "flowengage-widget-root",
@@ -15354,7 +15340,7 @@ function C_() {
15354
15340
  onWheel: (e) => e.stopPropagation(),
15355
15341
  onTouchMove: (e) => e.stopPropagation(),
15356
15342
  children: [
15357
- W === "entry_prompt" && /* @__PURE__ */ g(__, {
15343
+ W === "entry_prompt" && /* @__PURE__ */ g(h_, {
15358
15344
  copy: Ke,
15359
15345
  orbColors: Ee,
15360
15346
  primaryColor: Oe,
@@ -15437,13 +15423,13 @@ function C_() {
15437
15423
  children: E === "connected" ? `${Ft(lt)} with ${U}` : `Tap to return to ${U}`
15438
15424
  })]
15439
15425
  })]
15440
- }), /* @__PURE__ */ g(g_, {
15426
+ }), /* @__PURE__ */ g(m_, {
15441
15427
  size: Ae,
15442
15428
  orbColors: Ee,
15443
15429
  onClick: T ? At : Te ? zt : Vt
15444
15430
  })]
15445
15431
  }),
15446
- W === "connection_modal" && /* @__PURE__ */ g(v_, {
15432
+ W === "connection_modal" && /* @__PURE__ */ g(g_, {
15447
15433
  copy: Ke,
15448
15434
  orbColors: Ee,
15449
15435
  primaryColor: Oe,
@@ -15453,7 +15439,7 @@ function C_() {
15453
15439
  isMobile: Et,
15454
15440
  isClosing: xt
15455
15441
  }),
15456
- W === "voice_mode" && /* @__PURE__ */ g(y_, {
15442
+ W === "voice_mode" && /* @__PURE__ */ g(__, {
15457
15443
  orbColors: Ee,
15458
15444
  onEnterChat: Vt,
15459
15445
  onEndChat: Ht,
@@ -15466,7 +15452,7 @@ function C_() {
15466
15452
  voiceEndCounter: ye,
15467
15453
  websiteName: t?.websiteName,
15468
15454
  voiceFirstMessage: I.voiceFirstMessage || null,
15469
- captureVisitorEmail: ie,
15455
+ captureVisitorEmail: re,
15470
15456
  emailRequired: !h,
15471
15457
  emailCaptureEnabled: Ce.emailCapture !== !1 && L.disableEmailCapture !== !0,
15472
15458
  listeningLabel: L.voiceListeningLabel || "Listening...",
@@ -15474,7 +15460,7 @@ function C_() {
15474
15460
  enterChatModeLabel: L.voiceEnterChatLabel || "Enter Chat Mode",
15475
15461
  endConversationLabel: L.voiceEndConversationLabel || "End Conversation"
15476
15462
  }, "voice"),
15477
- W === "call_screen" && /* @__PURE__ */ g(hg, {
15463
+ W === "call_screen" && /* @__PURE__ */ g(pg, {
15478
15464
  incomingCall: w,
15479
15465
  activeCallId: T,
15480
15466
  callConnectionState: E,
@@ -15493,7 +15479,7 @@ function C_() {
15493
15479
  orbColors: Ee,
15494
15480
  chatHistory: r
15495
15481
  }),
15496
- W === "text_chat" && /* @__PURE__ */ g(S_, {
15482
+ W === "text_chat" && /* @__PURE__ */ g(b_, {
15497
15483
  isClosing: xt,
15498
15484
  copy: Ke,
15499
15485
  orbColors: Ee,
@@ -15559,7 +15545,7 @@ function C_() {
15559
15545
  }
15560
15546
  //#endregion
15561
15547
  //#region src/components/ErrorBoundary.jsx
15562
- var w_ = class extends e.Component {
15548
+ var S_ = class extends e.Component {
15563
15549
  constructor(e) {
15564
15550
  super(e), this.state = { hasError: !1 };
15565
15551
  }
@@ -15574,4 +15560,4 @@ var w_ = class extends e.Component {
15574
15560
  }
15575
15561
  };
15576
15562
  //#endregion
15577
- export { cg as AnimatedOrb, w_ as ErrorBoundary, pi as FlowEngageProvider, C_ as FlowEngageWidget, Cn as useFlowEngage };
15563
+ export { og as AnimatedOrb, S_ as ErrorBoundary, pi as FlowEngageProvider, x_ as FlowEngageWidget, Cn as useFlowEngage };