@flowengage/react-chatbot 8.0.52 → 8.0.63

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,46 +34,46 @@ 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", re = (e) => e ? `flowengage.visitorEmail.${e}` : null, ie = () => {
37
+ }, ee = 6e4, te = 480 * 60, ne = 3e4, j = typeof window < "u", M = (e) => e ? `flowengage.visitorEmail.${e}` : null, re = () => {
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
- }, ae = () => {
41
+ }, ie = () => {
42
42
  if (j) try {
43
43
  window.localStorage.removeItem(A.chatId);
44
44
  } catch {}
45
- }, oe = () => j ? typeof crypto < "u" && crypto.randomUUID ? crypto.randomUUID() : `${Date.now()}-${Math.random().toString(16).slice(2)}` : "server-chat-id", se = (e) => e ? `flowengage.entrySeen.${e}` : null, ce = (e) => {
45
+ }, ae = () => j ? typeof crypto < "u" && crypto.randomUUID ? crypto.randomUUID() : `${Date.now()}-${Math.random().toString(16).slice(2)}` : "server-chat-id", oe = (e) => e ? `flowengage.entrySeen.${e}` : null, se = (e) => {
46
46
  if (!j || !e) return !1;
47
47
  try {
48
- let t = se(e);
48
+ let t = oe(e);
49
49
  return t ? window.localStorage.getItem(t) === "1" : !1;
50
50
  } catch {
51
51
  return !1;
52
52
  }
53
- }, le = (e) => {
53
+ }, ce = (e) => {
54
54
  if (!(!j || !e)) try {
55
- let t = se(e);
55
+ let t = oe(e);
56
56
  t && window.localStorage.setItem(t, "1");
57
57
  } catch {}
58
- }, ue = (e) => e ? `flowengage.persistedChatId.${e}` : null, de = (e) => {
58
+ }, le = (e) => e ? `flowengage.persistedChatId.${e}` : null, ue = (e) => {
59
59
  if (!j || !e) return null;
60
60
  try {
61
- let t = ue(e), n = t ? window.localStorage.getItem(t) : null;
61
+ let t = le(e), n = t ? window.localStorage.getItem(t) : null;
62
62
  return n && String(n).trim() ? String(n).trim() : null;
63
63
  } catch {
64
64
  return null;
65
65
  }
66
- }, fe = (e) => {
66
+ }, de = (e) => {
67
67
  if (!(!j || !e)) try {
68
- let t = ue(e);
68
+ let t = le(e);
69
69
  t && window.localStorage.removeItem(t);
70
70
  } catch {}
71
- }, pe = (e, t) => {
71
+ }, fe = (e, t) => {
72
72
  if (!(!j || !e || !t)) try {
73
- let n = ue(e);
73
+ let n = le(e);
74
74
  n && window.localStorage.setItem(n, String(t).trim());
75
75
  } catch {}
76
- }, me = () => j ? {
76
+ }, pe = () => j ? {
77
77
  isOpen: !1,
78
78
  activeScreen: window.sessionStorage.getItem(A.activeScreen) || "ai",
79
79
  isHumanHandled: window.sessionStorage.getItem(A.isHumanHandled) === "true",
@@ -87,7 +87,7 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
87
87
  agentName: null,
88
88
  agentHeadshot: null,
89
89
  visitorEmail: ""
90
- }, he = (e) => {
90
+ }, me = (e) => {
91
91
  j && Object.entries(e).forEach(([e, t]) => {
92
92
  let n = A[e];
93
93
  if (n) {
@@ -98,17 +98,17 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
98
98
  window.sessionStorage.setItem(n, String(t));
99
99
  }
100
100
  });
101
- }, M = (e) => {
101
+ }, he = (e) => {
102
102
  if (!j || !e) return "";
103
- let t = re(e), n = window.localStorage.getItem(t);
103
+ let t = M(e), n = window.localStorage.getItem(t);
104
104
  if (!n) {
105
105
  let e = window.sessionStorage.getItem(A.visitorEmail);
106
106
  e && (window.localStorage.setItem(t, e), window.sessionStorage.removeItem(A.visitorEmail), n = e);
107
107
  }
108
108
  return n || "";
109
- }, ge = (e, t) => {
109
+ }, N = (e, t) => {
110
110
  if (!j) return;
111
- let n = re(t);
111
+ let n = M(t);
112
112
  if (!n) return;
113
113
  let r = typeof e == "string" ? e.trim() : "";
114
114
  if (!r) {
@@ -116,33 +116,33 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
116
116
  return;
117
117
  }
118
118
  window.localStorage.setItem(n, r), window.sessionStorage.removeItem(A.visitorEmail);
119
- }, _e = (e) => e ? `flowengage.visitorId.${e}` : null, ve = () => `v_${Date.now().toString(36)}_${typeof crypto < "u" && crypto.randomUUID ? crypto.randomUUID().replace(/-/g, "").slice(0, 16) : Math.random().toString(36).slice(2, 18)}`, ye = (e) => {
119
+ }, ge = (e) => e ? `flowengage.visitorId.${e}` : null, _e = () => `v_${Date.now().toString(36)}_${typeof crypto < "u" && crypto.randomUUID ? crypto.randomUUID().replace(/-/g, "").slice(0, 16) : Math.random().toString(36).slice(2, 18)}`, ve = (e) => {
120
120
  if (!j || !e) return null;
121
121
  try {
122
- let t = _e(e), n = t ? window.localStorage.getItem(t) : null;
122
+ let t = ge(e), n = t ? window.localStorage.getItem(t) : null;
123
123
  return n && String(n).trim() ? String(n).trim() : null;
124
124
  } catch {
125
125
  return null;
126
126
  }
127
- }, be = (e) => {
127
+ }, ye = (e) => {
128
128
  if (!j || !e) return null;
129
129
  try {
130
- let t = ye(e);
130
+ let t = ve(e);
131
131
  if (t) return t;
132
- let n = ve(), r = _e(e);
132
+ let n = _e(), r = ge(e);
133
133
  return r && window.localStorage.setItem(r, n), n;
134
134
  } catch {
135
- return ve();
135
+ return _e();
136
136
  }
137
- }, xe = "flowengage.tabId", Se = () => {
137
+ }, be = "flowengage.tabId", xe = () => {
138
138
  if (!j) return "default";
139
139
  try {
140
- let e = window.sessionStorage.getItem(xe);
141
- return e || (e = typeof crypto < "u" && crypto.randomUUID ? crypto.randomUUID().replace(/-/g, "").slice(0, 12) : Math.random().toString(36).slice(2, 14), window.sessionStorage.setItem(xe, e)), e;
140
+ let e = window.sessionStorage.getItem(be);
141
+ return e || (e = typeof crypto < "u" && crypto.randomUUID ? crypto.randomUUID().replace(/-/g, "").slice(0, 12) : Math.random().toString(36).slice(2, 14), window.sessionStorage.setItem(be, e)), e;
142
142
  } catch {
143
143
  return "default";
144
144
  }
145
- }, N = (e) => e ? `flowengage.voice.transcript.${e}.${Se()}` : null, Ce = 600 * 1e3, P = (e, t, n = {}) => {
145
+ }, Se = (e) => e ? `flowengage.voice.transcript.${e}.${xe()}` : null, Ce = 600 * 1e3, P = (e, t, n = {}) => {
146
146
  if (!j || !e) return;
147
147
  let r = typeof t == "string" ? t.trim() : "";
148
148
  if (!r) return;
@@ -151,13 +151,13 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
151
151
  expiresAt: Date.now() + i
152
152
  };
153
153
  try {
154
- let t = N(e);
154
+ let t = Se(e);
155
155
  t && window.localStorage.setItem(t, JSON.stringify(a));
156
156
  } catch {}
157
157
  }, we = (e) => {
158
158
  if (!j || !e) return null;
159
159
  try {
160
- let t = N(e), n = t ? window.localStorage.getItem(t) : null;
160
+ let t = Se(e), n = t ? window.localStorage.getItem(t) : null;
161
161
  if (!n) return null;
162
162
  let r = JSON.parse(n);
163
163
  return !r || typeof r.transcript != "string" ? null : Number.isFinite(r.expiresAt) && Date.now() > r.expiresAt ? (window.localStorage.removeItem(t), null) : r;
@@ -166,7 +166,7 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
166
166
  }
167
167
  }, Te = (e) => {
168
168
  if (!(!j || !e)) try {
169
- let t = N(e);
169
+ let t = Se(e);
170
170
  t && window.localStorage.removeItem(t);
171
171
  } catch {}
172
172
  }, F = "flowengage.voice.pendingResume", Ee = () => {
@@ -198,7 +198,7 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
198
198
  } catch {
199
199
  return !1;
200
200
  }
201
- }, je = (e) => e ? `flowengage.voice.navState.${e}.${Se()}` : null, Me = (e, t, n, r) => {
201
+ }, je = (e) => e ? `flowengage.voice.navState.${e}.${xe()}` : null, Me = (e, t, n, r) => {
202
202
  if (!(!j || !e || !t)) try {
203
203
  let i = je(e);
204
204
  i && window.sessionStorage.setItem(i, JSON.stringify({
@@ -224,14 +224,14 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
224
224
  } catch {
225
225
  return null;
226
226
  }
227
- }, L = async (e) => {
227
+ }, Pe = async (e) => {
228
228
  let t = await e.json().catch(() => ({}));
229
229
  if (!e.ok) {
230
230
  let n = Error(t.message || t.error || `Request failed with status ${e.status}`);
231
231
  throw n.status = e.status, n;
232
232
  }
233
233
  return t;
234
- }, Pe = async (e, t = {}) => {
234
+ }, L = async (e, t = {}) => {
235
235
  try {
236
236
  return await fetch(e, {
237
237
  mode: "cors",
@@ -243,7 +243,7 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
243
243
  }
244
244
  }, Fe = async ({ apiBaseUrl: e, userId: t, siteId: n, priorChatId: r = null, forceNew: i = !1, resumeChatId: a = null, visitorId: o = null }) => {
245
245
  let s = `${e}/api/visitors/resolve-session`, c = { siteId: n };
246
- return r && String(r).trim() && (c.priorChatId = String(r).trim()), i && (c.forceNew = !0), a && (c.resumeChatId = a), o && (c.visitorId = o), L(await Pe(s, {
246
+ return r && String(r).trim() && (c.priorChatId = String(r).trim()), i && (c.forceNew = !0), a && (c.resumeChatId = a), o && (c.visitorId = o), Pe(await L(s, {
247
247
  method: "POST",
248
248
  mode: "cors",
249
249
  headers: {
@@ -256,7 +256,7 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
256
256
  }));
257
257
  }, Ie = async ({ apiBaseUrl: e, siteId: t }) => {
258
258
  let n = typeof window < "u" ? window.location.origin : "http://localhost";
259
- return (await L(await Pe(`${e}/api/widget/chatbot-loader?${new URLSearchParams({
259
+ return (await Pe(await L(`${e}/api/widget/chatbot-loader?${new URLSearchParams({
260
260
  siteId: t,
261
261
  origin: n
262
262
  }).toString()}`, { method: "GET" }))).data;
@@ -274,7 +274,7 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
274
274
  headers: { "Content-Type": "application/json" },
275
275
  body: i
276
276
  }).catch(() => {}), !0) : !1;
277
- }, a = async (i, a = {}) => L(await Pe(`${e}${i}`, {
277
+ }, a = async (i, a = {}) => Pe(await L(`${e}${i}`, {
278
278
  ...a,
279
279
  headers: {
280
280
  "Content-Type": "application/json",
@@ -289,7 +289,7 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
289
289
  ...n ? { "x-site-id": n } : {},
290
290
  ...a.headers || {}
291
291
  };
292
- return L(await Pe(`${e}${r}`, {
292
+ return Pe(await L(`${e}${r}`, {
293
293
  ...a,
294
294
  body: i,
295
295
  headers: o
@@ -415,7 +415,7 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
415
415
  });
416
416
  },
417
417
  async getIceServersConfig() {
418
- return L(await Pe(`${e}/api/calls/ice-config`, {
418
+ return Pe(await L(`${e}/api/calls/ice-config`, {
419
419
  method: "GET",
420
420
  headers: {
421
421
  "x-user-id": t,
@@ -2919,7 +2919,7 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
2919
2919
  message: "Looks like you're already on this page!",
2920
2920
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
2921
2921
  }]);
2922
- }, []), [T, D] = m(me().isOpen), [O, k] = m(me().activeScreen), [A, j] = m(me().isHumanHandled), [re, se] = m(me().agentName), [ce, le] = m(me().agentHeadshot), [ue, _e] = m(() => M(i?.siteId)), [ve, ye] = m(!1), [xe, Se] = m(!1), [N, Ce] = m("idle"), [P, we] = m(!1), [Te, F] = m(!1), [De, Oe] = m(""), [I, ke] = m(!1), [Ae, je] = m(0), [Me, Ne] = m(0), [L, Pe] = m(!1), [R, Re] = m(null), [ze, Be] = m(null), [Ve, He] = m("idle"), [Ue, We] = m(null), [Ge, Ke] = m(!1), [qe, Je] = m(""), [Ye, Xe] = m(!1), z = p(null), B = p(null), Ze = p(""), Qe = p(!1), $e = p(null), et = p(null), tt = p(null), V = p(null), H = p(null), nt = p(null), rt = p(null), it = p(!1), U = p({
2922
+ }, []), [T, D] = m(pe().isOpen), [O, k] = m(pe().activeScreen), [A, j] = m(pe().isHumanHandled), [M, oe] = m(pe().agentName), [se, ce] = m(pe().agentHeadshot), [le, ge] = m(() => he(i?.siteId)), [_e, ve] = m(!1), [be, xe] = m(!1), [Se, Ce] = m("idle"), [P, we] = m(!1), [Te, F] = m(!1), [De, Oe] = m(""), [I, ke] = m(!1), [Ae, je] = m(0), [Me, Ne] = m(0), [Pe, L] = m(!1), [R, Re] = m(null), [ze, Be] = m(null), [Ve, He] = m("idle"), [Ue, We] = m(null), [Ge, Ke] = m(!1), [qe, Je] = m(""), [Ye, Xe] = m(!1), z = p(null), B = p(null), Ze = p(""), Qe = p(!1), $e = p(null), et = p(null), tt = p(null), V = p(null), H = p(null), nt = p(null), rt = p(null), it = p(!1), U = p({
2923
2923
  url: null,
2924
2924
  at: 0
2925
2925
  }), at = o((e, t) => {
@@ -2935,12 +2935,12 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
2935
2935
  url: n,
2936
2936
  at: Date.now()
2937
2937
  }, br(e, t));
2938
- }, []), ot = p([]), W = 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(re), _t = p([]), vt = p(!1), yt = p(!1), bt = p(i), xt = p({
2938
+ }, []), ot = p([]), W = 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(M), _t = p([]), vt = p(!1), yt = p(!1), bt = p(i), xt = p({
2939
2939
  notifyRouteChange: () => {},
2940
2940
  cleanup: () => {}
2941
2941
  }), St = o((e = {}) => {
2942
2942
  let t = !!e.is_human_handled;
2943
- return j(t), t ? (k("agent"), e.agent_info?.name && se(e.agent_info.name), e.agent_info?.headshot && le(e.agent_info.headshot), t) : (k("ai"), t);
2943
+ return j(t), t ? (k("agent"), e.agent_info?.name && oe(e.agent_info.name), e.agent_info?.headshot && ce(e.agent_info.headshot), t) : (k("ai"), t);
2944
2944
  }, []), Ct = f(() => {
2945
2945
  let e = _?.widgetSettings?.call?.maxDurationSeconds ?? i?.widgetSettings?.call?.maxDurationSeconds ?? i?.callMaxDurationSeconds, t = Number(e);
2946
2946
  return Number.isFinite(t) && t > 0 ? t : te;
@@ -2948,8 +2948,8 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
2948
2948
  c(() => {
2949
2949
  et.current = R;
2950
2950
  }, [R]), c(() => {
2951
- gt.current = re;
2952
- }, [re]), c(() => {
2951
+ gt.current = M;
2952
+ }, [M]), c(() => {
2953
2953
  yt.current = I;
2954
2954
  }, [I]), c(() => {
2955
2955
  bt.current = i;
@@ -2960,17 +2960,17 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
2960
2960
  ct.current &&= (window.clearTimeout(ct.current), null);
2961
2961
  }, []), Et = (e) => {
2962
2962
  let t = typeof e == "string" ? e.trim().toLowerCase() : "";
2963
- return _e(t), ge(t, i?.siteId), t;
2963
+ return ge(t), N(t, i?.siteId), t;
2964
2964
  };
2965
2965
  c(() => {
2966
2966
  let e = i?.siteId;
2967
2967
  if (!e) return;
2968
- let t = M(e);
2968
+ let t = he(e);
2969
2969
  if (t) {
2970
- _e(t);
2970
+ ge(t);
2971
2971
  return;
2972
2972
  }
2973
- _e((t) => (t && ge(t, e), t));
2973
+ ge((t) => (t && N(t, e), t));
2974
2974
  }, [i?.siteId]);
2975
2975
  let G = (e = "unspecified") => {
2976
2976
  let t = W.current || nt.current?.callId, n = ht.current, r = ft.current;
@@ -3100,19 +3100,19 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
3100
3100
  });
3101
3101
  };
3102
3102
  c(() => {
3103
- he({
3103
+ me({
3104
3104
  isOpen: T,
3105
3105
  activeScreen: O,
3106
3106
  isHumanHandled: A,
3107
- agentName: re,
3108
- agentHeadshot: ce
3107
+ agentName: M,
3108
+ agentHeadshot: se
3109
3109
  });
3110
3110
  }, [
3111
3111
  T,
3112
3112
  O,
3113
3113
  A,
3114
- re,
3115
- ce
3114
+ M,
3115
+ se
3116
3116
  ]), c(() => {
3117
3117
  let e = !0;
3118
3118
  return (async () => {
@@ -3120,21 +3120,21 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
3120
3120
  try {
3121
3121
  let t = E(i), n = await Ie(t);
3122
3122
  if (!e) return;
3123
- let a = t.siteId, o = de(a), s = be(a), c = "";
3123
+ let a = t.siteId, o = ue(a), s = ye(a), c = "";
3124
3124
  try {
3125
3125
  let e = Qe.current, r = $e.current;
3126
3126
  if (Qe.current = !1, $e.current = null, c = (await Fe({
3127
3127
  apiBaseUrl: t.apiBaseUrl,
3128
3128
  userId: n.userId,
3129
3129
  siteId: a,
3130
- priorChatId: e || r ? null : o || ie(),
3130
+ priorChatId: e || r ? null : o || re(),
3131
3131
  forceNew: e,
3132
3132
  resumeChatId: r,
3133
3133
  visitorId: s
3134
3134
  }))?.data?.chatId, !c) throw Error("resolve-session returned no chatId");
3135
- ae(), pe(a, c);
3135
+ ie(), fe(a, c);
3136
3136
  } catch (e) {
3137
- console.warn("[FlowEngageProvider] resolve-session failed, reusing persisted or ephemeral chat id", e?.message || e), c = o || oe(), pe(a, c);
3137
+ console.warn("[FlowEngageProvider] resolve-session failed, reusing persisted or ephemeral chat id", e?.message || e), c = o || ae(), fe(a, c);
3138
3138
  }
3139
3139
  Ze.current = c;
3140
3140
  let l = Le({
@@ -3162,15 +3162,15 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
3162
3162
  }), f.on("disconnect", () => {
3163
3163
  Ce("disconnected");
3164
3164
  }), f.on("aiTyping", () => {
3165
- Se(!0);
3165
+ xe(!0);
3166
3166
  }), f.on("ai:typing", () => {
3167
- Se(!0);
3167
+ xe(!0);
3168
3168
  }), f.on("messageReceived", (e) => {
3169
3169
  let t = e.message || e, n = {
3170
3170
  ...t,
3171
3171
  message: Tr(t.message)
3172
3172
  };
3173
- Se(!1), ye(!1), !(n.type === "call_recording" || typeof n.message == "string" && n.message.includes("AI chat recording")) && S((e) => [...e.filter((e) => !e.isPending), {
3173
+ xe(!1), ve(!1), !(n.type === "call_recording" || typeof n.message == "string" && n.message.includes("AI chat recording")) && S((e) => [...e.filter((e) => !e.isPending), {
3174
3174
  ...n,
3175
3175
  isPending: !1,
3176
3176
  id: n.messageId || `${n.sender}-${Date.now()}-${Math.random()}`
@@ -3188,7 +3188,7 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
3188
3188
  ...t,
3189
3189
  message: Tr(t.message)
3190
3190
  };
3191
- Se(!1), !(n.type === "call_recording" || typeof n.message == "string" && n.message.includes("AI chat recording")) && ((n.sender === "agent" || n.agent_name || n.sender === "ai" || n.sender === "bot") && ye(!1), S((e) => n.sender === "bot" || n.sender === "ai" ? [...e, {
3191
+ xe(!1), !(n.type === "call_recording" || typeof n.message == "string" && n.message.includes("AI chat recording")) && ((n.sender === "agent" || n.agent_name || n.sender === "ai" || n.sender === "bot") && ve(!1), S((e) => n.sender === "bot" || n.sender === "ai" ? [...e, {
3192
3192
  ...n,
3193
3193
  isPending: !1,
3194
3194
  id: n.messageId || `${n.sender}-${Date.now()}-${Math.random()}`
@@ -3200,11 +3200,11 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
3200
3200
  ...n,
3201
3201
  isPending: !1,
3202
3202
  id: n.messageId || `${n.sender}-${Date.now()}-${Math.random()}`
3203
- }]), (n.sender === "agent" || n.agent_name) && (j(!0), k("agent"), se(Ar([
3203
+ }]), (n.sender === "agent" || n.agent_name) && (j(!0), k("agent"), oe(Ar([
3204
3204
  n.agent_name,
3205
3205
  n.agentName,
3206
3206
  n.metadata?.agentName
3207
- ], d)), n.sender_headshot && le(n.sender_headshot), D(!0), je((e) => e + 1)));
3207
+ ], d)), n.sender_headshot && ce(n.sender_headshot), D(!0), je((e) => e + 1)));
3208
3208
  });
3209
3209
  let p = (e = {}) => {
3210
3210
  let t = Ar([
@@ -3213,7 +3213,7 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
3213
3213
  e.agent_name,
3214
3214
  gt.current
3215
3215
  ], d);
3216
- j(!0), k("agent"), se(t), le(e.agent?.headshot || null), D(!0), je((e) => e + 1), S((e) => jr(e, {
3216
+ j(!0), k("agent"), oe(t), ce(e.agent?.headshot || null), D(!0), je((e) => e + 1), S((e) => jr(e, {
3217
3217
  id: `agent-joined-${Date.now()}`,
3218
3218
  sender: "system",
3219
3219
  message: `${t} has joined the chat.`,
@@ -3236,7 +3236,7 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
3236
3236
  }));
3237
3237
  };
3238
3238
  f.on("agent:joined", p), f.on("agentJoined", p), f.on("agent:left", m), f.on("agentLeft", m), f.on("conversationEnded", (e) => {
3239
- Pe(!0);
3239
+ L(!0);
3240
3240
  let t = e?.message || "This conversation has ended. Thank you for reaching out!";
3241
3241
  S((e) => [...e, {
3242
3242
  id: `conversation-ended-${Date.now()}`,
@@ -3247,15 +3247,15 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
3247
3247
  }]);
3248
3248
  }), f.on("chat:history_update", (e) => {
3249
3249
  let t = Er(e.chat_history || []);
3250
- S(t), t.length === 0 && (Pe(!1), j(!1), k("ai"), Se(!1), ye(!1));
3250
+ S(t), t.length === 0 && (L(!1), j(!1), k("ai"), xe(!1), ve(!1));
3251
3251
  }), f.on("conversation:reset", () => {
3252
- S([]), Pe(!1), j(!1), k("ai"), Se(!1), ye(!1);
3252
+ S([]), L(!1), j(!1), k("ai"), xe(!1), ve(!1);
3253
3253
  }), f.on("voice:end_session", (e = {}) => {
3254
3254
  console.log("[FlowEngageProvider] voice:end_session received — ending voice session"), Ne((e) => e + 1), D(!0), je((e) => e + 1);
3255
3255
  }), f.on("typing:start", (e) => {
3256
- e.sender === "agent" && ye(!0);
3256
+ e.sender === "agent" && ve(!0);
3257
3257
  }), f.on("typing:stop", (e) => {
3258
- e.sender === "agent" && ye(!1);
3258
+ e.sender === "agent" && ve(!1);
3259
3259
  }), f.on("call:incoming", (e = {}) => {
3260
3260
  let t = Ar([
3261
3261
  e.agentName,
@@ -3268,7 +3268,7 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
3268
3268
  from: e.from || "owner",
3269
3269
  agentId: e.agentId || null,
3270
3270
  agentName: t
3271
- }), se((e) => Ar([t, e], "Agent")), He("incoming"), We(null), D(!0);
3271
+ }), oe((e) => Ar([t, e], "Agent")), He("incoming"), We(null), D(!0);
3272
3272
  }), f.on("call:offer", async (e = {}) => {
3273
3273
  nt.current = e;
3274
3274
  try {
@@ -3584,7 +3584,7 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
3584
3584
  }
3585
3585
  let Ut = async (e, t = "", n = null, i = {}) => {
3586
3586
  let a = typeof e == "string" ? e.trim() : "";
3587
- if (!a || !B.current || !y || l !== "ready" || L) return;
3587
+ if (!a || !B.current || !y || l !== "ready" || Pe) return;
3588
3588
  Bt(), it.current = !1;
3589
3589
  let o = /^\s*(yes|yeah|sure|ok|okay|go ahead|take me(?: there)?(?!\s+\w)|navigate(?!\s+(?:me\s+)?to\s+\w)|yep|absolutely|please do|do it|let'?s go|go there|show me(?!\s+(?:the|a|an)\s+\w)|go to it|bring me there|navigate me there)\b/i, s = /^\s*(?:yes|yeah|sure|ok|okay|yep|absolutely)\s+(?!(?:please|do\s+it|let'?s|that|this|there|it|thanks|go|cool|great|perfect|sounds|alright|proceed)\b)\w/i, c = /\b(take me|navigate|go to|show me|bring me|open|go there|navigate to|take me to|let'?s go to)\b/i;
3590
3590
  if (rt.current && o.test(a) && !s.test(a)) {
@@ -3620,7 +3620,7 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
3620
3620
  chatId: y,
3621
3621
  content: e,
3622
3622
  sender: "user",
3623
- email: ue || void 0,
3623
+ email: le || void 0,
3624
3624
  type: i?.type || "text",
3625
3625
  metadata: i?.metadata || {},
3626
3626
  ...n || {}
@@ -3631,7 +3631,7 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
3631
3631
  try {
3632
3632
  let o = await B.current.sendAiMessage(y, e, r, t, {
3633
3633
  ...n || {},
3634
- ...ue ? { email: ue } : {}
3634
+ ...le ? { email: le } : {}
3635
3635
  }, {
3636
3636
  ...i,
3637
3637
  currentPageUrl: typeof window < "u" ? window.location.href : void 0,
@@ -3700,9 +3700,9 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
3700
3700
  });
3701
3701
  }
3702
3702
  }
3703
- S(Er(s)), j(!!o.is_human_handled), k(o.is_human_handled ? "agent" : "ai"), Se(!1), we(!1), await B.current.updateChatStatus(y, "messageSent");
3703
+ S(Er(s)), j(!!o.is_human_handled), k(o.is_human_handled ? "agent" : "ai"), xe(!1), we(!1), await B.current.updateChatStatus(y, "messageSent");
3704
3704
  } catch (e) {
3705
- S((e) => e.filter((e) => e.id !== u)), Se(!1), we(!1), e.status === 429 ? (F(!0), Oe(e.message), window.setTimeout(() => {
3705
+ S((e) => e.filter((e) => e.id !== u)), xe(!1), we(!1), e.status === 429 ? (F(!0), Oe(e.message), window.setTimeout(() => {
3706
3706
  F(!1), Oe("");
3707
3707
  }, ee)) : h(e);
3708
3708
  }
@@ -3756,7 +3756,7 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
3756
3756
  await B.current.updateChatStatus(y, "ended");
3757
3757
  } catch {}
3758
3758
  }
3759
- Pe(!0), S((e) => [...e, {
3759
+ L(!0), S((e) => [...e, {
3760
3760
  id: `conversation-ended-${Date.now()}`,
3761
3761
  sender: "system",
3762
3762
  message: "This conversation has ended. Thank you for reaching out!",
@@ -3795,9 +3795,9 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
3795
3795
  }, []);
3796
3796
  let Jt = o(() => {
3797
3797
  let e = i?.siteId;
3798
- fe(e), Qe.current = !0, $e.current = null, z.current?.disconnect(), S([]), b(""), Ze.current = "", Pe(!1), j(!1), se(null), le(null), Xe(!0), s((e) => e + 1);
3798
+ de(e), Qe.current = !0, $e.current = null, z.current?.disconnect(), S([]), b(""), Ze.current = "", L(!1), j(!1), oe(null), ce(null), Xe(!0), s((e) => e + 1);
3799
3799
  }, [i?.siteId]), Yt = o((e) => {
3800
- i?.siteId, Qe.current = !1, $e.current = e, z.current?.disconnect(), S([]), b(""), Ze.current = "", Pe(!1), j(!1), se(null), le(null), Xe(!0), s((e) => e + 1);
3800
+ i?.siteId, Qe.current = !1, $e.current = e, z.current?.disconnect(), S([]), b(""), Ze.current = "", L(!1), j(!1), oe(null), ce(null), Xe(!0), s((e) => e + 1);
3801
3801
  }, [i?.siteId]), Xt = f(() => ({
3802
3802
  status: l,
3803
3803
  error: d,
@@ -3808,17 +3808,17 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
3808
3808
  isOpen: T,
3809
3809
  activeScreen: O,
3810
3810
  isHumanHandled: A,
3811
- agentName: re,
3812
- agentHeadshot: ce,
3813
- visitorEmail: ue,
3814
- isAgentTyping: ve,
3815
- isAiTyping: xe,
3816
- connectionStatus: N,
3811
+ agentName: M,
3812
+ agentHeadshot: se,
3813
+ visitorEmail: le,
3814
+ isAgentTyping: _e,
3815
+ isAiTyping: be,
3816
+ connectionStatus: Se,
3817
3817
  isLoading: P,
3818
3818
  isVoiceMode: I,
3819
3819
  isRateLimited: Te,
3820
3820
  rateLimitMessage: De,
3821
- isConversationEnded: L,
3821
+ isConversationEnded: Pe,
3822
3822
  isSessionRestoring: Ye,
3823
3823
  openToChatCounter: Ae,
3824
3824
  voiceEndCounter: Me,
@@ -3869,17 +3869,17 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
3869
3869
  T,
3870
3870
  O,
3871
3871
  A,
3872
- re,
3873
- ce,
3874
- ue,
3875
- ve,
3876
- xe,
3877
- N,
3872
+ M,
3873
+ se,
3874
+ le,
3875
+ _e,
3876
+ be,
3877
+ Se,
3878
3878
  P,
3879
3879
  I,
3880
3880
  Te,
3881
3881
  De,
3882
- L,
3882
+ Pe,
3883
3883
  Ye,
3884
3884
  Ae,
3885
3885
  Me,
@@ -8826,8 +8826,13 @@ var _m = {
8826
8826
  ..._m,
8827
8827
  ...nm,
8828
8828
  ...vm
8829
- }, hp), bm = 24e3, xm = 2048, Sm = 1200;
8830
- function Cm(e) {
8829
+ }, hp), bm = 24e3, xm = 2048, Sm = 1200, Cm = .05, wm = 3;
8830
+ function Tm(e) {
8831
+ let t = 0;
8832
+ for (let n = 0; n < e.length; n++) t += e[n] * e[n];
8833
+ return Math.sqrt(t / e.length);
8834
+ }
8835
+ function Em(e) {
8831
8836
  let t = new Int16Array(e.length);
8832
8837
  for (let n = 0; n < e.length; n++) {
8833
8838
  let r = Math.max(-1, Math.min(1, e[n]));
@@ -8835,35 +8840,36 @@ function Cm(e) {
8835
8840
  }
8836
8841
  return t;
8837
8842
  }
8838
- function wm(e) {
8843
+ function Dm(e) {
8839
8844
  let t = new Float32Array(e.length);
8840
8845
  for (let n = 0; n < e.length; n++) t[n] = e[n] / 32768;
8841
8846
  return t;
8842
8847
  }
8843
- function Tm(e, t) {
8844
- let n = 0, r = [];
8848
+ var Om = .18;
8849
+ function km(e, t) {
8850
+ let n = 0, r = [], i = () => {
8851
+ r.forEach((e) => {
8852
+ try {
8853
+ e.stop();
8854
+ } catch {}
8855
+ }), r = [], n = 0;
8856
+ }, a = () => n > e.currentTime;
8845
8857
  return {
8846
8858
  enqueue: (i) => {
8847
- let a = wm(i), o = e.createBuffer(1, a.length, bm);
8848
- o.copyToChannel(a, 0);
8849
- let s = e.createBufferSource();
8850
- s.buffer = o, s.connect(e.destination);
8851
- let c = Math.max(e.currentTime, n);
8852
- s.start(c), n = c + o.duration, r.push(s), s.onended = () => {
8853
- r = r.filter((e) => e !== s), r.length || t?.();
8859
+ let o = Dm(i), s = e.createBuffer(1, o.length, bm);
8860
+ s.copyToChannel(o, 0);
8861
+ let c = e.createBufferSource();
8862
+ c.buffer = s, c.connect(e.destination);
8863
+ let l = a() ? n : e.currentTime + Om;
8864
+ c.start(l), n = l + s.duration, r.push(c), c.onended = () => {
8865
+ r = r.filter((e) => e !== c), !r.length && !a() && t?.();
8854
8866
  };
8855
8867
  },
8856
- stop: () => {
8857
- r.forEach((e) => {
8858
- try {
8859
- e.stop();
8860
- } catch {}
8861
- }), r = [], n = 0;
8862
- },
8863
- isPlaying: () => r.length > 0
8868
+ stop: i,
8869
+ isPlaying: a
8864
8870
  };
8865
8871
  }
8866
- async function Em(e, t, n) {
8872
+ async function Am(e, t, n) {
8867
8873
  let r = new URLSearchParams({ siteId: t || "" });
8868
8874
  n && r.set("chatId", n);
8869
8875
  let i = await fetch(`${e}/api/voice/session?${r.toString()}`, {
@@ -8876,76 +8882,93 @@ async function Em(e, t, n) {
8876
8882
  }
8877
8883
  if (!i.ok) throw Error("Could not start a voice session.");
8878
8884
  let a = await i.json();
8879
- if (!a?.success || !a.token) throw Error(a?.error || "Voice session was refused.");
8885
+ if (!a?.success || !a.wsUrl) throw Error(a?.error || "Voice session was refused.");
8880
8886
  return a;
8881
8887
  }
8882
- async function Dm(e) {
8883
- 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 } = e, p = await Em(t, n, r);
8884
- f?.({ emailOnFile: !!p.emailOnFile }), e.greeting !== void 0 && (e.greeting ? p.settings.agent.greeting = e.greeting : delete p.settings.agent.greeting);
8885
- let m = await navigator.mediaDevices.getUserMedia({ audio: {
8888
+ async function jm(e) {
8889
+ 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 Am(t, n, r);
8890
+ f?.({ emailOnFile: !!m.emailOnFile });
8891
+ let h = { type: "Start" };
8892
+ e.greeting !== void 0 && (h.greeting = e.greeting || null);
8893
+ let g = await navigator.mediaDevices.getUserMedia({ audio: {
8886
8894
  channelCount: 1,
8887
8895
  echoCancellation: !0,
8888
8896
  noiseSuppression: !0,
8889
8897
  autoGainControl: !0
8890
- } }), h = new (window.AudioContext || window.webkitAudioContext)({ sampleRate: bm });
8891
- h.state === "suspended" && await h.resume();
8892
- let g = new WebSocket(p.wsUrl, ["token", p.token]);
8893
- g.binaryType = "arraybuffer";
8894
- let _ = /* @__PURE__ */ new Set(), v = {
8898
+ } }), _ = new (window.AudioContext || window.webkitAudioContext)({ sampleRate: bm });
8899
+ _.state === "suspended" && await _.resume();
8900
+ let v = new WebSocket(m.wsUrl);
8901
+ v.binaryType = "arraybuffer";
8902
+ let y = /* @__PURE__ */ new Set(), b = {
8895
8903
  role: null,
8896
8904
  text: "",
8897
8905
  timer: null
8898
- }, y = "", b = () => {
8899
- v.timer &&= (clearTimeout(v.timer), null);
8900
- let e = v.text.trim(), t = v.role;
8901
- if (v.text = "", v.role = null, !(!e || !t)) {
8906
+ }, x = "", S = () => {
8907
+ b.timer &&= (clearTimeout(b.timer), null);
8908
+ let e = b.text.trim(), t = b.role;
8909
+ if (b.text = "", b.role = null, !(!e || !t)) {
8902
8910
  if (t === "agent") {
8903
- if (e === y) {
8911
+ if (e === x) {
8904
8912
  console.debug("[FlowEngage] duplicate agent turn suppressed");
8905
8913
  return;
8906
8914
  }
8907
- y = e;
8915
+ x = e;
8908
8916
  }
8909
8917
  s?.({
8910
8918
  role: t,
8911
8919
  message: e
8912
8920
  });
8913
8921
  }
8914
- }, x = (e, t) => {
8915
- t && (v.role && v.role !== e && b(), v.role = e, v.text = v.text ? `${v.text} ${t}`.replace(/\s+/g, " ") : t, v.timer && clearTimeout(v.timer), v.timer = setTimeout(b, Sm));
8916
- }, S = !1, C = !1, w = !1, T = !1, E = null, D = () => {
8917
- E && clearTimeout(E);
8922
+ }, C = (e, t) => {
8923
+ t && (b.role && b.role !== e && S(), b.role = e, b.text = b.text ? `${b.text} ${t}`.replace(/\s+/g, " ") : t, b.timer && clearTimeout(b.timer), b.timer = setTimeout(S, Sm));
8924
+ }, w = !1, T = !1, E = !1, D = !1, O = !0, k = 0, A = !1, ee = !1, te = null, ne = !1, j = () => {
8925
+ te && clearTimeout(te);
8918
8926
  let e = () => {
8919
- if (!S) {
8920
- if (O.isPlaying()) {
8921
- E = setTimeout(e, 150);
8927
+ if (!w) {
8928
+ if (M.isPlaying()) {
8929
+ te = setTimeout(e, 150);
8922
8930
  return;
8923
8931
  }
8924
- E = null, d?.();
8932
+ if (te = null, ne) {
8933
+ p?.();
8934
+ return;
8935
+ }
8936
+ !w && v.readyState === WebSocket.OPEN && v.send(JSON.stringify({ type: "PlaybackDrained" })), d?.();
8925
8937
  }
8926
8938
  };
8927
- E = setTimeout(e, 150);
8928
- }, O = Tm(h, () => {
8929
- T && (T = !1, c?.({ mode: "listening" }));
8930
- }), k = h.createMediaStreamSource(m), A = h.createScriptProcessor(xm, 1, 1);
8931
- A.onaudioprocess = (e) => {
8932
- if (S || g.readyState !== WebSocket.OPEN) return;
8933
- let t = e.inputBuffer.getChannelData(0);
8934
- if (C) {
8935
- w || (w = !0, console.debug("[FlowEngage] mic held — streaming silence to keep socket alive")), g.send(new Int16Array(t.length).buffer);
8939
+ te = setTimeout(e, 150);
8940
+ }, M = km(_, () => {
8941
+ D && (D = !1, c?.({ mode: "listening" }));
8942
+ }), re = _.createMediaStreamSource(g), ie = _.createScriptProcessor(xm, 1, 1);
8943
+ ie.onaudioprocess = (e) => {
8944
+ if (w || v.readyState !== WebSocket.OPEN) return;
8945
+ let t = e.inputBuffer.getChannelData(0), n = () => v.send(new Int16Array(t.length).buffer);
8946
+ if (T) {
8947
+ E || (E = !0, console.debug("[FlowEngage] mic held — streaming silence to keep socket alive")), n();
8936
8948
  return;
8937
8949
  }
8938
- g.send(Cm(t).buffer);
8939
- }, k.connect(A), A.connect(h.destination);
8940
- let ee = () => {
8941
- if (!S) {
8942
- S = !0, E &&= (clearTimeout(E), null), b(), O.stop();
8950
+ if ((M.isPlaying() || ee) && !A) {
8951
+ if (Tm(t) < Cm) {
8952
+ k = 0, n();
8953
+ return;
8954
+ }
8955
+ if (k += 1, k < wm) {
8956
+ n();
8957
+ return;
8958
+ }
8959
+ A = !0, k = 0, M.stop(), O = !1, console.debug("[FlowEngage] barge-in — visitor spoke over the agent");
8960
+ }
8961
+ v.send(Em(t).buffer);
8962
+ }, re.connect(ie), ie.connect(_.destination);
8963
+ let ae = () => {
8964
+ if (!w) {
8965
+ w = !0, te &&= (clearTimeout(te), null), S(), M.stop();
8943
8966
  try {
8944
- A.disconnect(), k.disconnect();
8967
+ ie.disconnect(), re.disconnect();
8945
8968
  } catch {}
8946
- m.getTracks().forEach((e) => e.stop()), h.close().catch(() => {}), (g.readyState === WebSocket.OPEN || g.readyState === WebSocket.CONNECTING) && g.close();
8969
+ g.getTracks().forEach((e) => e.stop()), _.close().catch(() => {}), (v.readyState === WebSocket.OPEN || v.readyState === WebSocket.CONNECTING) && v.close();
8947
8970
  }
8948
- }, te = async (e) => {
8971
+ }, oe = async (e) => {
8949
8972
  let t = i[e.name];
8950
8973
  if (!t) return u?.({ tool_name: e.name }), { error: `Unknown tool ${e.name}` };
8951
8974
  let n = {};
@@ -8957,29 +8980,29 @@ async function Dm(e) {
8957
8980
  } catch (e) {
8958
8981
  return { error: e?.message || "Tool execution failed" };
8959
8982
  }
8960
- }, ne = async (e) => {
8983
+ }, se = async (e) => {
8961
8984
  for (let t of e.functions || []) {
8962
8985
  if (!t.client_side) continue;
8963
- let e = await te(t);
8964
- if (S || g.readyState !== WebSocket.OPEN) return;
8965
- g.send(JSON.stringify({
8986
+ let e = await oe(t);
8987
+ if (w || v.readyState !== WebSocket.OPEN) return;
8988
+ v.send(JSON.stringify({
8966
8989
  type: "FunctionCallResponse",
8967
8990
  id: t.id,
8968
8991
  name: t.name,
8969
8992
  content: typeof e == "string" ? e : JSON.stringify(e ?? {})
8970
8993
  }));
8971
8994
  }
8972
- }, j = (e) => {
8995
+ }, ce = (e) => {
8973
8996
  switch (e.type) {
8974
8997
  case "Welcome":
8975
- a?.({ conversationId: e.request_id || p.token.slice(0, 12) });
8998
+ a?.({ conversationId: e.session_id || r || n });
8976
8999
  break;
8977
9000
  case "ConversationText": {
8978
9001
  let t = String(e.content || "");
8979
9002
  if (e.role === "user") {
8980
9003
  let e = t.trim();
8981
- if (_.has(e)) {
8982
- _.delete(e);
9004
+ if (y.has(e)) {
9005
+ y.delete(e);
8983
9006
  break;
8984
9007
  }
8985
9008
  if (/^\[SYSTEM:/i.test(e) || /^Continue (now )?to the next section/i.test(e) || /^That was the last section/i.test(e)) {
@@ -8987,72 +9010,88 @@ async function Dm(e) {
8987
9010
  break;
8988
9011
  }
8989
9012
  }
8990
- x(e.role === "user" ? "user" : "agent", t);
9013
+ C(e.role === "user" ? "user" : "agent", t);
8991
9014
  break;
8992
9015
  }
8993
9016
  case "UserStartedSpeaking":
8994
- b(), O.stop(), T = !1, c?.({ mode: "listening" });
9017
+ S(), M.stop(), ee = !1, O = !1, D = !1, c?.({ mode: "listening" });
8995
9018
  break;
8996
9019
  case "AgentStartedSpeaking":
8997
- T = !0, c?.({ mode: "speaking" });
9020
+ O = !0, D = !0, A = !1, k = 0, c?.({ mode: "speaking" });
8998
9021
  break;
8999
9022
  case "AgentAudioDone":
9000
- b(), D(), O.isPlaying() || (T = !1, c?.({ mode: "listening" }));
9023
+ ee = !1, S(), j(), M.isPlaying() || (D = !1, c?.({ mode: "listening" }));
9001
9024
  break;
9002
9025
  case "FunctionCallRequest":
9003
- ne(e);
9026
+ se(e);
9027
+ break;
9028
+ case "AgentPreparing":
9029
+ ee = !0;
9030
+ break;
9031
+ case "SessionEnding":
9032
+ console.debug("[FlowEngage] server is ending the session:", e.reason || "unspecified"), ne = !0;
9004
9033
  break;
9005
9034
  case "PromptUpdated":
9006
9035
  case "AgentThinking": break;
9007
9036
  case "Error":
9008
- console.error("[FlowEngage:Deepgram]", e.code || "", e.description || e), l?.(Error(e.description || "Voice service error"));
9037
+ console.error("[FlowEngage:Voice]", e.code || "", e.description || e), l?.(Error(e.description || "Voice service error"));
9009
9038
  break;
9010
9039
  case "Warning":
9011
- console.warn("[FlowEngage:Deepgram]", e.code || "", e.description || "");
9040
+ console.warn("[FlowEngage:Voice]", e.code || "", e.description || "");
9012
9041
  break;
9013
9042
  default: break;
9014
9043
  }
9015
9044
  };
9016
- return g.onopen = () => g.send(JSON.stringify(p.settings)), g.onmessage = (e) => {
9045
+ return v.onopen = () => v.send(JSON.stringify(h)), v.onmessage = (e) => {
9017
9046
  if (e.data instanceof ArrayBuffer) {
9018
- O.enqueue(new Int16Array(e.data));
9047
+ O && M.enqueue(new Int16Array(e.data));
9019
9048
  return;
9020
9049
  }
9021
9050
  try {
9022
- j(JSON.parse(e.data));
9051
+ ce(JSON.parse(e.data));
9023
9052
  } catch {}
9024
- }, g.onerror = () => l?.(/* @__PURE__ */ Error("Voice connection failed")), g.onclose = () => {
9025
- ee(), o?.();
9053
+ }, v.onerror = () => l?.(/* @__PURE__ */ Error("Voice connection failed")), v.onclose = () => {
9054
+ ae(), o?.();
9026
9055
  }, {
9027
- endSession: async () => ee(),
9056
+ endSession: async () => ae(),
9028
9057
  sendContextualUpdate: (e) => {
9029
- S || g.readyState !== WebSocket.OPEN || !e || g.send(JSON.stringify({
9058
+ w || v.readyState !== WebSocket.OPEN || !e || v.send(JSON.stringify({
9030
9059
  type: "UpdatePrompt",
9031
9060
  prompt: e
9032
9061
  }));
9033
9062
  },
9034
- sendUserMessage: (e, { silent: t = !0 } = {}) => {
9035
- S || g.readyState !== WebSocket.OPEN || !e || (t && _.add(e.trim()), g.send(JSON.stringify({
9063
+ sendUserMessage: (e, { silent: t = !0, suppressQuestion: n = !1 } = {}) => {
9064
+ w || v.readyState !== WebSocket.OPEN || !e || (t && y.add(e.trim()), v.send(JSON.stringify({
9036
9065
  type: "InjectUserMessage",
9037
- content: e
9066
+ content: e,
9067
+ suppress_question: n
9038
9068
  })));
9039
9069
  },
9040
9070
  injectAgentSpeech: (e, t = "interrupt") => {
9041
- S || g.readyState !== WebSocket.OPEN || !e || g.send(JSON.stringify({
9071
+ w || v.readyState !== WebSocket.OPEN || !e || v.send(JSON.stringify({
9042
9072
  type: "InjectAgentMessage",
9043
9073
  message: e,
9044
9074
  behavior: t
9045
9075
  }));
9046
9076
  },
9077
+ setWalkthroughActive: (e) => {
9078
+ w || v.readyState !== WebSocket.OPEN || v.send(JSON.stringify({
9079
+ type: "WalkthroughActive",
9080
+ active: !!e
9081
+ }));
9082
+ },
9047
9083
  setMicMuted: (e) => {
9048
- C = !!e;
9084
+ T = !!e, !w && v.readyState === WebSocket.OPEN && v.send(JSON.stringify({
9085
+ type: "MicHeld",
9086
+ held: T
9087
+ }));
9049
9088
  },
9050
9089
  get status() {
9051
- return S ? "disconnected" : "connected";
9090
+ return w ? "disconnected" : "connected";
9052
9091
  }
9053
9092
  };
9054
9093
  }
9055
- var Om = { startSession: Dm }, km = ({ size: e = 18, color: t = "currentColor" }) => /* @__PURE__ */ _("svg", {
9094
+ var Mm = { startSession: jm }, Nm = ({ size: e = 18, color: t = "currentColor" }) => /* @__PURE__ */ _("svg", {
9056
9095
  width: e,
9057
9096
  height: e,
9058
9097
  viewBox: "0 0 24 24",
@@ -9068,7 +9107,7 @@ var Om = { startSession: Dm }, km = ({ size: e = 18, color: t = "currentColor" }
9068
9107
  strokeLinecap: "round",
9069
9108
  strokeLinejoin: "round"
9070
9109
  })]
9071
- }), Am = ({ size: e = 20 }) => /* @__PURE__ */ _("svg", {
9110
+ }), Pm = ({ size: e = 20 }) => /* @__PURE__ */ _("svg", {
9072
9111
  width: e,
9073
9112
  height: e,
9074
9113
  viewBox: "0 0 24 24",
@@ -9083,7 +9122,7 @@ var Om = { startSession: Dm }, km = ({ size: e = 18, color: t = "currentColor" }
9083
9122
  x2: "1",
9084
9123
  y2: "23"
9085
9124
  })]
9086
- }), jm = ({ size: e = 18 }) => /* @__PURE__ */ _("svg", {
9125
+ }), Fm = ({ size: e = 18 }) => /* @__PURE__ */ _("svg", {
9087
9126
  width: e,
9088
9127
  height: e,
9089
9128
  viewBox: "0 0 24 24",
@@ -9098,7 +9137,7 @@ var Om = { startSession: Dm }, km = ({ size: e = 18, color: t = "currentColor" }
9098
9137
  x2: "12",
9099
9138
  y2: "5"
9100
9139
  }), /* @__PURE__ */ g("polyline", { points: "5 12 12 5 19 12" })]
9101
- }), Mm = () => /* @__PURE__ */ _("svg", {
9140
+ }), Im = () => /* @__PURE__ */ _("svg", {
9102
9141
  width: "14",
9103
9142
  height: "14",
9104
9143
  viewBox: "0 0 24 24",
@@ -9108,7 +9147,7 @@ var Om = { startSession: Dm }, km = ({ size: e = 18, color: t = "currentColor" }
9108
9147
  strokeLinecap: "round",
9109
9148
  strokeLinejoin: "round",
9110
9149
  children: [/* @__PURE__ */ g("polyline", { points: "9 17 4 12 9 7" }), /* @__PURE__ */ g("path", { d: "M20 18v-2a4 4 0 00-4-4H4" })]
9111
- }), Nm = () => /* @__PURE__ */ g("svg", {
9150
+ }), Lm = () => /* @__PURE__ */ g("svg", {
9112
9151
  width: "18",
9113
9152
  height: "18",
9114
9153
  viewBox: "0 0 24 24",
@@ -9118,7 +9157,7 @@ var Om = { startSession: Dm }, km = ({ size: e = 18, color: t = "currentColor" }
9118
9157
  strokeLinecap: "round",
9119
9158
  strokeLinejoin: "round",
9120
9159
  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" })
9121
- }), Pm = ({ className: e = "" }) => /* @__PURE__ */ _("svg", {
9160
+ }), Rm = ({ className: e = "" }) => /* @__PURE__ */ _("svg", {
9122
9161
  className: e,
9123
9162
  width: "14",
9124
9163
  height: "14",
@@ -9147,7 +9186,7 @@ var Om = { startSession: Dm }, km = ({ size: e = 18, color: t = "currentColor" }
9147
9186
  y2: "16"
9148
9187
  })
9149
9188
  ]
9150
- }), Fm = ({ size: e = 14 }) => /* @__PURE__ */ _("svg", {
9189
+ }), zm = ({ size: e = 14 }) => /* @__PURE__ */ _("svg", {
9151
9190
  width: e,
9152
9191
  height: e,
9153
9192
  viewBox: "0 0 24 24",
@@ -9170,7 +9209,7 @@ var Om = { startSession: Dm }, km = ({ size: e = 18, color: t = "currentColor" }
9170
9209
  /* @__PURE__ */ g("path", { d: "M15 13v2" }),
9171
9210
  /* @__PURE__ */ g("path", { d: "M9 13v2" })
9172
9211
  ]
9173
- }), Im = ({ size: e = 20, strokeWidth: t = 2, color: n = "currentColor" }) => /* @__PURE__ */ _("svg", {
9212
+ }), Bm = ({ size: e = 20, strokeWidth: t = 2, color: n = "currentColor" }) => /* @__PURE__ */ _("svg", {
9174
9213
  width: e,
9175
9214
  height: e,
9176
9215
  viewBox: "0 0 24 24",
@@ -9190,7 +9229,7 @@ var Om = { startSession: Dm }, km = ({ size: e = 18, color: t = "currentColor" }
9190
9229
  x2: "19",
9191
9230
  y2: "12"
9192
9231
  })]
9193
- }), Lm = ({ size: e = 20, color: t = "currentColor" }) => /* @__PURE__ */ _("svg", {
9232
+ }), Vm = ({ size: e = 20, color: t = "currentColor" }) => /* @__PURE__ */ _("svg", {
9194
9233
  width: e,
9195
9234
  height: e,
9196
9235
  viewBox: "0 0 24 24",
@@ -9216,7 +9255,7 @@ var Om = { startSession: Dm }, km = ({ size: e = 18, color: t = "currentColor" }
9216
9255
  fill: t
9217
9256
  })
9218
9257
  ]
9219
- }), Rm = ({ size: e = 20, color: t = "currentColor" }) => /* @__PURE__ */ _("svg", {
9258
+ }), Hm = ({ size: e = 20, color: t = "currentColor" }) => /* @__PURE__ */ _("svg", {
9220
9259
  width: "24",
9221
9260
  height: "24",
9222
9261
  viewBox: "0 0 24 24",
@@ -9234,7 +9273,7 @@ var Om = { startSession: Dm }, km = ({ size: e = 18, color: t = "currentColor" }
9234
9273
  "stroke-linecap": "round",
9235
9274
  "stroke-linejoin": "round"
9236
9275
  })]
9237
- }), zm = () => /* @__PURE__ */ g("svg", {
9276
+ }), Um = () => /* @__PURE__ */ g("svg", {
9238
9277
  width: "24",
9239
9278
  height: "24",
9240
9279
  viewBox: "0 0 24 24",
@@ -9246,7 +9285,7 @@ var Om = { startSession: Dm }, km = ({ size: e = 18, color: t = "currentColor" }
9246
9285
  "stroke-width": "1.5",
9247
9286
  "stroke-linejoin": "round"
9248
9287
  })
9249
- }), Bm = ({ size: e = 24 }) => /* @__PURE__ */ _("svg", {
9288
+ }), Wm = ({ size: e = 24 }) => /* @__PURE__ */ _("svg", {
9250
9289
  xmlns: "http://www.w3.org/2000/svg",
9251
9290
  width: e,
9252
9291
  height: e,
@@ -9264,7 +9303,7 @@ var Om = { startSession: Dm }, km = ({ size: e = 18, color: t = "currentColor" }
9264
9303
  /* @__PURE__ */ g("path", { d: "m2 2 20 20" }),
9265
9304
  /* @__PURE__ */ g("path", { d: "M9 9v3a3 3 0 0 0 5.12 2.12" })
9266
9305
  ]
9267
- }), Vm = (e = "") => String(e).replace(/<[^>]+>/g, "").replace(/\s+/g, " ").trim(), Hm = (e = "") => String(e).replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;"), Um = new Set([
9306
+ }), Gm = (e = "") => String(e).replace(/<[^>]+>/g, "").replace(/\s+/g, " ").trim(), Km = (e = "") => String(e).replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;"), qm = new Set([
9268
9307
  "p",
9269
9308
  "br",
9270
9309
  "ul",
@@ -9275,30 +9314,30 @@ var Om = { startSession: Dm }, km = ({ size: e = 18, color: t = "currentColor" }
9275
9314
  "b",
9276
9315
  "i",
9277
9316
  "a"
9278
- ]), Wm = /^https?:\/\//i;
9279
- function Gm(e) {
9317
+ ]), Jm = /^https?:\/\//i;
9318
+ function Ym(e) {
9280
9319
  let t = Array.from(e.childNodes);
9281
9320
  for (let n of t) if (n.nodeType === Node.ELEMENT_NODE) {
9282
9321
  let t = n.tagName.toLowerCase();
9283
- if (!Um.has(t)) {
9322
+ if (!qm.has(t)) {
9284
9323
  e.replaceChild(document.createTextNode(n.textContent), n);
9285
9324
  continue;
9286
9325
  }
9287
9326
  let r = {};
9288
9327
  if (t === "a") {
9289
9328
  let e = n.getAttribute("href") || "";
9290
- Wm.test(e) && (r.href = e), r.target = "_blank", r.rel = "noopener noreferrer";
9329
+ Jm.test(e) && (r.href = e), r.target = "_blank", r.rel = "noopener noreferrer";
9291
9330
  }
9292
9331
  for (; n.attributes.length > 0;) n.removeAttribute(n.attributes[0].name);
9293
9332
  for (let [e, t] of Object.entries(r)) n.setAttribute(e, t);
9294
- Gm(n);
9333
+ Ym(n);
9295
9334
  } else n.nodeType !== Node.TEXT_NODE && e.removeChild(n);
9296
9335
  }
9297
- function Km(e) {
9336
+ function Xm(e) {
9298
9337
  let t = document.createElement("div");
9299
- return t.innerHTML = e, Gm(t), t.innerHTML;
9338
+ return t.innerHTML = e, Ym(t), t.innerHTML;
9300
9339
  }
9301
- function qm(e) {
9340
+ function Zm(e) {
9302
9341
  let t = String(e || "").trim();
9303
9342
  if (!t) return t;
9304
9343
  let n = /^<p>\s*<strong>([\s\S]*?)<\/strong>\s*<\/p>$/i.exec(t);
@@ -9310,33 +9349,33 @@ function qm(e) {
9310
9349
  }
9311
9350
  return e;
9312
9351
  }
9313
- var Jm = (e = "") => {
9352
+ var Qm = (e = "") => {
9314
9353
  let t = String(e || "").trim();
9315
9354
  if (!t) return "";
9316
- if (/<(p|br|ul|ol|li|strong|em|a)\b/i.test(t)) return qm(Km(t));
9317
- 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) => Hm(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>");
9318
- return qm(n.map((e) => {
9355
+ if (/<(p|br|ul|ol|li|strong|em|a)\b/i.test(t)) return Zm(Xm(t));
9356
+ 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) => Km(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>");
9357
+ return Zm(n.map((e) => {
9319
9358
  let t = e.split("\n").map((e) => e.trim()).filter(Boolean), n = t.filter((e) => /^[-*]\s+/.test(e));
9320
9359
  if (n.length >= 2 && n.length === t.length) return `<ul>${n.map((e) => `<li>${r(e.replace(/^[-*]\s+/, ""))}</li>`).join("")}</ul>`;
9321
9360
  let i = e.split(/\s+(?=[-*]\s+\*\*?)/).map((e) => e.trim()).filter(Boolean);
9322
9361
  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>`;
9323
9362
  }).join(""));
9324
- }, Ym = new Set(["application/pdf", "application/vnd.openxmlformats-officedocument.wordprocessingml.document"]), Xm = new Set([
9363
+ }, $m = new Set(["application/pdf", "application/vnd.openxmlformats-officedocument.wordprocessingml.document"]), eh = new Set([
9325
9364
  ".pdf",
9326
9365
  ".docx",
9327
9366
  ".png",
9328
9367
  ".jpg",
9329
9368
  ".jpeg"
9330
- ]), Zm = "image/png,image/jpeg,.pdf,.docx";
9331
- function Qm(e) {
9369
+ ]), th = "image/png,image/jpeg,.pdf,.docx";
9370
+ function nh(e) {
9332
9371
  if (!e) return !1;
9333
9372
  let t = typeof e.name == "string" ? e.name.toLowerCase() : "", n = t.includes(".") ? `.${t.split(".").pop()}` : "", r = typeof e.type == "string" ? e.type.toLowerCase() : "";
9334
- return r === "image/png" || r === "image/jpeg" || Ym.has(r) || Xm.has(n);
9373
+ return r === "image/png" || r === "image/jpeg" || $m.has(r) || eh.has(n);
9335
9374
  }
9336
- function $m(e) {
9337
- return e ? Qm(e) ? e.size > 2097152 ? "File must be 2 MB or smaller." : "" : "Only PNG, JPEG, PDF, and DOCX files are allowed." : "No file selected.";
9375
+ function rh(e) {
9376
+ return e ? nh(e) ? e.size > 2097152 ? "File must be 2 MB or smaller." : "" : "Only PNG, JPEG, PDF, and DOCX files are allowed." : "No file selected.";
9338
9377
  }
9339
- function eh(e = 0) {
9378
+ function ih(e = 0) {
9340
9379
  if (!Number.isFinite(e) || e <= 0) return "";
9341
9380
  let t = [
9342
9381
  "B",
@@ -9348,12 +9387,12 @@ function eh(e = 0) {
9348
9387
  let i = n >= 10 || r === 0 ? 0 : 1;
9349
9388
  return `${n.toFixed(i)} ${t[r]}`;
9350
9389
  }
9351
- function th(e) {
9390
+ function ah(e) {
9352
9391
  return e ? e.name || "Attachment" : "";
9353
9392
  }
9354
9393
  //#endregion
9355
9394
  //#region src/utils/avatarHelpers.js
9356
- function nh(e) {
9395
+ function oh(e) {
9357
9396
  if (!e || typeof e != "string") return "?";
9358
9397
  let t = e.trim();
9359
9398
  if (!t) return "?";
@@ -9362,7 +9401,7 @@ function nh(e) {
9362
9401
  }
9363
9402
  //#endregion
9364
9403
  //#region src/components/AvatarImageOrInitials.jsx
9365
- function rh({ src: e, name: t, imgStyle: n, initialsSpanStyle: r }) {
9404
+ function sh({ src: e, name: t, imgStyle: n, initialsSpanStyle: r }) {
9366
9405
  let [i, a] = m(null), o = typeof e == "string" ? e.trim() : "";
9367
9406
  return c(() => {
9368
9407
  if (!o) {
@@ -9385,12 +9424,12 @@ function rh({ src: e, name: t, imgStyle: n, initialsSpanStyle: r }) {
9385
9424
  onError: () => a(null)
9386
9425
  }) : /* @__PURE__ */ g("span", {
9387
9426
  style: r,
9388
- children: nh(t)
9427
+ children: oh(t)
9389
9428
  });
9390
9429
  }
9391
9430
  //#endregion
9392
9431
  //#region src/components/MessageList.jsx
9393
- function ih({ chatHistory: e, isAiTyping: t, isLoading: n, isAgentTyping: r, setReplyContext: i, primaryColor: a = "#3B82F6", agentHeadshot: s = null, agentDisplayName: l = "Agent", botAvatarNode: u = null }) {
9432
+ function ch({ chatHistory: e, isAiTyping: t, isLoading: n, isAgentTyping: r, setReplyContext: i, primaryColor: a = "#3B82F6", agentHeadshot: s = null, agentDisplayName: l = "Agent", botAvatarNode: u = null }) {
9394
9433
  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) => {
9395
9434
  let t = e.target.closest("a[href]");
9396
9435
  if (!t) return;
@@ -9445,7 +9484,7 @@ function ih({ chatHistory: e, isAiTyping: t, isLoading: n, isAgentTyping: r, set
9445
9484
  children: [
9446
9485
  e.map((e) => {
9447
9486
  if (e.type === "call_recording" || typeof e.message == "string" && e.message.includes("AI chat recording")) return null;
9448
- 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 = Vm(e.replyToContent || e.replyContext?.message || ""), v = e.replyToSender === "user" ? "You" : e.replyToSender === "agent" ? "Agent" : e.replyToSender === "ai" || e.replyToSender === "bot" ? "AI Assistant" : "Message";
9487
+ 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 = Gm(e.replyToContent || e.replyContext?.message || ""), v = e.replyToSender === "user" ? "You" : e.replyToSender === "agent" ? "Agent" : e.replyToSender === "ai" || e.replyToSender === "bot" ? "AI Assistant" : "Message";
9449
9488
  return t ? /* @__PURE__ */ g("div", {
9450
9489
  style: {
9451
9490
  display: "flex",
@@ -9490,7 +9529,7 @@ function ih({ chatHistory: e, isAiTyping: t, isLoading: n, isAgentTyping: r, set
9490
9529
  fontWeight: 800,
9491
9530
  marginTop: !c && (r || o) ? "22px" : "0px"
9492
9531
  },
9493
- children: r ? u || /* @__PURE__ */ g(Fm, { size: 16 }) : /* @__PURE__ */ g(rh, {
9532
+ children: r ? u || /* @__PURE__ */ g(zm, { size: 16 }) : /* @__PURE__ */ g(sh, {
9494
9533
  src: p || "",
9495
9534
  name: f,
9496
9535
  imgStyle: {
@@ -9532,7 +9571,7 @@ function ih({ chatHistory: e, isAiTyping: t, isLoading: n, isAgentTyping: r, set
9532
9571
  onMouseLeave: (e) => {
9533
9572
  e.currentTarget.style.color = "#9ca3af";
9534
9573
  },
9535
- children: [/* @__PURE__ */ g(Mm, {}), "Reply"]
9574
+ children: [/* @__PURE__ */ g(Im, {}), "Reply"]
9536
9575
  }),
9537
9576
  /* @__PURE__ */ _("div", {
9538
9577
  style: {
@@ -9576,7 +9615,7 @@ function ih({ chatHistory: e, isAiTyping: t, isLoading: n, isAgentTyping: r, set
9576
9615
  children: m
9577
9616
  })]
9578
9617
  }), d ? (() => {
9579
- let t = e.metadata.fileType || "", r = e.metadata.fileName || e.message || "File", i = eh(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" ? {
9618
+ let t = e.metadata.fileType || "", r = e.metadata.fileName || e.message || "File", i = ih(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" ? {
9580
9619
  color: "#ef4444",
9581
9620
  label: "PDF"
9582
9621
  } : t.includes("word") || t.includes("docx") ? {
@@ -9757,7 +9796,7 @@ function ih({ chatHistory: e, isAiTyping: t, isLoading: n, isAgentTyping: r, set
9757
9796
  });
9758
9797
  })() : r ? /* @__PURE__ */ g("div", {
9759
9798
  className: "flowengage-message-content fe-bot-message",
9760
- dangerouslySetInnerHTML: { __html: Jm(e.message) },
9799
+ dangerouslySetInnerHTML: { __html: Qm(e.message) },
9761
9800
  onClick: T
9762
9801
  }) : /* @__PURE__ */ g("div", {
9763
9802
  style: { whiteSpace: "pre-wrap" },
@@ -9822,7 +9861,7 @@ function ih({ chatHistory: e, isAiTyping: t, isLoading: n, isAgentTyping: r, set
9822
9861
  boxShadow: u ? "none" : "0 8px 20px rgba(59,130,246,0.24)",
9823
9862
  overflow: "hidden"
9824
9863
  },
9825
- children: u || /* @__PURE__ */ g(Fm, { size: 16 })
9864
+ children: u || /* @__PURE__ */ g(zm, { size: 16 })
9826
9865
  }), /* @__PURE__ */ _("div", {
9827
9866
  style: {
9828
9867
  display: "flex",
@@ -9864,7 +9903,7 @@ function ih({ chatHistory: e, isAiTyping: t, isLoading: n, isAgentTyping: r, set
9864
9903
  borderRadius: "50%",
9865
9904
  overflow: "hidden"
9866
9905
  },
9867
- children: /* @__PURE__ */ g(rh, {
9906
+ children: /* @__PURE__ */ g(sh, {
9868
9907
  src: s || "",
9869
9908
  name: l,
9870
9909
  imgStyle: {
@@ -9958,8 +9997,8 @@ function ih({ chatHistory: e, isAiTyping: t, isLoading: n, isAgentTyping: r, set
9958
9997
  }
9959
9998
  //#endregion
9960
9999
  //#region src/components/ChatInput.jsx
9961
- var ah = typeof window < "u" && (window.matchMedia?.("(pointer: coarse)").matches || navigator.maxTouchPoints > 0);
9962
- function oh({ 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" }) {
10000
+ var lh = typeof window < "u" && (window.matchMedia?.("(pointer: coarse)").matches || navigator.maxTouchPoints > 0);
10001
+ function uh({ 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" }) {
9963
10002
  let D = p(null), O = p(null), k = (e) => {
9964
10003
  e && (e.style.height = "auto", e.style.height = `${Math.min(e.scrollHeight, 120)}px`);
9965
10004
  };
@@ -9967,7 +10006,7 @@ function oh({ input: e, setInput: t, onSubmit: n, isConversationEnded: r, callUi
9967
10006
  d || k(O.current);
9968
10007
  }, [e, d]);
9969
10008
  let A = (e) => {
9970
- e.key === "Enter" && (ah || e.shiftKey || e.altKey || e.ctrlKey || e.metaKey || (e.preventDefault(), e.currentTarget.form?.requestSubmit()));
10009
+ e.key === "Enter" && (lh || e.shiftKey || e.altKey || e.ctrlKey || e.metaKey || (e.preventDefault(), e.currentTarget.form?.requestSubmit()));
9971
10010
  }, 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;
9972
10011
  return /* @__PURE__ */ _("div", {
9973
10012
  style: {
@@ -10062,7 +10101,7 @@ function oh({ input: e, setInput: t, onSubmit: n, isConversationEnded: r, callUi
10062
10101
  background: "rgba(59,130,246,0.08)",
10063
10102
  color: "var(--flowengage-primary)"
10064
10103
  },
10065
- children: /* @__PURE__ */ g(Fm, { size: 13 })
10104
+ children: /* @__PURE__ */ g(zm, { size: 13 })
10066
10105
  }), /* @__PURE__ */ g("span", { children: "Please provide your email address so we can help you." })]
10067
10106
  })
10068
10107
  }),
@@ -10102,7 +10141,7 @@ function oh({ input: e, setInput: t, onSubmit: n, isConversationEnded: r, callUi
10102
10141
  overflow: "hidden",
10103
10142
  textOverflow: "ellipsis"
10104
10143
  },
10105
- children: th(S)
10144
+ children: ah(S)
10106
10145
  }),
10107
10146
  /* @__PURE__ */ g("div", {
10108
10147
  style: {
@@ -10110,7 +10149,7 @@ function oh({ input: e, setInput: t, onSubmit: n, isConversationEnded: r, callUi
10110
10149
  color: "#6b7280",
10111
10150
  marginTop: "2px"
10112
10151
  },
10113
- children: eh(S.size)
10152
+ children: ih(S.size)
10114
10153
  })
10115
10154
  ]
10116
10155
  }), /* @__PURE__ */ g("button", {
@@ -10155,7 +10194,7 @@ function oh({ input: e, setInput: t, onSubmit: n, isConversationEnded: r, callUi
10155
10194
  j ? /* @__PURE__ */ _(h, { children: [/* @__PURE__ */ g("input", {
10156
10195
  ref: D,
10157
10196
  type: "file",
10158
- accept: Zm,
10197
+ accept: th,
10159
10198
  style: { display: "none" },
10160
10199
  onChange: (e) => {
10161
10200
  let t = e.target.files?.[0];
@@ -10187,7 +10226,7 @@ function oh({ input: e, setInput: t, onSubmit: n, isConversationEnded: r, callUi
10187
10226
  onMouseLeave: (e) => {
10188
10227
  e.currentTarget.style.opacity = "1";
10189
10228
  },
10190
- children: /* @__PURE__ */ g(Im, {
10229
+ children: /* @__PURE__ */ g(Bm, {
10191
10230
  size: 16,
10192
10231
  color: "currentColor"
10193
10232
  })
@@ -10268,7 +10307,7 @@ function oh({ input: e, setInput: t, onSubmit: n, isConversationEnded: r, callUi
10268
10307
  onMouseLeave: (e) => {
10269
10308
  e.currentTarget.style.opacity = "1";
10270
10309
  },
10271
- children: /* @__PURE__ */ g(jm, { size: 16 })
10310
+ children: /* @__PURE__ */ g(Fm, { size: 16 })
10272
10311
  })
10273
10312
  ]
10274
10313
  }),
@@ -10331,7 +10370,7 @@ function oh({ input: e, setInput: t, onSubmit: n, isConversationEnded: r, callUi
10331
10370
  }
10332
10371
  //#endregion
10333
10372
  //#region src/components/StatusBanners.jsx
10334
- function sh({ webRTCError: e, micError: t, setMicError: n, dismissCallError: r, isRateLimited: i, rateLimitMessage: a }) {
10373
+ function dh({ webRTCError: e, micError: t, setMicError: n, dismissCallError: r, isRateLimited: i, rateLimitMessage: a }) {
10335
10374
  return /* @__PURE__ */ _(h, { children: [(e || t) && /* @__PURE__ */ _("div", {
10336
10375
  style: {
10337
10376
  margin: "0 20px 10px",
@@ -10344,7 +10383,7 @@ function sh({ webRTCError: e, micError: t, setMicError: n, dismissCallError: r,
10344
10383
  gap: "10px"
10345
10384
  },
10346
10385
  children: [
10347
- /* @__PURE__ */ g(Pm, { className: "" }),
10386
+ /* @__PURE__ */ g(Rm, { className: "" }),
10348
10387
  /* @__PURE__ */ g("span", {
10349
10388
  style: {
10350
10389
  fontSize: "12px",
@@ -10390,13 +10429,13 @@ function sh({ webRTCError: e, micError: t, setMicError: n, dismissCallError: r,
10390
10429
  }
10391
10430
  //#endregion
10392
10431
  //#region src/components/AnimatedOrb.jsx
10393
- var ch = [
10432
+ var fh = [
10394
10433
  "#135bd8",
10395
10434
  "#ef334b",
10396
10435
  "#ffbd2e"
10397
10436
  ];
10398
- function lh(e) {
10399
- return !Array.isArray(e) || e.length === 0 ? ch : e.length === 1 ? [
10437
+ function ph(e) {
10438
+ return !Array.isArray(e) || e.length === 0 ? fh : e.length === 1 ? [
10400
10439
  e[0],
10401
10440
  e[0],
10402
10441
  e[0]
@@ -10410,7 +10449,7 @@ function lh(e) {
10410
10449
  e[2]
10411
10450
  ];
10412
10451
  }
10413
- var uh = {
10452
+ var mh = {
10414
10453
  idle: 3,
10415
10454
  listening: .75,
10416
10455
  thinking: 1,
@@ -10418,7 +10457,7 @@ var uh = {
10418
10457
  muted: .75,
10419
10458
  error: .08
10420
10459
  };
10421
- function dh(e) {
10460
+ function hh(e) {
10422
10461
  if (!e || typeof e != "string") return [
10423
10462
  0,
10424
10463
  0,
@@ -10431,14 +10470,14 @@ function dh(e) {
10431
10470
  parseInt(n.slice(4, 6), 16) / 255
10432
10471
  ];
10433
10472
  }
10434
- function fh(e, t) {
10473
+ function gh(e, t) {
10435
10474
  if (!e || typeof e != "string") return `rgba(0,0,0,${t})`;
10436
10475
  if (e.startsWith("rgb")) return e.replace(/[\d.]+\)$/, `${t})`);
10437
10476
  let n = e.replace("#", ""), r = n.length === 3 ? n.split("").map((e) => e + e).join("") : n;
10438
10477
  return `rgba(${parseInt(r.slice(0, 2), 16)},${parseInt(r.slice(2, 4), 16)},${parseInt(r.slice(4, 6), 16)},${t})`;
10439
10478
  }
10440
- var ph = "\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", mh = "\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";
10441
- function hh(e, t, n) {
10479
+ var _h = "\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", vh = "\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";
10480
+ function yh(e, t, n) {
10442
10481
  let r = (t, n) => {
10443
10482
  let r = e.createShader(t);
10444
10483
  return e.shaderSource(r, n), e.compileShader(r), e.getShaderParameter(r, e.COMPILE_STATUS) ? r : (console.error("[AnimatedOrb shader]", e.getShaderInfoLog(r)), null);
@@ -10447,10 +10486,10 @@ function hh(e, t, n) {
10447
10486
  let o = e.createProgram();
10448
10487
  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);
10449
10488
  }
10450
- function gh({ size: e = 94, voiceState: t = "idle", isMuted: n = !1, colors: r, onClick: i, style: a, className: o }) {
10451
- let [s, l, u] = lh(r), d = t === "speaking", f = e <= 50, m = p(null), h = p(uh[t] ?? .35);
10489
+ function bh({ size: e = 94, voiceState: t = "idle", isMuted: n = !1, colors: r, onClick: i, style: a, className: o }) {
10490
+ let [s, l, u] = ph(r), d = t === "speaking", f = e <= 50, m = p(null), h = p(mh[t] ?? .35);
10452
10491
  c(() => {
10453
- h.current = uh[t] ?? .35;
10492
+ h.current = mh[t] ?? .35;
10454
10493
  }, [t]), c(() => {
10455
10494
  let t = m.current;
10456
10495
  if (!t) return;
@@ -10467,7 +10506,7 @@ function gh({ size: e = 94, voiceState: t = "idle", isMuted: n = !1, colors: r,
10467
10506
  console.warn("[AnimatedOrb] WebGL unavailable.");
10468
10507
  return;
10469
10508
  }
10470
- let i = hh(r, ph, mh);
10509
+ let i = yh(r, _h, vh);
10471
10510
  if (!i) {
10472
10511
  console.error("[AnimatedOrb] WebGL program failed to compile/link");
10473
10512
  return;
@@ -10497,7 +10536,7 @@ function gh({ size: e = 94, voiceState: t = "idle", isMuted: n = !1, colors: r,
10497
10536
  c2: r.getUniformLocation(i, "u_c2"),
10498
10537
  c3: r.getUniformLocation(i, "u_c3")
10499
10538
  };
10500
- r.uniform3fv(c.c1, dh(s)), r.uniform3fv(c.c2, dh(l)), r.uniform3fv(c.c3, dh(u)), r.viewport(0, 0, t.width, t.height);
10539
+ r.uniform3fv(c.c1, hh(s)), r.uniform3fv(c.c2, hh(l)), r.uniform3fv(c.c3, hh(u)), r.viewport(0, 0, t.width, t.height);
10501
10540
  let d = performance.now(), f, p = (e) => {
10502
10541
  r.uniform1f(c.time, (e - d) / 1e3), r.uniform1f(c.speed, h.current), r.drawArrays(r.TRIANGLES, 0, 6), f = requestAnimationFrame(p);
10503
10542
  };
@@ -10528,7 +10567,7 @@ function gh({ size: e = 94, voiceState: t = "idle", isMuted: n = !1, colors: r,
10528
10567
  position: "absolute",
10529
10568
  inset: -10,
10530
10569
  borderRadius: "50%",
10531
- background: `radial-gradient(circle, ${fh(s, .18)} 0%, transparent 70%)`,
10570
+ background: `radial-gradient(circle, ${gh(s, .18)} 0%, transparent 70%)`,
10532
10571
  pointerEvents: "none"
10533
10572
  },
10534
10573
  animate: { opacity: [.3, .75] },
@@ -10606,17 +10645,17 @@ function gh({ size: e = 94, voiceState: t = "idle", isMuted: n = !1, colors: r,
10606
10645
  }
10607
10646
  //#endregion
10608
10647
  //#region src/components/CallScreen.jsx
10609
- var _h = "\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";
10610
- function vh(e) {
10648
+ var xh = "\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";
10649
+ function Sh(e) {
10611
10650
  let t = (e || "").replace("#", ""), n = t.length === 3 ? t.split("").map((e) => e + e).join("") : t;
10612
10651
  return `${parseInt(n.slice(0, 2), 16)},${parseInt(n.slice(2, 4), 16)},${parseInt(n.slice(4, 6), 16)}`;
10613
10652
  }
10614
- function yh(e) {
10653
+ function Ch(e) {
10615
10654
  if (!e || typeof e != "string") return "#1a1a1a";
10616
10655
  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;
10617
10656
  return .2126 * o(r) + .7152 * o(i) + .0722 * o(a) > .179 ? "#1a1a1a" : "#ffffff";
10618
10657
  }
10619
- function bh(e, t) {
10658
+ function wh(e, t) {
10620
10659
  let n = Array.isArray(e) && e.length > 0 ? e : [t || "#3B82F6"], [r, i, a] = n;
10621
10660
  return n.length === 1 ? [
10622
10661
  `radial-gradient(ellipse 110% 65% at 50% -5%, ${r}28 0%, transparent 68%)`,
@@ -10633,8 +10672,8 @@ function bh(e, t) {
10633
10672
  "#f7f8fa"
10634
10673
  ].join(", ");
10635
10674
  }
10636
- function xh({ headshot: e, name: t, size: n = 80, primaryColor: r = "#3B82F6" }) {
10637
- let i = (t || "A")[0].toUpperCase(), a = yh(r), o = n > 48 ? {
10675
+ function Th({ headshot: e, name: t, size: n = 80, primaryColor: r = "#3B82F6" }) {
10676
+ let i = (t || "A")[0].toUpperCase(), a = Ch(r), o = n > 48 ? {
10638
10677
  boxShadow: `0 0 0 3px ${r}44`,
10639
10678
  border: "3px solid rgba(255,255,255,0.15)"
10640
10679
  } : { border: `1.5px solid ${r}55` };
@@ -10671,7 +10710,7 @@ function xh({ headshot: e, name: t, size: n = 80, primaryColor: r = "#3B82F6" })
10671
10710
  children: i
10672
10711
  });
10673
10712
  }
10674
- function Sh(e) {
10713
+ function Eh(e) {
10675
10714
  let t = p(null), n = o(() => {
10676
10715
  if (!t.current) return;
10677
10716
  let { audioContext: e, oscillator: n, interval: r, toneTimeout: i } = t.current;
@@ -10718,8 +10757,8 @@ function Sh(e) {
10718
10757
  n
10719
10758
  ]), c(() => () => n(), [n]), n;
10720
10759
  }
10721
- function Ch({ 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 = [] }) {
10722
- let y = a || s || "Agent", b = e ? "incoming" : n === "connecting" ? "connecting" : "ongoing", x = Sh(!!e), S = async () => {
10760
+ function Dh({ 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 = [] }) {
10761
+ let y = a || s || "Agent", b = e ? "incoming" : n === "connecting" ? "connecting" : "ongoing", x = Eh(!!e), S = async () => {
10723
10762
  x(), await c();
10724
10763
  }, C = async () => {
10725
10764
  x(), await l();
@@ -10731,14 +10770,14 @@ function Ch({ incomingCall: e, activeCallId: t, callConnectionState: n, callDura
10731
10770
  flexDirection: "column",
10732
10771
  borderRadius: "inherit",
10733
10772
  overflow: "hidden",
10734
- background: bh(h, m),
10773
+ background: wh(h, m),
10735
10774
  animation: T ? "fe-call-slide-up 0.36s cubic-bezier(0.16,1,0.3,1)" : "fe-call-fade-in 0.32s ease"
10736
10775
  };
10737
10776
  if (b === "incoming") {
10738
10777
  let e = Array.isArray(h) && h.length > 0 ? h : [m];
10739
10778
  return /* @__PURE__ */ _("div", {
10740
10779
  style: E,
10741
- children: [/* @__PURE__ */ g("style", { children: _h }), /* @__PURE__ */ _("div", {
10780
+ children: [/* @__PURE__ */ g("style", { children: xh }), /* @__PURE__ */ _("div", {
10742
10781
  style: {
10743
10782
  flex: 1,
10744
10783
  display: "flex",
@@ -10769,7 +10808,7 @@ function Ch({ incomingCall: e, activeCallId: t, callConnectionState: n, callDura
10769
10808
  width: "96px",
10770
10809
  height: "96px",
10771
10810
  borderRadius: "50%",
10772
- background: `radial-gradient(circle, rgba(${vh(e[0])},0.2) 0%, transparent 70%)`,
10811
+ background: `radial-gradient(circle, rgba(${Sh(e[0])},0.2) 0%, transparent 70%)`,
10773
10812
  filter: "blur(10px)",
10774
10813
  zIndex: 0
10775
10814
  } }),
@@ -10786,7 +10825,7 @@ function Ch({ incomingCall: e, activeCallId: t, callConnectionState: n, callDura
10786
10825
  animation: `fe-call-ring-pulse 2.6s cubic-bezier(0.215,0.61,0.355,1) ${t}s infinite`,
10787
10826
  zIndex: 1
10788
10827
  } }, n)),
10789
- /* @__PURE__ */ g(xh, {
10828
+ /* @__PURE__ */ g(Th, {
10790
10829
  headshot: o,
10791
10830
  name: y,
10792
10831
  size: 82,
@@ -10866,7 +10905,7 @@ function Ch({ incomingCall: e, activeCallId: t, callConnectionState: n, callDura
10866
10905
  e.currentTarget.style.transform = "scale(1)", e.currentTarget.style.boxShadow = "0 6px 24px rgba(239,68,68,0.5)";
10867
10906
  },
10868
10907
  "aria-label": "Decline call",
10869
- children: /* @__PURE__ */ g(Am, { size: 26 })
10908
+ children: /* @__PURE__ */ g(Pm, { size: 26 })
10870
10909
  }), /* @__PURE__ */ g("span", {
10871
10910
  style: {
10872
10911
  fontSize: "12px",
@@ -10907,7 +10946,7 @@ function Ch({ incomingCall: e, activeCallId: t, callConnectionState: n, callDura
10907
10946
  e.currentTarget.style.transform = "scale(1)", e.currentTarget.style.boxShadow = "0 6px 24px rgba(34,197,94,0.5)";
10908
10947
  },
10909
10948
  "aria-label": "Accept call",
10910
- children: /* @__PURE__ */ g(Nm, {})
10949
+ children: /* @__PURE__ */ g(Lm, {})
10911
10950
  }), /* @__PURE__ */ g("span", {
10912
10951
  style: {
10913
10952
  fontSize: "12px",
@@ -10924,7 +10963,7 @@ function Ch({ incomingCall: e, activeCallId: t, callConnectionState: n, callDura
10924
10963
  }
10925
10964
  return b === "connecting" ? /* @__PURE__ */ _("div", {
10926
10965
  style: E,
10927
- children: [/* @__PURE__ */ g("style", { children: _h }), /* @__PURE__ */ _("div", {
10966
+ children: [/* @__PURE__ */ g("style", { children: xh }), /* @__PURE__ */ _("div", {
10928
10967
  style: {
10929
10968
  flex: 1,
10930
10969
  display: "flex",
@@ -10934,7 +10973,7 @@ function Ch({ incomingCall: e, activeCallId: t, callConnectionState: n, callDura
10934
10973
  gap: "24px"
10935
10974
  },
10936
10975
  children: [
10937
- /* @__PURE__ */ g(xh, {
10976
+ /* @__PURE__ */ g(Th, {
10938
10977
  headshot: o,
10939
10978
  name: y,
10940
10979
  size: 64,
@@ -10961,7 +11000,7 @@ function Ch({ incomingCall: e, activeCallId: t, callConnectionState: n, callDura
10961
11000
  }) : /* @__PURE__ */ _("div", {
10962
11001
  style: E,
10963
11002
  children: [
10964
- /* @__PURE__ */ g("style", { children: _h }),
11003
+ /* @__PURE__ */ g("style", { children: xh }),
10965
11004
  /* @__PURE__ */ _("div", {
10966
11005
  style: {
10967
11006
  display: "flex",
@@ -11007,7 +11046,7 @@ function Ch({ incomingCall: e, activeCallId: t, callConnectionState: n, callDura
11007
11046
  children: /* @__PURE__ */ g("polyline", { points: "15 18 9 12 15 6" })
11008
11047
  })
11009
11048
  }),
11010
- /* @__PURE__ */ g(gh, {
11049
+ /* @__PURE__ */ g(bh, {
11011
11050
  colors: h,
11012
11051
  size: 36,
11013
11052
  voiceState: w
@@ -11058,7 +11097,7 @@ function Ch({ incomingCall: e, activeCallId: t, callConnectionState: n, callDura
11058
11097
  gap: "16px",
11059
11098
  padding: "0 24px 16px"
11060
11099
  },
11061
- children: [/* @__PURE__ */ g(xh, {
11100
+ children: [/* @__PURE__ */ g(Th, {
11062
11101
  headshot: o,
11063
11102
  name: y,
11064
11103
  size: 116,
@@ -11113,7 +11152,7 @@ function Ch({ incomingCall: e, activeCallId: t, callConnectionState: n, callDura
11113
11152
  transition: "all 0.2s ease"
11114
11153
  },
11115
11154
  "aria-label": i ? "Unmute" : "Mute",
11116
- children: [g(i ? Bm : km, { size: 18 }), i ? "Unmute" : "Mute"]
11155
+ children: [g(i ? Wm : Nm, { size: 18 }), i ? "Unmute" : "Mute"]
11117
11156
  }), /* @__PURE__ */ _("button", {
11118
11157
  type: "button",
11119
11158
  onClick: u,
@@ -11141,15 +11180,15 @@ function Ch({ incomingCall: e, activeCallId: t, callConnectionState: n, callDura
11141
11180
  e.currentTarget.style.background = "rgba(239,68,68,0.9)", e.currentTarget.style.transform = "scale(1)";
11142
11181
  },
11143
11182
  "aria-label": "End call",
11144
- children: [/* @__PURE__ */ g(Am, { size: 18 }), "End Call"]
11183
+ children: [/* @__PURE__ */ g(Pm, { size: 18 }), "End Call"]
11145
11184
  })]
11146
11185
  })
11147
11186
  ]
11148
11187
  });
11149
11188
  }
11150
- function wh({ agentName: e, agentHeadshot: t, fallbackAgentName: n, callDurationSeconds: r, isCallMuted: i, formatCallDuration: a, toggleCallMute: o, endWebRTCCall: s, onExpand: c, primaryColor: l = "#3B82F6" }) {
11189
+ function Oh({ agentName: e, agentHeadshot: t, fallbackAgentName: n, callDurationSeconds: r, isCallMuted: i, formatCallDuration: a, toggleCallMute: o, endWebRTCCall: s, onExpand: c, primaryColor: l = "#3B82F6" }) {
11151
11190
  let u = e || n || "Agent";
11152
- return /* @__PURE__ */ _(h, { children: [/* @__PURE__ */ g("style", { children: _h }), /* @__PURE__ */ _("div", {
11191
+ return /* @__PURE__ */ _(h, { children: [/* @__PURE__ */ g("style", { children: xh }), /* @__PURE__ */ _("div", {
11153
11192
  role: "button",
11154
11193
  tabIndex: 0,
11155
11194
  onClick: c,
@@ -11206,7 +11245,7 @@ function wh({ agentName: e, agentHeadshot: t, fallbackAgentName: n, callDuration
11206
11245
  borderRadius: "50%",
11207
11246
  border: `1.5px solid ${l}55`
11208
11247
  } }),
11209
- /* @__PURE__ */ g(xh, {
11248
+ /* @__PURE__ */ g(Th, {
11210
11249
  headshot: t,
11211
11250
  name: u,
11212
11251
  size: 38,
@@ -11290,7 +11329,7 @@ function wh({ agentName: e, agentHeadshot: t, fallbackAgentName: n, callDuration
11290
11329
  boxShadow: i ? `0 0 0 3px ${l}12` : "none"
11291
11330
  },
11292
11331
  "aria-label": i ? "Unmute" : "Mute",
11293
- children: g(i ? Bm : km, { size: 15 })
11332
+ children: g(i ? Wm : Nm, { size: 15 })
11294
11333
  }), /* @__PURE__ */ g("button", {
11295
11334
  type: "button",
11296
11335
  onClick: (e) => {
@@ -11318,7 +11357,7 @@ function wh({ agentName: e, agentHeadshot: t, fallbackAgentName: n, callDuration
11318
11357
  transition: "all 0.18s ease"
11319
11358
  },
11320
11359
  "aria-label": "End call",
11321
- children: /* @__PURE__ */ g(Am, { size: 16 })
11360
+ children: /* @__PURE__ */ g(Pm, { size: 16 })
11322
11361
  })]
11323
11362
  })
11324
11363
  ]
@@ -11326,7 +11365,7 @@ function wh({ agentName: e, agentHeadshot: t, fallbackAgentName: n, callDuration
11326
11365
  }
11327
11366
  //#endregion
11328
11367
  //#region src/utils/voicePriorContext.js
11329
- function Th(e, t = {}) {
11368
+ function kh(e, t = {}) {
11330
11369
  let n = t.maxChars ?? 4500;
11331
11370
  if (!Array.isArray(e) || e.length === 0) return "";
11332
11371
  let r = [];
@@ -11344,7 +11383,7 @@ function Th(e, t = {}) {
11344
11383
  //#endregion
11345
11384
  //#region src/utils/voiceActionVisuals.js
11346
11385
  var Q = "fe-vv";
11347
- function Eh() {
11386
+ function Ah() {
11348
11387
  if (typeof document > "u" || document.getElementById(`${Q}-styles`)) return;
11349
11388
  let e = `
11350
11389
  /* ── Action toast ───────────────────────────────────────────────────────────── */
@@ -11489,14 +11528,14 @@ function Eh() {
11489
11528
  `, t = document.createElement("style");
11490
11529
  t.id = `${Q}-styles`, t.textContent = e, (document.head || document.documentElement).appendChild(t);
11491
11530
  }
11492
- var Dh = null, Oh = null;
11493
- function kh() {
11494
- return (!Dh || !Dh.isConnected) && (Dh = document.createElement("div"), Dh.id = `${Q}-toast`, document.body.appendChild(Dh)), Dh;
11531
+ var jh = null, Mh = null;
11532
+ function Nh() {
11533
+ return (!jh || !jh.isConnected) && (jh = document.createElement("div"), jh.id = `${Q}-toast`, document.body.appendChild(jh)), jh;
11495
11534
  }
11496
- function Ah(e, { spinner: t = !0, icon: n = null, duration: r = 0 } = {}) {
11535
+ function Ph(e, { spinner: t = !0, icon: n = null, duration: r = 0 } = {}) {
11497
11536
  if (typeof document > "u") return;
11498
- Eh(), Oh &&= (clearTimeout(Oh), null);
11499
- let i = kh();
11537
+ Ah(), Mh &&= (clearTimeout(Mh), null);
11538
+ let i = Nh();
11500
11539
  if (i.innerHTML = "", n) {
11501
11540
  let e = document.createElement("span");
11502
11541
  e.className = `${Q}-icon`, e.textContent = n, i.appendChild(e);
@@ -11505,71 +11544,71 @@ function Ah(e, { spinner: t = !0, icon: n = null, duration: r = 0 } = {}) {
11505
11544
  e.className = `${Q}-spin`, i.appendChild(e);
11506
11545
  }
11507
11546
  let a = document.createElement("span");
11508
- a.textContent = e, i.appendChild(a), i.classList.remove(`${Q}-show`), i.offsetHeight, i.classList.add(`${Q}-show`), r > 0 && (Oh = setTimeout(() => jh(), r));
11547
+ a.textContent = e, i.appendChild(a), i.classList.remove(`${Q}-show`), i.offsetHeight, i.classList.add(`${Q}-show`), r > 0 && (Mh = setTimeout(() => Fh(), r));
11509
11548
  }
11510
- function jh(e = 0) {
11511
- Dh && (e > 0 ? Oh = setTimeout(() => {
11512
- Dh && Dh.classList.remove(`${Q}-show`);
11513
- }, e) : Dh && Dh.classList.remove(`${Q}-show`));
11549
+ function Fh(e = 0) {
11550
+ jh && (e > 0 ? Mh = setTimeout(() => {
11551
+ jh && jh.classList.remove(`${Q}-show`);
11552
+ }, e) : jh && jh.classList.remove(`${Q}-show`));
11514
11553
  }
11515
- var Mh = null, Nh = [];
11516
- function Ph() {
11517
- return (!Mh || !Mh.isConnected) && (Mh = document.createElement("div"), Mh.id = `${Q}-bar`, document.body.appendChild(Mh)), Mh;
11554
+ var Ih = null, Lh = [];
11555
+ function Rh() {
11556
+ return (!Ih || !Ih.isConnected) && (Ih = document.createElement("div"), Ih.id = `${Q}-bar`, document.body.appendChild(Ih)), Ih;
11518
11557
  }
11519
- function Fh() {
11558
+ function zh() {
11520
11559
  if (typeof document > "u") return;
11521
- Eh(), Nh.forEach(clearTimeout), Nh = [];
11522
- let e = Ph();
11560
+ Ah(), Lh.forEach(clearTimeout), Lh = [];
11561
+ let e = Rh();
11523
11562
  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";
11524
11563
  let t = [[80, "width 0.6s ease"], [92, "width 1.2s ease"]], n = 50;
11525
11564
  for (let [e, r] of t) {
11526
11565
  let t = n, i = e, a = r;
11527
- Nh.push(setTimeout(() => {
11528
- Mh && (Mh.style.transition = a, Mh.style.width = `${i}%`);
11566
+ Lh.push(setTimeout(() => {
11567
+ Ih && (Ih.style.transition = a, Ih.style.width = `${i}%`);
11529
11568
  }, t)), n += 800;
11530
11569
  }
11531
11570
  }
11532
- function Ih() {
11533
- Mh && (Nh.forEach(clearTimeout), Nh = [], Mh.style.transition = "width 0.2s ease", Mh.style.width = "100%", Nh.push(setTimeout(() => {
11534
- Mh && (Mh.style.transition = "opacity 0.35s ease", Mh.style.opacity = "0", Nh.push(setTimeout(() => {
11535
- Mh && (Mh.style.width = "0%", Mh.classList.remove(`${Q}-bar-active`));
11571
+ function Bh() {
11572
+ Ih && (Lh.forEach(clearTimeout), Lh = [], Ih.style.transition = "width 0.2s ease", Ih.style.width = "100%", Lh.push(setTimeout(() => {
11573
+ Ih && (Ih.style.transition = "opacity 0.35s ease", Ih.style.opacity = "0", Lh.push(setTimeout(() => {
11574
+ Ih && (Ih.style.width = "0%", Ih.classList.remove(`${Q}-bar-active`));
11536
11575
  }, 380)));
11537
11576
  }, 220)));
11538
11577
  }
11539
- var Lh = `<svg xmlns="http://www.w3.org/2000/svg" width="22" height="22" viewBox="0 0 22 22" fill="none">
11578
+ var Vh = `<svg xmlns="http://www.w3.org/2000/svg" width="22" height="22" viewBox="0 0 22 22" fill="none">
11540
11579
  <filter id="${Q}-csh">
11541
11580
  <feDropShadow dx="1" dy="2" stdDeviation="1.5" flood-color="#00000060"/>
11542
11581
  </filter>
11543
11582
  <path d="M4 2L19 10.5L11 12.8L8 20L4 2Z"
11544
11583
  fill="white" stroke="#1e1b4b" stroke-width="1.6" stroke-linejoin="round"
11545
11584
  filter="url(#${Q}-csh)"/>
11546
- </svg>`, Rh = null, zh = !1;
11547
- function Bh() {
11548
- return (!Rh || !Rh.isConnected) && (Rh = document.createElement("div"), Rh.id = `${Q}-cursor`, Rh.innerHTML = Lh, document.body.appendChild(Rh), zh = !1), Rh;
11585
+ </svg>`, Hh = null, Uh = !1;
11586
+ function Wh() {
11587
+ return (!Hh || !Hh.isConnected) && (Hh = document.createElement("div"), Hh.id = `${Q}-cursor`, Hh.innerHTML = Vh, document.body.appendChild(Hh), Uh = !1), Hh;
11549
11588
  }
11550
- async function Vh(e) {
11589
+ async function Gh(e) {
11551
11590
  if (typeof document > "u" || !e) return;
11552
- Eh();
11591
+ Ah();
11553
11592
  let t;
11554
11593
  try {
11555
11594
  t = e.getBoundingClientRect();
11556
11595
  } catch {
11557
11596
  return;
11558
11597
  }
11559
- let n = t.left + Math.min(16, t.width * .2), r = t.top + Math.min(12, t.height * .25), i = Bh();
11560
- zh ||= (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 Gh(360);
11598
+ let n = t.left + Math.min(16, t.width * .2), r = t.top + Math.min(12, t.height * .25), i = Wh();
11599
+ Uh ||= (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 Yh(360);
11561
11600
  }
11562
- function Hh(e = !1) {
11563
- Rh && (e ? (Rh.classList.remove(`${Q}-cursor-visible`), zh = !1) : (Rh.classList.remove(`${Q}-cursor-visible`), setTimeout(() => {
11564
- zh = !1;
11601
+ function Kh(e = !1) {
11602
+ Hh && (e ? (Hh.classList.remove(`${Q}-cursor-visible`), Uh = !1) : (Hh.classList.remove(`${Q}-cursor-visible`), setTimeout(() => {
11603
+ Uh = !1;
11565
11604
  }, 250)));
11566
11605
  }
11567
- async function Uh(e) {
11568
- Rh && (Rh.classList.add(`${Q}-cursor-click`), await Gh(280), Rh.classList.remove(`${Q}-cursor-click`));
11606
+ async function qh(e) {
11607
+ Hh && (Hh.classList.add(`${Q}-cursor-click`), await Yh(280), Hh.classList.remove(`${Q}-cursor-click`));
11569
11608
  }
11570
- function Wh(e) {
11609
+ function Jh(e) {
11571
11610
  if (!e || typeof document > "u") return;
11572
- Eh();
11611
+ Ah();
11573
11612
  let t;
11574
11613
  try {
11575
11614
  t = e.getBoundingClientRect();
@@ -11595,29 +11634,29 @@ function Wh(e) {
11595
11634
  a.remove(), e.style.position = n, e.style.overflow = r;
11596
11635
  }, 650);
11597
11636
  }
11598
- function Gh(e) {
11637
+ function Yh(e) {
11599
11638
  return new Promise((t) => setTimeout(t, e));
11600
11639
  }
11601
11640
  //#endregion
11602
11641
  //#region src/utils/voiceClientTools.js
11603
- var Kh = /^\/[a-z]{2}(?:-[a-z]{2})?(?=\/|$)/i;
11604
- function qh(e) {
11605
- return String(e || "").replace(Kh, "").replace(/\/+$/, "").toLowerCase() || "/";
11642
+ var Xh = /^\/[a-z]{2}(?:-[a-z]{2})?(?=\/|$)/i;
11643
+ function Zh(e) {
11644
+ return String(e || "").replace(Xh, "").replace(/\/+$/, "").toLowerCase() || "/";
11606
11645
  }
11607
- function Jh(e, t) {
11608
- return qh(e) === qh(t);
11646
+ function Qh(e, t) {
11647
+ return Zh(e) === Zh(t);
11609
11648
  }
11610
11649
  function $(...e) {
11611
11650
  wn() && console.log("[FlowEngage:voice-tools]", ...e);
11612
11651
  }
11613
- function Yh(e) {
11652
+ function $h(e) {
11614
11653
  try {
11615
11654
  let t = e.ownerDocument?.defaultView;
11616
11655
  if (t) return t.getComputedStyle(e);
11617
11656
  } catch {}
11618
11657
  return window.getComputedStyle(e);
11619
11658
  }
11620
- function Xh(e) {
11659
+ function eg(e) {
11621
11660
  let t = /* @__PURE__ */ new Set();
11622
11661
  function n(r) {
11623
11662
  if (!r || t.has(r)) return;
@@ -11630,10 +11669,10 @@ function Xh(e) {
11630
11669
  }
11631
11670
  typeof document < "u" && n(document);
11632
11671
  }
11633
- function Zh(e) {
11672
+ function tg(e) {
11634
11673
  return e == null ? null : String(e).replace(/\u00a0/g, " ").replace(/\s*\*+\s*$/u, "").replace(/\s+/g, " ").trim();
11635
11674
  }
11636
- function Qh(e) {
11675
+ function ng(e) {
11637
11676
  let t = e.ownerDocument || document, n = e.getAttribute("aria-labelledby");
11638
11677
  if (n) {
11639
11678
  let e = n.trim().split(/\s+/).filter(Boolean), r = [];
@@ -11641,40 +11680,40 @@ function Qh(e) {
11641
11680
  let e = t.getElementById(n);
11642
11681
  e?.textContent && r.push(e.textContent.trim());
11643
11682
  } catch {}
11644
- if (r.length) return Zh(r.join(" "));
11683
+ if (r.length) return tg(r.join(" "));
11645
11684
  }
11646
- if (e.labels && e.labels.length) return Zh(e.labels[0].textContent);
11685
+ if (e.labels && e.labels.length) return tg(e.labels[0].textContent);
11647
11686
  let r = e.id;
11648
11687
  if (r) try {
11649
11688
  let e = t.querySelector(`label[for="${CSS.escape(r)}"]`);
11650
- if (e) return Zh(e.textContent);
11689
+ if (e) return tg(e.textContent);
11651
11690
  } catch {
11652
11691
  let e = t.querySelector(`label[for="${r.replace(/"/g, "\\\"")}"]`);
11653
- if (e) return Zh(e.textContent);
11692
+ if (e) return tg(e.textContent);
11654
11693
  }
11655
11694
  let i = e.previousElementSibling;
11656
11695
  for (let e = 0; e < 6 && i; e += 1) {
11657
- if (i.tagName === "LABEL") return Zh(i.textContent);
11696
+ if (i.tagName === "LABEL") return tg(i.textContent);
11658
11697
  let e = (i.className || "").toString().toLowerCase();
11659
11698
  if (/chakra-form__label|formlabel|field-label|form-label|mui-form-label/.test(e)) {
11660
- let e = Zh(i.textContent);
11699
+ let e = tg(i.textContent);
11661
11700
  if (e) return e;
11662
11701
  }
11663
11702
  i = i.previousElementSibling;
11664
11703
  }
11665
11704
  let a = e.parentElement;
11666
11705
  for (let e = 0; e < 5 && a; e += 1) {
11667
- if (a.tagName === "LABEL") return Zh(a.textContent);
11706
+ if (a.tagName === "LABEL") return tg(a.textContent);
11668
11707
  let e = a.querySelector?.(":scope > label, :scope > [class*='FormLabel'], :scope > [class*='form__label']");
11669
- if (e?.textContent) return Zh(e.textContent);
11708
+ if (e?.textContent) return tg(e.textContent);
11670
11709
  a = a.parentElement;
11671
11710
  }
11672
11711
  let o = e.getAttribute("aria-label");
11673
- return o ? Zh(o) : null;
11712
+ return o ? tg(o) : null;
11674
11713
  }
11675
- function $h() {
11714
+ function rg() {
11676
11715
  let e = [];
11677
- return Xh((t) => {
11716
+ return eg((t) => {
11678
11717
  e.push(...Array.from(t.querySelectorAll("input, select, textarea")).filter((e) => {
11679
11718
  if (An(e)) return !1;
11680
11719
  let t = (e.type || "").toLowerCase();
@@ -11685,15 +11724,15 @@ function $h() {
11685
11724
  "image"
11686
11725
  ].includes(t) || e.disabled || e.readOnly) return !1;
11687
11726
  try {
11688
- let t = Yh(e);
11727
+ let t = $h(e);
11689
11728
  if (t.display === "none" || t.visibility === "hidden") return !1;
11690
11729
  } catch {}
11691
11730
  return !0;
11692
11731
  }));
11693
11732
  }), e;
11694
11733
  }
11695
- function eg() {
11696
- return $h().map((e, t) => {
11734
+ function ig() {
11735
+ return rg().map((e, t) => {
11697
11736
  let n = {
11698
11737
  formIndex: 0,
11699
11738
  fieldIndex: t,
@@ -11701,7 +11740,7 @@ function eg() {
11701
11740
  type: e.type || "text",
11702
11741
  name: e.name || null,
11703
11742
  id: e.id || null,
11704
- label: Qh(e),
11743
+ label: ng(e),
11705
11744
  placeholder: e.placeholder || null
11706
11745
  };
11707
11746
  return e.tagName === "SELECT" && (n.options = Array.from(e.options).filter((e) => e.value !== "" && !e.disabled).map((e) => ({
@@ -11710,13 +11749,13 @@ function eg() {
11710
11749
  })), n.currentValue = e.value || null), n;
11711
11750
  });
11712
11751
  }
11713
- function tg() {
11752
+ function ag() {
11714
11753
  let e = [];
11715
- return Xh((t) => {
11754
+ return eg((t) => {
11716
11755
  e.push(...Array.from(t.querySelectorAll("button, [role=\"button\"], input[type=\"submit\"], input[type=\"button\"]")).filter((e) => {
11717
11756
  if (An(e) || e.disabled) return !1;
11718
11757
  try {
11719
- let t = Yh(e);
11758
+ let t = $h(e);
11720
11759
  if (t.display === "none" || t.visibility === "hidden") return !1;
11721
11760
  } catch {}
11722
11761
  return !0;
@@ -11728,7 +11767,7 @@ function tg() {
11728
11767
  type: e.type || e.tagName
11729
11768
  }));
11730
11769
  }
11731
- function ng(e, t) {
11770
+ function og(e, t) {
11732
11771
  try {
11733
11772
  if (!e?.getBoundingClientRect || !t?.getBoundingClientRect) return Infinity;
11734
11773
  let n = e.getBoundingClientRect(), r = t.getBoundingClientRect(), i = {
@@ -11743,7 +11782,7 @@ function ng(e, t) {
11743
11782
  return Infinity;
11744
11783
  }
11745
11784
  }
11746
- function rg(e, t) {
11785
+ function sg(e, t) {
11747
11786
  let n = String(t || "").toLowerCase().trim();
11748
11787
  if (!n) return 0;
11749
11788
  let r = (e.innerText || e.textContent || "").replace(/\s+/g, " ").trim(), i = [
@@ -11761,21 +11800,21 @@ function rg(e, t) {
11761
11800
  for (let e of a) i.includes(e) && (o += 1);
11762
11801
  return o / a.length * 92;
11763
11802
  }
11764
- function ig(e, t, n = 6) {
11803
+ function cg(e, t, n = 6) {
11765
11804
  let r = String(t || "").toLowerCase().trim();
11766
11805
  if (!r) return !1;
11767
11806
  let i = e;
11768
11807
  for (let e = 0; e < n && i && (i = i.parentElement, i); e++) if ((i.innerText || i.textContent || "").toLowerCase().includes(r)) return !0;
11769
11808
  return !1;
11770
11809
  }
11771
- function ag(e, t, n) {
11810
+ function lg(e, t, n) {
11772
11811
  let r = [];
11773
- Xh((e) => {
11812
+ eg((e) => {
11774
11813
  let t = Array.from(e.querySelectorAll("button, [role=\"button\"], input[type=\"submit\"], input[type=\"button\"], a[href]"));
11775
11814
  r.push(...t.filter((e) => {
11776
11815
  if (An(e) || e.disabled) return !1;
11777
11816
  try {
11778
- let t = Yh(e);
11817
+ let t = $h(e);
11779
11818
  if (t.display === "none" || t.visibility === "hidden" || t.opacity === "0") return !1;
11780
11819
  } catch {}
11781
11820
  return !0;
@@ -11783,14 +11822,14 @@ function ag(e, t, n) {
11783
11822
  });
11784
11823
  let i = 0, a = r.map((t) => ({
11785
11824
  el: t,
11786
- s: rg(t, e)
11825
+ s: sg(t, e)
11787
11826
  }));
11788
11827
  for (let { s: e } of a) e > i && (i = e);
11789
11828
  if (i < 28) return null;
11790
11829
  let o = a.filter(({ s: e }) => e === i).map(({ el: e }) => e);
11791
11830
  if (o.length === 1) return o[0];
11792
11831
  if (n) {
11793
- let e = o.filter((e) => ig(e, n));
11832
+ let e = o.filter((e) => cg(e, n));
11794
11833
  if (e.length === 1) return e[0];
11795
11834
  e.length > 1 && (o = e);
11796
11835
  }
@@ -11798,14 +11837,14 @@ function ag(e, t, n) {
11798
11837
  if (s.length) {
11799
11838
  let e = o[0], t = Infinity;
11800
11839
  for (let n of o) for (let r of s) {
11801
- let i = ng(n, r);
11840
+ let i = og(n, r);
11802
11841
  i < t && (t = i, e = n);
11803
11842
  }
11804
11843
  return e;
11805
11844
  }
11806
11845
  return o[0];
11807
11846
  }
11808
- function og(e) {
11847
+ function ug(e) {
11809
11848
  if (e == null) return {};
11810
11849
  if (typeof e == "string") {
11811
11850
  let t = e.trim();
@@ -11818,12 +11857,12 @@ function og(e) {
11818
11857
  }
11819
11858
  return e;
11820
11859
  }
11821
- function sg(e) {
11860
+ function dg(e) {
11822
11861
  if (!e || typeof e != "object") return null;
11823
11862
  let t = e.url ?? e.target_url ?? e.page_url ?? e.pageUrl ?? e.link ?? e.href ?? e.path;
11824
11863
  return t == null ? null : String(t).trim() || null;
11825
11864
  }
11826
- function cg() {
11865
+ function fg() {
11827
11866
  let e = {};
11828
11867
  document.querySelectorAll("h1, h2, h3, h4, h5, h6").forEach((t) => {
11829
11868
  if (t.id) return;
@@ -11838,7 +11877,7 @@ function cg() {
11838
11877
  e[r] = !0, t.id = r;
11839
11878
  });
11840
11879
  }
11841
- function lg() {
11880
+ function pg() {
11842
11881
  let e = (e) => {
11843
11882
  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;
11844
11883
  for (; r < t.length;) {
@@ -11881,7 +11920,7 @@ function lg() {
11881
11920
  introText: o
11882
11921
  };
11883
11922
  }
11884
- function ug(e) {
11923
+ function mg(e) {
11885
11924
  if (!e || typeof document > "u") return "";
11886
11925
  let t = new Set([
11887
11926
  "script",
@@ -11967,11 +12006,11 @@ function ug(e) {
11967
12006
  return d.has(t) ? !1 : (d.add(t), !0);
11968
12007
  }).join("\n").replace(/\n{3,}/g, "\n\n").trim();
11969
12008
  }
11970
- function dg(e) {
12009
+ function hg(e) {
11971
12010
  let t = e.siteId || null, n = (e.apiBaseUrl || "").replace(/\/$/, ""), r = typeof e.getLastUserVoiceText == "function" ? e.getLastUserVoiceText : null, i = [], a = {
11972
12011
  "fwh-navigate-mvp": async (n) => {
11973
12012
  $("fwh-navigate-mvp ▶ raw parameters:", n);
11974
- let i = og(n), a = sg(i), o = i.section_text ?? i.sectionText ?? i.section, s = Array.isArray(i.expected_landmarks) ? i.expected_landmarks : Array.isArray(i.expectedLandmarks) ? i.expectedLandmarks : [];
12013
+ let i = ug(n), a = dg(i), o = i.section_text ?? i.sectionText ?? i.section, s = Array.isArray(i.expected_landmarks) ? i.expected_landmarks : Array.isArray(i.expectedLandmarks) ? i.expectedLandmarks : [];
11975
12014
  if ($("fwh-navigate-mvp · coerced:", {
11976
12015
  url: a,
11977
12016
  sectionText: o,
@@ -12010,11 +12049,11 @@ function dg(e) {
12010
12049
  correctedUrl: l
12011
12050
  }), a = l);
12012
12051
  try {
12013
- Ah(`Navigating to ${a}...`, { spinner: !0 }), Fh(), On();
12052
+ Ph(`Navigating to ${a}...`, { spinner: !0 }), zh(), On();
12014
12053
  try {
12015
12054
  let e = r ? r() : "";
12016
12055
  if (e && t) {
12017
- let n = Th([{
12056
+ let n = kh([{
12018
12057
  sender: "user",
12019
12058
  message: e
12020
12059
  }]);
@@ -12042,8 +12081,8 @@ function dg(e) {
12042
12081
  typeof window < "u" && window.scrollTo(0, 0);
12043
12082
  } catch {}
12044
12083
  let o = [], s = null, c = "", l = Date.now() + 12e3;
12045
- for (; Date.now() < l && (await new Promise((e) => setTimeout(e, 300)), {headings: o, pageTitleHeading: s, introText: c} = lg(), !(o.length >= 1)););
12046
- cg(), $("fwh-navigate-mvp → page headings collected:", o, "titleHeading:", s);
12084
+ for (; Date.now() < l && (await new Promise((e) => setTimeout(e, 300)), {headings: o, pageTitleHeading: s, introText: c} = pg(), !(o.length >= 1)););
12085
+ fg(), $("fwh-navigate-mvp → page headings collected:", o, "titleHeading:", s);
12047
12086
  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 = "";
12048
12087
  try {
12049
12088
  if (o.length > 0) {
@@ -12051,7 +12090,7 @@ function dg(e) {
12051
12090
  for (let n of e) {
12052
12091
  let e = cr(null, n);
12053
12092
  if (e) {
12054
- let r = ug(e).substring(0, 800);
12093
+ let r = mg(e).substring(0, 800);
12055
12094
  r && t.push(`[Section: ${n}] ${r}`);
12056
12095
  }
12057
12096
  }
@@ -12060,13 +12099,13 @@ function dg(e) {
12060
12099
  } catch {}
12061
12100
  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.`;
12062
12101
  let m = Date.now() + 4e3, h = typeof window < "u" ? window.location.pathname : r;
12063
- for (; Date.now() < m && !Jh(h, e) && Jh(h, t);) await new Promise((e) => setTimeout(e, 120)), h = window.location.pathname;
12102
+ for (; Date.now() < m && !Qh(h, e) && Qh(h, t);) await new Promise((e) => setTimeout(e, 120)), h = window.location.pathname;
12064
12103
  $("fwh-navigate-mvp route settle:", {
12065
12104
  startPath: t,
12066
12105
  targetPath: e,
12067
12106
  settledPath: h
12068
12107
  });
12069
- 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 = Jh(h, e), y = !Jh(h, t), b = v || y;
12108
+ 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 = Qh(h, e), y = !Qh(h, t), b = v || y;
12070
12109
  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.`);
12071
12110
  } catch {}
12072
12111
  let o = "this";
@@ -12077,45 +12116,45 @@ function dg(e) {
12077
12116
  return `OK_NAVIGATE_RELOADING. Navigating to the page now; the voice session will resume automatically on the new page. When the session resumes, say EXACTLY: "I have navigated you on ${o} page. Do you want to know about any specific section or want a complete overview?" Then STOP — wait for the visitor's reply.`;
12078
12117
  } catch (e) {
12079
12118
  let t = `Navigation error: ${e?.message || String(e)}`;
12080
- return $("fwh-navigate-mvp ✖", t), Ah("Navigation failed", {
12119
+ return $("fwh-navigate-mvp ✖", t), Ph("Navigation failed", {
12081
12120
  spinner: !1,
12082
12121
  icon: "⚠️",
12083
12122
  duration: 1800
12084
12123
  }), t;
12085
12124
  } finally {
12086
- Ih(), jh(900);
12125
+ Bh(), Fh(900);
12087
12126
  }
12088
12127
  },
12089
12128
  "fwh-highlight-mvp": async (e) => {
12090
12129
  $("fwh-highlight-mvp ▶", e);
12091
- let t = og(e), n = t?.section_id || t?.sectionId, r = t?.section_text || t?.sectionText;
12130
+ let t = ug(e), n = t?.section_id || t?.sectionId, r = t?.section_text || t?.sectionText;
12092
12131
  if (typeof window < "u" && window.__fe_user_nav_during_speech) {
12093
12132
  let e = window.__fe_user_nav_during_speech, t = window.location.pathname;
12094
12133
  if (Date.now() - e.ts >= 3e4) window.__fe_user_nav_during_speech = null;
12095
12134
  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 flowengage_highlight 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.`;
12096
12135
  }
12097
- cg();
12136
+ fg();
12098
12137
  let i = ((e) => e && e.replace(/^\d+\.\s*/, "").replace(/^["']|["']$/g, "").trim())(r), a = cr(n || null, i || null);
12099
12138
  if (!a && i) {
12100
12139
  let e = Date.now() + 600;
12101
- for (; !a && Date.now() < e;) await new Promise((e) => setTimeout(e, 50)), cg(), a = cr(null, i);
12140
+ for (; !a && Date.now() < e;) await new Promise((e) => setTimeout(e, 50)), fg(), a = cr(null, i);
12102
12141
  }
12103
12142
  if (!a) {
12104
12143
  $("fwh-highlight-mvp ✖ no element for:", i || n);
12105
- let { headings: e } = lg(), 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.";
12144
+ let { headings: e } = pg(), 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.";
12106
12145
  return `HIGHLIGHT_NOT_FOUND: "${i || n}" on the current page. ${t}`;
12107
12146
  }
12108
12147
  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, then end with the continue question.`;
12109
12148
  },
12110
12149
  "fwh-read-content-mvp": async (e) => {
12111
12150
  $("fwh-read-content-mvp ▶", e);
12112
- let t = og(e), n = t?.section_text || t?.sectionText || "";
12151
+ let t = ug(e), n = t?.section_text || t?.sectionText || "";
12113
12152
  try {
12114
12153
  let e = "";
12115
12154
  if (n) {
12116
12155
  let t = cr(null, n);
12117
12156
  if (!t) return `Could not find section "${n}" on the page.`;
12118
- e = ug(t);
12157
+ e = mg(t);
12119
12158
  } else {
12120
12159
  let t = (document.querySelector("main") || document.querySelector("article") || document.querySelector("[role=\"main\"]") || document.querySelector("#content") || document.querySelector(".content") || document.body).cloneNode(!0);
12121
12160
  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();
@@ -12127,7 +12166,7 @@ function dg(e) {
12127
12166
  },
12128
12167
  "fwh-page-content-mvp": async (e) => {
12129
12168
  $("fwh-page-content-mvp ▶", e);
12130
- let r = og(e), i = r?.url || r?.page_url || "";
12169
+ let r = ug(e), i = r?.url || r?.page_url || "";
12131
12170
  if ($("fwh-page-content-mvp · url:", i, "siteId:", t, "apiBase:", n || "(empty)"), !i) return $("fwh-page-content-mvp ✖ missing url"), "Missing url parameter.";
12132
12171
  if (!t) return $("fwh-page-content-mvp ✖ no siteId"), "Site is not configured.";
12133
12172
  if (!n) return $("fwh-page-content-mvp ✖ no api base"), "API base URL is missing; cannot fetch page content.";
@@ -12159,7 +12198,7 @@ function dg(e) {
12159
12198
  },
12160
12199
  "fwh-search-mvp": async (e) => {
12161
12200
  $("fwh-search-mvp ▶", e);
12162
- let r = og(e).query;
12201
+ let r = ug(e).query;
12163
12202
  if (!r) return $("fwh-search-mvp ✖ missing query"), "Missing query parameter.";
12164
12203
  if (!t) return $("fwh-search-mvp ✖ no siteId"), "Search unavailable (no siteId configured).";
12165
12204
  if (!n) return $("fwh-search-mvp ✖ no api base"), "Search unavailable (no API base URL).";
@@ -12197,7 +12236,7 @@ function dg(e) {
12197
12236
  "[class*='menu'] a",
12198
12237
  "[class*='header'] a"
12199
12238
  ];
12200
- if (Xh((t) => {
12239
+ if (eg((t) => {
12201
12240
  for (let r of n) try {
12202
12241
  t.querySelectorAll(r).forEach((t) => {
12203
12242
  if (An(t)) return;
@@ -12205,7 +12244,7 @@ function dg(e) {
12205
12244
  if (!r || !n || n === "#" || n.startsWith("javascript:")) return;
12206
12245
  try {
12207
12246
  let e = t.parentElement;
12208
- if (e && Yh(e).display === "none" && !e.closest("nav, [role='navigation'], header, [class*='nav'], [class*='menu']")) return;
12247
+ if (e && $h(e).display === "none" && !e.closest("nav, [role='navigation'], header, [class*='nav'], [class*='menu']")) return;
12209
12248
  } catch {}
12210
12249
  let i = r.toLowerCase() + "|" + n;
12211
12250
  e.has(i) || e.set(i, {
@@ -12216,7 +12255,7 @@ function dg(e) {
12216
12255
  } catch {}
12217
12256
  t.querySelectorAll("select").forEach((t) => {
12218
12257
  if (An(t)) return;
12219
- let n = Qh(t);
12258
+ let n = ng(t);
12220
12259
  /nav|menu|page|section|go to/i.test(n || t.name || t.id || "") && Array.from(t.options).forEach((r) => {
12221
12260
  if (!r.value || r.disabled) return;
12222
12261
  let i = r.text.trim();
@@ -12238,7 +12277,7 @@ function dg(e) {
12238
12277
  "fwh-request-email-mvp": async () => ($("fwh-request-email-mvp ▶"), typeof e.requestEmailCollection == "function" && e.requestEmailCollection(), "EMAIL_BOX_SHOWN. An email input text box is now visible to the visitor. Say EXACTLY: \"Please enter your email in the text box to continue.\" Then stop and wait silently — do NOT ask them to say it aloud, do NOT repeat, and do NOT answer any other question until you receive the EMAIL_SAVED message."),
12239
12278
  "fwh-get-current-page-mvp": async () => {
12240
12279
  if ($("fwh-get-current-page-mvp ▶"), typeof window > "u") return "Cannot determine current page (no browser context).";
12241
- let e = window.location.href, t = window.location.pathname, n = document.title || "", { headings: r, pageTitleHeading: i, introText: a } = lg();
12280
+ let e = window.location.href, t = window.location.pathname, n = document.title || "", { headings: r, pageTitleHeading: i, introText: a } = pg();
12242
12281
  $("fwh-get-current-page-mvp ✓", {
12243
12282
  url: e,
12244
12283
  path: t,
@@ -12250,7 +12289,7 @@ function dg(e) {
12250
12289
  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. ***`;
12251
12290
  },
12252
12291
  "fwh-list-forms-mvp": async () => {
12253
- let e = eg(), t = tg();
12292
+ let e = ig(), t = ag();
12254
12293
  $("fwh-list-forms-mvp ✓", `${e.length} field(s)`, `${t.length} button(s)`);
12255
12294
  let n = e.map((e) => ({
12256
12295
  ...e,
@@ -12264,12 +12303,12 @@ function dg(e) {
12264
12303
  },
12265
12304
  "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.",
12266
12305
  "fwh-click-button-mvp": async (e) => {
12267
- let t = og(e), n = (t.button_text ?? t.buttonText ?? t.text ?? "").trim(), r = (t.card_context ?? t.cardContext ?? "").trim();
12306
+ let t = ug(e), n = (t.button_text ?? t.buttonText ?? t.text ?? "").trim(), r = (t.card_context ?? t.cardContext ?? "").trim();
12268
12307
  if ($("fwh-click-button-mvp ▶", n, r ? `(card_context: ${r})` : ""), !n) return "Missing button_text: pass the visible label, e.g. Conduct Audit.";
12269
- let a = ag(n, i, r);
12308
+ let a = lg(n, i, r);
12270
12309
  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.`;
12271
12310
  try {
12272
- Ah(`Clicking ${n}...`, { spinner: !0 });
12311
+ Ph(`Clicking ${n}...`, { spinner: !0 });
12273
12312
  try {
12274
12313
  a.scrollIntoView({
12275
12314
  block: "center",
@@ -12278,22 +12317,22 @@ function dg(e) {
12278
12317
  } catch {
12279
12318
  a.scrollIntoView(!0);
12280
12319
  }
12281
- await Vh(a), a.focus?.(), await Uh(a), Wh(a), a.click();
12320
+ await Gh(a), a.focus?.(), await qh(a), Jh(a), a.click();
12282
12321
  let e = (a.textContent || a.value || a.getAttribute("aria-label") || "").trim().slice(0, 80) || "button", t = `OK_CLICK ${e}`;
12283
- return $("fwh-click-button-mvp ✓", t), Ah(`Clicked ${e}`, {
12322
+ return $("fwh-click-button-mvp ✓", t), Ph(`Clicked ${e}`, {
12284
12323
  spinner: !1,
12285
12324
  icon: "✅",
12286
12325
  duration: 1200
12287
12326
  }), t;
12288
12327
  } catch (e) {
12289
12328
  let t = `Click failed: ${e?.message || String(e)}`;
12290
- return $("fwh-click-button-mvp ✖", t), Ah("Click failed", {
12329
+ return $("fwh-click-button-mvp ✖", t), Ph("Click failed", {
12291
12330
  spinner: !1,
12292
12331
  icon: "⚠️",
12293
12332
  duration: 1800
12294
12333
  }), t;
12295
12334
  } finally {
12296
- Hh(), jh(700);
12335
+ Kh(), Fh(700);
12297
12336
  }
12298
12337
  }
12299
12338
  };
@@ -12307,18 +12346,18 @@ function dg(e) {
12307
12346
  clickPageButton: a["fwh-click-button-mvp"]
12308
12347
  };
12309
12348
  }
12310
- var fg = /^(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;
12311
- function pg() {
12349
+ var gg = /^(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;
12350
+ function _g() {
12312
12351
  try {
12313
- let { headings: e } = lg();
12314
- return (e || []).map((e) => typeof e == "string" ? e : e?.text || "").filter(Boolean).filter((e) => !fg.test(e.trim()));
12352
+ let { headings: e } = pg();
12353
+ return (e || []).map((e) => typeof e == "string" ? e : e?.text || "").filter(Boolean).filter((e) => !gg.test(e.trim()));
12315
12354
  } catch {
12316
12355
  return [];
12317
12356
  }
12318
12357
  }
12319
12358
  //#endregion
12320
12359
  //#region src/utils/wrapVoiceToolsForLogging.js
12321
- function mg(e) {
12360
+ function vg(e) {
12322
12361
  return !e || typeof e != "object" ? e : Object.fromEntries(Object.entries(e).map(([e, t]) => [e, async (n) => {
12323
12362
  let r = wn();
12324
12363
  r ? console.log("[FlowEngage:voice-tool] ▶", e, n) : console.info(`[FlowEngage] voice tool » ${e}`);
@@ -12335,7 +12374,7 @@ function mg(e) {
12335
12374
  }
12336
12375
  //#endregion
12337
12376
  //#region src/components/FlowEngageWidget.jsx
12338
- var hg = {
12377
+ var yg = {
12339
12378
  blue: "#135bd8",
12340
12379
  red: "#ef334b",
12341
12380
  yellow: "#ffbd2e",
@@ -12343,7 +12382,7 @@ var hg = {
12343
12382
  highlight: "rgba(255,255,255,0.9)",
12344
12383
  green: "#10b981"
12345
12384
  };
12346
- function gg(e) {
12385
+ function bg(e) {
12347
12386
  if (!Array.isArray(e) || e.length < 2) return "linear-gradient(145deg, #dce8f022 0%, #e8dff522 45%, #f5e0e022 100%), #f7f8fa";
12348
12387
  let [t, n, r] = e;
12349
12388
  return e.length >= 3 && r ? [
@@ -12357,12 +12396,12 @@ function gg(e) {
12357
12396
  "#f7f8fa"
12358
12397
  ].join(", ");
12359
12398
  }
12360
- function _g(e) {
12399
+ function xg(e) {
12361
12400
  if (!e || typeof e != "string") return "#1a1a1a";
12362
12401
  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;
12363
12402
  return .2126 * o(r) + .7152 * o(i) + .0722 * o(a) > .179 ? "#1a1a1a" : "#ffffff";
12364
12403
  }
12365
- function vg(t) {
12404
+ function Sg(t) {
12366
12405
  let [n, r] = e.useState(null), i = typeof t == "string" ? t.trim() : "";
12367
12406
  return e.useEffect(() => {
12368
12407
  if (!i) {
@@ -12380,8 +12419,8 @@ function vg(t) {
12380
12419
  };
12381
12420
  }, [i]), n;
12382
12421
  }
12383
- function yg({ logo: t, style: n }) {
12384
- let r = vg(typeof t == "string" ? t : null);
12422
+ function Cg({ logo: t, style: n }) {
12423
+ let r = Sg(typeof t == "string" ? t : null);
12385
12424
  if (!t) return null;
12386
12425
  if (typeof t == "string") return r ? /* @__PURE__ */ g("img", {
12387
12426
  src: r,
@@ -12406,7 +12445,7 @@ function yg({ logo: t, style: n }) {
12406
12445
  children: i
12407
12446
  }) : null;
12408
12447
  }
12409
- function bg({ title: e }) {
12448
+ function wg({ title: e }) {
12410
12449
  return /* @__PURE__ */ g("div", {
12411
12450
  style: {
12412
12451
  width: "100%",
@@ -12424,18 +12463,18 @@ function bg({ title: e }) {
12424
12463
  children: String(e || "FE").split(/\s+/).filter(Boolean).slice(0, 2).map((e) => e[0]?.toUpperCase() || "").join("") || "FE"
12425
12464
  });
12426
12465
  }
12427
- function xg(e, t) {
12466
+ function Tg(e, t) {
12428
12467
  let n = (t || "").trim();
12429
12468
  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;
12430
12469
  }
12431
- function Sg({ orbColors: e, ...t }) {
12432
- return /* @__PURE__ */ g(gh, {
12470
+ function Eg({ orbColors: e, ...t }) {
12471
+ return /* @__PURE__ */ g(bh, {
12433
12472
  colors: e,
12434
12473
  ...t
12435
12474
  });
12436
12475
  }
12437
- function Cg({ copy: e, orbColors: t, primaryColor: n, onYes: r, onLater: i, isMobile: a, isClosing: o }) {
12438
- let s = n || hg.green, c = _g(s), l = a ? 72 : 94, u = /* @__PURE__ */ _("div", {
12476
+ function Dg({ copy: e, orbColors: t, primaryColor: n, onYes: r, onLater: i, isMobile: a, isClosing: o }) {
12477
+ let s = n || yg.green, c = xg(s), l = a ? 72 : 94, u = /* @__PURE__ */ _("div", {
12439
12478
  style: {
12440
12479
  display: "flex",
12441
12480
  alignItems: a ? "flex-end" : "center",
@@ -12561,7 +12600,7 @@ function Cg({ copy: e, orbColors: t, primaryColor: n, onYes: r, onLater: i, isMo
12561
12600
  delay: 0
12562
12601
  },
12563
12602
  style: { flexShrink: 0 },
12564
- children: /* @__PURE__ */ g(Sg, {
12603
+ children: /* @__PURE__ */ g(Eg, {
12565
12604
  size: l,
12566
12605
  orbColors: t
12567
12606
  })
@@ -12593,8 +12632,8 @@ function Cg({ copy: e, orbColors: t, primaryColor: n, onYes: r, onLater: i, isMo
12593
12632
  children: u
12594
12633
  })] });
12595
12634
  }
12596
- function wg({ copy: e, orbColors: t, primaryColor: n, onVoice: r, onText: i, onClose: a, isMobile: o, isClosing: s }) {
12597
- let c = n || hg.green, l = _g(c);
12635
+ function Og({ copy: e, orbColors: t, primaryColor: n, onVoice: r, onText: i, onClose: a, isMobile: o, isClosing: s }) {
12636
+ let c = n || yg.green, l = xg(c);
12598
12637
  return /* @__PURE__ */ _(ym.div, {
12599
12638
  initial: {
12600
12639
  scale: 50 / 350,
@@ -12665,7 +12704,7 @@ function wg({ copy: e, orbColors: t, primaryColor: n, onVoice: r, onText: i, onC
12665
12704
  children: /* @__PURE__ */ g("polyline", { points: "6 9 12 15 18 9" })
12666
12705
  })
12667
12706
  }),
12668
- /* @__PURE__ */ g(Sg, {
12707
+ /* @__PURE__ */ g(Eg, {
12669
12708
  size: 72,
12670
12709
  orbColors: t
12671
12710
  }),
@@ -12745,60 +12784,62 @@ function wg({ copy: e, orbColors: t, primaryColor: n, onVoice: r, onText: i, onC
12745
12784
  ]
12746
12785
  });
12747
12786
  }
12748
- function Tg({ 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...", enterChatModeLabel: S = "Enter Chat Mode", endConversationLabel: C = "End Conversation" }) {
12787
+ function kg({ 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...", enterChatModeLabel: S = "Enter Chat Mode", endConversationLabel: C = "End Conversation" }) {
12749
12788
  c(() => (console.log("[FlowEngage:VoiceDebug] 🔵 VoiceMode MOUNTED"), () => console.log("[FlowEngage:VoiceDebug] 🔴 VoiceMode UNMOUNTED")), []);
12750
- let [w, T] = m("idle"), [E, D] = m(!1), [O, k] = m(!1), [A, ee] = m(!1), [te, ne] = m(""), [j, re] = m(""), ie = p(!1), ae = p(!1), oe = p(null), se = p(0), ce = p(""), le = p(!1), ue = p(0), de = p(!1), fe = p(!1), pe = p([]), me = p(null);
12751
- me.current = async () => {
12752
- let e = pe.current;
12789
+ let [w, T] = m("idle"), [E, D] = m(!1), [O, k] = m(!1), [A, ee] = m(!1), [te, ne] = m(""), [j, M] = m(""), re = p(!1), ie = p(!1), ae = p(null), oe = p(0), se = p(""), ce = p(!1), le = p(0), ue = p(!1), de = p(!1), fe = p([]), pe = p(null), me = (e) => {
12790
+ ue.current = e, N.current?.setWalkthroughActive?.(e);
12791
+ };
12792
+ pe.current = async () => {
12793
+ let e = fe.current;
12753
12794
  he.current += 1;
12754
12795
  let t = he.current, n = e[t];
12755
12796
  if (!n) {
12756
- de.current = !1, e.length && M.current?.sendUserMessage?.("That was the last section. Say so in one short sentence and ask if they want to explore any section further.");
12797
+ me(!1), e.length && N.current?.sendUserMessage?.("That was the last section. Say so in one short sentence and ask if they want to explore any section further.");
12757
12798
  return;
12758
12799
  }
12759
12800
  try {
12760
12801
  await toolsRef.current?.highlightOnPage?.({ section_text: n });
12761
12802
  } catch {}
12762
- console.debug(`[FlowEngage] walkthrough step ${t + 1}/${e.length}: ${n}`), M.current?.sendUserMessage?.(`Describe the section titled "${n}" in 3-4 sentences, starting with ${t === 0 ? "Starting with" : "Next —"} ${n}. Describe ONLY this section. Do not mention any other section, do not ask whether to continue, then stop.`);
12803
+ console.debug(`[FlowEngage] walkthrough step ${t + 1}/${e.length}: ${n}`), N.current?.sendUserMessage?.(`Describe the section titled "${n}" in 3-4 sentences, starting with ${t === 0 ? "Starting with" : "Next —"} ${n}. Describe ONLY this section. Do not mention any other section, do not ask whether to continue, then stop.`, { suppressQuestion: !0 });
12763
12804
  };
12764
- let he = p(0), M = p(null), ge = p(""), _e = p(async () => {}), ve = p(!1), ye = p(!1), be = p(!1), xe = p(!1), Se = p("minimized"), N = p(null), Ce = p(null), F = p(null), De = p(0), Oe = p(!1), I = p("idle"), ke = p(!1), je = p(!1), Me = p(null), L = p(null), Pe = p(!1), Fe = o((e = "minimized") => {
12805
+ let he = p(0), N = p(null), ge = p(""), _e = p(async () => {}), ve = p(!1), ye = p(!1), be = p(!1), xe = p(!1), Se = p("minimized"), Ce = p(null), F = p(null), De = p(null), Oe = p(0), I = p(!1), ke = p("idle"), je = p(null), Me = p(!1), Pe = o((e = "minimized") => {
12765
12806
  console.warn("[FlowEngage:VoiceDebug] 🛑 requestSessionShutdown called", {
12766
12807
  destination: e,
12767
12808
  stack: (/* @__PURE__ */ Error()).stack?.split("\n").slice(1, 4).join(" | ")
12768
12809
  }), Se.current = e, xe.current = !0, queueMicrotask(() => {
12769
12810
  ve.current || (ve.current = !0, _e.current?.());
12770
12811
  });
12771
- }, [l]), Ie = o(() => {
12772
- oe.current &&= (clearTimeout(oe.current), null);
12812
+ }, [l]), L = o(() => {
12813
+ ae.current &&= (clearTimeout(ae.current), null);
12773
12814
  }, []);
12774
12815
  c(() => {
12775
12816
  if (y) {
12776
- ie.current = !1;
12817
+ re.current = !1;
12777
12818
  return;
12778
12819
  }
12779
- if (ie.current = !0, ae.current = !1, ee(!1), Ie(), le.current) {
12780
- le.current = !1, M.current?.setMicMuted?.(!1);
12781
- let e = ce.current;
12782
- ce.current = "", M.current?.injectAgentSpeech?.("Thanks — I already have your email on file.", "interrupt"), e && M.current?.sendUserMessage?.(`The visitor's email is already on file — do not ask for it. Answer their question now: "${e}"`);
12783
- }
12784
- M.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.");
12785
- }, [y, Ie]);
12786
- let Le = /(walk me through|complete overview|full overview|tell me about (each|all)|go through (it|them|each)|overview of|one by one|tell me everything)/i, R = /(that covers everything|that was all|covered everything|anything else)/i, Re = o(() => {
12787
- Ie(), oe.current = setTimeout(() => {
12788
- if (!(!ae.current || ie.current)) if (se.current < 3) {
12789
- se.current += 1;
12820
+ if (re.current = !0, ie.current = !1, ee(!1), L(), ce.current) {
12821
+ ce.current = !1, N.current?.setMicMuted?.(!1);
12822
+ let e = se.current;
12823
+ se.current = "", N.current?.injectAgentSpeech?.("Thanks — I already have your email on file.", "interrupt"), e && N.current?.sendUserMessage?.(`The visitor's email is already on file — do not ask for it. Answer their question now: "${e}"`);
12824
+ }
12825
+ N.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.");
12826
+ }, [y, L]);
12827
+ let Fe = /(walk\s*(me\s*)?through|walkthrough|take me through|complete overview|full overview|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|show me (each|all|around))/i, Ie = /(that covers everything|that was all|covered everything|anything else)/i, Le = o(() => {
12828
+ L(), ae.current = setTimeout(() => {
12829
+ if (!(!ie.current || re.current)) if (oe.current < 3) {
12830
+ oe.current += 1;
12790
12831
  try {
12791
- M.current?.injectAgentSpeech?.("I still need your email in the box below to continue — could you enter it, please?", "queue");
12832
+ N.current?.injectAgentSpeech?.("I still need your email in the box below to continue — could you enter it, please?", "queue");
12792
12833
  } catch {}
12793
- Re();
12834
+ Le();
12794
12835
  } else {
12795
12836
  try {
12796
- M.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");
12837
+ N.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");
12797
12838
  } catch {}
12798
- ae.current = !1, ee(!1), Ie(), Oe.current = !0;
12839
+ ie.current = !1, ee(!1), L(), I.current = !0;
12799
12840
  }
12800
12841
  }, 1e4);
12801
- }, [Ie]), ze = o(async (e) => {
12842
+ }, [L]), R = o(async (e) => {
12802
12843
  xe.current = !0;
12803
12844
  try {
12804
12845
  On();
@@ -12807,9 +12848,9 @@ function Tg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
12807
12848
  Ne(i);
12808
12849
  } catch {}
12809
12850
  try {
12810
- await M.current?.endSession?.();
12851
+ await N.current?.endSession?.();
12811
12852
  } catch {}
12812
- let t = N.current, n = Ce.current;
12853
+ let t = Ce.current, n = F.current;
12813
12854
  if (t && s && a) {
12814
12855
  let e = n ? Math.round((Date.now() - n) / 1e3) : 0;
12815
12856
  fetch(`${a}/api/voice/save-chat-recording`, {
@@ -12817,13 +12858,13 @@ function Tg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
12817
12858
  headers: { "Content-Type": "application/json" },
12818
12859
  body: JSON.stringify({
12819
12860
  chatId: s,
12820
- elevenLabsConversationId: t,
12861
+ voiceSessionId: t,
12821
12862
  duration: e,
12822
12863
  siteId: i
12823
12864
  })
12824
12865
  }).catch((e) => console.warn("[FlowEngage] save-chat-recording failed:", e.message));
12825
12866
  }
12826
- if (N.current = null, Ce.current = null, M.current = null, T("idle"), D(!1), ve.current = !1, wr(), i) try {
12867
+ if (Ce.current = null, F.current = null, N.current = null, T("idle"), D(!1), ve.current = !1, wr(), i) try {
12827
12868
  Te(i);
12828
12869
  } catch {}
12829
12870
  typeof u == "function" && await u(l.current), e?.();
@@ -12834,10 +12875,10 @@ function Tg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
12834
12875
  s,
12835
12876
  a
12836
12877
  ]);
12837
- _e.current = () => ze(Se.current === "chat" ? t : n), c(() => {
12878
+ _e.current = () => R(Se.current === "chat" ? t : n), c(() => {
12838
12879
  ye.current = E;
12839
12880
  }, [E]), c(() => {
12840
- d && Fe("chat");
12881
+ d && Pe("chat");
12841
12882
  }, [d]), c(() => {
12842
12883
  let e = !1, o = null, c = null, d = null;
12843
12884
  return (async () => {
@@ -12849,15 +12890,15 @@ function Tg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
12849
12890
  if ((await navigator.mediaDevices.getUserMedia({ audio: !0 })).getTracks().forEach((e) => e.stop()), e) return;
12850
12891
  l.current = [], ge.current = "", ve.current = !1, be.current = !1, xe.current = !1, Se.current = "minimized", Cr({ onBeforeNavigate: () => {
12851
12892
  if (i && l.current.length > 0) try {
12852
- let e = Th(l.current);
12893
+ let e = kh(l.current);
12853
12894
  e && P(i, e);
12854
12895
  } catch {}
12855
12896
  if (!qn()) {
12856
- let e = N.current, t = Ce.current;
12897
+ let e = Ce.current, t = F.current;
12857
12898
  if (e && s && a) try {
12858
12899
  let n = t ? Math.round((Date.now() - t) / 1e3) : 0, r = JSON.stringify({
12859
12900
  chatId: s,
12860
- elevenLabsConversationId: e,
12901
+ voiceSessionId: e,
12861
12902
  duration: n,
12862
12903
  siteId: i
12863
12904
  }), o = `${a}/api/voice/save-chat-recording`;
@@ -12866,21 +12907,21 @@ function Tg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
12866
12907
  headers: { "Content-Type": "application/json" },
12867
12908
  body: r,
12868
12909
  keepalive: !0
12869
- }).catch(() => {}), N.current = null, Ce.current = null;
12910
+ }).catch(() => {}), Ce.current = null, F.current = null;
12870
12911
  } catch {}
12871
12912
  }
12872
12913
  Ee();
12873
12914
  } });
12874
- let t = mg(dg({
12915
+ let t = vg(hg({
12875
12916
  siteId: i || null,
12876
12917
  apiBaseUrl: a || null,
12877
12918
  chatId: s || null,
12878
12919
  getLastUserVoiceText: () => ge.current,
12879
12920
  requestEndSession: () => {
12880
- Oe.current = !0;
12921
+ I.current = !0;
12881
12922
  },
12882
12923
  requestEmailCollection: () => {
12883
- b && (ie.current || ae.current || (ae.current = !0, se.current = 0, ee(!0), Re()));
12924
+ b && (re.current || ie.current || (ie.current = !0, oe.current = 0, ee(!0), Le()));
12884
12925
  }
12885
12926
  })), n = i ? we(i) : null, r = !!n?.transcript, u = i ? Ne(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 = {
12886
12927
  apiBaseUrl: a,
@@ -12906,89 +12947,88 @@ function Tg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
12906
12947
  let e = f || "";
12907
12948
  x.greeting = h || (v ? e ? `Hi, welcome to ${e}! How may I help you?` : "Hi, welcome! How may I help you?" : `Welcome to the ${w} page!`), v || console.log(`[FlowEngage] 🏠 Page-context greeting: "${w}" for ${m}`);
12908
12949
  }
12909
- let O = !1, k = p ? `NAVIGATION COMPLETE — The exact phrase "I have navigated you on [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, A = !1, te = !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, ne = r && !p, j = !1, re = ne ? `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, oe = !1, _e = !1, Te = b && !!y && !fe.current, F = await Om.startSession({
12950
+ let O = !1, k = p ? `NAVIGATION COMPLETE — The exact phrase "I have navigated you on [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, A = !1, te = !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, ne = r && !p, j = !1, M = ne ? `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, ae = !1, _e = !1, Te = b && !!y && !de.current, De = await Mm.startSession({
12910
12951
  ...x,
12911
12952
  onConnect: ({ conversationId: e }) => {
12912
- N.current = e, Ce.current = Date.now(), console.log("[FlowEngage] 🎙️ AI chat session connected:", e);
12953
+ Ce.current = e, F.current = Date.now(), console.log("[FlowEngage] 🎙️ AI chat session connected:", e);
12913
12954
  },
12914
12955
  onUnhandledClientToolCall: (e) => console.error("[FlowEngage] Unhandled tool:", e?.tool_name),
12915
12956
  onSessionInfo: ({ emailOnFile: e }) => {
12916
- fe.current = !!e, e && (ie.current = !0, ae.current = !1, ee(!1), Ie(), console.log("[FlowEngage] email already on file per server — gate disabled"));
12957
+ de.current = !!e, e && (re.current = !0, ie.current = !1, ee(!1), L(), console.log("[FlowEngage] email already on file per server — gate disabled"));
12917
12958
  },
12918
12959
  onAgentTurnEnd: () => {
12919
- e || de.current && (le.current || setTimeout(() => me.current?.(), 250));
12960
+ e || ue.current && (ce.current || setTimeout(() => pe.current?.(), 250));
12961
+ },
12962
+ onSessionEnding: () => {
12963
+ e || Pe("minimized");
12920
12964
  },
12921
12965
  onModeChange: ({ mode: t }) => {
12922
12966
  if (!e) {
12923
12967
  if (t === "speaking") {
12924
- L.current &&= (clearTimeout(L.current), null), T("speaking"), I.current = "speaking", ke.current = !0, Pe.current = !1, Me.current &&= (clearTimeout(Me.current), null);
12968
+ je.current &&= (clearTimeout(je.current), null), T("speaking"), ke.current = "speaking", Me.current = !1;
12925
12969
  return;
12926
12970
  }
12927
- if (I.current = "listening", Oe.current) {
12928
- Oe.current = !1, Fe();
12971
+ if (ke.current = "listening", I.current) {
12972
+ I.current = !1, Pe();
12929
12973
  return;
12930
12974
  }
12931
- if (Te && !_e && !ie.current && !fe.current) {
12975
+ if (Te && !_e && !re.current && !de.current) {
12932
12976
  _e = !0, O = !0, A = !0;
12933
12977
  try {
12934
- M.current?.sendContextualUpdate?.("CRITICAL — EMAIL REQUIRED BEFORE ANYTHING ELSE. The visitor has not provided their email. Do NOT speak right now. Wait silently for the visitor to speak first. The MOMENT the visitor says ANYTHING — a question, a request, or just a greeting — your ENTIRE next response must be EXACTLY this one sentence: \"Before I answer that, could you please enter your email in the text box below?\" Do NOT answer their question. Do NOT say anything about the topic. Do NOT begin an answer and then switch — your first word must be \"Before\". After you say that sentence, stay completely silent until you receive an EMAIL_SAVED message, then thank them briefly and answer their question in full.");
12978
+ N.current?.sendContextualUpdate?.("CRITICAL — EMAIL REQUIRED BEFORE ANYTHING ELSE. The visitor has not provided their email. Do NOT speak right now. Wait silently for the visitor to speak first. The MOMENT the visitor says ANYTHING — a question, a request, or just a greeting — your ENTIRE next response must be EXACTLY this one sentence: \"Before I answer that, could you please enter your email in the text box below?\" Do NOT answer their question. Do NOT say anything about the topic. Do NOT begin an answer and then switch — your first word must be \"Before\". After you say that sentence, stay completely silent until you receive an EMAIL_SAVED message, then thank them briefly and answer their question in full.");
12935
12979
  } catch {}
12936
12980
  }
12937
12981
  if (k && !O) {
12938
12982
  O = !0;
12939
12983
  try {
12940
- M.current?.sendContextualUpdate?.(k);
12984
+ N.current?.sendContextualUpdate?.(k);
12941
12985
  } catch {}
12942
12986
  }
12943
- if (re && !j) {
12987
+ if (M && !j) {
12944
12988
  j = !0;
12945
12989
  try {
12946
- M.current?.sendContextualUpdate?.(re);
12990
+ N.current?.sendContextualUpdate?.(M);
12947
12991
  } catch {}
12948
12992
  }
12949
12993
  if (te && !A) {
12950
12994
  A = !0;
12951
12995
  try {
12952
- M.current?.sendContextualUpdate?.(te);
12996
+ N.current?.sendContextualUpdate?.(te);
12953
12997
  } catch {}
12954
12998
  }
12955
- L.current && clearTimeout(L.current), L.current = setTimeout(() => {
12956
- e || I.current !== "speaking" && (Pe.current || (L.current = null, I.current = "listening", T("listening"), ke.current && je.current && !ye.current && !ae.current && (Me.current && clearTimeout(Me.current), Me.current = setTimeout(() => {
12957
- if (!e && I.current === "listening" && !ye.current && !ae.current) try {
12958
- M.current?.sendContextualUpdate?.("The visitor has been silent for a while. Ask one short, natural question to re-engage — for example: 'Is there anything specific you'd like to know more about?' or 'What else can I help you with today?' Keep it to one sentence.");
12959
- } catch {}
12960
- }, 15e3))));
12999
+ je.current && clearTimeout(je.current), je.current = setTimeout(() => {
13000
+ e || ke.current !== "speaking" && (Me.current || (je.current = null, ke.current = "listening", T("listening")));
12961
13001
  }, 1200);
12962
13002
  }
12963
13003
  },
12964
13004
  onMessage: (t) => {
12965
- if (e || le.current && t.role !== "user" && !/email/i.test(String(t.message || ""))) return;
12966
- t.role === "user" && Le.test(String(t.message || "")) && (de.current = !0, ue.current = 0, he.current = -1, pe.current = pg(), setTimeout(() => me.current?.(), 400), console.log(`[FlowEngage] walkthrough armed — ${pe.current.length} sections on this page`)), t.role !== "user" && R.test(String(t.message || "")) && (de.current = !1);
13005
+ if (e || ce.current && t.role !== "user" && !/email/i.test(String(t.message || ""))) return;
13006
+ t.role === "user" && Fe.test(String(t.message || "")) && (me(!0), le.current = 0, he.current = -1, fe.current = _g(), setTimeout(() => pe.current?.(), 400), console.log(`[FlowEngage] walkthrough armed — ${fe.current.length} sections on this page`)), t.role !== "user" && Ie.test(String(t.message || "")) && me(!1);
12967
13007
  let n = t.role === "user" ? "user" : "bot", r = t.message || t.text || t.content || "";
12968
13008
  if (r) {
12969
13009
  if (n === "user") {
12970
- ge.current = r, Pe.current = !0, je.current = !0, L.current &&= (clearTimeout(L.current), null), Me.current &&= (clearTimeout(Me.current), null);
13010
+ ge.current = r, Me.current = !0, je.current &&= (clearTimeout(je.current), null);
12971
13011
  try {
12972
13012
  On();
12973
13013
  } catch {}
12974
- Te && !oe && !ie.current && !fe.current && (oe = !0, ce.current = r, le.current = !0, M.current?.injectAgentSpeech?.("Before I answer that, could you please enter your email in the text box below?", "interrupt"), M.current?.setMicMuted?.(!0), ae.current || (ae.current = !0, se.current = 0, ee(!0), Re()));
13014
+ Te && !ae && !re.current && !de.current && (ae = !0, se.current = r, ce.current = !0, N.current?.injectAgentSpeech?.("Before I answer that, could you please enter your email in the text box below?", "interrupt"), N.current?.setMicMuted?.(!0), ie.current || (ie.current = !0, oe.current = 0, ee(!0), Le()));
12975
13015
  }
12976
13016
  if (l.current = [...l.current, {
12977
13017
  sender: n,
12978
13018
  message: r,
12979
13019
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
12980
13020
  }], i) try {
12981
- let e = Th(l.current);
13021
+ let e = kh(l.current);
12982
13022
  e && P(i, e);
12983
13023
  } catch {}
12984
- if (xg(n, r)) {
12985
- Oe.current = !0;
13024
+ if (Tg(n, r)) {
13025
+ I.current = !0;
12986
13026
  return;
12987
13027
  }
12988
- if (ye.current && n === "bot" && /are you still there|still there\??|hello\?|anyone there|checking in|you there|are you available|is anyone|did you step away/i.test(r)) if (De.current += 1, De.current === 2) try {
12989
- M.current?.sendContextualUpdate?.("IMPORTANT: The visitor is muted and has not responded to your last 2 checks. Make exactly ONE more check. If there is still no response, say: 'I feel like you are not active, so I'm ending this session. You can connect with me anytime.' then immediately call the fwh-end-session-mvp tool to end the voice session. Do NOT ask again after that.");
13028
+ if (ye.current && n === "bot" && /are you still there|still there\??|hello\?|anyone there|checking in|you there|are you available|is anyone|did you step away/i.test(r)) if (Oe.current += 1, Oe.current === 2) try {
13029
+ N.current?.sendContextualUpdate?.("IMPORTANT: The visitor is muted and has not responded to your last 2 checks. Make exactly ONE more check. If there is still no response, say: 'I feel like you are not active, so I'm ending this session. You can connect with me anytime.' then immediately call the fwh-end-session-mvp tool to end the voice session. Do NOT ask again after that.");
12990
13030
  } catch {}
12991
- else De.current >= 5 && Fe("minimized");
13031
+ else Oe.current >= 5 && Pe("minimized");
12992
13032
  }
12993
13033
  },
12994
13034
  onError: (t) => {
@@ -12999,9 +13039,9 @@ function Tg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
12999
13039
  raw: t
13000
13040
  });
13001
13041
  try {
13002
- M.current?.setMicMuted?.(!0);
13042
+ N.current?.setMicMuted?.(!0);
13003
13043
  } catch {}
13004
- D(!0), T("error"), Fe("chat");
13044
+ D(!0), T("error"), Pe("chat");
13005
13045
  }
13006
13046
  },
13007
13047
  onDisconnect: (t) => {
@@ -13016,16 +13056,16 @@ function Tg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13016
13056
  wasMuted: ye.current
13017
13057
  }), be.current = !0;
13018
13058
  try {
13019
- M.current?.setMicMuted?.(!0);
13059
+ N.current?.setMicMuted?.(!0);
13020
13060
  } catch {}
13021
- D(!0), Fe("chat");
13061
+ D(!0), Pe("chat");
13022
13062
  }
13023
13063
  });
13024
13064
  if (e) {
13025
- console.warn("[FlowEngage:VoiceDebug] ❌ cancelled=true after startSession resolved — killing session immediately"), F.endSession().catch(() => {});
13065
+ console.warn("[FlowEngage:VoiceDebug] ❌ cancelled=true after startSession resolved — killing session immediately"), De.endSession().catch(() => {});
13026
13066
  return;
13027
13067
  }
13028
- o = F, M.current = F, T("listening");
13068
+ o = De, N.current = De, T("listening");
13029
13069
  try {
13030
13070
  let e = typeof window < "u" ? window.location.href : "", a = "[]";
13031
13071
  try {
@@ -13037,7 +13077,7 @@ function Tg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13037
13077
  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(" | "));
13038
13078
  } catch {}
13039
13079
  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` : "";
13040
- F.sendContextualUpdate(`${s}SESSION_CONTEXT (NOT a tool result — do NOT treat as CURRENT_PAGE): Visitor is on: ${e} | Approx headings for awareness only: ${o}. SiteId: ${i || "unknown"}. Forms: ${a}. ${y ? "" : "Visitor's email is already on file from a prior session — do NOT ask for it again. "}The visitor is ALREADY on this page — do NOT offer to navigate there. 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. The approximate headings above are for routing awareness ONLY — they are NOT precise enough for fwh-highlight-mvp. Do NOT skip fwh-get-current-page-mvp. Voice: call end_voice_session or say you are ending the session to stop.`);
13080
+ De.sendContextualUpdate(`${s}SESSION_CONTEXT (NOT a tool result — do NOT treat as CURRENT_PAGE): Visitor is on: ${e} | Approx headings for awareness only: ${o}. SiteId: ${i || "unknown"}. Forms: ${a}. ${y ? "" : "Visitor's email is already on file from a prior session — do NOT ask for it again. "}The visitor is ALREADY on this page — do NOT offer to navigate there. 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. The approximate headings above are for routing awareness ONLY — they are NOT precise enough for fwh-highlight-mvp. Do NOT skip fwh-get-current-page-mvp. Voice: call end_voice_session or say you are ending the session to stop.`);
13041
13081
  } catch {}
13042
13082
  if (typeof window < "u") {
13043
13083
  let t = window.location.pathname, n = () => {
@@ -13066,7 +13106,7 @@ function Tg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13066
13106
  ts: Date.now()
13067
13107
  });
13068
13108
  try {
13069
- M.current?.sendUserMessage?.(`[SYSTEM: I navigated away mid-walkthrough — I am now on the "${l}" page (${i}). Page title: "${a}". Sections: ${JSON.stringify(o)}. STOP everything. Do NOT describe the new page. Say EXACTLY: "I see you've navigated to the ${l} 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 flowengage_navigate, do NOT call flowengage_highlight, the visitor will navigate themselves if needed. IF I want to hear about this page: call flowengage_highlight for sections of "${l}" only.]`);
13109
+ N.current?.sendUserMessage?.(`[SYSTEM: I navigated away mid-walkthrough — I am now on the "${l}" page (${i}). Page title: "${a}". Sections: ${JSON.stringify(o)}. STOP everything. Do NOT describe the new page. Say EXACTLY: "I see you've navigated to the ${l} 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 flowengage_navigate, do NOT call flowengage_highlight, the visitor will navigate themselves if needed. IF I want to hear about this page: call flowengage_highlight for sections of "${l}" only.]`);
13070
13110
  } catch {}
13071
13111
  };
13072
13112
  c = window.history.pushState.bind(window.history), window.history.pushState = (...e) => {
@@ -13090,12 +13130,12 @@ function Tg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13090
13130
  if (i) try {
13091
13131
  Ne(i);
13092
13132
  } catch {}
13093
- typeof window < "u" && (window.__fe_user_nav_during_speech = null), wr(), Me.current &&= (clearTimeout(Me.current), null), L.current &&= (clearTimeout(L.current), null), oe.current &&= (clearTimeout(oe.current), null), ke.current = !1, Pe.current = !1, I.current = "idle", c && typeof window < "u" && (window.history.pushState = c), d && typeof window < "u" && window.removeEventListener("popstate", d);
13094
- let t = o || M.current, n = N.current, f = Ce.current;
13133
+ typeof window < "u" && (window.__fe_user_nav_during_speech = null), wr(), je.current &&= (clearTimeout(je.current), null), ae.current &&= (clearTimeout(ae.current), null), Me.current = !1, ke.current = "idle", c && typeof window < "u" && (window.history.pushState = c), d && typeof window < "u" && window.removeEventListener("popstate", d);
13134
+ let t = o || N.current, n = Ce.current, f = F.current;
13095
13135
  if (t?.endSession?.().catch(() => {}), n && s && a) {
13096
13136
  let e = f ? Math.round((Date.now() - f) / 1e3) : 0, t = JSON.stringify({
13097
13137
  chatId: s,
13098
- elevenLabsConversationId: n,
13138
+ voiceSessionId: n,
13099
13139
  duration: e,
13100
13140
  siteId: i
13101
13141
  }), r = `${a}/api/voice/save-chat-recording`;
@@ -13104,7 +13144,7 @@ function Tg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13104
13144
  headers: { "Content-Type": "application/json" },
13105
13145
  body: t,
13106
13146
  keepalive: !0
13107
- }).catch(() => {}), N.current = null, Ce.current = null;
13147
+ }).catch(() => {}), Ce.current = null, F.current = null;
13108
13148
  }
13109
13149
  typeof u == "function" && l.current.length > 0 && u(l.current).catch?.(() => {});
13110
13150
  };
@@ -13112,53 +13152,53 @@ function Tg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13112
13152
  r,
13113
13153
  i,
13114
13154
  a,
13115
- Fe
13155
+ Pe
13116
13156
  ]), c(() => {
13117
13157
  if (!O) return;
13118
13158
  let e = (e) => {
13119
13159
  let t = e.composedPath?.()?.[0] || e.target;
13120
- F.current && !F.current.contains(t) && k(!1);
13160
+ De.current && !De.current.contains(t) && k(!1);
13121
13161
  };
13122
13162
  return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
13123
13163
  }, [O]);
13124
- let Be = async () => {
13125
- if (M.current) try {
13164
+ let Re = async () => {
13165
+ if (N.current) try {
13126
13166
  if (E) {
13127
- De.current = 0, await M.current.setMicMuted?.(!1), D(!1);
13167
+ Oe.current = 0, await N.current.setMicMuted?.(!1), D(!1);
13128
13168
  try {
13129
- M.current.sendContextualUpdate?.("The visitor has unmuted. Resume normal interaction and wait for them to speak.");
13169
+ N.current.sendContextualUpdate?.("The visitor has unmuted. Resume normal interaction and wait for them to speak.");
13130
13170
  } catch {}
13131
13171
  } else {
13132
- De.current = 0, await M.current.setMicMuted?.(!0), D(!0);
13172
+ Oe.current = 0, await N.current.setMicMuted?.(!0), D(!0);
13133
13173
  try {
13134
- M.current.sendContextualUpdate?.("The visitor has muted their microphone. Do NOT speak, ask if they are there, or prompt them in any way. Stay completely silent until they unmute.");
13174
+ N.current.sendContextualUpdate?.("The visitor has muted their microphone. Do NOT speak, ask if they are there, or prompt them in any way. Stay completely silent until they unmute.");
13135
13175
  } catch {}
13136
13176
  }
13137
13177
  } catch {}
13138
- }, Ve = o(async (e) => {
13178
+ }, ze = o(async (e) => {
13139
13179
  e?.preventDefault?.();
13140
13180
  let t = te.trim().toLowerCase();
13141
13181
  if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t)) {
13142
- re("Please enter a valid email address.");
13182
+ M("Please enter a valid email address.");
13143
13183
  return;
13144
13184
  }
13145
- re("");
13185
+ M("");
13146
13186
  try {
13147
13187
  typeof v == "function" && await v(t);
13148
13188
  } catch {}
13149
- ie.current = !0, ae.current = !1, Ie(), ee(!1), ne(""), le.current = !1, M.current?.setMicMuted?.(!1);
13150
- let n = ce.current;
13151
- ce.current = "";
13189
+ re.current = !0, ie.current = !1, L(), ee(!1), ne(""), ce.current = !1, N.current?.setMicMuted?.(!1);
13190
+ let n = se.current;
13191
+ se.current = "";
13152
13192
  try {
13153
- M.current?.sendUserMessage?.("[SYSTEM: EMAIL_SAVED — the visitor typed and submitted their email address. Say a brief 'Thank you!' and then " + (n ? `immediately answer their original question fully: "${n}".` : "continue helping them.") + " Do NOT ask for their email again.]");
13193
+ N.current?.sendUserMessage?.("[SYSTEM: EMAIL_SAVED — the visitor typed and submitted their email address. Say a brief 'Thank you!' and then " + (n ? `immediately answer their original question fully: "${n}".` : "continue helping them.") + " Do NOT ask for their email again.]");
13154
13194
  } catch {}
13155
13195
  }, [
13156
13196
  te,
13157
13197
  v,
13158
- Ie
13159
- ]), He = Array.isArray(e) && e[0] || "#3B82F6";
13198
+ L
13199
+ ]), Be = Array.isArray(e) && e[0] || "#3B82F6";
13160
13200
  return /* @__PURE__ */ _("div", {
13161
- ref: F,
13201
+ ref: De,
13162
13202
  style: {
13163
13203
  position: "relative",
13164
13204
  display: "flex",
@@ -13169,7 +13209,7 @@ function Tg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13169
13209
  },
13170
13210
  children: [
13171
13211
  A && /* @__PURE__ */ _("form", {
13172
- onSubmit: Ve,
13212
+ onSubmit: ze,
13173
13213
  style: {
13174
13214
  width: "270px",
13175
13215
  maxWidth: "calc(100vw - 40px)",
@@ -13202,7 +13242,7 @@ function Tg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13202
13242
  autoFocus: !0,
13203
13243
  value: te,
13204
13244
  onChange: (e) => {
13205
- ne(e.target.value), j && re("");
13245
+ ne(e.target.value), j && M("");
13206
13246
  },
13207
13247
  placeholder: "you@example.com",
13208
13248
  style: {
@@ -13232,7 +13272,7 @@ function Tg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13232
13272
  padding: "10px 12px",
13233
13273
  borderRadius: "10px",
13234
13274
  border: "none",
13235
- background: te.trim() ? He : "#374151",
13275
+ background: te.trim() ? Be : "#374151",
13236
13276
  color: "white",
13237
13277
  fontSize: "14px",
13238
13278
  fontWeight: 600,
@@ -13278,7 +13318,7 @@ function Tg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13278
13318
  },
13279
13319
  children: "Muted"
13280
13320
  }),
13281
- /* @__PURE__ */ g(Sg, {
13321
+ /* @__PURE__ */ g(Eg, {
13282
13322
  size: 72,
13283
13323
  voiceState: w,
13284
13324
  isMuted: E,
@@ -13301,7 +13341,7 @@ function Tg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13301
13341
  alignItems: "center"
13302
13342
  },
13303
13343
  children: [/* @__PURE__ */ g("button", {
13304
- onClick: Be,
13344
+ onClick: Re,
13305
13345
  title: E ? "Unmute" : "Mute",
13306
13346
  style: {
13307
13347
  width: "24px",
@@ -13350,7 +13390,7 @@ function Tg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13350
13390
  y2: "23"
13351
13391
  })
13352
13392
  ]
13353
- }) : /* @__PURE__ */ g(km, {
13393
+ }) : /* @__PURE__ */ g(Nm, {
13354
13394
  size: 16,
13355
13395
  color: "currentColor"
13356
13396
  })
@@ -13372,7 +13412,7 @@ function Tg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13372
13412
  padding: 0,
13373
13413
  flexShrink: 0
13374
13414
  },
13375
- children: /* @__PURE__ */ g(Lm, {
13415
+ children: /* @__PURE__ */ g(Vm, {
13376
13416
  size: 16,
13377
13417
  color: "currentColor"
13378
13418
  })
@@ -13396,7 +13436,7 @@ function Tg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13396
13436
  children: [
13397
13437
  /* @__PURE__ */ _("button", {
13398
13438
  onClick: () => {
13399
- k(!1), Se.current = "chat", ze(t);
13439
+ k(!1), Se.current = "chat", R(t);
13400
13440
  },
13401
13441
  style: {
13402
13442
  display: "flex",
@@ -13421,11 +13461,11 @@ function Tg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13421
13461
  onMouseLeave: (e) => {
13422
13462
  e.currentTarget.style.background = "none";
13423
13463
  },
13424
- children: [/* @__PURE__ */ g(Rm, {}), S]
13464
+ children: [/* @__PURE__ */ g(Hm, {}), S]
13425
13465
  }),
13426
13466
  /* @__PURE__ */ _("button", {
13427
13467
  onClick: () => {
13428
- k(!1), Se.current = "minimized", ze(n);
13468
+ k(!1), Se.current = "minimized", R(n);
13429
13469
  },
13430
13470
  style: {
13431
13471
  display: "flex",
@@ -13450,7 +13490,7 @@ function Tg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13450
13490
  onMouseLeave: (e) => {
13451
13491
  e.currentTarget.style.background = "none";
13452
13492
  },
13453
- children: [/* @__PURE__ */ g(zm, {}), C]
13493
+ children: [/* @__PURE__ */ g(Um, {}), C]
13454
13494
  }),
13455
13495
  /* @__PURE__ */ g("button", {
13456
13496
  onClick: () => k(!1),
@@ -13502,7 +13542,7 @@ function Tg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13502
13542
  ]
13503
13543
  });
13504
13544
  }
13505
- function Eg({ orbColors: e }) {
13545
+ function Ag({ orbColors: e }) {
13506
13546
  let t = Array.isArray(e) && e.length > 0 ? e : [
13507
13547
  "#135bd8",
13508
13548
  "#ef334b",
@@ -13521,7 +13561,7 @@ function Eg({ orbColors: e }) {
13521
13561
  `.replace(/\s+/g, " ").trim()
13522
13562
  } });
13523
13563
  }
13524
- var Dg = () => /* @__PURE__ */ g("div", {
13564
+ var jg = () => /* @__PURE__ */ g("div", {
13525
13565
  style: {
13526
13566
  display: "flex",
13527
13567
  marginBottom: "12px",
@@ -13551,8 +13591,8 @@ var Dg = () => /* @__PURE__ */ g("div", {
13551
13591
  } }, e))
13552
13592
  })
13553
13593
  });
13554
- function Og({ 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: re, emailError: ie, emailCaptureSuccess: ae, replyContext: oe, setReplyContext: se, webRTCError: ce, micError: le, setMicError: ue, dismissCallError: de, activeCallId: fe, isCallMuted: pe, toggleCallMute: me, endWebRTCCall: he, formatCallDuration: M, callDurationSeconds: ge, isCallMinimized: _e, onExpand: ve, onCollapse: ye, onStartVoice: be, voiceEnabled: xe, headerBgColor: Se, onNewChat: N, showPoweredBy: Ce, privacyPolicyUrl: P, getVisitorChatHistory: we, resumeChat: Te, isSessionRestoring: F, isClosing: Ee }) {
13555
- let De = l.length > 0, Oe = T || E || w, I = !!fe, [ke, Ae] = m(!1), [je, Me] = m(!1), [Ne, L] = m([]), [Pe, Fe] = m(!1), Ie = p(null), [Le, R] = m(() => typeof window < "u" ? window.visualViewport?.height ?? window.innerHeight : 600), [Re, ze] = m(0);
13594
+ function Mg({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i, quickChatOptions: a, onQuickChatSelect: o, isMobile: s, chatHistory: l, isAiTyping: u, isAgentTyping: d, activeScreen: f, agentName: v, agentHeadshot: y, fallbackAgentName: b, input: x, setInput: S, onSubmit: C, isConversationEnded: w, isLoading: T, isRateLimited: E, rateLimitMessage: D, selectedFile: O, onFileSelect: k, onRemoveSelectedFile: A, attachmentError: ee, isUploadingAttachment: te, requiresEmail: ne, emailInput: j, setEmailInput: M, emailError: re, emailCaptureSuccess: ie, replyContext: ae, setReplyContext: oe, webRTCError: se, micError: ce, setMicError: le, dismissCallError: ue, activeCallId: de, isCallMuted: fe, toggleCallMute: pe, endWebRTCCall: me, formatCallDuration: he, callDurationSeconds: N, isCallMinimized: ge, onExpand: _e, onCollapse: ve, onStartVoice: ye, voiceEnabled: be, headerBgColor: xe, onNewChat: Se, showPoweredBy: Ce, privacyPolicyUrl: P, getVisitorChatHistory: we, resumeChat: Te, isSessionRestoring: F, isClosing: Ee }) {
13595
+ let De = l.length > 0, Oe = T || E || w, I = !!de, [ke, Ae] = m(!1), [je, Me] = m(!1), [Ne, Pe] = m([]), [L, Fe] = m(!1), Ie = p(null), [Le, R] = m(() => typeof window < "u" ? window.visualViewport?.height ?? window.innerHeight : 600), [Re, ze] = m(0);
13556
13596
  c(() => {
13557
13597
  if (!s) return;
13558
13598
  let e = window.visualViewport;
@@ -13568,7 +13608,7 @@ function Og({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
13568
13608
  Ae(!1), Me(!0), Fe(!0);
13569
13609
  try {
13570
13610
  let e = await we();
13571
- e?.data && L(e.data);
13611
+ e?.data && Pe(e.data);
13572
13612
  } catch (e) {
13573
13613
  console.error(e);
13574
13614
  } finally {
@@ -13621,7 +13661,7 @@ function Og({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
13621
13661
  alignItems: "center",
13622
13662
  columnGap: "14px",
13623
13663
  padding: "16px 10px 14px",
13624
- background: Se || "transparent",
13664
+ background: xe || "transparent",
13625
13665
  flexShrink: 0,
13626
13666
  position: "relative",
13627
13667
  zIndex: 30
@@ -13634,7 +13674,7 @@ function Og({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
13634
13674
  alignItems: "center"
13635
13675
  },
13636
13676
  children: /* @__PURE__ */ g("button", {
13637
- onClick: ye,
13677
+ onClick: ve,
13638
13678
  style: {
13639
13679
  width: "40px",
13640
13680
  height: "40px",
@@ -13691,7 +13731,7 @@ function Og({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
13691
13731
  justifyContent: "center",
13692
13732
  height: "40px"
13693
13733
  },
13694
- children: i ? /* @__PURE__ */ g(yg, {
13734
+ children: i ? /* @__PURE__ */ g(Cg, {
13695
13735
  logo: i,
13696
13736
  style: {
13697
13737
  height: "34px",
@@ -13704,7 +13744,7 @@ function Og({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
13704
13744
  height: "40px",
13705
13745
  flexShrink: 0
13706
13746
  },
13707
- children: /* @__PURE__ */ g(bg, { title: e.chatTitle })
13747
+ children: /* @__PURE__ */ g(wg, { title: e.chatTitle })
13708
13748
  })
13709
13749
  }), o && /* @__PURE__ */ g("div", {
13710
13750
  style: {
@@ -13801,10 +13841,10 @@ function Og({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
13801
13841
  animation: "fe-orb-fade-in 0.18s ease"
13802
13842
  },
13803
13843
  children: [
13804
- xe && /* @__PURE__ */ _(h, { children: [/* @__PURE__ */ _("button", {
13844
+ be && /* @__PURE__ */ _(h, { children: [/* @__PURE__ */ _("button", {
13805
13845
  type: "button",
13806
13846
  onClick: () => {
13807
- Ae(!1), be?.();
13847
+ Ae(!1), ye?.();
13808
13848
  },
13809
13849
  style: {
13810
13850
  display: "flex",
@@ -13846,7 +13886,7 @@ function Og({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
13846
13886
  /* @__PURE__ */ _("button", {
13847
13887
  type: "button",
13848
13888
  onClick: () => {
13849
- Ae(!1), N?.();
13889
+ Ae(!1), Se?.();
13850
13890
  },
13851
13891
  style: {
13852
13892
  display: "flex",
@@ -13929,7 +13969,7 @@ function Og({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
13929
13969
  /* @__PURE__ */ _("button", {
13930
13970
  type: "button",
13931
13971
  onClick: () => {
13932
- Ae(!1), ye?.();
13972
+ Ae(!1), ve?.();
13933
13973
  },
13934
13974
  style: {
13935
13975
  display: "flex",
@@ -13987,24 +14027,24 @@ function Og({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
13987
14027
  })
13988
14028
  ]
13989
14029
  }),
13990
- /* @__PURE__ */ g(sh, {
13991
- webRTCError: ce,
13992
- micError: le,
13993
- setMicError: ue,
13994
- dismissCallError: de,
14030
+ /* @__PURE__ */ g(dh, {
14031
+ webRTCError: se,
14032
+ micError: ce,
14033
+ setMicError: le,
14034
+ dismissCallError: ue,
13995
14035
  isRateLimited: E,
13996
14036
  rateLimitMessage: D
13997
14037
  }),
13998
- _e && /* @__PURE__ */ g(wh, {
14038
+ ge && /* @__PURE__ */ g(Oh, {
13999
14039
  agentName: v,
14000
14040
  agentHeadshot: y,
14001
14041
  fallbackAgentName: b,
14002
- callDurationSeconds: ge,
14003
- isCallMuted: pe,
14004
- formatCallDuration: M,
14005
- toggleCallMute: me,
14006
- endWebRTCCall: he,
14007
- onExpand: ve,
14042
+ callDurationSeconds: N,
14043
+ isCallMuted: fe,
14044
+ formatCallDuration: he,
14045
+ toggleCallMute: pe,
14046
+ endWebRTCCall: me,
14047
+ onExpand: _e,
14008
14048
  primaryColor: n
14009
14049
  }),
14010
14050
  /* @__PURE__ */ _("div", {
@@ -14069,7 +14109,7 @@ function Og({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
14069
14109
  overflowY: "auto",
14070
14110
  position: "relative"
14071
14111
  },
14072
- children: Pe ? /* @__PURE__ */ g("div", {
14112
+ children: L ? /* @__PURE__ */ g("div", {
14073
14113
  style: {
14074
14114
  padding: "40px 20px",
14075
14115
  textAlign: "center",
@@ -14129,17 +14169,17 @@ function Og({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
14129
14169
  children: "No previous chats found."
14130
14170
  })
14131
14171
  })]
14132
- }) : null, De ? /* @__PURE__ */ g(ih, {
14172
+ }) : null, De ? /* @__PURE__ */ g(ch, {
14133
14173
  chatHistory: l,
14134
14174
  isAiTyping: u,
14135
14175
  isLoading: T,
14136
14176
  isAgentTyping: d,
14137
- setReplyContext: se,
14138
- TypingDots: Dg,
14177
+ setReplyContext: oe,
14178
+ TypingDots: jg,
14139
14179
  primaryColor: n,
14140
14180
  agentHeadshot: y,
14141
14181
  agentDisplayName: v || b,
14142
- botAvatarNode: /* @__PURE__ */ g(Eg, { orbColors: t })
14182
+ botAvatarNode: /* @__PURE__ */ g(Ag, { orbColors: t })
14143
14183
  }) : F ? /* @__PURE__ */ _("div", {
14144
14184
  style: {
14145
14185
  flex: 1,
@@ -14180,7 +14220,7 @@ function Og({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
14180
14220
  padding: "28px 24px"
14181
14221
  },
14182
14222
  children: [
14183
- /* @__PURE__ */ g(Sg, {
14223
+ /* @__PURE__ */ g(Eg, {
14184
14224
  size: 94,
14185
14225
  orbColors: t
14186
14226
  }),
@@ -14230,7 +14270,7 @@ function Og({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
14230
14270
  ]
14231
14271
  })]
14232
14272
  }),
14233
- ae && /* @__PURE__ */ _("div", {
14273
+ ie && /* @__PURE__ */ _("div", {
14234
14274
  style: {
14235
14275
  margin: "0 16px 8px",
14236
14276
  padding: "9px 14px",
@@ -14271,18 +14311,18 @@ function Og({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
14271
14311
  zIndex: 1,
14272
14312
  padding: ne ? "6px 0 0" : "12px 0 0"
14273
14313
  },
14274
- children: /* @__PURE__ */ g(oh, {
14314
+ children: /* @__PURE__ */ g(uh, {
14275
14315
  input: x,
14276
14316
  setInput: S,
14277
14317
  onSubmit: C,
14278
14318
  isConversationEnded: w,
14279
14319
  callUiActive: I,
14280
- handleToggleVoice: be,
14320
+ handleToggleVoice: ye,
14281
14321
  showVoiceToggle: f === "agent",
14282
14322
  activeScreen: f,
14283
14323
  inputDisabled: Oe,
14284
- replyContext: oe,
14285
- clearReplyContext: () => se(null),
14324
+ replyContext: ae,
14325
+ clearReplyContext: () => oe(null),
14286
14326
  onFileSelect: k,
14287
14327
  selectedFile: O,
14288
14328
  onRemoveSelectedFile: A,
@@ -14290,8 +14330,8 @@ function Og({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
14290
14330
  isUploadingAttachment: te,
14291
14331
  requiresEmail: ne,
14292
14332
  emailInput: j,
14293
- setEmailInput: re,
14294
- emailError: ie,
14333
+ setEmailInput: M,
14334
+ emailError: re,
14295
14335
  inputPlaceholder: e.inputPlaceholder
14296
14336
  })
14297
14337
  }),
@@ -14345,29 +14385,29 @@ function Og({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
14345
14385
  ]
14346
14386
  });
14347
14387
  }
14348
- function kg() {
14349
- 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: re, openWidget: ie, captureVisitorEmail: ae, setVoiceMode: oe, endConversation: se, startNewChat: ue, acceptCall: de, rejectCall: fe, endWebRTCCall: pe, toggleCallMute: me, dismissCallError: he, startTyping: M, stopTyping: ge, updateTypingDraft: _e, getVisitorChatHistory: ve, resumeChat: ye, isSessionRestoring: be, openToChatCounter: xe, voiceEndCounter: Se } = Cn();
14388
+ function Ng() {
14389
+ 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: ae, endConversation: oe, startNewChat: le, acceptCall: ue, rejectCall: de, endWebRTCCall: fe, toggleCallMute: pe, dismissCallError: me, startTyping: he, stopTyping: N, updateTypingDraft: ge, getVisitorChatHistory: _e, resumeChat: ve, isSessionRestoring: ye, openToChatCounter: be, voiceEndCounter: xe } = Cn();
14350
14390
  c(() => {
14351
14391
  try {
14352
14392
  or();
14353
14393
  } catch {}
14354
14394
  }, []), c(() => {
14355
- xe && V !== "voice_mode" && V !== "text_chat" && V !== "call_screen" && (oe?.(!1), H("text_chat"));
14356
- }, [xe]);
14357
- let N = t?.widgetSettings || {}, Ce = n?.widgetSettings || {}, P = {
14358
- ...N.branding || {},
14395
+ be && V !== "voice_mode" && V !== "text_chat" && V !== "call_screen" && (ae?.(!1), H("text_chat"));
14396
+ }, [be]);
14397
+ let Se = t?.widgetSettings || {}, Ce = n?.widgetSettings || {}, P = {
14398
+ ...Se.branding || {},
14359
14399
  ...Ce.branding || {}
14360
14400
  }, F = {
14361
- ...N.theme || {},
14401
+ ...Se.theme || {},
14362
14402
  ...Ce.theme || {}
14363
14403
  }, Ee = {
14364
- ...N.features || {},
14404
+ ...Se.features || {},
14365
14405
  ...Ce.features || {}
14366
14406
  }, Oe = Ee.voice !== !1, I = Array.isArray(F.orbColors) && F.orbColors.length > 0 ? F.orbColors : null, Ae = F.buttonColor || F.primaryColor || I?.[0] || "#3B82F6", je = {
14367
14407
  small: 50,
14368
14408
  medium: 64,
14369
14409
  large: 80
14370
- }, Me = je[F.orbSize] || je.small, Ne = F.position || "bottom-right", L = P.fallbackAgentName || "Agent", Pe = gg(I ?? F.chatBgColors), Fe = P.logo || P.logoUrl || null, Ie = A || "en", Le = N.recommendations?.[Ie] || [], R = (Ce.recommendations?.[Ie] ?? Le).filter((e) => String(e?.label ?? "").trim()).map((e, t) => ({
14410
+ }, Me = je[F.orbSize] || je.small, Ne = F.position || "bottom-right", Pe = P.fallbackAgentName || "Agent", L = bg(I ?? F.chatBgColors), Fe = P.logo || P.logoUrl || null, Ie = A || "en", Le = Se.recommendations?.[Ie] || [], R = (Ce.recommendations?.[Ie] ?? Le).filter((e) => String(e?.label ?? "").trim()).map((e, t) => ({
14371
14411
  id: e.key || `qr-${t}`,
14372
14412
  label: e.label,
14373
14413
  message: e.label,
@@ -14384,11 +14424,11 @@ function kg() {
14384
14424
  }, []);
14385
14425
  let Ke = (() => {
14386
14426
  let e = {
14387
- ...N.pageVisibility || {},
14427
+ ...Se.pageVisibility || {},
14388
14428
  ...Ce.pageVisibility || {}
14389
14429
  };
14390
14430
  return Array.isArray(e.allowedPaths) ? e.allowedPaths.filter(Boolean) : [];
14391
- })(), qe = Ke.length === 0 || Ke.some((e) => e === "*" || e === "/*" ? !0 : e.endsWith("/*") ? We.startsWith(e.slice(0, -1)) : We.replace(/\/$/, "") === e.replace(/\/$/, "")), Je = N.greetings?.[A] || Ce.greetings?.[A] || P.introGreeting || "Hello, I'm here to help you know more about OpenSense Labs.", Ye = {
14431
+ })(), qe = Ke.length === 0 || Ke.some((e) => e === "*" || e === "/*" ? !0 : e.endsWith("/*") ? We.startsWith(e.slice(0, -1)) : We.replace(/\/$/, "") === e.replace(/\/$/, "")), Je = Se.greetings?.[A] || Ce.greetings?.[A] || P.introGreeting || "Hello, I'm here to help you know more about OpenSense Labs.", Ye = {
14392
14432
  entryPrompt: P.entryPrompt || "Do you want to explore in a new way?",
14393
14433
  yesLabel: P.yesLabel || "Yes",
14394
14434
  laterLabel: P.laterLabel || "Later",
@@ -14412,7 +14452,7 @@ function kg() {
14412
14452
  ]), Qe = u && String(u).trim() || t?.ownerProfileImageUrl && String(t.ownerProfileImageUrl).trim() || null, $e = r.some((e) => e.sender === "user"), et = f(() => {
14413
14453
  let e = r.findIndex((e) => e.sender === "user");
14414
14454
  return e === -1 ? !1 : r.slice(e + 1).some((e) => e.sender === "bot" || e.sender === "ai" || e.sender === "agent");
14415
- }, [r]), tt = !!(Ce._dashboardLivePreview || N._dashboardLivePreview), [V, H] = m(() => tt ? "text_chat" : "entry_prompt"), [nt, rt] = m(""), [it, U] = m(null), [at, ot] = m(h || ""), [W, st] = m(""), [ct, lt] = m(!1), [ut, dt] = m(0), [ft, pt] = m(null), [mt, ht] = m(null), [gt, _t] = m(""), [vt, yt] = m(!1), [bt, xt] = m(!1), [St, Ct] = m(!1), wt = p(null), Tt = p(!1), Et = !h && $e && et && V !== "voice_mode";
14455
+ }, [r]), tt = !!(Ce._dashboardLivePreview || Se._dashboardLivePreview), [V, H] = m(() => tt ? "text_chat" : "entry_prompt"), [nt, rt] = m(""), [it, U] = m(null), [at, ot] = m(h || ""), [W, st] = m(""), [ct, lt] = m(!1), [ut, dt] = m(0), [ft, pt] = m(null), [mt, ht] = m(null), [gt, _t] = m(""), [vt, yt] = m(!1), [bt, xt] = m(!1), [St, Ct] = m(!1), wt = p(null), Tt = p(!1), Et = !h && $e && et && V !== "voice_mode";
14416
14456
  d(() => {
14417
14457
  if (e !== "ready" || Tt.current) return;
14418
14458
  if (Tt.current = !0, !Oe) {
@@ -14425,11 +14465,11 @@ function kg() {
14425
14465
  } catch {}
14426
14466
  let n = De(), r = z ? we(z) : null, i = n || !!r?.transcript;
14427
14467
  if (t) {
14428
- ie?.({ notifyChatInitiated: !0 }), oe?.(!0), H("voice_mode");
14468
+ re?.({ notifyChatInitiated: !0 }), ae?.(!0), H("voice_mode");
14429
14469
  return;
14430
14470
  }
14431
14471
  if (ke()) {
14432
- ie?.({ notifyChatInitiated: !1 }), H("text_chat");
14472
+ re?.({ notifyChatInitiated: !1 }), H("text_chat");
14433
14473
  return;
14434
14474
  }
14435
14475
  if (i) {
@@ -14437,13 +14477,13 @@ function kg() {
14437
14477
  H("minimized_orb");
14438
14478
  return;
14439
14479
  }
14440
- ie?.({ notifyChatInitiated: !0 }), oe?.(!0), H("voice_mode");
14480
+ re?.({ notifyChatInitiated: !0 }), ae?.(!0), H("voice_mode");
14441
14481
  return;
14442
14482
  }
14443
14483
  if (z) try {
14444
14484
  Te(z);
14445
14485
  } catch {}
14446
- if (ce(z)) {
14486
+ if (se(z)) {
14447
14487
  H("minimized_orb");
14448
14488
  return;
14449
14489
  }
@@ -14458,7 +14498,7 @@ function kg() {
14458
14498
  let Ot = o(() => {
14459
14499
  ht(null), _t("");
14460
14500
  }, []), kt = o((e) => {
14461
- let t = $m(e);
14501
+ let t = rh(e);
14462
14502
  if (t) {
14463
14503
  ht(null), _t(t);
14464
14504
  return;
@@ -14501,7 +14541,7 @@ function kg() {
14501
14541
  hasIncomingCall: !!w?.callId,
14502
14542
  activeCallId: T,
14503
14543
  callConnectionState: E
14504
- }), wt.current = e, V === "voice_mode" && oe?.(!1), ie?.(), At());
14544
+ }), wt.current = e, V === "voice_mode" && ae?.(!1), re?.(), At());
14505
14545
  }
14506
14546
  }, [
14507
14547
  T,
@@ -14509,8 +14549,8 @@ function kg() {
14509
14549
  At,
14510
14550
  w?.callId,
14511
14551
  i,
14512
- ie,
14513
- oe,
14552
+ re,
14553
+ ae,
14514
14554
  V
14515
14555
  ]), c(() => {
14516
14556
  !w && !T && V === "call_screen" && H("text_chat");
@@ -14522,16 +14562,16 @@ function kg() {
14522
14562
  !T && bt && xt(!1);
14523
14563
  }, [T, bt]), c(() => {
14524
14564
  if (!s || C) {
14525
- _e?.(""), ge?.();
14565
+ ge?.(""), N?.();
14526
14566
  return;
14527
14567
  }
14528
14568
  if (!nt.trim() || mt) {
14529
- _e?.("");
14530
- let e = window.setTimeout(() => ge?.(), 100);
14569
+ ge?.("");
14570
+ let e = window.setTimeout(() => N?.(), 100);
14531
14571
  return () => window.clearTimeout(e);
14532
14572
  }
14533
- M?.();
14534
- let e = window.setTimeout(() => _e?.(nt), 120), t = window.setTimeout(() => ge?.(), 1200);
14573
+ he?.();
14574
+ let e = window.setTimeout(() => ge?.(nt), 120), t = window.setTimeout(() => N?.(), 1200);
14535
14575
  return () => {
14536
14576
  window.clearTimeout(e), window.clearTimeout(t);
14537
14577
  };
@@ -14540,9 +14580,9 @@ function kg() {
14540
14580
  mt,
14541
14581
  s,
14542
14582
  C,
14543
- M,
14544
- ge,
14545
- _e
14583
+ he,
14584
+ N,
14585
+ ge
14546
14586
  ]);
14547
14587
  let Mt = (e) => e ? {
14548
14588
  replyTo: e.messageId || e.id || null,
@@ -14556,7 +14596,7 @@ function kg() {
14556
14596
  st("Please enter a valid email so we can continue helping you.");
14557
14597
  return;
14558
14598
  }
14559
- await ae(e), st(""), lt(!0), setTimeout(() => lt(!1), 3e3);
14599
+ await ie(e), st(""), lt(!0), setTimeout(() => lt(!1), 3e3);
14560
14600
  return;
14561
14601
  }
14562
14602
  let t = Mt(it);
@@ -14564,7 +14604,7 @@ function kg() {
14564
14604
  if (mt) {
14565
14605
  try {
14566
14606
  yt(!0), _t("");
14567
- let e = await re(mt), n = e?.data || e, r = nt.trim() || `Shared file: ${th(mt)}`;
14607
+ let e = await M(mt), n = e?.data || e, r = nt.trim() || `Shared file: ${ah(mt)}`;
14568
14608
  rt(""), U(null), Ot(), await j(r, "", t, {
14569
14609
  type: "file",
14570
14610
  metadata: {
@@ -14584,8 +14624,8 @@ function kg() {
14584
14624
  let n = nt.trim();
14585
14625
  rt(""), U(null), await j(n, "", t);
14586
14626
  }, Pt = o(() => {
14587
- r.length !== 0 && ue?.();
14588
- }, [r.length, ue]), Ft = (e) => {
14627
+ r.length !== 0 && le?.();
14628
+ }, [r.length, le]), Ft = (e) => {
14589
14629
  let t = Math.floor(e / 60);
14590
14630
  return `${String(t).padStart(2, "0")}:${String(e % 60).padStart(2, "0")}`;
14591
14631
  }, It = o(async (e) => {
@@ -14641,11 +14681,11 @@ function kg() {
14641
14681
  t.resume().catch(() => {}), setTimeout(() => t.close().catch(() => {}), 3e3);
14642
14682
  }
14643
14683
  } catch {}
14644
- ie({ notifyChatInitiated: !0 }), oe?.(!0), H("voice_mode");
14684
+ re({ notifyChatInitiated: !0 }), ae?.(!0), H("voice_mode");
14645
14685
  }, Vt = () => {
14646
- ie({ notifyChatInitiated: !0 }), oe?.(!1), H("text_chat");
14686
+ re({ notifyChatInitiated: !0 }), ae?.(!1), H("text_chat");
14647
14687
  }, Ht = () => {
14648
- oe?.(!1), Rt();
14688
+ ae?.(!1), Rt();
14649
14689
  };
14650
14690
  return e !== "ready" || !Ue || Ee.chat === !1 || !qe ? null : /* @__PURE__ */ _("div", {
14651
14691
  className: "flowengage-widget-root",
@@ -14657,15 +14697,15 @@ function kg() {
14657
14697
  onWheel: (e) => e.stopPropagation(),
14658
14698
  onTouchMove: (e) => e.stopPropagation(),
14659
14699
  children: [
14660
- V === "entry_prompt" && /* @__PURE__ */ g(Cg, {
14700
+ V === "entry_prompt" && /* @__PURE__ */ g(Dg, {
14661
14701
  copy: Ye,
14662
14702
  orbColors: I,
14663
14703
  primaryColor: Ae,
14664
14704
  onYes: () => {
14665
- le(z), Bt();
14705
+ ce(z), Bt();
14666
14706
  },
14667
14707
  onLater: () => {
14668
- le(z), Rt();
14708
+ ce(z), Rt();
14669
14709
  },
14670
14710
  isMobile: G,
14671
14711
  isClosing: St
@@ -14740,13 +14780,13 @@ function kg() {
14740
14780
  children: E === "connected" ? `${Ft(ut)} with ${Ze}` : `Tap to return to ${Ze}`
14741
14781
  })]
14742
14782
  })]
14743
- }), /* @__PURE__ */ g(Sg, {
14783
+ }), /* @__PURE__ */ g(Eg, {
14744
14784
  size: Me,
14745
14785
  orbColors: I,
14746
14786
  onClick: T ? At : Oe ? zt : Vt
14747
14787
  })]
14748
14788
  }),
14749
- V === "connection_modal" && /* @__PURE__ */ g(wg, {
14789
+ V === "connection_modal" && /* @__PURE__ */ g(Og, {
14750
14790
  copy: Ye,
14751
14791
  orbColors: I,
14752
14792
  primaryColor: Ae,
@@ -14756,7 +14796,7 @@ function kg() {
14756
14796
  isMobile: G,
14757
14797
  isClosing: St
14758
14798
  }),
14759
- V === "voice_mode" && /* @__PURE__ */ g(Tg, {
14799
+ V === "voice_mode" && /* @__PURE__ */ g(kg, {
14760
14800
  orbColors: I,
14761
14801
  onEnterChat: Vt,
14762
14802
  onEndChat: Ht,
@@ -14766,17 +14806,17 @@ function kg() {
14766
14806
  chatId: ee,
14767
14807
  historyRef: te,
14768
14808
  onMessageSync: ne,
14769
- voiceEndCounter: Se,
14809
+ voiceEndCounter: xe,
14770
14810
  websiteName: t?.websiteName,
14771
- voiceFirstMessage: N.voiceFirstMessage || null,
14772
- captureVisitorEmail: ae,
14811
+ voiceFirstMessage: Se.voiceFirstMessage || null,
14812
+ captureVisitorEmail: ie,
14773
14813
  emailRequired: !h,
14774
14814
  emailCaptureEnabled: P.disableEmailCapture !== !0,
14775
14815
  listeningLabel: P.voiceListeningLabel || "Listening...",
14776
14816
  enterChatModeLabel: P.voiceEnterChatLabel || "Enter Chat Mode",
14777
14817
  endConversationLabel: P.voiceEndConversationLabel || "End Conversation"
14778
14818
  }, "voice"),
14779
- V === "call_screen" && /* @__PURE__ */ g(Ch, {
14819
+ V === "call_screen" && /* @__PURE__ */ g(Dh, {
14780
14820
  incomingCall: w,
14781
14821
  activeCallId: T,
14782
14822
  callConnectionState: E,
@@ -14784,23 +14824,23 @@ function kg() {
14784
14824
  isCallMuted: O,
14785
14825
  agentName: Ze,
14786
14826
  agentHeadshot: Qe,
14787
- fallbackAgentName: L,
14788
- acceptCall: de,
14789
- rejectCall: fe,
14790
- endWebRTCCall: pe,
14791
- toggleCallMute: me,
14827
+ fallbackAgentName: Pe,
14828
+ acceptCall: ue,
14829
+ rejectCall: de,
14830
+ endWebRTCCall: fe,
14831
+ toggleCallMute: pe,
14792
14832
  formatCallDuration: Ft,
14793
14833
  onMinimize: jt,
14794
14834
  primaryColor: Ae,
14795
14835
  orbColors: I,
14796
14836
  chatHistory: r
14797
14837
  }),
14798
- V === "text_chat" && /* @__PURE__ */ g(Og, {
14838
+ V === "text_chat" && /* @__PURE__ */ g(Mg, {
14799
14839
  isClosing: St,
14800
14840
  copy: Ye,
14801
14841
  orbColors: I,
14802
14842
  primaryColor: Ae,
14803
- chatBgGradient: Pe,
14843
+ chatBgGradient: L,
14804
14844
  logo: Fe,
14805
14845
  quickChatOptions: Re,
14806
14846
  onQuickChatSelect: It,
@@ -14811,7 +14851,7 @@ function kg() {
14811
14851
  activeScreen: a,
14812
14852
  agentName: Ze,
14813
14853
  agentHeadshot: Qe,
14814
- fallbackAgentName: L,
14854
+ fallbackAgentName: Pe,
14815
14855
  input: nt,
14816
14856
  setInput: rt,
14817
14857
  onSubmit: Nt,
@@ -14834,11 +14874,11 @@ function kg() {
14834
14874
  webRTCError: k,
14835
14875
  micError: ft,
14836
14876
  setMicError: pt,
14837
- dismissCallError: he,
14877
+ dismissCallError: me,
14838
14878
  activeCallId: T,
14839
14879
  isCallMuted: O,
14840
- toggleCallMute: me,
14841
- endWebRTCCall: pe,
14880
+ toggleCallMute: pe,
14881
+ endWebRTCCall: fe,
14842
14882
  formatCallDuration: Ft,
14843
14883
  callDurationSeconds: ut,
14844
14884
  onCollapse: Rt,
@@ -14851,9 +14891,9 @@ function kg() {
14851
14891
  showPoweredBy: ze,
14852
14892
  privacyPolicyUrl: He,
14853
14893
  headerBgColor: Be,
14854
- getVisitorChatHistory: ve,
14855
- resumeChat: ye,
14856
- isSessionRestoring: be
14894
+ getVisitorChatHistory: _e,
14895
+ resumeChat: ve,
14896
+ isSessionRestoring: ye
14857
14897
  }),
14858
14898
  /* @__PURE__ */ g("style", { children: "\n /* Force any SVG (or img) inside LogoSlot to fill the container height\n regardless of whether the component forwards its style prop. */\n .fe-logo-slot svg,\n .fe-logo-slot img { height: 100%; width: auto; display: block; }\n\n @keyframes fe-orb-breathe { 0%,100%{transform:scale(1)} 50%{transform:scale(1.04)} }\n @keyframes fe-orb-breathe-subtle { 0%,100%{transform:scale(1)} 50%{transform:scale(1.025)} }\n @keyframes fe-orb-pulse { 0%{transform:scale(1);opacity:.65} 50%{transform:scale(1.28);opacity:.1} 100%{transform:scale(1);opacity:.65} }\n @keyframes fe-orb-glow { from{opacity:.35} to{opacity:.75} }\n @keyframes fe-orb-fade-in { from{opacity:0} to{opacity:1} }\n @keyframes fe-orb-slide-up { from{opacity:0;transform:translateY(18px)} to{opacity:1;transform:translateY(0)} }\n @keyframes fe-orb-slide-down { from{opacity:1;transform:translateY(0)} to{opacity:0;transform:translateY(24px)} }\n @keyframes fe-orb-bar-0 { from{height:6px} to{height:18px} }\n @keyframes fe-orb-bar-1 { from{height:10px} to{height:22px} }\n @keyframes fe-orb-bar-2 { from{height:14px} to{height:26px} }\n @keyframes fe-orb-bar-3 { from{height:8px} to{height:20px} }\n @keyframes fe-orb-bar-4 { from{height:6px} to{height:16px} }\n @keyframes fe-dot-bounce { 0%,80%,100%{transform:translateY(0);opacity:.5} 40%{transform:translateY(-5px);opacity:1} }\n " })
14859
14899
  ]
@@ -14861,7 +14901,7 @@ function kg() {
14861
14901
  }
14862
14902
  //#endregion
14863
14903
  //#region src/components/ErrorBoundary.jsx
14864
- var Ag = class extends e.Component {
14904
+ var Pg = class extends e.Component {
14865
14905
  constructor(e) {
14866
14906
  super(e), this.state = { hasError: !1 };
14867
14907
  }
@@ -14876,4 +14916,4 @@ var Ag = class extends e.Component {
14876
14916
  }
14877
14917
  };
14878
14918
  //#endregion
14879
- export { gh as AnimatedOrb, Ag as ErrorBoundary, Mr as FlowEngageProvider, kg as FlowEngageWidget, Cn as useFlowEngage };
14919
+ export { bh as AnimatedOrb, Pg as ErrorBoundary, Mr as FlowEngageProvider, Ng as FlowEngageWidget, Cn as useFlowEngage };