@flowengage/react-chatbot 8.0.110 → 8.0.112

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -34,46 +34,46 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
34
34
  agentName: "flowengage.agentName",
35
35
  agentHeadshot: "flowengage.agentHeadshot",
36
36
  visitorEmail: "flowengage.visitorEmail"
37
- }, ee = 6e4, te = 480 * 60, ne = 3e4, j = typeof window < "u", M = (e) => e ? `flowengage.visitorEmail.${e}` : null, re = () => {
38
- if (!j) return null;
37
+ }, ee = 6e4, te = 480 * 60, j = 3e4, M = typeof window < "u", N = (e) => e ? `flowengage.visitorEmail.${e}` : null, ne = () => {
38
+ if (!M) return null;
39
39
  let e = window.localStorage.getItem(A.chatId);
40
40
  return e && String(e).trim() ? String(e).trim() : null;
41
- }, ie = () => {
42
- if (j) try {
41
+ }, re = () => {
42
+ if (M) try {
43
43
  window.localStorage.removeItem(A.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", N = (e) => e ? `flowengage.entrySeen.${e}` : null, oe = (e) => {
46
- if (!j || !e) return !1;
45
+ }, P = () => M ? typeof crypto < "u" && crypto.randomUUID ? crypto.randomUUID() : `${Date.now()}-${Math.random().toString(16).slice(2)}` : "server-chat-id", ie = (e) => e ? `flowengage.entrySeen.${e}` : null, F = (e) => {
46
+ if (!M || !e) return !1;
47
47
  try {
48
- let t = N(e);
48
+ let t = ie(e);
49
49
  return t ? window.localStorage.getItem(t) === "1" : !1;
50
50
  } catch {
51
51
  return !1;
52
52
  }
53
- }, se = (e) => {
54
- if (!(!j || !e)) try {
55
- let t = N(e);
53
+ }, ae = (e) => {
54
+ if (!(!M || !e)) try {
55
+ let t = ie(e);
56
56
  t && window.localStorage.setItem(t, "1");
57
57
  } catch {}
58
- }, P = (e) => e ? `flowengage.persistedChatId.${e}` : null, ce = (e) => {
59
- if (!j || !e) return null;
58
+ }, I = (e) => e ? `flowengage.persistedChatId.${e}` : null, oe = (e) => {
59
+ if (!M || !e) return null;
60
60
  try {
61
- let t = P(e), n = t ? window.localStorage.getItem(t) : null;
61
+ let t = I(e), n = t ? window.localStorage.getItem(t) : null;
62
62
  return n && String(n).trim() ? String(n).trim() : null;
63
63
  } catch {
64
64
  return null;
65
65
  }
66
- }, le = (e) => {
67
- if (!(!j || !e)) try {
68
- let t = P(e);
66
+ }, se = (e) => {
67
+ if (!(!M || !e)) try {
68
+ let t = I(e);
69
69
  t && window.localStorage.removeItem(t);
70
70
  } catch {}
71
- }, ue = (e, t) => {
72
- if (!(!j || !e || !t)) try {
73
- let n = P(e);
71
+ }, ce = (e, t) => {
72
+ if (!(!M || !e || !t)) try {
73
+ let n = I(e);
74
74
  n && window.localStorage.setItem(n, String(t).trim());
75
75
  } catch {}
76
- }, de = () => j ? {
76
+ }, le = () => M ? {
77
77
  isOpen: !1,
78
78
  activeScreen: window.sessionStorage.getItem(A.activeScreen) || "ai",
79
79
  isHumanHandled: window.sessionStorage.getItem(A.isHumanHandled) === "true",
@@ -87,8 +87,8 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
87
87
  agentName: null,
88
88
  agentHeadshot: null,
89
89
  visitorEmail: ""
90
- }, fe = (e) => {
91
- j && Object.entries(e).forEach(([e, t]) => {
90
+ }, ue = (e) => {
91
+ M && Object.entries(e).forEach(([e, t]) => {
92
92
  let n = A[e];
93
93
  if (n) {
94
94
  if (t == null || t === !1) {
@@ -98,17 +98,17 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
98
98
  window.sessionStorage.setItem(n, String(t));
99
99
  }
100
100
  });
101
- }, pe = (e) => {
102
- if (!j || !e) return "";
103
- let t = M(e), n = window.localStorage.getItem(t);
101
+ }, de = (e) => {
102
+ if (!M || !e) return "";
103
+ let t = N(e), n = window.localStorage.getItem(t);
104
104
  if (!n) {
105
105
  let e = window.sessionStorage.getItem(A.visitorEmail);
106
106
  e && (window.localStorage.setItem(t, e), window.sessionStorage.removeItem(A.visitorEmail), n = e);
107
107
  }
108
108
  return n || "";
109
- }, me = (e, t) => {
110
- if (!j) return;
111
- let n = M(t);
109
+ }, fe = (e, t) => {
110
+ if (!M) return;
111
+ let n = N(t);
112
112
  if (!n) return;
113
113
  let r = typeof e == "string" ? e.trim() : "";
114
114
  if (!r) {
@@ -116,91 +116,91 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
116
116
  return;
117
117
  }
118
118
  window.localStorage.setItem(n, r), window.sessionStorage.removeItem(A.visitorEmail);
119
- }, he = (e) => e ? `flowengage.visitorId.${e}` : null, ge = () => `v_${Date.now().toString(36)}_${typeof crypto < "u" && crypto.randomUUID ? crypto.randomUUID().replace(/-/g, "").slice(0, 16) : Math.random().toString(36).slice(2, 18)}`, F = (e) => {
120
- if (!j || !e) return null;
119
+ }, pe = (e) => e ? `flowengage.visitorId.${e}` : null, me = () => `v_${Date.now().toString(36)}_${typeof crypto < "u" && crypto.randomUUID ? crypto.randomUUID().replace(/-/g, "").slice(0, 16) : Math.random().toString(36).slice(2, 18)}`, he = (e) => {
120
+ if (!M || !e) return null;
121
121
  try {
122
- let t = he(e), n = t ? window.localStorage.getItem(t) : null;
122
+ let t = pe(e), n = t ? window.localStorage.getItem(t) : null;
123
123
  return n && String(n).trim() ? String(n).trim() : null;
124
124
  } catch {
125
125
  return null;
126
126
  }
127
- }, _e = (e) => {
128
- if (!j || !e) return null;
127
+ }, L = (e) => {
128
+ if (!M || !e) return null;
129
129
  try {
130
- let t = F(e);
130
+ let t = he(e);
131
131
  if (t) return t;
132
- let n = ge(), r = he(e);
132
+ let n = me(), r = pe(e);
133
133
  return r && window.localStorage.setItem(r, n), n;
134
134
  } catch {
135
- return ge();
135
+ return me();
136
136
  }
137
- }, ve = "flowengage.tabId", ye = () => {
138
- if (!j) return "default";
137
+ }, ge = "flowengage.tabId", _e = () => {
138
+ if (!M) return "default";
139
139
  try {
140
- let e = window.sessionStorage.getItem(ve);
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(ve, e)), e;
140
+ let e = window.sessionStorage.getItem(ge);
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(ge, e)), e;
142
142
  } catch {
143
143
  return "default";
144
144
  }
145
- }, I = (e) => e ? `flowengage.voice.transcript.${e}.${ye()}` : null, be = 600 * 1e3, L = (e, t, n = {}) => {
146
- if (!j || !e) return;
145
+ }, R = (e) => e ? `flowengage.voice.transcript.${e}.${_e()}` : null, ve = 600 * 1e3, z = (e, t, n = {}) => {
146
+ if (!M || !e) return;
147
147
  let r = typeof t == "string" ? t.trim() : "";
148
148
  if (!r) return;
149
- let i = Number.isFinite(n.ttlMs) ? n.ttlMs : be, a = {
149
+ let i = Number.isFinite(n.ttlMs) ? n.ttlMs : ve, a = {
150
150
  transcript: r,
151
151
  expiresAt: Date.now() + i
152
152
  };
153
153
  try {
154
- let t = I(e);
154
+ let t = R(e);
155
155
  t && window.localStorage.setItem(t, JSON.stringify(a));
156
156
  } catch {}
157
- }, xe = (e) => {
158
- if (!j || !e) return null;
157
+ }, ye = (e) => {
158
+ if (!M || !e) return null;
159
159
  try {
160
- let t = I(e), n = t ? window.localStorage.getItem(t) : null;
160
+ let t = R(e), n = t ? window.localStorage.getItem(t) : null;
161
161
  if (!n) return null;
162
162
  let r = JSON.parse(n);
163
163
  return !r || typeof r.transcript != "string" ? null : Number.isFinite(r.expiresAt) && Date.now() > r.expiresAt ? (window.localStorage.removeItem(t), null) : r;
164
164
  } catch {
165
165
  return null;
166
166
  }
167
- }, Se = (e) => {
168
- if (!(!j || !e)) try {
169
- let t = I(e);
167
+ }, be = (e) => {
168
+ if (!(!M || !e)) try {
169
+ let t = R(e);
170
170
  t && window.localStorage.removeItem(t);
171
171
  } catch {}
172
- }, R = "flowengage.voice.pendingResume", Ce = () => {
173
- if (j) try {
174
- window.sessionStorage.setItem(R, "1");
172
+ }, xe = "flowengage.voice.pendingResume", Se = () => {
173
+ if (M) try {
174
+ window.sessionStorage.setItem(xe, "1");
175
175
  } catch {}
176
- }, we = () => {
177
- if (!j) return !1;
176
+ }, Ce = () => {
177
+ if (!M) return !1;
178
178
  try {
179
- return window.sessionStorage.getItem(R) === "1" ? (window.sessionStorage.removeItem(R), !0) : !1;
179
+ return window.sessionStorage.getItem(xe) === "1" ? (window.sessionStorage.removeItem(xe), !0) : !1;
180
180
  } catch {
181
181
  return !1;
182
182
  }
183
- }, Te = "flowengage.chat.pendingReopen", Ee = () => {
184
- if (j) try {
185
- window.sessionStorage.setItem(Te, "1");
183
+ }, we = "flowengage.chat.pendingReopen", Te = () => {
184
+ if (M) try {
185
+ window.sessionStorage.setItem(we, "1");
186
186
  } catch {}
187
- }, De = () => {
188
- if (!j) return !1;
187
+ }, Ee = () => {
188
+ if (!M) return !1;
189
189
  try {
190
- return window.sessionStorage.getItem(Te) === "1" ? (window.sessionStorage.removeItem(Te), !0) : !1;
190
+ return window.sessionStorage.getItem(we) === "1" ? (window.sessionStorage.removeItem(we), !0) : !1;
191
191
  } catch {
192
192
  return !1;
193
193
  }
194
- }, Oe = () => {
195
- if (!j) return !1;
194
+ }, De = () => {
195
+ if (!M) return !1;
196
196
  try {
197
- return window.sessionStorage.getItem(R) === "1";
197
+ return window.sessionStorage.getItem(xe) === "1";
198
198
  } catch {
199
199
  return !1;
200
200
  }
201
- }, ke = (e) => e ? `flowengage.voice.navState.${e}.${ye()}` : null, Ae = (e, t, n, r) => {
202
- if (!(!j || !e || !t)) try {
203
- let i = ke(e);
201
+ }, Oe = (e) => e ? `flowengage.voice.navState.${e}.${_e()}` : null, ke = (e, t, n, r) => {
202
+ if (!(!M || !e || !t)) try {
203
+ let i = Oe(e);
204
204
  i && window.sessionStorage.setItem(i, JSON.stringify({
205
205
  previousPage: String(t),
206
206
  targetPath: n ? new URL(String(n), window.location.href).pathname : null,
@@ -208,10 +208,10 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
208
208
  ts: Date.now()
209
209
  }));
210
210
  } catch {}
211
- }, je = (e) => {
212
- if (!j || !e) return null;
211
+ }, Ae = (e) => {
212
+ if (!M || !e) return null;
213
213
  try {
214
- let t = ke(e);
214
+ let t = Oe(e);
215
215
  if (!t) return null;
216
216
  let n = window.sessionStorage.getItem(t);
217
217
  if (!n) return null;
@@ -224,14 +224,14 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
224
224
  } catch {
225
225
  return null;
226
226
  }
227
- }, Me = async (e) => {
227
+ }, je = async (e) => {
228
228
  let t = await e.json().catch(() => ({}));
229
229
  if (!e.ok) {
230
230
  let n = Error(t.message || t.error || `Request failed with status ${e.status}`);
231
231
  throw n.status = e.status, n;
232
232
  }
233
233
  return t;
234
- }, z = async (e, t = {}) => {
234
+ }, Me = async (e, t = {}) => {
235
235
  try {
236
236
  return await fetch(e, {
237
237
  mode: "cors",
@@ -243,7 +243,7 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
243
243
  }
244
244
  }, Ne = async ({ apiBaseUrl: e, userId: t, siteId: n, priorChatId: r = null, forceNew: i = !1, resumeChatId: a = null, visitorId: o = null }) => {
245
245
  let s = `${e}/api/visitors/resolve-session`, c = { siteId: n };
246
- return r && String(r).trim() && (c.priorChatId = String(r).trim()), i && (c.forceNew = !0), a && (c.resumeChatId = a), o && (c.visitorId = o), Me(await z(s, {
246
+ return r && String(r).trim() && (c.priorChatId = String(r).trim()), i && (c.forceNew = !0), a && (c.resumeChatId = a), o && (c.visitorId = o), je(await Me(s, {
247
247
  method: "POST",
248
248
  mode: "cors",
249
249
  headers: {
@@ -256,7 +256,7 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
256
256
  }));
257
257
  }, Pe = async ({ apiBaseUrl: e, siteId: t }) => {
258
258
  let n = typeof window < "u" ? window.location.origin : "http://localhost";
259
- return (await Me(await z(`${e}/api/widget/chatbot-loader?${new URLSearchParams({
259
+ return (await je(await Me(`${e}/api/widget/chatbot-loader?${new URLSearchParams({
260
260
  siteId: t,
261
261
  origin: n
262
262
  }).toString()}`, { method: "GET" }))).data;
@@ -274,7 +274,7 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
274
274
  headers: { "Content-Type": "application/json" },
275
275
  body: i
276
276
  }).catch(() => {}), !0) : !1;
277
- }, a = async (i, a = {}) => Me(await z(`${e}${i}`, {
277
+ }, a = async (i, a = {}) => je(await Me(`${e}${i}`, {
278
278
  ...a,
279
279
  headers: {
280
280
  "Content-Type": "application/json",
@@ -289,7 +289,7 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
289
289
  ...n ? { "x-site-id": n } : {},
290
290
  ...a.headers || {}
291
291
  };
292
- return Me(await z(`${e}${r}`, {
292
+ return je(await Me(`${e}${r}`, {
293
293
  ...a,
294
294
  body: i,
295
295
  headers: o
@@ -320,7 +320,7 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
320
320
  method: "POST",
321
321
  body: JSON.stringify(f)
322
322
  });
323
- let p = await z(`${e}/api/ai/chat`, {
323
+ let p = await Me(`${e}/api/ai/chat`, {
324
324
  method: "POST",
325
325
  headers: {
326
326
  "Content-Type": "application/json",
@@ -333,7 +333,7 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
333
333
  stream: !0
334
334
  })
335
335
  });
336
- if (!(p.headers.get("content-type") || "").includes("text/event-stream")) return Me(p);
336
+ if (!(p.headers.get("content-type") || "").includes("text/event-stream")) return je(p);
337
337
  let m = p.body.getReader(), h = new TextDecoder(), g = "", _ = null, v = (e) => {
338
338
  let t = e.split("\n").find((e) => e.startsWith("data: "));
339
339
  if (t) try {
@@ -449,7 +449,7 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
449
449
  });
450
450
  },
451
451
  async getIceServersConfig() {
452
- return Me(await z(`${e}/api/calls/ice-config`, {
452
+ return je(await Me(`${e}/api/calls/ice-config`, {
453
453
  method: "GET",
454
454
  headers: {
455
455
  "x-user-id": t,
@@ -2855,7 +2855,7 @@ async function wr(e, t = {}) {
2855
2855
  reason: "already-on-page"
2856
2856
  };
2857
2857
  let a = i.pathname + i.search + i.hash;
2858
- if (window.Shopify) return n && mr(n), r || Ee(), r ? Cr().then(() => window.location.assign(i.href)) : window.location.assign(i.href), { navigated: !0 };
2858
+ if (window.Shopify) return n && mr(n), r || Te(), r ? Cr().then(() => window.location.assign(i.href)) : window.location.assign(i.href), { navigated: !0 };
2859
2859
  let o = window.next?.router;
2860
2860
  if (o?.push) return new Promise((e) => {
2861
2861
  let t = () => {
@@ -2874,11 +2874,11 @@ async function wr(e, t = {}) {
2874
2874
  try {
2875
2875
  window.history.pushState({}, "", e), window.dispatchEvent(new PopStateEvent("popstate", { state: {} }));
2876
2876
  } catch {}
2877
- return n && mr(n), r || Ee(), window.location.assign(i.href), { navigated: !0 };
2877
+ return n && mr(n), r || Te(), window.location.assign(i.href), { navigated: !0 };
2878
2878
  }
2879
2879
  return { navigated: !0 };
2880
2880
  }
2881
- return n && mr(n), r || Ee(), window.location.assign(i.href), { navigated: !0 };
2881
+ return n && mr(n), r || Te(), window.location.assign(i.href), { navigated: !0 };
2882
2882
  } catch (t) {
2883
2883
  console.warn("[FlowEngage] shadowNavigate error:", t), n && mr(n);
2884
2884
  try {
@@ -3296,7 +3296,7 @@ function pi({ siteId: e, config: t, children: n, language: r = "en" }) {
3296
3296
  message: "Looks like you're already on this page!",
3297
3297
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
3298
3298
  }]);
3299
- }, []), [D, O] = m(de().isOpen), [k, A] = m(de().activeScreen), [j, M] = m(de().isHumanHandled), [N, oe] = m(de().agentName), [se, P] = m(de().agentHeadshot), [he, ge] = m(() => pe(i?.siteId)), [F, ve] = m(!1), [ye, I] = m(!1), [be, L] = m("idle"), [xe, Se] = m(!1), [R, we] = m(!1), [Te, Ee] = m(""), [De, Oe] = m(!1), [ke, Ae] = m(0), [je, Me] = m(0), [z, B] = m(!1), [V, Ie] = m(null), [Le, Re] = m(null), [ze, Be] = m("idle"), [Ve, He] = m(null), [Ue, We] = m(!1), [Ge, Ke] = m(""), [qe, Je] = m(!1), H = p(null), U = p(null), Ye = p(""), Xe = p(!1), Ze = p(null), Qe = p(null), W = p(null), $e = p(null), et = p(null), tt = p(null), nt = p(null), G = p(!1), rt = p({
3299
+ }, []), [D, O] = m(le().isOpen), [k, A] = m(le().activeScreen), [M, N] = m(le().isHumanHandled), [ie, F] = m(le().agentName), [ae, I] = m(le().agentHeadshot), [pe, me] = m(() => de(i?.siteId)), [he, ge] = m(!1), [_e, R] = m(!1), [ve, z] = m("idle"), [ye, be] = m(!1), [xe, Ce] = m(!1), [we, Te] = m(""), [Ee, De] = m(!1), [Oe, ke] = m(0), [Ae, je] = m(0), [Me, B] = m(!1), [V, Ie] = m(null), [Le, Re] = m(null), [ze, Be] = m("idle"), [Ve, He] = m(null), [Ue, We] = m(!1), [Ge, Ke] = m(""), [qe, Je] = m(!1), H = p(null), U = p(null), Ye = p(""), Xe = p(!1), Ze = p(null), Qe = p(null), W = p(null), $e = p(null), et = p(null), tt = p(null), nt = p(null), G = p(!1), rt = p({
3300
3300
  url: null,
3301
3301
  at: 0
3302
3302
  }), it = o((e, t) => {
@@ -3313,12 +3313,12 @@ function pi({ siteId: e, config: t, children: n, language: r = "en" }) {
3313
3313
  url: n,
3314
3314
  at: Date.now()
3315
3315
  }, wr(e, t));
3316
- }, []), at = p([]), ot = p(null), st = p(null), ct = p(null), lt = p(!1), ut = p(!1), dt = p(""), ft = p(null), pt = p(null), mt = p([]), ht = p(0), gt = p(N), _t = p([]), vt = p(!1), yt = p(!1), bt = p(i), xt = p({
3316
+ }, []), at = p([]), ot = p(null), st = p(null), ct = p(null), lt = p(!1), ut = p(!1), dt = p(""), ft = p(null), pt = p(null), mt = p([]), ht = p(0), gt = p(ie), _t = p([]), vt = p(!1), yt = p(!1), bt = p(i), xt = p({
3317
3317
  notifyRouteChange: () => {},
3318
3318
  cleanup: () => {}
3319
3319
  }), St = o((e = {}) => {
3320
3320
  let t = !!e.is_human_handled;
3321
- return M(t), t ? (A("agent"), e.agent_info?.name && oe(e.agent_info.name), e.agent_info?.headshot && P(e.agent_info.headshot), t) : (A("ai"), t);
3321
+ return N(t), t ? (A("agent"), e.agent_info?.name && F(e.agent_info.name), e.agent_info?.headshot && I(e.agent_info.headshot), t) : (A("ai"), t);
3322
3322
  }, []), Ct = f(() => {
3323
3323
  let e = _?.widgetSettings?.call?.maxDurationSeconds ?? i?.widgetSettings?.call?.maxDurationSeconds ?? i?.callMaxDurationSeconds, t = Number(e);
3324
3324
  return Number.isFinite(t) && t > 0 ? t : te;
@@ -3326,10 +3326,10 @@ function pi({ siteId: e, config: t, children: n, language: r = "en" }) {
3326
3326
  c(() => {
3327
3327
  Qe.current = V;
3328
3328
  }, [V]), c(() => {
3329
- gt.current = N;
3330
- }, [N]), c(() => {
3331
- yt.current = De;
3332
- }, [De]), c(() => {
3329
+ gt.current = ie;
3330
+ }, [ie]), c(() => {
3331
+ yt.current = Ee;
3332
+ }, [Ee]), c(() => {
3333
3333
  bt.current = i;
3334
3334
  }, [i]);
3335
3335
  let wt = () => {
@@ -3338,17 +3338,17 @@ function pi({ siteId: e, config: t, children: n, language: r = "en" }) {
3338
3338
  ct.current &&= (window.clearTimeout(ct.current), null);
3339
3339
  }, []), Et = (e) => {
3340
3340
  let t = typeof e == "string" ? e.trim().toLowerCase() : "";
3341
- return ge(t), me(t, i?.siteId), t;
3341
+ return me(t), fe(t, i?.siteId), t;
3342
3342
  };
3343
3343
  c(() => {
3344
3344
  let e = i?.siteId;
3345
3345
  if (!e) return;
3346
- let t = pe(e);
3346
+ let t = de(e);
3347
3347
  if (t) {
3348
- ge(t);
3348
+ me(t);
3349
3349
  return;
3350
3350
  }
3351
- ge((t) => (t && me(t, e), t));
3351
+ me((t) => (t && fe(t, e), t));
3352
3352
  }, [i?.siteId]);
3353
3353
  let Dt = (e = "unspecified") => {
3354
3354
  let t = ot.current || tt.current?.callId, n = ht.current, r = ft.current;
@@ -3478,19 +3478,19 @@ function pi({ siteId: e, config: t, children: n, language: r = "en" }) {
3478
3478
  });
3479
3479
  };
3480
3480
  c(() => {
3481
- fe({
3481
+ ue({
3482
3482
  isOpen: D,
3483
3483
  activeScreen: k,
3484
- isHumanHandled: j,
3485
- agentName: N,
3486
- agentHeadshot: se
3484
+ isHumanHandled: M,
3485
+ agentName: ie,
3486
+ agentHeadshot: ae
3487
3487
  });
3488
3488
  }, [
3489
3489
  D,
3490
3490
  k,
3491
- j,
3492
- N,
3493
- se
3491
+ M,
3492
+ ie,
3493
+ ae
3494
3494
  ]), c(() => {
3495
3495
  let e = !0;
3496
3496
  return (async () => {
@@ -3498,21 +3498,21 @@ function pi({ siteId: e, config: t, children: n, language: r = "en" }) {
3498
3498
  try {
3499
3499
  let t = E(i), n = await Pe(t);
3500
3500
  if (!e) return;
3501
- let a = t.siteId, o = ce(a), s = _e(a), c = "";
3501
+ let a = t.siteId, o = oe(a), s = L(a), c = "";
3502
3502
  try {
3503
3503
  let e = Xe.current, r = Ze.current;
3504
3504
  if (Xe.current = !1, Ze.current = null, c = (await Ne({
3505
3505
  apiBaseUrl: t.apiBaseUrl,
3506
3506
  userId: n.userId,
3507
3507
  siteId: a,
3508
- priorChatId: e || r ? null : o || re(),
3508
+ priorChatId: e || r ? null : o || ne(),
3509
3509
  forceNew: e,
3510
3510
  resumeChatId: r,
3511
3511
  visitorId: s
3512
3512
  }))?.data?.chatId, !c) throw Error("resolve-session returned no chatId");
3513
- ie(), ue(a, c);
3513
+ re(), ce(a, c);
3514
3514
  } catch (e) {
3515
- console.warn("[FlowEngageProvider] resolve-session failed, reusing persisted or ephemeral chat id", e?.message || e), c = o || ae(), ue(a, c);
3515
+ console.warn("[FlowEngageProvider] resolve-session failed, reusing persisted or ephemeral chat id", e?.message || e), c = o || P(), ce(a, c);
3516
3516
  }
3517
3517
  Ye.current = c;
3518
3518
  let l = Fe({
@@ -3532,23 +3532,23 @@ function pi({ siteId: e, config: t, children: n, language: r = "en" }) {
3532
3532
  siteId: t.siteId
3533
3533
  });
3534
3534
  H.current = f, f.on("connect", async () => {
3535
- L("connected");
3535
+ z("connected");
3536
3536
  let e = Ye.current;
3537
3537
  if (e && U.current) try {
3538
3538
  St(await U.current.checkHumanHandled(e));
3539
3539
  } catch {}
3540
3540
  }), f.on("disconnect", () => {
3541
- L("disconnected");
3541
+ z("disconnected");
3542
3542
  }), f.on("aiTyping", () => {
3543
- I(!0);
3543
+ R(!0);
3544
3544
  }), f.on("ai:typing", () => {
3545
- I(!0);
3545
+ R(!0);
3546
3546
  }), f.on("messageReceived", (e) => {
3547
3547
  let t = e.message || e, n = {
3548
3548
  ...t,
3549
3549
  message: oi(t.message)
3550
3550
  };
3551
- I(!1), ve(!1), !(n.type === "call_recording" || typeof n.message == "string" && n.message.includes("AI chat recording")) && S((e) => [...e.filter((e) => !e.isPending), {
3551
+ R(!1), ge(!1), !(n.type === "call_recording" || typeof n.message == "string" && n.message.includes("AI chat recording")) && S((e) => [...e.filter((e) => !e.isPending), {
3552
3552
  ...n,
3553
3553
  isPending: !1,
3554
3554
  id: n.messageId || `${n.sender}-${Date.now()}-${Math.random()}`
@@ -3566,7 +3566,7 @@ function pi({ siteId: e, config: t, children: n, language: r = "en" }) {
3566
3566
  ...t,
3567
3567
  message: oi(t.message)
3568
3568
  };
3569
- I(!1), !(n.type === "call_recording" || typeof n.message == "string" && n.message.includes("AI chat recording")) && ((n.sender === "agent" || n.agent_name || n.sender === "ai" || n.sender === "bot") && ve(!1), S((e) => n.sender === "bot" || n.sender === "ai" ? [...e, {
3569
+ R(!1), !(n.type === "call_recording" || typeof n.message == "string" && n.message.includes("AI chat recording")) && ((n.sender === "agent" || n.agent_name || n.sender === "ai" || n.sender === "bot") && ge(!1), S((e) => n.sender === "bot" || n.sender === "ai" ? [...e, {
3570
3570
  ...n,
3571
3571
  isPending: !1,
3572
3572
  id: n.messageId || `${n.sender}-${Date.now()}-${Math.random()}`
@@ -3578,11 +3578,11 @@ function pi({ siteId: e, config: t, children: n, language: r = "en" }) {
3578
3578
  ...n,
3579
3579
  isPending: !1,
3580
3580
  id: n.messageId || `${n.sender}-${Date.now()}-${Math.random()}`
3581
- }]), (n.sender === "agent" || n.agent_name) && (M(!0), A("agent"), oe(di([
3581
+ }]), (n.sender === "agent" || n.agent_name) && (N(!0), A("agent"), F(di([
3582
3582
  n.agent_name,
3583
3583
  n.agentName,
3584
3584
  n.metadata?.agentName
3585
- ], d)), n.sender_headshot && P(n.sender_headshot), O(!0), Ae((e) => e + 1)));
3585
+ ], d)), n.sender_headshot && I(n.sender_headshot), O(!0), ke((e) => e + 1)));
3586
3586
  });
3587
3587
  let p = (e = {}) => {
3588
3588
  let t = di([
@@ -3591,7 +3591,7 @@ function pi({ siteId: e, config: t, children: n, language: r = "en" }) {
3591
3591
  e.agent_name,
3592
3592
  gt.current
3593
3593
  ], d);
3594
- M(!0), A("agent"), oe(t), P(e.agent?.headshot || null), O(!0), Ae((e) => e + 1), S((e) => fi(e, {
3594
+ N(!0), A("agent"), F(t), I(e.agent?.headshot || null), O(!0), ke((e) => e + 1), S((e) => fi(e, {
3595
3595
  id: `agent-joined-${Date.now()}`,
3596
3596
  sender: "system",
3597
3597
  message: `${t} has joined the chat.`,
@@ -3605,7 +3605,7 @@ function pi({ siteId: e, config: t, children: n, language: r = "en" }) {
3605
3605
  e.agent_name,
3606
3606
  gt.current
3607
3607
  ], d);
3608
- M(!1), A("ai"), S((e) => fi(e, {
3608
+ N(!1), A("ai"), S((e) => fi(e, {
3609
3609
  id: `agent-left-${Date.now()}`,
3610
3610
  sender: "system",
3611
3611
  message: `${t} has left the chat.`,
@@ -3625,15 +3625,15 @@ function pi({ siteId: e, config: t, children: n, language: r = "en" }) {
3625
3625
  }]);
3626
3626
  }), f.on("chat:history_update", (e) => {
3627
3627
  let t = si(e.chat_history || []);
3628
- S(t), t.length === 0 && (B(!1), M(!1), A("ai"), I(!1), ve(!1));
3628
+ S(t), t.length === 0 && (B(!1), N(!1), A("ai"), R(!1), ge(!1));
3629
3629
  }), f.on("conversation:reset", () => {
3630
- S([]), B(!1), M(!1), A("ai"), I(!1), ve(!1);
3630
+ S([]), B(!1), N(!1), A("ai"), R(!1), ge(!1);
3631
3631
  }), f.on("voice:end_session", (e = {}) => {
3632
- console.log("[FlowEngageProvider] voice:end_session received — ending voice session"), Me((e) => e + 1), O(!0), Ae((e) => e + 1);
3632
+ console.log("[FlowEngageProvider] voice:end_session received — ending voice session"), je((e) => e + 1), O(!0), ke((e) => e + 1);
3633
3633
  }), f.on("typing:start", (e) => {
3634
- e.sender === "agent" && ve(!0);
3634
+ e.sender === "agent" && ge(!0);
3635
3635
  }), f.on("typing:stop", (e) => {
3636
- e.sender === "agent" && ve(!1);
3636
+ e.sender === "agent" && ge(!1);
3637
3637
  }), f.on("call:incoming", (e = {}) => {
3638
3638
  let t = di([
3639
3639
  e.agentName,
@@ -3646,7 +3646,7 @@ function pi({ siteId: e, config: t, children: n, language: r = "en" }) {
3646
3646
  from: e.from || "owner",
3647
3647
  agentId: e.agentId || null,
3648
3648
  agentName: t
3649
- }), oe((e) => di([t, e], "Agent")), Be("incoming"), He(null), O(!0);
3649
+ }), F((e) => di([t, e], "Agent")), Be("incoming"), He(null), O(!0);
3650
3650
  }), f.on("call:offer", async (e = {}) => {
3651
3651
  tt.current = e;
3652
3652
  try {
@@ -3721,7 +3721,7 @@ function pi({ siteId: e, config: t, children: n, language: r = "en" }) {
3721
3721
  });
3722
3722
  let h = await l.loadHistory(c, r);
3723
3723
  if (!e) return;
3724
- S(si(h.chat_history || [])), M(!!h.is_human_handled), A(h.is_human_handled ? "agent" : k);
3724
+ S(si(h.chat_history || [])), N(!!h.is_human_handled), A(h.is_human_handled ? "agent" : k);
3725
3725
  let g = h?.visitor_email || h?.visitorEmail;
3726
3726
  if (g && String(g).trim() && Et(String(g).trim()), await new Promise((e) => setTimeout(e, 500)), !e) return;
3727
3727
  u("ready");
@@ -3739,11 +3739,11 @@ function pi({ siteId: e, config: t, children: n, language: r = "en" }) {
3739
3739
  r,
3740
3740
  a
3741
3741
  ]), c(() => () => {
3742
- if (De && !vt.current && _t.current.length > 0) {
3742
+ if (Ee && !vt.current && _t.current.length > 0) {
3743
3743
  let e = Ye.current, t = _t.current, n = U.current;
3744
3744
  n && e && t.length > 0 && (console.log("[FlowEngageProvider] safety-net: syncing voice transcript on unmount"), n.beaconSyncVoice(e, t) || n.syncVoice(e, t).catch(() => {}), vt.current = !0);
3745
3745
  }
3746
- }, [De, _]);
3746
+ }, [Ee, _]);
3747
3747
  let Mt = p(null);
3748
3748
  c(() => {
3749
3749
  let e = U.current;
@@ -3877,7 +3877,7 @@ function pi({ siteId: e, config: t, children: n, language: r = "en" }) {
3877
3877
  let e = V.callId;
3878
3878
  return Tt(), ct.current = window.setTimeout(() => {
3879
3879
  Qe.current?.callId === e && st.current !== e && ot.current !== e && Ft.current();
3880
- }, ne), () => {
3880
+ }, j), () => {
3881
3881
  ct.current &&= (window.clearTimeout(ct.current), null);
3882
3882
  };
3883
3883
  }, [
@@ -3962,7 +3962,7 @@ function pi({ siteId: e, config: t, children: n, language: r = "en" }) {
3962
3962
  }
3963
3963
  let Wt = async (e, t = "", n = null, i = {}) => {
3964
3964
  let a = typeof e == "string" ? e.trim() : "";
3965
- if (!a || !U.current || !y || l !== "ready" || z) return;
3965
+ if (!a || !U.current || !y || l !== "ready" || Me) return;
3966
3966
  Vt(), G.current = !1;
3967
3967
  let o = /^\s*(yes|yeah|sure|ok|okay|go ahead|take me(?: there)?(?!\s+\w)|navigate(?!\s+(?:me\s+)?to\s+\w)|yep|absolutely|please do|do it|let'?s go|go there|show me(?!\s+(?:the|a|an)\s+\w)|go to it|bring me there|navigate me there)\b/i, s = /^\s*(?:yes|yeah|sure|ok|okay|yep|absolutely)\s+(?!(?:please|do\s+it|let'?s|that|this|there|it|thanks|go|cool|great|perfect|sounds|alright|proceed)\b)\w/i, c = /\b(take me|navigate|go to|show me|bring me|open|go there|navigate to|take me to|let'?s go to)\b/i;
3968
3968
  if (nt.current && o.test(a) && !s.test(a)) {
@@ -3989,7 +3989,7 @@ function pi({ siteId: e, config: t, children: n, language: r = "en" }) {
3989
3989
  ...n || {}
3990
3990
  };
3991
3991
  S((e) => [...e, d]);
3992
- let f = j;
3992
+ let f = M;
3993
3993
  if (f) try {
3994
3994
  f = St(await U.current.checkHumanHandled(y));
3995
3995
  } catch {}
@@ -3998,17 +3998,17 @@ function pi({ siteId: e, config: t, children: n, language: r = "en" }) {
3998
3998
  chatId: y,
3999
3999
  content: e,
4000
4000
  sender: "user",
4001
- email: he || void 0,
4001
+ email: pe || void 0,
4002
4002
  type: i?.type || "text",
4003
4003
  metadata: i?.metadata || {},
4004
4004
  ...n || {}
4005
4005
  });
4006
4006
  return;
4007
4007
  }
4008
- Se(!0);
4008
+ be(!0);
4009
4009
  try {
4010
4010
  let o = await Lr(), s = Fr(), l = `stream-preview-${Date.now().toString(36)}`, u = (e) => {
4011
- I(!1), S((t) => {
4011
+ R(!1), S((t) => {
4012
4012
  let n = t.findIndex((e) => e.id === l);
4013
4013
  if (n === -1) return [...t, {
4014
4014
  id: l,
@@ -4025,7 +4025,7 @@ function pi({ siteId: e, config: t, children: n, language: r = "en" }) {
4025
4025
  });
4026
4026
  }, d = await U.current.sendAiMessage(y, e, r, t, {
4027
4027
  ...n || {},
4028
- ...he ? { email: he } : {}
4028
+ ...pe ? { email: pe } : {}
4029
4029
  }, {
4030
4030
  ...i,
4031
4031
  currentPageUrl: typeof window < "u" ? window.location.href : void 0,
@@ -4102,10 +4102,10 @@ function pi({ siteId: e, config: t, children: n, language: r = "en" }) {
4102
4102
  });
4103
4103
  }
4104
4104
  }
4105
- S(si(f)), Array.isArray(d.cart_actions) && d.cart_actions.length && w(d.cart_actions), M(!!d.is_human_handled), A(d.is_human_handled ? "agent" : "ai"), I(!1), Se(!1), await U.current.updateChatStatus(y, "messageSent");
4105
+ S(si(f)), Array.isArray(d.cart_actions) && d.cart_actions.length && w(d.cart_actions), N(!!d.is_human_handled), A(d.is_human_handled ? "agent" : "ai"), R(!1), be(!1), await U.current.updateChatStatus(y, "messageSent");
4106
4106
  } catch (e) {
4107
- S((e) => e.filter((e) => e.id !== u && !e.isStreaming)), I(!1), Se(!1), e.status === 429 ? (we(!0), Ee(e.message), window.setTimeout(() => {
4108
- we(!1), Ee("");
4107
+ S((e) => e.filter((e) => e.id !== u && !e.isStreaming)), R(!1), be(!1), e.status === 429 ? (Ce(!0), Te(e.message), window.setTimeout(() => {
4108
+ Ce(!1), Te("");
4109
4109
  }, ee)) : h(e);
4110
4110
  }
4111
4111
  }, Gt = async (e) => {
@@ -4117,12 +4117,12 @@ function pi({ siteId: e, config: t, children: n, language: r = "en" }) {
4117
4117
  let t = e ? "voice" : "text";
4118
4118
  await U.current.setChatMode(y, t);
4119
4119
  } catch {}
4120
- Oe(e), e && (vt.current = !1);
4120
+ De(e), e && (vt.current = !1);
4121
4121
  }
4122
4122
  }, qt = async (e) => {
4123
4123
  if (vt.current) return;
4124
4124
  if (vt.current = !0, !U.current || !y || !e?.length) {
4125
- Oe(!1);
4125
+ De(!1);
4126
4126
  return;
4127
4127
  }
4128
4128
  let t = () => {
@@ -4146,11 +4146,11 @@ function pi({ siteId: e, config: t, children: n, language: r = "en" }) {
4146
4146
  } catch {
4147
4147
  t();
4148
4148
  } finally {
4149
- Oe(!1);
4149
+ De(!1);
4150
4150
  }
4151
4151
  }, Jt = async () => {
4152
4152
  if (!(!U.current || !y)) {
4153
- De && !vt.current && _t.current.length > 0 && await qt(_t.current);
4153
+ Ee && !vt.current && _t.current.length > 0 && await qt(_t.current);
4154
4154
  try {
4155
4155
  await U.current.endConversation(y);
4156
4156
  } catch {
@@ -4184,7 +4184,7 @@ function pi({ siteId: e, config: t, children: n, language: r = "en" }) {
4184
4184
  let e = () => {
4185
4185
  let e = Ye.current, t = U.current;
4186
4186
  if (!t || !e) return;
4187
- if (yt.current && _t.current.length > 0 && Ce(), !vt.current && _t.current.length > 0 && (t.beaconSyncVoice(e, _t.current) || t.syncVoice(e, _t.current).catch(() => {}), vt.current = !0), ot.current) {
4187
+ if (yt.current && _t.current.length > 0 && Se(), !vt.current && _t.current.length > 0 && (t.beaconSyncVoice(e, _t.current) || t.syncVoice(e, _t.current).catch(() => {}), vt.current = !0), ot.current) {
4188
4188
  t.beaconEndWebRTCCall(ot.current, e);
4189
4189
  return;
4190
4190
  }
@@ -4197,9 +4197,9 @@ function pi({ siteId: e, config: t, children: n, language: r = "en" }) {
4197
4197
  }, []);
4198
4198
  let Yt = o(() => {
4199
4199
  let e = i?.siteId;
4200
- le(e), Xe.current = !0, Ze.current = null, H.current?.disconnect(), S([]), b(""), Ye.current = "", B(!1), M(!1), oe(null), P(null), Je(!0), s((e) => e + 1);
4200
+ se(e), Xe.current = !0, Ze.current = null, H.current?.disconnect(), S([]), b(""), Ye.current = "", B(!1), N(!1), F(null), I(null), Je(!0), s((e) => e + 1);
4201
4201
  }, [i?.siteId]), Xt = o((e) => {
4202
- i?.siteId, Xe.current = !1, Ze.current = e, H.current?.disconnect(), S([]), b(""), Ye.current = "", B(!1), M(!1), oe(null), P(null), Je(!0), s((e) => e + 1);
4202
+ i?.siteId, Xe.current = !1, Ze.current = e, H.current?.disconnect(), S([]), b(""), Ye.current = "", B(!1), N(!1), F(null), I(null), Je(!0), s((e) => e + 1);
4203
4203
  }, [i?.siteId]), Zt = f(() => ({
4204
4204
  status: l,
4205
4205
  error: d,
@@ -4209,21 +4209,21 @@ function pi({ siteId: e, config: t, children: n, language: r = "en" }) {
4209
4209
  chatHistory: x,
4210
4210
  isOpen: D,
4211
4211
  activeScreen: k,
4212
- isHumanHandled: j,
4213
- agentName: N,
4214
- agentHeadshot: se,
4215
- visitorEmail: he,
4216
- isAgentTyping: F,
4217
- isAiTyping: ye,
4218
- connectionStatus: be,
4219
- isLoading: xe,
4220
- isVoiceMode: De,
4221
- isRateLimited: R,
4222
- rateLimitMessage: Te,
4223
- isConversationEnded: z,
4212
+ isHumanHandled: M,
4213
+ agentName: ie,
4214
+ agentHeadshot: ae,
4215
+ visitorEmail: pe,
4216
+ isAgentTyping: he,
4217
+ isAiTyping: _e,
4218
+ connectionStatus: ve,
4219
+ isLoading: ye,
4220
+ isVoiceMode: Ee,
4221
+ isRateLimited: xe,
4222
+ rateLimitMessage: we,
4223
+ isConversationEnded: Me,
4224
4224
  isSessionRestoring: qe,
4225
- openToChatCounter: ke,
4226
- voiceEndCounter: je,
4225
+ openToChatCounter: Oe,
4226
+ voiceEndCounter: Ae,
4227
4227
  incomingCall: V,
4228
4228
  activeCallId: Le,
4229
4229
  callConnectionState: ze,
@@ -4270,21 +4270,21 @@ function pi({ siteId: e, config: t, children: n, language: r = "en" }) {
4270
4270
  x,
4271
4271
  D,
4272
4272
  k,
4273
- j,
4274
- N,
4275
- se,
4273
+ M,
4274
+ ie,
4275
+ ae,
4276
+ pe,
4276
4277
  he,
4277
- F,
4278
+ _e,
4279
+ ve,
4278
4280
  ye,
4279
- be,
4281
+ Ee,
4280
4282
  xe,
4281
- De,
4282
- R,
4283
- Te,
4284
- z,
4283
+ we,
4284
+ Me,
4285
4285
  qe,
4286
- ke,
4287
- je,
4286
+ Oe,
4287
+ Ae,
4288
4288
  V,
4289
4289
  Le,
4290
4290
  ze,
@@ -9228,13 +9228,18 @@ var Qm = {
9228
9228
  ...Qm,
9229
9229
  ...Lm,
9230
9230
  ...$m
9231
- }, Xp), th = 24e3, nh = 2048, rh = 1200, ih = .03, ah = 2, oh = 11;
9232
- function sh(e) {
9231
+ }, Xp), th = 24e3, nh = 2048, rh = 1200, ih = .05, ah = .005, oh = .35, sh = 3, ch = 3, lh = 5, uh = 1.6;
9232
+ function dh(e) {
9233
+ let t = 0;
9234
+ for (let n = 1; n < e.length; n++) e[n - 1] >= 0 != e[n] >= 0 && (t += 1);
9235
+ return t / (e.length - 1);
9236
+ }
9237
+ function fh(e) {
9233
9238
  let t = 0;
9234
9239
  for (let n = 0; n < e.length; n++) t += e[n] * e[n];
9235
9240
  return Math.sqrt(t / e.length);
9236
9241
  }
9237
- function ch(e) {
9242
+ function ph(e) {
9238
9243
  let t = new Int16Array(e.length);
9239
9244
  for (let n = 0; n < e.length; n++) {
9240
9245
  let r = Math.max(-1, Math.min(1, e[n]));
@@ -9242,16 +9247,16 @@ function ch(e) {
9242
9247
  }
9243
9248
  return t;
9244
9249
  }
9245
- function lh(e) {
9250
+ function mh(e) {
9246
9251
  let t = new Float32Array(e.length);
9247
9252
  for (let n = 0; n < e.length; n++) t[n] = e[n] / 32768;
9248
9253
  return t;
9249
9254
  }
9250
- var uh = .13, dh = ["audio/webm", "audio/mp4"];
9251
- function fh() {
9252
- return typeof window > "u" || window.MediaRecorder === void 0 ? null : dh.find((e) => window.MediaRecorder.isTypeSupported(e)) || null;
9255
+ var hh = .13, gh = ["audio/webm", "audio/mp4"];
9256
+ function _h() {
9257
+ return typeof window > "u" || window.MediaRecorder === void 0 ? null : gh.find((e) => window.MediaRecorder.isTypeSupported(e)) || null;
9253
9258
  }
9254
- function ph(e, t, n, r, i) {
9259
+ function vh(e, t, n, r, i) {
9255
9260
  if (!r.length || !n || !e) return;
9256
9261
  let a = new Blob(r, { type: i }), o = new FormData();
9257
9262
  o.append("audio", a, `aichat-${n}.webm`), o.append("voiceSessionId", n), o.append("siteId", t || ""), fetch(`${e}/api/voice/upload-chat-recording`, {
@@ -9261,25 +9266,25 @@ function ph(e, t, n, r, i) {
9261
9266
  if (!e.ok) throw Error(`HTTP ${e.status}`);
9262
9267
  }).catch((e) => console.warn("[FlowEngage] voice recording upload failed:", e.message));
9263
9268
  }
9264
- var mh = .02;
9265
- function hh(e, t, n) {
9269
+ var yh = .02;
9270
+ function bh(e, t, n) {
9266
9271
  let r = 0, i = 0, a = [], o = () => {
9267
9272
  let t = e.currentTime;
9268
9273
  a.forEach(({ source: e, gain: n }) => {
9269
9274
  try {
9270
- n.gain.cancelScheduledValues(t), n.gain.setValueAtTime(n.gain.value, t), n.gain.linearRampToValueAtTime(0, t + mh), e.stop(t + mh);
9275
+ n.gain.cancelScheduledValues(t), n.gain.setValueAtTime(n.gain.value, t), n.gain.linearRampToValueAtTime(0, t + yh), e.stop(t + yh);
9271
9276
  } catch {}
9272
9277
  }), a = [], r = 0, i = 0;
9273
9278
  }, s = () => r > e.currentTime;
9274
9279
  return {
9275
9280
  enqueue: (o) => {
9276
- let c = lh(o), l = e.createBuffer(1, c.length, th);
9281
+ let c = mh(o), l = e.createBuffer(1, c.length, th);
9277
9282
  l.copyToChannel(c, 0);
9278
9283
  let u = e.createBufferSource();
9279
9284
  u.buffer = l;
9280
9285
  let d = e.createGain();
9281
9286
  u.connect(d), d.connect(e.destination), n && d.connect(n);
9282
- let f = s() ? r : e.currentTime + uh;
9287
+ let f = s() ? r : e.currentTime + hh;
9283
9288
  i ||= f, u.start(f), r = f + l.duration;
9284
9289
  let p = {
9285
9290
  source: u,
@@ -9294,7 +9299,7 @@ function hh(e, t, n) {
9294
9299
  playedMs: () => Math.max(0, (e.currentTime - i) * 1e3)
9295
9300
  };
9296
9301
  }
9297
- async function gh(e, t, n) {
9302
+ async function xh(e, t, n) {
9298
9303
  let r = new URLSearchParams({ siteId: t || "" });
9299
9304
  n && r.set("chatId", n);
9300
9305
  let i = Fr();
@@ -9312,8 +9317,8 @@ async function gh(e, t, n) {
9312
9317
  if (!o?.success || !o.wsUrl) throw Error(o?.error || "Voice session was refused.");
9313
9318
  return o;
9314
9319
  }
9315
- async function _h(e) {
9316
- let { apiBaseUrl: t, siteId: n, chatId: r, clientTools: i = {}, onConnect: a, onDisconnect: o, onMessage: s, onModeChange: c, onError: l, onUnhandledClientToolCall: u, onAgentTurnEnd: d, onSessionInfo: f, onSessionEnding: p } = e, m = await gh(t, n, r);
9320
+ async function Sh(e) {
9321
+ 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 xh(t, n, r);
9317
9322
  f?.({ emailOnFile: !!m.emailOnFile });
9318
9323
  let h = { type: "Start" };
9319
9324
  e.greeting !== void 0 && (h.greeting = e.greeting || null);
@@ -9324,7 +9329,7 @@ async function _h(e) {
9324
9329
  autoGainControl: !0
9325
9330
  } }), _ = new (window.AudioContext || window.webkitAudioContext)({ sampleRate: th });
9326
9331
  _.state === "suspended" && await _.resume();
9327
- let v = _.createMediaStreamDestination(), y = fh(), b = [], x = null, S = r || n || null;
9332
+ let v = _.createMediaStreamDestination(), y = _h(), b = [], x = null, S = r || n || null;
9328
9333
  y && (x = new window.MediaRecorder(v.stream, { mimeType: y }), x.ondataavailable = (e) => {
9329
9334
  e.data && e.data.size > 0 && b.push(e.data);
9330
9335
  }, x.start());
@@ -9354,59 +9359,64 @@ async function _h(e) {
9354
9359
  }
9355
9360
  }, O = (e, t, n) => {
9356
9361
  t && (T.role && T.role !== e && D(), T.role = e, T.text = T.text ? `${T.text} ${t}`.replace(/\s+/g, " ") : t, n && (T.debug = n), T.timer && clearTimeout(T.timer), T.timer = setTimeout(D, rh));
9357
- }, k = !1, A = !1, ee = !1, te = !1, ne = !0, j = !1, M = null, re = !1, ie = !1, ae = () => {
9358
- M && clearTimeout(M);
9362
+ }, k = !1, A = !1, ee = !1, te = !1, j = !1, M = !0, N = 0, ne = 0, re = !1, P = !1, ie = ih, F = null, ae = !1, I = !1, oe = () => {
9363
+ F && clearTimeout(F);
9359
9364
  let e = () => {
9360
9365
  if (!k) {
9361
- if (N.isPlaying()) {
9362
- M = setTimeout(e, 150);
9366
+ if (se.isPlaying()) {
9367
+ F = setTimeout(e, 150);
9363
9368
  return;
9364
9369
  }
9365
- if (M = null, re) {
9370
+ if (F = null, ae) {
9366
9371
  p?.();
9367
9372
  return;
9368
9373
  }
9369
- !k && C.readyState === WebSocket.OPEN && C.send(JSON.stringify({ type: "PlaybackDrained" })), ie && (ie = !1, d?.());
9374
+ !k && C.readyState === WebSocket.OPEN && C.send(JSON.stringify({ type: "PlaybackDrained" })), I && (I = !1, d?.());
9370
9375
  }
9371
9376
  };
9372
- M = setTimeout(e, 150);
9373
- }, N = hh(_, () => {
9374
- te && (te = !1, c?.({ mode: "listening" }));
9377
+ F = setTimeout(e, 150);
9378
+ }, se = bh(_, () => {
9379
+ te && (te = !1, c?.({ mode: j ? "thinking" : "listening" }));
9375
9380
  }, v);
9376
- typeof window < "u" && (window.__fe_agentAudioPlaying = () => N.isPlaying());
9377
- let oe = _.createMediaStreamSource(g);
9378
- oe.connect(v);
9379
- let se = _.createScriptProcessor(nh, 1, 1), P = !1, ce = 0, le = 0;
9380
- se.onaudioprocess = (e) => {
9381
+ typeof window < "u" && (window.__fe_agentAudioPlaying = () => se.isPlaying());
9382
+ let ce = _.createMediaStreamSource(g);
9383
+ ce.connect(v);
9384
+ let le = _.createScriptProcessor(nh, 1, 1), ue = !1;
9385
+ le.onaudioprocess = (e) => {
9381
9386
  if (k || C.readyState !== WebSocket.OPEN) return;
9382
9387
  let t = e.inputBuffer.getChannelData(0), n = () => C.send(new Int16Array(t.length).buffer);
9383
9388
  if (A) {
9384
- ee || (ee = !0, console.debug("[FlowEngage] mic held — streaming silence to keep socket alive")), P = !1, ce = 0, le = 0, n();
9389
+ ee || (ee = !0, console.debug("[FlowEngage] mic held — streaming silence to keep socket alive")), ue = !1, N = 0, ne = 0, n();
9385
9390
  return;
9386
9391
  }
9387
- let r = sh(t);
9388
- N.isPlaying() || j ? (P = !1, ce = 0, le = 0) : r >= ih ? (le = 0, ce += 1, !P && ce >= ah && (P = !0, c?.({ mode: "user-speaking" }))) : (ce = 0, P && ++le >= oh && (P = !1, le = 0, c?.({
9389
- mode: "thinking",
9390
- tentative: !0
9391
- }))), C.send(ch(t).buffer);
9392
- }, oe.connect(se), se.connect(_.destination);
9393
- let ue = () => {
9392
+ let r = fh(t), i = dh(t), a = se.isPlaying() || P, o = a ? ie * uh : ie, s = a ? lh : sh;
9393
+ if (r >= o && i >= ah && i <= oh ? (ne = 0, N += 1) : ++ne >= ch && (N = 0), a ? ue = !1 : !ue && N >= sh ? (ue = !0, c?.({ mode: "user-speaking" })) : ue && N === 0 && (ue = !1), a && !re && N >= s) {
9394
+ re = !0, j = !1, N = 0;
9395
+ let e = se.playedMs();
9396
+ se.stop(), M = !1, P = !1, F && !ae && (clearTimeout(F), F = null), I = !1, C.send(JSON.stringify({
9397
+ type: "VisitorInterrupted",
9398
+ played_ms: Math.round(e)
9399
+ })), console.debug("[FlowEngage] barge-in — visitor spoke over the agent");
9400
+ }
9401
+ C.send(ph(t).buffer);
9402
+ }, ce.connect(le), le.connect(_.destination);
9403
+ let de = () => {
9394
9404
  if (!k) {
9395
- k = !0, M &&= (clearTimeout(M), null), D(), N.stop(), typeof window < "u" && delete window.__fe_agentAudioPlaying;
9405
+ k = !0, F &&= (clearTimeout(F), null), D(), se.stop(), typeof window < "u" && delete window.__fe_agentAudioPlaying;
9396
9406
  try {
9397
- se.disconnect(), oe.disconnect();
9407
+ le.disconnect(), ce.disconnect();
9398
9408
  } catch {}
9399
9409
  if (g.getTracks().forEach((e) => e.stop()), x && x.state !== "inactive") {
9400
- x.onstop = () => ph(t, n, S, b, y);
9410
+ x.onstop = () => vh(t, n, S, b, y);
9401
9411
  try {
9402
9412
  x.stop();
9403
9413
  } catch {
9404
9414
  x.onstop = null;
9405
9415
  }
9406
- } else b.length && ph(t, n, S, b, y);
9416
+ } else b.length && vh(t, n, S, b, y);
9407
9417
  _.close().catch(() => {}), (C.readyState === WebSocket.OPEN || C.readyState === WebSocket.CONNECTING) && C.close();
9408
9418
  }
9409
- }, de = async (e) => {
9419
+ }, fe = async (e) => {
9410
9420
  let t = i[e.name];
9411
9421
  if (!t) return u?.({ tool_name: e.name }), { error: `Unknown tool ${e.name}` };
9412
9422
  let n = {};
@@ -9418,10 +9428,10 @@ async function _h(e) {
9418
9428
  } catch (e) {
9419
9429
  return { error: e?.message || "Tool execution failed" };
9420
9430
  }
9421
- }, fe = async (e) => {
9431
+ }, pe = async (e) => {
9422
9432
  for (let t of e.functions || []) {
9423
9433
  if (!t.client_side) continue;
9424
- let e = await de(t);
9434
+ let e = await fe(t);
9425
9435
  if (k || C.readyState !== WebSocket.OPEN) return;
9426
9436
  C.send(JSON.stringify({
9427
9437
  type: "FunctionCallResponse",
@@ -9430,10 +9440,10 @@ async function _h(e) {
9430
9440
  content: typeof e == "string" ? e : JSON.stringify(e ?? {})
9431
9441
  }));
9432
9442
  }
9433
- }, pe = (e) => {
9443
+ }, me = (e) => {
9434
9444
  switch (e.type) {
9435
9445
  case "Welcome":
9436
- Number.isFinite(e.barge_in_rms) && e.barge_in_rms > 0 && e.barge_in_rms, Number.isFinite(e.barge_in_frames) && e.barge_in_frames > 0 && e.barge_in_frames, S = e.session_id || r || n || null, a?.({ conversationId: S });
9446
+ Number.isFinite(e.barge_in_rms) && e.barge_in_rms > 0 && (ie = e.barge_in_rms), Number.isFinite(e.barge_in_frames) && e.barge_in_frames > 0 && e.barge_in_frames, S = e.session_id || r || n || null, a?.({ conversationId: S });
9437
9447
  break;
9438
9448
  case "ConversationText": {
9439
9449
  let t = String(e.content || "");
@@ -9452,28 +9462,28 @@ async function _h(e) {
9452
9462
  break;
9453
9463
  }
9454
9464
  case "UserStartedSpeaking":
9455
- D(), N.stop(), j = !1, ne = !1, te = !1, M && !re && (clearTimeout(M), M = null), ie = !1, c?.({ mode: "listening" });
9465
+ D(), se.stop(), P = !1, M = !1, te = !1, j = !1, F && !ae && (clearTimeout(F), F = null), I = !1, c?.({ mode: "listening" });
9456
9466
  break;
9457
9467
  case "AgentStartedSpeaking":
9458
- ne = !0, te = !0, c?.({ mode: "speaking" });
9468
+ M = !0, te = !0, re = !1, N = 0, c?.({ mode: "speaking" });
9459
9469
  break;
9460
9470
  case "AgentAudioDone":
9461
- j = !1, D(), ae(), N.isPlaying() || (te = !1, c?.({ mode: "listening" }));
9471
+ P = !1, D(), oe(), se.isPlaying() || (te = !1, c?.({ mode: j ? "thinking" : "listening" }));
9462
9472
  break;
9463
9473
  case "FunctionCallRequest":
9464
- fe(e);
9474
+ pe(e);
9465
9475
  break;
9466
9476
  case "AgentPreparing":
9467
- j = !0;
9477
+ P = !0;
9468
9478
  break;
9469
9479
  case "AgentTurnComplete":
9470
- ie = !0, ae();
9480
+ j = !1, I = !0, oe();
9471
9481
  break;
9472
9482
  case "SessionEnding":
9473
- console.debug("[FlowEngage] server is ending the session:", e.reason || "unspecified"), re = !0;
9483
+ console.debug("[FlowEngage] server is ending the session:", e.reason || "unspecified"), ae = !0;
9474
9484
  break;
9475
9485
  case "AgentThinking":
9476
- c?.({ mode: "thinking" });
9486
+ j = !0, c?.({ mode: "thinking" });
9477
9487
  break;
9478
9488
  case "PromptUpdated": break;
9479
9489
  case "Error":
@@ -9487,16 +9497,16 @@ async function _h(e) {
9487
9497
  };
9488
9498
  return C.onopen = () => C.send(JSON.stringify(h)), C.onmessage = (e) => {
9489
9499
  if (e.data instanceof ArrayBuffer) {
9490
- ne && N.enqueue(new Int16Array(e.data));
9500
+ M && se.enqueue(new Int16Array(e.data));
9491
9501
  return;
9492
9502
  }
9493
9503
  try {
9494
- pe(JSON.parse(e.data));
9504
+ me(JSON.parse(e.data));
9495
9505
  } catch {}
9496
9506
  }, C.onerror = () => l?.(/* @__PURE__ */ Error("Voice connection failed")), C.onclose = () => {
9497
- ue(), o?.();
9507
+ de(), o?.();
9498
9508
  }, {
9499
- endSession: async () => ue(),
9509
+ endSession: async () => de(),
9500
9510
  sendContextualUpdate: (e) => {
9501
9511
  k || C.readyState !== WebSocket.OPEN || !e || C.send(JSON.stringify({
9502
9512
  type: "UpdatePrompt",
@@ -9534,7 +9544,7 @@ async function _h(e) {
9534
9544
  }
9535
9545
  };
9536
9546
  }
9537
- var vh = { startSession: _h }, yh = ({ size: e = 18, color: t = "currentColor" }) => /* @__PURE__ */ _("svg", {
9547
+ var Ch = { startSession: Sh }, wh = ({ size: e = 18, color: t = "currentColor" }) => /* @__PURE__ */ _("svg", {
9538
9548
  width: e,
9539
9549
  height: e,
9540
9550
  viewBox: "0 0 24 24",
@@ -9550,7 +9560,7 @@ var vh = { startSession: _h }, yh = ({ size: e = 18, color: t = "currentColor" }
9550
9560
  strokeLinecap: "round",
9551
9561
  strokeLinejoin: "round"
9552
9562
  })]
9553
- }), bh = ({ size: e = 20 }) => /* @__PURE__ */ _("svg", {
9563
+ }), Th = ({ size: e = 20 }) => /* @__PURE__ */ _("svg", {
9554
9564
  width: e,
9555
9565
  height: e,
9556
9566
  viewBox: "0 0 24 24",
@@ -9565,7 +9575,7 @@ var vh = { startSession: _h }, yh = ({ size: e = 18, color: t = "currentColor" }
9565
9575
  x2: "1",
9566
9576
  y2: "23"
9567
9577
  })]
9568
- }), xh = ({ size: e = 18 }) => /* @__PURE__ */ _("svg", {
9578
+ }), Eh = ({ size: e = 18 }) => /* @__PURE__ */ _("svg", {
9569
9579
  width: e,
9570
9580
  height: e,
9571
9581
  viewBox: "0 0 24 24",
@@ -9580,7 +9590,7 @@ var vh = { startSession: _h }, yh = ({ size: e = 18, color: t = "currentColor" }
9580
9590
  x2: "12",
9581
9591
  y2: "5"
9582
9592
  }), /* @__PURE__ */ g("polyline", { points: "5 12 12 5 19 12" })]
9583
- }), Sh = () => /* @__PURE__ */ _("svg", {
9593
+ }), Dh = () => /* @__PURE__ */ _("svg", {
9584
9594
  width: "14",
9585
9595
  height: "14",
9586
9596
  viewBox: "0 0 24 24",
@@ -9590,7 +9600,7 @@ var vh = { startSession: _h }, yh = ({ size: e = 18, color: t = "currentColor" }
9590
9600
  strokeLinecap: "round",
9591
9601
  strokeLinejoin: "round",
9592
9602
  children: [/* @__PURE__ */ g("polyline", { points: "9 17 4 12 9 7" }), /* @__PURE__ */ g("path", { d: "M20 18v-2a4 4 0 00-4-4H4" })]
9593
- }), Ch = () => /* @__PURE__ */ g("svg", {
9603
+ }), Oh = () => /* @__PURE__ */ g("svg", {
9594
9604
  width: "18",
9595
9605
  height: "18",
9596
9606
  viewBox: "0 0 24 24",
@@ -9600,7 +9610,7 @@ var vh = { startSession: _h }, yh = ({ size: e = 18, color: t = "currentColor" }
9600
9610
  strokeLinecap: "round",
9601
9611
  strokeLinejoin: "round",
9602
9612
  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" })
9603
- }), wh = ({ className: e = "" }) => /* @__PURE__ */ _("svg", {
9613
+ }), kh = ({ className: e = "" }) => /* @__PURE__ */ _("svg", {
9604
9614
  className: e,
9605
9615
  width: "14",
9606
9616
  height: "14",
@@ -9629,7 +9639,7 @@ var vh = { startSession: _h }, yh = ({ size: e = 18, color: t = "currentColor" }
9629
9639
  y2: "16"
9630
9640
  })
9631
9641
  ]
9632
- }), Th = ({ size: e = 14 }) => /* @__PURE__ */ _("svg", {
9642
+ }), Ah = ({ size: e = 14 }) => /* @__PURE__ */ _("svg", {
9633
9643
  width: e,
9634
9644
  height: e,
9635
9645
  viewBox: "0 0 24 24",
@@ -9652,7 +9662,7 @@ var vh = { startSession: _h }, yh = ({ size: e = 18, color: t = "currentColor" }
9652
9662
  /* @__PURE__ */ g("path", { d: "M15 13v2" }),
9653
9663
  /* @__PURE__ */ g("path", { d: "M9 13v2" })
9654
9664
  ]
9655
- }), Eh = ({ size: e = 20, strokeWidth: t = 2, color: n = "currentColor" }) => /* @__PURE__ */ _("svg", {
9665
+ }), jh = ({ size: e = 20, strokeWidth: t = 2, color: n = "currentColor" }) => /* @__PURE__ */ _("svg", {
9656
9666
  width: e,
9657
9667
  height: e,
9658
9668
  viewBox: "0 0 24 24",
@@ -9672,7 +9682,7 @@ var vh = { startSession: _h }, yh = ({ size: e = 18, color: t = "currentColor" }
9672
9682
  x2: "19",
9673
9683
  y2: "12"
9674
9684
  })]
9675
- }), Dh = ({ size: e = 20, color: t = "currentColor" }) => /* @__PURE__ */ _("svg", {
9685
+ }), Mh = ({ size: e = 20, color: t = "currentColor" }) => /* @__PURE__ */ _("svg", {
9676
9686
  width: e,
9677
9687
  height: e,
9678
9688
  viewBox: "0 0 24 24",
@@ -9698,7 +9708,7 @@ var vh = { startSession: _h }, yh = ({ size: e = 18, color: t = "currentColor" }
9698
9708
  fill: t
9699
9709
  })
9700
9710
  ]
9701
- }), Oh = ({ size: e = 20, color: t = "currentColor" }) => /* @__PURE__ */ _("svg", {
9711
+ }), Nh = ({ size: e = 20, color: t = "currentColor" }) => /* @__PURE__ */ _("svg", {
9702
9712
  width: "24",
9703
9713
  height: "24",
9704
9714
  viewBox: "0 0 24 24",
@@ -9716,7 +9726,7 @@ var vh = { startSession: _h }, yh = ({ size: e = 18, color: t = "currentColor" }
9716
9726
  "stroke-linecap": "round",
9717
9727
  "stroke-linejoin": "round"
9718
9728
  })]
9719
- }), kh = () => /* @__PURE__ */ g("svg", {
9729
+ }), Ph = () => /* @__PURE__ */ g("svg", {
9720
9730
  width: "24",
9721
9731
  height: "24",
9722
9732
  viewBox: "0 0 24 24",
@@ -9728,7 +9738,7 @@ var vh = { startSession: _h }, yh = ({ size: e = 18, color: t = "currentColor" }
9728
9738
  "stroke-width": "1.5",
9729
9739
  "stroke-linejoin": "round"
9730
9740
  })
9731
- }), Ah = ({ size: e = 24 }) => /* @__PURE__ */ _("svg", {
9741
+ }), Fh = ({ size: e = 24 }) => /* @__PURE__ */ _("svg", {
9732
9742
  xmlns: "http://www.w3.org/2000/svg",
9733
9743
  width: e,
9734
9744
  height: e,
@@ -9746,7 +9756,7 @@ var vh = { startSession: _h }, yh = ({ size: e = 18, color: t = "currentColor" }
9746
9756
  /* @__PURE__ */ g("path", { d: "m2 2 20 20" }),
9747
9757
  /* @__PURE__ */ g("path", { d: "M9 9v3a3 3 0 0 0 5.12 2.12" })
9748
9758
  ]
9749
- }), jh = (e = "") => String(e).replace(/<[^>]+>/g, "").replace(/\s+/g, " ").trim(), Mh = (e = "") => String(e).replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;"), Nh = new Set([
9759
+ }), Ih = (e = "") => String(e).replace(/<[^>]+>/g, "").replace(/\s+/g, " ").trim(), Lh = (e = "") => String(e).replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;"), Rh = new Set([
9750
9760
  "p",
9751
9761
  "br",
9752
9762
  "ul",
@@ -9757,30 +9767,30 @@ var vh = { startSession: _h }, yh = ({ size: e = 18, color: t = "currentColor" }
9757
9767
  "b",
9758
9768
  "i",
9759
9769
  "a"
9760
- ]), Ph = /^https?:\/\//i;
9761
- function Fh(e) {
9770
+ ]), zh = /^https?:\/\//i;
9771
+ function Bh(e) {
9762
9772
  let t = Array.from(e.childNodes);
9763
9773
  for (let n of t) if (n.nodeType === Node.ELEMENT_NODE) {
9764
9774
  let t = n.tagName.toLowerCase();
9765
- if (!Nh.has(t)) {
9775
+ if (!Rh.has(t)) {
9766
9776
  e.replaceChild(document.createTextNode(n.textContent), n);
9767
9777
  continue;
9768
9778
  }
9769
9779
  let r = {};
9770
9780
  if (t === "a") {
9771
9781
  let e = n.getAttribute("href") || "";
9772
- Ph.test(e) && (r.href = e), r.target = "_blank", r.rel = "noopener noreferrer";
9782
+ zh.test(e) && (r.href = e), r.target = "_blank", r.rel = "noopener noreferrer";
9773
9783
  }
9774
9784
  for (; n.attributes.length > 0;) n.removeAttribute(n.attributes[0].name);
9775
9785
  for (let [e, t] of Object.entries(r)) n.setAttribute(e, t);
9776
- Fh(n);
9786
+ Bh(n);
9777
9787
  } else n.nodeType !== Node.TEXT_NODE && e.removeChild(n);
9778
9788
  }
9779
- function Ih(e) {
9789
+ function Vh(e) {
9780
9790
  let t = document.createElement("div");
9781
- return t.innerHTML = e, Fh(t), t.innerHTML;
9791
+ return t.innerHTML = e, Bh(t), t.innerHTML;
9782
9792
  }
9783
- function Lh(e) {
9793
+ function Hh(e) {
9784
9794
  let t = String(e || "").trim();
9785
9795
  if (!t) return t;
9786
9796
  let n = /^<p>\s*<strong>([\s\S]*?)<\/strong>\s*<\/p>$/i.exec(t);
@@ -9792,33 +9802,33 @@ function Lh(e) {
9792
9802
  }
9793
9803
  return e;
9794
9804
  }
9795
- var Rh = (e = "") => {
9805
+ var Uh = (e = "") => {
9796
9806
  let t = String(e || "").trim();
9797
9807
  if (!t) return "";
9798
- if (/<(p|br|ul|ol|li|strong|em|a)\b/i.test(t)) return Lh(Ih(t));
9799
- let n = t.replace(/\r\n/g, "\n").replace(/\n{3,}/g, "\n\n").split(/\n\s*\n/).map((e) => e.trim()).filter(Boolean), r = (e) => Mh(e).replace(/\[([^\]]+)\]\((https?:\/\/[^\s)]+)\)/g, "<a href=\"$2\" target=\"_blank\" rel=\"noopener noreferrer\">$1</a>").replace(/\*\*([^*]+)\*\*/g, "<strong>$1</strong>").replace(/\*([^*\n]+)\*/g, "<em>$1</em>");
9800
- return Lh(n.map((e) => {
9808
+ if (/<(p|br|ul|ol|li|strong|em|a)\b/i.test(t)) return Hh(Vh(t));
9809
+ 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) => Lh(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>");
9810
+ return Hh(n.map((e) => {
9801
9811
  let t = e.split("\n").map((e) => e.trim()).filter(Boolean), n = t.filter((e) => /^[-*]\s+/.test(e));
9802
9812
  if (n.length >= 2 && n.length === t.length) return `<ul>${n.map((e) => `<li>${r(e.replace(/^[-*]\s+/, ""))}</li>`).join("")}</ul>`;
9803
9813
  let i = e.split(/\s+(?=[-*]\s+\*\*?)/).map((e) => e.trim()).filter(Boolean);
9804
9814
  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>`;
9805
9815
  }).join(""));
9806
- }, zh = new Set(["application/pdf", "application/vnd.openxmlformats-officedocument.wordprocessingml.document"]), Bh = new Set([
9816
+ }, Wh = new Set(["application/pdf", "application/vnd.openxmlformats-officedocument.wordprocessingml.document"]), Gh = new Set([
9807
9817
  ".pdf",
9808
9818
  ".docx",
9809
9819
  ".png",
9810
9820
  ".jpg",
9811
9821
  ".jpeg"
9812
- ]), Vh = "image/png,image/jpeg,.pdf,.docx";
9813
- function Hh(e) {
9822
+ ]), Kh = "image/png,image/jpeg,.pdf,.docx";
9823
+ function qh(e) {
9814
9824
  if (!e) return !1;
9815
9825
  let t = typeof e.name == "string" ? e.name.toLowerCase() : "", n = t.includes(".") ? `.${t.split(".").pop()}` : "", r = typeof e.type == "string" ? e.type.toLowerCase() : "";
9816
- return r === "image/png" || r === "image/jpeg" || zh.has(r) || Bh.has(n);
9826
+ return r === "image/png" || r === "image/jpeg" || Wh.has(r) || Gh.has(n);
9817
9827
  }
9818
- function Uh(e) {
9819
- return e ? Hh(e) ? e.size > 2097152 ? "File must be 2 MB or smaller." : "" : "Only PNG, JPEG, PDF, and DOCX files are allowed." : "No file selected.";
9828
+ function Jh(e) {
9829
+ return e ? qh(e) ? e.size > 2097152 ? "File must be 2 MB or smaller." : "" : "Only PNG, JPEG, PDF, and DOCX files are allowed." : "No file selected.";
9820
9830
  }
9821
- function Wh(e = 0) {
9831
+ function Yh(e = 0) {
9822
9832
  if (!Number.isFinite(e) || e <= 0) return "";
9823
9833
  let t = [
9824
9834
  "B",
@@ -9830,12 +9840,12 @@ function Wh(e = 0) {
9830
9840
  let i = n >= 10 || r === 0 ? 0 : 1;
9831
9841
  return `${n.toFixed(i)} ${t[r]}`;
9832
9842
  }
9833
- function Gh(e) {
9843
+ function Xh(e) {
9834
9844
  return e ? e.name || "Attachment" : "";
9835
9845
  }
9836
9846
  //#endregion
9837
9847
  //#region src/utils/avatarHelpers.js
9838
- function Kh(e) {
9848
+ function Zh(e) {
9839
9849
  if (!e || typeof e != "string") return "?";
9840
9850
  let t = e.trim();
9841
9851
  if (!t) return "?";
@@ -9844,7 +9854,7 @@ function Kh(e) {
9844
9854
  }
9845
9855
  //#endregion
9846
9856
  //#region src/components/AvatarImageOrInitials.jsx
9847
- function qh({ src: e, name: t, imgStyle: n, initialsSpanStyle: r }) {
9857
+ function Qh({ src: e, name: t, imgStyle: n, initialsSpanStyle: r }) {
9848
9858
  let [i, a] = m(null), o = typeof e == "string" ? e.trim() : "";
9849
9859
  return c(() => {
9850
9860
  if (!o) {
@@ -9867,12 +9877,12 @@ function qh({ src: e, name: t, imgStyle: n, initialsSpanStyle: r }) {
9867
9877
  onError: () => a(null)
9868
9878
  }) : /* @__PURE__ */ g("span", {
9869
9879
  style: r,
9870
- children: Kh(t)
9880
+ children: Zh(t)
9871
9881
  });
9872
9882
  }
9873
9883
  //#endregion
9874
9884
  //#region src/components/MessageList.jsx
9875
- function Jh({ chatHistory: e, isAiTyping: t, isLoading: n, isAgentTyping: r, setReplyContext: i, primaryColor: a = "#3B82F6", agentHeadshot: s = null, agentDisplayName: l = "Agent", botAvatarNode: u = null }) {
9885
+ function $h({ chatHistory: e, isAiTyping: t, isLoading: n, isAgentTyping: r, setReplyContext: i, primaryColor: a = "#3B82F6", agentHeadshot: s = null, agentDisplayName: l = "Agent", botAvatarNode: u = null }) {
9876
9886
  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) => {
9877
9887
  let t = e.target.closest("a[href]");
9878
9888
  if (!t) return;
@@ -9927,7 +9937,7 @@ function Jh({ chatHistory: e, isAiTyping: t, isLoading: n, isAgentTyping: r, set
9927
9937
  children: [
9928
9938
  e.map((e) => {
9929
9939
  if (e.type === "call_recording" || typeof e.message == "string" && e.message.includes("AI chat recording")) return null;
9930
- let t = e.sender === "system", n = e.sender === "user", r = e.sender === "ai" || e.sender === "bot", o = e.sender === "agent", c = e.isPending, d = e.type === "file" && e.metadata?.fileUrl, f = e.agent_name || e.agentName || e.metadata?.agentName || l, p = typeof e.sender_headshot == "string" && e.sender_headshot.trim() || typeof s == "string" && s.trim() || null, m = jh(e.replyToContent || e.replyContext?.message || ""), v = e.replyToSender === "user" ? "You" : e.replyToSender === "agent" ? "Agent" : e.replyToSender === "ai" || e.replyToSender === "bot" ? "AI Assistant" : "Message";
9940
+ 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 = Ih(e.replyToContent || e.replyContext?.message || ""), v = e.replyToSender === "user" ? "You" : e.replyToSender === "agent" ? "Agent" : e.replyToSender === "ai" || e.replyToSender === "bot" ? "AI Assistant" : "Message";
9931
9941
  return t ? /* @__PURE__ */ g("div", {
9932
9942
  style: {
9933
9943
  display: "flex",
@@ -9972,7 +9982,7 @@ function Jh({ chatHistory: e, isAiTyping: t, isLoading: n, isAgentTyping: r, set
9972
9982
  fontWeight: 800,
9973
9983
  marginTop: !c && (r || o) ? "22px" : "0px"
9974
9984
  },
9975
- children: r ? u || /* @__PURE__ */ g(Th, { size: 16 }) : /* @__PURE__ */ g(qh, {
9985
+ children: r ? u || /* @__PURE__ */ g(Ah, { size: 16 }) : /* @__PURE__ */ g(Qh, {
9976
9986
  src: p || "",
9977
9987
  name: f,
9978
9988
  imgStyle: {
@@ -10014,7 +10024,7 @@ function Jh({ chatHistory: e, isAiTyping: t, isLoading: n, isAgentTyping: r, set
10014
10024
  onMouseLeave: (e) => {
10015
10025
  e.currentTarget.style.color = "#9ca3af";
10016
10026
  },
10017
- children: [/* @__PURE__ */ g(Sh, {}), "Reply"]
10027
+ children: [/* @__PURE__ */ g(Dh, {}), "Reply"]
10018
10028
  }),
10019
10029
  /* @__PURE__ */ _("div", {
10020
10030
  style: {
@@ -10058,7 +10068,7 @@ function Jh({ chatHistory: e, isAiTyping: t, isLoading: n, isAgentTyping: r, set
10058
10068
  children: m
10059
10069
  })]
10060
10070
  }), d ? (() => {
10061
- let t = e.metadata.fileType || "", r = e.metadata.fileName || e.message || "File", i = Wh(e.metadata.fileSize), a = t.startsWith("image/"), o = `shared file: ${r}`.toLowerCase(), s = (e.message || "").trim(), c = s && s.toLowerCase() !== o && !s.toLowerCase().startsWith("shared file:"), l = t === "application/pdf" ? {
10071
+ let t = e.metadata.fileType || "", r = e.metadata.fileName || e.message || "File", i = Yh(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" ? {
10062
10072
  color: "#ef4444",
10063
10073
  label: "PDF"
10064
10074
  } : t.includes("word") || t.includes("docx") ? {
@@ -10239,7 +10249,7 @@ function Jh({ chatHistory: e, isAiTyping: t, isLoading: n, isAgentTyping: r, set
10239
10249
  });
10240
10250
  })() : r ? /* @__PURE__ */ g("div", {
10241
10251
  className: "flowengage-message-content fe-bot-message",
10242
- dangerouslySetInnerHTML: { __html: Rh(e.message) },
10252
+ dangerouslySetInnerHTML: { __html: Uh(e.message) },
10243
10253
  onClick: T
10244
10254
  }) : /* @__PURE__ */ g("div", {
10245
10255
  style: { whiteSpace: "pre-wrap" },
@@ -10304,7 +10314,7 @@ function Jh({ chatHistory: e, isAiTyping: t, isLoading: n, isAgentTyping: r, set
10304
10314
  boxShadow: u ? "none" : "0 8px 20px rgba(59,130,246,0.24)",
10305
10315
  overflow: "hidden"
10306
10316
  },
10307
- children: u || /* @__PURE__ */ g(Th, { size: 16 })
10317
+ children: u || /* @__PURE__ */ g(Ah, { size: 16 })
10308
10318
  }), /* @__PURE__ */ _("div", {
10309
10319
  style: {
10310
10320
  display: "flex",
@@ -10346,7 +10356,7 @@ function Jh({ chatHistory: e, isAiTyping: t, isLoading: n, isAgentTyping: r, set
10346
10356
  borderRadius: "50%",
10347
10357
  overflow: "hidden"
10348
10358
  },
10349
- children: /* @__PURE__ */ g(qh, {
10359
+ children: /* @__PURE__ */ g(Qh, {
10350
10360
  src: s || "",
10351
10361
  name: l,
10352
10362
  imgStyle: {
@@ -10440,23 +10450,23 @@ function Jh({ chatHistory: e, isAiTyping: t, isLoading: n, isAgentTyping: r, set
10440
10450
  }
10441
10451
  //#endregion
10442
10452
  //#region src/components/ChatInput.jsx
10443
- var Yh = typeof window < "u" && (window.matchMedia?.("(pointer: coarse)").matches || navigator.maxTouchPoints > 0);
10444
- function Xh({ input: e, setInput: t, onSubmit: n, isConversationEnded: r, callUiActive: i, handleToggleVoice: a, activeScreen: o, inputDisabled: s, replyContext: l, clearReplyContext: u, requiresEmail: d, emailInput: f, setEmailInput: m, emailError: v, showVoiceToggle: y = !1, voiceEnabled: b = !0, onFileSelect: x, selectedFile: S = null, onRemoveSelectedFile: C, attachmentError: w = "", isUploadingAttachment: T = !1, inputPlaceholder: E = "Type your message" }) {
10453
+ var eg = typeof window < "u" && (window.matchMedia?.("(pointer: coarse)").matches || navigator.maxTouchPoints > 0);
10454
+ function tg({ 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" }) {
10445
10455
  let D = p(null), O = p(null), k = (e) => {
10446
10456
  e && (e.style.height = "auto", e.style.height = `${Math.min(e.scrollHeight, 120)}px`);
10447
10457
  };
10448
10458
  c(() => {
10449
10459
  d || k(O.current);
10450
10460
  }, [e, d]), c(() => {
10451
- d || Yh || e || s || O.current?.focus();
10461
+ d || eg || e || s || O.current?.focus();
10452
10462
  }, [
10453
10463
  e,
10454
10464
  d,
10455
10465
  s
10456
10466
  ]);
10457
10467
  let A = (e) => {
10458
- e.key === "Enter" && (Yh || e.shiftKey || e.altKey || e.ctrlKey || e.metaKey || (e.preventDefault(), e.currentTarget.form?.requestSubmit()));
10459
- }, 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;
10468
+ e.key === "Enter" && (eg || e.shiftKey || e.altKey || e.ctrlKey || e.metaKey || (e.preventDefault(), e.currentTarget.form?.requestSubmit()));
10469
+ }, ee = l?.sender === "user" ? "You" : l?.sender === "agent" ? "Agent" : "AI Assistant", te = d ? !!f?.trim() : !!e?.trim() || !!S, j = s || T || !te, M = !d && b && y;
10460
10470
  return /* @__PURE__ */ _("div", {
10461
10471
  style: {
10462
10472
  padding: "0 16px",
@@ -10550,7 +10560,7 @@ function Xh({ input: e, setInput: t, onSubmit: n, isConversationEnded: r, callUi
10550
10560
  background: "rgba(59,130,246,0.08)",
10551
10561
  color: "var(--flowengage-primary)"
10552
10562
  },
10553
- children: /* @__PURE__ */ g(Th, { size: 13 })
10563
+ children: /* @__PURE__ */ g(Ah, { size: 13 })
10554
10564
  }), /* @__PURE__ */ g("span", { children: "Please provide your email address so we can help you." })]
10555
10565
  })
10556
10566
  }),
@@ -10590,7 +10600,7 @@ function Xh({ input: e, setInput: t, onSubmit: n, isConversationEnded: r, callUi
10590
10600
  overflow: "hidden",
10591
10601
  textOverflow: "ellipsis"
10592
10602
  },
10593
- children: Gh(S)
10603
+ children: Xh(S)
10594
10604
  }),
10595
10605
  /* @__PURE__ */ g("div", {
10596
10606
  style: {
@@ -10598,7 +10608,7 @@ function Xh({ input: e, setInput: t, onSubmit: n, isConversationEnded: r, callUi
10598
10608
  color: "#6b7280",
10599
10609
  marginTop: "2px"
10600
10610
  },
10601
- children: Wh(S.size)
10611
+ children: Yh(S.size)
10602
10612
  })
10603
10613
  ]
10604
10614
  }), /* @__PURE__ */ g("button", {
@@ -10640,10 +10650,10 @@ function Xh({ input: e, setInput: t, onSubmit: n, isConversationEnded: r, callUi
10640
10650
  },
10641
10651
  onSubmit: n,
10642
10652
  children: [
10643
- j ? /* @__PURE__ */ _(h, { children: [/* @__PURE__ */ g("input", {
10653
+ M ? /* @__PURE__ */ _(h, { children: [/* @__PURE__ */ g("input", {
10644
10654
  ref: D,
10645
10655
  type: "file",
10646
- accept: Vh,
10656
+ accept: Kh,
10647
10657
  style: { display: "none" },
10648
10658
  onChange: (e) => {
10649
10659
  let t = e.target.files?.[0];
@@ -10675,7 +10685,7 @@ function Xh({ input: e, setInput: t, onSubmit: n, isConversationEnded: r, callUi
10675
10685
  onMouseLeave: (e) => {
10676
10686
  e.currentTarget.style.opacity = "1";
10677
10687
  },
10678
- children: /* @__PURE__ */ g(Eh, {
10688
+ children: /* @__PURE__ */ g(jh, {
10679
10689
  size: 16,
10680
10690
  color: "currentColor"
10681
10691
  })
@@ -10690,7 +10700,7 @@ function Xh({ input: e, setInput: t, onSubmit: n, isConversationEnded: r, callUi
10690
10700
  fontSize: "14px",
10691
10701
  outline: "none",
10692
10702
  padding: 0,
10693
- paddingLeft: j ? "0" : "8px",
10703
+ paddingLeft: M ? "0" : "8px",
10694
10704
  color: "#111827",
10695
10705
  background: "transparent",
10696
10706
  cursor: "text",
@@ -10715,7 +10725,7 @@ function Xh({ input: e, setInput: t, onSubmit: n, isConversationEnded: r, callUi
10715
10725
  lineHeight: "20px",
10716
10726
  outline: "none",
10717
10727
  padding: "6px 0",
10718
- paddingLeft: j ? "0" : "8px",
10728
+ paddingLeft: M ? "0" : "8px",
10719
10729
  color: "#111827",
10720
10730
  background: "transparent",
10721
10731
  cursor: "text",
@@ -10745,18 +10755,18 @@ function Xh({ input: e, setInput: t, onSubmit: n, isConversationEnded: r, callUi
10745
10755
  alignItems: "center",
10746
10756
  justifyContent: "center",
10747
10757
  transition: "opacity 0.2s ease",
10748
- cursor: ne ? "not-allowed" : "pointer",
10749
- opacity: ne ? .45 : 1,
10758
+ cursor: j ? "not-allowed" : "pointer",
10759
+ opacity: j ? .45 : 1,
10750
10760
  flexShrink: 0
10751
10761
  },
10752
- disabled: ne,
10762
+ disabled: j,
10753
10763
  onMouseEnter: (e) => {
10754
- ne || (e.currentTarget.style.opacity = "0.85");
10764
+ j || (e.currentTarget.style.opacity = "0.85");
10755
10765
  },
10756
10766
  onMouseLeave: (e) => {
10757
10767
  e.currentTarget.style.opacity = "1";
10758
10768
  },
10759
- children: /* @__PURE__ */ g(xh, { size: 16 })
10769
+ children: /* @__PURE__ */ g(Eh, { size: 16 })
10760
10770
  })
10761
10771
  ]
10762
10772
  }),
@@ -10819,7 +10829,7 @@ function Xh({ input: e, setInput: t, onSubmit: n, isConversationEnded: r, callUi
10819
10829
  }
10820
10830
  //#endregion
10821
10831
  //#region src/components/StatusBanners.jsx
10822
- function Zh({ webRTCError: e, micError: t, setMicError: n, dismissCallError: r, isRateLimited: i, rateLimitMessage: a }) {
10832
+ function ng({ webRTCError: e, micError: t, setMicError: n, dismissCallError: r, isRateLimited: i, rateLimitMessage: a }) {
10823
10833
  return /* @__PURE__ */ _(h, { children: [(e || t) && /* @__PURE__ */ _("div", {
10824
10834
  style: {
10825
10835
  margin: "0 20px 10px",
@@ -10832,7 +10842,7 @@ function Zh({ webRTCError: e, micError: t, setMicError: n, dismissCallError: r,
10832
10842
  gap: "10px"
10833
10843
  },
10834
10844
  children: [
10835
- /* @__PURE__ */ g(wh, { className: "" }),
10845
+ /* @__PURE__ */ g(kh, { className: "" }),
10836
10846
  /* @__PURE__ */ g("span", {
10837
10847
  style: {
10838
10848
  fontSize: "12px",
@@ -10878,13 +10888,13 @@ function Zh({ webRTCError: e, micError: t, setMicError: n, dismissCallError: r,
10878
10888
  }
10879
10889
  //#endregion
10880
10890
  //#region src/components/AnimatedOrb.jsx
10881
- var Qh = [
10891
+ var rg = [
10882
10892
  "#135bd8",
10883
10893
  "#ef334b",
10884
10894
  "#ffbd2e"
10885
10895
  ];
10886
- function $h(e) {
10887
- return !Array.isArray(e) || e.length === 0 ? Qh : e.length === 1 ? [
10896
+ function ig(e) {
10897
+ return !Array.isArray(e) || e.length === 0 ? rg : e.length === 1 ? [
10888
10898
  e[0],
10889
10899
  e[0],
10890
10900
  e[0]
@@ -10898,7 +10908,7 @@ function $h(e) {
10898
10908
  e[2]
10899
10909
  ];
10900
10910
  }
10901
- var eg = {
10911
+ var ag = {
10902
10912
  idle: 3,
10903
10913
  listening: .75,
10904
10914
  thinking: 1,
@@ -10906,7 +10916,7 @@ var eg = {
10906
10916
  muted: .75,
10907
10917
  error: .08
10908
10918
  };
10909
- function tg(e) {
10919
+ function og(e) {
10910
10920
  if (!e || typeof e != "string") return [
10911
10921
  0,
10912
10922
  0,
@@ -10919,14 +10929,14 @@ function tg(e) {
10919
10929
  parseInt(n.slice(4, 6), 16) / 255
10920
10930
  ];
10921
10931
  }
10922
- function ng(e, t) {
10932
+ function sg(e, t) {
10923
10933
  if (!e || typeof e != "string") return `rgba(0,0,0,${t})`;
10924
10934
  if (e.startsWith("rgb")) return e.replace(/[\d.]+\)$/, `${t})`);
10925
10935
  let n = e.replace("#", ""), r = n.length === 3 ? n.split("").map((e) => e + e).join("") : n;
10926
10936
  return `rgba(${parseInt(r.slice(0, 2), 16)},${parseInt(r.slice(2, 4), 16)},${parseInt(r.slice(4, 6), 16)},${t})`;
10927
10937
  }
10928
- var rg = "\n attribute vec2 a_pos;\n varying vec2 v_uv;\n void main() {\n v_uv = a_pos * 0.5 + 0.5;\n gl_Position = vec4(a_pos, 0.0, 1.0);\n }\n", ig = "\n precision highp float;\n\n varying vec2 v_uv;\n uniform float u_time;\n uniform float u_speed;\n uniform vec3 u_c1;\n uniform vec3 u_c2;\n uniform vec3 u_c3;\n\n // ── Gradient noise ─────────────────────────────────────────────────────────\n vec2 hash2(vec2 p) {\n p = vec2(dot(p, vec2(127.1, 311.7)), dot(p, vec2(269.5, 183.3)));\n return -1.0 + 2.0 * fract(sin(p) * 43758.5453123);\n }\n float gnoise(vec2 p) {\n vec2 i = floor(p), f = fract(p);\n vec2 u = f*f*f*(f*(f*6.0-15.0)+10.0);\n return mix(\n mix(dot(hash2(i), f),\n dot(hash2(i+vec2(1,0)), f-vec2(1,0)), u.x),\n mix(dot(hash2(i+vec2(0,1)), f-vec2(0,1)),\n dot(hash2(i+vec2(1,1)), f-vec2(1,1)), u.x),\n u.y\n ) * 0.5 + 0.5;\n }\n\n // ── 3-octave FBM normalised to [0,1] — fewer octaves → larger, softer blobs\n float fbm(vec2 p) {\n float v = 0.0, a = 0.5;\n for (int i = 0; i < 3; i++) {\n v += a * gnoise(p);\n p = p * 2.1 + vec2(100.0);\n a *= 0.5;\n }\n return v / 0.875;\n }\n\n // ── Scalar hash for grain ──────────────────────────────────────────────────\n float hash1(vec2 p) {\n return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453);\n }\n\n void main() {\n vec2 uv = v_uv;\n float t = u_time * u_speed + 47.3;\n\n // ── ① Two-level domain warp — deep organic folding and swirling ───────────\n // First pass: large-scale sweep\n vec2 q = vec2(\n fbm(uv * 1.8 + vec2( t * 0.13, t * 0.11)) * 2.0 - 1.0,\n fbm(uv * 1.8 + vec2( t * 0.11 + 3.7, -t * 0.14 + 1.1)) * 2.0 - 1.0\n );\n // Second pass: warp the warp — creates curling, folding sub-currents\n vec2 r = vec2(\n fbm(uv * 1.8 + q * 0.55 + vec2( t * 0.09, t * 0.07)) * 2.0 - 1.0,\n fbm(uv * 1.8 + q * 0.55 + vec2(-t * 0.07 + 5.1, t * 0.10 + 2.3)) * 2.0 - 1.0\n );\n vec2 wp = uv + r * 0.38;\n\n // ── ② Three independent fields — each drifts inward from its source edge ──\n // Asymmetric velocities: dominant axis matches the inflow direction so the\n // noise texture visually streams inward (left→right, right→left, bottom→top).\n float f1 = fbm(wp * 0.85 + vec2(-t * 0.18, t * 0.04)); // LEFT → right\n float f2 = fbm(wp * 0.85 + vec2( t * 0.18 + 5.3, t * 0.04 + 1.7)); // RIGHT → left\n float f3 = fbm(wp * 0.85 + vec2( t * 0.04 - 3.2, -t * 0.18 + 6.4)); // BOTTOM → up\n\n // ── ③ Breathing blobs — sin pulse makes each field expand and contract ────\n float p1 = 0.88 + 0.12 * sin(t * 0.61);\n float p2 = 0.88 + 0.12 * sin(t * 0.47 + 2.09);\n float p3 = 0.88 + 0.12 * sin(t * 0.53 + 4.19);\n\n // Wide smoothstep (0.26 → 0.70) → soft, diffused blob edges that dissolve\n // gradually into each other, like dye spreading through water.\n float b1 = smoothstep(0.26, 0.70, f1 * p1);\n float b2 = smoothstep(0.26, 0.70, f2 * p2);\n float b3 = smoothstep(0.26, 0.70, f3 * p3);\n\n // ── ④ Directional origin gradients.\n // Each color owns its home edge (value = 1.0) and smoothly fades to zero\n // before reaching the opposite side. The transition windows are offset so\n // they overlap only in the center third — that overlap zone is where the\n // three colors meet and blend, while the edges stay uncontaminated.\n float d1 = 1.0 - smoothstep(0.20, 0.74, uv.x); // c1: LEFT → full at x<0.20, zero by x=0.74\n float d2 = 1.0 - smoothstep(0.20, 0.74, 1.0 - uv.x); // c2: RIGHT → full at x>0.80, zero by x=0.26\n float d3 = 1.0 - smoothstep(0.18, 0.68, uv.y); // c3: BOTTOM → full at y<0.18, zero by y=0.68\n\n float w1 = b1 * d1;\n float w2 = b2 * d2;\n float w3 = b3 * d3;\n\n // ── ⑤ Dye-mixing colour blend ──────────────────────────────────────────────\n // dyeColor is the weighted average of all active colours — exactly how dyes\n // mix in water: overlapping streams blend smoothly, no hard edges.\n float total = w1 + w2 + w3;\n vec3 dyeColor = (u_c1 * w1 + u_c2 * w2 + u_c3 * w3) / max(total, 0.001);\n\n // Boost brightness of the dye to make colors pop and seem less dull\n dyeColor *= 1.65;\n\n // Exponential coverage: cores are rich and opaque; edges dissolve into the\n // near-white base. White only shows through where dye concentration is thin.\n float coverage = 1.0 - exp(-total * 5.0);\n vec3 col = mix(vec3(1.0, 1.0, 1.0), dyeColor, coverage);\n col = clamp(col, 0.0, 1.0);\n\n // ── ⑥ Sphere shading — subtle edge vignette only, no specular ─────────────\n vec2 uvc = v_uv * 2.0 - 1.0;\n\n // ── ⑦ Subtle grain — breaks gradient banding, adds filmic texture ──────────\n float grain = hash1(v_uv * 437.3 + fract(t)) * 2.0 - 1.0;\n col += grain * 0.018;\n\n gl_FragColor = vec4(clamp(col, 0.0, 1.0), 1.0);\n }\n";
10929
- function ag(e, t, n) {
10938
+ var cg = "\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", lg = "\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";
10939
+ function ug(e, t, n) {
10930
10940
  let r = (t, n) => {
10931
10941
  let r = e.createShader(t);
10932
10942
  return e.shaderSource(r, n), e.compileShader(r), e.getShaderParameter(r, e.COMPILE_STATUS) ? r : (console.error("[AnimatedOrb shader]", e.getShaderInfoLog(r)), null);
@@ -10935,10 +10945,10 @@ function ag(e, t, n) {
10935
10945
  let o = e.createProgram();
10936
10946
  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);
10937
10947
  }
10938
- function og({ size: e = 94, voiceState: t = "idle", isMuted: n = !1, colors: r, onClick: i, style: a, className: o }) {
10939
- let [s, l, u] = $h(r), d = t === "speaking", f = e <= 50, m = p(null), h = p(eg[t] ?? .35);
10948
+ function dg({ size: e = 94, voiceState: t = "idle", isMuted: n = !1, colors: r, onClick: i, style: a, className: o }) {
10949
+ let [s, l, u] = ig(r), d = t === "speaking", f = e <= 50, m = p(null), h = p(ag[t] ?? .35);
10940
10950
  c(() => {
10941
- h.current = eg[t] ?? .35;
10951
+ h.current = ag[t] ?? .35;
10942
10952
  }, [t]), c(() => {
10943
10953
  let t = m.current;
10944
10954
  if (!t) return;
@@ -10955,7 +10965,7 @@ function og({ size: e = 94, voiceState: t = "idle", isMuted: n = !1, colors: r,
10955
10965
  console.warn("[AnimatedOrb] WebGL unavailable.");
10956
10966
  return;
10957
10967
  }
10958
- let i = ag(r, rg, ig);
10968
+ let i = ug(r, cg, lg);
10959
10969
  if (!i) {
10960
10970
  console.error("[AnimatedOrb] WebGL program failed to compile/link");
10961
10971
  return;
@@ -10985,7 +10995,7 @@ function og({ size: e = 94, voiceState: t = "idle", isMuted: n = !1, colors: r,
10985
10995
  c2: r.getUniformLocation(i, "u_c2"),
10986
10996
  c3: r.getUniformLocation(i, "u_c3")
10987
10997
  };
10988
- r.uniform3fv(c.c1, tg(s)), r.uniform3fv(c.c2, tg(l)), r.uniform3fv(c.c3, tg(u)), r.viewport(0, 0, t.width, t.height);
10998
+ r.uniform3fv(c.c1, og(s)), r.uniform3fv(c.c2, og(l)), r.uniform3fv(c.c3, og(u)), r.viewport(0, 0, t.width, t.height);
10989
10999
  let d = performance.now(), f, p = (e) => {
10990
11000
  r.uniform1f(c.time, (e - d) / 1e3), r.uniform1f(c.speed, h.current), r.drawArrays(r.TRIANGLES, 0, 6), f = requestAnimationFrame(p);
10991
11001
  };
@@ -11016,7 +11026,7 @@ function og({ size: e = 94, voiceState: t = "idle", isMuted: n = !1, colors: r,
11016
11026
  position: "absolute",
11017
11027
  inset: -10,
11018
11028
  borderRadius: "50%",
11019
- background: `radial-gradient(circle, ${ng(s, .18)} 0%, transparent 70%)`,
11029
+ background: `radial-gradient(circle, ${sg(s, .18)} 0%, transparent 70%)`,
11020
11030
  pointerEvents: "none"
11021
11031
  },
11022
11032
  animate: { opacity: [.3, .75] },
@@ -11094,17 +11104,17 @@ function og({ size: e = 94, voiceState: t = "idle", isMuted: n = !1, colors: r,
11094
11104
  }
11095
11105
  //#endregion
11096
11106
  //#region src/components/CallScreen.jsx
11097
- var sg = "\n @keyframes fe-call-ring-pulse {\n 0% { transform: scale(1); opacity: 0.55; }\n 70% { transform: scale(1.85); opacity: 0; }\n 100% { transform: scale(1.85); opacity: 0; }\n }\n @keyframes fe-call-spin {\n to { transform: rotate(360deg); }\n }\n @keyframes fe-call-slide-up {\n from { opacity: 0; transform: translateY(24px); }\n to { opacity: 1; transform: translateY(0); }\n }\n @keyframes fe-call-fade-in {\n from { opacity: 0; }\n to { opacity: 1; }\n }\n @keyframes fe-call-bar-slide-in {\n from { opacity: 0; transform: translateY(10px) scale(0.97); }\n to { opacity: 1; transform: translateY(0) scale(1); }\n }\n @keyframes fe-call-dot-blink {\n 0%, 100% { opacity: 1; }\n 50% { opacity: 0.35; }\n }\n @keyframes fe-call-avatar-breathe {\n 0%, 100% { opacity: 0.5; transform: scale(1); }\n 50% { opacity: 0.9; transform: scale(1.12); }\n }\n";
11098
- function cg(e) {
11107
+ var fg = "\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";
11108
+ function pg(e) {
11099
11109
  let t = (e || "").replace("#", ""), n = t.length === 3 ? t.split("").map((e) => e + e).join("") : t;
11100
11110
  return `${parseInt(n.slice(0, 2), 16)},${parseInt(n.slice(2, 4), 16)},${parseInt(n.slice(4, 6), 16)}`;
11101
11111
  }
11102
- function lg(e) {
11112
+ function mg(e) {
11103
11113
  if (!e || typeof e != "string") return "#1a1a1a";
11104
11114
  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;
11105
11115
  return .2126 * o(r) + .7152 * o(i) + .0722 * o(a) > .179 ? "#1a1a1a" : "#ffffff";
11106
11116
  }
11107
- function ug(e, t) {
11117
+ function hg(e, t) {
11108
11118
  let n = Array.isArray(e) && e.length > 0 ? e : [t || "#3B82F6"], [r, i, a] = n;
11109
11119
  return n.length === 1 ? [
11110
11120
  `radial-gradient(ellipse 110% 65% at 50% -5%, ${r}28 0%, transparent 68%)`,
@@ -11121,8 +11131,8 @@ function ug(e, t) {
11121
11131
  "#f7f8fa"
11122
11132
  ].join(", ");
11123
11133
  }
11124
- function dg({ headshot: e, name: t, size: n = 80, primaryColor: r = "#3B82F6" }) {
11125
- let i = (t || "A")[0].toUpperCase(), a = lg(r), o = n > 48 ? {
11134
+ function gg({ headshot: e, name: t, size: n = 80, primaryColor: r = "#3B82F6" }) {
11135
+ let i = (t || "A")[0].toUpperCase(), a = mg(r), o = n > 48 ? {
11126
11136
  boxShadow: `0 0 0 3px ${r}44`,
11127
11137
  border: "3px solid rgba(255,255,255,0.15)"
11128
11138
  } : { border: `1.5px solid ${r}55` };
@@ -11159,7 +11169,7 @@ function dg({ headshot: e, name: t, size: n = 80, primaryColor: r = "#3B82F6" })
11159
11169
  children: i
11160
11170
  });
11161
11171
  }
11162
- function fg(e) {
11172
+ function _g(e) {
11163
11173
  let t = p(null), n = o(() => {
11164
11174
  if (!t.current) return;
11165
11175
  let { audioContext: e, oscillator: n, interval: r, toneTimeout: i } = t.current;
@@ -11206,8 +11216,8 @@ function fg(e) {
11206
11216
  n
11207
11217
  ]), c(() => () => n(), [n]), n;
11208
11218
  }
11209
- function pg({ incomingCall: e, activeCallId: t, callConnectionState: n, callDurationSeconds: r, isCallMuted: i, agentName: a, agentHeadshot: o, fallbackAgentName: s, acceptCall: c, rejectCall: l, endWebRTCCall: u, toggleCallMute: d, formatCallDuration: f, onMinimize: p, primaryColor: m = "#3B82F6", orbColors: h, chatHistory: v = [] }) {
11210
- let y = a || s || "Agent", b = e ? "incoming" : n === "connecting" ? "connecting" : "ongoing", x = fg(!!e), S = async () => {
11219
+ function vg({ 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 = [] }) {
11220
+ let y = a || s || "Agent", b = e ? "incoming" : n === "connecting" ? "connecting" : "ongoing", x = _g(!!e), S = async () => {
11211
11221
  x(), await c();
11212
11222
  }, C = async () => {
11213
11223
  x(), await l();
@@ -11219,14 +11229,14 @@ function pg({ incomingCall: e, activeCallId: t, callConnectionState: n, callDura
11219
11229
  flexDirection: "column",
11220
11230
  borderRadius: "inherit",
11221
11231
  overflow: "hidden",
11222
- background: ug(h, m),
11232
+ background: hg(h, m),
11223
11233
  animation: T ? "fe-call-slide-up 0.36s cubic-bezier(0.16,1,0.3,1)" : "fe-call-fade-in 0.32s ease"
11224
11234
  };
11225
11235
  if (b === "incoming") {
11226
11236
  let e = Array.isArray(h) && h.length > 0 ? h : [m];
11227
11237
  return /* @__PURE__ */ _("div", {
11228
11238
  style: E,
11229
- children: [/* @__PURE__ */ g("style", { children: sg }), /* @__PURE__ */ _("div", {
11239
+ children: [/* @__PURE__ */ g("style", { children: fg }), /* @__PURE__ */ _("div", {
11230
11240
  style: {
11231
11241
  flex: 1,
11232
11242
  display: "flex",
@@ -11257,7 +11267,7 @@ function pg({ incomingCall: e, activeCallId: t, callConnectionState: n, callDura
11257
11267
  width: "96px",
11258
11268
  height: "96px",
11259
11269
  borderRadius: "50%",
11260
- background: `radial-gradient(circle, rgba(${cg(e[0])},0.2) 0%, transparent 70%)`,
11270
+ background: `radial-gradient(circle, rgba(${pg(e[0])},0.2) 0%, transparent 70%)`,
11261
11271
  filter: "blur(10px)",
11262
11272
  zIndex: 0
11263
11273
  } }),
@@ -11274,7 +11284,7 @@ function pg({ incomingCall: e, activeCallId: t, callConnectionState: n, callDura
11274
11284
  animation: `fe-call-ring-pulse 2.6s cubic-bezier(0.215,0.61,0.355,1) ${t}s infinite`,
11275
11285
  zIndex: 1
11276
11286
  } }, n)),
11277
- /* @__PURE__ */ g(dg, {
11287
+ /* @__PURE__ */ g(gg, {
11278
11288
  headshot: o,
11279
11289
  name: y,
11280
11290
  size: 82,
@@ -11354,7 +11364,7 @@ function pg({ incomingCall: e, activeCallId: t, callConnectionState: n, callDura
11354
11364
  e.currentTarget.style.transform = "scale(1)", e.currentTarget.style.boxShadow = "0 6px 24px rgba(239,68,68,0.5)";
11355
11365
  },
11356
11366
  "aria-label": "Decline call",
11357
- children: /* @__PURE__ */ g(bh, { size: 26 })
11367
+ children: /* @__PURE__ */ g(Th, { size: 26 })
11358
11368
  }), /* @__PURE__ */ g("span", {
11359
11369
  style: {
11360
11370
  fontSize: "12px",
@@ -11395,7 +11405,7 @@ function pg({ incomingCall: e, activeCallId: t, callConnectionState: n, callDura
11395
11405
  e.currentTarget.style.transform = "scale(1)", e.currentTarget.style.boxShadow = "0 6px 24px rgba(34,197,94,0.5)";
11396
11406
  },
11397
11407
  "aria-label": "Accept call",
11398
- children: /* @__PURE__ */ g(Ch, {})
11408
+ children: /* @__PURE__ */ g(Oh, {})
11399
11409
  }), /* @__PURE__ */ g("span", {
11400
11410
  style: {
11401
11411
  fontSize: "12px",
@@ -11412,7 +11422,7 @@ function pg({ incomingCall: e, activeCallId: t, callConnectionState: n, callDura
11412
11422
  }
11413
11423
  return b === "connecting" ? /* @__PURE__ */ _("div", {
11414
11424
  style: E,
11415
- children: [/* @__PURE__ */ g("style", { children: sg }), /* @__PURE__ */ _("div", {
11425
+ children: [/* @__PURE__ */ g("style", { children: fg }), /* @__PURE__ */ _("div", {
11416
11426
  style: {
11417
11427
  flex: 1,
11418
11428
  display: "flex",
@@ -11422,7 +11432,7 @@ function pg({ incomingCall: e, activeCallId: t, callConnectionState: n, callDura
11422
11432
  gap: "24px"
11423
11433
  },
11424
11434
  children: [
11425
- /* @__PURE__ */ g(dg, {
11435
+ /* @__PURE__ */ g(gg, {
11426
11436
  headshot: o,
11427
11437
  name: y,
11428
11438
  size: 64,
@@ -11449,7 +11459,7 @@ function pg({ incomingCall: e, activeCallId: t, callConnectionState: n, callDura
11449
11459
  }) : /* @__PURE__ */ _("div", {
11450
11460
  style: E,
11451
11461
  children: [
11452
- /* @__PURE__ */ g("style", { children: sg }),
11462
+ /* @__PURE__ */ g("style", { children: fg }),
11453
11463
  /* @__PURE__ */ _("div", {
11454
11464
  style: {
11455
11465
  display: "flex",
@@ -11495,7 +11505,7 @@ function pg({ incomingCall: e, activeCallId: t, callConnectionState: n, callDura
11495
11505
  children: /* @__PURE__ */ g("polyline", { points: "15 18 9 12 15 6" })
11496
11506
  })
11497
11507
  }),
11498
- /* @__PURE__ */ g(og, {
11508
+ /* @__PURE__ */ g(dg, {
11499
11509
  colors: h,
11500
11510
  size: 36,
11501
11511
  voiceState: w
@@ -11546,7 +11556,7 @@ function pg({ incomingCall: e, activeCallId: t, callConnectionState: n, callDura
11546
11556
  gap: "16px",
11547
11557
  padding: "0 24px 16px"
11548
11558
  },
11549
- children: [/* @__PURE__ */ g(dg, {
11559
+ children: [/* @__PURE__ */ g(gg, {
11550
11560
  headshot: o,
11551
11561
  name: y,
11552
11562
  size: 116,
@@ -11601,7 +11611,7 @@ function pg({ incomingCall: e, activeCallId: t, callConnectionState: n, callDura
11601
11611
  transition: "all 0.2s ease"
11602
11612
  },
11603
11613
  "aria-label": i ? "Unmute" : "Mute",
11604
- children: [g(i ? Ah : yh, { size: 18 }), i ? "Unmute" : "Mute"]
11614
+ children: [g(i ? Fh : wh, { size: 18 }), i ? "Unmute" : "Mute"]
11605
11615
  }), /* @__PURE__ */ _("button", {
11606
11616
  type: "button",
11607
11617
  onClick: u,
@@ -11629,15 +11639,15 @@ function pg({ incomingCall: e, activeCallId: t, callConnectionState: n, callDura
11629
11639
  e.currentTarget.style.background = "rgba(239,68,68,0.9)", e.currentTarget.style.transform = "scale(1)";
11630
11640
  },
11631
11641
  "aria-label": "End call",
11632
- children: [/* @__PURE__ */ g(bh, { size: 18 }), "End Call"]
11642
+ children: [/* @__PURE__ */ g(Th, { size: 18 }), "End Call"]
11633
11643
  })]
11634
11644
  })
11635
11645
  ]
11636
11646
  });
11637
11647
  }
11638
- function mg({ agentName: e, agentHeadshot: t, fallbackAgentName: n, callDurationSeconds: r, isCallMuted: i, formatCallDuration: a, toggleCallMute: o, endWebRTCCall: s, onExpand: c, primaryColor: l = "#3B82F6" }) {
11648
+ function yg({ agentName: e, agentHeadshot: t, fallbackAgentName: n, callDurationSeconds: r, isCallMuted: i, formatCallDuration: a, toggleCallMute: o, endWebRTCCall: s, onExpand: c, primaryColor: l = "#3B82F6" }) {
11639
11649
  let u = e || n || "Agent";
11640
- return /* @__PURE__ */ _(h, { children: [/* @__PURE__ */ g("style", { children: sg }), /* @__PURE__ */ _("div", {
11650
+ return /* @__PURE__ */ _(h, { children: [/* @__PURE__ */ g("style", { children: fg }), /* @__PURE__ */ _("div", {
11641
11651
  role: "button",
11642
11652
  tabIndex: 0,
11643
11653
  onClick: c,
@@ -11694,7 +11704,7 @@ function mg({ agentName: e, agentHeadshot: t, fallbackAgentName: n, callDuration
11694
11704
  borderRadius: "50%",
11695
11705
  border: `1.5px solid ${l}55`
11696
11706
  } }),
11697
- /* @__PURE__ */ g(dg, {
11707
+ /* @__PURE__ */ g(gg, {
11698
11708
  headshot: t,
11699
11709
  name: u,
11700
11710
  size: 38,
@@ -11778,7 +11788,7 @@ function mg({ agentName: e, agentHeadshot: t, fallbackAgentName: n, callDuration
11778
11788
  boxShadow: i ? `0 0 0 3px ${l}12` : "none"
11779
11789
  },
11780
11790
  "aria-label": i ? "Unmute" : "Mute",
11781
- children: g(i ? Ah : yh, { size: 15 })
11791
+ children: g(i ? Fh : wh, { size: 15 })
11782
11792
  }), /* @__PURE__ */ g("button", {
11783
11793
  type: "button",
11784
11794
  onClick: (e) => {
@@ -11806,7 +11816,7 @@ function mg({ agentName: e, agentHeadshot: t, fallbackAgentName: n, callDuration
11806
11816
  transition: "all 0.18s ease"
11807
11817
  },
11808
11818
  "aria-label": "End call",
11809
- children: /* @__PURE__ */ g(bh, { size: 16 })
11819
+ children: /* @__PURE__ */ g(Th, { size: 16 })
11810
11820
  })]
11811
11821
  })
11812
11822
  ]
@@ -11814,7 +11824,7 @@ function mg({ agentName: e, agentHeadshot: t, fallbackAgentName: n, callDuration
11814
11824
  }
11815
11825
  //#endregion
11816
11826
  //#region src/utils/voicePriorContext.js
11817
- function hg(e, t = {}) {
11827
+ function bg(e, t = {}) {
11818
11828
  let n = t.maxChars ?? 4500;
11819
11829
  if (!Array.isArray(e) || e.length === 0) return "";
11820
11830
  let r = [];
@@ -11832,7 +11842,7 @@ function hg(e, t = {}) {
11832
11842
  //#endregion
11833
11843
  //#region src/utils/voiceActionVisuals.js
11834
11844
  var Q = "fe-vv";
11835
- function gg() {
11845
+ function xg() {
11836
11846
  if (typeof document > "u" || document.getElementById(`${Q}-styles`)) return;
11837
11847
  let e = `
11838
11848
  /* ── Action toast ───────────────────────────────────────────────────────────── */
@@ -11977,14 +11987,14 @@ function gg() {
11977
11987
  `, t = document.createElement("style");
11978
11988
  t.id = `${Q}-styles`, t.textContent = e, (document.head || document.documentElement).appendChild(t);
11979
11989
  }
11980
- var _g = null, vg = null;
11981
- function yg() {
11982
- return (!_g || !_g.isConnected) && (_g = document.createElement("div"), _g.id = `${Q}-toast`, document.body.appendChild(_g)), _g;
11990
+ var Sg = null, Cg = null;
11991
+ function wg() {
11992
+ return (!Sg || !Sg.isConnected) && (Sg = document.createElement("div"), Sg.id = `${Q}-toast`, document.body.appendChild(Sg)), Sg;
11983
11993
  }
11984
- function bg(e, { spinner: t = !0, icon: n = null, duration: r = 0 } = {}) {
11994
+ function Tg(e, { spinner: t = !0, icon: n = null, duration: r = 0 } = {}) {
11985
11995
  if (typeof document > "u") return;
11986
- gg(), vg &&= (clearTimeout(vg), null);
11987
- let i = yg();
11996
+ xg(), Cg &&= (clearTimeout(Cg), null);
11997
+ let i = wg();
11988
11998
  if (i.innerHTML = "", n) {
11989
11999
  let e = document.createElement("span");
11990
12000
  e.className = `${Q}-icon`, e.textContent = n, i.appendChild(e);
@@ -11993,71 +12003,71 @@ function bg(e, { spinner: t = !0, icon: n = null, duration: r = 0 } = {}) {
11993
12003
  e.className = `${Q}-spin`, i.appendChild(e);
11994
12004
  }
11995
12005
  let a = document.createElement("span");
11996
- a.textContent = e, i.appendChild(a), i.classList.remove(`${Q}-show`), i.offsetHeight, i.classList.add(`${Q}-show`), r > 0 && (vg = setTimeout(() => xg(), r));
12006
+ a.textContent = e, i.appendChild(a), i.classList.remove(`${Q}-show`), i.offsetHeight, i.classList.add(`${Q}-show`), r > 0 && (Cg = setTimeout(() => Eg(), r));
11997
12007
  }
11998
- function xg(e = 0) {
11999
- _g && (e > 0 ? vg = setTimeout(() => {
12000
- _g && _g.classList.remove(`${Q}-show`);
12001
- }, e) : _g && _g.classList.remove(`${Q}-show`));
12008
+ function Eg(e = 0) {
12009
+ Sg && (e > 0 ? Cg = setTimeout(() => {
12010
+ Sg && Sg.classList.remove(`${Q}-show`);
12011
+ }, e) : Sg && Sg.classList.remove(`${Q}-show`));
12002
12012
  }
12003
- var Sg = null, Cg = [];
12004
- function wg() {
12005
- return (!Sg || !Sg.isConnected) && (Sg = document.createElement("div"), Sg.id = `${Q}-bar`, document.body.appendChild(Sg)), Sg;
12013
+ var Dg = null, Og = [];
12014
+ function kg() {
12015
+ return (!Dg || !Dg.isConnected) && (Dg = document.createElement("div"), Dg.id = `${Q}-bar`, document.body.appendChild(Dg)), Dg;
12006
12016
  }
12007
- function Tg() {
12017
+ function Ag() {
12008
12018
  if (typeof document > "u") return;
12009
- gg(), Cg.forEach(clearTimeout), Cg = [];
12010
- let e = wg();
12019
+ xg(), Og.forEach(clearTimeout), Og = [];
12020
+ let e = kg();
12011
12021
  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";
12012
12022
  let t = [[80, "width 0.6s ease"], [92, "width 1.2s ease"]], n = 50;
12013
12023
  for (let [e, r] of t) {
12014
12024
  let t = n, i = e, a = r;
12015
- Cg.push(setTimeout(() => {
12016
- Sg && (Sg.style.transition = a, Sg.style.width = `${i}%`);
12025
+ Og.push(setTimeout(() => {
12026
+ Dg && (Dg.style.transition = a, Dg.style.width = `${i}%`);
12017
12027
  }, t)), n += 800;
12018
12028
  }
12019
12029
  }
12020
- function Eg() {
12021
- Sg && (Cg.forEach(clearTimeout), Cg = [], Sg.style.transition = "width 0.2s ease", Sg.style.width = "100%", Cg.push(setTimeout(() => {
12022
- Sg && (Sg.style.transition = "opacity 0.35s ease", Sg.style.opacity = "0", Cg.push(setTimeout(() => {
12023
- Sg && (Sg.style.width = "0%", Sg.classList.remove(`${Q}-bar-active`));
12030
+ function jg() {
12031
+ Dg && (Og.forEach(clearTimeout), Og = [], Dg.style.transition = "width 0.2s ease", Dg.style.width = "100%", Og.push(setTimeout(() => {
12032
+ Dg && (Dg.style.transition = "opacity 0.35s ease", Dg.style.opacity = "0", Og.push(setTimeout(() => {
12033
+ Dg && (Dg.style.width = "0%", Dg.classList.remove(`${Q}-bar-active`));
12024
12034
  }, 380)));
12025
12035
  }, 220)));
12026
12036
  }
12027
- var Dg = `<svg xmlns="http://www.w3.org/2000/svg" width="22" height="22" viewBox="0 0 22 22" fill="none">
12037
+ var Mg = `<svg xmlns="http://www.w3.org/2000/svg" width="22" height="22" viewBox="0 0 22 22" fill="none">
12028
12038
  <filter id="${Q}-csh">
12029
12039
  <feDropShadow dx="1" dy="2" stdDeviation="1.5" flood-color="#00000060"/>
12030
12040
  </filter>
12031
12041
  <path d="M4 2L19 10.5L11 12.8L8 20L4 2Z"
12032
12042
  fill="white" stroke="#1e1b4b" stroke-width="1.6" stroke-linejoin="round"
12033
12043
  filter="url(#${Q}-csh)"/>
12034
- </svg>`, Og = null, kg = !1;
12035
- function Ag() {
12036
- return (!Og || !Og.isConnected) && (Og = document.createElement("div"), Og.id = `${Q}-cursor`, Og.innerHTML = Dg, document.body.appendChild(Og), kg = !1), Og;
12044
+ </svg>`, Ng = null, Pg = !1;
12045
+ function Fg() {
12046
+ return (!Ng || !Ng.isConnected) && (Ng = document.createElement("div"), Ng.id = `${Q}-cursor`, Ng.innerHTML = Mg, document.body.appendChild(Ng), Pg = !1), Ng;
12037
12047
  }
12038
- async function jg(e) {
12048
+ async function Ig(e) {
12039
12049
  if (typeof document > "u" || !e) return;
12040
- gg();
12050
+ xg();
12041
12051
  let t;
12042
12052
  try {
12043
12053
  t = e.getBoundingClientRect();
12044
12054
  } catch {
12045
12055
  return;
12046
12056
  }
12047
- let n = t.left + Math.min(16, t.width * .2), r = t.top + Math.min(12, t.height * .25), i = Ag();
12048
- kg ||= (i.style.transition = "none", i.style.left = `${window.innerWidth / 2}px`, i.style.top = `${window.innerHeight * .4}px`, i.classList.add(`${Q}-cursor-visible`), i.offsetHeight, i.style.transition = "left 0.32s cubic-bezier(0.25,0.46,0.45,0.94), top 0.32s cubic-bezier(0.25,0.46,0.45,0.94), opacity 0.2s ease", !0), i.style.left = `${n}px`, i.style.top = `${r}px`, await Fg(360);
12057
+ let n = t.left + Math.min(16, t.width * .2), r = t.top + Math.min(12, t.height * .25), i = Fg();
12058
+ Pg ||= (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 Bg(360);
12049
12059
  }
12050
- function Mg(e = !1) {
12051
- Og && (e ? (Og.classList.remove(`${Q}-cursor-visible`), kg = !1) : (Og.classList.remove(`${Q}-cursor-visible`), setTimeout(() => {
12052
- kg = !1;
12060
+ function Lg(e = !1) {
12061
+ Ng && (e ? (Ng.classList.remove(`${Q}-cursor-visible`), Pg = !1) : (Ng.classList.remove(`${Q}-cursor-visible`), setTimeout(() => {
12062
+ Pg = !1;
12053
12063
  }, 250)));
12054
12064
  }
12055
- async function Ng(e) {
12056
- Og && (Og.classList.add(`${Q}-cursor-click`), await Fg(280), Og.classList.remove(`${Q}-cursor-click`));
12065
+ async function Rg(e) {
12066
+ Ng && (Ng.classList.add(`${Q}-cursor-click`), await Bg(280), Ng.classList.remove(`${Q}-cursor-click`));
12057
12067
  }
12058
- function Pg(e) {
12068
+ function zg(e) {
12059
12069
  if (!e || typeof document > "u") return;
12060
- gg();
12070
+ xg();
12061
12071
  let t;
12062
12072
  try {
12063
12073
  t = e.getBoundingClientRect();
@@ -12083,29 +12093,29 @@ function Pg(e) {
12083
12093
  a.remove(), e.style.position = n, e.style.overflow = r;
12084
12094
  }, 650);
12085
12095
  }
12086
- function Fg(e) {
12096
+ function Bg(e) {
12087
12097
  return new Promise((t) => setTimeout(t, e));
12088
12098
  }
12089
12099
  //#endregion
12090
12100
  //#region src/utils/voiceClientTools.js
12091
- var Ig = /^\/[a-z]{2}(?:-[a-z]{2})?(?=\/|$)/i;
12092
- function Lg(e) {
12093
- return String(e || "").replace(Ig, "").replace(/\/+$/, "").toLowerCase() || "/";
12101
+ var Vg = /^\/[a-z]{2}(?:-[a-z]{2})?(?=\/|$)/i;
12102
+ function Hg(e) {
12103
+ return String(e || "").replace(Vg, "").replace(/\/+$/, "").toLowerCase() || "/";
12094
12104
  }
12095
- function Rg(e, t) {
12096
- return Lg(e) === Lg(t);
12105
+ function Ug(e, t) {
12106
+ return Hg(e) === Hg(t);
12097
12107
  }
12098
12108
  function $(...e) {
12099
12109
  wn() && console.log("[FlowEngage:voice-tools]", ...e);
12100
12110
  }
12101
- function zg(e) {
12111
+ function Wg(e) {
12102
12112
  try {
12103
12113
  let t = e.ownerDocument?.defaultView;
12104
12114
  if (t) return t.getComputedStyle(e);
12105
12115
  } catch {}
12106
12116
  return window.getComputedStyle(e);
12107
12117
  }
12108
- function Bg(e) {
12118
+ function Gg(e) {
12109
12119
  let t = /* @__PURE__ */ new Set();
12110
12120
  function n(r) {
12111
12121
  if (!r || t.has(r)) return;
@@ -12118,10 +12128,10 @@ function Bg(e) {
12118
12128
  }
12119
12129
  typeof document < "u" && n(document);
12120
12130
  }
12121
- function Vg(e) {
12131
+ function Kg(e) {
12122
12132
  return e == null ? null : String(e).replace(/\u00a0/g, " ").replace(/\s*\*+\s*$/u, "").replace(/\s+/g, " ").trim();
12123
12133
  }
12124
- function Hg(e) {
12134
+ function qg(e) {
12125
12135
  let t = e.ownerDocument || document, n = e.getAttribute("aria-labelledby");
12126
12136
  if (n) {
12127
12137
  let e = n.trim().split(/\s+/).filter(Boolean), r = [];
@@ -12129,40 +12139,40 @@ function Hg(e) {
12129
12139
  let e = t.getElementById(n);
12130
12140
  e?.textContent && r.push(e.textContent.trim());
12131
12141
  } catch {}
12132
- if (r.length) return Vg(r.join(" "));
12142
+ if (r.length) return Kg(r.join(" "));
12133
12143
  }
12134
- if (e.labels && e.labels.length) return Vg(e.labels[0].textContent);
12144
+ if (e.labels && e.labels.length) return Kg(e.labels[0].textContent);
12135
12145
  let r = e.id;
12136
12146
  if (r) try {
12137
12147
  let e = t.querySelector(`label[for="${CSS.escape(r)}"]`);
12138
- if (e) return Vg(e.textContent);
12148
+ if (e) return Kg(e.textContent);
12139
12149
  } catch {
12140
12150
  let e = t.querySelector(`label[for="${r.replace(/"/g, "\\\"")}"]`);
12141
- if (e) return Vg(e.textContent);
12151
+ if (e) return Kg(e.textContent);
12142
12152
  }
12143
12153
  let i = e.previousElementSibling;
12144
12154
  for (let e = 0; e < 6 && i; e += 1) {
12145
- if (i.tagName === "LABEL") return Vg(i.textContent);
12155
+ if (i.tagName === "LABEL") return Kg(i.textContent);
12146
12156
  let e = (i.className || "").toString().toLowerCase();
12147
12157
  if (/chakra-form__label|formlabel|field-label|form-label|mui-form-label/.test(e)) {
12148
- let e = Vg(i.textContent);
12158
+ let e = Kg(i.textContent);
12149
12159
  if (e) return e;
12150
12160
  }
12151
12161
  i = i.previousElementSibling;
12152
12162
  }
12153
12163
  let a = e.parentElement;
12154
12164
  for (let e = 0; e < 5 && a; e += 1) {
12155
- if (a.tagName === "LABEL") return Vg(a.textContent);
12165
+ if (a.tagName === "LABEL") return Kg(a.textContent);
12156
12166
  let e = a.querySelector?.(":scope > label, :scope > [class*='FormLabel'], :scope > [class*='form__label']");
12157
- if (e?.textContent) return Vg(e.textContent);
12167
+ if (e?.textContent) return Kg(e.textContent);
12158
12168
  a = a.parentElement;
12159
12169
  }
12160
12170
  let o = e.getAttribute("aria-label");
12161
- return o ? Vg(o) : null;
12171
+ return o ? Kg(o) : null;
12162
12172
  }
12163
- function Ug() {
12173
+ function Jg() {
12164
12174
  let e = [];
12165
- return Bg((t) => {
12175
+ return Gg((t) => {
12166
12176
  e.push(...Array.from(t.querySelectorAll("input, select, textarea")).filter((e) => {
12167
12177
  if (An(e)) return !1;
12168
12178
  let t = (e.type || "").toLowerCase();
@@ -12173,15 +12183,15 @@ function Ug() {
12173
12183
  "image"
12174
12184
  ].includes(t) || e.disabled || e.readOnly) return !1;
12175
12185
  try {
12176
- let t = zg(e);
12186
+ let t = Wg(e);
12177
12187
  if (t.display === "none" || t.visibility === "hidden") return !1;
12178
12188
  } catch {}
12179
12189
  return !0;
12180
12190
  }));
12181
12191
  }), e;
12182
12192
  }
12183
- function Wg() {
12184
- return Ug().map((e, t) => {
12193
+ function Yg() {
12194
+ return Jg().map((e, t) => {
12185
12195
  let n = {
12186
12196
  formIndex: 0,
12187
12197
  fieldIndex: t,
@@ -12189,7 +12199,7 @@ function Wg() {
12189
12199
  type: e.type || "text",
12190
12200
  name: e.name || null,
12191
12201
  id: e.id || null,
12192
- label: Hg(e),
12202
+ label: qg(e),
12193
12203
  placeholder: e.placeholder || null
12194
12204
  };
12195
12205
  return e.tagName === "SELECT" && (n.options = Array.from(e.options).filter((e) => e.value !== "" && !e.disabled).map((e) => ({
@@ -12198,13 +12208,13 @@ function Wg() {
12198
12208
  })), n.currentValue = e.value || null), n;
12199
12209
  });
12200
12210
  }
12201
- function Gg() {
12211
+ function Xg() {
12202
12212
  let e = [];
12203
- return Bg((t) => {
12213
+ return Gg((t) => {
12204
12214
  e.push(...Array.from(t.querySelectorAll("button, [role=\"button\"], input[type=\"submit\"], input[type=\"button\"]")).filter((e) => {
12205
12215
  if (An(e) || e.disabled) return !1;
12206
12216
  try {
12207
- let t = zg(e);
12217
+ let t = Wg(e);
12208
12218
  if (t.display === "none" || t.visibility === "hidden") return !1;
12209
12219
  } catch {}
12210
12220
  return !0;
@@ -12216,7 +12226,7 @@ function Gg() {
12216
12226
  type: e.type || e.tagName
12217
12227
  }));
12218
12228
  }
12219
- function Kg(e, t) {
12229
+ function Zg(e, t) {
12220
12230
  try {
12221
12231
  if (!e?.getBoundingClientRect || !t?.getBoundingClientRect) return Infinity;
12222
12232
  let n = e.getBoundingClientRect(), r = t.getBoundingClientRect(), i = {
@@ -12231,7 +12241,7 @@ function Kg(e, t) {
12231
12241
  return Infinity;
12232
12242
  }
12233
12243
  }
12234
- function qg(e, t) {
12244
+ function Qg(e, t) {
12235
12245
  let n = String(t || "").toLowerCase().trim();
12236
12246
  if (!n) return 0;
12237
12247
  let r = (e.innerText || e.textContent || "").replace(/\s+/g, " ").trim(), i = [
@@ -12249,21 +12259,21 @@ function qg(e, t) {
12249
12259
  for (let e of a) i.includes(e) && (o += 1);
12250
12260
  return o / a.length * 92;
12251
12261
  }
12252
- function Jg(e, t, n = 6) {
12262
+ function $g(e, t, n = 6) {
12253
12263
  let r = String(t || "").toLowerCase().trim();
12254
12264
  if (!r) return !1;
12255
12265
  let i = e;
12256
12266
  for (let e = 0; e < n && i && (i = i.parentElement, i); e++) if ((i.innerText || i.textContent || "").toLowerCase().includes(r)) return !0;
12257
12267
  return !1;
12258
12268
  }
12259
- function Yg(e, t, n) {
12269
+ function e_(e, t, n) {
12260
12270
  let r = [];
12261
- Bg((e) => {
12271
+ Gg((e) => {
12262
12272
  let t = Array.from(e.querySelectorAll("button, [role=\"button\"], input[type=\"submit\"], input[type=\"button\"], a[href]"));
12263
12273
  r.push(...t.filter((e) => {
12264
12274
  if (An(e) || e.disabled) return !1;
12265
12275
  try {
12266
- let t = zg(e);
12276
+ let t = Wg(e);
12267
12277
  if (t.display === "none" || t.visibility === "hidden" || t.opacity === "0") return !1;
12268
12278
  } catch {}
12269
12279
  return !0;
@@ -12271,14 +12281,14 @@ function Yg(e, t, n) {
12271
12281
  });
12272
12282
  let i = 0, a = r.map((t) => ({
12273
12283
  el: t,
12274
- s: qg(t, e)
12284
+ s: Qg(t, e)
12275
12285
  }));
12276
12286
  for (let { s: e } of a) e > i && (i = e);
12277
12287
  if (i < 28) return null;
12278
12288
  let o = a.filter(({ s: e }) => e === i).map(({ el: e }) => e);
12279
12289
  if (o.length === 1) return o[0];
12280
12290
  if (n) {
12281
- let e = o.filter((e) => Jg(e, n));
12291
+ let e = o.filter((e) => $g(e, n));
12282
12292
  if (e.length === 1) return e[0];
12283
12293
  e.length > 1 && (o = e);
12284
12294
  }
@@ -12286,14 +12296,14 @@ function Yg(e, t, n) {
12286
12296
  if (s.length) {
12287
12297
  let e = o[0], t = Infinity;
12288
12298
  for (let n of o) for (let r of s) {
12289
- let i = Kg(n, r);
12299
+ let i = Zg(n, r);
12290
12300
  i < t && (t = i, e = n);
12291
12301
  }
12292
12302
  return e;
12293
12303
  }
12294
12304
  return o[0];
12295
12305
  }
12296
- function Xg(e) {
12306
+ function t_(e) {
12297
12307
  if (e == null) return {};
12298
12308
  if (typeof e == "string") {
12299
12309
  let t = e.trim();
@@ -12306,12 +12316,12 @@ function Xg(e) {
12306
12316
  }
12307
12317
  return e;
12308
12318
  }
12309
- function Zg(e) {
12319
+ function n_(e) {
12310
12320
  if (!e || typeof e != "object") return null;
12311
12321
  let t = e.url ?? e.target_url ?? e.page_url ?? e.pageUrl ?? e.link ?? e.href ?? e.path;
12312
12322
  return t == null ? null : String(t).trim() || null;
12313
12323
  }
12314
- function Qg() {
12324
+ function r_() {
12315
12325
  let e = {};
12316
12326
  document.querySelectorAll("h1, h2, h3, h4, h5, h6").forEach((t) => {
12317
12327
  if (t.id) return;
@@ -12326,7 +12336,7 @@ function Qg() {
12326
12336
  e[r] = !0, t.id = r;
12327
12337
  });
12328
12338
  }
12329
- function $g() {
12339
+ function i_() {
12330
12340
  let e = (e) => {
12331
12341
  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;
12332
12342
  for (; r < t.length;) {
@@ -12381,7 +12391,7 @@ function $g() {
12381
12391
  containerHeadings: o
12382
12392
  };
12383
12393
  }
12384
- function e_(e) {
12394
+ function a_(e) {
12385
12395
  if (!e || typeof document > "u") return "";
12386
12396
  let t = new Set([
12387
12397
  "script",
@@ -12467,11 +12477,11 @@ function e_(e) {
12467
12477
  return d.has(t) ? !1 : (d.add(t), !0);
12468
12478
  }).join("\n").replace(/\n{3,}/g, "\n\n").trim();
12469
12479
  }
12470
- function t_(e) {
12480
+ function o_(e) {
12471
12481
  let t = e.siteId || null, n = (e.apiBaseUrl || "").replace(/\/$/, ""), r = typeof e.getLastUserVoiceText == "function" ? e.getLastUserVoiceText : null, i = [], a = {
12472
12482
  "fwh-navigate-mvp": async (n) => {
12473
12483
  if ($("fwh-navigate-mvp ▶ raw parameters:", n), e?.isWalkthroughActive?.()) return $("fwh-navigate-mvp ✖ blocked — walkthrough in progress"), "NAVIGATION_BLOCKED_DURING_WALKTHROUGH. A walkthrough of the current page is in progress, so navigation is not allowed. Do NOT tell the visitor you navigated or offer to. Describe the requested section using the CURRENT page's own content (fwh-read-content-mvp), then stop.";
12474
- let i = Xg(n), a = Zg(i), o = i.section_text ?? i.sectionText ?? i.section, s = Array.isArray(i.expected_landmarks) ? i.expected_landmarks : Array.isArray(i.expectedLandmarks) ? i.expectedLandmarks : [];
12484
+ let i = t_(n), a = n_(i), o = i.section_text ?? i.sectionText ?? i.section, s = Array.isArray(i.expected_landmarks) ? i.expected_landmarks : Array.isArray(i.expectedLandmarks) ? i.expectedLandmarks : [];
12475
12485
  if ($("fwh-navigate-mvp · coerced:", {
12476
12486
  url: a,
12477
12487
  sectionText: o,
@@ -12511,18 +12521,18 @@ function t_(e) {
12511
12521
  correctedUrl: l
12512
12522
  }), a = l);
12513
12523
  try {
12514
- bg(`Navigating to ${a}...`, { spinner: !0 }), Tg(), On();
12524
+ Tg(`Navigating to ${a}...`, { spinner: !0 }), Ag(), On();
12515
12525
  try {
12516
12526
  let e = r ? r() : "";
12517
12527
  if (e && t) {
12518
- let n = hg([{
12528
+ let n = bg([{
12519
12529
  sender: "user",
12520
12530
  message: e
12521
12531
  }]);
12522
- n && L(t, n);
12532
+ n && z(t, n);
12523
12533
  }
12524
12534
  } catch {}
12525
- Ce();
12535
+ Se();
12526
12536
  let e = a;
12527
12537
  try {
12528
12538
  e = new URL(a, typeof window < "u" ? window.location.href : "").href;
@@ -12532,7 +12542,7 @@ function t_(e) {
12532
12542
  let e = new URL(a, window.location.href).pathname.split("/").filter(Boolean).pop() || "";
12533
12543
  n = e ? e.replace(/[-_]/g, " ").replace(/\b\w/g, (e) => e.toUpperCase()) : "Home";
12534
12544
  } catch {}
12535
- t && typeof window < "u" && Ae(t, window.location.href, e, n), gr(e);
12545
+ t && typeof window < "u" && ke(t, window.location.href, e, n), gr(e);
12536
12546
  try {
12537
12547
  window.__fe_agent_nav = {
12538
12548
  path: new URL(e, window.location.href).pathname,
@@ -12550,8 +12560,8 @@ function t_(e) {
12550
12560
  typeof window < "u" && window.scrollTo(0, 0);
12551
12561
  } catch {}
12552
12562
  let o = [], s = null, c = "", l = Date.now() + 12e3;
12553
- for (; Date.now() < l && (await new Promise((e) => setTimeout(e, 300)), {headings: o, pageTitleHeading: s, introText: c} = $g(), !(o.length >= 1)););
12554
- Qg(), $("fwh-navigate-mvp → page headings collected:", o, "titleHeading:", s);
12563
+ for (; Date.now() < l && (await new Promise((e) => setTimeout(e, 300)), {headings: o, pageTitleHeading: s, introText: c} = i_(), !(o.length >= 1)););
12564
+ r_(), $("fwh-navigate-mvp → page headings collected:", o, "titleHeading:", s);
12555
12565
  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 = "";
12556
12566
  try {
12557
12567
  if (o.length > 0) {
@@ -12559,7 +12569,7 @@ function t_(e) {
12559
12569
  for (let n of e) {
12560
12570
  let e = cr(null, n);
12561
12571
  if (e) {
12562
- let r = e_(e).substring(0, 800);
12572
+ let r = a_(e).substring(0, 800);
12563
12573
  r && t.push(`[Section: ${n}] ${r}`);
12564
12574
  }
12565
12575
  }
@@ -12568,57 +12578,57 @@ function t_(e) {
12568
12578
  } catch {}
12569
12579
  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.`;
12570
12580
  let m = Date.now() + 4e3, h = typeof window < "u" ? window.location.pathname : r;
12571
- for (; Date.now() < m && !Rg(h, e) && Rg(h, t);) await new Promise((e) => setTimeout(e, 120)), h = window.location.pathname;
12581
+ for (; Date.now() < m && !Ug(h, e) && Ug(h, t);) await new Promise((e) => setTimeout(e, 120)), h = window.location.pathname;
12572
12582
  $("fwh-navigate-mvp route settle:", {
12573
12583
  startPath: t,
12574
12584
  targetPath: e,
12575
12585
  settledPath: h
12576
12586
  });
12577
- let g = typeof window < "u" ? window.location.href : i, _ = (h.split("/").filter(Boolean).pop() || "").replace(/[-_]/g, " ").replace(/\b\w/g, (e) => e.toUpperCase()) || "Home", v = Rg(h, e), y = !Rg(h, t), b = v || y;
12587
+ 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 = Ug(h, e), y = !Ug(h, t), b = v || y;
12578
12588
  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.`);
12579
12589
  } catch {}
12580
12590
  return "OK_NAVIGATE_RELOADING. The page is reloading now and this session is ending. Say NOTHING further — do not confirm the navigation, do not describe the page. The arrival greeting is spoken automatically on the new page; you resume from the visitor's next reply.";
12581
12591
  } catch (e) {
12582
12592
  let t = `Navigation error: ${e?.message || String(e)}`;
12583
- return $("fwh-navigate-mvp ✖", t), bg("Navigation failed", {
12593
+ return $("fwh-navigate-mvp ✖", t), Tg("Navigation failed", {
12584
12594
  spinner: !1,
12585
12595
  icon: "⚠️",
12586
12596
  duration: 1800
12587
12597
  }), t;
12588
12598
  } finally {
12589
- Eg(), xg(900);
12599
+ jg(), Eg(900);
12590
12600
  }
12591
12601
  },
12592
12602
  "fwh-highlight-mvp": async (e) => {
12593
12603
  $("fwh-highlight-mvp ▶", e);
12594
- let t = Xg(e), n = t?.section_id || t?.sectionId, r = t?.section_text || t?.sectionText;
12604
+ let t = t_(e), n = t?.section_id || t?.sectionId, r = t?.section_text || t?.sectionText;
12595
12605
  if (Rn(3e3), typeof window < "u" && window.__fe_user_nav_during_speech) {
12596
12606
  let e = window.__fe_user_nav_during_speech, t = window.location.pathname;
12597
12607
  if (Date.now() - e.ts >= 3e4) window.__fe_user_nav_during_speech = null;
12598
12608
  else return $("flowengage_highlight ✖ blocked — user navigated during speech", e), `NAV_CHANGED: The visitor navigated from "${e.fromPageName}" to "${e.toPageName}" (current path: ${t}) while you were speaking. STOP the current walkthrough immediately. DO NOT call fwh-highlight-mvp again. Say out loud: "I see you've navigated to the ${e.toPageName} page — do you want me to continue what I was explaining, or shall I guide you through this page?" Wait for the visitor's answer before doing anything else.`;
12599
12609
  }
12600
- Qg();
12610
+ r_();
12601
12611
  let i = ((e) => e && e.replace(/^\d+\.\s*/, "").replace(/^["']|["']$/g, "").trim())(r), a = cr(n || null, i || null);
12602
12612
  if (!a && i) {
12603
12613
  let e = Date.now() + 600;
12604
- for (; !a && Date.now() < e;) await new Promise((e) => setTimeout(e, 50)), Qg(), a = cr(null, i);
12614
+ for (; !a && Date.now() < e;) await new Promise((e) => setTimeout(e, 50)), r_(), a = cr(null, i);
12605
12615
  }
12606
12616
  if (!a) {
12607
12617
  $("fwh-highlight-mvp ✖ no element for:", i || n);
12608
- let { headings: e } = $g(), t = e.length ? `Page headings: ${e.map((e) => `"${e}"`).join(" | ")}. Use one of these EXACT strings for section_text — no numbers, no quotes around them.` : "No headings found — skip highlight and continue speaking.";
12618
+ let { headings: e } = i_(), 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.";
12609
12619
  return `HIGHLIGHT_NOT_FOUND: "${i || n}" on the current page. ${t}`;
12610
12620
  }
12611
12621
  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.`;
12612
12622
  },
12613
12623
  "fwh-read-content-mvp": async (e) => {
12614
12624
  $("fwh-read-content-mvp ▶", e);
12615
- let t = Xg(e), n = t?.section_text || t?.sectionText || "";
12625
+ let t = t_(e), n = t?.section_text || t?.sectionText || "";
12616
12626
  try {
12617
12627
  let e = "";
12618
12628
  if (n) {
12619
12629
  let t = cr(null, n);
12620
12630
  if (!t) return `Could not find section "${n}" on the page.`;
12621
- e = e_(t);
12631
+ e = a_(t);
12622
12632
  } else {
12623
12633
  let t = (document.querySelector("main") || document.querySelector("article") || document.querySelector("[role=\"main\"]") || document.querySelector("#content") || document.querySelector(".content") || document.body).cloneNode(!0);
12624
12634
  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();
@@ -12630,7 +12640,7 @@ function t_(e) {
12630
12640
  },
12631
12641
  "fwh-page-content-mvp": async (e) => {
12632
12642
  $("fwh-page-content-mvp ▶", e);
12633
- let r = Xg(e), i = r?.url || r?.page_url || "";
12643
+ let r = t_(e), i = r?.url || r?.page_url || "";
12634
12644
  if ($("fwh-page-content-mvp · url:", i, "siteId:", t, "apiBase:", n || "(empty)"), !i) return $("fwh-page-content-mvp ✖ missing url"), "Missing url parameter.";
12635
12645
  if (!t) return $("fwh-page-content-mvp ✖ no siteId"), "Site is not configured.";
12636
12646
  if (!n) return $("fwh-page-content-mvp ✖ no api base"), "API base URL is missing; cannot fetch page content.";
@@ -12662,7 +12672,7 @@ function t_(e) {
12662
12672
  },
12663
12673
  "fwh-search-mvp": async (e) => {
12664
12674
  $("fwh-search-mvp ▶", e);
12665
- let r = Xg(e).query;
12675
+ let r = t_(e).query;
12666
12676
  if (!r) return $("fwh-search-mvp ✖ missing query"), "Missing query parameter.";
12667
12677
  if (!t) return $("fwh-search-mvp ✖ no siteId"), "Search unavailable (no siteId configured).";
12668
12678
  if (!n) return $("fwh-search-mvp ✖ no api base"), "Search unavailable (no API base URL).";
@@ -12700,7 +12710,7 @@ function t_(e) {
12700
12710
  "[class*='menu'] a",
12701
12711
  "[class*='header'] a"
12702
12712
  ];
12703
- if (Bg((t) => {
12713
+ if (Gg((t) => {
12704
12714
  for (let r of n) try {
12705
12715
  t.querySelectorAll(r).forEach((t) => {
12706
12716
  if (An(t)) return;
@@ -12708,7 +12718,7 @@ function t_(e) {
12708
12718
  if (!r || !n || n === "#" || n.startsWith("javascript:")) return;
12709
12719
  try {
12710
12720
  let e = t.parentElement;
12711
- if (e && zg(e).display === "none" && !e.closest("nav, [role='navigation'], header, [class*='nav'], [class*='menu']")) return;
12721
+ if (e && Wg(e).display === "none" && !e.closest("nav, [role='navigation'], header, [class*='nav'], [class*='menu']")) return;
12712
12722
  } catch {}
12713
12723
  let i = r.toLowerCase() + "|" + n;
12714
12724
  e.has(i) || e.set(i, {
@@ -12719,7 +12729,7 @@ function t_(e) {
12719
12729
  } catch {}
12720
12730
  t.querySelectorAll("select").forEach((t) => {
12721
12731
  if (An(t)) return;
12722
- let n = Hg(t);
12732
+ let n = qg(t);
12723
12733
  /nav|menu|page|section|go to/i.test(n || t.name || t.id || "") && Array.from(t.options).forEach((r) => {
12724
12734
  if (!r.value || r.disabled) return;
12725
12735
  let i = r.text.trim();
@@ -12743,7 +12753,7 @@ function t_(e) {
12743
12753
  if ($("fwh-get-current-page-mvp ▶"), typeof window > "u") return "Cannot determine current page (no browser context).";
12744
12754
  let e = window.location.href, t = window.location.pathname, n = document.title || "";
12745
12755
  if (yr()) return $("fwh-get-current-page-mvp ✓ 404 detected", { url: e }), `CURRENT_PAGE_NOT_FOUND. The visitor is currently on a 404 / page-not-found error page (${e}). There is no real content here. Do NOT describe this page, do NOT list sections, do NOT offer a walkthrough, and do NOT describe it from your own knowledge. Tell the visitor plainly that the page they are on doesn't exist, and offer to take them somewhere that does.`;
12746
- let { headings: r, pageTitleHeading: i, introText: a } = $g();
12756
+ let { headings: r, pageTitleHeading: i, introText: a } = i_();
12747
12757
  $("fwh-get-current-page-mvp ✓", {
12748
12758
  url: e,
12749
12759
  path: t,
@@ -12755,7 +12765,7 @@ function t_(e) {
12755
12765
  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. ***`;
12756
12766
  },
12757
12767
  "fwh-list-forms-mvp": async () => {
12758
- let e = Wg(), t = Gg();
12768
+ let e = Yg(), t = Xg();
12759
12769
  $("fwh-list-forms-mvp ✓", `${e.length} field(s)`, `${t.length} button(s)`);
12760
12770
  let n = e.map((e) => ({
12761
12771
  ...e,
@@ -12769,12 +12779,12 @@ function t_(e) {
12769
12779
  },
12770
12780
  "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.",
12771
12781
  "fwh-click-button-mvp": async (e) => {
12772
- let t = Xg(e), n = (t.button_text ?? t.buttonText ?? t.text ?? "").trim(), r = (t.card_context ?? t.cardContext ?? "").trim();
12782
+ let t = t_(e), n = (t.button_text ?? t.buttonText ?? t.text ?? "").trim(), r = (t.card_context ?? t.cardContext ?? "").trim();
12773
12783
  if ($("fwh-click-button-mvp ▶", n, r ? `(card_context: ${r})` : ""), !n) return "Missing button_text: pass the visible label, e.g. Conduct Audit.";
12774
- let a = Yg(n, i, r);
12784
+ let a = e_(n, i, r);
12775
12785
  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.`;
12776
12786
  try {
12777
- bg(`Clicking ${n}...`, { spinner: !0 });
12787
+ Tg(`Clicking ${n}...`, { spinner: !0 });
12778
12788
  try {
12779
12789
  a.scrollIntoView({
12780
12790
  block: "center",
@@ -12783,22 +12793,22 @@ function t_(e) {
12783
12793
  } catch {
12784
12794
  a.scrollIntoView(!0);
12785
12795
  }
12786
- await jg(a), a.focus?.(), await Ng(a), Pg(a), a.click();
12796
+ await Ig(a), a.focus?.(), await Rg(a), zg(a), a.click();
12787
12797
  let e = (a.textContent || a.value || a.getAttribute("aria-label") || "").trim().slice(0, 80) || "button", t = `OK_CLICK ${e}`;
12788
- return $("fwh-click-button-mvp ✓", t), bg(`Clicked ${e}`, {
12798
+ return $("fwh-click-button-mvp ✓", t), Tg(`Clicked ${e}`, {
12789
12799
  spinner: !1,
12790
12800
  icon: "✅",
12791
12801
  duration: 1200
12792
12802
  }), t;
12793
12803
  } catch (e) {
12794
12804
  let t = `Click failed: ${e?.message || String(e)}`;
12795
- return $("fwh-click-button-mvp ✖", t), bg("Click failed", {
12805
+ return $("fwh-click-button-mvp ✖", t), Tg("Click failed", {
12796
12806
  spinner: !1,
12797
12807
  icon: "⚠️",
12798
12808
  duration: 1800
12799
12809
  }), t;
12800
12810
  } finally {
12801
- Mg(), xg(700);
12811
+ Lg(), Eg(700);
12802
12812
  }
12803
12813
  },
12804
12814
  "fwh-cart-get-mvp": async () => {
@@ -12897,7 +12907,7 @@ function t_(e) {
12897
12907
  try {
12898
12908
  r = new URL(e, window.location.href).href;
12899
12909
  } catch {}
12900
- return t && Ae(t, window.location.href, r, n), gr(r), Cr().then(() => {
12910
+ return t && ke(t, window.location.href, r, n), gr(r), Cr().then(() => {
12901
12911
  window.location.assign(r);
12902
12912
  }), `OK_NAVIGATING to ${n}. The page is loading — say one short phrase like "Here you go." and nothing more.`;
12903
12913
  }
@@ -12911,10 +12921,10 @@ function t_(e) {
12911
12921
  clickPageButton: a["fwh-click-button-mvp"]
12912
12922
  };
12913
12923
  }
12914
- var n_ = /^(get in touch|contact us|let'?s (talk|connect)|subscribe|newsletter|follow us|quick links|company|solutions|what we do|resources|legal|sitemap|share this)/i;
12915
- function r_() {
12924
+ var s_ = /^(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;
12925
+ function c_() {
12916
12926
  try {
12917
- let { headings: e, pageTitleHeading: t, containerHeadings: n } = $g(), r = new Set((n || []).map((e) => e.trim())), i = (e || []).map((e) => typeof e == "string" ? e : e?.text || "").filter(Boolean).filter((e) => !t || e.trim() !== t.trim()).filter((e) => !n_.test(e.trim())), a = i.filter((e) => !r.has(e.trim()));
12927
+ let { headings: e, pageTitleHeading: t, containerHeadings: n } = i_(), r = new Set((n || []).map((e) => e.trim())), i = (e || []).map((e) => typeof e == "string" ? e : e?.text || "").filter(Boolean).filter((e) => !t || e.trim() !== t.trim()).filter((e) => !s_.test(e.trim())), a = i.filter((e) => !r.has(e.trim()));
12918
12928
  return a.length ? a : i;
12919
12929
  } catch {
12920
12930
  return [];
@@ -12922,7 +12932,7 @@ function r_() {
12922
12932
  }
12923
12933
  //#endregion
12924
12934
  //#region src/utils/wrapVoiceToolsForLogging.js
12925
- function i_(e) {
12935
+ function l_(e) {
12926
12936
  return !e || typeof e != "object" ? e : Object.fromEntries(Object.entries(e).map(([e, t]) => [e, async (n) => {
12927
12937
  let r = wn();
12928
12938
  r ? console.log("[FlowEngage:voice-tool] ▶", e, n) : console.info(`[FlowEngage] voice tool » ${e}`);
@@ -12939,11 +12949,11 @@ function i_(e) {
12939
12949
  }
12940
12950
  //#endregion
12941
12951
  //#region src/components/FlowEngageWidget.jsx
12942
- var a_ = "[PAGE_CONTEXT]";
12943
- function o_(e, t, n) {
12944
- return `${a_} SESSION_CONTEXT (NOT a tool result — do NOT treat as CURRENT_PAGE): Visitor is on: ${e} | Approx headings for awareness only: ${t || ""}. ${n ? `Forms: ${n}. ` : ""}The visitor is ALREADY on this page — do NOT offer to navigate there.`;
12952
+ var u_ = "[PAGE_CONTEXT]";
12953
+ function d_(e, t, n) {
12954
+ return `${u_} SESSION_CONTEXT (NOT a tool result — do NOT treat as CURRENT_PAGE): Visitor is on: ${e} | Approx headings for awareness only: ${t || ""}. ${n ? `Forms: ${n}. ` : ""}The visitor is ALREADY on this page — do NOT offer to navigate there.`;
12945
12955
  }
12946
- var s_ = {
12956
+ var f_ = {
12947
12957
  blue: "#135bd8",
12948
12958
  red: "#ef334b",
12949
12959
  yellow: "#ffbd2e",
@@ -12951,7 +12961,7 @@ var s_ = {
12951
12961
  highlight: "rgba(255,255,255,0.9)",
12952
12962
  green: "#10b981"
12953
12963
  };
12954
- function c_(e) {
12964
+ function p_(e) {
12955
12965
  if (!Array.isArray(e) || e.length < 2) return "linear-gradient(145deg, #dce8f022 0%, #e8dff522 45%, #f5e0e022 100%), #f7f8fa";
12956
12966
  let [t, n, r] = e;
12957
12967
  return e.length >= 3 && r ? [
@@ -12965,12 +12975,12 @@ function c_(e) {
12965
12975
  "#f7f8fa"
12966
12976
  ].join(", ");
12967
12977
  }
12968
- function l_(e) {
12978
+ function m_(e) {
12969
12979
  if (!e || typeof e != "string") return "#1a1a1a";
12970
12980
  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;
12971
12981
  return .2126 * o(r) + .7152 * o(i) + .0722 * o(a) > .179 ? "#1a1a1a" : "#ffffff";
12972
12982
  }
12973
- function u_(t) {
12983
+ function h_(t) {
12974
12984
  let [n, r] = e.useState(null), i = typeof t == "string" ? t.trim() : "";
12975
12985
  return e.useEffect(() => {
12976
12986
  if (!i) {
@@ -12988,8 +12998,8 @@ function u_(t) {
12988
12998
  };
12989
12999
  }, [i]), n;
12990
13000
  }
12991
- function d_({ logo: t, style: n }) {
12992
- let r = u_(typeof t == "string" ? t : null);
13001
+ function g_({ logo: t, style: n }) {
13002
+ let r = h_(typeof t == "string" ? t : null);
12993
13003
  if (!t) return null;
12994
13004
  if (typeof t == "string") return r ? /* @__PURE__ */ g("img", {
12995
13005
  src: r,
@@ -13014,7 +13024,7 @@ function d_({ logo: t, style: n }) {
13014
13024
  children: i
13015
13025
  }) : null;
13016
13026
  }
13017
- function f_({ title: e }) {
13027
+ function __({ title: e }) {
13018
13028
  return /* @__PURE__ */ g("div", {
13019
13029
  style: {
13020
13030
  width: "100%",
@@ -13032,18 +13042,18 @@ function f_({ title: e }) {
13032
13042
  children: String(e || "FE").split(/\s+/).filter(Boolean).slice(0, 2).map((e) => e[0]?.toUpperCase() || "").join("") || "FE"
13033
13043
  });
13034
13044
  }
13035
- function p_(e, t) {
13045
+ function v_(e, t) {
13036
13046
  let n = (t || "").trim();
13037
13047
  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;
13038
13048
  }
13039
- function m_({ orbColors: e, ...t }) {
13040
- return /* @__PURE__ */ g(og, {
13049
+ function y_({ orbColors: e, ...t }) {
13050
+ return /* @__PURE__ */ g(dg, {
13041
13051
  colors: e,
13042
13052
  ...t
13043
13053
  });
13044
13054
  }
13045
- function h_({ copy: e, orbColors: t, primaryColor: n, onYes: r, onLater: i, isMobile: a, isClosing: o }) {
13046
- let s = n || s_.green, c = l_(s), l = a ? 72 : 94, u = /* @__PURE__ */ _("div", {
13055
+ function b_({ copy: e, orbColors: t, primaryColor: n, onYes: r, onLater: i, isMobile: a, isClosing: o }) {
13056
+ let s = n || f_.green, c = m_(s), l = a ? 72 : 94, u = /* @__PURE__ */ _("div", {
13047
13057
  style: {
13048
13058
  display: "flex",
13049
13059
  alignItems: a ? "flex-end" : "center",
@@ -13169,7 +13179,7 @@ function h_({ copy: e, orbColors: t, primaryColor: n, onYes: r, onLater: i, isMo
13169
13179
  delay: 0
13170
13180
  },
13171
13181
  style: { flexShrink: 0 },
13172
- children: /* @__PURE__ */ g(m_, {
13182
+ children: /* @__PURE__ */ g(y_, {
13173
13183
  size: l,
13174
13184
  orbColors: t
13175
13185
  })
@@ -13201,8 +13211,8 @@ function h_({ copy: e, orbColors: t, primaryColor: n, onYes: r, onLater: i, isMo
13201
13211
  children: u
13202
13212
  })] });
13203
13213
  }
13204
- function g_({ copy: e, orbColors: t, primaryColor: n, onVoice: r, onText: i, onClose: a, isMobile: o, isClosing: s }) {
13205
- let c = n || s_.green, l = l_(c);
13214
+ function x_({ copy: e, orbColors: t, primaryColor: n, onVoice: r, onText: i, onClose: a, isMobile: o, isClosing: s }) {
13215
+ let c = n || f_.green, l = m_(c);
13206
13216
  return /* @__PURE__ */ _(eh.div, {
13207
13217
  initial: {
13208
13218
  scale: 50 / 350,
@@ -13273,7 +13283,7 @@ function g_({ copy: e, orbColors: t, primaryColor: n, onVoice: r, onText: i, onC
13273
13283
  children: /* @__PURE__ */ g("polyline", { points: "6 9 12 15 18 9" })
13274
13284
  })
13275
13285
  }),
13276
- /* @__PURE__ */ g(m_, {
13286
+ /* @__PURE__ */ g(y_, {
13277
13287
  size: 72,
13278
13288
  orbColors: t
13279
13289
  }),
@@ -13353,96 +13363,96 @@ function g_({ copy: e, orbColors: t, primaryColor: n, onVoice: r, onText: i, onC
13353
13363
  ]
13354
13364
  });
13355
13365
  }
13356
- function __({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i, apiBaseUrl: a, chatId: s, historyRef: l, onMessageSync: u, voiceEndCounter: d, websiteName: f, voiceFirstMessage: h, captureVisitorEmail: v, emailRequired: y, emailCaptureEnabled: b = !0, listeningLabel: x = "Listening...", thinkingLabel: S = "Thinking...", enterChatModeLabel: C = "Enter Chat Mode", endConversationLabel: w = "End Conversation" }) {
13366
+ function S_({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i, apiBaseUrl: a, chatId: s, historyRef: l, onMessageSync: u, voiceEndCounter: d, websiteName: f, voiceFirstMessage: h, captureVisitorEmail: v, emailRequired: y, emailCaptureEnabled: b = !0, listeningLabel: x = "Listening...", thinkingLabel: S = "Thinking...", enterChatModeLabel: C = "Enter Chat Mode", endConversationLabel: w = "End Conversation" }) {
13357
13367
  c(() => (console.log("[FlowEngage:VoiceDebug] 🔵 VoiceMode MOUNTED"), () => console.log("[FlowEngage:VoiceDebug] 🔴 VoiceMode UNMOUNTED")), []);
13358
- let [T, E] = m("idle"), [D, O] = m(!1), [k, A] = m(!1), [ee, te] = m(!1), [ne, j] = m(""), [M, re] = m(""), ie = p(!1), ae = p(!1), N = p(null), oe = p(0), se = p(""), P = p(!1), ce = p(0), le = p(!1), ue = p(!1), de = p(!1), fe = p([]), pe = p(null), me = p(null), he = (e) => {
13359
- le.current = e, e || (ue.current = !1), F.current?.setWalkthroughActive?.(e);
13368
+ let [T, E] = m("idle"), [D, O] = m(!1), [k, A] = m(!1), [ee, te] = m(!1), [j, M] = m(""), [N, ne] = m(""), re = p(!1), P = p(!1), ie = p(null), F = p(0), ae = p(""), I = p(!1), oe = p(0), se = p(!1), ce = p(!1), le = p(!1), ue = p([]), de = p(null), fe = p(""), pe = p(null), me = (e) => {
13369
+ se.current = e, e || (ce.current = !1), L.current?.setWalkthroughActive?.(e);
13360
13370
  };
13361
- me.current = async () => {
13362
- if (ue.current) return;
13371
+ pe.current = async () => {
13372
+ if (ce.current) return;
13363
13373
  let e = typeof window < "u" ? window.location.pathname : null;
13364
- if (e && pe.current && e !== pe.current) {
13365
- console.log("[FlowEngage] walkthrough ended — visitor left " + pe.current), pe.current = null, fe.current = [], he(!1);
13374
+ if (e && de.current && e !== de.current) {
13375
+ console.log("[FlowEngage] walkthrough ended — visitor left " + de.current), de.current = null, ue.current = [], me(!1);
13366
13376
  return;
13367
13377
  }
13368
- let t = fe.current;
13369
- ge.current += 1;
13370
- let n = ge.current, r = t[n];
13378
+ let t = ue.current;
13379
+ he.current += 1;
13380
+ let n = he.current, r = t[n];
13371
13381
  if (!r) {
13372
- if (he(!1), t.length) F.current?.sendUserMessage?.("That was the last section. Say so in one short sentence and ask if they want to explore any section further.");
13382
+ if (me(!1), t.length) L.current?.sendUserMessage?.("That was the last section. Say so in one short sentence and ask if they want to explore any section further.");
13373
13383
  else if (n === 0) {
13374
13384
  let e = "";
13375
13385
  try {
13376
- let t = await _e.current?.["fwh-read-content-mvp"]?.({});
13386
+ let t = await ge.current?.["fwh-read-content-mvp"]?.({});
13377
13387
  typeof t == "string" && t && !/^Could not/i.test(t) && (e = t.slice(0, 2800));
13378
13388
  } catch {}
13379
- F.current?.sendUserMessage?.(e ? `Give the visitor a complete spoken overview of this page in 4-6 sentences, based ONLY on this page content:\n"""${e}"""\nThen ask which part they'd like to hear more about. Do not call any tool.` : "Give the visitor a complete spoken overview of this page in 4-6 sentences based on what you know about it, then ask which part they'd like to hear more about. Do not call any tool.", { suppressQuestion: !0 });
13389
+ L.current?.sendUserMessage?.(e ? `Give the visitor a complete spoken overview of this page in 4-6 sentences, based ONLY on this page content:\n"""${e}"""\nThen ask which part they'd like to hear more about. Do not call any tool.` : "Give the visitor a complete spoken overview of this page in 4-6 sentences based on what you know about it, then ask which part they'd like to hear more about. Do not call any tool.", { suppressQuestion: !0 });
13380
13390
  }
13381
13391
  return;
13382
13392
  }
13383
13393
  try {
13384
- await _e.current?.highlightOnPage?.({ section_text: r });
13394
+ await ge.current?.highlightOnPage?.({ section_text: r });
13385
13395
  } catch (e) {
13386
13396
  console.warn("[FlowEngage] walkthrough highlight failed:", e?.message || e);
13387
13397
  }
13388
13398
  console.debug(`[FlowEngage] walkthrough step ${n + 1}/${t.length}: ${r}`);
13389
13399
  let i = "";
13390
13400
  try {
13391
- let e = await _e.current?.["fwh-read-content-mvp"]?.({ section_text: r });
13401
+ let e = await ge.current?.["fwh-read-content-mvp"]?.({ section_text: r });
13392
13402
  typeof e == "string" && e && !/^Could not/i.test(e) && (i = e.slice(0, 2500));
13393
13403
  } catch {}
13394
13404
  let a = i ? `Here is this section's full content — describe it from THIS text only, and do not call any tool:\n"""${i}"""\n` : "read the section's content silently first (fwh-read-content-mvp) if you don't already have it. ";
13395
- F.current?.sendUserMessage?.(`Describe the section titled "${r}" in 3-4 sentences, starting with ${n === 0 ? "Starting with" : "Next —"} ${r}. Describe ONLY this section. If this section contains named sub-items (steps, checklist entries, cards, plans, FAQs, team members), name EVERY one of them in order with a short phrase each — never skip or collapse them into a summary; ` + a + "This section is ON THE PAGE THE VISITOR IS ALREADY ON — do NOT call fwh-navigate-mvp, do not go to a product/detail page, and do not offer to, even if this section's name also matches a page name. Do not mention any other section, do not ask whether to continue, then stop.", { suppressQuestion: !0 });
13405
+ L.current?.sendUserMessage?.(`Describe the section titled "${r}" in 3-4 sentences, starting with ${n === 0 ? "Starting with" : "Next —"} ${r}. Describe ONLY this section. If this section contains named sub-items (steps, checklist entries, cards, plans, FAQs, team members), name EVERY one of them in order with a short phrase each — never skip or collapse them into a summary; ` + a + "This section is ON THE PAGE THE VISITOR IS ALREADY ON — do NOT call fwh-navigate-mvp, do not go to a product/detail page, and do not offer to, even if this section's name also matches a page name. Do not mention any other section, do not ask whether to continue, then stop.", { suppressQuestion: !0 });
13396
13406
  };
13397
- let ge = p(0), F = p(null), _e = p(null), ve = p(""), ye = p(async () => {}), I = p(!1), be = p(!1), R = p(!1), we = p(!1), Te = p("minimized"), Ee = p(null), De = p(null), ke = p(null), Ae = p(0), Me = p(!1), z = p("idle"), Ne = p(null), Pe = p(!1), Fe = p(null), B = o((e = "minimized") => {
13407
+ let he = p(0), L = p(null), ge = p(null), _e = p(""), R = p(async () => {}), ve = p(!1), xe = p(!1), Ce = p(!1), we = p(!1), Te = p("minimized"), Ee = p(null), Oe = p(null), ke = p(null), je = p(0), Me = p(!1), Ne = p("idle"), Pe = p(null), Fe = p(!1), B = p(null), V = o((e = "minimized") => {
13398
13408
  console.warn("[FlowEngage:VoiceDebug] 🛑 requestSessionShutdown called", {
13399
13409
  destination: e,
13400
13410
  stack: (/* @__PURE__ */ Error()).stack?.split("\n").slice(1, 4).join(" | ")
13401
13411
  }), Te.current = e, we.current = !0, queueMicrotask(() => {
13402
- I.current || (I.current = !0, ye.current?.());
13412
+ ve.current || (ve.current = !0, R.current?.());
13403
13413
  });
13404
- }, [l]), V = o(() => {
13405
- N.current &&= (clearTimeout(N.current), null);
13414
+ }, [l]), Ie = o(() => {
13415
+ ie.current &&= (clearTimeout(ie.current), null);
13406
13416
  }, []);
13407
13417
  c(() => {
13408
13418
  if (y) {
13409
- ie.current = !1;
13419
+ re.current = !1;
13410
13420
  return;
13411
13421
  }
13412
- if (ie.current = !0, ae.current = !1, te(!1), V(), P.current) {
13413
- P.current = !1, F.current?.setMicMuted?.(!1);
13414
- let e = se.current;
13415
- se.current = "", F.current?.injectAgentSpeech?.("Thanks — I already have your email on file.", "interrupt"), e && F.current?.sendUserMessage?.(`The visitor's email is already on file — do not ask for it. Answer their question now: "${e}"`);
13416
- }
13417
- F.current?.sendContextualUpdate?.("EMAIL REQUIREMENT SATISFIED — the visitor's email is already on file. All earlier instructions about requiring or asking for an email are VOID. Never ask for it again.");
13418
- }, [y, V]);
13419
- let Ie = /(walk\s*(me\s*)?through|walkthrough|take me through|(complete|full|detailed) (overview|understanding|walkthrough|picture|breakdown|explanation)|give me (a|an|the) (overview|tour|walk)|tell me about (each|all)|go through (it|them|each|all)|overview of|one by one|tell me everything|explain (me )?(this|the) (whole |entire |full )?page|everything (about|on) this page|show me (each|all|around))/i, Le = /(that covers everything|that was all|covered everything|that(?:'|’)?s everything)/i, Re = /^((uh+|um+|so|well|okay|ok|yeah)[,.\s]+)*(yes|yeah|yep|yup|sure|ok(ay)?|please|continue|go on|next|keep going|carry on|go ahead|resume|back to the tour)[\s.!,]*$/i, ze = /^((uh+|um+|oh|ah|so|well)[,.\s]+)*(cool|nice|great|awesome|wow|lovely|perfect|got it|gotcha|i see|understood|makes sense|interesting|right|alright|sounds good|mm+-?hmm+|hmm+|k)[\s.!,]*$/i, Be = (e) => String(e || "").replace(/[\s.,!?]*((uh+|um+|er+|hmm+|mm+)[\s.,!?]*)+$/i, "").trim(), Ve = o(() => {
13420
- V(), N.current = setTimeout(() => {
13421
- if (!(!ae.current || ie.current)) if (oe.current < 3) {
13422
- oe.current += 1;
13422
+ if (re.current = !0, P.current = !1, te(!1), Ie(), I.current) {
13423
+ I.current = !1, L.current?.setMicMuted?.(!1);
13424
+ let e = ae.current;
13425
+ ae.current = "", L.current?.injectAgentSpeech?.("Thanks — I already have your email on file.", "interrupt"), e && L.current?.sendUserMessage?.(`The visitor's email is already on file — do not ask for it. Answer their question now: "${e}"`);
13426
+ }
13427
+ L.current?.sendContextualUpdate?.("EMAIL REQUIREMENT SATISFIED — the visitor's email is already on file. All earlier instructions about requiring or asking for an email are VOID. Never ask for it again.");
13428
+ }, [y, Ie]);
13429
+ let Le = /(walk\s*(me\s*)?through|walkthrough|take me through|(complete|full|detailed) (overview|understanding|walkthrough|picture|breakdown|explanation)|give me (a|an|the) (overview|tour|walk)|tell me about (each|all)|go through (it|them|each|all)|overview of|one by one|tell me everything|explain (me )?(this|the) (whole |entire |full )?page|everything (about|on) this page|show me (each|all|around))/i, Re = /(that covers everything|that was all|covered everything|that(?:'|’)?s everything)/i, ze = /^((uh+|um+|so|well|okay|ok|yeah)[,.\s]+)*(yes|yeah|yep|yup|sure|ok(ay)?|please|continue|go on|next|keep going|carry on|go ahead|resume|back to the tour)[\s.!,]*$/i, Be = /(would you like (me )?to take you|shall i take you|want me to take you|would you like to (go|explore|visit|see)|take you there)/i, Ve = /^((uh+|um+|oh|ah|so|well)[,.\s]+)*(cool|nice|great|awesome|wow|lovely|perfect|got it|gotcha|i see|understood|makes sense|interesting|right|alright|sounds good|mm+-?hmm+|hmm+|k)[\s.!,]*$/i, He = (e) => String(e || "").replace(/[\s.,!?]*((uh+|um+|er+|hmm+|mm+)[\s.,!?]*)+$/i, "").trim(), Ue = o(() => {
13430
+ Ie(), ie.current = setTimeout(() => {
13431
+ if (!(!P.current || re.current)) if (F.current < 3) {
13432
+ F.current += 1;
13423
13433
  try {
13424
- F.current?.injectAgentSpeech?.("I still need your email in the box below to continue — could you enter it, please?", "queue");
13434
+ L.current?.injectAgentSpeech?.("I still need your email in the box below to continue — could you enter it, please?", "queue");
13425
13435
  } catch {}
13426
- Ve();
13436
+ Ue();
13427
13437
  } else {
13428
13438
  try {
13429
- F.current?.injectAgentSpeech?.("Since I haven't received your email, I'll close this session for now. Feel free to come back anytime — take care!", "queue");
13439
+ L.current?.injectAgentSpeech?.("Since I haven't received your email, I'll close this session for now. Feel free to come back anytime — take care!", "queue");
13430
13440
  } catch {}
13431
- ae.current = !1, te(!1), V(), Me.current = !0;
13441
+ P.current = !1, te(!1), Ie(), Me.current = !0;
13432
13442
  }
13433
13443
  }, 1e4);
13434
- }, [V]), He = o(async (e) => {
13444
+ }, [Ie]), We = o(async (e) => {
13435
13445
  we.current = !0;
13436
13446
  try {
13437
13447
  On();
13438
13448
  } catch {}
13439
13449
  if (i) try {
13440
- je(i);
13450
+ Ae(i);
13441
13451
  } catch {}
13442
13452
  try {
13443
- await F.current?.endSession?.();
13453
+ await L.current?.endSession?.();
13444
13454
  } catch {}
13445
- let t = Ee.current, n = De.current;
13455
+ let t = Ee.current, n = Oe.current;
13446
13456
  if (t && s && a) {
13447
13457
  let e = n ? Math.round((Date.now() - n) / 1e3) : 0;
13448
13458
  fetch(`${a}/api/voice/save-chat-recording`, {
@@ -13456,8 +13466,8 @@ function __({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13456
13466
  })
13457
13467
  }).catch((e) => console.warn("[FlowEngage] save-chat-recording failed:", e.message));
13458
13468
  }
13459
- if (Ee.current = null, De.current = null, F.current = null, E("idle"), O(!1), I.current = !1, Or(), i) try {
13460
- Se(i);
13469
+ if (Ee.current = null, Oe.current = null, L.current = null, E("idle"), O(!1), ve.current = !1, Or(), i) try {
13470
+ be(i);
13461
13471
  } catch {}
13462
13472
  typeof u == "function" && await u(l.current), e?.();
13463
13473
  }, [
@@ -13467,10 +13477,10 @@ function __({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13467
13477
  s,
13468
13478
  a
13469
13479
  ]);
13470
- ye.current = () => He(Te.current === "chat" ? t : n), c(() => {
13471
- be.current = D;
13480
+ R.current = () => We(Te.current === "chat" ? t : n), c(() => {
13481
+ xe.current = D;
13472
13482
  }, [D]), c(() => {
13473
- d && B("chat");
13483
+ d && V("chat");
13474
13484
  }, [d]), c(() => {
13475
13485
  let e = !1, o = null, c = null, d = null;
13476
13486
  return (async () => {
@@ -13480,13 +13490,13 @@ function __({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13480
13490
  }
13481
13491
  try {
13482
13492
  if ((await navigator.mediaDevices.getUserMedia({ audio: !0 })).getTracks().forEach((e) => e.stop()), e) return;
13483
- l.current = [], ve.current = "", I.current = !1, R.current = !1, we.current = !1, Te.current = "minimized", Dr({ onBeforeNavigate: () => {
13493
+ l.current = [], _e.current = "", ve.current = !1, Ce.current = !1, we.current = !1, Te.current = "minimized", Dr({ onBeforeNavigate: () => {
13484
13494
  if (i && l.current.length > 0) try {
13485
- let e = hg(l.current);
13486
- e && L(i, e);
13495
+ let e = bg(l.current);
13496
+ e && z(i, e);
13487
13497
  } catch {}
13488
13498
  if (!qn()) {
13489
- let e = Ee.current, t = De.current;
13499
+ let e = Ee.current, t = Oe.current;
13490
13500
  if (e && s && a) try {
13491
13501
  let n = t ? Math.round((Date.now() - t) / 1e3) : 0, r = JSON.stringify({
13492
13502
  chatId: s,
@@ -13499,30 +13509,30 @@ function __({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13499
13509
  headers: { "Content-Type": "application/json" },
13500
13510
  body: r,
13501
13511
  keepalive: !0
13502
- }).catch(() => {}), Ee.current = null, De.current = null;
13512
+ }).catch(() => {}), Ee.current = null, Oe.current = null;
13503
13513
  } catch {}
13504
13514
  }
13505
- Ce();
13515
+ Se();
13506
13516
  } });
13507
- let t = i_(t_({
13517
+ let t = l_(o_({
13508
13518
  siteId: i || null,
13509
13519
  apiBaseUrl: a || null,
13510
13520
  chatId: s || null,
13511
- getLastUserVoiceText: () => ve.current,
13512
- isWalkthroughActive: () => le.current && !ue.current,
13521
+ getLastUserVoiceText: () => _e.current,
13522
+ isWalkthroughActive: () => se.current && !ce.current,
13513
13523
  requestEndSession: () => {
13514
13524
  Me.current = !0;
13515
13525
  },
13516
13526
  requestEmailCollection: () => {
13517
- b && (ie.current || ae.current || (ae.current = !0, oe.current = 0, te(!0), Ve()));
13527
+ b && (re.current || P.current || (P.current = !0, F.current = 0, te(!0), Ue()));
13518
13528
  }
13519
- })), n = i ? xe(i) : null, r = !!n?.transcript, u = i ? je(i) : null, p = !!u, m = typeof window < "u" ? window.location.pathname : "/", g = typeof document < "u" ? document.title : "", _ = m.replace(/^\/[a-z]{2}(?:-[a-z]{2})?(?=\/|$)/i, "") || "/", v = _ === "/" || _ === "", x = {
13529
+ })), n = i ? ye(i) : null, r = !!n?.transcript, u = i ? Ae(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 = {
13520
13530
  apiBaseUrl: a,
13521
13531
  siteId: i,
13522
13532
  chatId: s,
13523
13533
  clientTools: t
13524
13534
  };
13525
- _e.current = t;
13535
+ ge.current = t;
13526
13536
  let S = (m.split("/").filter(Boolean).pop() || "").replace(/[-_]/g, " ").replace(/\b\w/g, (e) => e.toUpperCase()), C = "";
13527
13537
  g && g.includes("|") && (C = g.split("|").map((e) => e.trim()).filter(Boolean).reduce((e, t) => e.length <= t.length ? e : t));
13528
13538
  let w = C || S || "", T = w ? `the ${w} page` : "this page", D = (() => {
@@ -13549,145 +13559,145 @@ function __({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13549
13559
  let e = f || "";
13550
13560
  x.greeting = h || (v ? e ? `Hi, welcome to ${e}! How may I help you?` : "Hi, welcome! How may I help you?" : `Welcome to ${T}! How may I help you?`), v || console.log(`[FlowEngage] 🏠 Page-context greeting: "${w}" for ${m}`);
13551
13561
  }
13552
- let A = !1, ee = p ? `NAVIGATION COMPLETE — The exact phrase "I have navigated you to the [page] page. Do you want to know about any specific section or want a complete overview?" has already been spoken as your firstMessage. DO NOT repeat it. PRIOR CONVERSATION CONTEXT:\n${n?.transcript ? `Prior transcript:\n${n.transcript}\n` : "(no prior transcript)"}\nNow STOP — wait silently for the visitor's reply. Do NOT speak, do NOT call any tool until the visitor responds. When they reply: if they name a specific section → call fwh-get-current-page-mvp then answer immediately; if they say "overview" or anything non-specific → call fwh-get-current-page-mvp (zero speech) then do a full highlighted walkthrough.` : null, ne = !1, j = !p && !r ? "Your greeting has been spoken. Wait for the visitor to ask a question or tell you what they need. Do NOT auto-start a walkthrough or highlight any sections — let the visitor lead." : null, M = r && !p, re = !1, N = M ? `The question "Would you like me to continue what I was explaining before, or would you like to know about this page instead?" has already been spoken as your firstMessage. DO NOT repeat it. PRIOR CONVERSATION CONTEXT:\n${n?.transcript ? `Prior transcript:\n${n.transcript}\n` : "(no prior transcript, or the visitor navigated before saying much)"}\nNow STOP — wait silently for the visitor's reply. Do NOT speak, do NOT call any tool until they respond. When they reply: if they want you to CONTINUE the previous topic → resume verbally from the prior transcript above, do NOT call fwh-get-current-page-mvp or describe the new page unless they ask. If they want to know about THIS page → call fwh-get-current-page-mvp (zero speech) then proceed as a normal fresh-page walkthrough/description. If their reply is ambiguous, ask them to clarify which they'd prefer rather than guessing.` : null, ye = !1, Se = !1, ke = b && !!y && !de.current, He = await vh.startSession({
13562
+ let A = !1, ee = p ? `NAVIGATION COMPLETE — The exact phrase "I have navigated you to the [page] page. Do you want to know about any specific section or want a complete overview?" has already been spoken as your firstMessage. DO NOT repeat it. PRIOR CONVERSATION CONTEXT:\n${n?.transcript ? `Prior transcript:\n${n.transcript}\n` : "(no prior transcript)"}\nNow STOP — wait silently for the visitor's reply. Do NOT speak, do NOT call any tool until the visitor responds. When they reply: if they name a specific section → call fwh-get-current-page-mvp then answer immediately; if they say "overview" or anything non-specific → call fwh-get-current-page-mvp (zero speech) then do a full highlighted walkthrough.` : null, j = !1, M = !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, N = r && !p, ne = !1, ie = N ? `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, R = !1, be = !1, ke = b && !!y && !le.current, We = await Ch.startSession({
13553
13563
  ...x,
13554
13564
  onConnect: ({ conversationId: e }) => {
13555
- Ee.current = e, De.current = Date.now(), console.log("[FlowEngage] 🎙️ AI chat session connected:", e);
13565
+ Ee.current = e, Oe.current = Date.now(), console.log("[FlowEngage] 🎙️ AI chat session connected:", e);
13556
13566
  },
13557
13567
  onUnhandledClientToolCall: (e) => console.error("[FlowEngage] Unhandled tool:", e?.tool_name),
13558
13568
  onSessionInfo: ({ emailOnFile: e }) => {
13559
- de.current = !!e, e && (ie.current = !0, ae.current = !1, te(!1), V(), console.log("[FlowEngage] email already on file per server — gate disabled"));
13569
+ le.current = !!e, e && (re.current = !0, P.current = !1, te(!1), Ie(), console.log("[FlowEngage] email already on file per server — gate disabled"));
13560
13570
  },
13561
13571
  onAgentTurnEnd: () => {
13562
- e || le.current && (ue.current || P.current || setTimeout(() => me.current?.(), 250));
13572
+ e || se.current && (ce.current || I.current || setTimeout(() => pe.current?.(), 250));
13563
13573
  },
13564
13574
  onSessionEnding: () => {
13565
- e || B("minimized");
13575
+ e || V("minimized");
13566
13576
  },
13567
13577
  onModeChange: ({ mode: t, tentative: n }) => {
13568
13578
  if (!e) {
13569
13579
  if (t === "speaking") {
13570
- Ne.current &&= (clearTimeout(Ne.current), null), Fe.current &&= (clearTimeout(Fe.current), null), E("speaking"), z.current = "speaking", Pe.current = !1;
13580
+ Pe.current &&= (clearTimeout(Pe.current), null), B.current &&= (clearTimeout(B.current), null), E("speaking"), Ne.current = "speaking", Fe.current = !1;
13571
13581
  return;
13572
13582
  }
13573
13583
  if (t === "user-speaking") {
13574
- if (ae.current && !ie.current && Ve(), Fe.current &&= (clearTimeout(Fe.current), null), z.current === "speaking") return;
13584
+ if (P.current && !re.current && Ue(), B.current &&= (clearTimeout(B.current), null), Ne.current === "speaking") return;
13575
13585
  try {
13576
13586
  On();
13577
13587
  } catch {}
13578
- Ne.current &&= (clearTimeout(Ne.current), null), z.current !== "listening" && (E("listening"), z.current = "listening");
13588
+ Pe.current &&= (clearTimeout(Pe.current), null), Ne.current !== "listening" && (E("listening"), Ne.current = "listening");
13579
13589
  return;
13580
13590
  }
13581
13591
  if (t === "thinking") {
13582
- if (Ne.current &&= (clearTimeout(Ne.current), null), Fe.current &&= (clearTimeout(Fe.current), null), z.current === "speaking") return;
13583
- E("thinking"), z.current = "thinking", n && (Fe.current = setTimeout(() => {
13584
- Fe.current = null, !(e || z.current !== "thinking") && (z.current = "listening", E("listening"));
13592
+ if (Pe.current &&= (clearTimeout(Pe.current), null), B.current &&= (clearTimeout(B.current), null), Ne.current === "speaking") return;
13593
+ E("thinking"), Ne.current = "thinking", n && (B.current = setTimeout(() => {
13594
+ B.current = null, !(e || Ne.current !== "thinking") && (Ne.current = "listening", E("listening"));
13585
13595
  }, 4e3));
13586
13596
  return;
13587
13597
  }
13588
- if (z.current = "listening", Me.current) {
13589
- Me.current = !1, B();
13598
+ if (Ne.current = "listening", Me.current) {
13599
+ Me.current = !1, V();
13590
13600
  return;
13591
13601
  }
13592
- if (ke && !Se && !ie.current && !de.current) {
13593
- Se = !0, A = !0, ne = !0;
13602
+ if (ke && !be && !re.current && !le.current) {
13603
+ be = !0, A = !0, j = !0;
13594
13604
  try {
13595
- F.current?.sendContextualUpdate?.("CRITICAL — EMAIL REQUIRED BEFORE ANYTHING ELSE. The visitor has not provided their email. The app itself speaks the email request out loud — you must NOT say it, and you must NOT answer. Stay completely silent from now until you receive an EMAIL_SAVED message: produce no speech and call no tools, no matter what the visitor says. Remember their question. On EMAIL_SAVED, thank them briefly and answer that remembered question in full.");
13605
+ L.current?.sendContextualUpdate?.("CRITICAL — EMAIL REQUIRED BEFORE ANYTHING ELSE. The visitor has not provided their email. The app itself speaks the email request out loud — you must NOT say it, and you must NOT answer. Stay completely silent from now until you receive an EMAIL_SAVED message: produce no speech and call no tools, no matter what the visitor says. Remember their question. On EMAIL_SAVED, thank them briefly and answer that remembered question in full.");
13596
13606
  } catch {}
13597
13607
  }
13598
13608
  if (ee && !A) {
13599
13609
  A = !0;
13600
13610
  try {
13601
- F.current?.sendContextualUpdate?.(ee);
13611
+ L.current?.sendContextualUpdate?.(ee);
13602
13612
  } catch {}
13603
13613
  }
13604
- if (N && !re) {
13605
- re = !0;
13614
+ if (ie && !ne) {
13615
+ ne = !0;
13606
13616
  try {
13607
- F.current?.sendContextualUpdate?.(N);
13617
+ L.current?.sendContextualUpdate?.(ie);
13608
13618
  } catch {}
13609
13619
  }
13610
- if (j && !ne) {
13611
- ne = !0;
13620
+ if (M && !j) {
13621
+ j = !0;
13612
13622
  try {
13613
- F.current?.sendContextualUpdate?.(j);
13623
+ L.current?.sendContextualUpdate?.(M);
13614
13624
  } catch {}
13615
13625
  }
13616
- Ne.current && clearTimeout(Ne.current), Ne.current = setTimeout(() => {
13617
- e || z.current !== "speaking" && (Pe.current || (Ne.current = null, z.current = "listening", E("listening")));
13626
+ Pe.current && clearTimeout(Pe.current), Pe.current = setTimeout(() => {
13627
+ e || Ne.current !== "speaking" && (Fe.current || (Pe.current = null, Ne.current = "listening", E("listening")));
13618
13628
  }, 1200);
13619
13629
  }
13620
13630
  },
13621
13631
  onMessage: (t) => {
13622
- if (e || P.current && t.role !== "user" && !/email/i.test(String(t.message || ""))) return;
13632
+ if (e || I.current && t.role !== "user" && !/email/i.test(String(t.message || ""))) return;
13623
13633
  let n = t.role === "user" && /^(Describe the section titled "|\[SYSTEM:|Give the visitor a complete spoken overview|That was the last section)/.test(String(t.message || "").trim()), r = /\b(?:this|that|the)\s+(?:case\s*stud(?:y|ies)|product|article|blog|post|item|service)\b/i.test(String(t.message || ""));
13624
- if (!n && !r && t.role === "user" && Ie.test(String(t.message || ""))) typeof window < "u" && (window.__fe_user_nav_during_speech = null), he(!0), ue.current = !1, ce.current = 0, ge.current = -1, fe.current = r_(), pe.current = typeof window < "u" ? window.location.pathname : null, setTimeout(() => me.current?.(), 400), console.log(`[FlowEngage] walkthrough armed — ${fe.current.length} sections on this page`);
13625
- else if (!n && t.role === "user" && le.current) {
13626
- let e = String(t.message || "").trim(), n = Be(e), r = (e) => !!e && (Re.test(e) || ze.test(e));
13627
- !n || r(e) || r(n) ? ue.current && (ue.current = !1, console.debug("[FlowEngage] walkthrough resumed by visitor"), setTimeout(() => me.current?.(), 300)) : (console.log("[FlowEngage] walkthrough ended — visitor moved to a new topic"), pe.current = null, fe.current = [], he(!1));
13634
+ if (!n && !r && t.role === "user" && Le.test(String(t.message || ""))) typeof window < "u" && (window.__fe_user_nav_during_speech = null), me(!0), ce.current = !1, oe.current = 0, he.current = -1, ue.current = c_(), de.current = typeof window < "u" ? window.location.pathname : null, setTimeout(() => pe.current?.(), 400), console.log(`[FlowEngage] walkthrough armed — ${ue.current.length} sections on this page`);
13635
+ else if (!n && t.role === "user" && se.current) {
13636
+ let e = String(t.message || "").trim(), n = He(e), r = (e) => !!e && (ze.test(e) || Ve.test(e));
13637
+ Be.test(fe.current || "") ? (console.log("[FlowEngage] walkthrough ended — visitor accepted a navigation offer"), de.current = null, ue.current = [], me(!1)) : !n || r(e) || r(n) ? ce.current && (ce.current = !1, console.debug("[FlowEngage] walkthrough resumed by visitor"), setTimeout(() => pe.current?.(), 300)) : (console.log("[FlowEngage] walkthrough ended — visitor moved to a new topic"), de.current = null, ue.current = [], me(!1));
13628
13638
  }
13629
- if (t.role !== "user" && Le.test(String(t.message || ""))) {
13630
- let e = fe.current.length;
13631
- !e || ge.current >= e - 1 ? he(!1) : console.debug(`[FlowEngage] agent claimed completion at step ${ge.current + 1}/${e} — ignoring, tour continues`);
13639
+ if (t.role !== "user" && !n && (fe.current = String(t.message || "")), t.role !== "user" && Re.test(String(t.message || ""))) {
13640
+ let e = ue.current.length;
13641
+ !e || he.current >= e - 1 ? me(!1) : console.debug(`[FlowEngage] agent claimed completion at step ${he.current + 1}/${e} — ignoring, tour continues`);
13632
13642
  }
13633
13643
  let a = t.role === "user" ? "user" : "bot", o = t.message || t.text || t.content || "";
13634
13644
  if (o) {
13635
- if (a === "user" && (ve.current = o, typeof window < "u" && (window.__fe_user_nav_during_speech = null), Pe.current = !0, Ne.current &&= (clearTimeout(Ne.current), null), z.current !== "speaking" && (E("thinking"), z.current = "thinking"), ke && !ye && !ie.current && !de.current && (ye = !0, se.current = o, P.current = !0, F.current?.injectAgentSpeech?.("Before I answer that, could you please enter your email in the text box below?", "interrupt"), F.current?.setMicMuted?.(!0), ae.current || (ae.current = !0, oe.current = 0, te(!0), Ve()))), l.current = [...l.current, {
13645
+ if (a === "user" && (_e.current = o, typeof window < "u" && (window.__fe_user_nav_during_speech = null), Fe.current = !0, Pe.current &&= (clearTimeout(Pe.current), null), Ne.current !== "speaking" && (E("thinking"), Ne.current = "thinking"), ke && !R && !re.current && !le.current && (R = !0, ae.current = o, I.current = !0, L.current?.injectAgentSpeech?.("Before I answer that, could you please enter your email in the text box below?", "interrupt"), L.current?.setMicMuted?.(!0), P.current || (P.current = !0, F.current = 0, te(!0), Ue()))), l.current = [...l.current, {
13636
13646
  sender: a,
13637
13647
  message: o,
13638
13648
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
13639
13649
  debug: t.debug
13640
13650
  }], i) try {
13641
- let e = hg(l.current);
13642
- e && L(i, e);
13651
+ let e = bg(l.current);
13652
+ e && z(i, e);
13643
13653
  } catch {}
13644
- if (p_(a, o)) {
13654
+ if (v_(a, o)) {
13645
13655
  Me.current = !0;
13646
13656
  return;
13647
13657
  }
13648
- if (be.current && a === "bot" && /are you still there|still there\??|hello\?|anyone there|checking in|you there|are you available|is anyone|did you step away/i.test(o)) if (Ae.current += 1, Ae.current === 2) try {
13649
- F.current?.sendContextualUpdate?.("IMPORTANT: The visitor is muted and has not responded to your last 2 checks. Make exactly ONE more check. If there is still no response, say: 'I feel like you are not active, so I'm ending this session. You can connect with me anytime.' then immediately call the fwh-end-session-mvp tool to end the voice session. Do NOT ask again after that.");
13658
+ if (xe.current && a === "bot" && /are you still there|still there\??|hello\?|anyone there|checking in|you there|are you available|is anyone|did you step away/i.test(o)) if (je.current += 1, je.current === 2) try {
13659
+ L.current?.sendContextualUpdate?.("IMPORTANT: The visitor is muted and has not responded to your last 2 checks. Make exactly ONE more check. If there is still no response, say: 'I feel like you are not active, so I'm ending this session. You can connect with me anytime.' then immediately call the fwh-end-session-mvp tool to end the voice session. Do NOT ask again after that.");
13650
13660
  } catch {}
13651
- else Ae.current >= 5 && B("minimized");
13661
+ else je.current >= 5 && V("minimized");
13652
13662
  }
13653
13663
  },
13654
13664
  onError: (t) => {
13655
- if (!e && !we.current && !R.current && !Oe()) {
13656
- R.current = !0, console.error("[FlowEngageVoiceCall] session:error", {
13665
+ if (!e && !we.current && !Ce.current && !De()) {
13666
+ Ce.current = !0, console.error("[FlowEngageVoiceCall] session:error", {
13657
13667
  message: t?.message,
13658
13668
  name: t?.name,
13659
13669
  raw: t
13660
13670
  });
13661
13671
  try {
13662
- F.current?.setMicMuted?.(!0);
13672
+ L.current?.setMicMuted?.(!0);
13663
13673
  } catch {}
13664
- O(!0), E("error"), B("chat");
13674
+ O(!0), E("error"), V("chat");
13665
13675
  }
13666
13676
  },
13667
13677
  onDisconnect: (t) => {
13668
- if (e || we.current || R.current || Oe()) return;
13678
+ if (e || we.current || Ce.current || De()) return;
13669
13679
  let n = l.current?.length || 0;
13670
13680
  console.warn("[FlowEngageVoiceCall] session:disconnected", {
13671
13681
  historyCount: n,
13672
13682
  reason: t?.reason,
13673
13683
  closeCode: t?.context?.code,
13674
13684
  closeReason: t?.context?.reason || t?.message,
13675
- lastUserText: ve.current || "",
13676
- wasMuted: be.current
13677
- }), R.current = !0;
13685
+ lastUserText: _e.current || "",
13686
+ wasMuted: xe.current
13687
+ }), Ce.current = !0;
13678
13688
  try {
13679
- F.current?.setMicMuted?.(!0);
13689
+ L.current?.setMicMuted?.(!0);
13680
13690
  } catch {}
13681
- O(!0), B("chat");
13691
+ O(!0), V("chat");
13682
13692
  }
13683
13693
  });
13684
13694
  if (e) {
13685
- console.warn("[FlowEngage:VoiceDebug] ❌ cancelled=true after startSession resolved — killing session immediately"), He.endSession().catch(() => {});
13695
+ console.warn("[FlowEngage:VoiceDebug] ❌ cancelled=true after startSession resolved — killing session immediately"), We.endSession().catch(() => {});
13686
13696
  return;
13687
13697
  }
13688
- o = He, F.current = He, E("listening");
13698
+ o = We, L.current = We, E("listening");
13689
13699
  try {
13690
- sessionStorage.setItem(`el_conv_${i}`, He.getId());
13700
+ sessionStorage.setItem(`el_conv_${i}`, We.getId());
13691
13701
  } catch {}
13692
13702
  parent.postMessage({ type: "AGENT_EXPAND" }, "*");
13693
13703
  try {
@@ -13701,7 +13711,7 @@ function __({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13701
13711
  n.length || (n = Array.from(document.body.querySelectorAll("h1, h2, h3")).filter((t) => !t.closest(e)).map((e) => e.textContent.replace(/\s+/g, " ").trim()).filter((e) => e.length > 2 && e.length < 200)), n.length && (o = [...new Set(n)].slice(0, 15).join(" | "));
13702
13712
  } catch {}
13703
13713
  let s = r && !p ? `RESUMING PRIOR SESSION — DO NOT GREET. The visitor is continuing the same conversation after a page reload. Do not introduce yourself or re-state your capabilities. Wait silently until the visitor speaks; if you must speak first, briefly acknowledge where you left off in one short sentence.\nPrior transcript:\n${n?.transcript || ""}\n\n` : "";
13704
- He.sendContextualUpdate(`${s}SiteId: ${i || "unknown"}. ${y ? "" : "Visitor's email is already on file from a prior session — do NOT ask for it again. "}WALKTHROUGH RULE: When the visitor asks for a walkthrough or overview of this page, you MUST IMMEDIATELY call fwh-get-current-page-mvp (zero speech — call it silently with NO words before it) to get the exact highlightable headings. Do NOT skip fwh-get-current-page-mvp. Voice: call end_voice_session or say you are ending the session to stop.`), He.sendContextualUpdate(o_(e, o, a));
13714
+ We.sendContextualUpdate(`${s}SiteId: ${i || "unknown"}. ${y ? "" : "Visitor's email is already on file from a prior session — do NOT ask for it again. "}WALKTHROUGH RULE: When the visitor asks for a walkthrough or overview of this page, you MUST IMMEDIATELY call fwh-get-current-page-mvp (zero speech — call it silently with NO words before it) to get the exact highlightable headings. Do NOT skip fwh-get-current-page-mvp. Voice: call end_voice_session or say you are ending the session to stop.`), We.sendContextualUpdate(d_(e, o, a));
13705
13715
  } catch {}
13706
13716
  if (typeof window < "u") {
13707
13717
  let t = window.location.pathname, n = Date.now(), r = (e) => {
@@ -13734,10 +13744,10 @@ function __({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13734
13744
  if (o) {
13735
13745
  typeof window < "u" && (window.__fe_agent_nav = null), console.log(`[FlowEngage] agent-driven navigation settled: "${s}" → "${i}"`);
13736
13746
  try {
13737
- F.current?.sendUserMessage?.(`[SYSTEM: YOU just navigated the visitor to the "${m}" page (${c}) at their request — this was YOUR action, not theirs. Page title: "${l}". Sections: ${JSON.stringify(u)}. Say: "Here we are on the ${m} page." Then introduce this page in 2-3 sentences, and finish by asking: "Would you like me to walk you through it section by section?" NEVER say "I see you've navigated" — the visitor did not navigate, you did. Do NOT call fwh-navigate-mvp again. Wait for their answer before describing sections.]`, { suppressQuestion: !0 });
13747
+ L.current?.sendUserMessage?.(`[SYSTEM: YOU just navigated the visitor to the "${m}" page (${c}) at their request — this was YOUR action, not theirs. Page title: "${l}". Sections: ${JSON.stringify(u)}. Say: "Here we are on the ${m} page." Then introduce this page in 2-3 sentences, and finish by asking: "Would you like me to walk you through it section by section?" NEVER say "I see you've navigated" — the visitor did not navigate, you did. Do NOT call fwh-navigate-mvp again. Wait for their answer before describing sections.]`, { suppressQuestion: !0 });
13738
13748
  } catch {}
13739
13749
  try {
13740
- F.current?.sendContextualUpdate?.(o_(c, d));
13750
+ L.current?.sendContextualUpdate?.(d_(c, d));
13741
13751
  } catch {}
13742
13752
  return;
13743
13753
  }
@@ -13749,10 +13759,10 @@ function __({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13749
13759
  ts: Date.now()
13750
13760
  }), console.log(`[FlowEngage] visitor navigation detected: "${s}" → "${i}" (agent target: ${k || "none"})`);
13751
13761
  try {
13752
- F.current?.sendUserMessage?.(`[SYSTEM: I navigated away mid-walkthrough — I am now on the "${m}" page (${c}). Page title: "${l}". Sections: ${JSON.stringify(u)}. STOP everything. Do NOT describe the new page. Say EXACTLY: "I see you've navigated to the ${m} page — would you like me to continue what I was explaining, or shall I walk you through this page?" Then wait for my answer. IF I say continue/yes/carry on: resume speaking verbally from where you left off — do NOT call fwh-navigate-mvp, do NOT call fwh-highlight-mvp, the visitor will navigate themselves if needed. IF I want to hear about this page: call fwh-highlight-mvp for sections of "${m}" only.]`);
13762
+ L.current?.sendUserMessage?.(`[SYSTEM: I navigated away mid-walkthrough — I am now on the "${m}" page (${c}). Page title: "${l}". Sections: ${JSON.stringify(u)}. STOP everything. Do NOT describe the new page. Say EXACTLY: "I see you've navigated to the ${m} page — would you like me to continue what I was explaining, or shall I walk you through this page?" Then wait for my answer. IF I say continue/yes/carry on: resume speaking verbally from where you left off — do NOT call fwh-navigate-mvp, do NOT call fwh-highlight-mvp, the visitor will navigate themselves if needed. IF I want to hear about this page: call fwh-highlight-mvp for sections of "${m}" only.]`);
13753
13763
  } catch {}
13754
13764
  try {
13755
- F.current?.sendContextualUpdate?.(o_(c, d));
13765
+ L.current?.sendContextualUpdate?.(d_(c, d));
13756
13766
  } catch {}
13757
13767
  };
13758
13768
  c = window.history.pushState.bind(window.history), window.history.pushState = (...e) => {
@@ -13774,10 +13784,10 @@ function __({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13774
13784
  On();
13775
13785
  } catch {}
13776
13786
  if (i) try {
13777
- je(i);
13787
+ Ae(i);
13778
13788
  } catch {}
13779
- typeof window < "u" && (window.__fe_user_nav_during_speech = null), Or(), Ne.current &&= (clearTimeout(Ne.current), null), Fe.current &&= (clearTimeout(Fe.current), null), N.current &&= (clearTimeout(N.current), null), Pe.current = !1, z.current = "idle", c && typeof window < "u" && (window.history.pushState = c), d && typeof window < "u" && window.removeEventListener("popstate", d);
13780
- let t = o || F.current, n = Ee.current, f = De.current;
13789
+ typeof window < "u" && (window.__fe_user_nav_during_speech = null), Or(), Pe.current &&= (clearTimeout(Pe.current), null), B.current &&= (clearTimeout(B.current), null), ie.current &&= (clearTimeout(ie.current), null), Fe.current = !1, Ne.current = "idle", c && typeof window < "u" && (window.history.pushState = c), d && typeof window < "u" && window.removeEventListener("popstate", d);
13790
+ let t = o || L.current, n = Ee.current, f = Oe.current;
13781
13791
  if (t?.endSession?.().catch(() => {}), n && s && a) {
13782
13792
  let e = f ? Math.round((Date.now() - f) / 1e3) : 0, t = JSON.stringify({
13783
13793
  chatId: s,
@@ -13790,7 +13800,7 @@ function __({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13790
13800
  headers: { "Content-Type": "application/json" },
13791
13801
  body: t,
13792
13802
  keepalive: !0
13793
- }).catch(() => {}), Ee.current = null, De.current = null;
13803
+ }).catch(() => {}), Ee.current = null, Oe.current = null;
13794
13804
  }
13795
13805
  typeof u == "function" && l.current.length > 0 && u(l.current).catch?.(() => {});
13796
13806
  };
@@ -13798,7 +13808,7 @@ function __({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13798
13808
  r,
13799
13809
  i,
13800
13810
  a,
13801
- B
13811
+ V
13802
13812
  ]), c(() => {
13803
13813
  if (!k) return;
13804
13814
  let e = (e) => {
@@ -13807,42 +13817,42 @@ function __({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13807
13817
  };
13808
13818
  return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
13809
13819
  }, [k]);
13810
- let Ue = async () => {
13811
- if (F.current) try {
13820
+ let Ge = async () => {
13821
+ if (L.current) try {
13812
13822
  if (D) {
13813
- Ae.current = 0, await F.current.setMicMuted?.(!1), O(!1);
13823
+ je.current = 0, await L.current.setMicMuted?.(!1), O(!1);
13814
13824
  try {
13815
- F.current.sendContextualUpdate?.("The visitor has unmuted. Resume normal interaction and wait for them to speak.");
13825
+ L.current.sendContextualUpdate?.("The visitor has unmuted. Resume normal interaction and wait for them to speak.");
13816
13826
  } catch {}
13817
13827
  } else {
13818
- Ae.current = 0, await F.current.setMicMuted?.(!0), O(!0);
13828
+ je.current = 0, await L.current.setMicMuted?.(!0), O(!0);
13819
13829
  try {
13820
- F.current.sendContextualUpdate?.("The visitor has muted their microphone. Do NOT speak, ask if they are there, or prompt them in any way. Stay completely silent until they unmute.");
13830
+ L.current.sendContextualUpdate?.("The visitor has muted their microphone. Do NOT speak, ask if they are there, or prompt them in any way. Stay completely silent until they unmute.");
13821
13831
  } catch {}
13822
13832
  }
13823
13833
  } catch {}
13824
- }, We = o(async (e) => {
13834
+ }, Ke = o(async (e) => {
13825
13835
  e?.preventDefault?.();
13826
- let t = ne.trim().toLowerCase();
13836
+ let t = j.trim().toLowerCase();
13827
13837
  if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t)) {
13828
- re("Please enter a valid email address.");
13838
+ ne("Please enter a valid email address.");
13829
13839
  return;
13830
13840
  }
13831
- re(""), ie.current = !0, ae.current = !1, V(), te(!1), j(""), P.current = !1;
13841
+ ne(""), re.current = !0, P.current = !1, Ie(), te(!1), M(""), I.current = !1;
13832
13842
  try {
13833
13843
  typeof v == "function" && await v(t);
13834
13844
  } catch {}
13835
- F.current?.setMicMuted?.(!1);
13836
- let n = se.current;
13837
- se.current = "";
13845
+ L.current?.setMicMuted?.(!1);
13846
+ let n = ae.current;
13847
+ ae.current = "";
13838
13848
  try {
13839
- F.current?.injectAgentSpeech?.("Thank you for submitting your email."), F.current?.sendUserMessage?.(n || "The visitor's email is on file. Carry on helping them and never ask for it again.");
13849
+ L.current?.injectAgentSpeech?.("Thank you for submitting your email."), L.current?.sendUserMessage?.(n || "The visitor's email is on file. Carry on helping them and never ask for it again.");
13840
13850
  } catch {}
13841
13851
  }, [
13842
- ne,
13852
+ j,
13843
13853
  v,
13844
- V
13845
- ]), Ge = Array.isArray(e) && e[0] || "#3B82F6";
13854
+ Ie
13855
+ ]), qe = Array.isArray(e) && e[0] || "#3B82F6";
13846
13856
  return /* @__PURE__ */ _("div", {
13847
13857
  ref: ke,
13848
13858
  style: {
@@ -13855,7 +13865,7 @@ function __({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13855
13865
  },
13856
13866
  children: [
13857
13867
  ee && /* @__PURE__ */ _("form", {
13858
- onSubmit: We,
13868
+ onSubmit: Ke,
13859
13869
  style: {
13860
13870
  width: "270px",
13861
13871
  maxWidth: "calc(100vw - 40px)",
@@ -13886,9 +13896,9 @@ function __({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13886
13896
  inputMode: "email",
13887
13897
  autoComplete: "email",
13888
13898
  autoFocus: !0,
13889
- value: ne,
13899
+ value: j,
13890
13900
  onChange: (e) => {
13891
- j(e.target.value), M && re("");
13901
+ M(e.target.value), N && ne("");
13892
13902
  },
13893
13903
  placeholder: "you@example.com",
13894
13904
  style: {
@@ -13896,33 +13906,33 @@ function __({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13896
13906
  boxSizing: "border-box",
13897
13907
  padding: "10px 12px",
13898
13908
  borderRadius: "10px",
13899
- border: M ? "1.5px solid #ef4444" : "1.5px solid #4b5563",
13909
+ border: N ? "1.5px solid #ef4444" : "1.5px solid #4b5563",
13900
13910
  background: "#1f2937",
13901
13911
  color: "white",
13902
13912
  fontSize: "14px",
13903
13913
  outline: "none"
13904
13914
  }
13905
13915
  }),
13906
- M && /* @__PURE__ */ g("span", {
13916
+ N && /* @__PURE__ */ g("span", {
13907
13917
  style: {
13908
13918
  color: "#f87171",
13909
13919
  fontSize: "12px"
13910
13920
  },
13911
- children: M
13921
+ children: N
13912
13922
  }),
13913
13923
  /* @__PURE__ */ g("button", {
13914
13924
  type: "submit",
13915
- disabled: !ne.trim(),
13925
+ disabled: !j.trim(),
13916
13926
  style: {
13917
13927
  width: "100%",
13918
13928
  padding: "10px 12px",
13919
13929
  borderRadius: "10px",
13920
13930
  border: "none",
13921
- background: ne.trim() ? Ge : "#374151",
13931
+ background: j.trim() ? qe : "#374151",
13922
13932
  color: "white",
13923
13933
  fontSize: "14px",
13924
13934
  fontWeight: 600,
13925
- cursor: ne.trim() ? "pointer" : "default",
13935
+ cursor: j.trim() ? "pointer" : "default",
13926
13936
  transition: "background 0.2s ease"
13927
13937
  },
13928
13938
  children: "Submit"
@@ -13964,7 +13974,7 @@ function __({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13964
13974
  },
13965
13975
  children: "Muted"
13966
13976
  }),
13967
- /* @__PURE__ */ g(m_, {
13977
+ /* @__PURE__ */ g(y_, {
13968
13978
  size: 72,
13969
13979
  voiceState: T,
13970
13980
  isMuted: D,
@@ -13987,7 +13997,7 @@ function __({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13987
13997
  alignItems: "center"
13988
13998
  },
13989
13999
  children: [/* @__PURE__ */ g("button", {
13990
- onClick: Ue,
14000
+ onClick: Ge,
13991
14001
  title: D ? "Unmute" : "Mute",
13992
14002
  style: {
13993
14003
  width: "24px",
@@ -14036,7 +14046,7 @@ function __({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
14036
14046
  y2: "23"
14037
14047
  })
14038
14048
  ]
14039
- }) : /* @__PURE__ */ g(yh, {
14049
+ }) : /* @__PURE__ */ g(wh, {
14040
14050
  size: 16,
14041
14051
  color: "currentColor"
14042
14052
  })
@@ -14058,7 +14068,7 @@ function __({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
14058
14068
  padding: 0,
14059
14069
  flexShrink: 0
14060
14070
  },
14061
- children: /* @__PURE__ */ g(Dh, {
14071
+ children: /* @__PURE__ */ g(Mh, {
14062
14072
  size: 16,
14063
14073
  color: "currentColor"
14064
14074
  })
@@ -14082,7 +14092,7 @@ function __({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
14082
14092
  children: [
14083
14093
  /* @__PURE__ */ _("button", {
14084
14094
  onClick: () => {
14085
- A(!1), Te.current = "chat", He(t);
14095
+ A(!1), Te.current = "chat", We(t);
14086
14096
  },
14087
14097
  style: {
14088
14098
  display: "flex",
@@ -14107,11 +14117,11 @@ function __({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
14107
14117
  onMouseLeave: (e) => {
14108
14118
  e.currentTarget.style.background = "none";
14109
14119
  },
14110
- children: [/* @__PURE__ */ g(Oh, {}), C]
14120
+ children: [/* @__PURE__ */ g(Nh, {}), C]
14111
14121
  }),
14112
14122
  /* @__PURE__ */ _("button", {
14113
14123
  onClick: () => {
14114
- A(!1), Te.current = "minimized", He(n);
14124
+ A(!1), Te.current = "minimized", We(n);
14115
14125
  },
14116
14126
  style: {
14117
14127
  display: "flex",
@@ -14136,7 +14146,7 @@ function __({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
14136
14146
  onMouseLeave: (e) => {
14137
14147
  e.currentTarget.style.background = "none";
14138
14148
  },
14139
- children: [/* @__PURE__ */ g(kh, {}), w]
14149
+ children: [/* @__PURE__ */ g(Ph, {}), w]
14140
14150
  }),
14141
14151
  /* @__PURE__ */ g("button", {
14142
14152
  onClick: () => A(!1),
@@ -14188,7 +14198,7 @@ function __({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
14188
14198
  ]
14189
14199
  });
14190
14200
  }
14191
- function v_({ orbColors: e }) {
14201
+ function C_({ orbColors: e }) {
14192
14202
  let t = Array.isArray(e) && e.length > 0 ? e : [
14193
14203
  "#135bd8",
14194
14204
  "#ef334b",
@@ -14207,7 +14217,7 @@ function v_({ orbColors: e }) {
14207
14217
  `.replace(/\s+/g, " ").trim()
14208
14218
  } });
14209
14219
  }
14210
- var y_ = () => /* @__PURE__ */ g("div", {
14220
+ var w_ = () => /* @__PURE__ */ g("div", {
14211
14221
  style: {
14212
14222
  display: "flex",
14213
14223
  marginBottom: "12px",
@@ -14237,8 +14247,8 @@ var y_ = () => /* @__PURE__ */ g("div", {
14237
14247
  } }, e))
14238
14248
  })
14239
14249
  });
14240
- function b_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i, quickChatOptions: a, onQuickChatSelect: o, isMobile: s, chatHistory: l, isAiTyping: u, isAgentTyping: d, activeScreen: f, agentName: v, agentHeadshot: y, fallbackAgentName: b, input: x, setInput: S, onSubmit: C, isConversationEnded: w, isLoading: T, isRateLimited: E, rateLimitMessage: D, selectedFile: O, onFileSelect: k, onRemoveSelectedFile: A, attachmentError: ee, isUploadingAttachment: te, requiresEmail: ne, emailInput: j, setEmailInput: M, emailError: re, emailCaptureSuccess: ie, replyContext: ae, setReplyContext: N, webRTCError: oe, micError: se, setMicError: P, dismissCallError: ce, activeCallId: le, isCallMuted: ue, toggleCallMute: de, endWebRTCCall: fe, formatCallDuration: pe, callDurationSeconds: me, isCallMinimized: he, onExpand: ge, onCollapse: F, onStartVoice: _e, voiceEnabled: ve, headerBgColor: ye, onNewChat: I, showPoweredBy: be, privacyPolicyUrl: L, getVisitorChatHistory: xe, resumeChat: Se, isSessionRestoring: R, isClosing: Ce }) {
14241
- let we = l.length > 0, Te = T || E || w, Ee = !!le, [De, Oe] = m(!1), [ke, Ae] = m(!1), [je, Me] = m([]), [z, Ne] = m(!1), Pe = p(null), [Fe, B] = m(() => typeof window < "u" ? window.visualViewport?.height ?? window.innerHeight : 600), [V, Ie] = m(0);
14250
+ function T_({ 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: j, emailInput: M, setEmailInput: N, emailError: ne, emailCaptureSuccess: re, replyContext: P, setReplyContext: ie, webRTCError: F, micError: ae, setMicError: I, dismissCallError: oe, activeCallId: se, isCallMuted: ce, toggleCallMute: le, endWebRTCCall: ue, formatCallDuration: de, callDurationSeconds: fe, isCallMinimized: pe, onExpand: me, onCollapse: he, onStartVoice: L, voiceEnabled: ge, headerBgColor: _e, onNewChat: R, showPoweredBy: ve, privacyPolicyUrl: z, getVisitorChatHistory: ye, resumeChat: be, isSessionRestoring: xe, isClosing: Se }) {
14251
+ let Ce = l.length > 0, we = T || E || w, Te = !!se, [Ee, De] = m(!1), [Oe, ke] = m(!1), [Ae, je] = m([]), [Me, Ne] = m(!1), Pe = p(null), [Fe, B] = m(() => typeof window < "u" ? window.visualViewport?.height ?? window.innerHeight : 600), [V, Ie] = m(0);
14242
14252
  c(() => {
14243
14253
  if (!s) return;
14244
14254
  let e = window.visualViewport;
@@ -14251,26 +14261,26 @@ function b_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
14251
14261
  };
14252
14262
  }, [s]);
14253
14263
  let Le = s && window.innerHeight - Fe > 150, Re = async () => {
14254
- Oe(!1), Ae(!0), Ne(!0);
14264
+ De(!1), ke(!0), Ne(!0);
14255
14265
  try {
14256
- let e = await xe();
14257
- e?.data && Me(e.data);
14266
+ let e = await ye();
14267
+ e?.data && je(e.data);
14258
14268
  } catch (e) {
14259
14269
  console.error(e);
14260
14270
  } finally {
14261
14271
  Ne(!1);
14262
14272
  }
14263
14273
  }, ze = async (e) => {
14264
- Ae(!1), Se?.(e.chatId);
14274
+ ke(!1), be?.(e.chatId);
14265
14275
  };
14266
14276
  return c(() => {
14267
- if (!De) return;
14277
+ if (!Ee) return;
14268
14278
  let e = (e) => {
14269
14279
  let t = e.composedPath?.()?.[0] || e.target;
14270
- Pe.current && !Pe.current.contains(t) && Oe(!1);
14280
+ Pe.current && !Pe.current.contains(t) && De(!1);
14271
14281
  };
14272
14282
  return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
14273
- }, [De]), /* @__PURE__ */ _("div", {
14283
+ }, [Ee]), /* @__PURE__ */ _("div", {
14274
14284
  style: s ? {
14275
14285
  "--flowengage-primary": n,
14276
14286
  "--flowengage-accent": n,
@@ -14284,7 +14294,7 @@ function b_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
14284
14294
  display: "flex",
14285
14295
  flexDirection: "column",
14286
14296
  overflow: "hidden",
14287
- animation: Ce ? "fe-orb-slide-down 0.28s cubic-bezier(0.16,1,0.3,1) forwards" : "fe-orb-slide-up 0.28s cubic-bezier(0.16,1,0.3,1)"
14297
+ animation: Se ? "fe-orb-slide-down 0.28s cubic-bezier(0.16,1,0.3,1) forwards" : "fe-orb-slide-up 0.28s cubic-bezier(0.16,1,0.3,1)"
14288
14298
  } : {
14289
14299
  "--flowengage-primary": n,
14290
14300
  "--flowengage-accent": n,
@@ -14297,7 +14307,7 @@ function b_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
14297
14307
  flexDirection: "column",
14298
14308
  overflow: "hidden",
14299
14309
  position: "relative",
14300
- animation: Ce ? "fe-orb-slide-down 0.28s cubic-bezier(0.16,1,0.3,1) forwards" : "fe-orb-slide-up 0.36s cubic-bezier(0.16,1,0.3,1)"
14310
+ animation: Se ? "fe-orb-slide-down 0.28s cubic-bezier(0.16,1,0.3,1) forwards" : "fe-orb-slide-up 0.36s cubic-bezier(0.16,1,0.3,1)"
14301
14311
  },
14302
14312
  children: [
14303
14313
  /* @__PURE__ */ _("div", {
@@ -14307,7 +14317,7 @@ function b_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
14307
14317
  alignItems: "center",
14308
14318
  columnGap: "14px",
14309
14319
  padding: "16px 10px 14px",
14310
- background: ye || "transparent",
14320
+ background: _e || "transparent",
14311
14321
  flexShrink: 0,
14312
14322
  position: "relative",
14313
14323
  zIndex: 30
@@ -14320,7 +14330,7 @@ function b_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
14320
14330
  alignItems: "center"
14321
14331
  },
14322
14332
  children: /* @__PURE__ */ g("button", {
14323
- onClick: F,
14333
+ onClick: he,
14324
14334
  style: {
14325
14335
  width: "40px",
14326
14336
  height: "40px",
@@ -14377,7 +14387,7 @@ function b_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
14377
14387
  justifyContent: "center",
14378
14388
  height: "40px"
14379
14389
  },
14380
- children: i ? /* @__PURE__ */ g(d_, {
14390
+ children: i ? /* @__PURE__ */ g(g_, {
14381
14391
  logo: i,
14382
14392
  style: {
14383
14393
  height: "34px",
@@ -14390,7 +14400,7 @@ function b_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
14390
14400
  height: "40px",
14391
14401
  flexShrink: 0
14392
14402
  },
14393
- children: /* @__PURE__ */ g(f_, { title: e.chatTitle })
14403
+ children: /* @__PURE__ */ g(__, { title: e.chatTitle })
14394
14404
  })
14395
14405
  }), o && /* @__PURE__ */ g("div", {
14396
14406
  style: {
@@ -14425,7 +14435,7 @@ function b_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
14425
14435
  ref: Pe,
14426
14436
  children: [/* @__PURE__ */ g("button", {
14427
14437
  type: "button",
14428
- onClick: () => Oe((e) => !e),
14438
+ onClick: () => De((e) => !e),
14429
14439
  style: {
14430
14440
  width: "40px",
14431
14441
  height: "40px",
@@ -14471,7 +14481,7 @@ function b_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
14471
14481
  })
14472
14482
  ]
14473
14483
  })
14474
- }), De && /* @__PURE__ */ _("div", {
14484
+ }), Ee && /* @__PURE__ */ _("div", {
14475
14485
  style: {
14476
14486
  position: "absolute",
14477
14487
  top: "34px",
@@ -14487,10 +14497,10 @@ function b_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
14487
14497
  animation: "fe-orb-fade-in 0.18s ease"
14488
14498
  },
14489
14499
  children: [
14490
- ve && /* @__PURE__ */ _(h, { children: [/* @__PURE__ */ _("button", {
14500
+ ge && /* @__PURE__ */ _(h, { children: [/* @__PURE__ */ _("button", {
14491
14501
  type: "button",
14492
14502
  onClick: () => {
14493
- Oe(!1), _e?.();
14503
+ De(!1), L?.();
14494
14504
  },
14495
14505
  style: {
14496
14506
  display: "flex",
@@ -14532,7 +14542,7 @@ function b_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
14532
14542
  /* @__PURE__ */ _("button", {
14533
14543
  type: "button",
14534
14544
  onClick: () => {
14535
- Oe(!1), I?.();
14545
+ De(!1), R?.();
14536
14546
  },
14537
14547
  style: {
14538
14548
  display: "flex",
@@ -14567,7 +14577,7 @@ function b_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
14567
14577
  children: [/* @__PURE__ */ g("path", { d: "M12 5H5a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-7" }), /* @__PURE__ */ g("path", { d: "M18.5 2.5a2.121 2.121 0 013 3L12 15l-4 1 1-4 9.5-9.5z" })]
14568
14578
  }), "Start new chat"]
14569
14579
  }),
14570
- xe && /* @__PURE__ */ _(h, { children: [/* @__PURE__ */ g("div", { style: {
14580
+ ye && /* @__PURE__ */ _(h, { children: [/* @__PURE__ */ g("div", { style: {
14571
14581
  height: "1px",
14572
14582
  background: "rgba(255,255,255,0.07)",
14573
14583
  margin: "0 14px"
@@ -14615,7 +14625,7 @@ function b_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
14615
14625
  /* @__PURE__ */ _("button", {
14616
14626
  type: "button",
14617
14627
  onClick: () => {
14618
- Oe(!1), F?.();
14628
+ De(!1), he?.();
14619
14629
  },
14620
14630
  style: {
14621
14631
  display: "flex",
@@ -14673,24 +14683,24 @@ function b_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
14673
14683
  })
14674
14684
  ]
14675
14685
  }),
14676
- /* @__PURE__ */ g(Zh, {
14677
- webRTCError: oe,
14678
- micError: se,
14679
- setMicError: P,
14680
- dismissCallError: ce,
14686
+ /* @__PURE__ */ g(ng, {
14687
+ webRTCError: F,
14688
+ micError: ae,
14689
+ setMicError: I,
14690
+ dismissCallError: oe,
14681
14691
  isRateLimited: E,
14682
14692
  rateLimitMessage: D
14683
14693
  }),
14684
- he && /* @__PURE__ */ g(mg, {
14694
+ pe && /* @__PURE__ */ g(yg, {
14685
14695
  agentName: v,
14686
14696
  agentHeadshot: y,
14687
14697
  fallbackAgentName: b,
14688
- callDurationSeconds: me,
14689
- isCallMuted: ue,
14690
- formatCallDuration: pe,
14691
- toggleCallMute: de,
14692
- endWebRTCCall: fe,
14693
- onExpand: ge,
14698
+ callDurationSeconds: fe,
14699
+ isCallMuted: ce,
14700
+ formatCallDuration: de,
14701
+ toggleCallMute: le,
14702
+ endWebRTCCall: ue,
14703
+ onExpand: me,
14694
14704
  primaryColor: n
14695
14705
  }),
14696
14706
  /* @__PURE__ */ _("div", {
@@ -14702,7 +14712,7 @@ function b_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
14702
14712
  background: "transparent",
14703
14713
  position: "relative"
14704
14714
  },
14705
- children: [ke ? /* @__PURE__ */ _("div", {
14715
+ children: [Oe ? /* @__PURE__ */ _("div", {
14706
14716
  style: {
14707
14717
  position: "absolute",
14708
14718
  inset: 0,
@@ -14721,7 +14731,7 @@ function b_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
14721
14731
  flexShrink: 0
14722
14732
  },
14723
14733
  children: /* @__PURE__ */ _("button", {
14724
- onClick: () => Ae(!1),
14734
+ onClick: () => ke(!1),
14725
14735
  style: {
14726
14736
  background: "none",
14727
14737
  border: "none",
@@ -14755,7 +14765,7 @@ function b_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
14755
14765
  overflowY: "auto",
14756
14766
  position: "relative"
14757
14767
  },
14758
- children: z ? /* @__PURE__ */ g("div", {
14768
+ children: Me ? /* @__PURE__ */ g("div", {
14759
14769
  style: {
14760
14770
  padding: "40px 20px",
14761
14771
  textAlign: "center",
@@ -14763,7 +14773,7 @@ function b_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
14763
14773
  fontSize: "14px"
14764
14774
  },
14765
14775
  children: "Loading past conversations..."
14766
- }) : je.length > 0 ? /* @__PURE__ */ g("div", { children: je.map((e) => /* @__PURE__ */ _("div", {
14776
+ }) : Ae.length > 0 ? /* @__PURE__ */ g("div", { children: Ae.map((e) => /* @__PURE__ */ _("div", {
14767
14777
  onClick: () => ze(e),
14768
14778
  style: {
14769
14779
  padding: "16px 20px",
@@ -14815,18 +14825,18 @@ function b_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
14815
14825
  children: "No previous chats found."
14816
14826
  })
14817
14827
  })]
14818
- }) : null, we ? /* @__PURE__ */ g(Jh, {
14828
+ }) : null, Ce ? /* @__PURE__ */ g($h, {
14819
14829
  chatHistory: l,
14820
14830
  isAiTyping: u,
14821
14831
  isLoading: T,
14822
14832
  isAgentTyping: d,
14823
- setReplyContext: N,
14824
- TypingDots: y_,
14833
+ setReplyContext: ie,
14834
+ TypingDots: w_,
14825
14835
  primaryColor: n,
14826
14836
  agentHeadshot: y,
14827
14837
  agentDisplayName: v || b,
14828
- botAvatarNode: /* @__PURE__ */ g(v_, { orbColors: t })
14829
- }) : R ? /* @__PURE__ */ _("div", {
14838
+ botAvatarNode: /* @__PURE__ */ g(C_, { orbColors: t })
14839
+ }) : xe ? /* @__PURE__ */ _("div", {
14830
14840
  style: {
14831
14841
  flex: 1,
14832
14842
  display: "flex",
@@ -14866,7 +14876,7 @@ function b_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
14866
14876
  padding: "28px 24px"
14867
14877
  },
14868
14878
  children: [
14869
- /* @__PURE__ */ g(m_, {
14879
+ /* @__PURE__ */ g(y_, {
14870
14880
  size: 94,
14871
14881
  orbColors: t
14872
14882
  }),
@@ -14916,7 +14926,7 @@ function b_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
14916
14926
  ]
14917
14927
  })]
14918
14928
  }),
14919
- ie && /* @__PURE__ */ _("div", {
14929
+ re && /* @__PURE__ */ _("div", {
14920
14930
  style: {
14921
14931
  margin: "0 16px 8px",
14922
14932
  padding: "9px 14px",
@@ -14955,29 +14965,29 @@ function b_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
14955
14965
  flexShrink: 0,
14956
14966
  position: "relative",
14957
14967
  zIndex: 1,
14958
- padding: ne ? "6px 0 0" : "12px 0 0"
14968
+ padding: j ? "6px 0 0" : "12px 0 0"
14959
14969
  },
14960
- children: /* @__PURE__ */ g(Xh, {
14970
+ children: /* @__PURE__ */ g(tg, {
14961
14971
  input: x,
14962
14972
  setInput: S,
14963
14973
  onSubmit: C,
14964
14974
  isConversationEnded: w,
14965
- callUiActive: Ee,
14966
- handleToggleVoice: _e,
14975
+ callUiActive: Te,
14976
+ handleToggleVoice: L,
14967
14977
  showVoiceToggle: f === "agent",
14968
14978
  activeScreen: f,
14969
- inputDisabled: Te,
14970
- replyContext: ae,
14971
- clearReplyContext: () => N(null),
14979
+ inputDisabled: we,
14980
+ replyContext: P,
14981
+ clearReplyContext: () => ie(null),
14972
14982
  onFileSelect: k,
14973
14983
  selectedFile: O,
14974
14984
  onRemoveSelectedFile: A,
14975
14985
  attachmentError: ee,
14976
14986
  isUploadingAttachment: te,
14977
- requiresEmail: ne,
14978
- emailInput: j,
14979
- setEmailInput: M,
14980
- emailError: re,
14987
+ requiresEmail: j,
14988
+ emailInput: M,
14989
+ setEmailInput: N,
14990
+ emailError: ne,
14981
14991
  inputPlaceholder: e.inputPlaceholder
14982
14992
  })
14983
14993
  }),
@@ -14989,7 +14999,7 @@ function b_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
14989
14999
  paddingBottom: "max(12px, env(safe-area-inset-bottom, 12px))",
14990
15000
  pointerEvents: "none"
14991
15001
  },
14992
- children: [L && /* @__PURE__ */ _("p", {
15002
+ children: [z && /* @__PURE__ */ _("p", {
14993
15003
  style: {
14994
15004
  margin: "0 0 4px",
14995
15005
  fontSize: "10px",
@@ -15002,7 +15012,7 @@ function b_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
15002
15012
  "This conversation is recorded for quality assurance purposes.",
15003
15013
  " ",
15004
15014
  /* @__PURE__ */ g("a", {
15005
- href: L,
15015
+ href: z,
15006
15016
  target: "_blank",
15007
15017
  rel: "noopener noreferrer",
15008
15018
  style: {
@@ -15012,7 +15022,7 @@ function b_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
15012
15022
  children: "See our privacy policy"
15013
15023
  })
15014
15024
  ]
15015
- }), be && /* @__PURE__ */ _("span", {
15025
+ }), ve && /* @__PURE__ */ _("span", {
15016
15026
  style: {
15017
15027
  fontSize: "11px",
15018
15028
  color: "#9ca3af",
@@ -15031,34 +15041,34 @@ function b_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
15031
15041
  ]
15032
15042
  });
15033
15043
  }
15034
- function x_() {
15035
- let { status: e, runtimeConfig: t, resolvedConfig: n, chatHistory: r, isOpen: i, activeScreen: a, isHumanHandled: s, agentName: l, agentHeadshot: u, visitorEmail: h, isAgentTyping: v, isAiTyping: y, isLoading: b, isRateLimited: x, rateLimitMessage: S, isConversationEnded: C, incomingCall: w, activeCallId: T, callConnectionState: E, callConnectedAt: D, isCallMuted: O, webRTCError: k, language: A, chatId: ee, historyRef: te, onMessageSync: ne, sendMessage: j, uploadChatFile: M, openWidget: re, captureVisitorEmail: ie, setVoiceMode: ae, endConversation: N, startNewChat: P, acceptCall: ce, rejectCall: le, endWebRTCCall: ue, toggleCallMute: de, dismissCallError: fe, startTyping: pe, stopTyping: me, updateTypingDraft: he, getVisitorChatHistory: ge, resumeChat: F, isSessionRestoring: _e, openToChatCounter: ve, voiceEndCounter: ye } = Cn();
15044
+ function E_() {
15045
+ 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: j, sendMessage: M, uploadChatFile: N, openWidget: ne, captureVisitorEmail: re, setVoiceMode: P, endConversation: ie, startNewChat: I, acceptCall: oe, rejectCall: se, endWebRTCCall: ce, toggleCallMute: le, dismissCallError: ue, startTyping: de, stopTyping: fe, updateTypingDraft: pe, getVisitorChatHistory: me, resumeChat: he, isSessionRestoring: L, openToChatCounter: ge, voiceEndCounter: _e } = Cn();
15036
15046
  c(() => {
15037
15047
  try {
15038
15048
  or();
15039
15049
  } catch {}
15040
15050
  }, []), c(() => {
15041
- ve && W !== "voice_mode" && W !== "text_chat" && W !== "call_screen" && (ae?.(!1), $e("text_chat"));
15042
- }, [ve]);
15043
- let I = t?.widgetSettings || {}, be = n?.widgetSettings || {}, L = {
15044
- ...I.branding || {},
15045
- ...be.branding || {}
15046
- }, R = {
15047
- ...I.theme || {},
15048
- ...be.theme || {}
15049
- }, Ce = {
15050
- ...I.features || {},
15051
- ...be.features || {}
15052
- }, Te = Ce.voice !== !1, Ee = Array.isArray(R.orbColors) && R.orbColors.length > 0 ? R.orbColors : null, Oe = R.buttonColor || R.primaryColor || Ee?.[0] || "#3B82F6", ke = {
15051
+ ge && W !== "voice_mode" && W !== "text_chat" && W !== "call_screen" && (P?.(!1), $e("text_chat"));
15052
+ }, [ge]);
15053
+ let R = t?.widgetSettings || {}, ve = n?.widgetSettings || {}, z = {
15054
+ ...R.branding || {},
15055
+ ...ve.branding || {}
15056
+ }, xe = {
15057
+ ...R.theme || {},
15058
+ ...ve.theme || {}
15059
+ }, Se = {
15060
+ ...R.features || {},
15061
+ ...ve.features || {}
15062
+ }, we = Se.voice !== !1, Te = Array.isArray(xe.orbColors) && xe.orbColors.length > 0 ? xe.orbColors : null, De = xe.buttonColor || xe.primaryColor || Te?.[0] || "#3B82F6", Oe = {
15053
15063
  small: 50,
15054
15064
  medium: 64,
15055
15065
  large: 80
15056
- }, Ae = ke[R.orbSize] || ke.small, je = R.position || "bottom-right", Me = L.fallbackAgentName || "Agent", z = c_(Ee ?? R.chatBgColors), Ne = L.logo || L.logoUrl || null, Pe = A || "en", Fe = I.recommendations?.[Pe] || [], B = (be.recommendations?.[Pe] ?? Fe).filter((e) => String(e?.label ?? "").trim()).map((e, t) => ({
15066
+ }, ke = Oe[xe.orbSize] || Oe.small, Ae = xe.position || "bottom-right", je = z.fallbackAgentName || "Agent", Me = p_(Te ?? xe.chatBgColors), Ne = z.logo || z.logoUrl || null, Pe = A || "en", Fe = R.recommendations?.[Pe] || [], B = (ve.recommendations?.[Pe] ?? Fe).filter((e) => String(e?.label ?? "").trim()).map((e, t) => ({
15057
15067
  id: e.key || `qr-${t}`,
15058
15068
  label: e.label,
15059
15069
  message: e.label,
15060
15070
  text: e.label
15061
- })), V = Array.isArray(L.quickChatOptions) && L.quickChatOptions.length > 0 ? L.quickChatOptions : B, Ie = L.hideWatermark === !0 ? !1 : L.showPoweredBy !== !1, Le = L.headerBgColor || null, Re = R.bottomPosition == null ? "1.5rem" : `${R.bottomPosition}px`, ze = L.privacyPolicyUrl || null, Be = L.chatbotEnabled !== !1 && R.chatbotEnabled !== !1, [Ve, He] = m(() => typeof window < "u" ? window.location.pathname : "/");
15071
+ })), V = Array.isArray(z.quickChatOptions) && z.quickChatOptions.length > 0 ? z.quickChatOptions : B, Ie = z.hideWatermark === !0 ? !1 : z.showPoweredBy !== !1, Le = z.headerBgColor || null, Re = xe.bottomPosition == null ? "1.5rem" : `${xe.bottomPosition}px`, ze = z.privacyPolicyUrl || null, Be = z.chatbotEnabled !== !1 && xe.chatbotEnabled !== !1, [Ve, He] = m(() => typeof window < "u" ? window.location.pathname : "/");
15062
15072
  c(() => {
15063
15073
  if (typeof window > "u") return;
15064
15074
  let e = () => He(window.location.pathname), t = window.history.pushState.bind(window.history);
@@ -15070,24 +15080,24 @@ function x_() {
15070
15080
  }, []);
15071
15081
  let Ue = (() => {
15072
15082
  let e = {
15073
- ...I.pageVisibility || {},
15074
- ...be.pageVisibility || {}
15083
+ ...R.pageVisibility || {},
15084
+ ...ve.pageVisibility || {}
15075
15085
  };
15076
15086
  return Array.isArray(e.allowedPaths) ? e.allowedPaths.filter(Boolean) : [];
15077
- })(), We = Ue.length === 0 || Ue.some((e) => e === "*" || e === "/*" ? !0 : e.endsWith("/*") ? Ve.startsWith(e.slice(0, -1)) : Ve.replace(/\/$/, "") === e.replace(/\/$/, "")), Ge = I.greetings?.[A] || be.greetings?.[A] || L.introGreeting || "Hello, I'm here to help you know more about OpenSense Labs.", Ke = {
15078
- entryPrompt: L.entryPrompt || "Do you want to explore in a new way?",
15079
- yesLabel: L.yesLabel || "Yes",
15080
- laterLabel: L.laterLabel || "Later",
15081
- connectionTitle: L.connectionTitle || "How would you like to connect?",
15082
- connectionSubtitle: L.connectionSubtitle || "",
15083
- voiceLabel: L.voiceLabel || "Voice",
15084
- textLabel: L.textLabel || "Text",
15085
- chatTitle: L.headerName || "Chat with FlowEngage",
15086
- hasCustomTitle: !!(L.headerName && String(L.headerName).trim()),
15087
+ })(), We = Ue.length === 0 || Ue.some((e) => e === "*" || e === "/*" ? !0 : e.endsWith("/*") ? Ve.startsWith(e.slice(0, -1)) : Ve.replace(/\/$/, "") === e.replace(/\/$/, "")), Ge = R.greetings?.[A] || ve.greetings?.[A] || z.introGreeting || "Hello, I'm here to help you know more about OpenSense Labs.", Ke = {
15088
+ entryPrompt: z.entryPrompt || "Do you want to explore in a new way?",
15089
+ yesLabel: z.yesLabel || "Yes",
15090
+ laterLabel: z.laterLabel || "Later",
15091
+ connectionTitle: z.connectionTitle || "How would you like to connect?",
15092
+ connectionSubtitle: z.connectionSubtitle || "",
15093
+ voiceLabel: z.voiceLabel || "Voice",
15094
+ textLabel: z.textLabel || "Text",
15095
+ chatTitle: z.headerName || "Chat with FlowEngage",
15096
+ hasCustomTitle: !!(z.headerName && String(z.headerName).trim()),
15087
15097
  introGreeting: Ge,
15088
- inputPlaceholder: L.inputPlaceholder || "Type your message",
15089
- analysingLabel: L.analysingLabel || "analysing..."
15090
- }, qe = be.elevenLabsAgentId || t?.elevenLabsAgentId || null, Je = t?.siteId || n?.siteId || null, H = t?.apiBaseUrl || "";
15098
+ inputPlaceholder: z.inputPlaceholder || "Type your message",
15099
+ analysingLabel: z.analysingLabel || "analysing..."
15100
+ }, qe = ve.elevenLabsAgentId || t?.elevenLabsAgentId || null, Je = t?.siteId || n?.siteId || null, H = t?.apiBaseUrl || "";
15091
15101
  c(() => {
15092
15102
  Kn(t?.siteType || null);
15093
15103
  }, [t?.siteType]);
@@ -15098,10 +15108,10 @@ function x_() {
15098
15108
  ]), Ye = u && String(u).trim() || t?.ownerProfileImageUrl && String(t.ownerProfileImageUrl).trim() || null, Xe = r.some((e) => e.sender === "user"), Ze = f(() => {
15099
15109
  let e = r.findIndex((e) => e.sender === "user");
15100
15110
  return e === -1 ? !1 : r.slice(e + 1).some((e) => e.sender === "bot" || e.sender === "ai" || e.sender === "agent");
15101
- }, [r]), Qe = !!(be._dashboardLivePreview || I._dashboardLivePreview), [W, $e] = m(() => Qe ? "text_chat" : "entry_prompt"), [et, tt] = m(""), [nt, G] = m(null), [rt, it] = m(h || ""), [at, ot] = m(""), [st, ct] = m(!1), [lt, ut] = m(0), [dt, ft] = m(null), [pt, mt] = m(null), [ht, gt] = m(""), [_t, vt] = m(!1), [yt, bt] = m(!1), [xt, St] = m(!1), Ct = p(null), wt = p(!1), Tt = !h && Xe && Ze && W !== "voice_mode";
15111
+ }, [r]), Qe = !!(ve._dashboardLivePreview || R._dashboardLivePreview), [W, $e] = m(() => Qe ? "text_chat" : "entry_prompt"), [et, tt] = m(""), [nt, G] = m(null), [rt, it] = m(h || ""), [at, ot] = m(""), [st, ct] = m(!1), [lt, ut] = m(0), [dt, ft] = m(null), [pt, mt] = m(null), [ht, gt] = m(""), [_t, vt] = m(!1), [yt, bt] = m(!1), [xt, St] = m(!1), Ct = p(null), wt = p(!1), Tt = !h && Xe && Ze && W !== "voice_mode";
15102
15112
  d(() => {
15103
15113
  if (e !== "ready" || wt.current) return;
15104
- if (wt.current = !0, !Te) {
15114
+ if (wt.current = !0, !we) {
15105
15115
  $e("minimized_orb");
15106
15116
  return;
15107
15117
  }
@@ -15109,13 +15119,13 @@ function x_() {
15109
15119
  try {
15110
15120
  t = vr().shouldResumeVoice;
15111
15121
  } catch {}
15112
- let n = we(), r = Je ? xe(Je) : null, i = n || !!r?.transcript;
15122
+ let n = Ce(), r = Je ? ye(Je) : null, i = n || !!r?.transcript;
15113
15123
  if (t) {
15114
- re?.({ notifyChatInitiated: !0 }), ae?.(!0), $e("voice_mode");
15124
+ ne?.({ notifyChatInitiated: !0 }), P?.(!0), $e("voice_mode");
15115
15125
  return;
15116
15126
  }
15117
- if (De()) {
15118
- re?.({ notifyChatInitiated: !1 }), $e("text_chat");
15127
+ if (Ee()) {
15128
+ ne?.({ notifyChatInitiated: !1 }), $e("text_chat");
15119
15129
  return;
15120
15130
  }
15121
15131
  if (i) {
@@ -15123,13 +15133,13 @@ function x_() {
15123
15133
  $e("minimized_orb");
15124
15134
  return;
15125
15135
  }
15126
- re?.({ notifyChatInitiated: !0 }), ae?.(!0), $e("voice_mode");
15136
+ ne?.({ notifyChatInitiated: !0 }), P?.(!0), $e("voice_mode");
15127
15137
  return;
15128
15138
  }
15129
15139
  if (Je) try {
15130
- Se(Je);
15140
+ be(Je);
15131
15141
  } catch {}
15132
- if (oe(Je)) {
15142
+ if (F(Je)) {
15133
15143
  $e("minimized_orb");
15134
15144
  return;
15135
15145
  }
@@ -15144,7 +15154,7 @@ function x_() {
15144
15154
  let Ot = o(() => {
15145
15155
  mt(null), gt("");
15146
15156
  }, []), kt = o((e) => {
15147
- let t = Uh(e);
15157
+ let t = Jh(e);
15148
15158
  if (t) {
15149
15159
  mt(null), gt(t);
15150
15160
  return;
@@ -15187,7 +15197,7 @@ function x_() {
15187
15197
  hasIncomingCall: !!w?.callId,
15188
15198
  activeCallId: T,
15189
15199
  callConnectionState: E
15190
- }), Ct.current = e, W === "voice_mode" && ae?.(!1), re?.(), At());
15200
+ }), Ct.current = e, W === "voice_mode" && P?.(!1), ne?.(), At());
15191
15201
  }
15192
15202
  }, [
15193
15203
  T,
@@ -15195,8 +15205,8 @@ function x_() {
15195
15205
  At,
15196
15206
  w?.callId,
15197
15207
  i,
15198
- re,
15199
- ae,
15208
+ ne,
15209
+ P,
15200
15210
  W
15201
15211
  ]), c(() => {
15202
15212
  !w && !T && W === "call_screen" && $e("text_chat");
@@ -15208,16 +15218,16 @@ function x_() {
15208
15218
  !T && yt && bt(!1);
15209
15219
  }, [T, yt]), c(() => {
15210
15220
  if (!s || C) {
15211
- he?.(""), me?.();
15221
+ pe?.(""), fe?.();
15212
15222
  return;
15213
15223
  }
15214
15224
  if (!et.trim() || pt) {
15215
- he?.("");
15216
- let e = window.setTimeout(() => me?.(), 100);
15225
+ pe?.("");
15226
+ let e = window.setTimeout(() => fe?.(), 100);
15217
15227
  return () => window.clearTimeout(e);
15218
15228
  }
15219
- pe?.();
15220
- let e = window.setTimeout(() => he?.(et), 120), t = window.setTimeout(() => me?.(), 1200);
15229
+ de?.();
15230
+ let e = window.setTimeout(() => pe?.(et), 120), t = window.setTimeout(() => fe?.(), 1200);
15221
15231
  return () => {
15222
15232
  window.clearTimeout(e), window.clearTimeout(t);
15223
15233
  };
@@ -15226,9 +15236,9 @@ function x_() {
15226
15236
  pt,
15227
15237
  s,
15228
15238
  C,
15229
- pe,
15230
- me,
15231
- he
15239
+ de,
15240
+ fe,
15241
+ pe
15232
15242
  ]);
15233
15243
  let Mt = (e) => e ? {
15234
15244
  replyTo: e.messageId || e.id || null,
@@ -15242,7 +15252,7 @@ function x_() {
15242
15252
  ot("Please enter a valid email so we can continue helping you.");
15243
15253
  return;
15244
15254
  }
15245
- await ie(e), ot(""), ct(!0), setTimeout(() => ct(!1), 3e3);
15255
+ await re(e), ot(""), ct(!0), setTimeout(() => ct(!1), 3e3);
15246
15256
  return;
15247
15257
  }
15248
15258
  let t = Mt(nt);
@@ -15250,8 +15260,8 @@ function x_() {
15250
15260
  if (pt) {
15251
15261
  try {
15252
15262
  vt(!0), gt("");
15253
- let e = await M(pt), n = e?.data || e, r = et.trim() || `Shared file: ${Gh(pt)}`;
15254
- tt(""), G(null), Ot(), await j(r, "", t, {
15263
+ let e = await N(pt), n = e?.data || e, r = et.trim() || `Shared file: ${Xh(pt)}`;
15264
+ tt(""), G(null), Ot(), await M(r, "", t, {
15255
15265
  type: "file",
15256
15266
  metadata: {
15257
15267
  fileUrl: n?.fileUrl,
@@ -15268,20 +15278,20 @@ function x_() {
15268
15278
  return;
15269
15279
  }
15270
15280
  let n = et.trim();
15271
- tt(""), G(null), await j(n, "", t);
15281
+ tt(""), G(null), await M(n, "", t);
15272
15282
  }, Pt = o(() => {
15273
- r.length !== 0 && P?.();
15274
- }, [r.length, P]), Ft = (e) => {
15283
+ r.length !== 0 && I?.();
15284
+ }, [r.length, I]), Ft = (e) => {
15275
15285
  let t = Math.floor(e / 60);
15276
15286
  return `${String(t).padStart(2, "0")}:${String(e % 60).padStart(2, "0")}`;
15277
15287
  }, It = o(async (e) => {
15278
15288
  if (C || b) return;
15279
15289
  let t = e.message || e.label || e.text || "";
15280
- t.trim() && await j(t.trim(), "");
15290
+ t.trim() && await M(t.trim(), "");
15281
15291
  }, [
15282
15292
  C,
15283
15293
  b,
15284
- j
15294
+ M
15285
15295
  ]), Lt = Et && W === "entry_prompt" ? { inset: 0 } : Et && W === "text_chat" ? {
15286
15296
  left: 0,
15287
15297
  right: 0,
@@ -15302,14 +15312,14 @@ function x_() {
15302
15312
  height: "min(640px, calc(100vh - 120px))",
15303
15313
  borderRadius: "22px",
15304
15314
  overflow: "hidden",
15305
- ...je === "bottom-left" ? {
15315
+ ...Ae === "bottom-left" ? {
15306
15316
  left: "1.5rem",
15307
15317
  bottom: Re
15308
15318
  } : {
15309
15319
  right: "1.5rem",
15310
15320
  bottom: Re
15311
15321
  }
15312
- } : je === "bottom-left" ? {
15322
+ } : Ae === "bottom-left" ? {
15313
15323
  left: "1.5rem",
15314
15324
  bottom: Re
15315
15325
  } : {
@@ -15327,13 +15337,13 @@ function x_() {
15327
15337
  t.resume().catch(() => {}), setTimeout(() => t.close().catch(() => {}), 3e3);
15328
15338
  }
15329
15339
  } catch {}
15330
- re({ notifyChatInitiated: !0 }), ae?.(!0), $e("voice_mode");
15340
+ ne({ notifyChatInitiated: !0 }), P?.(!0), $e("voice_mode");
15331
15341
  }, Vt = () => {
15332
- re({ notifyChatInitiated: !0 }), ae?.(!1), $e("text_chat");
15342
+ ne({ notifyChatInitiated: !0 }), P?.(!1), $e("text_chat");
15333
15343
  }, Ht = () => {
15334
- ae?.(!1), Rt();
15344
+ P?.(!1), Rt();
15335
15345
  };
15336
- return e !== "ready" || !Be || Ce.chat === !1 || !We ? null : /* @__PURE__ */ _("div", {
15346
+ return e !== "ready" || !Be || Se.chat === !1 || !We ? null : /* @__PURE__ */ _("div", {
15337
15347
  className: "flowengage-widget-root",
15338
15348
  style: {
15339
15349
  position: "fixed",
@@ -15343,15 +15353,15 @@ function x_() {
15343
15353
  onWheel: (e) => e.stopPropagation(),
15344
15354
  onTouchMove: (e) => e.stopPropagation(),
15345
15355
  children: [
15346
- W === "entry_prompt" && /* @__PURE__ */ g(h_, {
15356
+ W === "entry_prompt" && /* @__PURE__ */ g(b_, {
15347
15357
  copy: Ke,
15348
- orbColors: Ee,
15349
- primaryColor: Oe,
15358
+ orbColors: Te,
15359
+ primaryColor: De,
15350
15360
  onYes: () => {
15351
- se(Je), Bt();
15361
+ ae(Je), Bt();
15352
15362
  },
15353
15363
  onLater: () => {
15354
- se(Je), Rt();
15364
+ ae(Je), Rt();
15355
15365
  },
15356
15366
  isMobile: Et,
15357
15367
  isClosing: xt
@@ -15375,7 +15385,7 @@ function x_() {
15375
15385
  transformOrigin: "bottom right",
15376
15386
  display: "inline-flex",
15377
15387
  flexDirection: "column",
15378
- alignItems: je === "bottom-left" ? "flex-start" : "flex-end",
15388
+ alignItems: Ae === "bottom-left" ? "flex-start" : "flex-end",
15379
15389
  gap: "10px"
15380
15390
  },
15381
15391
  children: [T && /* @__PURE__ */ _("button", {
@@ -15426,24 +15436,24 @@ function x_() {
15426
15436
  children: E === "connected" ? `${Ft(lt)} with ${U}` : `Tap to return to ${U}`
15427
15437
  })]
15428
15438
  })]
15429
- }), /* @__PURE__ */ g(m_, {
15430
- size: Ae,
15431
- orbColors: Ee,
15432
- onClick: T ? At : Te ? zt : Vt
15439
+ }), /* @__PURE__ */ g(y_, {
15440
+ size: ke,
15441
+ orbColors: Te,
15442
+ onClick: T ? At : we ? zt : Vt
15433
15443
  })]
15434
15444
  }),
15435
- W === "connection_modal" && /* @__PURE__ */ g(g_, {
15445
+ W === "connection_modal" && /* @__PURE__ */ g(x_, {
15436
15446
  copy: Ke,
15437
- orbColors: Ee,
15438
- primaryColor: Oe,
15447
+ orbColors: Te,
15448
+ primaryColor: De,
15439
15449
  onVoice: Bt,
15440
15450
  onText: Vt,
15441
15451
  onClose: Rt,
15442
15452
  isMobile: Et,
15443
15453
  isClosing: xt
15444
15454
  }),
15445
- W === "voice_mode" && /* @__PURE__ */ g(__, {
15446
- orbColors: Ee,
15455
+ W === "voice_mode" && /* @__PURE__ */ g(S_, {
15456
+ orbColors: Te,
15447
15457
  onEnterChat: Vt,
15448
15458
  onEndChat: Ht,
15449
15459
  agentId: qe,
@@ -15451,19 +15461,19 @@ function x_() {
15451
15461
  apiBaseUrl: H,
15452
15462
  chatId: ee,
15453
15463
  historyRef: te,
15454
- onMessageSync: ne,
15455
- voiceEndCounter: ye,
15464
+ onMessageSync: j,
15465
+ voiceEndCounter: _e,
15456
15466
  websiteName: t?.websiteName,
15457
- voiceFirstMessage: I.voiceFirstMessage || null,
15458
- captureVisitorEmail: ie,
15467
+ voiceFirstMessage: R.voiceFirstMessage || null,
15468
+ captureVisitorEmail: re,
15459
15469
  emailRequired: !h,
15460
- emailCaptureEnabled: Ce.emailCapture !== !1 && L.disableEmailCapture !== !0,
15461
- listeningLabel: L.voiceListeningLabel || "Listening...",
15462
- thinkingLabel: L.voiceThinkingLabel || "Thinking...",
15463
- enterChatModeLabel: L.voiceEnterChatLabel || "Enter Chat Mode",
15464
- endConversationLabel: L.voiceEndConversationLabel || "End Conversation"
15470
+ emailCaptureEnabled: Se.emailCapture !== !1 && z.disableEmailCapture !== !0,
15471
+ listeningLabel: z.voiceListeningLabel || "Listening...",
15472
+ thinkingLabel: z.voiceThinkingLabel || "Thinking...",
15473
+ enterChatModeLabel: z.voiceEnterChatLabel || "Enter Chat Mode",
15474
+ endConversationLabel: z.voiceEndConversationLabel || "End Conversation"
15465
15475
  }, "voice"),
15466
- W === "call_screen" && /* @__PURE__ */ g(pg, {
15476
+ W === "call_screen" && /* @__PURE__ */ g(vg, {
15467
15477
  incomingCall: w,
15468
15478
  activeCallId: T,
15469
15479
  callConnectionState: E,
@@ -15471,23 +15481,23 @@ function x_() {
15471
15481
  isCallMuted: O,
15472
15482
  agentName: U,
15473
15483
  agentHeadshot: Ye,
15474
- fallbackAgentName: Me,
15475
- acceptCall: ce,
15476
- rejectCall: le,
15477
- endWebRTCCall: ue,
15478
- toggleCallMute: de,
15484
+ fallbackAgentName: je,
15485
+ acceptCall: oe,
15486
+ rejectCall: se,
15487
+ endWebRTCCall: ce,
15488
+ toggleCallMute: le,
15479
15489
  formatCallDuration: Ft,
15480
15490
  onMinimize: jt,
15481
- primaryColor: Oe,
15482
- orbColors: Ee,
15491
+ primaryColor: De,
15492
+ orbColors: Te,
15483
15493
  chatHistory: r
15484
15494
  }),
15485
- W === "text_chat" && /* @__PURE__ */ g(b_, {
15495
+ W === "text_chat" && /* @__PURE__ */ g(T_, {
15486
15496
  isClosing: xt,
15487
15497
  copy: Ke,
15488
- orbColors: Ee,
15489
- primaryColor: Oe,
15490
- chatBgGradient: z,
15498
+ orbColors: Te,
15499
+ primaryColor: De,
15500
+ chatBgGradient: Me,
15491
15501
  logo: Ne,
15492
15502
  quickChatOptions: V,
15493
15503
  onQuickChatSelect: It,
@@ -15498,7 +15508,7 @@ function x_() {
15498
15508
  activeScreen: a,
15499
15509
  agentName: U,
15500
15510
  agentHeadshot: Ye,
15501
- fallbackAgentName: Me,
15511
+ fallbackAgentName: je,
15502
15512
  input: et,
15503
15513
  setInput: tt,
15504
15514
  onSubmit: Nt,
@@ -15521,16 +15531,16 @@ function x_() {
15521
15531
  webRTCError: k,
15522
15532
  micError: dt,
15523
15533
  setMicError: ft,
15524
- dismissCallError: fe,
15534
+ dismissCallError: ue,
15525
15535
  activeCallId: T,
15526
15536
  isCallMuted: O,
15527
- toggleCallMute: de,
15528
- endWebRTCCall: ue,
15537
+ toggleCallMute: le,
15538
+ endWebRTCCall: ce,
15529
15539
  formatCallDuration: Ft,
15530
15540
  callDurationSeconds: lt,
15531
15541
  onCollapse: Rt,
15532
15542
  onStartVoice: Bt,
15533
- voiceEnabled: Te,
15543
+ voiceEnabled: we,
15534
15544
  onNewChat: Pt,
15535
15545
  onMinimize: jt,
15536
15546
  onExpand: At,
@@ -15538,9 +15548,9 @@ function x_() {
15538
15548
  showPoweredBy: Ie,
15539
15549
  privacyPolicyUrl: ze,
15540
15550
  headerBgColor: Le,
15541
- getVisitorChatHistory: ge,
15542
- resumeChat: F,
15543
- isSessionRestoring: _e
15551
+ getVisitorChatHistory: me,
15552
+ resumeChat: he,
15553
+ isSessionRestoring: L
15544
15554
  }),
15545
15555
  /* @__PURE__ */ g("style", { children: "\n /* Force any SVG (or img) inside LogoSlot to fill the container height\n regardless of whether the component forwards its style prop. */\n .fe-logo-slot svg,\n .fe-logo-slot img { height: 100%; width: auto; display: block; }\n\n @keyframes fe-orb-breathe { 0%,100%{transform:scale(1)} 50%{transform:scale(1.04)} }\n @keyframes fe-orb-breathe-subtle { 0%,100%{transform:scale(1)} 50%{transform:scale(1.025)} }\n @keyframes fe-orb-pulse { 0%{transform:scale(1);opacity:.65} 50%{transform:scale(1.28);opacity:.1} 100%{transform:scale(1);opacity:.65} }\n @keyframes fe-orb-glow { from{opacity:.35} to{opacity:.75} }\n @keyframes fe-orb-fade-in { from{opacity:0} to{opacity:1} }\n @keyframes fe-orb-slide-up { from{opacity:0;transform:translateY(18px)} to{opacity:1;transform:translateY(0)} }\n @keyframes fe-orb-slide-down { from{opacity:1;transform:translateY(0)} to{opacity:0;transform:translateY(24px)} }\n @keyframes fe-orb-bar-0 { from{height:6px} to{height:18px} }\n @keyframes fe-orb-bar-1 { from{height:10px} to{height:22px} }\n @keyframes fe-orb-bar-2 { from{height:14px} to{height:26px} }\n @keyframes fe-orb-bar-3 { from{height:8px} to{height:20px} }\n @keyframes fe-orb-bar-4 { from{height:6px} to{height:16px} }\n @keyframes fe-dot-bounce { 0%,80%,100%{transform:translateY(0);opacity:.5} 40%{transform:translateY(-5px);opacity:1} }\n " })
15546
15556
  ]
@@ -15548,7 +15558,7 @@ function x_() {
15548
15558
  }
15549
15559
  //#endregion
15550
15560
  //#region src/components/ErrorBoundary.jsx
15551
- var S_ = class extends e.Component {
15561
+ var D_ = class extends e.Component {
15552
15562
  constructor(e) {
15553
15563
  super(e), this.state = { hasError: !1 };
15554
15564
  }
@@ -15563,4 +15573,4 @@ var S_ = class extends e.Component {
15563
15573
  }
15564
15574
  };
15565
15575
  //#endregion
15566
- export { og as AnimatedOrb, S_ as ErrorBoundary, pi as FlowEngageProvider, x_ as FlowEngageWidget, Cn as useFlowEngage };
15576
+ export { dg as AnimatedOrb, D_ as ErrorBoundary, pi as FlowEngageProvider, E_ as FlowEngageWidget, Cn as useFlowEngage };