@flowengage/react-chatbot 8.0.69 → 8.0.71

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.
@@ -26,7 +26,7 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
26
26
  }, D = (e, t) => {
27
27
  let n = Number.parseInt(String(e ?? ""), 10);
28
28
  return Number.isFinite(n) && n > 0 ? n : t;
29
- }, O = D(void 0, 1e4), k = D(void 0, 15e3), A = {
29
+ }, ee = D(void 0, 1e4), O = D(void 0, 15e3), k = {
30
30
  chatId: "flowengage.chatId",
31
31
  isOpen: "flowengage.isOpen",
32
32
  activeScreen: "flowengage.activeScreen",
@@ -34,29 +34,29 @@ 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 = () => {
38
- if (!j) return null;
39
- let e = window.localStorage.getItem(A.chatId);
37
+ }, te = 6e4, ne = 480 * 60, re = 3e4, A = typeof window < "u", ie = (e) => e ? `flowengage.visitorEmail.${e}` : null, j = () => {
38
+ if (!A) return null;
39
+ let e = window.localStorage.getItem(k.chatId);
40
40
  return e && String(e).trim() ? String(e).trim() : null;
41
- }, M = () => {
42
- if (j) try {
43
- window.localStorage.removeItem(A.chatId);
41
+ }, ae = () => {
42
+ if (A) try {
43
+ window.localStorage.removeItem(k.chatId);
44
44
  } catch {}
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
- if (!j || !e) return !1;
45
+ }, oe = () => A ? typeof crypto < "u" && crypto.randomUUID ? crypto.randomUUID() : `${Date.now()}-${Math.random().toString(16).slice(2)}` : "server-chat-id", M = (e) => e ? `flowengage.entrySeen.${e}` : null, se = (e) => {
46
+ if (!A || !e) return !1;
47
47
  try {
48
- let t = oe(e);
48
+ let t = M(e);
49
49
  return t ? window.localStorage.getItem(t) === "1" : !1;
50
50
  } catch {
51
51
  return !1;
52
52
  }
53
53
  }, ce = (e) => {
54
- if (!(!j || !e)) try {
55
- let t = oe(e);
54
+ if (!(!A || !e)) try {
55
+ let t = M(e);
56
56
  t && window.localStorage.setItem(t, "1");
57
57
  } catch {}
58
58
  }, le = (e) => e ? `flowengage.persistedChatId.${e}` : null, ue = (e) => {
59
- if (!j || !e) return null;
59
+ if (!A || !e) return null;
60
60
  try {
61
61
  let t = le(e), n = t ? window.localStorage.getItem(t) : null;
62
62
  return n && String(n).trim() ? String(n).trim() : null;
@@ -64,21 +64,21 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
64
64
  return null;
65
65
  }
66
66
  }, de = (e) => {
67
- if (!(!j || !e)) try {
67
+ if (!(!A || !e)) try {
68
68
  let t = le(e);
69
69
  t && window.localStorage.removeItem(t);
70
70
  } catch {}
71
71
  }, fe = (e, t) => {
72
- if (!(!j || !e || !t)) try {
72
+ if (!(!A || !e || !t)) try {
73
73
  let n = le(e);
74
74
  n && window.localStorage.setItem(n, String(t).trim());
75
75
  } catch {}
76
- }, pe = () => j ? {
76
+ }, pe = () => A ? {
77
77
  isOpen: !1,
78
- activeScreen: window.sessionStorage.getItem(A.activeScreen) || "ai",
79
- isHumanHandled: window.sessionStorage.getItem(A.isHumanHandled) === "true",
80
- agentName: window.sessionStorage.getItem(A.agentName),
81
- agentHeadshot: window.sessionStorage.getItem(A.agentHeadshot),
78
+ activeScreen: window.sessionStorage.getItem(k.activeScreen) || "ai",
79
+ isHumanHandled: window.sessionStorage.getItem(k.isHumanHandled) === "true",
80
+ agentName: window.sessionStorage.getItem(k.agentName),
81
+ agentHeadshot: window.sessionStorage.getItem(k.agentHeadshot),
82
82
  visitorEmail: ""
83
83
  } : {
84
84
  isOpen: !1,
@@ -88,8 +88,8 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
88
88
  agentHeadshot: null,
89
89
  visitorEmail: ""
90
90
  }, me = (e) => {
91
- j && Object.entries(e).forEach(([e, t]) => {
92
- let n = A[e];
91
+ A && Object.entries(e).forEach(([e, t]) => {
92
+ let n = k[e];
93
93
  if (n) {
94
94
  if (t == null || t === !1) {
95
95
  window.sessionStorage.removeItem(n);
@@ -99,25 +99,25 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
99
99
  }
100
100
  });
101
101
  }, he = (e) => {
102
- if (!j || !e) return "";
103
- let t = re(e), n = window.localStorage.getItem(t);
102
+ if (!A || !e) return "";
103
+ let t = ie(e), n = window.localStorage.getItem(t);
104
104
  if (!n) {
105
- let e = window.sessionStorage.getItem(A.visitorEmail);
106
- e && (window.localStorage.setItem(t, e), window.sessionStorage.removeItem(A.visitorEmail), n = e);
105
+ let e = window.sessionStorage.getItem(k.visitorEmail);
106
+ e && (window.localStorage.setItem(t, e), window.sessionStorage.removeItem(k.visitorEmail), n = e);
107
107
  }
108
108
  return n || "";
109
109
  }, N = (e, t) => {
110
- if (!j) return;
111
- let n = re(t);
110
+ if (!A) return;
111
+ let n = ie(t);
112
112
  if (!n) return;
113
113
  let r = typeof e == "string" ? e.trim() : "";
114
114
  if (!r) {
115
- window.localStorage.removeItem(n), window.sessionStorage.removeItem(A.visitorEmail);
115
+ window.localStorage.removeItem(n), window.sessionStorage.removeItem(k.visitorEmail);
116
116
  return;
117
117
  }
118
- window.localStorage.setItem(n, r), window.sessionStorage.removeItem(A.visitorEmail);
118
+ window.localStorage.setItem(n, r), window.sessionStorage.removeItem(k.visitorEmail);
119
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
- if (!j || !e) return null;
120
+ if (!A || !e) return null;
121
121
  try {
122
122
  let t = ge(e), n = t ? window.localStorage.getItem(t) : null;
123
123
  return n && String(n).trim() ? String(n).trim() : null;
@@ -125,7 +125,7 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
125
125
  return null;
126
126
  }
127
127
  }, ye = (e) => {
128
- if (!j || !e) return null;
128
+ if (!A || !e) return null;
129
129
  try {
130
130
  let t = ve(e);
131
131
  if (t) return t;
@@ -135,7 +135,7 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
135
135
  return _e();
136
136
  }
137
137
  }, be = "flowengage.tabId", xe = () => {
138
- if (!j) return "default";
138
+ if (!A) return "default";
139
139
  try {
140
140
  let e = window.sessionStorage.getItem(be);
141
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;
@@ -143,7 +143,7 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
143
143
  return "default";
144
144
  }
145
145
  }, Se = (e) => e ? `flowengage.voice.transcript.${e}.${xe()}` : null, Ce = 600 * 1e3, P = (e, t, n = {}) => {
146
- if (!j || !e) return;
146
+ if (!A || !e) return;
147
147
  let r = typeof t == "string" ? t.trim() : "";
148
148
  if (!r) return;
149
149
  let i = Number.isFinite(n.ttlMs) ? n.ttlMs : Ce, a = {
@@ -155,7 +155,7 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
155
155
  t && window.localStorage.setItem(t, JSON.stringify(a));
156
156
  } catch {}
157
157
  }, we = (e) => {
158
- if (!j || !e) return null;
158
+ if (!A || !e) return null;
159
159
  try {
160
160
  let t = Se(e), n = t ? window.localStorage.getItem(t) : null;
161
161
  if (!n) return null;
@@ -165,41 +165,41 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
165
165
  return null;
166
166
  }
167
167
  }, Te = (e) => {
168
- if (!(!j || !e)) try {
168
+ if (!(!A || !e)) try {
169
169
  let t = Se(e);
170
170
  t && window.localStorage.removeItem(t);
171
171
  } catch {}
172
172
  }, F = "flowengage.voice.pendingResume", Ee = () => {
173
- if (j) try {
173
+ if (A) try {
174
174
  window.sessionStorage.setItem(F, "1");
175
175
  } catch {}
176
176
  }, De = () => {
177
- if (!j) return !1;
177
+ if (!A) return !1;
178
178
  try {
179
179
  return window.sessionStorage.getItem(F) === "1" ? (window.sessionStorage.removeItem(F), !0) : !1;
180
180
  } catch {
181
181
  return !1;
182
182
  }
183
183
  }, Oe = "flowengage.chat.pendingReopen", I = () => {
184
- if (j) try {
184
+ if (A) try {
185
185
  window.sessionStorage.setItem(Oe, "1");
186
186
  } catch {}
187
187
  }, ke = () => {
188
- if (!j) return !1;
188
+ if (!A) return !1;
189
189
  try {
190
190
  return window.sessionStorage.getItem(Oe) === "1" ? (window.sessionStorage.removeItem(Oe), !0) : !1;
191
191
  } catch {
192
192
  return !1;
193
193
  }
194
194
  }, Ae = () => {
195
- if (!j) return !1;
195
+ if (!A) return !1;
196
196
  try {
197
197
  return window.sessionStorage.getItem(F) === "1";
198
198
  } catch {
199
199
  return !1;
200
200
  }
201
201
  }, je = (e) => e ? `flowengage.voice.navState.${e}.${xe()}` : null, Me = (e, t, n, r) => {
202
- if (!(!j || !e || !t)) try {
202
+ if (!(!A || !e || !t)) try {
203
203
  let i = je(e);
204
204
  i && window.sessionStorage.setItem(i, JSON.stringify({
205
205
  previousPage: String(t),
@@ -209,7 +209,7 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
209
209
  }));
210
210
  } catch {}
211
211
  }, Ne = (e) => {
212
- if (!j || !e) return null;
212
+ if (!A || !e) return null;
213
213
  try {
214
214
  let t = je(e);
215
215
  if (!t) return null;
@@ -1951,7 +1951,7 @@ var bn = ({ apiBaseUrl: e, userId: t, chatId: n, siteId: r }) => yn(e, {
1951
1951
  timestamp: Date.now()
1952
1952
  });
1953
1953
  }, u = () => {
1954
- i && window.clearInterval(i), i = window.setInterval(l, O);
1954
+ i && window.clearInterval(i), i = window.setInterval(l, ee);
1955
1955
  }, d = () => {
1956
1956
  i &&= (window.clearInterval(i), null);
1957
1957
  }, f = (r) => {
@@ -1969,7 +1969,7 @@ var bn = ({ apiBaseUrl: e, userId: t, chatId: n, siteId: r }) => yn(e, {
1969
1969
  if (document.hidden) {
1970
1970
  a && window.clearTimeout(a), a = window.setTimeout(() => {
1971
1971
  a = null, d(), f("hidden");
1972
- }, k);
1972
+ }, O);
1973
1973
  return;
1974
1974
  }
1975
1975
  a &&= (window.clearTimeout(a), null), f("visible"), l(), u();
@@ -2001,7 +2001,7 @@ var bn = ({ apiBaseUrl: e, userId: t, chatId: n, siteId: r }) => yn(e, {
2001
2001
  };
2002
2002
  return window.addEventListener("popstate", m), window.addEventListener("hashchange", m), window.addEventListener("beforeunload", v), window.addEventListener("pagehide", y), window.addEventListener("visibilitychange", p), o(), document.hidden ? a = window.setTimeout(() => {
2003
2003
  a = null, d(), f("hidden");
2004
- }, k) : (l(), u()), {
2004
+ }, O) : (l(), u()), {
2005
2005
  notifyRouteChange: m,
2006
2006
  cleanup: () => {
2007
2007
  a &&= (window.clearTimeout(a), null), d(), window.history.pushState = h, window.history.replaceState = g, window.removeEventListener("popstate", m), window.removeEventListener("hashchange", m), window.removeEventListener("beforeunload", v), window.removeEventListener("pagehide", y), window.removeEventListener("visibilitychange", p);
@@ -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(pe().isOpen), [O, k] = m(pe().activeScreen), [A, j] = m(pe().isHumanHandled), [re, 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({
2922
+ }, []), [T, D] = m(pe().isOpen), [ee, O] = m(pe().activeScreen), [k, A] = m(pe().isHumanHandled), [ie, M] = 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,21 +2935,21 @@ 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(ie), _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 && oe(e.agent_info.name), e.agent_info?.headshot && ce(e.agent_info.headshot), t) : (k("ai"), t);
2943
+ return A(t), t ? (O("agent"), e.agent_info?.name && M(e.agent_info.name), e.agent_info?.headshot && ce(e.agent_info.headshot), t) : (O("ai"), t);
2944
2944
  }, []), Ct = f(() => {
2945
2945
  let e = _?.widgetSettings?.call?.maxDurationSeconds ?? i?.widgetSettings?.call?.maxDurationSeconds ?? i?.callMaxDurationSeconds, t = Number(e);
2946
- return Number.isFinite(t) && t > 0 ? t : te;
2946
+ return Number.isFinite(t) && t > 0 ? t : ne;
2947
2947
  }, [i, _]);
2948
2948
  c(() => {
2949
2949
  et.current = R;
2950
2950
  }, [R]), c(() => {
2951
- gt.current = re;
2952
- }, [re]), c(() => {
2951
+ gt.current = ie;
2952
+ }, [ie]), c(() => {
2953
2953
  yt.current = I;
2954
2954
  }, [I]), c(() => {
2955
2955
  bt.current = i;
@@ -3102,16 +3102,16 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
3102
3102
  c(() => {
3103
3103
  me({
3104
3104
  isOpen: T,
3105
- activeScreen: O,
3106
- isHumanHandled: A,
3107
- agentName: re,
3105
+ activeScreen: ee,
3106
+ isHumanHandled: k,
3107
+ agentName: ie,
3108
3108
  agentHeadshot: se
3109
3109
  });
3110
3110
  }, [
3111
3111
  T,
3112
- O,
3113
- A,
3114
- re,
3112
+ ee,
3113
+ k,
3114
+ ie,
3115
3115
  se
3116
3116
  ]), c(() => {
3117
3117
  let e = !0;
@@ -3127,14 +3127,14 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
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 || j(),
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
- M(), fe(a, c);
3135
+ ae(), 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 || ae(), fe(a, c);
3137
+ console.warn("[FlowEngageProvider] resolve-session failed, reusing persisted or ephemeral chat id", e?.message || e), c = o || oe(), fe(a, c);
3138
3138
  }
3139
3139
  Ze.current = c;
3140
3140
  let l = Le({
@@ -3200,7 +3200,7 @@ 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"), oe(Ar([
3203
+ }]), (n.sender === "agent" || n.agent_name) && (A(!0), O("agent"), M(Ar([
3204
3204
  n.agent_name,
3205
3205
  n.agentName,
3206
3206
  n.metadata?.agentName
@@ -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"), oe(t), ce(e.agent?.headshot || null), D(!0), je((e) => e + 1), S((e) => jr(e, {
3216
+ A(!0), O("agent"), M(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.`,
@@ -3227,7 +3227,7 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
3227
3227
  e.agent_name,
3228
3228
  gt.current
3229
3229
  ], d);
3230
- j(!1), k("ai"), S((e) => jr(e, {
3230
+ A(!1), O("ai"), S((e) => jr(e, {
3231
3231
  id: `agent-left-${Date.now()}`,
3232
3232
  sender: "system",
3233
3233
  message: `${t} has left the chat.`,
@@ -3247,9 +3247,9 @@ 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 && (L(!1), j(!1), k("ai"), xe(!1), ve(!1));
3250
+ S(t), t.length === 0 && (L(!1), A(!1), O("ai"), xe(!1), ve(!1));
3251
3251
  }), f.on("conversation:reset", () => {
3252
- S([]), L(!1), j(!1), k("ai"), xe(!1), ve(!1);
3252
+ S([]), L(!1), A(!1), O("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) => {
@@ -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
- }), oe((e) => Ar([t, e], "Agent")), He("incoming"), We(null), D(!0);
3271
+ }), M((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 {
@@ -3343,7 +3343,7 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
3343
3343
  });
3344
3344
  let h = await l.loadHistory(c, r);
3345
3345
  if (!e) return;
3346
- S(Er(h.chat_history || [])), j(!!h.is_human_handled), k(h.is_human_handled ? "agent" : O);
3346
+ S(Er(h.chat_history || [])), A(!!h.is_human_handled), O(h.is_human_handled ? "agent" : ee);
3347
3347
  let g = h?.visitor_email || h?.visitorEmail;
3348
3348
  if (g && String(g).trim() && Et(String(g).trim()), await new Promise((e) => setTimeout(e, 500)), !e) return;
3349
3349
  u("ready");
@@ -3499,7 +3499,7 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
3499
3499
  let e = R.callId;
3500
3500
  return Tt(), ct.current = window.setTimeout(() => {
3501
3501
  et.current?.callId === e && st.current !== e && W.current !== e && Pt.current();
3502
- }, ne), () => {
3502
+ }, re), () => {
3503
3503
  ct.current &&= (window.clearTimeout(ct.current), null);
3504
3504
  };
3505
3505
  }, [
@@ -3611,7 +3611,7 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
3611
3611
  ...n || {}
3612
3612
  };
3613
3613
  S((e) => [...e, d]);
3614
- let f = A;
3614
+ let f = k;
3615
3615
  if (f) try {
3616
3616
  f = St(await B.current.checkHumanHandled(y));
3617
3617
  } catch {}
@@ -3700,11 +3700,11 @@ 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"), xe(!1), we(!1), await B.current.updateChatStatus(y, "messageSent");
3703
+ S(Er(s)), A(!!o.is_human_handled), O(o.is_human_handled ? "agent" : "ai"), xe(!1), we(!1), await B.current.updateChatStatus(y, "messageSent");
3704
3704
  } catch (e) {
3705
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
- }, ee)) : h(e);
3707
+ }, te)) : h(e);
3708
3708
  }
3709
3709
  }, Wt = async (e) => {
3710
3710
  if (!B.current || !e) throw Error("Upload is unavailable right now.");
@@ -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
- 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);
3798
+ de(e), Qe.current = !0, $e.current = null, z.current?.disconnect(), S([]), b(""), Ze.current = "", L(!1), A(!1), M(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 = "", L(!1), j(!1), oe(null), ce(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), A(!1), M(null), ce(null), Xe(!0), s((e) => e + 1);
3801
3801
  }, [i?.siteId]), Xt = f(() => ({
3802
3802
  status: l,
3803
3803
  error: d,
@@ -3806,9 +3806,9 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
3806
3806
  chatId: y,
3807
3807
  chatHistory: x,
3808
3808
  isOpen: T,
3809
- activeScreen: O,
3810
- isHumanHandled: A,
3811
- agentName: re,
3809
+ activeScreen: ee,
3810
+ isHumanHandled: k,
3811
+ agentName: ie,
3812
3812
  agentHeadshot: se,
3813
3813
  visitorEmail: le,
3814
3814
  isAgentTyping: _e,
@@ -3867,9 +3867,9 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
3867
3867
  y,
3868
3868
  x,
3869
3869
  T,
3870
- O,
3871
- A,
3872
- re,
3870
+ ee,
3871
+ k,
3872
+ ie,
3873
3873
  se,
3874
3874
  le,
3875
3875
  _e,
@@ -8845,32 +8845,45 @@ function Dm(e) {
8845
8845
  for (let n = 0; n < e.length; n++) t[n] = e[n] / 32768;
8846
8846
  return t;
8847
8847
  }
8848
- var Om = .09;
8849
- function km(e, t) {
8850
- let n = 0, r = 0, i = [], a = () => {
8851
- i.forEach((e) => {
8848
+ var Om = .09, km = ["audio/webm", "audio/mp4"];
8849
+ function Am() {
8850
+ return typeof window > "u" || window.MediaRecorder === void 0 ? null : km.find((e) => window.MediaRecorder.isTypeSupported(e)) || null;
8851
+ }
8852
+ function jm(e, t, n, r, i) {
8853
+ if (!r.length || !n || !e) return;
8854
+ let a = new Blob(r, { type: i }), o = new FormData();
8855
+ o.append("audio", a, `aichat-${n}.webm`), o.append("voiceSessionId", n), o.append("siteId", t || ""), fetch(`${e}/api/voice/upload-chat-recording`, {
8856
+ method: "POST",
8857
+ body: o
8858
+ }).then((e) => {
8859
+ if (!e.ok) throw Error(`HTTP ${e.status}`);
8860
+ }).catch((e) => console.warn("[FlowEngage] voice recording upload failed:", e.message));
8861
+ }
8862
+ function Mm(e, t, n) {
8863
+ let r = 0, i = 0, a = [], o = () => {
8864
+ a.forEach((e) => {
8852
8865
  try {
8853
8866
  e.stop();
8854
8867
  } catch {}
8855
- }), i = [], n = 0;
8856
- }, o = () => n > e.currentTime;
8868
+ }), a = [], r = 0;
8869
+ }, s = () => r > e.currentTime;
8857
8870
  return {
8858
- enqueue: (a) => {
8859
- let s = Dm(a), c = e.createBuffer(1, s.length, bm);
8860
- c.copyToChannel(s, 0);
8861
- let l = e.createBufferSource();
8862
- l.buffer = c, l.connect(e.destination);
8863
- let u = !o(), d = u ? e.currentTime + Om : n;
8864
- u && (r = d), l.start(d), n = d + c.duration, i.push(l), l.onended = () => {
8865
- i = i.filter((e) => e !== l), !i.length && !o() && t?.();
8871
+ enqueue: (o) => {
8872
+ let c = Dm(o), l = e.createBuffer(1, c.length, bm);
8873
+ l.copyToChannel(c, 0);
8874
+ let u = e.createBufferSource();
8875
+ u.buffer = l, u.connect(e.destination), n && u.connect(n);
8876
+ let d = !s(), f = d ? e.currentTime + Om : r;
8877
+ d && (i = f), u.start(f), r = f + l.duration, a.push(u), u.onended = () => {
8878
+ a = a.filter((e) => e !== u), !a.length && !s() && t?.();
8866
8879
  };
8867
8880
  },
8868
- stop: a,
8869
- isPlaying: o,
8870
- playedMs: () => Math.max(0, (e.currentTime - r) * 1e3)
8881
+ stop: o,
8882
+ isPlaying: s,
8883
+ playedMs: () => Math.max(0, (e.currentTime - i) * 1e3)
8871
8884
  };
8872
8885
  }
8873
- async function Am(e, t, n) {
8886
+ async function Nm(e, t, n) {
8874
8887
  let r = new URLSearchParams({ siteId: t || "" });
8875
8888
  n && r.set("chatId", n);
8876
8889
  let i = await fetch(`${e}/api/voice/session?${r.toString()}`, {
@@ -8886,8 +8899,8 @@ async function Am(e, t, n) {
8886
8899
  if (!a?.success || !a.wsUrl) throw Error(a?.error || "Voice session was refused.");
8887
8900
  return a;
8888
8901
  }
8889
- async function jm(e) {
8890
- 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);
8902
+ async function Pm(e) {
8903
+ 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 Nm(t, n, r);
8891
8904
  f?.({ emailOnFile: !!m.emailOnFile });
8892
8905
  let h = { type: "Start" };
8893
8906
  e.greeting !== void 0 && (h.greeting = e.greeting || null);
@@ -8898,83 +8911,99 @@ async function jm(e) {
8898
8911
  autoGainControl: !0
8899
8912
  } }), _ = new (window.AudioContext || window.webkitAudioContext)({ sampleRate: bm });
8900
8913
  _.state === "suspended" && await _.resume();
8901
- let v = new WebSocket(m.wsUrl);
8902
- v.binaryType = "arraybuffer";
8903
- let y = /* @__PURE__ */ new Set(), b = {
8914
+ let v = _.createMediaStreamDestination(), y = Am(), b = [], x = null, S = r || n || null;
8915
+ y && (x = new window.MediaRecorder(v.stream, { mimeType: y }), x.ondataavailable = (e) => {
8916
+ e.data && e.data.size > 0 && b.push(e.data);
8917
+ }, x.start());
8918
+ let C = new WebSocket(m.wsUrl);
8919
+ C.binaryType = "arraybuffer";
8920
+ let w = /* @__PURE__ */ new Set(), T = {
8904
8921
  role: null,
8905
8922
  text: "",
8906
- timer: null
8907
- }, x = "", S = () => {
8908
- b.timer &&= (clearTimeout(b.timer), null);
8909
- let e = b.text.trim(), t = b.role;
8910
- if (b.text = "", b.role = null, !(!e || !t)) {
8923
+ timer: null,
8924
+ debug: null
8925
+ }, E = "", D = () => {
8926
+ T.timer &&= (clearTimeout(T.timer), null);
8927
+ let e = T.text.trim(), t = T.role, n = T.debug;
8928
+ if (T.text = "", T.role = null, T.debug = null, !(!e || !t)) {
8911
8929
  if (t === "agent") {
8912
- if (e === x) {
8930
+ if (e === E) {
8913
8931
  console.debug("[FlowEngage] duplicate agent turn suppressed");
8914
8932
  return;
8915
8933
  }
8916
- x = e;
8934
+ E = e;
8917
8935
  }
8918
8936
  s?.({
8919
8937
  role: t,
8920
- message: e
8938
+ message: e,
8939
+ debug: n
8921
8940
  });
8922
8941
  }
8923
- }, C = (e, t) => {
8924
- 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));
8925
- }, w = !1, T = !1, E = !1, D = !1, O = !0, k = 0, A = !1, ee = !1, te = Cm, ne = wm, j = null, re = !1, ie = () => {
8926
- j && clearTimeout(j);
8942
+ }, ee = (e, t, n) => {
8943
+ t && (T.role && T.role !== e && D(), T.role = e, T.text = T.text ? `${T.text} ${t}`.replace(/\s+/g, " ") : t, n && (T.debug = n), T.timer && clearTimeout(T.timer), T.timer = setTimeout(D, Sm));
8944
+ }, O = !1, k = !1, te = !1, ne = !1, re = !0, A = 0, ie = !1, j = !1, ae = Cm, oe = wm, M = null, se = !1, ce = () => {
8945
+ M && clearTimeout(M);
8927
8946
  let e = () => {
8928
- if (!w) {
8929
- if (M.isPlaying()) {
8930
- j = setTimeout(e, 150);
8947
+ if (!O) {
8948
+ if (le.isPlaying()) {
8949
+ M = setTimeout(e, 150);
8931
8950
  return;
8932
8951
  }
8933
- if (j = null, re) {
8952
+ if (M = null, se) {
8934
8953
  p?.();
8935
8954
  return;
8936
8955
  }
8937
- !w && v.readyState === WebSocket.OPEN && v.send(JSON.stringify({ type: "PlaybackDrained" })), d?.();
8956
+ !O && C.readyState === WebSocket.OPEN && C.send(JSON.stringify({ type: "PlaybackDrained" })), d?.();
8938
8957
  }
8939
8958
  };
8940
- j = setTimeout(e, 150);
8941
- }, M = km(_, () => {
8942
- D && (D = !1, c?.({ mode: "listening" }));
8943
- }), ae = _.createMediaStreamSource(g), oe = _.createScriptProcessor(xm, 1, 1);
8944
- oe.onaudioprocess = (e) => {
8945
- if (w || v.readyState !== WebSocket.OPEN) return;
8946
- let t = e.inputBuffer.getChannelData(0), n = () => v.send(new Int16Array(t.length).buffer);
8947
- if (T) {
8948
- E || (E = !0, console.debug("[FlowEngage] mic held streaming silence to keep socket alive")), n();
8959
+ M = setTimeout(e, 150);
8960
+ }, le = Mm(_, () => {
8961
+ ne && (ne = !1, c?.({ mode: "listening" }));
8962
+ }, v), ue = _.createMediaStreamSource(g);
8963
+ ue.connect(v);
8964
+ let de = _.createScriptProcessor(xm, 1, 1);
8965
+ de.onaudioprocess = (e) => {
8966
+ if (O || C.readyState !== WebSocket.OPEN) return;
8967
+ let t = e.inputBuffer.getChannelData(0), n = () => C.send(new Int16Array(t.length).buffer);
8968
+ if (k) {
8969
+ te || (te = !0, console.debug("[FlowEngage] mic held — streaming silence to keep socket alive")), n();
8949
8970
  return;
8950
8971
  }
8951
- if ((M.isPlaying() || ee) && !A) {
8952
- if (Tm(t) < te) {
8953
- k = 0, n();
8972
+ if ((le.isPlaying() || j) && !ie) {
8973
+ if (Tm(t) < ae) {
8974
+ A = 0, n();
8954
8975
  return;
8955
8976
  }
8956
- if (k += 1, k < ne) {
8977
+ if (A += 1, A < oe) {
8957
8978
  n();
8958
8979
  return;
8959
8980
  }
8960
- A = !0, k = 0;
8961
- let e = M.playedMs();
8962
- M.stop(), O = !1, ee = !1, v.send(JSON.stringify({
8981
+ ie = !0, A = 0;
8982
+ let e = le.playedMs();
8983
+ le.stop(), re = !1, j = !1, C.send(JSON.stringify({
8963
8984
  type: "VisitorInterrupted",
8964
8985
  played_ms: Math.round(e)
8965
8986
  })), console.debug("[FlowEngage] barge-in — visitor spoke over the agent");
8966
8987
  }
8967
- v.send(Em(t).buffer);
8968
- }, ae.connect(oe), oe.connect(_.destination);
8969
- let se = () => {
8970
- if (!w) {
8971
- w = !0, j &&= (clearTimeout(j), null), S(), M.stop();
8988
+ C.send(Em(t).buffer);
8989
+ }, ue.connect(de), de.connect(_.destination);
8990
+ let fe = () => {
8991
+ if (!O) {
8992
+ O = !0, M &&= (clearTimeout(M), null), D(), le.stop();
8972
8993
  try {
8973
- oe.disconnect(), ae.disconnect();
8994
+ de.disconnect(), ue.disconnect();
8974
8995
  } catch {}
8975
- g.getTracks().forEach((e) => e.stop()), _.close().catch(() => {}), (v.readyState === WebSocket.OPEN || v.readyState === WebSocket.CONNECTING) && v.close();
8996
+ if (g.getTracks().forEach((e) => e.stop()), x && x.state !== "inactive") {
8997
+ x.onstop = () => jm(t, n, S, b, y);
8998
+ try {
8999
+ x.stop();
9000
+ } catch {
9001
+ x.onstop = null;
9002
+ }
9003
+ } else b.length && jm(t, n, S, b, y);
9004
+ _.close().catch(() => {}), (C.readyState === WebSocket.OPEN || C.readyState === WebSocket.CONNECTING) && C.close();
8976
9005
  }
8977
- }, ce = async (e) => {
9006
+ }, pe = async (e) => {
8978
9007
  let t = i[e.name];
8979
9008
  if (!t) return u?.({ tool_name: e.name }), { error: `Unknown tool ${e.name}` };
8980
9009
  let n = {};
@@ -8986,29 +9015,29 @@ async function jm(e) {
8986
9015
  } catch (e) {
8987
9016
  return { error: e?.message || "Tool execution failed" };
8988
9017
  }
8989
- }, le = async (e) => {
9018
+ }, me = async (e) => {
8990
9019
  for (let t of e.functions || []) {
8991
9020
  if (!t.client_side) continue;
8992
- let e = await ce(t);
8993
- if (w || v.readyState !== WebSocket.OPEN) return;
8994
- v.send(JSON.stringify({
9021
+ let e = await pe(t);
9022
+ if (O || C.readyState !== WebSocket.OPEN) return;
9023
+ C.send(JSON.stringify({
8995
9024
  type: "FunctionCallResponse",
8996
9025
  id: t.id,
8997
9026
  name: t.name,
8998
9027
  content: typeof e == "string" ? e : JSON.stringify(e ?? {})
8999
9028
  }));
9000
9029
  }
9001
- }, ue = (e) => {
9030
+ }, he = (e) => {
9002
9031
  switch (e.type) {
9003
9032
  case "Welcome":
9004
- Number.isFinite(e.barge_in_rms) && e.barge_in_rms > 0 && (te = e.barge_in_rms), Number.isFinite(e.barge_in_frames) && e.barge_in_frames > 0 && (ne = e.barge_in_frames), a?.({ conversationId: e.session_id || r || n });
9033
+ Number.isFinite(e.barge_in_rms) && e.barge_in_rms > 0 && (ae = e.barge_in_rms), Number.isFinite(e.barge_in_frames) && e.barge_in_frames > 0 && (oe = e.barge_in_frames), S = e.session_id || r || n || null, a?.({ conversationId: S });
9005
9034
  break;
9006
9035
  case "ConversationText": {
9007
9036
  let t = String(e.content || "");
9008
9037
  if (e.role === "user") {
9009
9038
  let e = t.trim();
9010
- if (y.has(e)) {
9011
- y.delete(e);
9039
+ if (w.has(e)) {
9040
+ w.delete(e);
9012
9041
  break;
9013
9042
  }
9014
9043
  if (/^\[SYSTEM:/i.test(e) || /^Continue (now )?to the next section/i.test(e) || /^That was the last section/i.test(e)) {
@@ -9016,26 +9045,26 @@ async function jm(e) {
9016
9045
  break;
9017
9046
  }
9018
9047
  }
9019
- C(e.role === "user" ? "user" : "agent", t);
9048
+ ee(e.role === "user" ? "user" : "agent", t, e.debug);
9020
9049
  break;
9021
9050
  }
9022
9051
  case "UserStartedSpeaking":
9023
- S(), M.stop(), ee = !1, O = !1, D = !1, c?.({ mode: "listening" });
9052
+ D(), le.stop(), j = !1, re = !1, ne = !1, c?.({ mode: "listening" });
9024
9053
  break;
9025
9054
  case "AgentStartedSpeaking":
9026
- O = !0, D = !0, A = !1, k = 0, c?.({ mode: "speaking" });
9055
+ re = !0, ne = !0, ie = !1, A = 0, c?.({ mode: "speaking" });
9027
9056
  break;
9028
9057
  case "AgentAudioDone":
9029
- ee = !1, S(), ie(), M.isPlaying() || (D = !1, c?.({ mode: "listening" }));
9058
+ j = !1, D(), ce(), le.isPlaying() || (ne = !1, c?.({ mode: "listening" }));
9030
9059
  break;
9031
9060
  case "FunctionCallRequest":
9032
- le(e);
9061
+ me(e);
9033
9062
  break;
9034
9063
  case "AgentPreparing":
9035
- ee = !0;
9064
+ j = !0;
9036
9065
  break;
9037
9066
  case "SessionEnding":
9038
- console.debug("[FlowEngage] server is ending the session:", e.reason || "unspecified"), re = !0;
9067
+ console.debug("[FlowEngage] server is ending the session:", e.reason || "unspecified"), se = !0;
9039
9068
  break;
9040
9069
  case "PromptUpdated":
9041
9070
  case "AgentThinking": break;
@@ -9048,56 +9077,56 @@ async function jm(e) {
9048
9077
  default: break;
9049
9078
  }
9050
9079
  };
9051
- return v.onopen = () => v.send(JSON.stringify(h)), v.onmessage = (e) => {
9080
+ return C.onopen = () => C.send(JSON.stringify(h)), C.onmessage = (e) => {
9052
9081
  if (e.data instanceof ArrayBuffer) {
9053
- O && M.enqueue(new Int16Array(e.data));
9082
+ re && le.enqueue(new Int16Array(e.data));
9054
9083
  return;
9055
9084
  }
9056
9085
  try {
9057
- ue(JSON.parse(e.data));
9086
+ he(JSON.parse(e.data));
9058
9087
  } catch {}
9059
- }, v.onerror = () => l?.(/* @__PURE__ */ Error("Voice connection failed")), v.onclose = () => {
9060
- se(), o?.();
9088
+ }, C.onerror = () => l?.(/* @__PURE__ */ Error("Voice connection failed")), C.onclose = () => {
9089
+ fe(), o?.();
9061
9090
  }, {
9062
- endSession: async () => se(),
9091
+ endSession: async () => fe(),
9063
9092
  sendContextualUpdate: (e) => {
9064
- w || v.readyState !== WebSocket.OPEN || !e || v.send(JSON.stringify({
9093
+ O || C.readyState !== WebSocket.OPEN || !e || C.send(JSON.stringify({
9065
9094
  type: "UpdatePrompt",
9066
9095
  prompt: e
9067
9096
  }));
9068
9097
  },
9069
9098
  sendUserMessage: (e, { silent: t = !0, suppressQuestion: n = !1 } = {}) => {
9070
- w || v.readyState !== WebSocket.OPEN || !e || (t && y.add(e.trim()), v.send(JSON.stringify({
9099
+ O || C.readyState !== WebSocket.OPEN || !e || (t && w.add(e.trim()), C.send(JSON.stringify({
9071
9100
  type: "InjectUserMessage",
9072
9101
  content: e,
9073
9102
  suppress_question: n
9074
9103
  })));
9075
9104
  },
9076
9105
  injectAgentSpeech: (e, t = "interrupt") => {
9077
- w || v.readyState !== WebSocket.OPEN || !e || v.send(JSON.stringify({
9106
+ O || C.readyState !== WebSocket.OPEN || !e || C.send(JSON.stringify({
9078
9107
  type: "InjectAgentMessage",
9079
9108
  message: e,
9080
9109
  behavior: t
9081
9110
  }));
9082
9111
  },
9083
9112
  setWalkthroughActive: (e) => {
9084
- w || v.readyState !== WebSocket.OPEN || v.send(JSON.stringify({
9113
+ O || C.readyState !== WebSocket.OPEN || C.send(JSON.stringify({
9085
9114
  type: "WalkthroughActive",
9086
9115
  active: !!e
9087
9116
  }));
9088
9117
  },
9089
9118
  setMicMuted: (e) => {
9090
- T = !!e, !w && v.readyState === WebSocket.OPEN && v.send(JSON.stringify({
9119
+ k = !!e, !O && C.readyState === WebSocket.OPEN && C.send(JSON.stringify({
9091
9120
  type: "MicHeld",
9092
- held: T
9121
+ held: k
9093
9122
  }));
9094
9123
  },
9095
9124
  get status() {
9096
- return w ? "disconnected" : "connected";
9125
+ return O ? "disconnected" : "connected";
9097
9126
  }
9098
9127
  };
9099
9128
  }
9100
- var Mm = { startSession: jm }, Nm = ({ size: e = 18, color: t = "currentColor" }) => /* @__PURE__ */ _("svg", {
9129
+ var Fm = { startSession: Pm }, Im = ({ size: e = 18, color: t = "currentColor" }) => /* @__PURE__ */ _("svg", {
9101
9130
  width: e,
9102
9131
  height: e,
9103
9132
  viewBox: "0 0 24 24",
@@ -9113,7 +9142,7 @@ var Mm = { startSession: jm }, Nm = ({ size: e = 18, color: t = "currentColor" }
9113
9142
  strokeLinecap: "round",
9114
9143
  strokeLinejoin: "round"
9115
9144
  })]
9116
- }), Pm = ({ size: e = 20 }) => /* @__PURE__ */ _("svg", {
9145
+ }), Lm = ({ size: e = 20 }) => /* @__PURE__ */ _("svg", {
9117
9146
  width: e,
9118
9147
  height: e,
9119
9148
  viewBox: "0 0 24 24",
@@ -9128,7 +9157,7 @@ var Mm = { startSession: jm }, Nm = ({ size: e = 18, color: t = "currentColor" }
9128
9157
  x2: "1",
9129
9158
  y2: "23"
9130
9159
  })]
9131
- }), Fm = ({ size: e = 18 }) => /* @__PURE__ */ _("svg", {
9160
+ }), Rm = ({ size: e = 18 }) => /* @__PURE__ */ _("svg", {
9132
9161
  width: e,
9133
9162
  height: e,
9134
9163
  viewBox: "0 0 24 24",
@@ -9143,7 +9172,7 @@ var Mm = { startSession: jm }, Nm = ({ size: e = 18, color: t = "currentColor" }
9143
9172
  x2: "12",
9144
9173
  y2: "5"
9145
9174
  }), /* @__PURE__ */ g("polyline", { points: "5 12 12 5 19 12" })]
9146
- }), Im = () => /* @__PURE__ */ _("svg", {
9175
+ }), zm = () => /* @__PURE__ */ _("svg", {
9147
9176
  width: "14",
9148
9177
  height: "14",
9149
9178
  viewBox: "0 0 24 24",
@@ -9153,7 +9182,7 @@ var Mm = { startSession: jm }, Nm = ({ size: e = 18, color: t = "currentColor" }
9153
9182
  strokeLinecap: "round",
9154
9183
  strokeLinejoin: "round",
9155
9184
  children: [/* @__PURE__ */ g("polyline", { points: "9 17 4 12 9 7" }), /* @__PURE__ */ g("path", { d: "M20 18v-2a4 4 0 00-4-4H4" })]
9156
- }), Lm = () => /* @__PURE__ */ g("svg", {
9185
+ }), Bm = () => /* @__PURE__ */ g("svg", {
9157
9186
  width: "18",
9158
9187
  height: "18",
9159
9188
  viewBox: "0 0 24 24",
@@ -9163,7 +9192,7 @@ var Mm = { startSession: jm }, Nm = ({ size: e = 18, color: t = "currentColor" }
9163
9192
  strokeLinecap: "round",
9164
9193
  strokeLinejoin: "round",
9165
9194
  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" })
9166
- }), Rm = ({ className: e = "" }) => /* @__PURE__ */ _("svg", {
9195
+ }), Vm = ({ className: e = "" }) => /* @__PURE__ */ _("svg", {
9167
9196
  className: e,
9168
9197
  width: "14",
9169
9198
  height: "14",
@@ -9192,7 +9221,7 @@ var Mm = { startSession: jm }, Nm = ({ size: e = 18, color: t = "currentColor" }
9192
9221
  y2: "16"
9193
9222
  })
9194
9223
  ]
9195
- }), zm = ({ size: e = 14 }) => /* @__PURE__ */ _("svg", {
9224
+ }), Hm = ({ size: e = 14 }) => /* @__PURE__ */ _("svg", {
9196
9225
  width: e,
9197
9226
  height: e,
9198
9227
  viewBox: "0 0 24 24",
@@ -9215,7 +9244,7 @@ var Mm = { startSession: jm }, Nm = ({ size: e = 18, color: t = "currentColor" }
9215
9244
  /* @__PURE__ */ g("path", { d: "M15 13v2" }),
9216
9245
  /* @__PURE__ */ g("path", { d: "M9 13v2" })
9217
9246
  ]
9218
- }), Bm = ({ size: e = 20, strokeWidth: t = 2, color: n = "currentColor" }) => /* @__PURE__ */ _("svg", {
9247
+ }), Um = ({ size: e = 20, strokeWidth: t = 2, color: n = "currentColor" }) => /* @__PURE__ */ _("svg", {
9219
9248
  width: e,
9220
9249
  height: e,
9221
9250
  viewBox: "0 0 24 24",
@@ -9235,7 +9264,7 @@ var Mm = { startSession: jm }, Nm = ({ size: e = 18, color: t = "currentColor" }
9235
9264
  x2: "19",
9236
9265
  y2: "12"
9237
9266
  })]
9238
- }), Vm = ({ size: e = 20, color: t = "currentColor" }) => /* @__PURE__ */ _("svg", {
9267
+ }), Wm = ({ size: e = 20, color: t = "currentColor" }) => /* @__PURE__ */ _("svg", {
9239
9268
  width: e,
9240
9269
  height: e,
9241
9270
  viewBox: "0 0 24 24",
@@ -9261,7 +9290,7 @@ var Mm = { startSession: jm }, Nm = ({ size: e = 18, color: t = "currentColor" }
9261
9290
  fill: t
9262
9291
  })
9263
9292
  ]
9264
- }), Hm = ({ size: e = 20, color: t = "currentColor" }) => /* @__PURE__ */ _("svg", {
9293
+ }), Gm = ({ size: e = 20, color: t = "currentColor" }) => /* @__PURE__ */ _("svg", {
9265
9294
  width: "24",
9266
9295
  height: "24",
9267
9296
  viewBox: "0 0 24 24",
@@ -9279,7 +9308,7 @@ var Mm = { startSession: jm }, Nm = ({ size: e = 18, color: t = "currentColor" }
9279
9308
  "stroke-linecap": "round",
9280
9309
  "stroke-linejoin": "round"
9281
9310
  })]
9282
- }), Um = () => /* @__PURE__ */ g("svg", {
9311
+ }), Km = () => /* @__PURE__ */ g("svg", {
9283
9312
  width: "24",
9284
9313
  height: "24",
9285
9314
  viewBox: "0 0 24 24",
@@ -9291,7 +9320,7 @@ var Mm = { startSession: jm }, Nm = ({ size: e = 18, color: t = "currentColor" }
9291
9320
  "stroke-width": "1.5",
9292
9321
  "stroke-linejoin": "round"
9293
9322
  })
9294
- }), Wm = ({ size: e = 24 }) => /* @__PURE__ */ _("svg", {
9323
+ }), qm = ({ size: e = 24 }) => /* @__PURE__ */ _("svg", {
9295
9324
  xmlns: "http://www.w3.org/2000/svg",
9296
9325
  width: e,
9297
9326
  height: e,
@@ -9309,7 +9338,7 @@ var Mm = { startSession: jm }, Nm = ({ size: e = 18, color: t = "currentColor" }
9309
9338
  /* @__PURE__ */ g("path", { d: "m2 2 20 20" }),
9310
9339
  /* @__PURE__ */ g("path", { d: "M9 9v3a3 3 0 0 0 5.12 2.12" })
9311
9340
  ]
9312
- }), 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([
9341
+ }), Jm = (e = "") => String(e).replace(/<[^>]+>/g, "").replace(/\s+/g, " ").trim(), Ym = (e = "") => String(e).replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;"), Xm = new Set([
9313
9342
  "p",
9314
9343
  "br",
9315
9344
  "ul",
@@ -9320,30 +9349,30 @@ var Mm = { startSession: jm }, Nm = ({ size: e = 18, color: t = "currentColor" }
9320
9349
  "b",
9321
9350
  "i",
9322
9351
  "a"
9323
- ]), Jm = /^https?:\/\//i;
9324
- function Ym(e) {
9352
+ ]), Zm = /^https?:\/\//i;
9353
+ function Qm(e) {
9325
9354
  let t = Array.from(e.childNodes);
9326
9355
  for (let n of t) if (n.nodeType === Node.ELEMENT_NODE) {
9327
9356
  let t = n.tagName.toLowerCase();
9328
- if (!qm.has(t)) {
9357
+ if (!Xm.has(t)) {
9329
9358
  e.replaceChild(document.createTextNode(n.textContent), n);
9330
9359
  continue;
9331
9360
  }
9332
9361
  let r = {};
9333
9362
  if (t === "a") {
9334
9363
  let e = n.getAttribute("href") || "";
9335
- Jm.test(e) && (r.href = e), r.target = "_blank", r.rel = "noopener noreferrer";
9364
+ Zm.test(e) && (r.href = e), r.target = "_blank", r.rel = "noopener noreferrer";
9336
9365
  }
9337
9366
  for (; n.attributes.length > 0;) n.removeAttribute(n.attributes[0].name);
9338
9367
  for (let [e, t] of Object.entries(r)) n.setAttribute(e, t);
9339
- Ym(n);
9368
+ Qm(n);
9340
9369
  } else n.nodeType !== Node.TEXT_NODE && e.removeChild(n);
9341
9370
  }
9342
- function Xm(e) {
9371
+ function $m(e) {
9343
9372
  let t = document.createElement("div");
9344
- return t.innerHTML = e, Ym(t), t.innerHTML;
9373
+ return t.innerHTML = e, Qm(t), t.innerHTML;
9345
9374
  }
9346
- function Zm(e) {
9375
+ function eh(e) {
9347
9376
  let t = String(e || "").trim();
9348
9377
  if (!t) return t;
9349
9378
  let n = /^<p>\s*<strong>([\s\S]*?)<\/strong>\s*<\/p>$/i.exec(t);
@@ -9355,33 +9384,33 @@ function Zm(e) {
9355
9384
  }
9356
9385
  return e;
9357
9386
  }
9358
- var Qm = (e = "") => {
9387
+ var th = (e = "") => {
9359
9388
  let t = String(e || "").trim();
9360
9389
  if (!t) return "";
9361
- if (/<(p|br|ul|ol|li|strong|em|a)\b/i.test(t)) return Zm(Xm(t));
9362
- 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>");
9363
- return Zm(n.map((e) => {
9390
+ if (/<(p|br|ul|ol|li|strong|em|a)\b/i.test(t)) return eh($m(t));
9391
+ 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) => Ym(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>");
9392
+ return eh(n.map((e) => {
9364
9393
  let t = e.split("\n").map((e) => e.trim()).filter(Boolean), n = t.filter((e) => /^[-*]\s+/.test(e));
9365
9394
  if (n.length >= 2 && n.length === t.length) return `<ul>${n.map((e) => `<li>${r(e.replace(/^[-*]\s+/, ""))}</li>`).join("")}</ul>`;
9366
9395
  let i = e.split(/\s+(?=[-*]\s+\*\*?)/).map((e) => e.trim()).filter(Boolean);
9367
9396
  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>`;
9368
9397
  }).join(""));
9369
- }, $m = new Set(["application/pdf", "application/vnd.openxmlformats-officedocument.wordprocessingml.document"]), eh = new Set([
9398
+ }, nh = new Set(["application/pdf", "application/vnd.openxmlformats-officedocument.wordprocessingml.document"]), rh = new Set([
9370
9399
  ".pdf",
9371
9400
  ".docx",
9372
9401
  ".png",
9373
9402
  ".jpg",
9374
9403
  ".jpeg"
9375
- ]), th = "image/png,image/jpeg,.pdf,.docx";
9376
- function nh(e) {
9404
+ ]), ih = "image/png,image/jpeg,.pdf,.docx";
9405
+ function ah(e) {
9377
9406
  if (!e) return !1;
9378
9407
  let t = typeof e.name == "string" ? e.name.toLowerCase() : "", n = t.includes(".") ? `.${t.split(".").pop()}` : "", r = typeof e.type == "string" ? e.type.toLowerCase() : "";
9379
- return r === "image/png" || r === "image/jpeg" || $m.has(r) || eh.has(n);
9408
+ return r === "image/png" || r === "image/jpeg" || nh.has(r) || rh.has(n);
9380
9409
  }
9381
- function rh(e) {
9382
- 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.";
9410
+ function oh(e) {
9411
+ return e ? ah(e) ? e.size > 2097152 ? "File must be 2 MB or smaller." : "" : "Only PNG, JPEG, PDF, and DOCX files are allowed." : "No file selected.";
9383
9412
  }
9384
- function ih(e = 0) {
9413
+ function sh(e = 0) {
9385
9414
  if (!Number.isFinite(e) || e <= 0) return "";
9386
9415
  let t = [
9387
9416
  "B",
@@ -9393,12 +9422,12 @@ function ih(e = 0) {
9393
9422
  let i = n >= 10 || r === 0 ? 0 : 1;
9394
9423
  return `${n.toFixed(i)} ${t[r]}`;
9395
9424
  }
9396
- function ah(e) {
9425
+ function ch(e) {
9397
9426
  return e ? e.name || "Attachment" : "";
9398
9427
  }
9399
9428
  //#endregion
9400
9429
  //#region src/utils/avatarHelpers.js
9401
- function oh(e) {
9430
+ function lh(e) {
9402
9431
  if (!e || typeof e != "string") return "?";
9403
9432
  let t = e.trim();
9404
9433
  if (!t) return "?";
@@ -9407,7 +9436,7 @@ function oh(e) {
9407
9436
  }
9408
9437
  //#endregion
9409
9438
  //#region src/components/AvatarImageOrInitials.jsx
9410
- function sh({ src: e, name: t, imgStyle: n, initialsSpanStyle: r }) {
9439
+ function uh({ src: e, name: t, imgStyle: n, initialsSpanStyle: r }) {
9411
9440
  let [i, a] = m(null), o = typeof e == "string" ? e.trim() : "";
9412
9441
  return c(() => {
9413
9442
  if (!o) {
@@ -9430,12 +9459,12 @@ function sh({ src: e, name: t, imgStyle: n, initialsSpanStyle: r }) {
9430
9459
  onError: () => a(null)
9431
9460
  }) : /* @__PURE__ */ g("span", {
9432
9461
  style: r,
9433
- children: oh(t)
9462
+ children: lh(t)
9434
9463
  });
9435
9464
  }
9436
9465
  //#endregion
9437
9466
  //#region src/components/MessageList.jsx
9438
- function ch({ chatHistory: e, isAiTyping: t, isLoading: n, isAgentTyping: r, setReplyContext: i, primaryColor: a = "#3B82F6", agentHeadshot: s = null, agentDisplayName: l = "Agent", botAvatarNode: u = null }) {
9467
+ function dh({ chatHistory: e, isAiTyping: t, isLoading: n, isAgentTyping: r, setReplyContext: i, primaryColor: a = "#3B82F6", agentHeadshot: s = null, agentDisplayName: l = "Agent", botAvatarNode: u = null }) {
9439
9468
  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) => {
9440
9469
  let t = e.target.closest("a[href]");
9441
9470
  if (!t) return;
@@ -9490,7 +9519,7 @@ function ch({ chatHistory: e, isAiTyping: t, isLoading: n, isAgentTyping: r, set
9490
9519
  children: [
9491
9520
  e.map((e) => {
9492
9521
  if (e.type === "call_recording" || typeof e.message == "string" && e.message.includes("AI chat recording")) return null;
9493
- 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";
9522
+ 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 = Jm(e.replyToContent || e.replyContext?.message || ""), v = e.replyToSender === "user" ? "You" : e.replyToSender === "agent" ? "Agent" : e.replyToSender === "ai" || e.replyToSender === "bot" ? "AI Assistant" : "Message";
9494
9523
  return t ? /* @__PURE__ */ g("div", {
9495
9524
  style: {
9496
9525
  display: "flex",
@@ -9535,7 +9564,7 @@ function ch({ chatHistory: e, isAiTyping: t, isLoading: n, isAgentTyping: r, set
9535
9564
  fontWeight: 800,
9536
9565
  marginTop: !c && (r || o) ? "22px" : "0px"
9537
9566
  },
9538
- children: r ? u || /* @__PURE__ */ g(zm, { size: 16 }) : /* @__PURE__ */ g(sh, {
9567
+ children: r ? u || /* @__PURE__ */ g(Hm, { size: 16 }) : /* @__PURE__ */ g(uh, {
9539
9568
  src: p || "",
9540
9569
  name: f,
9541
9570
  imgStyle: {
@@ -9577,7 +9606,7 @@ function ch({ chatHistory: e, isAiTyping: t, isLoading: n, isAgentTyping: r, set
9577
9606
  onMouseLeave: (e) => {
9578
9607
  e.currentTarget.style.color = "#9ca3af";
9579
9608
  },
9580
- children: [/* @__PURE__ */ g(Im, {}), "Reply"]
9609
+ children: [/* @__PURE__ */ g(zm, {}), "Reply"]
9581
9610
  }),
9582
9611
  /* @__PURE__ */ _("div", {
9583
9612
  style: {
@@ -9621,7 +9650,7 @@ function ch({ chatHistory: e, isAiTyping: t, isLoading: n, isAgentTyping: r, set
9621
9650
  children: m
9622
9651
  })]
9623
9652
  }), d ? (() => {
9624
- 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" ? {
9653
+ let t = e.metadata.fileType || "", r = e.metadata.fileName || e.message || "File", i = sh(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" ? {
9625
9654
  color: "#ef4444",
9626
9655
  label: "PDF"
9627
9656
  } : t.includes("word") || t.includes("docx") ? {
@@ -9802,7 +9831,7 @@ function ch({ chatHistory: e, isAiTyping: t, isLoading: n, isAgentTyping: r, set
9802
9831
  });
9803
9832
  })() : r ? /* @__PURE__ */ g("div", {
9804
9833
  className: "flowengage-message-content fe-bot-message",
9805
- dangerouslySetInnerHTML: { __html: Qm(e.message) },
9834
+ dangerouslySetInnerHTML: { __html: th(e.message) },
9806
9835
  onClick: T
9807
9836
  }) : /* @__PURE__ */ g("div", {
9808
9837
  style: { whiteSpace: "pre-wrap" },
@@ -9867,7 +9896,7 @@ function ch({ chatHistory: e, isAiTyping: t, isLoading: n, isAgentTyping: r, set
9867
9896
  boxShadow: u ? "none" : "0 8px 20px rgba(59,130,246,0.24)",
9868
9897
  overflow: "hidden"
9869
9898
  },
9870
- children: u || /* @__PURE__ */ g(zm, { size: 16 })
9899
+ children: u || /* @__PURE__ */ g(Hm, { size: 16 })
9871
9900
  }), /* @__PURE__ */ _("div", {
9872
9901
  style: {
9873
9902
  display: "flex",
@@ -9909,7 +9938,7 @@ function ch({ chatHistory: e, isAiTyping: t, isLoading: n, isAgentTyping: r, set
9909
9938
  borderRadius: "50%",
9910
9939
  overflow: "hidden"
9911
9940
  },
9912
- children: /* @__PURE__ */ g(sh, {
9941
+ children: /* @__PURE__ */ g(uh, {
9913
9942
  src: s || "",
9914
9943
  name: l,
9915
9944
  imgStyle: {
@@ -10003,17 +10032,17 @@ function ch({ chatHistory: e, isAiTyping: t, isLoading: n, isAgentTyping: r, set
10003
10032
  }
10004
10033
  //#endregion
10005
10034
  //#region src/components/ChatInput.jsx
10006
- var lh = typeof window < "u" && (window.matchMedia?.("(pointer: coarse)").matches || navigator.maxTouchPoints > 0);
10007
- 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" }) {
10008
- let D = p(null), O = p(null), k = (e) => {
10035
+ var fh = typeof window < "u" && (window.matchMedia?.("(pointer: coarse)").matches || navigator.maxTouchPoints > 0);
10036
+ function ph({ 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" }) {
10037
+ let D = p(null), ee = p(null), O = (e) => {
10009
10038
  e && (e.style.height = "auto", e.style.height = `${Math.min(e.scrollHeight, 120)}px`);
10010
10039
  };
10011
10040
  c(() => {
10012
- d || k(O.current);
10041
+ d || O(ee.current);
10013
10042
  }, [e, d]);
10014
- let A = (e) => {
10015
- e.key === "Enter" && (lh || e.shiftKey || e.altKey || e.ctrlKey || e.metaKey || (e.preventDefault(), e.currentTarget.form?.requestSubmit()));
10016
- }, 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;
10043
+ let k = (e) => {
10044
+ e.key === "Enter" && (fh || e.shiftKey || e.altKey || e.ctrlKey || e.metaKey || (e.preventDefault(), e.currentTarget.form?.requestSubmit()));
10045
+ }, te = l?.sender === "user" ? "You" : l?.sender === "agent" ? "Agent" : "AI Assistant", ne = d ? !!f?.trim() : !!e?.trim() || !!S, re = s || T || !ne, A = !d && b && y;
10017
10046
  return /* @__PURE__ */ _("div", {
10018
10047
  style: {
10019
10048
  padding: "0 16px",
@@ -10046,7 +10075,7 @@ function uh({ input: e, setInput: t, onSubmit: n, isConversationEnded: r, callUi
10046
10075
  fontWeight: 600,
10047
10076
  color: "var(--flowengage-primary)"
10048
10077
  },
10049
- children: ["Replying to ", ee]
10078
+ children: ["Replying to ", te]
10050
10079
  }), /* @__PURE__ */ g("div", {
10051
10080
  style: {
10052
10081
  overflow: "hidden",
@@ -10107,7 +10136,7 @@ function uh({ input: e, setInput: t, onSubmit: n, isConversationEnded: r, callUi
10107
10136
  background: "rgba(59,130,246,0.08)",
10108
10137
  color: "var(--flowengage-primary)"
10109
10138
  },
10110
- children: /* @__PURE__ */ g(zm, { size: 13 })
10139
+ children: /* @__PURE__ */ g(Hm, { size: 13 })
10111
10140
  }), /* @__PURE__ */ g("span", { children: "Please provide your email address so we can help you." })]
10112
10141
  })
10113
10142
  }),
@@ -10147,7 +10176,7 @@ function uh({ input: e, setInput: t, onSubmit: n, isConversationEnded: r, callUi
10147
10176
  overflow: "hidden",
10148
10177
  textOverflow: "ellipsis"
10149
10178
  },
10150
- children: ah(S)
10179
+ children: ch(S)
10151
10180
  }),
10152
10181
  /* @__PURE__ */ g("div", {
10153
10182
  style: {
@@ -10155,7 +10184,7 @@ function uh({ input: e, setInput: t, onSubmit: n, isConversationEnded: r, callUi
10155
10184
  color: "#6b7280",
10156
10185
  marginTop: "2px"
10157
10186
  },
10158
- children: ih(S.size)
10187
+ children: sh(S.size)
10159
10188
  })
10160
10189
  ]
10161
10190
  }), /* @__PURE__ */ g("button", {
@@ -10197,10 +10226,10 @@ function uh({ input: e, setInput: t, onSubmit: n, isConversationEnded: r, callUi
10197
10226
  },
10198
10227
  onSubmit: n,
10199
10228
  children: [
10200
- j ? /* @__PURE__ */ _(h, { children: [/* @__PURE__ */ g("input", {
10229
+ A ? /* @__PURE__ */ _(h, { children: [/* @__PURE__ */ g("input", {
10201
10230
  ref: D,
10202
10231
  type: "file",
10203
- accept: th,
10232
+ accept: ih,
10204
10233
  style: { display: "none" },
10205
10234
  onChange: (e) => {
10206
10235
  let t = e.target.files?.[0];
@@ -10232,7 +10261,7 @@ function uh({ input: e, setInput: t, onSubmit: n, isConversationEnded: r, callUi
10232
10261
  onMouseLeave: (e) => {
10233
10262
  e.currentTarget.style.opacity = "1";
10234
10263
  },
10235
- children: /* @__PURE__ */ g(Bm, {
10264
+ children: /* @__PURE__ */ g(Um, {
10236
10265
  size: 16,
10237
10266
  color: "currentColor"
10238
10267
  })
@@ -10247,7 +10276,7 @@ function uh({ input: e, setInput: t, onSubmit: n, isConversationEnded: r, callUi
10247
10276
  fontSize: "14px",
10248
10277
  outline: "none",
10249
10278
  padding: 0,
10250
- paddingLeft: j ? "0" : "8px",
10279
+ paddingLeft: A ? "0" : "8px",
10251
10280
  color: "#111827",
10252
10281
  background: "transparent",
10253
10282
  cursor: "text",
@@ -10260,7 +10289,7 @@ function uh({ input: e, setInput: t, onSubmit: n, isConversationEnded: r, callUi
10260
10289
  type: "email",
10261
10290
  autoComplete: "email"
10262
10291
  }) : /* @__PURE__ */ g("textarea", {
10263
- ref: O,
10292
+ ref: ee,
10264
10293
  className: "flowengage-chat-text-input",
10265
10294
  rows: 1,
10266
10295
  style: {
@@ -10272,7 +10301,7 @@ function uh({ input: e, setInput: t, onSubmit: n, isConversationEnded: r, callUi
10272
10301
  lineHeight: "20px",
10273
10302
  outline: "none",
10274
10303
  padding: "6px 0",
10275
- paddingLeft: j ? "0" : "8px",
10304
+ paddingLeft: A ? "0" : "8px",
10276
10305
  color: "#111827",
10277
10306
  background: "transparent",
10278
10307
  cursor: "text",
@@ -10282,9 +10311,9 @@ function uh({ input: e, setInput: t, onSubmit: n, isConversationEnded: r, callUi
10282
10311
  },
10283
10312
  value: e,
10284
10313
  onChange: (e) => {
10285
- t(e.target.value), k(e.target);
10314
+ t(e.target.value), O(e.target);
10286
10315
  },
10287
- onKeyDown: A,
10316
+ onKeyDown: k,
10288
10317
  placeholder: o === "agent" ? "Message the agent…" : E,
10289
10318
  disabled: s,
10290
10319
  autoComplete: "off"
@@ -10302,18 +10331,18 @@ function uh({ input: e, setInput: t, onSubmit: n, isConversationEnded: r, callUi
10302
10331
  alignItems: "center",
10303
10332
  justifyContent: "center",
10304
10333
  transition: "opacity 0.2s ease",
10305
- cursor: ne ? "not-allowed" : "pointer",
10306
- opacity: ne ? .45 : 1,
10334
+ cursor: re ? "not-allowed" : "pointer",
10335
+ opacity: re ? .45 : 1,
10307
10336
  flexShrink: 0
10308
10337
  },
10309
- disabled: ne,
10338
+ disabled: re,
10310
10339
  onMouseEnter: (e) => {
10311
- ne || (e.currentTarget.style.opacity = "0.85");
10340
+ re || (e.currentTarget.style.opacity = "0.85");
10312
10341
  },
10313
10342
  onMouseLeave: (e) => {
10314
10343
  e.currentTarget.style.opacity = "1";
10315
10344
  },
10316
- children: /* @__PURE__ */ g(Fm, { size: 16 })
10345
+ children: /* @__PURE__ */ g(Rm, { size: 16 })
10317
10346
  })
10318
10347
  ]
10319
10348
  }),
@@ -10376,7 +10405,7 @@ function uh({ input: e, setInput: t, onSubmit: n, isConversationEnded: r, callUi
10376
10405
  }
10377
10406
  //#endregion
10378
10407
  //#region src/components/StatusBanners.jsx
10379
- function dh({ webRTCError: e, micError: t, setMicError: n, dismissCallError: r, isRateLimited: i, rateLimitMessage: a }) {
10408
+ function mh({ webRTCError: e, micError: t, setMicError: n, dismissCallError: r, isRateLimited: i, rateLimitMessage: a }) {
10380
10409
  return /* @__PURE__ */ _(h, { children: [(e || t) && /* @__PURE__ */ _("div", {
10381
10410
  style: {
10382
10411
  margin: "0 20px 10px",
@@ -10389,7 +10418,7 @@ function dh({ webRTCError: e, micError: t, setMicError: n, dismissCallError: r,
10389
10418
  gap: "10px"
10390
10419
  },
10391
10420
  children: [
10392
- /* @__PURE__ */ g(Rm, { className: "" }),
10421
+ /* @__PURE__ */ g(Vm, { className: "" }),
10393
10422
  /* @__PURE__ */ g("span", {
10394
10423
  style: {
10395
10424
  fontSize: "12px",
@@ -10435,13 +10464,13 @@ function dh({ webRTCError: e, micError: t, setMicError: n, dismissCallError: r,
10435
10464
  }
10436
10465
  //#endregion
10437
10466
  //#region src/components/AnimatedOrb.jsx
10438
- var fh = [
10467
+ var hh = [
10439
10468
  "#135bd8",
10440
10469
  "#ef334b",
10441
10470
  "#ffbd2e"
10442
10471
  ];
10443
- function ph(e) {
10444
- return !Array.isArray(e) || e.length === 0 ? fh : e.length === 1 ? [
10472
+ function gh(e) {
10473
+ return !Array.isArray(e) || e.length === 0 ? hh : e.length === 1 ? [
10445
10474
  e[0],
10446
10475
  e[0],
10447
10476
  e[0]
@@ -10455,7 +10484,7 @@ function ph(e) {
10455
10484
  e[2]
10456
10485
  ];
10457
10486
  }
10458
- var mh = {
10487
+ var _h = {
10459
10488
  idle: 3,
10460
10489
  listening: .75,
10461
10490
  thinking: 1,
@@ -10463,7 +10492,7 @@ var mh = {
10463
10492
  muted: .75,
10464
10493
  error: .08
10465
10494
  };
10466
- function hh(e) {
10495
+ function vh(e) {
10467
10496
  if (!e || typeof e != "string") return [
10468
10497
  0,
10469
10498
  0,
@@ -10476,14 +10505,14 @@ function hh(e) {
10476
10505
  parseInt(n.slice(4, 6), 16) / 255
10477
10506
  ];
10478
10507
  }
10479
- function gh(e, t) {
10508
+ function yh(e, t) {
10480
10509
  if (!e || typeof e != "string") return `rgba(0,0,0,${t})`;
10481
10510
  if (e.startsWith("rgb")) return e.replace(/[\d.]+\)$/, `${t})`);
10482
10511
  let n = e.replace("#", ""), r = n.length === 3 ? n.split("").map((e) => e + e).join("") : n;
10483
10512
  return `rgba(${parseInt(r.slice(0, 2), 16)},${parseInt(r.slice(2, 4), 16)},${parseInt(r.slice(4, 6), 16)},${t})`;
10484
10513
  }
10485
- 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";
10486
- function yh(e, t, n) {
10514
+ var bh = "\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", xh = "\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";
10515
+ function Sh(e, t, n) {
10487
10516
  let r = (t, n) => {
10488
10517
  let r = e.createShader(t);
10489
10518
  return e.shaderSource(r, n), e.compileShader(r), e.getShaderParameter(r, e.COMPILE_STATUS) ? r : (console.error("[AnimatedOrb shader]", e.getShaderInfoLog(r)), null);
@@ -10492,10 +10521,10 @@ function yh(e, t, n) {
10492
10521
  let o = e.createProgram();
10493
10522
  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);
10494
10523
  }
10495
- function bh({ size: e = 94, voiceState: t = "idle", isMuted: n = !1, colors: r, onClick: i, style: a, className: o }) {
10496
- let [s, l, u] = ph(r), d = t === "speaking", f = e <= 50, m = p(null), h = p(mh[t] ?? .35);
10524
+ function Ch({ size: e = 94, voiceState: t = "idle", isMuted: n = !1, colors: r, onClick: i, style: a, className: o }) {
10525
+ let [s, l, u] = gh(r), d = t === "speaking", f = e <= 50, m = p(null), h = p(_h[t] ?? .35);
10497
10526
  c(() => {
10498
- h.current = mh[t] ?? .35;
10527
+ h.current = _h[t] ?? .35;
10499
10528
  }, [t]), c(() => {
10500
10529
  let t = m.current;
10501
10530
  if (!t) return;
@@ -10512,7 +10541,7 @@ function bh({ size: e = 94, voiceState: t = "idle", isMuted: n = !1, colors: r,
10512
10541
  console.warn("[AnimatedOrb] WebGL unavailable.");
10513
10542
  return;
10514
10543
  }
10515
- let i = yh(r, _h, vh);
10544
+ let i = Sh(r, bh, xh);
10516
10545
  if (!i) {
10517
10546
  console.error("[AnimatedOrb] WebGL program failed to compile/link");
10518
10547
  return;
@@ -10542,7 +10571,7 @@ function bh({ size: e = 94, voiceState: t = "idle", isMuted: n = !1, colors: r,
10542
10571
  c2: r.getUniformLocation(i, "u_c2"),
10543
10572
  c3: r.getUniformLocation(i, "u_c3")
10544
10573
  };
10545
- 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);
10574
+ r.uniform3fv(c.c1, vh(s)), r.uniform3fv(c.c2, vh(l)), r.uniform3fv(c.c3, vh(u)), r.viewport(0, 0, t.width, t.height);
10546
10575
  let d = performance.now(), f, p = (e) => {
10547
10576
  r.uniform1f(c.time, (e - d) / 1e3), r.uniform1f(c.speed, h.current), r.drawArrays(r.TRIANGLES, 0, 6), f = requestAnimationFrame(p);
10548
10577
  };
@@ -10573,7 +10602,7 @@ function bh({ size: e = 94, voiceState: t = "idle", isMuted: n = !1, colors: r,
10573
10602
  position: "absolute",
10574
10603
  inset: -10,
10575
10604
  borderRadius: "50%",
10576
- background: `radial-gradient(circle, ${gh(s, .18)} 0%, transparent 70%)`,
10605
+ background: `radial-gradient(circle, ${yh(s, .18)} 0%, transparent 70%)`,
10577
10606
  pointerEvents: "none"
10578
10607
  },
10579
10608
  animate: { opacity: [.3, .75] },
@@ -10651,17 +10680,17 @@ function bh({ size: e = 94, voiceState: t = "idle", isMuted: n = !1, colors: r,
10651
10680
  }
10652
10681
  //#endregion
10653
10682
  //#region src/components/CallScreen.jsx
10654
- 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";
10655
- function Sh(e) {
10683
+ var wh = "\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";
10684
+ function Th(e) {
10656
10685
  let t = (e || "").replace("#", ""), n = t.length === 3 ? t.split("").map((e) => e + e).join("") : t;
10657
10686
  return `${parseInt(n.slice(0, 2), 16)},${parseInt(n.slice(2, 4), 16)},${parseInt(n.slice(4, 6), 16)}`;
10658
10687
  }
10659
- function Ch(e) {
10688
+ function Eh(e) {
10660
10689
  if (!e || typeof e != "string") return "#1a1a1a";
10661
10690
  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;
10662
10691
  return .2126 * o(r) + .7152 * o(i) + .0722 * o(a) > .179 ? "#1a1a1a" : "#ffffff";
10663
10692
  }
10664
- function wh(e, t) {
10693
+ function Dh(e, t) {
10665
10694
  let n = Array.isArray(e) && e.length > 0 ? e : [t || "#3B82F6"], [r, i, a] = n;
10666
10695
  return n.length === 1 ? [
10667
10696
  `radial-gradient(ellipse 110% 65% at 50% -5%, ${r}28 0%, transparent 68%)`,
@@ -10678,8 +10707,8 @@ function wh(e, t) {
10678
10707
  "#f7f8fa"
10679
10708
  ].join(", ");
10680
10709
  }
10681
- function Th({ headshot: e, name: t, size: n = 80, primaryColor: r = "#3B82F6" }) {
10682
- let i = (t || "A")[0].toUpperCase(), a = Ch(r), o = n > 48 ? {
10710
+ function Oh({ headshot: e, name: t, size: n = 80, primaryColor: r = "#3B82F6" }) {
10711
+ let i = (t || "A")[0].toUpperCase(), a = Eh(r), o = n > 48 ? {
10683
10712
  boxShadow: `0 0 0 3px ${r}44`,
10684
10713
  border: "3px solid rgba(255,255,255,0.15)"
10685
10714
  } : { border: `1.5px solid ${r}55` };
@@ -10716,7 +10745,7 @@ function Th({ headshot: e, name: t, size: n = 80, primaryColor: r = "#3B82F6" })
10716
10745
  children: i
10717
10746
  });
10718
10747
  }
10719
- function Eh(e) {
10748
+ function kh(e) {
10720
10749
  let t = p(null), n = o(() => {
10721
10750
  if (!t.current) return;
10722
10751
  let { audioContext: e, oscillator: n, interval: r, toneTimeout: i } = t.current;
@@ -10763,8 +10792,8 @@ function Eh(e) {
10763
10792
  n
10764
10793
  ]), c(() => () => n(), [n]), n;
10765
10794
  }
10766
- 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 = [] }) {
10767
- let y = a || s || "Agent", b = e ? "incoming" : n === "connecting" ? "connecting" : "ongoing", x = Eh(!!e), S = async () => {
10795
+ function Ah({ 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 = [] }) {
10796
+ let y = a || s || "Agent", b = e ? "incoming" : n === "connecting" ? "connecting" : "ongoing", x = kh(!!e), S = async () => {
10768
10797
  x(), await c();
10769
10798
  }, C = async () => {
10770
10799
  x(), await l();
@@ -10776,14 +10805,14 @@ function Dh({ incomingCall: e, activeCallId: t, callConnectionState: n, callDura
10776
10805
  flexDirection: "column",
10777
10806
  borderRadius: "inherit",
10778
10807
  overflow: "hidden",
10779
- background: wh(h, m),
10808
+ background: Dh(h, m),
10780
10809
  animation: T ? "fe-call-slide-up 0.36s cubic-bezier(0.16,1,0.3,1)" : "fe-call-fade-in 0.32s ease"
10781
10810
  };
10782
10811
  if (b === "incoming") {
10783
10812
  let e = Array.isArray(h) && h.length > 0 ? h : [m];
10784
10813
  return /* @__PURE__ */ _("div", {
10785
10814
  style: E,
10786
- children: [/* @__PURE__ */ g("style", { children: xh }), /* @__PURE__ */ _("div", {
10815
+ children: [/* @__PURE__ */ g("style", { children: wh }), /* @__PURE__ */ _("div", {
10787
10816
  style: {
10788
10817
  flex: 1,
10789
10818
  display: "flex",
@@ -10814,7 +10843,7 @@ function Dh({ incomingCall: e, activeCallId: t, callConnectionState: n, callDura
10814
10843
  width: "96px",
10815
10844
  height: "96px",
10816
10845
  borderRadius: "50%",
10817
- background: `radial-gradient(circle, rgba(${Sh(e[0])},0.2) 0%, transparent 70%)`,
10846
+ background: `radial-gradient(circle, rgba(${Th(e[0])},0.2) 0%, transparent 70%)`,
10818
10847
  filter: "blur(10px)",
10819
10848
  zIndex: 0
10820
10849
  } }),
@@ -10831,7 +10860,7 @@ function Dh({ incomingCall: e, activeCallId: t, callConnectionState: n, callDura
10831
10860
  animation: `fe-call-ring-pulse 2.6s cubic-bezier(0.215,0.61,0.355,1) ${t}s infinite`,
10832
10861
  zIndex: 1
10833
10862
  } }, n)),
10834
- /* @__PURE__ */ g(Th, {
10863
+ /* @__PURE__ */ g(Oh, {
10835
10864
  headshot: o,
10836
10865
  name: y,
10837
10866
  size: 82,
@@ -10911,7 +10940,7 @@ function Dh({ incomingCall: e, activeCallId: t, callConnectionState: n, callDura
10911
10940
  e.currentTarget.style.transform = "scale(1)", e.currentTarget.style.boxShadow = "0 6px 24px rgba(239,68,68,0.5)";
10912
10941
  },
10913
10942
  "aria-label": "Decline call",
10914
- children: /* @__PURE__ */ g(Pm, { size: 26 })
10943
+ children: /* @__PURE__ */ g(Lm, { size: 26 })
10915
10944
  }), /* @__PURE__ */ g("span", {
10916
10945
  style: {
10917
10946
  fontSize: "12px",
@@ -10952,7 +10981,7 @@ function Dh({ incomingCall: e, activeCallId: t, callConnectionState: n, callDura
10952
10981
  e.currentTarget.style.transform = "scale(1)", e.currentTarget.style.boxShadow = "0 6px 24px rgba(34,197,94,0.5)";
10953
10982
  },
10954
10983
  "aria-label": "Accept call",
10955
- children: /* @__PURE__ */ g(Lm, {})
10984
+ children: /* @__PURE__ */ g(Bm, {})
10956
10985
  }), /* @__PURE__ */ g("span", {
10957
10986
  style: {
10958
10987
  fontSize: "12px",
@@ -10969,7 +10998,7 @@ function Dh({ incomingCall: e, activeCallId: t, callConnectionState: n, callDura
10969
10998
  }
10970
10999
  return b === "connecting" ? /* @__PURE__ */ _("div", {
10971
11000
  style: E,
10972
- children: [/* @__PURE__ */ g("style", { children: xh }), /* @__PURE__ */ _("div", {
11001
+ children: [/* @__PURE__ */ g("style", { children: wh }), /* @__PURE__ */ _("div", {
10973
11002
  style: {
10974
11003
  flex: 1,
10975
11004
  display: "flex",
@@ -10979,7 +11008,7 @@ function Dh({ incomingCall: e, activeCallId: t, callConnectionState: n, callDura
10979
11008
  gap: "24px"
10980
11009
  },
10981
11010
  children: [
10982
- /* @__PURE__ */ g(Th, {
11011
+ /* @__PURE__ */ g(Oh, {
10983
11012
  headshot: o,
10984
11013
  name: y,
10985
11014
  size: 64,
@@ -11006,7 +11035,7 @@ function Dh({ incomingCall: e, activeCallId: t, callConnectionState: n, callDura
11006
11035
  }) : /* @__PURE__ */ _("div", {
11007
11036
  style: E,
11008
11037
  children: [
11009
- /* @__PURE__ */ g("style", { children: xh }),
11038
+ /* @__PURE__ */ g("style", { children: wh }),
11010
11039
  /* @__PURE__ */ _("div", {
11011
11040
  style: {
11012
11041
  display: "flex",
@@ -11052,7 +11081,7 @@ function Dh({ incomingCall: e, activeCallId: t, callConnectionState: n, callDura
11052
11081
  children: /* @__PURE__ */ g("polyline", { points: "15 18 9 12 15 6" })
11053
11082
  })
11054
11083
  }),
11055
- /* @__PURE__ */ g(bh, {
11084
+ /* @__PURE__ */ g(Ch, {
11056
11085
  colors: h,
11057
11086
  size: 36,
11058
11087
  voiceState: w
@@ -11103,7 +11132,7 @@ function Dh({ incomingCall: e, activeCallId: t, callConnectionState: n, callDura
11103
11132
  gap: "16px",
11104
11133
  padding: "0 24px 16px"
11105
11134
  },
11106
- children: [/* @__PURE__ */ g(Th, {
11135
+ children: [/* @__PURE__ */ g(Oh, {
11107
11136
  headshot: o,
11108
11137
  name: y,
11109
11138
  size: 116,
@@ -11158,7 +11187,7 @@ function Dh({ incomingCall: e, activeCallId: t, callConnectionState: n, callDura
11158
11187
  transition: "all 0.2s ease"
11159
11188
  },
11160
11189
  "aria-label": i ? "Unmute" : "Mute",
11161
- children: [g(i ? Wm : Nm, { size: 18 }), i ? "Unmute" : "Mute"]
11190
+ children: [g(i ? qm : Im, { size: 18 }), i ? "Unmute" : "Mute"]
11162
11191
  }), /* @__PURE__ */ _("button", {
11163
11192
  type: "button",
11164
11193
  onClick: u,
@@ -11186,15 +11215,15 @@ function Dh({ incomingCall: e, activeCallId: t, callConnectionState: n, callDura
11186
11215
  e.currentTarget.style.background = "rgba(239,68,68,0.9)", e.currentTarget.style.transform = "scale(1)";
11187
11216
  },
11188
11217
  "aria-label": "End call",
11189
- children: [/* @__PURE__ */ g(Pm, { size: 18 }), "End Call"]
11218
+ children: [/* @__PURE__ */ g(Lm, { size: 18 }), "End Call"]
11190
11219
  })]
11191
11220
  })
11192
11221
  ]
11193
11222
  });
11194
11223
  }
11195
- function Oh({ agentName: e, agentHeadshot: t, fallbackAgentName: n, callDurationSeconds: r, isCallMuted: i, formatCallDuration: a, toggleCallMute: o, endWebRTCCall: s, onExpand: c, primaryColor: l = "#3B82F6" }) {
11224
+ function jh({ agentName: e, agentHeadshot: t, fallbackAgentName: n, callDurationSeconds: r, isCallMuted: i, formatCallDuration: a, toggleCallMute: o, endWebRTCCall: s, onExpand: c, primaryColor: l = "#3B82F6" }) {
11196
11225
  let u = e || n || "Agent";
11197
- return /* @__PURE__ */ _(h, { children: [/* @__PURE__ */ g("style", { children: xh }), /* @__PURE__ */ _("div", {
11226
+ return /* @__PURE__ */ _(h, { children: [/* @__PURE__ */ g("style", { children: wh }), /* @__PURE__ */ _("div", {
11198
11227
  role: "button",
11199
11228
  tabIndex: 0,
11200
11229
  onClick: c,
@@ -11251,7 +11280,7 @@ function Oh({ agentName: e, agentHeadshot: t, fallbackAgentName: n, callDuration
11251
11280
  borderRadius: "50%",
11252
11281
  border: `1.5px solid ${l}55`
11253
11282
  } }),
11254
- /* @__PURE__ */ g(Th, {
11283
+ /* @__PURE__ */ g(Oh, {
11255
11284
  headshot: t,
11256
11285
  name: u,
11257
11286
  size: 38,
@@ -11335,7 +11364,7 @@ function Oh({ agentName: e, agentHeadshot: t, fallbackAgentName: n, callDuration
11335
11364
  boxShadow: i ? `0 0 0 3px ${l}12` : "none"
11336
11365
  },
11337
11366
  "aria-label": i ? "Unmute" : "Mute",
11338
- children: g(i ? Wm : Nm, { size: 15 })
11367
+ children: g(i ? qm : Im, { size: 15 })
11339
11368
  }), /* @__PURE__ */ g("button", {
11340
11369
  type: "button",
11341
11370
  onClick: (e) => {
@@ -11363,7 +11392,7 @@ function Oh({ agentName: e, agentHeadshot: t, fallbackAgentName: n, callDuration
11363
11392
  transition: "all 0.18s ease"
11364
11393
  },
11365
11394
  "aria-label": "End call",
11366
- children: /* @__PURE__ */ g(Pm, { size: 16 })
11395
+ children: /* @__PURE__ */ g(Lm, { size: 16 })
11367
11396
  })]
11368
11397
  })
11369
11398
  ]
@@ -11371,7 +11400,7 @@ function Oh({ agentName: e, agentHeadshot: t, fallbackAgentName: n, callDuration
11371
11400
  }
11372
11401
  //#endregion
11373
11402
  //#region src/utils/voicePriorContext.js
11374
- function kh(e, t = {}) {
11403
+ function Mh(e, t = {}) {
11375
11404
  let n = t.maxChars ?? 4500;
11376
11405
  if (!Array.isArray(e) || e.length === 0) return "";
11377
11406
  let r = [];
@@ -11389,7 +11418,7 @@ function kh(e, t = {}) {
11389
11418
  //#endregion
11390
11419
  //#region src/utils/voiceActionVisuals.js
11391
11420
  var Q = "fe-vv";
11392
- function Ah() {
11421
+ function Nh() {
11393
11422
  if (typeof document > "u" || document.getElementById(`${Q}-styles`)) return;
11394
11423
  let e = `
11395
11424
  /* ── Action toast ───────────────────────────────────────────────────────────── */
@@ -11534,14 +11563,14 @@ function Ah() {
11534
11563
  `, t = document.createElement("style");
11535
11564
  t.id = `${Q}-styles`, t.textContent = e, (document.head || document.documentElement).appendChild(t);
11536
11565
  }
11537
- var jh = null, Mh = null;
11538
- function Nh() {
11539
- return (!jh || !jh.isConnected) && (jh = document.createElement("div"), jh.id = `${Q}-toast`, document.body.appendChild(jh)), jh;
11566
+ var Ph = null, Fh = null;
11567
+ function Ih() {
11568
+ return (!Ph || !Ph.isConnected) && (Ph = document.createElement("div"), Ph.id = `${Q}-toast`, document.body.appendChild(Ph)), Ph;
11540
11569
  }
11541
- function Ph(e, { spinner: t = !0, icon: n = null, duration: r = 0 } = {}) {
11570
+ function Lh(e, { spinner: t = !0, icon: n = null, duration: r = 0 } = {}) {
11542
11571
  if (typeof document > "u") return;
11543
- Ah(), Mh &&= (clearTimeout(Mh), null);
11544
- let i = Nh();
11572
+ Nh(), Fh &&= (clearTimeout(Fh), null);
11573
+ let i = Ih();
11545
11574
  if (i.innerHTML = "", n) {
11546
11575
  let e = document.createElement("span");
11547
11576
  e.className = `${Q}-icon`, e.textContent = n, i.appendChild(e);
@@ -11550,71 +11579,71 @@ function Ph(e, { spinner: t = !0, icon: n = null, duration: r = 0 } = {}) {
11550
11579
  e.className = `${Q}-spin`, i.appendChild(e);
11551
11580
  }
11552
11581
  let a = document.createElement("span");
11553
- a.textContent = e, i.appendChild(a), i.classList.remove(`${Q}-show`), i.offsetHeight, i.classList.add(`${Q}-show`), r > 0 && (Mh = setTimeout(() => Fh(), r));
11582
+ a.textContent = e, i.appendChild(a), i.classList.remove(`${Q}-show`), i.offsetHeight, i.classList.add(`${Q}-show`), r > 0 && (Fh = setTimeout(() => Rh(), r));
11554
11583
  }
11555
- function Fh(e = 0) {
11556
- jh && (e > 0 ? Mh = setTimeout(() => {
11557
- jh && jh.classList.remove(`${Q}-show`);
11558
- }, e) : jh && jh.classList.remove(`${Q}-show`));
11584
+ function Rh(e = 0) {
11585
+ Ph && (e > 0 ? Fh = setTimeout(() => {
11586
+ Ph && Ph.classList.remove(`${Q}-show`);
11587
+ }, e) : Ph && Ph.classList.remove(`${Q}-show`));
11559
11588
  }
11560
- var Ih = null, Lh = [];
11561
- function Rh() {
11562
- return (!Ih || !Ih.isConnected) && (Ih = document.createElement("div"), Ih.id = `${Q}-bar`, document.body.appendChild(Ih)), Ih;
11589
+ var zh = null, Bh = [];
11590
+ function Vh() {
11591
+ return (!zh || !zh.isConnected) && (zh = document.createElement("div"), zh.id = `${Q}-bar`, document.body.appendChild(zh)), zh;
11563
11592
  }
11564
- function zh() {
11593
+ function Hh() {
11565
11594
  if (typeof document > "u") return;
11566
- Ah(), Lh.forEach(clearTimeout), Lh = [];
11567
- let e = Rh();
11595
+ Nh(), Bh.forEach(clearTimeout), Bh = [];
11596
+ let e = Vh();
11568
11597
  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";
11569
11598
  let t = [[80, "width 0.6s ease"], [92, "width 1.2s ease"]], n = 50;
11570
11599
  for (let [e, r] of t) {
11571
11600
  let t = n, i = e, a = r;
11572
- Lh.push(setTimeout(() => {
11573
- Ih && (Ih.style.transition = a, Ih.style.width = `${i}%`);
11601
+ Bh.push(setTimeout(() => {
11602
+ zh && (zh.style.transition = a, zh.style.width = `${i}%`);
11574
11603
  }, t)), n += 800;
11575
11604
  }
11576
11605
  }
11577
- function Bh() {
11578
- Ih && (Lh.forEach(clearTimeout), Lh = [], Ih.style.transition = "width 0.2s ease", Ih.style.width = "100%", Lh.push(setTimeout(() => {
11579
- Ih && (Ih.style.transition = "opacity 0.35s ease", Ih.style.opacity = "0", Lh.push(setTimeout(() => {
11580
- Ih && (Ih.style.width = "0%", Ih.classList.remove(`${Q}-bar-active`));
11606
+ function Uh() {
11607
+ zh && (Bh.forEach(clearTimeout), Bh = [], zh.style.transition = "width 0.2s ease", zh.style.width = "100%", Bh.push(setTimeout(() => {
11608
+ zh && (zh.style.transition = "opacity 0.35s ease", zh.style.opacity = "0", Bh.push(setTimeout(() => {
11609
+ zh && (zh.style.width = "0%", zh.classList.remove(`${Q}-bar-active`));
11581
11610
  }, 380)));
11582
11611
  }, 220)));
11583
11612
  }
11584
- var Vh = `<svg xmlns="http://www.w3.org/2000/svg" width="22" height="22" viewBox="0 0 22 22" fill="none">
11613
+ var Wh = `<svg xmlns="http://www.w3.org/2000/svg" width="22" height="22" viewBox="0 0 22 22" fill="none">
11585
11614
  <filter id="${Q}-csh">
11586
11615
  <feDropShadow dx="1" dy="2" stdDeviation="1.5" flood-color="#00000060"/>
11587
11616
  </filter>
11588
11617
  <path d="M4 2L19 10.5L11 12.8L8 20L4 2Z"
11589
11618
  fill="white" stroke="#1e1b4b" stroke-width="1.6" stroke-linejoin="round"
11590
11619
  filter="url(#${Q}-csh)"/>
11591
- </svg>`, Hh = null, Uh = !1;
11592
- function Wh() {
11593
- return (!Hh || !Hh.isConnected) && (Hh = document.createElement("div"), Hh.id = `${Q}-cursor`, Hh.innerHTML = Vh, document.body.appendChild(Hh), Uh = !1), Hh;
11620
+ </svg>`, Gh = null, Kh = !1;
11621
+ function qh() {
11622
+ return (!Gh || !Gh.isConnected) && (Gh = document.createElement("div"), Gh.id = `${Q}-cursor`, Gh.innerHTML = Wh, document.body.appendChild(Gh), Kh = !1), Gh;
11594
11623
  }
11595
- async function Gh(e) {
11624
+ async function Jh(e) {
11596
11625
  if (typeof document > "u" || !e) return;
11597
- Ah();
11626
+ Nh();
11598
11627
  let t;
11599
11628
  try {
11600
11629
  t = e.getBoundingClientRect();
11601
11630
  } catch {
11602
11631
  return;
11603
11632
  }
11604
- let n = t.left + Math.min(16, t.width * .2), r = t.top + Math.min(12, t.height * .25), i = Wh();
11605
- 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);
11633
+ let n = t.left + Math.min(16, t.width * .2), r = t.top + Math.min(12, t.height * .25), i = qh();
11634
+ Kh ||= (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 Qh(360);
11606
11635
  }
11607
- function Kh(e = !1) {
11608
- Hh && (e ? (Hh.classList.remove(`${Q}-cursor-visible`), Uh = !1) : (Hh.classList.remove(`${Q}-cursor-visible`), setTimeout(() => {
11609
- Uh = !1;
11636
+ function Yh(e = !1) {
11637
+ Gh && (e ? (Gh.classList.remove(`${Q}-cursor-visible`), Kh = !1) : (Gh.classList.remove(`${Q}-cursor-visible`), setTimeout(() => {
11638
+ Kh = !1;
11610
11639
  }, 250)));
11611
11640
  }
11612
- async function qh(e) {
11613
- Hh && (Hh.classList.add(`${Q}-cursor-click`), await Yh(280), Hh.classList.remove(`${Q}-cursor-click`));
11641
+ async function Xh(e) {
11642
+ Gh && (Gh.classList.add(`${Q}-cursor-click`), await Qh(280), Gh.classList.remove(`${Q}-cursor-click`));
11614
11643
  }
11615
- function Jh(e) {
11644
+ function Zh(e) {
11616
11645
  if (!e || typeof document > "u") return;
11617
- Ah();
11646
+ Nh();
11618
11647
  let t;
11619
11648
  try {
11620
11649
  t = e.getBoundingClientRect();
@@ -11640,29 +11669,29 @@ function Jh(e) {
11640
11669
  a.remove(), e.style.position = n, e.style.overflow = r;
11641
11670
  }, 650);
11642
11671
  }
11643
- function Yh(e) {
11672
+ function Qh(e) {
11644
11673
  return new Promise((t) => setTimeout(t, e));
11645
11674
  }
11646
11675
  //#endregion
11647
11676
  //#region src/utils/voiceClientTools.js
11648
- var Xh = /^\/[a-z]{2}(?:-[a-z]{2})?(?=\/|$)/i;
11649
- function Zh(e) {
11650
- return String(e || "").replace(Xh, "").replace(/\/+$/, "").toLowerCase() || "/";
11677
+ var $h = /^\/[a-z]{2}(?:-[a-z]{2})?(?=\/|$)/i;
11678
+ function eg(e) {
11679
+ return String(e || "").replace($h, "").replace(/\/+$/, "").toLowerCase() || "/";
11651
11680
  }
11652
- function Qh(e, t) {
11653
- return Zh(e) === Zh(t);
11681
+ function tg(e, t) {
11682
+ return eg(e) === eg(t);
11654
11683
  }
11655
11684
  function $(...e) {
11656
11685
  wn() && console.log("[FlowEngage:voice-tools]", ...e);
11657
11686
  }
11658
- function $h(e) {
11687
+ function ng(e) {
11659
11688
  try {
11660
11689
  let t = e.ownerDocument?.defaultView;
11661
11690
  if (t) return t.getComputedStyle(e);
11662
11691
  } catch {}
11663
11692
  return window.getComputedStyle(e);
11664
11693
  }
11665
- function eg(e) {
11694
+ function rg(e) {
11666
11695
  let t = /* @__PURE__ */ new Set();
11667
11696
  function n(r) {
11668
11697
  if (!r || t.has(r)) return;
@@ -11675,10 +11704,10 @@ function eg(e) {
11675
11704
  }
11676
11705
  typeof document < "u" && n(document);
11677
11706
  }
11678
- function tg(e) {
11707
+ function ig(e) {
11679
11708
  return e == null ? null : String(e).replace(/\u00a0/g, " ").replace(/\s*\*+\s*$/u, "").replace(/\s+/g, " ").trim();
11680
11709
  }
11681
- function ng(e) {
11710
+ function ag(e) {
11682
11711
  let t = e.ownerDocument || document, n = e.getAttribute("aria-labelledby");
11683
11712
  if (n) {
11684
11713
  let e = n.trim().split(/\s+/).filter(Boolean), r = [];
@@ -11686,40 +11715,40 @@ function ng(e) {
11686
11715
  let e = t.getElementById(n);
11687
11716
  e?.textContent && r.push(e.textContent.trim());
11688
11717
  } catch {}
11689
- if (r.length) return tg(r.join(" "));
11718
+ if (r.length) return ig(r.join(" "));
11690
11719
  }
11691
- if (e.labels && e.labels.length) return tg(e.labels[0].textContent);
11720
+ if (e.labels && e.labels.length) return ig(e.labels[0].textContent);
11692
11721
  let r = e.id;
11693
11722
  if (r) try {
11694
11723
  let e = t.querySelector(`label[for="${CSS.escape(r)}"]`);
11695
- if (e) return tg(e.textContent);
11724
+ if (e) return ig(e.textContent);
11696
11725
  } catch {
11697
11726
  let e = t.querySelector(`label[for="${r.replace(/"/g, "\\\"")}"]`);
11698
- if (e) return tg(e.textContent);
11727
+ if (e) return ig(e.textContent);
11699
11728
  }
11700
11729
  let i = e.previousElementSibling;
11701
11730
  for (let e = 0; e < 6 && i; e += 1) {
11702
- if (i.tagName === "LABEL") return tg(i.textContent);
11731
+ if (i.tagName === "LABEL") return ig(i.textContent);
11703
11732
  let e = (i.className || "").toString().toLowerCase();
11704
11733
  if (/chakra-form__label|formlabel|field-label|form-label|mui-form-label/.test(e)) {
11705
- let e = tg(i.textContent);
11734
+ let e = ig(i.textContent);
11706
11735
  if (e) return e;
11707
11736
  }
11708
11737
  i = i.previousElementSibling;
11709
11738
  }
11710
11739
  let a = e.parentElement;
11711
11740
  for (let e = 0; e < 5 && a; e += 1) {
11712
- if (a.tagName === "LABEL") return tg(a.textContent);
11741
+ if (a.tagName === "LABEL") return ig(a.textContent);
11713
11742
  let e = a.querySelector?.(":scope > label, :scope > [class*='FormLabel'], :scope > [class*='form__label']");
11714
- if (e?.textContent) return tg(e.textContent);
11743
+ if (e?.textContent) return ig(e.textContent);
11715
11744
  a = a.parentElement;
11716
11745
  }
11717
11746
  let o = e.getAttribute("aria-label");
11718
- return o ? tg(o) : null;
11747
+ return o ? ig(o) : null;
11719
11748
  }
11720
- function rg() {
11749
+ function og() {
11721
11750
  let e = [];
11722
- return eg((t) => {
11751
+ return rg((t) => {
11723
11752
  e.push(...Array.from(t.querySelectorAll("input, select, textarea")).filter((e) => {
11724
11753
  if (An(e)) return !1;
11725
11754
  let t = (e.type || "").toLowerCase();
@@ -11730,15 +11759,15 @@ function rg() {
11730
11759
  "image"
11731
11760
  ].includes(t) || e.disabled || e.readOnly) return !1;
11732
11761
  try {
11733
- let t = $h(e);
11762
+ let t = ng(e);
11734
11763
  if (t.display === "none" || t.visibility === "hidden") return !1;
11735
11764
  } catch {}
11736
11765
  return !0;
11737
11766
  }));
11738
11767
  }), e;
11739
11768
  }
11740
- function ig() {
11741
- return rg().map((e, t) => {
11769
+ function sg() {
11770
+ return og().map((e, t) => {
11742
11771
  let n = {
11743
11772
  formIndex: 0,
11744
11773
  fieldIndex: t,
@@ -11746,7 +11775,7 @@ function ig() {
11746
11775
  type: e.type || "text",
11747
11776
  name: e.name || null,
11748
11777
  id: e.id || null,
11749
- label: ng(e),
11778
+ label: ag(e),
11750
11779
  placeholder: e.placeholder || null
11751
11780
  };
11752
11781
  return e.tagName === "SELECT" && (n.options = Array.from(e.options).filter((e) => e.value !== "" && !e.disabled).map((e) => ({
@@ -11755,13 +11784,13 @@ function ig() {
11755
11784
  })), n.currentValue = e.value || null), n;
11756
11785
  });
11757
11786
  }
11758
- function ag() {
11787
+ function cg() {
11759
11788
  let e = [];
11760
- return eg((t) => {
11789
+ return rg((t) => {
11761
11790
  e.push(...Array.from(t.querySelectorAll("button, [role=\"button\"], input[type=\"submit\"], input[type=\"button\"]")).filter((e) => {
11762
11791
  if (An(e) || e.disabled) return !1;
11763
11792
  try {
11764
- let t = $h(e);
11793
+ let t = ng(e);
11765
11794
  if (t.display === "none" || t.visibility === "hidden") return !1;
11766
11795
  } catch {}
11767
11796
  return !0;
@@ -11773,7 +11802,7 @@ function ag() {
11773
11802
  type: e.type || e.tagName
11774
11803
  }));
11775
11804
  }
11776
- function og(e, t) {
11805
+ function lg(e, t) {
11777
11806
  try {
11778
11807
  if (!e?.getBoundingClientRect || !t?.getBoundingClientRect) return Infinity;
11779
11808
  let n = e.getBoundingClientRect(), r = t.getBoundingClientRect(), i = {
@@ -11788,7 +11817,7 @@ function og(e, t) {
11788
11817
  return Infinity;
11789
11818
  }
11790
11819
  }
11791
- function sg(e, t) {
11820
+ function ug(e, t) {
11792
11821
  let n = String(t || "").toLowerCase().trim();
11793
11822
  if (!n) return 0;
11794
11823
  let r = (e.innerText || e.textContent || "").replace(/\s+/g, " ").trim(), i = [
@@ -11806,21 +11835,21 @@ function sg(e, t) {
11806
11835
  for (let e of a) i.includes(e) && (o += 1);
11807
11836
  return o / a.length * 92;
11808
11837
  }
11809
- function cg(e, t, n = 6) {
11838
+ function dg(e, t, n = 6) {
11810
11839
  let r = String(t || "").toLowerCase().trim();
11811
11840
  if (!r) return !1;
11812
11841
  let i = e;
11813
11842
  for (let e = 0; e < n && i && (i = i.parentElement, i); e++) if ((i.innerText || i.textContent || "").toLowerCase().includes(r)) return !0;
11814
11843
  return !1;
11815
11844
  }
11816
- function lg(e, t, n) {
11845
+ function fg(e, t, n) {
11817
11846
  let r = [];
11818
- eg((e) => {
11847
+ rg((e) => {
11819
11848
  let t = Array.from(e.querySelectorAll("button, [role=\"button\"], input[type=\"submit\"], input[type=\"button\"], a[href]"));
11820
11849
  r.push(...t.filter((e) => {
11821
11850
  if (An(e) || e.disabled) return !1;
11822
11851
  try {
11823
- let t = $h(e);
11852
+ let t = ng(e);
11824
11853
  if (t.display === "none" || t.visibility === "hidden" || t.opacity === "0") return !1;
11825
11854
  } catch {}
11826
11855
  return !0;
@@ -11828,14 +11857,14 @@ function lg(e, t, n) {
11828
11857
  });
11829
11858
  let i = 0, a = r.map((t) => ({
11830
11859
  el: t,
11831
- s: sg(t, e)
11860
+ s: ug(t, e)
11832
11861
  }));
11833
11862
  for (let { s: e } of a) e > i && (i = e);
11834
11863
  if (i < 28) return null;
11835
11864
  let o = a.filter(({ s: e }) => e === i).map(({ el: e }) => e);
11836
11865
  if (o.length === 1) return o[0];
11837
11866
  if (n) {
11838
- let e = o.filter((e) => cg(e, n));
11867
+ let e = o.filter((e) => dg(e, n));
11839
11868
  if (e.length === 1) return e[0];
11840
11869
  e.length > 1 && (o = e);
11841
11870
  }
@@ -11843,14 +11872,14 @@ function lg(e, t, n) {
11843
11872
  if (s.length) {
11844
11873
  let e = o[0], t = Infinity;
11845
11874
  for (let n of o) for (let r of s) {
11846
- let i = og(n, r);
11875
+ let i = lg(n, r);
11847
11876
  i < t && (t = i, e = n);
11848
11877
  }
11849
11878
  return e;
11850
11879
  }
11851
11880
  return o[0];
11852
11881
  }
11853
- function ug(e) {
11882
+ function pg(e) {
11854
11883
  if (e == null) return {};
11855
11884
  if (typeof e == "string") {
11856
11885
  let t = e.trim();
@@ -11863,12 +11892,12 @@ function ug(e) {
11863
11892
  }
11864
11893
  return e;
11865
11894
  }
11866
- function dg(e) {
11895
+ function mg(e) {
11867
11896
  if (!e || typeof e != "object") return null;
11868
11897
  let t = e.url ?? e.target_url ?? e.page_url ?? e.pageUrl ?? e.link ?? e.href ?? e.path;
11869
11898
  return t == null ? null : String(t).trim() || null;
11870
11899
  }
11871
- function fg() {
11900
+ function hg() {
11872
11901
  let e = {};
11873
11902
  document.querySelectorAll("h1, h2, h3, h4, h5, h6").forEach((t) => {
11874
11903
  if (t.id) return;
@@ -11883,7 +11912,7 @@ function fg() {
11883
11912
  e[r] = !0, t.id = r;
11884
11913
  });
11885
11914
  }
11886
- function pg() {
11915
+ function gg() {
11887
11916
  let e = (e) => {
11888
11917
  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;
11889
11918
  for (; r < t.length;) {
@@ -11926,7 +11955,7 @@ function pg() {
11926
11955
  introText: o
11927
11956
  };
11928
11957
  }
11929
- function mg(e) {
11958
+ function _g(e) {
11930
11959
  if (!e || typeof document > "u") return "";
11931
11960
  let t = new Set([
11932
11961
  "script",
@@ -12012,11 +12041,11 @@ function mg(e) {
12012
12041
  return d.has(t) ? !1 : (d.add(t), !0);
12013
12042
  }).join("\n").replace(/\n{3,}/g, "\n\n").trim();
12014
12043
  }
12015
- function hg(e) {
12044
+ function vg(e) {
12016
12045
  let t = e.siteId || null, n = (e.apiBaseUrl || "").replace(/\/$/, ""), r = typeof e.getLastUserVoiceText == "function" ? e.getLastUserVoiceText : null, i = [], a = {
12017
12046
  "fwh-navigate-mvp": async (n) => {
12018
12047
  $("fwh-navigate-mvp ▶ raw parameters:", n);
12019
- 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 : [];
12048
+ let i = pg(n), a = mg(i), o = i.section_text ?? i.sectionText ?? i.section, s = Array.isArray(i.expected_landmarks) ? i.expected_landmarks : Array.isArray(i.expectedLandmarks) ? i.expectedLandmarks : [];
12020
12049
  if ($("fwh-navigate-mvp · coerced:", {
12021
12050
  url: a,
12022
12051
  sectionText: o,
@@ -12055,11 +12084,11 @@ function hg(e) {
12055
12084
  correctedUrl: l
12056
12085
  }), a = l);
12057
12086
  try {
12058
- Ph(`Navigating to ${a}...`, { spinner: !0 }), zh(), On();
12087
+ Lh(`Navigating to ${a}...`, { spinner: !0 }), Hh(), On();
12059
12088
  try {
12060
12089
  let e = r ? r() : "";
12061
12090
  if (e && t) {
12062
- let n = kh([{
12091
+ let n = Mh([{
12063
12092
  sender: "user",
12064
12093
  message: e
12065
12094
  }]);
@@ -12087,8 +12116,8 @@ function hg(e) {
12087
12116
  typeof window < "u" && window.scrollTo(0, 0);
12088
12117
  } catch {}
12089
12118
  let o = [], s = null, c = "", l = Date.now() + 12e3;
12090
- for (; Date.now() < l && (await new Promise((e) => setTimeout(e, 300)), {headings: o, pageTitleHeading: s, introText: c} = pg(), !(o.length >= 1)););
12091
- fg(), $("fwh-navigate-mvp → page headings collected:", o, "titleHeading:", s);
12119
+ for (; Date.now() < l && (await new Promise((e) => setTimeout(e, 300)), {headings: o, pageTitleHeading: s, introText: c} = gg(), !(o.length >= 1)););
12120
+ hg(), $("fwh-navigate-mvp → page headings collected:", o, "titleHeading:", s);
12092
12121
  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 = "";
12093
12122
  try {
12094
12123
  if (o.length > 0) {
@@ -12096,7 +12125,7 @@ function hg(e) {
12096
12125
  for (let n of e) {
12097
12126
  let e = cr(null, n);
12098
12127
  if (e) {
12099
- let r = mg(e).substring(0, 800);
12128
+ let r = _g(e).substring(0, 800);
12100
12129
  r && t.push(`[Section: ${n}] ${r}`);
12101
12130
  }
12102
12131
  }
@@ -12105,13 +12134,13 @@ function hg(e) {
12105
12134
  } catch {}
12106
12135
  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.`;
12107
12136
  let m = Date.now() + 4e3, h = typeof window < "u" ? window.location.pathname : r;
12108
- for (; Date.now() < m && !Qh(h, e) && Qh(h, t);) await new Promise((e) => setTimeout(e, 120)), h = window.location.pathname;
12137
+ for (; Date.now() < m && !tg(h, e) && tg(h, t);) await new Promise((e) => setTimeout(e, 120)), h = window.location.pathname;
12109
12138
  $("fwh-navigate-mvp route settle:", {
12110
12139
  startPath: t,
12111
12140
  targetPath: e,
12112
12141
  settledPath: h
12113
12142
  });
12114
- 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;
12143
+ 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 = tg(h, e), y = !tg(h, t), b = v || y;
12115
12144
  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.`);
12116
12145
  } catch {}
12117
12146
  let o = "this";
@@ -12122,45 +12151,45 @@ function hg(e) {
12122
12151
  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.`;
12123
12152
  } catch (e) {
12124
12153
  let t = `Navigation error: ${e?.message || String(e)}`;
12125
- return $("fwh-navigate-mvp ✖", t), Ph("Navigation failed", {
12154
+ return $("fwh-navigate-mvp ✖", t), Lh("Navigation failed", {
12126
12155
  spinner: !1,
12127
12156
  icon: "⚠️",
12128
12157
  duration: 1800
12129
12158
  }), t;
12130
12159
  } finally {
12131
- Bh(), Fh(900);
12160
+ Uh(), Rh(900);
12132
12161
  }
12133
12162
  },
12134
12163
  "fwh-highlight-mvp": async (e) => {
12135
12164
  $("fwh-highlight-mvp ▶", e);
12136
- let t = ug(e), n = t?.section_id || t?.sectionId, r = t?.section_text || t?.sectionText;
12165
+ let t = pg(e), n = t?.section_id || t?.sectionId, r = t?.section_text || t?.sectionText;
12137
12166
  if (typeof window < "u" && window.__fe_user_nav_during_speech) {
12138
12167
  let e = window.__fe_user_nav_during_speech, t = window.location.pathname;
12139
12168
  if (Date.now() - e.ts >= 3e4) window.__fe_user_nav_during_speech = null;
12140
12169
  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.`;
12141
12170
  }
12142
- fg();
12171
+ hg();
12143
12172
  let i = ((e) => e && e.replace(/^\d+\.\s*/, "").replace(/^["']|["']$/g, "").trim())(r), a = cr(n || null, i || null);
12144
12173
  if (!a && i) {
12145
12174
  let e = Date.now() + 600;
12146
- for (; !a && Date.now() < e;) await new Promise((e) => setTimeout(e, 50)), fg(), a = cr(null, i);
12175
+ for (; !a && Date.now() < e;) await new Promise((e) => setTimeout(e, 50)), hg(), a = cr(null, i);
12147
12176
  }
12148
12177
  if (!a) {
12149
12178
  $("fwh-highlight-mvp ✖ no element for:", i || n);
12150
- 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.";
12179
+ let { headings: e } = gg(), 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.";
12151
12180
  return `HIGHLIGHT_NOT_FOUND: "${i || n}" on the current page. ${t}`;
12152
12181
  }
12153
12182
  return Dn(a), $("fwh-highlight-mvp ✓", i || n), `OK_HIGHLIGHT: "${i || n}". Your NEXT response must be speech only (no tool call) describing THIS section — "${i || n}" — using its own content. Do not ask whether to continue.`;
12154
12183
  },
12155
12184
  "fwh-read-content-mvp": async (e) => {
12156
12185
  $("fwh-read-content-mvp ▶", e);
12157
- let t = ug(e), n = t?.section_text || t?.sectionText || "";
12186
+ let t = pg(e), n = t?.section_text || t?.sectionText || "";
12158
12187
  try {
12159
12188
  let e = "";
12160
12189
  if (n) {
12161
12190
  let t = cr(null, n);
12162
12191
  if (!t) return `Could not find section "${n}" on the page.`;
12163
- e = mg(t);
12192
+ e = _g(t);
12164
12193
  } else {
12165
12194
  let t = (document.querySelector("main") || document.querySelector("article") || document.querySelector("[role=\"main\"]") || document.querySelector("#content") || document.querySelector(".content") || document.body).cloneNode(!0);
12166
12195
  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();
@@ -12172,7 +12201,7 @@ function hg(e) {
12172
12201
  },
12173
12202
  "fwh-page-content-mvp": async (e) => {
12174
12203
  $("fwh-page-content-mvp ▶", e);
12175
- let r = ug(e), i = r?.url || r?.page_url || "";
12204
+ let r = pg(e), i = r?.url || r?.page_url || "";
12176
12205
  if ($("fwh-page-content-mvp · url:", i, "siteId:", t, "apiBase:", n || "(empty)"), !i) return $("fwh-page-content-mvp ✖ missing url"), "Missing url parameter.";
12177
12206
  if (!t) return $("fwh-page-content-mvp ✖ no siteId"), "Site is not configured.";
12178
12207
  if (!n) return $("fwh-page-content-mvp ✖ no api base"), "API base URL is missing; cannot fetch page content.";
@@ -12204,7 +12233,7 @@ function hg(e) {
12204
12233
  },
12205
12234
  "fwh-search-mvp": async (e) => {
12206
12235
  $("fwh-search-mvp ▶", e);
12207
- let r = ug(e).query;
12236
+ let r = pg(e).query;
12208
12237
  if (!r) return $("fwh-search-mvp ✖ missing query"), "Missing query parameter.";
12209
12238
  if (!t) return $("fwh-search-mvp ✖ no siteId"), "Search unavailable (no siteId configured).";
12210
12239
  if (!n) return $("fwh-search-mvp ✖ no api base"), "Search unavailable (no API base URL).";
@@ -12242,7 +12271,7 @@ function hg(e) {
12242
12271
  "[class*='menu'] a",
12243
12272
  "[class*='header'] a"
12244
12273
  ];
12245
- if (eg((t) => {
12274
+ if (rg((t) => {
12246
12275
  for (let r of n) try {
12247
12276
  t.querySelectorAll(r).forEach((t) => {
12248
12277
  if (An(t)) return;
@@ -12250,7 +12279,7 @@ function hg(e) {
12250
12279
  if (!r || !n || n === "#" || n.startsWith("javascript:")) return;
12251
12280
  try {
12252
12281
  let e = t.parentElement;
12253
- if (e && $h(e).display === "none" && !e.closest("nav, [role='navigation'], header, [class*='nav'], [class*='menu']")) return;
12282
+ if (e && ng(e).display === "none" && !e.closest("nav, [role='navigation'], header, [class*='nav'], [class*='menu']")) return;
12254
12283
  } catch {}
12255
12284
  let i = r.toLowerCase() + "|" + n;
12256
12285
  e.has(i) || e.set(i, {
@@ -12261,7 +12290,7 @@ function hg(e) {
12261
12290
  } catch {}
12262
12291
  t.querySelectorAll("select").forEach((t) => {
12263
12292
  if (An(t)) return;
12264
- let n = ng(t);
12293
+ let n = ag(t);
12265
12294
  /nav|menu|page|section|go to/i.test(n || t.name || t.id || "") && Array.from(t.options).forEach((r) => {
12266
12295
  if (!r.value || r.disabled) return;
12267
12296
  let i = r.text.trim();
@@ -12283,7 +12312,7 @@ function hg(e) {
12283
12312
  "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."),
12284
12313
  "fwh-get-current-page-mvp": async () => {
12285
12314
  if ($("fwh-get-current-page-mvp ▶"), typeof window > "u") return "Cannot determine current page (no browser context).";
12286
- let e = window.location.href, t = window.location.pathname, n = document.title || "", { headings: r, pageTitleHeading: i, introText: a } = pg();
12315
+ let e = window.location.href, t = window.location.pathname, n = document.title || "", { headings: r, pageTitleHeading: i, introText: a } = gg();
12287
12316
  $("fwh-get-current-page-mvp ✓", {
12288
12317
  url: e,
12289
12318
  path: t,
@@ -12295,7 +12324,7 @@ function hg(e) {
12295
12324
  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. ***`;
12296
12325
  },
12297
12326
  "fwh-list-forms-mvp": async () => {
12298
- let e = ig(), t = ag();
12327
+ let e = sg(), t = cg();
12299
12328
  $("fwh-list-forms-mvp ✓", `${e.length} field(s)`, `${t.length} button(s)`);
12300
12329
  let n = e.map((e) => ({
12301
12330
  ...e,
@@ -12309,12 +12338,12 @@ function hg(e) {
12309
12338
  },
12310
12339
  "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.",
12311
12340
  "fwh-click-button-mvp": async (e) => {
12312
- let t = ug(e), n = (t.button_text ?? t.buttonText ?? t.text ?? "").trim(), r = (t.card_context ?? t.cardContext ?? "").trim();
12341
+ let t = pg(e), n = (t.button_text ?? t.buttonText ?? t.text ?? "").trim(), r = (t.card_context ?? t.cardContext ?? "").trim();
12313
12342
  if ($("fwh-click-button-mvp ▶", n, r ? `(card_context: ${r})` : ""), !n) return "Missing button_text: pass the visible label, e.g. Conduct Audit.";
12314
- let a = lg(n, i, r);
12343
+ let a = fg(n, i, r);
12315
12344
  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.`;
12316
12345
  try {
12317
- Ph(`Clicking ${n}...`, { spinner: !0 });
12346
+ Lh(`Clicking ${n}...`, { spinner: !0 });
12318
12347
  try {
12319
12348
  a.scrollIntoView({
12320
12349
  block: "center",
@@ -12323,22 +12352,22 @@ function hg(e) {
12323
12352
  } catch {
12324
12353
  a.scrollIntoView(!0);
12325
12354
  }
12326
- await Gh(a), a.focus?.(), await qh(a), Jh(a), a.click();
12355
+ await Jh(a), a.focus?.(), await Xh(a), Zh(a), a.click();
12327
12356
  let e = (a.textContent || a.value || a.getAttribute("aria-label") || "").trim().slice(0, 80) || "button", t = `OK_CLICK ${e}`;
12328
- return $("fwh-click-button-mvp ✓", t), Ph(`Clicked ${e}`, {
12357
+ return $("fwh-click-button-mvp ✓", t), Lh(`Clicked ${e}`, {
12329
12358
  spinner: !1,
12330
12359
  icon: "✅",
12331
12360
  duration: 1200
12332
12361
  }), t;
12333
12362
  } catch (e) {
12334
12363
  let t = `Click failed: ${e?.message || String(e)}`;
12335
- return $("fwh-click-button-mvp ✖", t), Ph("Click failed", {
12364
+ return $("fwh-click-button-mvp ✖", t), Lh("Click failed", {
12336
12365
  spinner: !1,
12337
12366
  icon: "⚠️",
12338
12367
  duration: 1800
12339
12368
  }), t;
12340
12369
  } finally {
12341
- Kh(), Fh(700);
12370
+ Yh(), Rh(700);
12342
12371
  }
12343
12372
  }
12344
12373
  };
@@ -12352,18 +12381,18 @@ function hg(e) {
12352
12381
  clickPageButton: a["fwh-click-button-mvp"]
12353
12382
  };
12354
12383
  }
12355
- 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;
12356
- function _g() {
12384
+ var yg = /^(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;
12385
+ function bg() {
12357
12386
  try {
12358
- let { headings: e } = pg();
12359
- return (e || []).map((e) => typeof e == "string" ? e : e?.text || "").filter(Boolean).filter((e) => !gg.test(e.trim()));
12387
+ let { headings: e } = gg();
12388
+ return (e || []).map((e) => typeof e == "string" ? e : e?.text || "").filter(Boolean).filter((e) => !yg.test(e.trim()));
12360
12389
  } catch {
12361
12390
  return [];
12362
12391
  }
12363
12392
  }
12364
12393
  //#endregion
12365
12394
  //#region src/utils/wrapVoiceToolsForLogging.js
12366
- function vg(e) {
12395
+ function xg(e) {
12367
12396
  return !e || typeof e != "object" ? e : Object.fromEntries(Object.entries(e).map(([e, t]) => [e, async (n) => {
12368
12397
  let r = wn();
12369
12398
  r ? console.log("[FlowEngage:voice-tool] ▶", e, n) : console.info(`[FlowEngage] voice tool » ${e}`);
@@ -12380,7 +12409,7 @@ function vg(e) {
12380
12409
  }
12381
12410
  //#endregion
12382
12411
  //#region src/components/FlowEngageWidget.jsx
12383
- var yg = {
12412
+ var Sg = {
12384
12413
  blue: "#135bd8",
12385
12414
  red: "#ef334b",
12386
12415
  yellow: "#ffbd2e",
@@ -12388,7 +12417,7 @@ var yg = {
12388
12417
  highlight: "rgba(255,255,255,0.9)",
12389
12418
  green: "#10b981"
12390
12419
  };
12391
- function bg(e) {
12420
+ function Cg(e) {
12392
12421
  if (!Array.isArray(e) || e.length < 2) return "linear-gradient(145deg, #dce8f022 0%, #e8dff522 45%, #f5e0e022 100%), #f7f8fa";
12393
12422
  let [t, n, r] = e;
12394
12423
  return e.length >= 3 && r ? [
@@ -12402,12 +12431,12 @@ function bg(e) {
12402
12431
  "#f7f8fa"
12403
12432
  ].join(", ");
12404
12433
  }
12405
- function xg(e) {
12434
+ function wg(e) {
12406
12435
  if (!e || typeof e != "string") return "#1a1a1a";
12407
12436
  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;
12408
12437
  return .2126 * o(r) + .7152 * o(i) + .0722 * o(a) > .179 ? "#1a1a1a" : "#ffffff";
12409
12438
  }
12410
- function Sg(t) {
12439
+ function Tg(t) {
12411
12440
  let [n, r] = e.useState(null), i = typeof t == "string" ? t.trim() : "";
12412
12441
  return e.useEffect(() => {
12413
12442
  if (!i) {
@@ -12425,8 +12454,8 @@ function Sg(t) {
12425
12454
  };
12426
12455
  }, [i]), n;
12427
12456
  }
12428
- function Cg({ logo: t, style: n }) {
12429
- let r = Sg(typeof t == "string" ? t : null);
12457
+ function Eg({ logo: t, style: n }) {
12458
+ let r = Tg(typeof t == "string" ? t : null);
12430
12459
  if (!t) return null;
12431
12460
  if (typeof t == "string") return r ? /* @__PURE__ */ g("img", {
12432
12461
  src: r,
@@ -12451,7 +12480,7 @@ function Cg({ logo: t, style: n }) {
12451
12480
  children: i
12452
12481
  }) : null;
12453
12482
  }
12454
- function wg({ title: e }) {
12483
+ function Dg({ title: e }) {
12455
12484
  return /* @__PURE__ */ g("div", {
12456
12485
  style: {
12457
12486
  width: "100%",
@@ -12469,18 +12498,18 @@ function wg({ title: e }) {
12469
12498
  children: String(e || "FE").split(/\s+/).filter(Boolean).slice(0, 2).map((e) => e[0]?.toUpperCase() || "").join("") || "FE"
12470
12499
  });
12471
12500
  }
12472
- function Tg(e, t) {
12501
+ function Og(e, t) {
12473
12502
  let n = (t || "").trim();
12474
12503
  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;
12475
12504
  }
12476
- function Eg({ orbColors: e, ...t }) {
12477
- return /* @__PURE__ */ g(bh, {
12505
+ function kg({ orbColors: e, ...t }) {
12506
+ return /* @__PURE__ */ g(Ch, {
12478
12507
  colors: e,
12479
12508
  ...t
12480
12509
  });
12481
12510
  }
12482
- function Dg({ copy: e, orbColors: t, primaryColor: n, onYes: r, onLater: i, isMobile: a, isClosing: o }) {
12483
- let s = n || yg.green, c = xg(s), l = a ? 72 : 94, u = /* @__PURE__ */ _("div", {
12511
+ function Ag({ copy: e, orbColors: t, primaryColor: n, onYes: r, onLater: i, isMobile: a, isClosing: o }) {
12512
+ let s = n || Sg.green, c = wg(s), l = a ? 72 : 94, u = /* @__PURE__ */ _("div", {
12484
12513
  style: {
12485
12514
  display: "flex",
12486
12515
  alignItems: a ? "flex-end" : "center",
@@ -12606,7 +12635,7 @@ function Dg({ copy: e, orbColors: t, primaryColor: n, onYes: r, onLater: i, isMo
12606
12635
  delay: 0
12607
12636
  },
12608
12637
  style: { flexShrink: 0 },
12609
- children: /* @__PURE__ */ g(Eg, {
12638
+ children: /* @__PURE__ */ g(kg, {
12610
12639
  size: l,
12611
12640
  orbColors: t
12612
12641
  })
@@ -12638,8 +12667,8 @@ function Dg({ copy: e, orbColors: t, primaryColor: n, onYes: r, onLater: i, isMo
12638
12667
  children: u
12639
12668
  })] });
12640
12669
  }
12641
- function Og({ copy: e, orbColors: t, primaryColor: n, onVoice: r, onText: i, onClose: a, isMobile: o, isClosing: s }) {
12642
- let c = n || yg.green, l = xg(c);
12670
+ function jg({ copy: e, orbColors: t, primaryColor: n, onVoice: r, onText: i, onClose: a, isMobile: o, isClosing: s }) {
12671
+ let c = n || Sg.green, l = wg(c);
12643
12672
  return /* @__PURE__ */ _(ym.div, {
12644
12673
  initial: {
12645
12674
  scale: 50 / 350,
@@ -12710,7 +12739,7 @@ function Og({ copy: e, orbColors: t, primaryColor: n, onVoice: r, onText: i, onC
12710
12739
  children: /* @__PURE__ */ g("polyline", { points: "6 9 12 15 18 9" })
12711
12740
  })
12712
12741
  }),
12713
- /* @__PURE__ */ g(Eg, {
12742
+ /* @__PURE__ */ g(kg, {
12714
12743
  size: 72,
12715
12744
  orbColors: t
12716
12745
  }),
@@ -12790,9 +12819,9 @@ function Og({ copy: e, orbColors: t, primaryColor: n, onVoice: r, onText: i, onC
12790
12819
  ]
12791
12820
  });
12792
12821
  }
12793
- 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" }) {
12822
+ function Mg({ 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" }) {
12794
12823
  c(() => (console.log("[FlowEngage:VoiceDebug] 🔵 VoiceMode MOUNTED"), () => console.log("[FlowEngage:VoiceDebug] 🔴 VoiceMode UNMOUNTED")), []);
12795
- 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), M = 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) => {
12824
+ let [w, T] = m("idle"), [E, D] = m(!1), [ee, O] = m(!1), [k, te] = m(!1), [ne, re] = m(""), [A, ie] = m(""), j = p(!1), ae = p(!1), oe = p(null), M = p(0), se = p(""), ce = p(!1), le = p(0), ue = p(!1), de = p(!1), fe = p([]), pe = p(null), me = (e) => {
12796
12825
  ue.current = e, N.current?.setWalkthroughActive?.(e);
12797
12826
  };
12798
12827
  pe.current = async () => {
@@ -12816,14 +12845,14 @@ function kg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
12816
12845
  ve.current || (ve.current = !0, _e.current?.());
12817
12846
  });
12818
12847
  }, [l]), L = o(() => {
12819
- ae.current &&= (clearTimeout(ae.current), null);
12848
+ oe.current &&= (clearTimeout(oe.current), null);
12820
12849
  }, []);
12821
12850
  c(() => {
12822
12851
  if (y) {
12823
- ie.current = !1;
12852
+ j.current = !1;
12824
12853
  return;
12825
12854
  }
12826
- if (ie.current = !0, M.current = !1, ee(!1), L(), ce.current) {
12855
+ if (j.current = !0, ae.current = !1, te(!1), L(), ce.current) {
12827
12856
  ce.current = !1, N.current?.setMicMuted?.(!1);
12828
12857
  let e = se.current;
12829
12858
  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}"`);
@@ -12831,9 +12860,9 @@ function kg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
12831
12860
  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.");
12832
12861
  }, [y, L]);
12833
12862
  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(() => {
12834
- L(), ae.current = setTimeout(() => {
12835
- if (!(!M.current || ie.current)) if (oe.current < 3) {
12836
- oe.current += 1;
12863
+ L(), oe.current = setTimeout(() => {
12864
+ if (!(!ae.current || j.current)) if (M.current < 3) {
12865
+ M.current += 1;
12837
12866
  try {
12838
12867
  N.current?.injectAgentSpeech?.("I still need your email in the box below to continue — could you enter it, please?", "queue");
12839
12868
  } catch {}
@@ -12842,7 +12871,7 @@ function kg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
12842
12871
  try {
12843
12872
  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");
12844
12873
  } catch {}
12845
- M.current = !1, ee(!1), L(), I.current = !0;
12874
+ ae.current = !1, te(!1), L(), I.current = !0;
12846
12875
  }
12847
12876
  }, 1e4);
12848
12877
  }, [L]), R = o(async (e) => {
@@ -12896,7 +12925,7 @@ function kg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
12896
12925
  if ((await navigator.mediaDevices.getUserMedia({ audio: !0 })).getTracks().forEach((e) => e.stop()), e) return;
12897
12926
  l.current = [], ge.current = "", ve.current = !1, be.current = !1, xe.current = !1, Se.current = "minimized", Cr({ onBeforeNavigate: () => {
12898
12927
  if (i && l.current.length > 0) try {
12899
- let e = kh(l.current);
12928
+ let e = Mh(l.current);
12900
12929
  e && P(i, e);
12901
12930
  } catch {}
12902
12931
  if (!qn()) {
@@ -12918,7 +12947,7 @@ function kg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
12918
12947
  }
12919
12948
  Ee();
12920
12949
  } });
12921
- let t = vg(hg({
12950
+ let t = xg(vg({
12922
12951
  siteId: i || null,
12923
12952
  apiBaseUrl: a || null,
12924
12953
  chatId: s || null,
@@ -12927,7 +12956,7 @@ function kg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
12927
12956
  I.current = !0;
12928
12957
  },
12929
12958
  requestEmailCollection: () => {
12930
- b && (ie.current || M.current || (M.current = !0, oe.current = 0, ee(!0), Le()));
12959
+ b && (j.current || ae.current || (ae.current = !0, M.current = 0, te(!0), Le()));
12931
12960
  }
12932
12961
  })), 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 = {
12933
12962
  apiBaseUrl: a,
@@ -12953,14 +12982,14 @@ function kg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
12953
12982
  let e = f || "";
12954
12983
  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}`);
12955
12984
  }
12956
- 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, ae = !1, _e = !1, Te = b && !!y && !de.current, De = await Mm.startSession({
12985
+ let ee = !1, O = 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, k = !1, ne = !p && !r ? "Your greeting has been spoken. Wait for the visitor to ask a question or tell you what they need. Do NOT auto-start a walkthrough or highlight any sections — let the visitor lead." : null, re = r && !p, A = !1, ie = re ? `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 && !de.current, De = await Fm.startSession({
12957
12986
  ...x,
12958
12987
  onConnect: ({ conversationId: e }) => {
12959
12988
  Ce.current = e, F.current = Date.now(), console.log("[FlowEngage] 🎙️ AI chat session connected:", e);
12960
12989
  },
12961
12990
  onUnhandledClientToolCall: (e) => console.error("[FlowEngage] Unhandled tool:", e?.tool_name),
12962
12991
  onSessionInfo: ({ emailOnFile: e }) => {
12963
- de.current = !!e, e && (ie.current = !0, M.current = !1, ee(!1), L(), console.log("[FlowEngage] email already on file per server — gate disabled"));
12992
+ de.current = !!e, e && (j.current = !0, ae.current = !1, te(!1), L(), console.log("[FlowEngage] email already on file per server — gate disabled"));
12964
12993
  },
12965
12994
  onAgentTurnEnd: () => {
12966
12995
  e || ue.current && (ce.current || setTimeout(() => pe.current?.(), 250));
@@ -12978,28 +13007,28 @@ function kg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
12978
13007
  I.current = !1, Pe();
12979
13008
  return;
12980
13009
  }
12981
- if (Te && !_e && !ie.current && !de.current) {
12982
- _e = !0, O = !0, A = !0;
13010
+ if (Te && !_e && !j.current && !de.current) {
13011
+ _e = !0, ee = !0, k = !0;
12983
13012
  try {
12984
13013
  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.");
12985
13014
  } catch {}
12986
13015
  }
12987
- if (k && !O) {
12988
- O = !0;
13016
+ if (O && !ee) {
13017
+ ee = !0;
12989
13018
  try {
12990
- N.current?.sendContextualUpdate?.(k);
13019
+ N.current?.sendContextualUpdate?.(O);
12991
13020
  } catch {}
12992
13021
  }
12993
- if (re && !j) {
12994
- j = !0;
13022
+ if (ie && !A) {
13023
+ A = !0;
12995
13024
  try {
12996
- N.current?.sendContextualUpdate?.(re);
13025
+ N.current?.sendContextualUpdate?.(ie);
12997
13026
  } catch {}
12998
13027
  }
12999
- if (te && !A) {
13000
- A = !0;
13028
+ if (ne && !k) {
13029
+ k = !0;
13001
13030
  try {
13002
- N.current?.sendContextualUpdate?.(te);
13031
+ N.current?.sendContextualUpdate?.(ne);
13003
13032
  } catch {}
13004
13033
  }
13005
13034
  je.current && clearTimeout(je.current), je.current = setTimeout(() => {
@@ -13009,7 +13038,7 @@ function kg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13009
13038
  },
13010
13039
  onMessage: (t) => {
13011
13040
  if (e || ce.current && t.role !== "user" && !/email/i.test(String(t.message || ""))) return;
13012
- t.role === "user" && Fe.test(String(t.message || "")) && (typeof window < "u" && (window.__fe_user_nav_during_speech = null), 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);
13041
+ t.role === "user" && Fe.test(String(t.message || "")) && (typeof window < "u" && (window.__fe_user_nav_during_speech = null), me(!0), le.current = 0, he.current = -1, fe.current = bg(), 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);
13013
13042
  let n = t.role === "user" ? "user" : "bot", r = t.message || t.text || t.content || "";
13014
13043
  if (r) {
13015
13044
  if (n === "user") {
@@ -13017,17 +13046,18 @@ function kg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13017
13046
  try {
13018
13047
  On();
13019
13048
  } catch {}
13020
- Te && !ae && !ie.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), M.current || (M.current = !0, oe.current = 0, ee(!0), Le()));
13049
+ Te && !oe && !j.current && !de.current && (oe = !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), ae.current || (ae.current = !0, M.current = 0, te(!0), Le()));
13021
13050
  }
13022
13051
  if (l.current = [...l.current, {
13023
13052
  sender: n,
13024
13053
  message: r,
13025
- timestamp: (/* @__PURE__ */ new Date()).toISOString()
13054
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
13055
+ debug: t.debug
13026
13056
  }], i) try {
13027
- let e = kh(l.current);
13057
+ let e = Mh(l.current);
13028
13058
  e && P(i, e);
13029
13059
  } catch {}
13030
- if (Tg(n, r)) {
13060
+ if (Og(n, r)) {
13031
13061
  I.current = !0;
13032
13062
  return;
13033
13063
  }
@@ -13136,7 +13166,7 @@ function kg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13136
13166
  if (i) try {
13137
13167
  Ne(i);
13138
13168
  } catch {}
13139
- 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);
13169
+ typeof window < "u" && (window.__fe_user_nav_during_speech = null), wr(), je.current &&= (clearTimeout(je.current), null), oe.current &&= (clearTimeout(oe.current), null), Me.current = !1, ke.current = "idle", c && typeof window < "u" && (window.history.pushState = c), d && typeof window < "u" && window.removeEventListener("popstate", d);
13140
13170
  let t = o || N.current, n = Ce.current, f = F.current;
13141
13171
  if (t?.endSession?.().catch(() => {}), n && s && a) {
13142
13172
  let e = f ? Math.round((Date.now() - f) / 1e3) : 0, t = JSON.stringify({
@@ -13160,13 +13190,13 @@ function kg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13160
13190
  a,
13161
13191
  Pe
13162
13192
  ]), c(() => {
13163
- if (!O) return;
13193
+ if (!ee) return;
13164
13194
  let e = (e) => {
13165
13195
  let t = e.composedPath?.()?.[0] || e.target;
13166
- De.current && !De.current.contains(t) && k(!1);
13196
+ De.current && !De.current.contains(t) && O(!1);
13167
13197
  };
13168
13198
  return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
13169
- }, [O]);
13199
+ }, [ee]);
13170
13200
  let Re = async () => {
13171
13201
  if (N.current) try {
13172
13202
  if (E) {
@@ -13183,23 +13213,23 @@ function kg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13183
13213
  } catch {}
13184
13214
  }, ze = o(async (e) => {
13185
13215
  e?.preventDefault?.();
13186
- let t = te.trim().toLowerCase();
13216
+ let t = ne.trim().toLowerCase();
13187
13217
  if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t)) {
13188
- re("Please enter a valid email address.");
13218
+ ie("Please enter a valid email address.");
13189
13219
  return;
13190
13220
  }
13191
- re("");
13221
+ ie("");
13192
13222
  try {
13193
13223
  typeof v == "function" && await v(t);
13194
13224
  } catch {}
13195
- ie.current = !0, M.current = !1, L(), ee(!1), ne(""), ce.current = !1, N.current?.setMicMuted?.(!1);
13225
+ j.current = !0, ae.current = !1, L(), te(!1), re(""), ce.current = !1, N.current?.setMicMuted?.(!1);
13196
13226
  let n = se.current;
13197
13227
  se.current = "";
13198
13228
  try {
13199
13229
  N.current?.injectAgentSpeech?.("Thank you for submitting your email."), N.current?.sendUserMessage?.(n || "The visitor's email is on file. Carry on helping them and never ask for it again.");
13200
13230
  } catch {}
13201
13231
  }, [
13202
- te,
13232
+ ne,
13203
13233
  v,
13204
13234
  L
13205
13235
  ]), Be = Array.isArray(e) && e[0] || "#3B82F6";
@@ -13214,7 +13244,7 @@ function kg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13214
13244
  animation: "fe-orb-slide-up 0.42s cubic-bezier(0.16,1,0.3,1)"
13215
13245
  },
13216
13246
  children: [
13217
- A && /* @__PURE__ */ _("form", {
13247
+ k && /* @__PURE__ */ _("form", {
13218
13248
  onSubmit: ze,
13219
13249
  style: {
13220
13250
  width: "270px",
@@ -13246,9 +13276,9 @@ function kg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13246
13276
  inputMode: "email",
13247
13277
  autoComplete: "email",
13248
13278
  autoFocus: !0,
13249
- value: te,
13279
+ value: ne,
13250
13280
  onChange: (e) => {
13251
- ne(e.target.value), j && re("");
13281
+ re(e.target.value), A && ie("");
13252
13282
  },
13253
13283
  placeholder: "you@example.com",
13254
13284
  style: {
@@ -13256,33 +13286,33 @@ function kg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13256
13286
  boxSizing: "border-box",
13257
13287
  padding: "10px 12px",
13258
13288
  borderRadius: "10px",
13259
- border: j ? "1.5px solid #ef4444" : "1.5px solid #4b5563",
13289
+ border: A ? "1.5px solid #ef4444" : "1.5px solid #4b5563",
13260
13290
  background: "#1f2937",
13261
13291
  color: "white",
13262
13292
  fontSize: "14px",
13263
13293
  outline: "none"
13264
13294
  }
13265
13295
  }),
13266
- j && /* @__PURE__ */ g("span", {
13296
+ A && /* @__PURE__ */ g("span", {
13267
13297
  style: {
13268
13298
  color: "#f87171",
13269
13299
  fontSize: "12px"
13270
13300
  },
13271
- children: j
13301
+ children: A
13272
13302
  }),
13273
13303
  /* @__PURE__ */ g("button", {
13274
13304
  type: "submit",
13275
- disabled: !te.trim(),
13305
+ disabled: !ne.trim(),
13276
13306
  style: {
13277
13307
  width: "100%",
13278
13308
  padding: "10px 12px",
13279
13309
  borderRadius: "10px",
13280
13310
  border: "none",
13281
- background: te.trim() ? Be : "#374151",
13311
+ background: ne.trim() ? Be : "#374151",
13282
13312
  color: "white",
13283
13313
  fontSize: "14px",
13284
13314
  fontWeight: 600,
13285
- cursor: te.trim() ? "pointer" : "default",
13315
+ cursor: ne.trim() ? "pointer" : "default",
13286
13316
  transition: "background 0.2s ease"
13287
13317
  },
13288
13318
  children: "Submit"
@@ -13324,7 +13354,7 @@ function kg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13324
13354
  },
13325
13355
  children: "Muted"
13326
13356
  }),
13327
- /* @__PURE__ */ g(Eg, {
13357
+ /* @__PURE__ */ g(kg, {
13328
13358
  size: 72,
13329
13359
  voiceState: w,
13330
13360
  isMuted: E,
@@ -13396,12 +13426,12 @@ function kg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13396
13426
  y2: "23"
13397
13427
  })
13398
13428
  ]
13399
- }) : /* @__PURE__ */ g(Nm, {
13429
+ }) : /* @__PURE__ */ g(Im, {
13400
13430
  size: 16,
13401
13431
  color: "currentColor"
13402
13432
  })
13403
13433
  }), /* @__PURE__ */ g("button", {
13404
- onClick: () => k((e) => !e),
13434
+ onClick: () => O((e) => !e),
13405
13435
  style: {
13406
13436
  width: "24px",
13407
13437
  height: "24px",
@@ -13418,13 +13448,13 @@ function kg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13418
13448
  padding: 0,
13419
13449
  flexShrink: 0
13420
13450
  },
13421
- children: /* @__PURE__ */ g(Vm, {
13451
+ children: /* @__PURE__ */ g(Wm, {
13422
13452
  size: 16,
13423
13453
  color: "currentColor"
13424
13454
  })
13425
13455
  })]
13426
13456
  }),
13427
- O && /* @__PURE__ */ _("div", {
13457
+ ee && /* @__PURE__ */ _("div", {
13428
13458
  style: {
13429
13459
  position: "absolute",
13430
13460
  bottom: 0,
@@ -13442,7 +13472,7 @@ function kg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13442
13472
  children: [
13443
13473
  /* @__PURE__ */ _("button", {
13444
13474
  onClick: () => {
13445
- k(!1), Se.current = "chat", R(t);
13475
+ O(!1), Se.current = "chat", R(t);
13446
13476
  },
13447
13477
  style: {
13448
13478
  display: "flex",
@@ -13467,11 +13497,11 @@ function kg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13467
13497
  onMouseLeave: (e) => {
13468
13498
  e.currentTarget.style.background = "none";
13469
13499
  },
13470
- children: [/* @__PURE__ */ g(Hm, {}), S]
13500
+ children: [/* @__PURE__ */ g(Gm, {}), S]
13471
13501
  }),
13472
13502
  /* @__PURE__ */ _("button", {
13473
13503
  onClick: () => {
13474
- k(!1), Se.current = "minimized", R(n);
13504
+ O(!1), Se.current = "minimized", R(n);
13475
13505
  },
13476
13506
  style: {
13477
13507
  display: "flex",
@@ -13496,10 +13526,10 @@ function kg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13496
13526
  onMouseLeave: (e) => {
13497
13527
  e.currentTarget.style.background = "none";
13498
13528
  },
13499
- children: [/* @__PURE__ */ g(Um, {}), C]
13529
+ children: [/* @__PURE__ */ g(Km, {}), C]
13500
13530
  }),
13501
13531
  /* @__PURE__ */ g("button", {
13502
- onClick: () => k(!1),
13532
+ onClick: () => O(!1),
13503
13533
  style: {
13504
13534
  position: "absolute",
13505
13535
  bottom: "8px",
@@ -13548,7 +13578,7 @@ function kg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13548
13578
  ]
13549
13579
  });
13550
13580
  }
13551
- function Ag({ orbColors: e }) {
13581
+ function Ng({ orbColors: e }) {
13552
13582
  let t = Array.isArray(e) && e.length > 0 ? e : [
13553
13583
  "#135bd8",
13554
13584
  "#ef334b",
@@ -13567,7 +13597,7 @@ function Ag({ orbColors: e }) {
13567
13597
  `.replace(/\s+/g, " ").trim()
13568
13598
  } });
13569
13599
  }
13570
- var jg = () => /* @__PURE__ */ g("div", {
13600
+ var Pg = () => /* @__PURE__ */ g("div", {
13571
13601
  style: {
13572
13602
  display: "flex",
13573
13603
  marginBottom: "12px",
@@ -13597,7 +13627,7 @@ var jg = () => /* @__PURE__ */ g("div", {
13597
13627
  } }, e))
13598
13628
  })
13599
13629
  });
13600
- 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: re, emailError: ie, emailCaptureSuccess: M, 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 }) {
13630
+ function Fg({ 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: ee, onFileSelect: O, onRemoveSelectedFile: k, attachmentError: te, isUploadingAttachment: ne, requiresEmail: re, emailInput: A, setEmailInput: ie, emailError: j, emailCaptureSuccess: ae, replyContext: oe, setReplyContext: M, 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 }) {
13601
13631
  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);
13602
13632
  c(() => {
13603
13633
  if (!s) return;
@@ -13737,7 +13767,7 @@ function Mg({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
13737
13767
  justifyContent: "center",
13738
13768
  height: "40px"
13739
13769
  },
13740
- children: i ? /* @__PURE__ */ g(Cg, {
13770
+ children: i ? /* @__PURE__ */ g(Eg, {
13741
13771
  logo: i,
13742
13772
  style: {
13743
13773
  height: "34px",
@@ -13750,7 +13780,7 @@ function Mg({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
13750
13780
  height: "40px",
13751
13781
  flexShrink: 0
13752
13782
  },
13753
- children: /* @__PURE__ */ g(wg, { title: e.chatTitle })
13783
+ children: /* @__PURE__ */ g(Dg, { title: e.chatTitle })
13754
13784
  })
13755
13785
  }), o && /* @__PURE__ */ g("div", {
13756
13786
  style: {
@@ -14033,7 +14063,7 @@ function Mg({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
14033
14063
  })
14034
14064
  ]
14035
14065
  }),
14036
- /* @__PURE__ */ g(dh, {
14066
+ /* @__PURE__ */ g(mh, {
14037
14067
  webRTCError: se,
14038
14068
  micError: ce,
14039
14069
  setMicError: le,
@@ -14041,7 +14071,7 @@ function Mg({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
14041
14071
  isRateLimited: E,
14042
14072
  rateLimitMessage: D
14043
14073
  }),
14044
- ge && /* @__PURE__ */ g(Oh, {
14074
+ ge && /* @__PURE__ */ g(jh, {
14045
14075
  agentName: v,
14046
14076
  agentHeadshot: y,
14047
14077
  fallbackAgentName: b,
@@ -14175,17 +14205,17 @@ function Mg({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
14175
14205
  children: "No previous chats found."
14176
14206
  })
14177
14207
  })]
14178
- }) : null, De ? /* @__PURE__ */ g(ch, {
14208
+ }) : null, De ? /* @__PURE__ */ g(dh, {
14179
14209
  chatHistory: l,
14180
14210
  isAiTyping: u,
14181
14211
  isLoading: T,
14182
14212
  isAgentTyping: d,
14183
- setReplyContext: oe,
14184
- TypingDots: jg,
14213
+ setReplyContext: M,
14214
+ TypingDots: Pg,
14185
14215
  primaryColor: n,
14186
14216
  agentHeadshot: y,
14187
14217
  agentDisplayName: v || b,
14188
- botAvatarNode: /* @__PURE__ */ g(Ag, { orbColors: t })
14218
+ botAvatarNode: /* @__PURE__ */ g(Ng, { orbColors: t })
14189
14219
  }) : F ? /* @__PURE__ */ _("div", {
14190
14220
  style: {
14191
14221
  flex: 1,
@@ -14226,7 +14256,7 @@ function Mg({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
14226
14256
  padding: "28px 24px"
14227
14257
  },
14228
14258
  children: [
14229
- /* @__PURE__ */ g(Eg, {
14259
+ /* @__PURE__ */ g(kg, {
14230
14260
  size: 94,
14231
14261
  orbColors: t
14232
14262
  }),
@@ -14276,7 +14306,7 @@ function Mg({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
14276
14306
  ]
14277
14307
  })]
14278
14308
  }),
14279
- M && /* @__PURE__ */ _("div", {
14309
+ ae && /* @__PURE__ */ _("div", {
14280
14310
  style: {
14281
14311
  margin: "0 16px 8px",
14282
14312
  padding: "9px 14px",
@@ -14315,9 +14345,9 @@ function Mg({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
14315
14345
  flexShrink: 0,
14316
14346
  position: "relative",
14317
14347
  zIndex: 1,
14318
- padding: ne ? "6px 0 0" : "12px 0 0"
14348
+ padding: re ? "6px 0 0" : "12px 0 0"
14319
14349
  },
14320
- children: /* @__PURE__ */ g(uh, {
14350
+ children: /* @__PURE__ */ g(ph, {
14321
14351
  input: x,
14322
14352
  setInput: S,
14323
14353
  onSubmit: C,
@@ -14327,17 +14357,17 @@ function Mg({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
14327
14357
  showVoiceToggle: f === "agent",
14328
14358
  activeScreen: f,
14329
14359
  inputDisabled: Oe,
14330
- replyContext: ae,
14331
- clearReplyContext: () => oe(null),
14332
- onFileSelect: k,
14333
- selectedFile: O,
14334
- onRemoveSelectedFile: A,
14335
- attachmentError: ee,
14336
- isUploadingAttachment: te,
14337
- requiresEmail: ne,
14338
- emailInput: j,
14339
- setEmailInput: re,
14340
- emailError: ie,
14360
+ replyContext: oe,
14361
+ clearReplyContext: () => M(null),
14362
+ onFileSelect: O,
14363
+ selectedFile: ee,
14364
+ onRemoveSelectedFile: k,
14365
+ attachmentError: te,
14366
+ isUploadingAttachment: ne,
14367
+ requiresEmail: re,
14368
+ emailInput: A,
14369
+ setEmailInput: ie,
14370
+ emailError: j,
14341
14371
  inputPlaceholder: e.inputPlaceholder
14342
14372
  })
14343
14373
  }),
@@ -14391,14 +14421,14 @@ function Mg({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
14391
14421
  ]
14392
14422
  });
14393
14423
  }
14394
- function Ng() {
14395
- 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: M, 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();
14424
+ function Ig() {
14425
+ 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: ee, webRTCError: O, language: k, chatId: te, historyRef: ne, onMessageSync: re, sendMessage: A, uploadChatFile: ie, openWidget: j, captureVisitorEmail: ae, setVoiceMode: oe, endConversation: M, 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();
14396
14426
  c(() => {
14397
14427
  try {
14398
14428
  or();
14399
14429
  } catch {}
14400
14430
  }, []), c(() => {
14401
- be && V !== "voice_mode" && V !== "text_chat" && V !== "call_screen" && (ae?.(!1), H("text_chat"));
14431
+ be && V !== "voice_mode" && V !== "text_chat" && V !== "call_screen" && (oe?.(!1), H("text_chat"));
14402
14432
  }, [be]);
14403
14433
  let Se = t?.widgetSettings || {}, Ce = n?.widgetSettings || {}, P = {
14404
14434
  ...Se.branding || {},
@@ -14413,7 +14443,7 @@ function Ng() {
14413
14443
  small: 50,
14414
14444
  medium: 64,
14415
14445
  large: 80
14416
- }, 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) => ({
14446
+ }, Me = je[F.orbSize] || je.small, Ne = F.position || "bottom-right", Pe = P.fallbackAgentName || "Agent", L = Cg(I ?? F.chatBgColors), Fe = P.logo || P.logoUrl || null, Ie = k || "en", Le = Se.recommendations?.[Ie] || [], R = (Ce.recommendations?.[Ie] ?? Le).filter((e) => String(e?.label ?? "").trim()).map((e, t) => ({
14417
14447
  id: e.key || `qr-${t}`,
14418
14448
  label: e.label,
14419
14449
  message: e.label,
@@ -14434,7 +14464,7 @@ function Ng() {
14434
14464
  ...Ce.pageVisibility || {}
14435
14465
  };
14436
14466
  return Array.isArray(e.allowedPaths) ? e.allowedPaths.filter(Boolean) : [];
14437
- })(), 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 = {
14467
+ })(), 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?.[k] || Ce.greetings?.[k] || P.introGreeting || "Hello, I'm here to help you know more about OpenSense Labs.", Ye = {
14438
14468
  entryPrompt: P.entryPrompt || "Do you want to explore in a new way?",
14439
14469
  yesLabel: P.yesLabel || "Yes",
14440
14470
  laterLabel: P.laterLabel || "Later",
@@ -14471,11 +14501,11 @@ function Ng() {
14471
14501
  } catch {}
14472
14502
  let n = De(), r = z ? we(z) : null, i = n || !!r?.transcript;
14473
14503
  if (t) {
14474
- ie?.({ notifyChatInitiated: !0 }), ae?.(!0), H("voice_mode");
14504
+ j?.({ notifyChatInitiated: !0 }), oe?.(!0), H("voice_mode");
14475
14505
  return;
14476
14506
  }
14477
14507
  if (ke()) {
14478
- ie?.({ notifyChatInitiated: !1 }), H("text_chat");
14508
+ j?.({ notifyChatInitiated: !1 }), H("text_chat");
14479
14509
  return;
14480
14510
  }
14481
14511
  if (i) {
@@ -14483,7 +14513,7 @@ function Ng() {
14483
14513
  H("minimized_orb");
14484
14514
  return;
14485
14515
  }
14486
- ie?.({ notifyChatInitiated: !0 }), ae?.(!0), H("voice_mode");
14516
+ j?.({ notifyChatInitiated: !0 }), oe?.(!0), H("voice_mode");
14487
14517
  return;
14488
14518
  }
14489
14519
  if (z) try {
@@ -14504,7 +14534,7 @@ function Ng() {
14504
14534
  let Ot = o(() => {
14505
14535
  ht(null), _t("");
14506
14536
  }, []), kt = o((e) => {
14507
- let t = rh(e);
14537
+ let t = oh(e);
14508
14538
  if (t) {
14509
14539
  ht(null), _t(t);
14510
14540
  return;
@@ -14547,7 +14577,7 @@ function Ng() {
14547
14577
  hasIncomingCall: !!w?.callId,
14548
14578
  activeCallId: T,
14549
14579
  callConnectionState: E
14550
- }), wt.current = e, V === "voice_mode" && ae?.(!1), ie?.(), At());
14580
+ }), wt.current = e, V === "voice_mode" && oe?.(!1), j?.(), At());
14551
14581
  }
14552
14582
  }, [
14553
14583
  T,
@@ -14555,8 +14585,8 @@ function Ng() {
14555
14585
  At,
14556
14586
  w?.callId,
14557
14587
  i,
14558
- ie,
14559
- ae,
14588
+ j,
14589
+ oe,
14560
14590
  V
14561
14591
  ]), c(() => {
14562
14592
  !w && !T && V === "call_screen" && H("text_chat");
@@ -14602,7 +14632,7 @@ function Ng() {
14602
14632
  st("Please enter a valid email so we can continue helping you.");
14603
14633
  return;
14604
14634
  }
14605
- await M(e), st(""), lt(!0), setTimeout(() => lt(!1), 3e3);
14635
+ await ae(e), st(""), lt(!0), setTimeout(() => lt(!1), 3e3);
14606
14636
  return;
14607
14637
  }
14608
14638
  let t = Mt(it);
@@ -14610,8 +14640,8 @@ function Ng() {
14610
14640
  if (mt) {
14611
14641
  try {
14612
14642
  yt(!0), _t("");
14613
- let e = await re(mt), n = e?.data || e, r = nt.trim() || `Shared file: ${ah(mt)}`;
14614
- rt(""), U(null), Ot(), await j(r, "", t, {
14643
+ let e = await ie(mt), n = e?.data || e, r = nt.trim() || `Shared file: ${ch(mt)}`;
14644
+ rt(""), U(null), Ot(), await A(r, "", t, {
14615
14645
  type: "file",
14616
14646
  metadata: {
14617
14647
  fileUrl: n?.fileUrl,
@@ -14628,7 +14658,7 @@ function Ng() {
14628
14658
  return;
14629
14659
  }
14630
14660
  let n = nt.trim();
14631
- rt(""), U(null), await j(n, "", t);
14661
+ rt(""), U(null), await A(n, "", t);
14632
14662
  }, Pt = o(() => {
14633
14663
  r.length !== 0 && le?.();
14634
14664
  }, [r.length, le]), Ft = (e) => {
@@ -14637,11 +14667,11 @@ function Ng() {
14637
14667
  }, It = o(async (e) => {
14638
14668
  if (C || b) return;
14639
14669
  let t = e.message || e.label || e.text || "";
14640
- t.trim() && await j(t.trim(), "");
14670
+ t.trim() && await A(t.trim(), "");
14641
14671
  }, [
14642
14672
  C,
14643
14673
  b,
14644
- j
14674
+ A
14645
14675
  ]), Lt = G && V === "entry_prompt" ? { inset: 0 } : G && V === "text_chat" ? {
14646
14676
  left: 0,
14647
14677
  right: 0,
@@ -14687,11 +14717,11 @@ function Ng() {
14687
14717
  t.resume().catch(() => {}), setTimeout(() => t.close().catch(() => {}), 3e3);
14688
14718
  }
14689
14719
  } catch {}
14690
- ie({ notifyChatInitiated: !0 }), ae?.(!0), H("voice_mode");
14720
+ j({ notifyChatInitiated: !0 }), oe?.(!0), H("voice_mode");
14691
14721
  }, Vt = () => {
14692
- ie({ notifyChatInitiated: !0 }), ae?.(!1), H("text_chat");
14722
+ j({ notifyChatInitiated: !0 }), oe?.(!1), H("text_chat");
14693
14723
  }, Ht = () => {
14694
- ae?.(!1), Rt();
14724
+ oe?.(!1), Rt();
14695
14725
  };
14696
14726
  return e !== "ready" || !Ue || Ee.chat === !1 || !qe ? null : /* @__PURE__ */ _("div", {
14697
14727
  className: "flowengage-widget-root",
@@ -14703,7 +14733,7 @@ function Ng() {
14703
14733
  onWheel: (e) => e.stopPropagation(),
14704
14734
  onTouchMove: (e) => e.stopPropagation(),
14705
14735
  children: [
14706
- V === "entry_prompt" && /* @__PURE__ */ g(Dg, {
14736
+ V === "entry_prompt" && /* @__PURE__ */ g(Ag, {
14707
14737
  copy: Ye,
14708
14738
  orbColors: I,
14709
14739
  primaryColor: Ae,
@@ -14786,13 +14816,13 @@ function Ng() {
14786
14816
  children: E === "connected" ? `${Ft(ut)} with ${Ze}` : `Tap to return to ${Ze}`
14787
14817
  })]
14788
14818
  })]
14789
- }), /* @__PURE__ */ g(Eg, {
14819
+ }), /* @__PURE__ */ g(kg, {
14790
14820
  size: Me,
14791
14821
  orbColors: I,
14792
14822
  onClick: T ? At : Oe ? zt : Vt
14793
14823
  })]
14794
14824
  }),
14795
- V === "connection_modal" && /* @__PURE__ */ g(Og, {
14825
+ V === "connection_modal" && /* @__PURE__ */ g(jg, {
14796
14826
  copy: Ye,
14797
14827
  orbColors: I,
14798
14828
  primaryColor: Ae,
@@ -14802,32 +14832,32 @@ function Ng() {
14802
14832
  isMobile: G,
14803
14833
  isClosing: St
14804
14834
  }),
14805
- V === "voice_mode" && /* @__PURE__ */ g(kg, {
14835
+ V === "voice_mode" && /* @__PURE__ */ g(Mg, {
14806
14836
  orbColors: I,
14807
14837
  onEnterChat: Vt,
14808
14838
  onEndChat: Ht,
14809
14839
  agentId: Xe,
14810
14840
  siteId: z,
14811
14841
  apiBaseUrl: B,
14812
- chatId: ee,
14813
- historyRef: te,
14814
- onMessageSync: ne,
14842
+ chatId: te,
14843
+ historyRef: ne,
14844
+ onMessageSync: re,
14815
14845
  voiceEndCounter: xe,
14816
14846
  websiteName: t?.websiteName,
14817
14847
  voiceFirstMessage: Se.voiceFirstMessage || null,
14818
- captureVisitorEmail: M,
14848
+ captureVisitorEmail: ae,
14819
14849
  emailRequired: !h,
14820
14850
  emailCaptureEnabled: P.disableEmailCapture !== !0,
14821
14851
  listeningLabel: P.voiceListeningLabel || "Listening...",
14822
14852
  enterChatModeLabel: P.voiceEnterChatLabel || "Enter Chat Mode",
14823
14853
  endConversationLabel: P.voiceEndConversationLabel || "End Conversation"
14824
14854
  }, "voice"),
14825
- V === "call_screen" && /* @__PURE__ */ g(Dh, {
14855
+ V === "call_screen" && /* @__PURE__ */ g(Ah, {
14826
14856
  incomingCall: w,
14827
14857
  activeCallId: T,
14828
14858
  callConnectionState: E,
14829
14859
  callDurationSeconds: ut,
14830
- isCallMuted: O,
14860
+ isCallMuted: ee,
14831
14861
  agentName: Ze,
14832
14862
  agentHeadshot: Qe,
14833
14863
  fallbackAgentName: Pe,
@@ -14841,7 +14871,7 @@ function Ng() {
14841
14871
  orbColors: I,
14842
14872
  chatHistory: r
14843
14873
  }),
14844
- V === "text_chat" && /* @__PURE__ */ g(Mg, {
14874
+ V === "text_chat" && /* @__PURE__ */ g(Fg, {
14845
14875
  isClosing: St,
14846
14876
  copy: Ye,
14847
14877
  orbColors: I,
@@ -14877,12 +14907,12 @@ function Ng() {
14877
14907
  emailCaptureSuccess: ct,
14878
14908
  replyContext: it,
14879
14909
  setReplyContext: U,
14880
- webRTCError: k,
14910
+ webRTCError: O,
14881
14911
  micError: ft,
14882
14912
  setMicError: pt,
14883
14913
  dismissCallError: me,
14884
14914
  activeCallId: T,
14885
- isCallMuted: O,
14915
+ isCallMuted: ee,
14886
14916
  toggleCallMute: pe,
14887
14917
  endWebRTCCall: fe,
14888
14918
  formatCallDuration: Ft,
@@ -14907,7 +14937,7 @@ function Ng() {
14907
14937
  }
14908
14938
  //#endregion
14909
14939
  //#region src/components/ErrorBoundary.jsx
14910
- var Pg = class extends e.Component {
14940
+ var Lg = class extends e.Component {
14911
14941
  constructor(e) {
14912
14942
  super(e), this.state = { hasError: !1 };
14913
14943
  }
@@ -14922,4 +14952,4 @@ var Pg = class extends e.Component {
14922
14952
  }
14923
14953
  };
14924
14954
  //#endregion
14925
- export { bh as AnimatedOrb, Pg as ErrorBoundary, Mr as FlowEngageProvider, Ng as FlowEngageWidget, Cn as useFlowEngage };
14955
+ export { Ch as AnimatedOrb, Lg as ErrorBoundary, Mr as FlowEngageProvider, Ig as FlowEngageWidget, Cn as useFlowEngage };