@flowengage/react-chatbot 2.0.1 → 2.0.3

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.
@@ -17,7 +17,7 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
17
17
  }, T = (e) => x.call(e, "module.exports") ? e["module.exports"] : w(v({}, "__esModule", { value: !0 }), e), ee = (e) => {
18
18
  if (!e || typeof e != "object") throw Error("FlowEngage config is required");
19
19
  if (!e.siteId || typeof e.siteId != "string") throw Error("[FlowEngage] config.siteId is required. Pass it as <FlowEngageProvider siteId=\"your-site-id\" /> or config={{ siteId: 'your-site-id' }}.");
20
- let t = (e.apiBaseUrl || "https://be-flowengage.oslabs.app").replace(/\/+$/, "");
20
+ let t = (e.apiBaseUrl || "https://be-flowengage-stage.oslabs.app").replace(/\/+$/, "");
21
21
  return {
22
22
  siteId: e.siteId.trim(),
23
23
  apiBaseUrl: t
@@ -286,6 +286,12 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
286
286
  })
287
287
  });
288
288
  },
289
+ async getVisitorChatHistory() {
290
+ return i("/api/visitors/my-chats", { method: "GET" });
291
+ },
292
+ async getVisitorChatThread(e) {
293
+ return i(`/api/visitors/my-chats/${e}`, { method: "GET" });
294
+ },
289
295
  async acceptCall(e, t) {
290
296
  return i(`/api/calls/${e}/accept`, {
291
297
  method: "POST",
@@ -356,82 +362,82 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
356
362
  return navigator.sendBeacon(`${e}/api/ai/voice/sync`, o);
357
363
  }
358
364
  };
359
- }, Oe = Object.create(null);
360
- Oe.open = "0", Oe.close = "1", Oe.ping = "2", Oe.pong = "3", Oe.message = "4", Oe.upgrade = "5", Oe.noop = "6";
361
- var ke = Object.create(null);
362
- Object.keys(Oe).forEach((e) => {
363
- ke[Oe[e]] = e;
365
+ }, D = Object.create(null);
366
+ D.open = "0", D.close = "1", D.ping = "2", D.pong = "3", D.message = "4", D.upgrade = "5", D.noop = "6";
367
+ var Oe = Object.create(null);
368
+ Object.keys(D).forEach((e) => {
369
+ Oe[D[e]] = e;
364
370
  });
365
- var Ae = {
371
+ var ke = {
366
372
  type: "error",
367
373
  data: "parser error"
368
- }, je = typeof Blob == "function" || typeof Blob < "u" && Object.prototype.toString.call(Blob) === "[object BlobConstructor]", Me = typeof ArrayBuffer == "function", Ne = (e) => typeof ArrayBuffer.isView == "function" ? ArrayBuffer.isView(e) : e && e.buffer instanceof ArrayBuffer, Pe = ({ type: e, data: t }, n, r) => je && t instanceof Blob ? n ? r(t) : Fe(t, r) : Me && (t instanceof ArrayBuffer || Ne(t)) ? n ? r(t) : Fe(new Blob([t]), r) : r(Oe[e] + (t || "")), Fe = (e, t) => {
374
+ }, Ae = typeof Blob == "function" || typeof Blob < "u" && Object.prototype.toString.call(Blob) === "[object BlobConstructor]", je = typeof ArrayBuffer == "function", Me = (e) => typeof ArrayBuffer.isView == "function" ? ArrayBuffer.isView(e) : e && e.buffer instanceof ArrayBuffer, Ne = ({ type: e, data: t }, n, r) => Ae && t instanceof Blob ? n ? r(t) : Pe(t, r) : je && (t instanceof ArrayBuffer || Me(t)) ? n ? r(t) : Pe(new Blob([t]), r) : r(D[e] + (t || "")), Pe = (e, t) => {
369
375
  let n = new FileReader();
370
376
  return n.onload = function() {
371
377
  let e = n.result.split(",")[1];
372
378
  t("b" + (e || ""));
373
379
  }, n.readAsDataURL(e);
374
380
  };
375
- function Ie(e) {
381
+ function Fe(e) {
376
382
  return e instanceof Uint8Array ? e : e instanceof ArrayBuffer ? new Uint8Array(e) : new Uint8Array(e.buffer, e.byteOffset, e.byteLength);
377
383
  }
378
- var Le;
379
- function Re(e, t) {
380
- if (je && e.data instanceof Blob) return e.data.arrayBuffer().then(Ie).then(t);
381
- if (Me && (e.data instanceof ArrayBuffer || Ne(e.data))) return t(Ie(e.data));
382
- Pe(e, !1, (e) => {
383
- Le ||= new TextEncoder(), t(Le.encode(e));
384
+ var Ie;
385
+ function Le(e, t) {
386
+ if (Ae && e.data instanceof Blob) return e.data.arrayBuffer().then(Fe).then(t);
387
+ if (je && (e.data instanceof ArrayBuffer || Me(e.data))) return t(Fe(e.data));
388
+ Ne(e, !1, (e) => {
389
+ Ie ||= new TextEncoder(), t(Ie.encode(e));
384
390
  });
385
391
  }
386
392
  //#endregion
387
393
  //#region node_modules/engine.io-parser/build/esm/contrib/base64-arraybuffer.js
388
- var ze = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", Be = typeof Uint8Array > "u" ? [] : new Uint8Array(256);
389
- for (let e = 0; e < 64; e++) Be[ze.charCodeAt(e)] = e;
390
- var D = (e) => {
394
+ var Re = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", ze = typeof Uint8Array > "u" ? [] : new Uint8Array(256);
395
+ for (let e = 0; e < 64; e++) ze[Re.charCodeAt(e)] = e;
396
+ var O = (e) => {
391
397
  let t = e.length * .75, n = e.length, r, i = 0, a, o, s, c;
392
398
  e[e.length - 1] === "=" && (t--, e[e.length - 2] === "=" && t--);
393
399
  let l = new ArrayBuffer(t), u = new Uint8Array(l);
394
- for (r = 0; r < n; r += 4) a = Be[e.charCodeAt(r)], o = Be[e.charCodeAt(r + 1)], s = Be[e.charCodeAt(r + 2)], c = Be[e.charCodeAt(r + 3)], u[i++] = a << 2 | o >> 4, u[i++] = (o & 15) << 4 | s >> 2, u[i++] = (s & 3) << 6 | c & 63;
400
+ for (r = 0; r < n; r += 4) a = ze[e.charCodeAt(r)], o = ze[e.charCodeAt(r + 1)], s = ze[e.charCodeAt(r + 2)], c = ze[e.charCodeAt(r + 3)], u[i++] = a << 2 | o >> 4, u[i++] = (o & 15) << 4 | s >> 2, u[i++] = (s & 3) << 6 | c & 63;
395
401
  return l;
396
- }, Ve = typeof ArrayBuffer == "function", He = (e, t) => {
402
+ }, Be = typeof ArrayBuffer == "function", Ve = (e, t) => {
397
403
  if (typeof e != "string") return {
398
404
  type: "message",
399
- data: We(e, t)
405
+ data: Ue(e, t)
400
406
  };
401
407
  let n = e.charAt(0);
402
408
  return n === "b" ? {
403
409
  type: "message",
404
- data: Ue(e.substring(1), t)
405
- } : ke[n] ? e.length > 1 ? {
406
- type: ke[n],
410
+ data: He(e.substring(1), t)
411
+ } : Oe[n] ? e.length > 1 ? {
412
+ type: Oe[n],
407
413
  data: e.substring(1)
408
- } : { type: ke[n] } : Ae;
409
- }, Ue = (e, t) => Ve ? We(D(e), t) : {
414
+ } : { type: Oe[n] } : ke;
415
+ }, He = (e, t) => Be ? Ue(O(e), t) : {
410
416
  base64: !0,
411
417
  data: e
412
- }, We = (e, t) => {
418
+ }, Ue = (e, t) => {
413
419
  switch (t) {
414
420
  case "blob": return e instanceof Blob ? e : new Blob([e]);
415
421
  default: return e instanceof ArrayBuffer ? e : e.buffer;
416
422
  }
417
- }, Ge = "", Ke = (e, t) => {
423
+ }, We = "", Ge = (e, t) => {
418
424
  let n = e.length, r = Array(n), i = 0;
419
425
  e.forEach((e, a) => {
420
- Pe(e, !1, (e) => {
421
- r[a] = e, ++i === n && t(r.join(Ge));
426
+ Ne(e, !1, (e) => {
427
+ r[a] = e, ++i === n && t(r.join(We));
422
428
  });
423
429
  });
424
- }, qe = (e, t) => {
425
- let n = e.split(Ge), r = [];
430
+ }, Ke = (e, t) => {
431
+ let n = e.split(We), r = [];
426
432
  for (let e = 0; e < n.length; e++) {
427
- let i = He(n[e], t);
433
+ let i = Ve(n[e], t);
428
434
  if (r.push(i), i.type === "error") break;
429
435
  }
430
436
  return r;
431
437
  };
432
- function Je() {
438
+ function qe() {
433
439
  return new TransformStream({ transform(e, t) {
434
- Re(e, (n) => {
440
+ Le(e, (n) => {
435
441
  let r = n.length, i;
436
442
  if (r < 126) i = new Uint8Array(1), new DataView(i.buffer).setUint8(0, r);
437
443
  else if (r < 65536) {
@@ -447,44 +453,44 @@ function Je() {
447
453
  });
448
454
  } });
449
455
  }
450
- var Ye;
451
- function Xe(e) {
456
+ var Je;
457
+ function Ye(e) {
452
458
  return e.reduce((e, t) => e + t.length, 0);
453
459
  }
454
- function O(e, t) {
460
+ function Xe(e, t) {
455
461
  if (e[0].length === t) return e.shift();
456
462
  let n = new Uint8Array(t), r = 0;
457
463
  for (let i = 0; i < t; i++) n[i] = e[0][r++], r === e[0].length && (e.shift(), r = 0);
458
464
  return e.length && r < e[0].length && (e[0] = e[0].slice(r)), n;
459
465
  }
460
466
  function Ze(e, t) {
461
- Ye ||= new TextDecoder();
467
+ Je ||= new TextDecoder();
462
468
  let n = [], r = 0, i = -1, a = !1;
463
469
  return new TransformStream({ transform(o, s) {
464
470
  for (n.push(o);;) {
465
471
  if (r === 0) {
466
- if (Xe(n) < 1) break;
467
- let e = O(n, 1);
472
+ if (Ye(n) < 1) break;
473
+ let e = Xe(n, 1);
468
474
  a = (e[0] & 128) == 128, i = e[0] & 127, r = i < 126 ? 3 : i === 126 ? 1 : 2;
469
475
  } else if (r === 1) {
470
- if (Xe(n) < 2) break;
471
- let e = O(n, 2);
476
+ if (Ye(n) < 2) break;
477
+ let e = Xe(n, 2);
472
478
  i = new DataView(e.buffer, e.byteOffset, e.length).getUint16(0), r = 3;
473
479
  } else if (r === 2) {
474
- if (Xe(n) < 8) break;
475
- let e = O(n, 8), t = new DataView(e.buffer, e.byteOffset, e.length), a = t.getUint32(0);
480
+ if (Ye(n) < 8) break;
481
+ let e = Xe(n, 8), t = new DataView(e.buffer, e.byteOffset, e.length), a = t.getUint32(0);
476
482
  if (a > 2 ** 21 - 1) {
477
- s.enqueue(Ae);
483
+ s.enqueue(ke);
478
484
  break;
479
485
  }
480
486
  i = a * 2 ** 32 + t.getUint32(4), r = 3;
481
487
  } else {
482
- if (Xe(n) < i) break;
483
- let e = O(n, i);
484
- s.enqueue(He(a ? e : Ye.decode(e), t)), r = 0;
488
+ if (Ye(n) < i) break;
489
+ let e = Xe(n, i);
490
+ s.enqueue(Ve(a ? e : Je.decode(e), t)), r = 0;
485
491
  }
486
492
  if (i === 0 || i > e) {
487
- s.enqueue(Ae);
493
+ s.enqueue(ke);
488
494
  break;
489
495
  }
490
496
  }
@@ -594,7 +600,7 @@ var ut = class extends Error {
594
600
  this.readyState = "open", this.writable = !0, super.emitReserved("open");
595
601
  }
596
602
  onData(e) {
597
- let t = He(e, this.socket.binaryType);
603
+ let t = Ve(e, this.socket.binaryType);
598
604
  this.onPacket(t);
599
605
  }
600
606
  onPacket(e) {
@@ -646,7 +652,7 @@ var ut = class extends Error {
646
652
  this._polling = !0, this.doPoll(), this.emitReserved("poll");
647
653
  }
648
654
  onData(e) {
649
- qe(e, this.socket.binaryType).forEach((e) => {
655
+ Ke(e, this.socket.binaryType).forEach((e) => {
650
656
  if (this.readyState === "opening" && e.type === "open" && this.onOpen(), e.type === "close") return this.onClose({ description: "transport closed by the server" }), !1;
651
657
  this.onPacket(e);
652
658
  }), this.readyState !== "closed" && (this._polling = !1, this.emitReserved("pollComplete"), this.readyState === "open" && this._poll());
@@ -658,7 +664,7 @@ var ut = class extends Error {
658
664
  this.readyState === "open" ? e() : this.once("open", e);
659
665
  }
660
666
  write(e) {
661
- this.writable = !1, Ke(e, (e) => {
667
+ this.writable = !1, Ge(e, (e) => {
662
668
  this.doWrite(e, () => {
663
669
  this.writable = !0, this.emitReserved("drain");
664
670
  });
@@ -814,7 +820,7 @@ var St = typeof navigator < "u" && typeof navigator.product == "string" && navig
814
820
  this.writable = !1;
815
821
  for (let t = 0; t < e.length; t++) {
816
822
  let n = e[t], r = t === e.length - 1;
817
- Pe(n, this.supportsBinary, (e) => {
823
+ Ne(n, this.supportsBinary, (e) => {
818
824
  try {
819
825
  this.doWrite(n, e);
820
826
  } catch {}
@@ -856,7 +862,7 @@ var St = typeof navigator < "u" && typeof navigator.product == "string" && navig
856
862
  this.onError("webtransport error", e);
857
863
  }), this._transport.ready.then(() => {
858
864
  this._transport.createBidirectionalStream().then((e) => {
859
- let t = Ze(2 ** 53 - 1, this.socket.binaryType), n = e.readable.pipeThrough(t).getReader(), r = Je();
865
+ let t = Ze(2 ** 53 - 1, this.socket.binaryType), n = e.readable.pipeThrough(t).getReader(), r = qe();
860
866
  r.readable.pipeTo(e.writable), this._writer = r.writable.getWriter();
861
867
  let i = () => {
862
868
  n.read().then(({ done: e, value: t }) => {
@@ -2552,7 +2558,7 @@ function tr({ siteId: e, config: t, children: n, language: r = "en" }) {
2552
2558
  let i = f(() => e ? {
2553
2559
  ...t || {},
2554
2560
  siteId: e
2555
- } : t || null, [e, t]), [a, s] = m(0), [l, u] = m("booting"), [d, h] = m(null), [_, v] = m(null), [y, b] = m(""), [x, S] = m([]), [C, w] = m(ye().isOpen), [T, te] = m(ye().activeScreen), [ne, re] = m(ye().isHumanHandled), [E, se] = m(ye().agentName), [ce, fe] = m(ye().agentHeadshot), [pe, me] = m(() => xe(i?.siteId)), [he, Ce] = m(!1), [we, Oe] = m(!1), [ke, Ae] = m("idle"), [je, Me] = m(!1), [Ne, Pe] = m(!1), [Fe, Ie] = m(""), [Le, Re] = m(!1), [ze, Be] = m(!1), [D, Ve] = m(null), [He, Ue] = m(null), [We, Ge] = m("idle"), [Ke, qe] = m(null), [Je, Ye] = m(!1), [Xe, O] = m(""), Ze = p(!1), k = p(null), A = p(null), j = p(""), Qe = p(null), $e = p(null), et = p(null), tt = p(null), nt = p(null), rt = p([]), it = p(null), at = p(null), ot = p(null), st = p(!1), ct = p(!1), lt = p(""), ut = p(E), dt = p([]), ft = p(!1), pt = p({
2561
+ } : t || null, [e, t]), [a, s] = m(0), [l, u] = m("booting"), [d, h] = m(null), [_, v] = m(null), [y, b] = m(""), [x, S] = m([]), [C, w] = m(ye().isOpen), [T, te] = m(ye().activeScreen), [ne, re] = m(ye().isHumanHandled), [E, se] = m(ye().agentName), [ce, fe] = m(ye().agentHeadshot), [pe, me] = m(() => xe(i?.siteId)), [he, Ce] = m(!1), [we, D] = m(!1), [Oe, ke] = m("idle"), [Ae, je] = m(!1), [Me, Ne] = m(!1), [Pe, Fe] = m(""), [Ie, Le] = m(!1), [Re, ze] = m(!1), [O, Be] = m(null), [Ve, He] = m(null), [Ue, We] = m("idle"), [Ge, Ke] = m(null), [qe, Je] = m(!1), [Ye, Xe] = m(""), Ze = p(!1), k = p(null), A = p(null), j = p(""), Qe = p(null), $e = p(null), et = p(null), tt = p(null), nt = p(null), rt = p([]), it = p(null), at = p(null), ot = p(null), st = p(!1), ct = p(!1), lt = p(""), ut = p(E), dt = p([]), ft = p(!1), pt = p({
2556
2562
  notifyRouteChange: () => {},
2557
2563
  cleanup: () => {}
2558
2564
  }), mt = o((e = {}) => {
@@ -2563,12 +2569,12 @@ function tr({ siteId: e, config: t, children: n, language: r = "en" }) {
2563
2569
  return Number.isFinite(t) && t > 0 ? t : ae;
2564
2570
  }, [i, _]);
2565
2571
  c(() => {
2566
- Qe.current = D;
2567
- }, [D]), c(() => {
2572
+ Qe.current = O;
2573
+ }, [O]), c(() => {
2568
2574
  ut.current = E;
2569
2575
  }, [E]);
2570
2576
  let gt = () => {
2571
- O("");
2577
+ Xe("");
2572
2578
  }, _t = o(() => {
2573
2579
  ot.current &&= (window.clearTimeout(ot.current), null);
2574
2580
  }, []), vt = (e) => {
@@ -2589,7 +2595,7 @@ function tr({ siteId: e, config: t, children: n, language: r = "en" }) {
2589
2595
  hasLocalStream: !!et.current,
2590
2596
  hasRemoteAudio: !!tt.current,
2591
2597
  queuedIceCount: rt.current.length
2592
- }), $e.current &&= ($e.current.close(), null), et.current &&= (et.current.getTracks().forEach((e) => e.stop()), null), tt.current &&= (tt.current.srcObject = null, tt.current.remove(), null), _t(), nt.current = null, rt.current = [], it.current = null, at.current = null, st.current = !1, Ye(!1), Ve(null), Ue(null), Ge("idle"), qe(null), console.log("[FlowEngageCall] cleanup:complete", {
2598
+ }), $e.current &&= ($e.current.close(), null), et.current &&= (et.current.getTracks().forEach((e) => e.stop()), null), tt.current &&= (tt.current.srcObject = null, tt.current.remove(), null), _t(), nt.current = null, rt.current = [], it.current = null, at.current = null, st.current = !1, Je(!1), Be(null), He(null), We("idle"), Ke(null), console.log("[FlowEngageCall] cleanup:complete", {
2593
2599
  reason: e,
2594
2600
  chatId: j.current
2595
2601
  });
@@ -2623,11 +2629,11 @@ function tr({ siteId: e, config: t, children: n, language: r = "en" }) {
2623
2629
  isAcceptingHere: t,
2624
2630
  isAlreadyActive: n,
2625
2631
  isIncomingHere: r
2626
- }), _t(), Ve(null), t || n) {
2627
- it.current = e.callId, Ue(e.callId), Ge((e) => e === "connected" ? e : "connecting"), w(!0);
2632
+ }), _t(), Be(null), t || n) {
2633
+ it.current = e.callId, He(e.callId), We((e) => e === "connected" ? e : "connecting"), w(!0);
2628
2634
  return;
2629
2635
  }
2630
- Ge("idle");
2636
+ We("idle");
2631
2637
  }
2632
2638
  }, St = (e = {}) => {
2633
2639
  if (!e.callId) return;
@@ -2644,7 +2650,7 @@ function tr({ siteId: e, config: t, children: n, language: r = "en" }) {
2644
2650
  yt();
2645
2651
  return;
2646
2652
  }
2647
- at.current = null, nt.current = null, rt.current = [], Ve(null), Ge("idle");
2653
+ at.current = null, nt.current = null, rt.current = [], Be(null), We("idle");
2648
2654
  }
2649
2655
  }, Ct = async (e = {}) => {
2650
2656
  let t = $e.current, n = k.current, r = e.sdpOffer || e.offer?.sdp;
@@ -2756,19 +2762,19 @@ function tr({ siteId: e, config: t, children: n, language: r = "en" }) {
2756
2762
  siteId: t.siteId
2757
2763
  });
2758
2764
  k.current = d, d.on("connect", () => {
2759
- console.log("[FlowEngageProvider] socket connected"), Ae("connected");
2765
+ console.log("[FlowEngageProvider] socket connected"), ke("connected");
2760
2766
  }), d.on("disconnect", () => {
2761
- console.log("[FlowEngageProvider] socket disconnected"), Ae("disconnected");
2767
+ console.log("[FlowEngageProvider] socket disconnected"), ke("disconnected");
2762
2768
  }), d.on("aiTyping", () => {
2763
- console.log("[FlowEngageProvider] received aiTyping", { chatId: j.current }), Oe(!0);
2769
+ console.log("[FlowEngageProvider] received aiTyping", { chatId: j.current }), D(!0);
2764
2770
  }), d.on("ai:typing", () => {
2765
- console.log("[FlowEngageProvider] received ai:typing", { chatId: j.current }), Oe(!0);
2771
+ console.log("[FlowEngageProvider] received ai:typing", { chatId: j.current }), D(!0);
2766
2772
  }), d.on("messageReceived", (e) => {
2767
2773
  let t = e.message || e, n = {
2768
2774
  ...t,
2769
2775
  message: Jn(t.message)
2770
2776
  };
2771
- Oe(!1), Ce(!1), S((e) => [...e.filter((e) => !e.isPending), {
2777
+ D(!1), Ce(!1), S((e) => [...e.filter((e) => !e.isPending), {
2772
2778
  ...n,
2773
2779
  isPending: !1,
2774
2780
  id: n.messageId || `${n.sender}-${Date.now()}-${Math.random()}`
@@ -2786,7 +2792,7 @@ function tr({ siteId: e, config: t, children: n, language: r = "en" }) {
2786
2792
  ...t,
2787
2793
  message: Jn(t.message)
2788
2794
  };
2789
- Oe(!1), (n.sender === "agent" || n.agent_name || n.sender === "ai" || n.sender === "bot") && Ce(!1), S((e) => n.sender === "bot" || n.sender === "ai" ? [...e, {
2795
+ D(!1), (n.sender === "agent" || n.agent_name || n.sender === "ai" || n.sender === "bot") && Ce(!1), S((e) => n.sender === "bot" || n.sender === "ai" ? [...e, {
2790
2796
  ...n,
2791
2797
  isPending: !1,
2792
2798
  id: n.messageId || `${n.sender}-${Date.now()}-${Math.random()}`
@@ -2834,7 +2840,7 @@ function tr({ siteId: e, config: t, children: n, language: r = "en" }) {
2834
2840
  }));
2835
2841
  };
2836
2842
  d.on("agent:joined", f), d.on("agentJoined", f), d.on("agent:left", p), d.on("agentLeft", p), d.on("conversationEnded", (e) => {
2837
- Be(!0);
2843
+ ze(!0);
2838
2844
  let t = e?.message || "This conversation has ended. Thank you for reaching out!";
2839
2845
  S((e) => [...e, {
2840
2846
  id: `conversation-ended-${Date.now()}`,
@@ -2845,9 +2851,9 @@ function tr({ siteId: e, config: t, children: n, language: r = "en" }) {
2845
2851
  }]);
2846
2852
  }), d.on("chat:history_update", (e) => {
2847
2853
  let t = Yn(e.chat_history || []);
2848
- S(t), t.length === 0 && (Be(!1), re(!1), te("ai"), Oe(!1), Ce(!1));
2854
+ S(t), t.length === 0 && (ze(!1), re(!1), te("ai"), D(!1), Ce(!1));
2849
2855
  }), d.on("conversation:reset", () => {
2850
- S([]), Be(!1), re(!1), te("ai"), Oe(!1), Ce(!1);
2856
+ S([]), ze(!1), re(!1), te("ai"), D(!1), Ce(!1);
2851
2857
  }), d.on("typing:start", (e) => {
2852
2858
  console.log("[FlowEngageProvider] received typing:start", {
2853
2859
  chatId: e?.chatId || j.current,
@@ -2869,12 +2875,12 @@ function tr({ siteId: e, config: t, children: n, language: r = "en" }) {
2869
2875
  callId: e.callId,
2870
2876
  chatId: j.current,
2871
2877
  agentName: t
2872
- }), gt(), _t(), st.current = !1, Ve({
2878
+ }), gt(), _t(), st.current = !1, Be({
2873
2879
  callId: e.callId,
2874
2880
  from: e.from || "owner",
2875
2881
  agentId: e.agentId || null,
2876
2882
  agentName: t
2877
- }), se((e) => $n([t, e], "Agent")), Ge("incoming"), qe(null), w(!0);
2883
+ }), se((e) => $n([t, e], "Agent")), We("incoming"), Ke(null), w(!0);
2878
2884
  }), d.on("call:offer", async (e = {}) => {
2879
2885
  console.log("[FlowEngageProvider] received call:offer", {
2880
2886
  callId: e.callId,
@@ -2965,24 +2971,24 @@ function tr({ siteId: e, config: t, children: n, language: r = "en" }) {
2965
2971
  isPendingOfferHere: r,
2966
2972
  isIncomingHere: i
2967
2973
  }), !t && !n && !r) {
2968
- i && (Ve(null), Ge("idle"));
2974
+ i && (Be(null), We("idle"));
2969
2975
  return;
2970
2976
  }
2971
- st.current = !0, at.current = null, it.current = e.callId, Ue(e.callId), Ve(null), Ge("connected"), qe(e.connectedAt || (/* @__PURE__ */ new Date()).toISOString()), w(!0);
2977
+ st.current = !0, at.current = null, it.current = e.callId, He(e.callId), Be(null), We("connected"), Ke(e.connectedAt || (/* @__PURE__ */ new Date()).toISOString()), w(!0);
2972
2978
  }), d.on("call:unavailable", (e = {}) => {
2973
2979
  console.warn("[FlowEngageCall] socket:event call:unavailable", {
2974
2980
  chatId: e.chatId || j.current,
2975
2981
  callId: e.callId,
2976
2982
  reason: e.reason || e.message || null,
2977
2983
  raw: e
2978
- }), yt("socket:call_unavailable"), O(Xn(e, "This visitor is not available for a call right now.")), w(!0);
2984
+ }), yt("socket:call_unavailable"), Xe(Xn(e, "This visitor is not available for a call right now.")), w(!0);
2979
2985
  }), d.on("call:error", (e = {}) => {
2980
2986
  console.error("[FlowEngageCall] socket:event call:error", {
2981
2987
  chatId: e.chatId || j.current,
2982
2988
  callId: e.callId,
2983
2989
  reason: e.reason || e.message || null,
2984
2990
  raw: e
2985
- }), yt("socket:call_error"), O(Xn(e, "We couldn't connect the call right now.")), w(!0);
2991
+ }), yt("socket:call_error"), Xe(Xn(e, "We couldn't connect the call right now.")), w(!0);
2986
2992
  }), d.on("visitor:navigate", async ({ url: e, section: t, highlight: n } = {}) => {
2987
2993
  console.log("[FlowEngageProvider] visitor:navigate DISABLED — ignoring navigation to", e, {
2988
2994
  section: t,
@@ -3020,11 +3026,11 @@ function tr({ siteId: e, config: t, children: n, language: r = "en" }) {
3020
3026
  r,
3021
3027
  a
3022
3028
  ]), c(() => () => {
3023
- if (Le && !ft.current && dt.current.length > 0) {
3029
+ if (Ie && !ft.current && dt.current.length > 0) {
3024
3030
  let e = j.current, t = dt.current, n = A.current;
3025
3031
  n && e && t.length > 0 && (console.log("[FlowEngageProvider] safety-net: syncing voice transcript on unmount"), n.beaconSyncVoice(e, t) || n.syncVoice(e, t).catch(() => {}), ft.current = !0);
3026
3032
  }
3027
- }, [Le, _]), c(() => {
3033
+ }, [Ie, _]), c(() => {
3028
3034
  if (!A.current || !y || l !== "ready") return;
3029
3035
  let e = window.setInterval(async () => {
3030
3036
  try {
@@ -3039,9 +3045,9 @@ function tr({ siteId: e, config: t, children: n, language: r = "en" }) {
3039
3045
  mt
3040
3046
  ]);
3041
3047
  let wt = async () => {
3042
- if (!(!D?.callId || !A.current || !k.current || !y)) {
3043
- gt(), at.current = D.callId, _t(), console.log("[FlowEngageProvider] acceptCall started", {
3044
- callId: D?.callId,
3048
+ if (!(!O?.callId || !A.current || !k.current || !y)) {
3049
+ gt(), at.current = O.callId, _t(), console.log("[FlowEngageProvider] acceptCall started", {
3050
+ callId: O?.callId,
3045
3051
  chatId: y,
3046
3052
  socketConnected: !!k.current?.connected,
3047
3053
  hasPendingOffer: !!nt.current
@@ -3049,7 +3055,7 @@ function tr({ siteId: e, config: t, children: n, language: r = "en" }) {
3049
3055
  try {
3050
3056
  let e = await navigator.mediaDevices.getUserMedia({ audio: !0 });
3051
3057
  console.log("[FlowEngageProvider] microphone stream acquired", {
3052
- callId: D.callId,
3058
+ callId: O.callId,
3053
3059
  chatId: y,
3054
3060
  trackCount: e.getTracks().length
3055
3061
  }), et.current = e;
@@ -3062,28 +3068,28 @@ function tr({ siteId: e, config: t, children: n, language: r = "en" }) {
3062
3068
  }
3063
3069
  let n = new RTCPeerConnection({ iceServers: t });
3064
3070
  $e.current = n, console.log("[FlowEngageCall] peer-connection:created", {
3065
- callId: D.callId,
3071
+ callId: O.callId,
3066
3072
  chatId: y,
3067
3073
  iceServers: 1
3068
3074
  }), n.onconnectionstatechange = () => {
3069
3075
  let e = n.connectionState;
3070
3076
  if (console.log("[FlowEngageProvider] peer connection state changed", {
3071
- callId: D.callId,
3077
+ callId: O.callId,
3072
3078
  chatId: y,
3073
3079
  connectionState: e,
3074
3080
  iceConnectionState: n.iceConnectionState,
3075
3081
  signalingState: n.signalingState
3076
3082
  }), e === "connected") {
3077
3083
  let e = (/* @__PURE__ */ new Date()).toISOString();
3078
- Ge("connected"), qe((t) => t || e), bt(e);
3084
+ We("connected"), Ke((t) => t || e), bt(e);
3079
3085
  return;
3080
3086
  }
3081
3087
  if (e === "connecting") {
3082
- Ge((e) => e === "connected" ? e : "connecting");
3088
+ We((e) => e === "connected" ? e : "connecting");
3083
3089
  return;
3084
3090
  }
3085
3091
  (e === "failed" || e === "disconnected" || e === "closed") && console.warn("[FlowEngageCall] peer-connection:terminal-state", {
3086
- callId: D.callId,
3092
+ callId: O.callId,
3087
3093
  chatId: y,
3088
3094
  connectionState: e,
3089
3095
  iceConnectionState: n.iceConnectionState,
@@ -3092,22 +3098,22 @@ function tr({ siteId: e, config: t, children: n, language: r = "en" }) {
3092
3098
  }, n.oniceconnectionstatechange = () => {
3093
3099
  let e = n.iceConnectionState;
3094
3100
  if (console.log("[FlowEngageProvider] ICE connection state changed", {
3095
- callId: D.callId,
3101
+ callId: O.callId,
3096
3102
  chatId: y,
3097
3103
  iceConnectionState: e,
3098
3104
  connectionState: n.connectionState,
3099
3105
  signalingState: n.signalingState
3100
3106
  }), e === "connected" || e === "completed") {
3101
3107
  let e = (/* @__PURE__ */ new Date()).toISOString();
3102
- Ge("connected"), qe((t) => t || e), bt(e);
3108
+ We("connected"), Ke((t) => t || e), bt(e);
3103
3109
  return;
3104
3110
  }
3105
3111
  if (e === "checking" || e === "new") {
3106
- Ge((e) => e === "connected" ? e : "connecting");
3112
+ We((e) => e === "connected" ? e : "connecting");
3107
3113
  return;
3108
3114
  }
3109
3115
  (e === "failed" || e === "disconnected" || e === "closed") && console.warn("[FlowEngageCall] ice-connection:terminal-state", {
3110
- callId: D.callId,
3116
+ callId: O.callId,
3111
3117
  chatId: y,
3112
3118
  iceConnectionState: e,
3113
3119
  connectionState: n.connectionState,
@@ -3115,7 +3121,7 @@ function tr({ siteId: e, config: t, children: n, language: r = "en" }) {
3115
3121
  });
3116
3122
  }, n.onsignalingstatechange = () => {
3117
3123
  console.log("[FlowEngageCall] signaling-state:changed", {
3118
- callId: D.callId,
3124
+ callId: O.callId,
3119
3125
  chatId: y,
3120
3126
  signalingState: n.signalingState,
3121
3127
  connectionState: n.connectionState,
@@ -3123,13 +3129,13 @@ function tr({ siteId: e, config: t, children: n, language: r = "en" }) {
3123
3129
  });
3124
3130
  }, n.onicegatheringstatechange = () => {
3125
3131
  console.log("[FlowEngageCall] ice-gathering-state:changed", {
3126
- callId: D.callId,
3132
+ callId: O.callId,
3127
3133
  chatId: y,
3128
3134
  iceGatheringState: n.iceGatheringState
3129
3135
  });
3130
3136
  }, e.getTracks().forEach((t) => {
3131
3137
  console.log("[FlowEngageCall] local-track:added", {
3132
- callId: D.callId,
3138
+ callId: O.callId,
3133
3139
  chatId: y,
3134
3140
  kind: t.kind,
3135
3141
  enabled: t.enabled,
@@ -3140,7 +3146,7 @@ function tr({ siteId: e, config: t, children: n, language: r = "en" }) {
3140
3146
  }), n.onicecandidate = (e) => {
3141
3147
  if (!e.candidate || !k.current?.connected) {
3142
3148
  console.log("[FlowEngageProvider] local ICE candidate skipped", {
3143
- callId: D.callId,
3149
+ callId: O.callId,
3144
3150
  chatId: y,
3145
3151
  hasCandidate: !!e.candidate,
3146
3152
  socketConnected: !!k.current?.connected
@@ -3149,11 +3155,11 @@ function tr({ siteId: e, config: t, children: n, language: r = "en" }) {
3149
3155
  }
3150
3156
  let t = e.candidate;
3151
3157
  console.log("[FlowEngageProvider] emitting local ICE candidate", {
3152
- callId: D.callId,
3158
+ callId: O.callId,
3153
3159
  chatId: y,
3154
3160
  candidate: Qn(t)
3155
3161
  }), k.current.emit("call:ice-candidate", {
3156
- callId: D.callId,
3162
+ callId: O.callId,
3157
3163
  candidate: t.candidate,
3158
3164
  sdpMid: t.sdpMid,
3159
3165
  sdpMLineIndex: t.sdpMLineIndex,
@@ -3162,13 +3168,13 @@ function tr({ siteId: e, config: t, children: n, language: r = "en" }) {
3162
3168
  });
3163
3169
  }, n.ontrack = (e) => {
3164
3170
  console.log("[FlowEngageProvider] remote audio track received", {
3165
- callId: D.callId,
3171
+ callId: O.callId,
3166
3172
  chatId: y,
3167
3173
  streamCount: e.streams?.length || 0
3168
3174
  });
3169
3175
  let [t] = e.streams || [], [n] = t?.getAudioTracks?.() || [];
3170
3176
  if (console.log("[FlowEngageCall] remote-track:details", {
3171
- callId: D.callId,
3177
+ callId: O.callId,
3172
3178
  chatId: y,
3173
3179
  trackKind: e.track?.kind || null,
3174
3180
  trackEnabled: e.track?.enabled ?? null,
@@ -3186,24 +3192,24 @@ function tr({ siteId: e, config: t, children: n, language: r = "en" }) {
3186
3192
  let e = document.createElement("audio");
3187
3193
  e.id = "flowengage-remote-audio", e.autoplay = !0, e.playsInline = !0, e.onplay = () => {
3188
3194
  console.log("[FlowEngageCall] remote-audio:onplay", {
3189
- callId: D.callId,
3195
+ callId: O.callId,
3190
3196
  chatId: y
3191
3197
  });
3192
3198
  }, e.onpause = () => {
3193
3199
  console.warn("[FlowEngageCall] remote-audio:onpause", {
3194
- callId: D.callId,
3200
+ callId: O.callId,
3195
3201
  chatId: y,
3196
3202
  currentTime: e.currentTime
3197
3203
  });
3198
3204
  }, e.onended = () => {
3199
3205
  console.warn("[FlowEngageCall] remote-audio:onended", {
3200
- callId: D.callId,
3206
+ callId: O.callId,
3201
3207
  chatId: y,
3202
3208
  currentTime: e.currentTime
3203
3209
  });
3204
3210
  }, e.onerror = (t) => {
3205
3211
  console.error("[FlowEngageCall] remote-audio:onerror", {
3206
- callId: D.callId,
3212
+ callId: O.callId,
3207
3213
  chatId: y,
3208
3214
  error: e.error ? {
3209
3215
  code: e.error.code,
@@ -3214,16 +3220,16 @@ function tr({ siteId: e, config: t, children: n, language: r = "en" }) {
3214
3220
  }, tt.current = e, document.body.appendChild(e);
3215
3221
  }
3216
3222
  tt.current.srcObject = e.streams[0];
3217
- let r = D?.callId, i = r && (at.current === r || it.current === r);
3223
+ let r = O?.callId, i = r && (at.current === r || it.current === r);
3218
3224
  if (!st.current && i) {
3219
3225
  let e = (/* @__PURE__ */ new Date()).toISOString();
3220
- Ge("connected"), qe((t) => t || e), it.current = r, Ue(r), bt(e);
3226
+ We("connected"), Ke((t) => t || e), it.current = r, He(r), bt(e);
3221
3227
  }
3222
3228
  tt.current.srcObject = t || null;
3223
3229
  let a = tt.current.play?.();
3224
3230
  a?.catch && a.catch((e) => {
3225
3231
  console.error("[FlowEngageCall] remote-audio:play-failed", {
3226
- callId: D.callId,
3232
+ callId: O.callId,
3227
3233
  chatId: y,
3228
3234
  message: e?.message,
3229
3235
  name: e?.name,
@@ -3233,72 +3239,72 @@ function tr({ siteId: e, config: t, children: n, language: r = "en" }) {
3233
3239
  };
3234
3240
  let r = nt.current;
3235
3241
  r && (console.log("[FlowEngageProvider] found pending remote offer during accept", {
3236
- callId: r.callId || D.callId,
3242
+ callId: r.callId || O.callId,
3237
3243
  chatId: y
3238
3244
  }), await Ct({
3239
3245
  ...r,
3240
- callId: r.callId || D.callId
3241
- })), await A.current.acceptCall(D.callId, y), console.log("[FlowEngageProvider] acceptCall API succeeded", {
3242
- callId: D.callId,
3246
+ callId: r.callId || O.callId
3247
+ })), await A.current.acceptCall(O.callId, y), console.log("[FlowEngageProvider] acceptCall API succeeded", {
3248
+ callId: O.callId,
3243
3249
  chatId: y
3244
- }), it.current = D.callId, Ue(D.callId), Ge((e) => e === "connected" || st.current ? "connected" : "connecting"), Ve(null), w(!0);
3250
+ }), it.current = O.callId, He(O.callId), We((e) => e === "connected" || st.current ? "connected" : "connecting"), Be(null), w(!0);
3245
3251
  } catch (e) {
3246
3252
  if (console.error("[FlowEngageProvider] acceptCall failed", e), at.current = null, yt("accept_call_failed"), e?.status === 404 || e?.status === 409 || e?.status === 422) {
3247
- O(Xn(e, "This visitor call is no longer available."));
3253
+ Xe(Xn(e, "This visitor call is no longer available."));
3248
3254
  return;
3249
3255
  }
3250
3256
  if (e?.name === "NotAllowedError" || e?.name === "PermissionDeniedError") {
3251
3257
  try {
3252
- await A.current.rejectCall(D.callId, y);
3258
+ await A.current.rejectCall(O.callId, y);
3253
3259
  } catch (e) {
3254
3260
  console.error("[FlowEngageProvider] failed to reject call after microphone denial", e);
3255
3261
  }
3256
- O("Microphone access was denied. Please allow microphone access to accept the call.");
3262
+ Xe("Microphone access was denied. Please allow microphone access to accept the call.");
3257
3263
  return;
3258
3264
  }
3259
- O("We couldn't connect the call right now. Please try again.");
3265
+ Xe("We couldn't connect the call right now. Please try again.");
3260
3266
  }
3261
3267
  }
3262
3268
  }, Tt = async () => {
3263
- if (!D?.callId || !A.current || !y) {
3269
+ if (!O?.callId || !A.current || !y) {
3264
3270
  yt("reject_call_without_server_context");
3265
3271
  return;
3266
3272
  }
3267
3273
  _t(), gt();
3268
3274
  try {
3269
- await A.current.rejectCall(D.callId, y);
3275
+ await A.current.rejectCall(O.callId, y);
3270
3276
  } catch (e) {
3271
- console.error("[FlowEngageProvider] rejectCall failed", e), O(Xn(e, "We couldn't decline the call cleanly."));
3277
+ console.error("[FlowEngageProvider] rejectCall failed", e), Xe(Xn(e, "We couldn't decline the call cleanly."));
3272
3278
  } finally {
3273
3279
  yt("reject_call_finally");
3274
3280
  }
3275
3281
  }, Et = p(Tt);
3276
3282
  Et.current = Tt, c(() => {
3277
- if (!D?.callId || He) {
3283
+ if (!O?.callId || Ve) {
3278
3284
  _t();
3279
3285
  return;
3280
3286
  }
3281
- let e = D.callId;
3287
+ let e = O.callId;
3282
3288
  return _t(), ot.current = window.setTimeout(() => {
3283
3289
  Qe.current?.callId === e && at.current !== e && it.current !== e && Et.current();
3284
3290
  }, oe), () => {
3285
3291
  ot.current &&= (window.clearTimeout(ot.current), null);
3286
3292
  };
3287
3293
  }, [
3288
- He,
3294
+ Ve,
3289
3295
  _t,
3290
- D?.callId
3296
+ O?.callId
3291
3297
  ]);
3292
3298
  let Dt = async () => {
3293
- if (!He || !A.current || !y) {
3299
+ if (!Ve || !A.current || !y) {
3294
3300
  yt("end_call_without_server_context");
3295
3301
  return;
3296
3302
  }
3297
3303
  gt();
3298
3304
  try {
3299
- await A.current.endWebRTCCall(He, y);
3305
+ await A.current.endWebRTCCall(Ve, y);
3300
3306
  } catch (e) {
3301
- console.error("[FlowEngageProvider] endWebRTCCall failed", e), O(Xn(e, "The call ended locally, but the server could not be updated."));
3307
+ console.error("[FlowEngageProvider] endWebRTCCall failed", e), Xe(Xn(e, "The call ended locally, but the server could not be updated."));
3302
3308
  } finally {
3303
3309
  yt("end_call_finally");
3304
3310
  }
@@ -3308,13 +3314,13 @@ function tr({ siteId: e, config: t, children: n, language: r = "en" }) {
3308
3314
  console.warn("[FlowEngageProvider] no local audio tracks available for mute");
3309
3315
  return;
3310
3316
  }
3311
- let r = !Je;
3317
+ let r = !qe;
3312
3318
  n.forEach((e) => {
3313
3319
  e.enabled = !r;
3314
3320
  }), console.log("[FlowEngageProvider] toggled local mute", {
3315
3321
  nextMuted: r,
3316
3322
  trackCount: n.length
3317
- }), Ye(r);
3323
+ }), Je(r);
3318
3324
  }, kt = async (e = {}) => {
3319
3325
  let t = e.notifyChatInitiated === !0;
3320
3326
  if (w(!0), !(!t || !A.current || !y || typeof window > "u")) {
@@ -3393,7 +3399,7 @@ function tr({ siteId: e, config: t, children: n, language: r = "en" }) {
3393
3399
  text: t
3394
3400
  }));
3395
3401
  }, Pt = async (e, t = "", n = null, i = {}) => {
3396
- if (!(typeof e == "string" && e.trim()) || !A.current || !y || l !== "ready" || ze) return;
3402
+ if (!(typeof e == "string" && e.trim()) || !A.current || !y || l !== "ready" || Re) return;
3397
3403
  Mt();
3398
3404
  let a = `pending-user-${Date.now()}`, o = {
3399
3405
  id: a,
@@ -3422,19 +3428,19 @@ function tr({ siteId: e, config: t, children: n, language: r = "en" }) {
3422
3428
  });
3423
3429
  return;
3424
3430
  }
3425
- Me(!0);
3431
+ je(!0);
3426
3432
  try {
3427
3433
  let a = await A.current.sendAiMessage(y, e, r, t, {
3428
3434
  ...n || {},
3429
3435
  ...pe ? { email: pe } : {}
3430
3436
  }, i), o = a.chat_history || [];
3431
- [...o].reverse().find((e) => e.sender === "bot" || e.sender === "assistant"), S(Yn(o)), re(!!a.is_human_handled), te(a.is_human_handled ? "agent" : "ai"), Oe(!1), await A.current.updateChatStatus(y, "messageSent");
3437
+ [...o].reverse().find((e) => e.sender === "bot" || e.sender === "assistant"), S(Yn(o)), re(!!a.is_human_handled), te(a.is_human_handled ? "agent" : "ai"), D(!1), await A.current.updateChatStatus(y, "messageSent");
3432
3438
  } catch (e) {
3433
- S((e) => e.filter((e) => e.id !== a)), Oe(!1), e.status === 429 ? (Pe(!0), Ie(e.message), window.setTimeout(() => {
3434
- Pe(!1), Ie("");
3439
+ S((e) => e.filter((e) => e.id !== a)), D(!1), e.status === 429 ? (Ne(!0), Fe(e.message), window.setTimeout(() => {
3440
+ Ne(!1), Fe("");
3435
3441
  }, ie)) : h(e);
3436
3442
  } finally {
3437
- Me(!1);
3443
+ je(!1);
3438
3444
  }
3439
3445
  }, Ft = async (e) => {
3440
3446
  if (!A.current || !e) throw Error("Upload is unavailable right now.");
@@ -3447,12 +3453,12 @@ function tr({ siteId: e, config: t, children: n, language: r = "en" }) {
3447
3453
  } catch (e) {
3448
3454
  console.error("[FlowEngageProvider] setVoiceMode failed", e);
3449
3455
  }
3450
- Re(e), e && (ft.current = !1);
3456
+ Le(e), e && (ft.current = !1);
3451
3457
  }
3452
3458
  }, Lt = async (e) => {
3453
3459
  if (ft.current) return;
3454
3460
  if (ft.current = !0, !A.current || !y || !e?.length) {
3455
- Re(!1);
3461
+ Le(!1);
3456
3462
  return;
3457
3463
  }
3458
3464
  let t = () => {
@@ -3476,11 +3482,11 @@ function tr({ siteId: e, config: t, children: n, language: r = "en" }) {
3476
3482
  } catch {
3477
3483
  t();
3478
3484
  } finally {
3479
- Re(!1);
3485
+ Le(!1);
3480
3486
  }
3481
3487
  }, Rt = async () => {
3482
3488
  if (!(!A.current || !y)) {
3483
- Le && !ft.current && dt.current.length > 0 && await Lt(dt.current);
3489
+ Ie && !ft.current && dt.current.length > 0 && await Lt(dt.current);
3484
3490
  try {
3485
3491
  await A.current.endConversation(y);
3486
3492
  } catch {
@@ -3488,7 +3494,7 @@ function tr({ siteId: e, config: t, children: n, language: r = "en" }) {
3488
3494
  await A.current.updateChatStatus(y, "ended");
3489
3495
  } catch {}
3490
3496
  }
3491
- Be(!0), S((e) => [...e, {
3497
+ ze(!0), S((e) => [...e, {
3492
3498
  id: `conversation-ended-${Date.now()}`,
3493
3499
  sender: "system",
3494
3500
  message: "This conversation has ended. Thank you for reaching out!",
@@ -3498,15 +3504,15 @@ function tr({ siteId: e, config: t, children: n, language: r = "en" }) {
3498
3504
  }
3499
3505
  };
3500
3506
  c(() => {
3501
- if (We !== "connected" || !He || !y || !Ke || !ht) return;
3502
- let e = new Date(Ke).getTime(), t = Number.isFinite(e) ? Date.now() - e : 0, n = Math.max(0, ht * 1e3 - t), r = window.setTimeout(() => {
3503
- O("The call ended because it reached the time limit."), Dt();
3507
+ if (Ue !== "connected" || !Ve || !y || !Ge || !ht) return;
3508
+ let e = new Date(Ge).getTime(), t = Number.isFinite(e) ? Date.now() - e : 0, n = Math.max(0, ht * 1e3 - t), r = window.setTimeout(() => {
3509
+ Xe("The call ended because it reached the time limit."), Dt();
3504
3510
  }, n);
3505
3511
  return () => window.clearTimeout(r);
3506
3512
  }, [
3507
- He,
3508
- Ke,
3509
- We,
3513
+ Ve,
3514
+ Ge,
3515
+ Ue,
3510
3516
  y,
3511
3517
  Dt,
3512
3518
  ht
@@ -3527,7 +3533,7 @@ function tr({ siteId: e, config: t, children: n, language: r = "en" }) {
3527
3533
  }, []);
3528
3534
  let zt = o(() => {
3529
3535
  let e = i?.siteId;
3530
- _e(e), Ze.current = !0, k.current?.disconnect(), S([]), b(""), j.current = "", Be(!1), re(!1), se(null), fe(null), s((e) => e + 1);
3536
+ _e(e), Ze.current = !0, k.current?.disconnect(), S([]), b(""), j.current = "", ze(!1), re(!1), se(null), fe(null), s((e) => e + 1);
3531
3537
  }, [i?.siteId]), Bt = f(() => ({
3532
3538
  status: l,
3533
3539
  error: d,
@@ -3543,18 +3549,18 @@ function tr({ siteId: e, config: t, children: n, language: r = "en" }) {
3543
3549
  visitorEmail: pe,
3544
3550
  isAgentTyping: he,
3545
3551
  isAiTyping: we,
3546
- connectionStatus: ke,
3547
- isLoading: je,
3548
- isVoiceMode: Le,
3549
- isRateLimited: Ne,
3550
- rateLimitMessage: Fe,
3551
- isConversationEnded: ze,
3552
- incomingCall: D,
3553
- activeCallId: He,
3554
- callConnectionState: We,
3555
- callConnectedAt: Ke,
3556
- isCallMuted: Je,
3557
- webRTCError: Xe,
3552
+ connectionStatus: Oe,
3553
+ isLoading: Ae,
3554
+ isVoiceMode: Ie,
3555
+ isRateLimited: Me,
3556
+ rateLimitMessage: Pe,
3557
+ isConversationEnded: Re,
3558
+ incomingCall: O,
3559
+ activeCallId: Ve,
3560
+ callConnectionState: Ue,
3561
+ callConnectedAt: Ge,
3562
+ isCallMuted: qe,
3563
+ webRTCError: Ye,
3558
3564
  language: r,
3559
3565
  historyRef: dt,
3560
3566
  hasSyncedRef: ft,
@@ -3579,6 +3585,8 @@ function tr({ siteId: e, config: t, children: n, language: r = "en" }) {
3579
3585
  onMessageSync: Lt,
3580
3586
  endConversation: Rt,
3581
3587
  startNewChat: zt,
3588
+ getVisitorChatHistory: () => A.current?.getVisitorChatHistory?.(),
3589
+ getVisitorChatThread: (e) => A.current?.getVisitorChatThread?.(e),
3582
3590
  acceptCall: wt,
3583
3591
  rejectCall: Tt,
3584
3592
  endWebRTCCall: Dt,
@@ -3598,18 +3606,18 @@ function tr({ siteId: e, config: t, children: n, language: r = "en" }) {
3598
3606
  pe,
3599
3607
  he,
3600
3608
  we,
3601
- ke,
3602
- je,
3603
- Le,
3604
- Ne,
3605
- Fe,
3606
- ze,
3607
- D,
3608
- He,
3609
- We,
3610
- Ke,
3611
- Je,
3612
- Xe,
3609
+ Oe,
3610
+ Ae,
3611
+ Ie,
3612
+ Me,
3613
+ Pe,
3614
+ Re,
3615
+ O,
3616
+ Ve,
3617
+ Ue,
3618
+ Ge,
3619
+ qe,
3620
+ Ye,
3613
3621
  r,
3614
3622
  At,
3615
3623
  jt,
@@ -30040,16 +30048,34 @@ var VO = () => /* @__PURE__ */ g("div", {
30040
30048
  } }, e))
30041
30049
  })
30042
30050
  });
30043
- function HO({ 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: h, agentHeadshot: v, fallbackAgentName: y, input: b, setInput: x, onSubmit: S, isConversationEnded: C, isLoading: w, isRateLimited: T, rateLimitMessage: ee, selectedFile: te, onFileSelect: ne, onRemoveSelectedFile: re, attachmentError: E, isUploadingAttachment: ie, requiresEmail: ae, emailInput: oe, setEmailInput: se, emailError: ce, replyContext: le, setReplyContext: ue, webRTCError: de, micError: fe, setMicError: pe, dismissCallError: me, activeCallId: he, isCallMuted: ge, toggleCallMute: _e, endWebRTCCall: ve, formatCallDuration: ye, callDurationSeconds: be, isCallMinimized: xe, onExpand: Se, onCollapse: Ce, onStartVoice: we, onNewChat: Te, showPoweredBy: Ee }) {
30044
- let De = l.length > 0, Oe = w || T || C, ke = !!he, [Ae, je] = m(!1), Me = p(null);
30051
+ function HO({ 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: ee, rateLimitMessage: te, selectedFile: ne, onFileSelect: re, onRemoveSelectedFile: E, attachmentError: ie, isUploadingAttachment: ae, requiresEmail: oe, emailInput: se, setEmailInput: ce, emailError: le, replyContext: ue, setReplyContext: de, webRTCError: fe, micError: pe, setMicError: me, dismissCallError: he, activeCallId: ge, isCallMuted: _e, toggleCallMute: ve, endWebRTCCall: ye, formatCallDuration: be, callDurationSeconds: xe, isCallMinimized: Se, onExpand: Ce, onCollapse: we, onStartVoice: Te, onNewChat: Ee, onEndConversation: De, showPoweredBy: D, getVisitorChatHistory: Oe, getVisitorChatThread: ke }) {
30052
+ let Ae = l.length > 0, je = T || ee || w, Me = !!ge, [Ne, Pe] = m(!1), [Fe, Ie] = m(!1), [Le, Re] = m([]), [ze, O] = m(!1), [Be, Ve] = m(null), [He, Ue] = m([]), We = p(null), Ge = async () => {
30053
+ Pe(!1), Ie(!0), O(!0), Ve(null);
30054
+ try {
30055
+ let e = await Oe();
30056
+ e?.data && Re(e.data);
30057
+ } catch (e) {
30058
+ console.error(e);
30059
+ } finally {
30060
+ O(!1);
30061
+ }
30062
+ }, Ke = async (e) => {
30063
+ Ve(e);
30064
+ try {
30065
+ let t = await ke(e.chatId);
30066
+ t?.data && Ue(t.data);
30067
+ } catch (e) {
30068
+ console.error(e);
30069
+ }
30070
+ };
30045
30071
  return c(() => {
30046
- if (!Ae) return;
30072
+ if (!Ne) return;
30047
30073
  let e = (e) => {
30048
30074
  let t = e.composedPath?.()?.[0] || e.target;
30049
- Me.current && !Me.current.contains(t) && je(!1);
30075
+ We.current && !We.current.contains(t) && Pe(!1);
30050
30076
  };
30051
30077
  return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
30052
- }, [Ae]), /* @__PURE__ */ _("div", {
30078
+ }, [Ne]), /* @__PURE__ */ _("div", {
30053
30079
  style: s ? {
30054
30080
  "--flowengage-primary": n,
30055
30081
  "--flowengage-accent": n,
@@ -30091,39 +30117,46 @@ function HO({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
30091
30117
  flexShrink: 0
30092
30118
  },
30093
30119
  children: [
30094
- /* @__PURE__ */ g("button", {
30095
- onClick: Ce,
30120
+ /* @__PURE__ */ g("div", {
30096
30121
  style: {
30097
- width: "40px",
30098
- height: "40px",
30099
- background: "none",
30100
- border: "none",
30101
- cursor: "pointer",
30102
- color: "#6b7280",
30103
30122
  display: "flex",
30104
- alignItems: "center",
30105
- justifyContent: "center",
30106
- padding: "4px",
30107
- borderRadius: "10px",
30108
- transition: "color 0.15s ease",
30109
- flexShrink: 0
30110
- },
30111
- onMouseEnter: (e) => {
30112
- e.currentTarget.style.color = "#111827";
30113
- },
30114
- onMouseLeave: (e) => {
30115
- e.currentTarget.style.color = "#6b7280";
30123
+ gap: "8px",
30124
+ alignItems: "center"
30116
30125
  },
30117
- children: /* @__PURE__ */ g("svg", {
30118
- width: "20",
30119
- height: "20",
30120
- viewBox: "0 0 24 24",
30121
- fill: "none",
30122
- stroke: "currentColor",
30123
- strokeWidth: "2.2",
30124
- strokeLinecap: "round",
30125
- strokeLinejoin: "round",
30126
- children: /* @__PURE__ */ g("polyline", { points: "6 9 12 15 18 9" })
30126
+ children: /* @__PURE__ */ g("button", {
30127
+ onClick: we,
30128
+ style: {
30129
+ width: "40px",
30130
+ height: "40px",
30131
+ background: "none",
30132
+ border: "none",
30133
+ cursor: "pointer",
30134
+ color: "#6b7280",
30135
+ display: "flex",
30136
+ alignItems: "center",
30137
+ justifyContent: "center",
30138
+ padding: "4px",
30139
+ borderRadius: "10px",
30140
+ transition: "color 0.15s ease",
30141
+ flexShrink: 0
30142
+ },
30143
+ onMouseEnter: (e) => {
30144
+ e.currentTarget.style.color = "#111827";
30145
+ },
30146
+ onMouseLeave: (e) => {
30147
+ e.currentTarget.style.color = "#6b7280";
30148
+ },
30149
+ children: /* @__PURE__ */ g("svg", {
30150
+ width: "20",
30151
+ height: "20",
30152
+ viewBox: "0 0 24 24",
30153
+ fill: "none",
30154
+ stroke: "currentColor",
30155
+ strokeWidth: "2.2",
30156
+ strokeLinecap: "round",
30157
+ strokeLinejoin: "round",
30158
+ children: /* @__PURE__ */ g("polyline", { points: "6 9 12 15 18 9" })
30159
+ })
30127
30160
  })
30128
30161
  }),
30129
30162
  /* @__PURE__ */ _("div", {
@@ -30187,10 +30220,10 @@ function HO({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
30187
30220
  isolation: "isolate",
30188
30221
  zIndex: 10
30189
30222
  },
30190
- ref: Me,
30223
+ ref: We,
30191
30224
  children: [/* @__PURE__ */ g("button", {
30192
30225
  type: "button",
30193
- onClick: () => je((e) => !e),
30226
+ onClick: () => Pe((e) => !e),
30194
30227
  style: {
30195
30228
  width: "40px",
30196
30229
  height: "40px",
@@ -30236,7 +30269,7 @@ function HO({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
30236
30269
  })
30237
30270
  ]
30238
30271
  })
30239
- }), Ae && /* @__PURE__ */ _("div", {
30272
+ }), Ne && /* @__PURE__ */ _("div", {
30240
30273
  style: {
30241
30274
  position: "absolute",
30242
30275
  top: "34px",
@@ -30255,7 +30288,7 @@ function HO({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
30255
30288
  /* @__PURE__ */ _("button", {
30256
30289
  type: "button",
30257
30290
  onClick: () => {
30258
- je(!1), we?.();
30291
+ Pe(!1), Te?.();
30259
30292
  },
30260
30293
  style: {
30261
30294
  display: "flex",
@@ -30298,7 +30331,7 @@ function HO({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
30298
30331
  /* @__PURE__ */ _("button", {
30299
30332
  type: "button",
30300
30333
  onClick: () => {
30301
- je(!1), Te?.();
30334
+ Pe(!1), Ee?.();
30302
30335
  },
30303
30336
  style: {
30304
30337
  display: "flex",
@@ -30331,8 +30364,48 @@ function HO({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
30331
30364
  strokeLinecap: "round",
30332
30365
  strokeLinejoin: "round",
30333
30366
  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" })]
30334
- }), "New Conversation"]
30367
+ }), "Start new conversation"]
30335
30368
  }),
30369
+ Oe && /* @__PURE__ */ _(h, { children: [/* @__PURE__ */ g("div", { style: {
30370
+ height: "1px",
30371
+ background: "rgba(255,255,255,0.07)",
30372
+ margin: "0 14px"
30373
+ } }), /* @__PURE__ */ _("button", {
30374
+ type: "button",
30375
+ onClick: Ge,
30376
+ style: {
30377
+ display: "flex",
30378
+ alignItems: "center",
30379
+ gap: "12px",
30380
+ width: "100%",
30381
+ padding: "14px 18px",
30382
+ background: "none",
30383
+ border: "none",
30384
+ color: "white",
30385
+ fontSize: "14px",
30386
+ fontWeight: 500,
30387
+ cursor: "pointer",
30388
+ textAlign: "left",
30389
+ transition: "background 0.15s ease"
30390
+ },
30391
+ onMouseEnter: (e) => {
30392
+ e.currentTarget.style.background = "rgba(255,255,255,0.08)";
30393
+ },
30394
+ onMouseLeave: (e) => {
30395
+ e.currentTarget.style.background = "none";
30396
+ },
30397
+ children: [/* @__PURE__ */ g("svg", {
30398
+ width: "16",
30399
+ height: "16",
30400
+ viewBox: "0 0 24 24",
30401
+ fill: "none",
30402
+ stroke: "currentColor",
30403
+ strokeWidth: "2",
30404
+ strokeLinecap: "round",
30405
+ strokeLinejoin: "round",
30406
+ children: /* @__PURE__ */ g("path", { d: "M12 8v4l3 3M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0z" })
30407
+ }), "Chat history"]
30408
+ })] }),
30336
30409
  /* @__PURE__ */ g("div", { style: {
30337
30410
  height: "1px",
30338
30411
  background: "rgba(255,255,255,0.07)",
@@ -30341,7 +30414,7 @@ function HO({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
30341
30414
  /* @__PURE__ */ _("button", {
30342
30415
  type: "button",
30343
30416
  onClick: () => {
30344
- je(!1), Ce?.();
30417
+ Pe(!1), De ? De().catch(() => {}).finally(() => Ee?.()) : Ee?.();
30345
30418
  },
30346
30419
  style: {
30347
30420
  display: "flex",
@@ -30373,13 +30446,26 @@ function HO({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
30373
30446
  strokeWidth: "2",
30374
30447
  strokeLinecap: "round",
30375
30448
  strokeLinejoin: "round",
30376
- children: [/* @__PURE__ */ g("path", { d: "M10.68 13.31a16 16 0 003.41 2.6l1.27-1.27a2 2 0 012.11-.45 12.84 12.84 0 002.81.7 2 2 0 011.72 2v3a2 2 0 01-2.18 2 19.79 19.79 0 01-8.63-3.07A19.42 19.42 0 013.07 8.62 19.79 19.79 0 01.1 2 2 2 0 012.11 0h3a2 2 0 012 1.72c.127.96.361 1.903.7 2.81a2 2 0 01-.45 2.11L6.18 7.84" }), /* @__PURE__ */ g("line", {
30377
- x1: "23",
30378
- y1: "1",
30379
- x2: "1",
30380
- y2: "23"
30381
- })]
30382
- }), "Close Conversation"]
30449
+ children: [
30450
+ /* @__PURE__ */ g("circle", {
30451
+ cx: "12",
30452
+ cy: "12",
30453
+ r: "10"
30454
+ }),
30455
+ /* @__PURE__ */ g("line", {
30456
+ x1: "15",
30457
+ y1: "9",
30458
+ x2: "9",
30459
+ y2: "15"
30460
+ }),
30461
+ /* @__PURE__ */ g("line", {
30462
+ x1: "9",
30463
+ y1: "9",
30464
+ x2: "15",
30465
+ y2: "15"
30466
+ })
30467
+ ]
30468
+ }), "Close conversation"]
30383
30469
  })
30384
30470
  ]
30385
30471
  })]
@@ -30387,43 +30473,228 @@ function HO({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
30387
30473
  ]
30388
30474
  }),
30389
30475
  /* @__PURE__ */ g(lD, {
30390
- webRTCError: de,
30391
- micError: fe,
30392
- setMicError: pe,
30393
- dismissCallError: me,
30394
- isRateLimited: T,
30395
- rateLimitMessage: ee
30476
+ webRTCError: fe,
30477
+ micError: pe,
30478
+ setMicError: me,
30479
+ dismissCallError: he,
30480
+ isRateLimited: ee,
30481
+ rateLimitMessage: te
30396
30482
  }),
30397
- xe && /* @__PURE__ */ g(ED, {
30398
- agentName: h,
30399
- agentHeadshot: v,
30400
- fallbackAgentName: y,
30401
- callDurationSeconds: be,
30402
- isCallMuted: ge,
30403
- formatCallDuration: ye,
30404
- toggleCallMute: _e,
30405
- endWebRTCCall: ve,
30406
- onExpand: Se,
30483
+ Se && /* @__PURE__ */ g(ED, {
30484
+ agentName: v,
30485
+ agentHeadshot: y,
30486
+ fallbackAgentName: b,
30487
+ callDurationSeconds: xe,
30488
+ isCallMuted: _e,
30489
+ formatCallDuration: be,
30490
+ toggleCallMute: ve,
30491
+ endWebRTCCall: ye,
30492
+ onExpand: Ce,
30407
30493
  primaryColor: n
30408
30494
  }),
30409
- /* @__PURE__ */ g("div", {
30495
+ /* @__PURE__ */ _("div", {
30410
30496
  style: {
30411
30497
  flex: 1,
30412
30498
  display: "flex",
30413
30499
  flexDirection: "column",
30414
30500
  minHeight: 0,
30415
- background: "transparent"
30501
+ background: "transparent",
30502
+ position: "relative"
30416
30503
  },
30417
- children: De ? /* @__PURE__ */ g(sD, {
30504
+ children: [Fe ? /* @__PURE__ */ _("div", {
30505
+ style: {
30506
+ position: "absolute",
30507
+ inset: 0,
30508
+ background: "white",
30509
+ zIndex: 20,
30510
+ display: "flex",
30511
+ flexDirection: "column",
30512
+ animation: "fe-orb-fade-in 0.2s ease"
30513
+ },
30514
+ children: [/* @__PURE__ */ g("div", {
30515
+ style: {
30516
+ display: "flex",
30517
+ alignItems: "center",
30518
+ padding: "16px",
30519
+ borderBottom: "1px solid #f3f4f6",
30520
+ flexShrink: 0
30521
+ },
30522
+ children: Be ? /* @__PURE__ */ _("button", {
30523
+ onClick: () => Ve(null),
30524
+ style: {
30525
+ background: "none",
30526
+ border: "none",
30527
+ cursor: "pointer",
30528
+ display: "flex",
30529
+ alignItems: "center",
30530
+ color: "#6b7280"
30531
+ },
30532
+ children: [/* @__PURE__ */ g("svg", {
30533
+ width: "20",
30534
+ height: "20",
30535
+ viewBox: "0 0 24 24",
30536
+ fill: "none",
30537
+ stroke: "currentColor",
30538
+ strokeWidth: "2",
30539
+ strokeLinecap: "round",
30540
+ strokeLinejoin: "round",
30541
+ children: /* @__PURE__ */ g("polyline", { points: "15 18 9 12 15 6" })
30542
+ }), /* @__PURE__ */ g("span", {
30543
+ style: {
30544
+ marginLeft: "8px",
30545
+ fontWeight: 500,
30546
+ fontSize: "15px"
30547
+ },
30548
+ children: "Back to List"
30549
+ })]
30550
+ }) : /* @__PURE__ */ _("button", {
30551
+ onClick: () => Ie(!1),
30552
+ style: {
30553
+ background: "none",
30554
+ border: "none",
30555
+ cursor: "pointer",
30556
+ display: "flex",
30557
+ alignItems: "center",
30558
+ color: "#6b7280"
30559
+ },
30560
+ children: [/* @__PURE__ */ g("svg", {
30561
+ width: "20",
30562
+ height: "20",
30563
+ viewBox: "0 0 24 24",
30564
+ fill: "none",
30565
+ stroke: "currentColor",
30566
+ strokeWidth: "2",
30567
+ strokeLinecap: "round",
30568
+ strokeLinejoin: "round",
30569
+ children: /* @__PURE__ */ g("polyline", { points: "15 18 9 12 15 6" })
30570
+ }), /* @__PURE__ */ g("span", {
30571
+ style: {
30572
+ marginLeft: "8px",
30573
+ fontWeight: 500,
30574
+ fontSize: "15px"
30575
+ },
30576
+ children: "Return to Chat"
30577
+ })]
30578
+ })
30579
+ }), /* @__PURE__ */ g("div", {
30580
+ style: {
30581
+ flex: 1,
30582
+ overflowY: "auto",
30583
+ position: "relative"
30584
+ },
30585
+ children: ze && !Be ? /* @__PURE__ */ g("div", {
30586
+ style: {
30587
+ padding: "40px 20px",
30588
+ textAlign: "center",
30589
+ color: "#6b7280",
30590
+ fontSize: "14px"
30591
+ },
30592
+ children: "Loading past conversations..."
30593
+ }) : Be ? /* @__PURE__ */ _("div", {
30594
+ style: { padding: "20px 16px" },
30595
+ children: [
30596
+ He.length === 0 ? /* @__PURE__ */ g("div", {
30597
+ style: {
30598
+ color: "#9ca3af",
30599
+ textAlign: "center",
30600
+ marginTop: "20px",
30601
+ fontSize: "14px"
30602
+ },
30603
+ children: "No messages"
30604
+ }) : null,
30605
+ He.map((e, t) => /* @__PURE__ */ g("div", {
30606
+ style: {
30607
+ marginBottom: "16px",
30608
+ display: "flex",
30609
+ justifyContent: e.sender === "user" ? "flex-end" : "flex-start"
30610
+ },
30611
+ children: /* @__PURE__ */ g("div", {
30612
+ style: {
30613
+ maxWidth: "85%",
30614
+ background: e.sender === "user" ? n : "#f3f4f6",
30615
+ color: e.sender === "user" ? "white" : "#111827",
30616
+ padding: "10px 14px",
30617
+ borderRadius: "14px",
30618
+ fontSize: "15px",
30619
+ lineHeight: 1.4,
30620
+ wordBreak: "break-word"
30621
+ },
30622
+ children: e.content
30623
+ })
30624
+ }, e._id || t)),
30625
+ He.length > 0 && /* @__PURE__ */ g("div", {
30626
+ style: {
30627
+ textAlign: "center",
30628
+ color: "#9ca3af",
30629
+ fontSize: "12px",
30630
+ marginTop: "32px",
30631
+ paddingBottom: "20px"
30632
+ },
30633
+ children: "— This conversation is closed —"
30634
+ })
30635
+ ]
30636
+ }) : Le.length > 0 ? /* @__PURE__ */ g("div", { children: Le.map((e) => /* @__PURE__ */ _("div", {
30637
+ onClick: () => Ke(e),
30638
+ style: {
30639
+ padding: "16px 20px",
30640
+ borderBottom: "1px solid #f3f4f6",
30641
+ cursor: "pointer",
30642
+ transition: "background 0.15s ease"
30643
+ },
30644
+ onMouseEnter: (e) => e.currentTarget.style.background = "#f9fafb",
30645
+ onMouseLeave: (e) => e.currentTarget.style.background = "white",
30646
+ children: [/* @__PURE__ */ _("div", {
30647
+ style: {
30648
+ fontSize: "12px",
30649
+ color: "#6b7280",
30650
+ marginBottom: "6px",
30651
+ fontWeight: 500
30652
+ },
30653
+ children: [
30654
+ new Date(e.createdAt).toLocaleDateString(void 0, {
30655
+ month: "short",
30656
+ day: "numeric"
30657
+ }),
30658
+ " at ",
30659
+ new Date(e.createdAt).toLocaleTimeString([], {
30660
+ hour: "2-digit",
30661
+ minute: "2-digit"
30662
+ })
30663
+ ]
30664
+ }), /* @__PURE__ */ g("div", {
30665
+ style: {
30666
+ fontSize: "14.5px",
30667
+ color: "#111827",
30668
+ opacity: .9,
30669
+ overflow: "hidden",
30670
+ textOverflow: "ellipsis",
30671
+ display: "-webkit-box",
30672
+ WebkitLineClamp: 2,
30673
+ WebkitBoxOrient: "vertical",
30674
+ lineHeight: 1.4
30675
+ },
30676
+ children: e.message || "Conversation"
30677
+ })]
30678
+ }, e.chatId)) }) : /* @__PURE__ */ g("div", {
30679
+ style: {
30680
+ padding: "40px 20px",
30681
+ textAlign: "center",
30682
+ color: "#9ca3af",
30683
+ fontSize: "14px"
30684
+ },
30685
+ children: "No previous chats found."
30686
+ })
30687
+ })]
30688
+ }) : null, Ae ? /* @__PURE__ */ g(sD, {
30418
30689
  chatHistory: l,
30419
30690
  isAiTyping: u,
30420
- isLoading: w,
30691
+ isLoading: T,
30421
30692
  isAgentTyping: d,
30422
- setReplyContext: ue,
30693
+ setReplyContext: de,
30423
30694
  TypingDots: VO,
30424
30695
  primaryColor: n,
30425
- agentHeadshot: v,
30426
- agentDisplayName: h || y,
30696
+ agentHeadshot: y,
30697
+ agentDisplayName: v || b,
30427
30698
  botAvatarNode: /* @__PURE__ */ g(BO, { orbColors: t })
30428
30699
  }) : /* @__PURE__ */ _("div", {
30429
30700
  style: {
@@ -30485,7 +30756,7 @@ function HO({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
30485
30756
  }, e.id))
30486
30757
  })
30487
30758
  ]
30488
- })
30759
+ })]
30489
30760
  }),
30490
30761
  /* @__PURE__ */ g("div", {
30491
30762
  style: {
@@ -30493,29 +30764,29 @@ function HO({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
30493
30764
  flexShrink: 0,
30494
30765
  position: "relative",
30495
30766
  zIndex: 1,
30496
- padding: ae ? "6px 0 0" : "12px 0 0"
30767
+ padding: oe ? "6px 0 0" : "12px 0 0"
30497
30768
  },
30498
30769
  children: /* @__PURE__ */ g(cD, {
30499
- input: b,
30500
- setInput: x,
30501
- onSubmit: S,
30502
- isConversationEnded: C,
30503
- callUiActive: ke,
30504
- handleToggleVoice: we,
30770
+ input: x,
30771
+ setInput: S,
30772
+ onSubmit: C,
30773
+ isConversationEnded: w,
30774
+ callUiActive: Me,
30775
+ handleToggleVoice: Te,
30505
30776
  showVoiceToggle: f === "agent",
30506
30777
  activeScreen: f,
30507
- inputDisabled: Oe,
30508
- replyContext: le,
30509
- clearReplyContext: () => ue(null),
30510
- onFileSelect: ne,
30511
- selectedFile: te,
30512
- onRemoveSelectedFile: re,
30513
- attachmentError: E,
30514
- isUploadingAttachment: ie,
30515
- requiresEmail: ae,
30516
- emailInput: oe,
30517
- setEmailInput: se,
30518
- emailError: ce,
30778
+ inputDisabled: je,
30779
+ replyContext: ue,
30780
+ clearReplyContext: () => de(null),
30781
+ onFileSelect: re,
30782
+ selectedFile: ne,
30783
+ onRemoveSelectedFile: E,
30784
+ attachmentError: ie,
30785
+ isUploadingAttachment: ae,
30786
+ requiresEmail: oe,
30787
+ emailInput: se,
30788
+ setEmailInput: ce,
30789
+ emailError: le,
30519
30790
  inputPlaceholder: e.inputPlaceholder
30520
30791
  })
30521
30792
  }),
@@ -30526,7 +30797,7 @@ function HO({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
30526
30797
  padding: "12px 20px 18px",
30527
30798
  pointerEvents: "none"
30528
30799
  },
30529
- children: Ee && /* @__PURE__ */ _("span", {
30800
+ children: D && /* @__PURE__ */ _("span", {
30530
30801
  style: {
30531
30802
  fontSize: "11px",
30532
30803
  color: "#9ca3af",
@@ -30546,196 +30817,196 @@ function HO({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
30546
30817
  });
30547
30818
  }
30548
30819
  function UO() {
30549
- 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: ee, callConnectedAt: te, isCallMuted: ne, webRTCError: re, language: E, historyRef: ie, onMessageSync: ae, sendMessage: oe, uploadChatFile: se, openWidget: ce, captureVisitorEmail: le, setVoiceMode: ue, endConversation: de, startNewChat: fe, acceptCall: he, rejectCall: ge, endWebRTCCall: _e, toggleCallMute: ve, dismissCallError: ye, startTyping: be, stopTyping: xe, updateTypingDraft: Se } = gn();
30820
+ 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: ee, callConnectedAt: te, isCallMuted: ne, webRTCError: re, language: E, historyRef: ie, onMessageSync: ae, sendMessage: oe, uploadChatFile: se, openWidget: ce, captureVisitorEmail: le, setVoiceMode: ue, endConversation: de, startNewChat: fe, acceptCall: he, rejectCall: ge, endWebRTCCall: _e, toggleCallMute: ve, dismissCallError: ye, startTyping: be, stopTyping: xe, updateTypingDraft: Se, getVisitorChatHistory: Ce, getVisitorChatThread: we } = gn();
30550
30821
  c(() => {
30551
30822
  try {
30552
30823
  Vn();
30553
30824
  } catch {}
30554
30825
  }, []);
30555
- let Ce = t?.widgetSettings || {}, we = n?.widgetSettings || {}, Te = {
30556
- ...Ce.branding || {},
30557
- ...we.branding || {}
30558
- }, Ee = {
30559
- ...Ce.theme || {},
30560
- ...we.theme || {}
30561
- }, De = {
30562
- ...Ce.features || {},
30563
- ...we.features || {}
30564
- }, Oe = De.voice !== !1, ke = Array.isArray(Ee.orbColors) && Ee.orbColors.length > 0 ? Ee.orbColors : null, Ae = ke?.[0] || Ee.primaryColor || "#3B82F6", je = Ee.position || "bottom-right", Me = Te.fallbackAgentName || "Agent", Ne = jO(ke ?? Ee.chatBgColors), Pe = Te.logo || Te.logoUrl || null, Fe = E || "en", Ie = Ce.recommendations?.[Fe] || [], Le = (we.recommendations?.[Fe] ?? Ie).filter((e) => String(e?.label ?? "").trim()).map((e, t) => ({
30826
+ let Te = t?.widgetSettings || {}, Ee = n?.widgetSettings || {}, De = {
30827
+ ...Te.branding || {},
30828
+ ...Ee.branding || {}
30829
+ }, D = {
30830
+ ...Te.theme || {},
30831
+ ...Ee.theme || {}
30832
+ }, Oe = {
30833
+ ...Te.features || {},
30834
+ ...Ee.features || {}
30835
+ }, ke = Oe.voice !== !1, Ae = Array.isArray(D.orbColors) && D.orbColors.length > 0 ? D.orbColors : null, je = Ae?.[0] || D.primaryColor || "#3B82F6", Me = D.position || "bottom-right", Ne = De.fallbackAgentName || "Agent", Pe = jO(Ae ?? D.chatBgColors), Fe = De.logo || De.logoUrl || null, Ie = E || "en", Le = Te.recommendations?.[Ie] || [], Re = (Ee.recommendations?.[Ie] ?? Le).filter((e) => String(e?.label ?? "").trim()).map((e, t) => ({
30565
30836
  id: e.key || `qr-${t}`,
30566
30837
  label: e.label,
30567
30838
  message: e.label,
30568
30839
  text: e.label
30569
- })), Re = Array.isArray(Te.quickChatOptions) && Te.quickChatOptions.length > 0 ? Te.quickChatOptions : Le, ze = Te.hideWatermark === !0 ? !1 : Te.showPoweredBy !== !1, Be = Te.chatbotEnabled !== !1 && Ee.chatbotEnabled !== !1, D = Ce.greetings?.[E] || we.greetings?.[E] || Te.introGreeting || "Hello, I'm here to help you know more about OpenSense Labs.", Ve = {
30570
- entryPrompt: Te.entryPrompt || "Do you want to explore in a new way?",
30571
- yesLabel: Te.yesLabel || "Yes",
30572
- laterLabel: Te.laterLabel || "Later",
30573
- connectionTitle: Te.connectionTitle || "How would you like to connect?",
30574
- voiceLabel: Te.voiceLabel || "Voice",
30575
- textLabel: Te.textLabel || "Text",
30576
- chatTitle: Te.headerName || "Chat with FlowEngage",
30577
- introGreeting: D,
30578
- inputPlaceholder: Te.inputPlaceholder || "Type your message",
30579
- analysingLabel: Te.analysingLabel || "analysing..."
30580
- }, He = we.elevenLabsAgentId || t?.elevenLabsAgentId || null, Ue = t?.siteId || n?.siteId || null, We = t?.apiBaseUrl || "", Ge = f(() => l && String(l).trim() || t?.ownerName && String(t.ownerName).trim() || t?.websiteName && String(t.websiteName).trim() || "Agent", [
30840
+ })), ze = Array.isArray(De.quickChatOptions) && De.quickChatOptions.length > 0 ? De.quickChatOptions : Re, O = De.hideWatermark === !0 ? !1 : De.showPoweredBy !== !1, Be = De.chatbotEnabled !== !1 && D.chatbotEnabled !== !1, Ve = Te.greetings?.[E] || Ee.greetings?.[E] || De.introGreeting || "Hello, I'm here to help you know more about OpenSense Labs.", He = {
30841
+ entryPrompt: De.entryPrompt || "Do you want to explore in a new way?",
30842
+ yesLabel: De.yesLabel || "Yes",
30843
+ laterLabel: De.laterLabel || "Later",
30844
+ connectionTitle: De.connectionTitle || "How would you like to connect?",
30845
+ voiceLabel: De.voiceLabel || "Voice",
30846
+ textLabel: De.textLabel || "Text",
30847
+ chatTitle: De.headerName || "Chat with FlowEngage",
30848
+ introGreeting: Ve,
30849
+ inputPlaceholder: De.inputPlaceholder || "Type your message",
30850
+ analysingLabel: De.analysingLabel || "analysing..."
30851
+ }, Ue = Ee.elevenLabsAgentId || t?.elevenLabsAgentId || null, We = t?.siteId || n?.siteId || null, Ge = t?.apiBaseUrl || "", Ke = f(() => l && String(l).trim() || t?.ownerName && String(t.ownerName).trim() || t?.websiteName && String(t.websiteName).trim() || "Agent", [
30581
30852
  l,
30582
30853
  t?.ownerName,
30583
30854
  t?.websiteName
30584
- ]), Ke = u && String(u).trim() || t?.ownerProfileImageUrl && String(t.ownerProfileImageUrl).trim() || null, qe = r.some((e) => e.sender === "user"), Je = f(() => {
30855
+ ]), qe = u && String(u).trim() || t?.ownerProfileImageUrl && String(t.ownerProfileImageUrl).trim() || null, Je = r.some((e) => e.sender === "user"), Ye = f(() => {
30585
30856
  let e = r.findIndex((e) => e.sender === "user");
30586
30857
  return e === -1 ? !1 : r.slice(e + 1).some((e) => e.sender === "bot" || e.sender === "ai" || e.sender === "agent");
30587
- }, [r]), Ye = !h && qe && Je, Xe = !!(we._dashboardLivePreview || Ce._dashboardLivePreview), [O, Ze] = m(() => Xe ? "text_chat" : "entry_prompt"), [k, A] = m(""), [j, Qe] = m(null), [$e, et] = m(h || ""), [tt, nt] = m(""), [rt, it] = m(0), [at, ot] = m(null), [st, ct] = m(null), [lt, ut] = m(""), [dt, ft] = m(!1), [pt, mt] = m(!1), ht = p(null), gt = p(!1);
30858
+ }, [r]), Xe = !h && Je && Ye, Ze = !!(Ee._dashboardLivePreview || Te._dashboardLivePreview), [k, A] = m(() => Ze ? "text_chat" : "entry_prompt"), [j, Qe] = m(""), [$e, et] = m(null), [tt, nt] = m(h || ""), [rt, it] = m(""), [at, ot] = m(0), [st, ct] = m(null), [lt, ut] = m(null), [dt, ft] = m(""), [pt, mt] = m(!1), [ht, gt] = m(!1), _t = p(null), vt = p(!1);
30588
30859
  d(() => {
30589
- if (!(e !== "ready" || gt.current)) {
30590
- if (gt.current = !0, pe(Ue) || !Oe) {
30591
- Ze("minimized_orb");
30860
+ if (!(e !== "ready" || vt.current)) {
30861
+ if (vt.current = !0, pe(We) || !ke) {
30862
+ A("minimized_orb");
30592
30863
  return;
30593
30864
  }
30594
30865
  try {
30595
30866
  let { shouldResumeVoice: e } = qn();
30596
- e && Ze("connection_modal");
30867
+ e && A("connection_modal");
30597
30868
  } catch {}
30598
30869
  }
30599
30870
  }, [e, r]);
30600
- let [_t, vt] = m(() => typeof window < "u" && window.matchMedia("(max-width: 640px)").matches);
30871
+ let [yt, bt] = m(() => typeof window < "u" && window.matchMedia("(max-width: 640px)").matches);
30601
30872
  c(() => {
30602
- let e = window.matchMedia("(max-width: 640px)"), t = (e) => vt(e.matches);
30873
+ let e = window.matchMedia("(max-width: 640px)"), t = (e) => bt(e.matches);
30603
30874
  return e.addEventListener("change", t), () => e.removeEventListener("change", t);
30604
30875
  }, []), c(() => {
30605
- et(h || ""), h && nt("");
30876
+ nt(h || ""), h && it("");
30606
30877
  }, [h]);
30607
- let yt = o(() => {
30608
- ct(null), ut("");
30609
- }, []), bt = o((e) => {
30878
+ let xt = o(() => {
30879
+ ut(null), ft("");
30880
+ }, []), St = o((e) => {
30610
30881
  let t = nD(e);
30611
30882
  if (t) {
30612
- ct(null), ut(t);
30883
+ ut(null), ft(t);
30613
30884
  return;
30614
30885
  }
30615
- ct(e), ut("");
30886
+ ut(e), ft("");
30616
30887
  }, []);
30617
30888
  c(() => {
30618
30889
  if (!te || ee !== "connected") {
30619
- it(0);
30890
+ ot(0);
30620
30891
  return;
30621
30892
  }
30622
30893
  let e = () => {
30623
30894
  let e = new Date(te).getTime();
30624
- isNaN(e) || it(Math.max(0, Math.floor((Date.now() - e) / 1e3)));
30895
+ isNaN(e) || ot(Math.max(0, Math.floor((Date.now() - e) / 1e3)));
30625
30896
  };
30626
30897
  e();
30627
30898
  let t = window.setInterval(e, 1e3);
30628
30899
  return () => window.clearInterval(t);
30629
30900
  }, [te, ee]);
30630
- let xt = o(() => {
30631
- Ze("call_screen"), mt(!1);
30632
- }, []), St = o(() => {
30633
- Ze("text_chat"), mt(!0);
30901
+ let Ct = o(() => {
30902
+ A("call_screen"), gt(!1);
30903
+ }, []), wt = o(() => {
30904
+ A("text_chat"), gt(!0);
30634
30905
  }, []);
30635
30906
  c(() => {
30636
30907
  let e = w?.callId || T || null;
30637
30908
  if (!e) {
30638
- ht.current = null;
30909
+ _t.current = null;
30639
30910
  return;
30640
30911
  }
30641
30912
  if (w?.callId || ee === "connecting" || ee === "connected") {
30642
- if (O === "minimized_orb" && pt && T && !w?.callId) {
30643
- ht.current = e;
30913
+ if (k === "minimized_orb" && ht && T && !w?.callId) {
30914
+ _t.current = e;
30644
30915
  return;
30645
30916
  }
30646
- !(!i || O === "minimized_orb" || O === "voice_mode") && ht.current === e || (console.log("[FlowEngageWidget] forcing call UI to front", {
30917
+ !(!i || k === "minimized_orb" || k === "voice_mode") && _t.current === e || (console.log("[FlowEngageWidget] forcing call UI to front", {
30647
30918
  forcedKey: e,
30648
30919
  isOpen: i,
30649
- surface: O,
30920
+ surface: k,
30650
30921
  hasIncomingCall: !!w?.callId,
30651
30922
  activeCallId: T,
30652
30923
  callConnectionState: ee
30653
- }), ht.current = e, O === "voice_mode" && ue?.(!1), ce?.(), xt());
30924
+ }), _t.current = e, k === "voice_mode" && ue?.(!1), ce?.(), Ct());
30654
30925
  }
30655
30926
  }, [
30656
30927
  T,
30657
30928
  ee,
30658
- xt,
30929
+ Ct,
30659
30930
  w?.callId,
30660
30931
  i,
30661
30932
  ce,
30662
30933
  ue,
30663
- O
30934
+ k
30664
30935
  ]), c(() => {
30665
- !w && !T && O === "call_screen" && Ze("text_chat");
30936
+ !w && !T && k === "call_screen" && A("text_chat");
30666
30937
  }, [
30667
30938
  w,
30668
30939
  T,
30669
- O
30940
+ k
30670
30941
  ]), c(() => {
30671
- !T && pt && mt(!1);
30672
- }, [T, pt]), c(() => {
30942
+ !T && ht && gt(!1);
30943
+ }, [T, ht]), c(() => {
30673
30944
  if (!s || C) {
30674
30945
  Se?.(""), xe?.();
30675
30946
  return;
30676
30947
  }
30677
- if (!k.trim() || st) {
30948
+ if (!j.trim() || lt) {
30678
30949
  Se?.("");
30679
30950
  let e = window.setTimeout(() => xe?.(), 100);
30680
30951
  return () => window.clearTimeout(e);
30681
30952
  }
30682
30953
  be?.();
30683
- let e = window.setTimeout(() => Se?.(k), 120), t = window.setTimeout(() => xe?.(), 1200);
30954
+ let e = window.setTimeout(() => Se?.(j), 120), t = window.setTimeout(() => xe?.(), 1200);
30684
30955
  return () => {
30685
30956
  window.clearTimeout(e), window.clearTimeout(t);
30686
30957
  };
30687
30958
  }, [
30688
- k,
30689
- st,
30959
+ j,
30960
+ lt,
30690
30961
  s,
30691
30962
  C,
30692
30963
  be,
30693
30964
  xe,
30694
30965
  Se
30695
30966
  ]);
30696
- let Ct = (e) => e ? {
30967
+ let Tt = (e) => e ? {
30697
30968
  replyTo: e.messageId || e.id || null,
30698
30969
  replyToContent: (e.replyToContent || e.message || "").replace(/<[^>]+>/g, "").trim().slice(0, 200),
30699
30970
  replyToSender: e.sender || null
30700
- } : null, wt = async (e) => {
30971
+ } : null, Et = async (e) => {
30701
30972
  if (e.preventDefault(), C) return;
30702
- if (Ye) {
30703
- let e = $e.trim().toLowerCase();
30973
+ if (Xe) {
30974
+ let e = tt.trim().toLowerCase();
30704
30975
  if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e)) {
30705
- nt("Please enter a valid email so we can continue helping you.");
30976
+ it("Please enter a valid email so we can continue helping you.");
30706
30977
  return;
30707
30978
  }
30708
- await le(e), nt("");
30979
+ await le(e), it("");
30709
30980
  return;
30710
30981
  }
30711
- let t = Ct(j);
30712
- if (!k.trim() && !st) return;
30713
- if (st) {
30982
+ let t = Tt($e);
30983
+ if (!j.trim() && !lt) return;
30984
+ if (lt) {
30714
30985
  try {
30715
- ft(!0), ut("");
30716
- let e = await se(st), n = e?.data || e, r = k.trim() || `Shared file: ${iD(st)}`;
30717
- A(""), Qe(null), yt(), await oe(r, "", t, {
30986
+ mt(!0), ft("");
30987
+ let e = await se(lt), n = e?.data || e, r = j.trim() || `Shared file: ${iD(lt)}`;
30988
+ Qe(""), et(null), xt(), await oe(r, "", t, {
30718
30989
  type: "file",
30719
30990
  metadata: {
30720
30991
  fileUrl: n?.fileUrl,
30721
- fileName: n?.fileName || st.name,
30722
- fileType: n?.fileType || st.type,
30723
- fileSize: n?.fileSize || st.size
30992
+ fileName: n?.fileName || lt.name,
30993
+ fileType: n?.fileType || lt.type,
30994
+ fileSize: n?.fileSize || lt.size
30724
30995
  }
30725
30996
  });
30726
30997
  } catch (e) {
30727
- ut(e?.message || "Failed to upload the selected file.");
30998
+ ft(e?.message || "Failed to upload the selected file.");
30728
30999
  } finally {
30729
- ft(!1);
31000
+ mt(!1);
30730
31001
  }
30731
31002
  return;
30732
31003
  }
30733
- let n = k.trim();
30734
- A(""), Qe(null), await oe(n, "", t);
30735
- }, Tt = (e) => {
31004
+ let n = j.trim();
31005
+ Qe(""), et(null), await oe(n, "", t);
31006
+ }, Dt = (e) => {
30736
31007
  let t = Math.floor(e / 60);
30737
31008
  return `${String(t).padStart(2, "0")}:${String(e % 60).padStart(2, "0")}`;
30738
- }, Et = o(async (e) => {
31009
+ }, Ot = o(async (e) => {
30739
31010
  if (C || b) return;
30740
31011
  let t = e.message || e.label || e.text || "";
30741
31012
  t.trim() && await oe(t.trim(), "");
@@ -30743,67 +31014,67 @@ function UO() {
30743
31014
  C,
30744
31015
  b,
30745
31016
  oe
30746
- ]), Dt = _t && O === "entry_prompt" ? { inset: 0 } : _t && O === "text_chat" ? {
31017
+ ]), kt = yt && k === "entry_prompt" ? { inset: 0 } : yt && k === "text_chat" ? {
30747
31018
  left: 0,
30748
31019
  right: 0,
30749
31020
  bottom: 0
30750
- } : _t && O === "call_screen" ? {
31021
+ } : yt && k === "call_screen" ? {
30751
31022
  left: 0,
30752
31023
  right: 0,
30753
31024
  bottom: 0,
30754
31025
  height: "90dvh",
30755
31026
  overflow: "hidden",
30756
31027
  borderRadius: "16px 16px 0 0"
30757
- } : _t && O === "connection_modal" ? {
31028
+ } : yt && k === "connection_modal" ? {
30758
31029
  left: "28px",
30759
31030
  right: "12px",
30760
31031
  bottom: "12px"
30761
- } : O === "call_screen" ? {
31032
+ } : k === "call_screen" ? {
30762
31033
  width: "min(350px, calc(100vw - 40px))",
30763
31034
  height: "min(640px, calc(100vh - 120px))",
30764
31035
  borderRadius: "22px",
30765
31036
  overflow: "hidden",
30766
- ...je === "bottom-left" ? {
31037
+ ...Me === "bottom-left" ? {
30767
31038
  left: "1.5rem",
30768
31039
  bottom: "1.5rem"
30769
31040
  } : {
30770
31041
  right: "1.5rem",
30771
31042
  bottom: "1.5rem"
30772
31043
  }
30773
- } : je === "bottom-left" ? {
31044
+ } : Me === "bottom-left" ? {
30774
31045
  left: "1.5rem",
30775
31046
  bottom: "1.5rem"
30776
31047
  } : {
30777
31048
  right: "1.5rem",
30778
31049
  bottom: "1.5rem"
30779
- }, Ot = () => Ze("minimized_orb"), kt = () => Ze("connection_modal"), At = () => {
30780
- ce({ notifyChatInitiated: !0 }), ue?.(!0), Ze("voice_mode");
30781
- }, jt = () => {
30782
- ce({ notifyChatInitiated: !0 }), ue?.(!1), Ze("text_chat");
30783
- }, Mt = () => {
30784
- ue?.(!1), Ot();
31050
+ }, At = () => A("minimized_orb"), jt = () => A("connection_modal"), Mt = () => {
31051
+ ce({ notifyChatInitiated: !0 }), ue?.(!0), A("voice_mode");
31052
+ }, Nt = () => {
31053
+ ce({ notifyChatInitiated: !0 }), ue?.(!1), A("text_chat");
31054
+ }, Pt = () => {
31055
+ ue?.(!1), At();
30785
31056
  };
30786
- return e !== "ready" || !Be || De.chat === !1 ? null : /* @__PURE__ */ _("div", {
31057
+ return e !== "ready" || !Be || Oe.chat === !1 ? null : /* @__PURE__ */ _("div", {
30787
31058
  className: "flowengage-widget-root",
30788
31059
  style: {
30789
31060
  position: "fixed",
30790
31061
  zIndex: 999999,
30791
- ...Dt
31062
+ ...kt
30792
31063
  },
30793
31064
  children: [
30794
- O === "entry_prompt" && /* @__PURE__ */ g(LO, {
30795
- copy: Ve,
30796
- orbColors: ke,
30797
- primaryColor: Ae,
31065
+ k === "entry_prompt" && /* @__PURE__ */ g(LO, {
31066
+ copy: He,
31067
+ orbColors: Ae,
31068
+ primaryColor: je,
30798
31069
  onYes: () => {
30799
- me(Ue), At();
31070
+ me(We), Mt();
30800
31071
  },
30801
31072
  onLater: () => {
30802
- me(Ue), Ot();
31073
+ me(We), At();
30803
31074
  },
30804
- isMobile: _t
31075
+ isMobile: yt
30805
31076
  }),
30806
- O === "minimized_orb" && /* @__PURE__ */ _(Wp.div, {
31077
+ k === "minimized_orb" && /* @__PURE__ */ _(Wp.div, {
30807
31078
  layoutId: "fe-main-orb",
30808
31079
  initial: { scale: 94 / 50 },
30809
31080
  animate: { scale: 1 },
@@ -30816,14 +31087,14 @@ function UO() {
30816
31087
  transformOrigin: "bottom right",
30817
31088
  display: "inline-flex",
30818
31089
  flexDirection: "column",
30819
- alignItems: je === "bottom-left" ? "flex-start" : "flex-end",
31090
+ alignItems: Me === "bottom-left" ? "flex-start" : "flex-end",
30820
31091
  gap: "10px"
30821
31092
  },
30822
- children: [T && pt && /* @__PURE__ */ _("button", {
31093
+ children: [T && ht && /* @__PURE__ */ _("button", {
30823
31094
  type: "button",
30824
- onClick: xt,
31095
+ onClick: Ct,
30825
31096
  style: {
30826
- maxWidth: _t ? "220px" : "240px",
31097
+ maxWidth: yt ? "220px" : "240px",
30827
31098
  padding: "10px 14px",
30828
31099
  borderRadius: "18px",
30829
31100
  border: "1px solid rgba(255,255,255,0.7)",
@@ -30864,105 +31135,107 @@ function UO() {
30864
31135
  marginTop: "2px",
30865
31136
  whiteSpace: "nowrap"
30866
31137
  },
30867
- children: ee === "connected" ? `${Tt(rt)} with ${Ge}` : `Tap to return to ${Ge}`
31138
+ children: ee === "connected" ? `${Dt(at)} with ${Ke}` : `Tap to return to ${Ke}`
30868
31139
  })]
30869
31140
  })]
30870
31141
  }), /* @__PURE__ */ g(IO, {
30871
31142
  size: 50,
30872
- orbColors: ke,
30873
- onClick: T && pt ? xt : Oe ? kt : jt
31143
+ orbColors: Ae,
31144
+ onClick: T && ht ? Ct : ke ? jt : Nt
30874
31145
  })]
30875
31146
  }),
30876
- O === "connection_modal" && /* @__PURE__ */ g(RO, {
30877
- copy: Ve,
30878
- orbColors: ke,
30879
- primaryColor: Ae,
30880
- onVoice: At,
30881
- onText: jt,
30882
- onClose: Ot,
30883
- isMobile: _t
31147
+ k === "connection_modal" && /* @__PURE__ */ g(RO, {
31148
+ copy: He,
31149
+ orbColors: Ae,
31150
+ primaryColor: je,
31151
+ onVoice: Mt,
31152
+ onText: Nt,
31153
+ onClose: At,
31154
+ isMobile: yt
30884
31155
  }),
30885
- O === "voice_mode" && /* @__PURE__ */ g(zO, {
30886
- orbColors: ke,
30887
- onEnterChat: jt,
30888
- onEndChat: Mt,
30889
- agentId: He,
30890
- siteId: Ue,
30891
- apiBaseUrl: We,
31156
+ k === "voice_mode" && /* @__PURE__ */ g(zO, {
31157
+ orbColors: Ae,
31158
+ onEnterChat: Nt,
31159
+ onEndChat: Pt,
31160
+ agentId: Ue,
31161
+ siteId: We,
31162
+ apiBaseUrl: Ge,
30892
31163
  historyRef: ie,
30893
31164
  onMessageSync: ae
30894
31165
  }, "voice"),
30895
- O === "call_screen" && /* @__PURE__ */ g(TD, {
31166
+ k === "call_screen" && /* @__PURE__ */ g(TD, {
30896
31167
  incomingCall: w,
30897
31168
  activeCallId: T,
30898
31169
  callConnectionState: ee,
30899
- callDurationSeconds: rt,
31170
+ callDurationSeconds: at,
30900
31171
  isCallMuted: ne,
30901
- agentName: Ge,
30902
- agentHeadshot: Ke,
30903
- fallbackAgentName: Me,
31172
+ agentName: Ke,
31173
+ agentHeadshot: qe,
31174
+ fallbackAgentName: Ne,
30904
31175
  acceptCall: he,
30905
31176
  rejectCall: ge,
30906
31177
  endWebRTCCall: _e,
30907
31178
  toggleCallMute: ve,
30908
- formatCallDuration: Tt,
30909
- onMinimize: St,
30910
- primaryColor: Ae,
30911
- orbColors: ke,
31179
+ formatCallDuration: Dt,
31180
+ onMinimize: wt,
31181
+ primaryColor: je,
31182
+ orbColors: Ae,
30912
31183
  chatHistory: r
30913
31184
  }),
30914
- O === "text_chat" && /* @__PURE__ */ g(HO, {
30915
- copy: Ve,
30916
- orbColors: ke,
30917
- primaryColor: Ae,
30918
- chatBgGradient: Ne,
30919
- logo: Pe,
30920
- quickChatOptions: Re,
30921
- onQuickChatSelect: Et,
30922
- isMobile: _t,
31185
+ k === "text_chat" && /* @__PURE__ */ g(HO, {
31186
+ copy: He,
31187
+ orbColors: Ae,
31188
+ primaryColor: je,
31189
+ chatBgGradient: Pe,
31190
+ logo: Fe,
31191
+ quickChatOptions: ze,
31192
+ onQuickChatSelect: Ot,
31193
+ isMobile: yt,
30923
31194
  chatHistory: r,
30924
31195
  isAiTyping: y,
30925
31196
  isAgentTyping: v,
30926
31197
  activeScreen: a,
30927
- agentName: Ge,
30928
- agentHeadshot: Ke,
30929
- fallbackAgentName: Me,
30930
- input: k,
30931
- setInput: A,
30932
- onSubmit: wt,
31198
+ agentName: Ke,
31199
+ agentHeadshot: qe,
31200
+ fallbackAgentName: Ne,
31201
+ input: j,
31202
+ setInput: Qe,
31203
+ onSubmit: Et,
30933
31204
  isConversationEnded: C,
30934
31205
  isLoading: b,
30935
31206
  isRateLimited: x,
30936
31207
  rateLimitMessage: S,
30937
- selectedFile: st,
30938
- onFileSelect: bt,
30939
- onRemoveSelectedFile: yt,
30940
- attachmentError: lt,
30941
- isUploadingAttachment: dt,
30942
- requiresEmail: Ye,
30943
- emailInput: $e,
30944
- setEmailInput: et,
30945
- emailError: tt,
30946
- replyContext: j,
30947
- setReplyContext: Qe,
31208
+ selectedFile: lt,
31209
+ onFileSelect: St,
31210
+ onRemoveSelectedFile: xt,
31211
+ attachmentError: dt,
31212
+ isUploadingAttachment: pt,
31213
+ requiresEmail: Xe,
31214
+ emailInput: tt,
31215
+ setEmailInput: nt,
31216
+ emailError: rt,
31217
+ replyContext: $e,
31218
+ setReplyContext: et,
30948
31219
  webRTCError: re,
30949
- micError: at,
30950
- setMicError: ot,
31220
+ micError: st,
31221
+ setMicError: ct,
30951
31222
  dismissCallError: ye,
30952
31223
  activeCallId: T,
30953
31224
  isCallMuted: ne,
30954
31225
  toggleCallMute: ve,
30955
31226
  endWebRTCCall: _e,
30956
- formatCallDuration: Tt,
30957
- callDurationSeconds: rt,
30958
- onCollapse: Ot,
30959
- onStartVoice: At,
31227
+ formatCallDuration: Dt,
31228
+ callDurationSeconds: at,
31229
+ onCollapse: At,
31230
+ onStartVoice: Mt,
30960
31231
  onNewChat: fe,
30961
31232
  onEndConversation: de,
30962
- onMinimize: St,
30963
- onExpand: xt,
30964
- isCallMinimized: pt && !!T,
30965
- showPoweredBy: ze
31233
+ onMinimize: wt,
31234
+ onExpand: Ct,
31235
+ isCallMinimized: ht && !!T,
31236
+ showPoweredBy: O,
31237
+ getVisitorChatHistory: Ce,
31238
+ getVisitorChatThread: we
30966
31239
  }),
30967
31240
  /* @__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-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 " })
30968
31241
  ]