@alxxsck/ai-assistant 2.24.0 → 2.24.2

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.
@@ -1,7 +1,7 @@
1
1
  import { jsx as H, jsxs as lt, Fragment as Mi } from "react/jsx-runtime";
2
2
  import * as M from "react";
3
- import Qr, { createContext as Yn, useContext as Or, useState as he, useRef as U, useMemo as un, useEffect as K, useCallback as le, useId as Ki, useLayoutEffect as Cn, memo as bl, useSyncExternalStore as ou, Suspense as Cl, lazy as yl, Component as Il, createElement as No } from "react";
4
- import { l as re, L as At, a as vl, n as Al, g as wl, i as Sl, P as El, S as kl, b as xl, c as Tl, o as Rl } from "./index-WDFSbfaV.js";
3
+ import Qr, { createContext as Yn, useContext as Or, useState as he, useRef as U, useMemo as un, useEffect as Y, useCallback as le, useId as Ki, useLayoutEffect as Cn, memo as bl, useSyncExternalStore as ou, Suspense as Cl, lazy as yl, Component as Il, createElement as No } from "react";
4
+ import { l as re, L as At, a as vl, n as Al, g as wl, i as Sl, P as El, S as kl, b as xl, c as Tl, o as Rl } from "./index-Daw1CgNA.js";
5
5
  import { createRoot as Ml } from "react-dom/client";
6
6
  function Lo(t) {
7
7
  return typeof t == "object" && t != null && "pathname" in t && "search" in t && "hash" in t && "state" in t && "key" in t;
@@ -952,7 +952,7 @@ function Ed({
952
952
  }
953
953
  );
954
954
  }
955
- function gy({
955
+ function my({
956
956
  to: t,
957
957
  replace: e,
958
958
  state: n,
@@ -1044,7 +1044,7 @@ function xd({
1044
1044
  `<Router basename="${a}"> is not able to match the URL "${c}${l}${d}" because it does not start with the basename, so the <Router> won't render anything.`
1045
1045
  ), m == null ? null : /* @__PURE__ */ M.createElement(ot.Provider, { value: u }, /* @__PURE__ */ M.createElement(Br.Provider, { children: e, value: m }));
1046
1046
  }
1047
- function by({
1047
+ function gy({
1048
1048
  children: t,
1049
1049
  location: e
1050
1050
  }) {
@@ -1470,20 +1470,20 @@ var Au = /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i, wu = M.forwardRef(
1470
1470
  }, m) {
1471
1471
  let { basename: g, navigator: C, unstable_useTransitions: b } = M.useContext(ot), I = typeof l == "string" && Au.test(l), S = du(l, g);
1472
1472
  l = S.to;
1473
- let y = ld(l, { relative: s }), E = wt(), x = null;
1473
+ let y = ld(l, { relative: s }), E = wt(), k = null;
1474
1474
  if (a) {
1475
- let V = Os(
1475
+ let B = Os(
1476
1476
  a,
1477
1477
  [],
1478
1478
  E.unstable_mask ? E.unstable_mask.pathname : "/",
1479
1479
  !0
1480
1480
  );
1481
- g !== "/" && (V.pathname = V.pathname === "/" ? g : Lt([g, V.pathname])), x = C.createHref(V);
1481
+ g !== "/" && (B.pathname = B.pathname === "/" ? g : Lt([g, B.pathname])), k = C.createHref(B);
1482
1482
  }
1483
- let [O, N, _] = Hd(
1483
+ let [P, F, _] = Hd(
1484
1484
  r,
1485
1485
  f
1486
- ), P = eh(l, {
1486
+ ), O = eh(l, {
1487
1487
  replace: o,
1488
1488
  unstable_mask: a,
1489
1489
  state: u,
@@ -1494,25 +1494,25 @@ var Au = /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i, wu = M.forwardRef(
1494
1494
  unstable_defaultShouldRevalidate: h,
1495
1495
  unstable_useTransitions: b
1496
1496
  });
1497
- function B(V) {
1498
- e && e(V), V.defaultPrevented || P(V);
1497
+ function V(B) {
1498
+ e && e(B), B.defaultPrevented || O(B);
1499
1499
  }
1500
- let ne = !(S.isExternal || i), q = (
1500
+ let q = !(S.isExternal || i), K = (
1501
1501
  // eslint-disable-next-line jsx-a11y/anchor-has-content
1502
1502
  /* @__PURE__ */ M.createElement(
1503
1503
  "a",
1504
1504
  {
1505
1505
  ...f,
1506
1506
  ..._,
1507
- href: (ne ? x : void 0) || S.absoluteURL || y,
1508
- onClick: ne ? B : e,
1509
- ref: Kd(m, N),
1507
+ href: (q ? k : void 0) || S.absoluteURL || y,
1508
+ onClick: q ? V : e,
1509
+ ref: Kd(m, F),
1510
1510
  target: c,
1511
1511
  "data-discover": !I && n === "render" ? "true" : void 0
1512
1512
  }
1513
1513
  )
1514
1514
  );
1515
- return O && !I ? /* @__PURE__ */ M.createElement(M.Fragment, null, q, /* @__PURE__ */ M.createElement(Xd, { page: y })) : q;
1515
+ return P && !I ? /* @__PURE__ */ M.createElement(M.Fragment, null, K, /* @__PURE__ */ M.createElement(Xd, { page: y })) : K;
1516
1516
  }
1517
1517
  );
1518
1518
  wu.displayName = "Link";
@@ -1533,30 +1533,30 @@ var Jd = M.forwardRef(
1533
1533
  ih(d) && a === !0, C = f.encodeLocation ? f.encodeLocation(d).pathname : d.pathname, b = p.pathname, I = h && h.navigation && h.navigation.location ? h.navigation.location.pathname : null;
1534
1534
  n || (b = b.toLowerCase(), I = I ? I.toLowerCase() : null, C = C.toLowerCase()), I && m && (I = jt(I, m) || I);
1535
1535
  const S = C !== "/" && C.endsWith("/") ? C.length - 1 : C.length;
1536
- let y = b === C || !s && b.startsWith(C) && b.charAt(S) === "/", E = I != null && (I === C || !s && I.startsWith(C) && I.charAt(C.length) === "/"), x = {
1536
+ let y = b === C || !s && b.startsWith(C) && b.charAt(S) === "/", E = I != null && (I === C || !s && I.startsWith(C) && I.charAt(C.length) === "/"), k = {
1537
1537
  isActive: y,
1538
1538
  isPending: E,
1539
1539
  isTransitioning: g
1540
- }, O = y ? e : void 0, N;
1541
- typeof r == "function" ? N = r(x) : N = [
1540
+ }, P = y ? e : void 0, F;
1541
+ typeof r == "function" ? F = r(k) : F = [
1542
1542
  r,
1543
1543
  y ? "active" : null,
1544
1544
  E ? "pending" : null,
1545
1545
  g ? "transitioning" : null
1546
1546
  ].filter(Boolean).join(" ");
1547
- let _ = typeof i == "function" ? i(x) : i;
1547
+ let _ = typeof i == "function" ? i(k) : i;
1548
1548
  return /* @__PURE__ */ M.createElement(
1549
1549
  wu,
1550
1550
  {
1551
1551
  ...c,
1552
- "aria-current": O,
1553
- className: N,
1552
+ "aria-current": P,
1553
+ className: F,
1554
1554
  ref: l,
1555
1555
  style: _,
1556
1556
  to: o,
1557
1557
  viewTransition: a
1558
1558
  },
1559
- typeof u == "function" ? u(x) : u
1559
+ typeof u == "function" ? u(k) : u
1560
1560
  );
1561
1561
  }
1562
1562
  );
@@ -1581,9 +1581,9 @@ var Qd = M.forwardRef(
1581
1581
  let { unstable_useTransitions: m } = M.useContext(ot), g = rh(), C = sh(a, { relative: c }), b = o.toLowerCase() === "get" ? "get" : "post", I = typeof a == "string" && Au.test(a), S = (y) => {
1582
1582
  if (u && u(y), y.defaultPrevented) return;
1583
1583
  y.preventDefault();
1584
- let E = y.nativeEvent.submitter, x = E?.getAttribute("formmethod") || o, O = () => g(E || y.currentTarget, {
1584
+ let E = y.nativeEvent.submitter, k = E?.getAttribute("formmethod") || o, P = () => g(E || y.currentTarget, {
1585
1585
  fetcherKey: e,
1586
- method: x,
1586
+ method: k,
1587
1587
  navigate: n,
1588
1588
  replace: s,
1589
1589
  state: i,
@@ -1592,7 +1592,7 @@ var Qd = M.forwardRef(
1592
1592
  viewTransition: d,
1593
1593
  unstable_defaultShouldRevalidate: p
1594
1594
  });
1595
- m && n !== !1 ? M.startTransition(() => O()) : O();
1595
+ m && n !== !1 ? M.startTransition(() => P()) : P();
1596
1596
  };
1597
1597
  return /* @__PURE__ */ M.createElement(
1598
1598
  "form",
@@ -2988,16 +2988,16 @@ function wh(t, e) {
2988
2988
  historyTimestamp: S,
2989
2989
  protocolOptions: y,
2990
2990
  concurrentSubscribes: E,
2991
- performFailures: x,
2992
- transportConfigurator: O,
2993
- auth: N
2991
+ performFailures: k,
2992
+ transportConfigurator: P,
2993
+ auth: F
2994
2994
  } = e;
2995
2995
  if (c = c || new Gr(u), typeof n == "string") {
2996
2996
  b = b || n;
2997
- let B = n.substring(0, n.lastIndexOf("-")), ne = n.substring(n.lastIndexOf("-") + 1);
2998
- if (y = y || {}, B === "actioncable-v1")
2997
+ let V = n.substring(0, n.lastIndexOf("-")), q = n.substring(n.lastIndexOf("-") + 1);
2998
+ if (y = y || {}, V === "actioncable-v1")
2999
2999
  n = new Tu({ logger: c, ...y });
3000
- else if (B === "actioncable-v1-ext")
3000
+ else if (V === "actioncable-v1-ext")
3001
3001
  n = new mh({
3002
3002
  logger: c,
3003
3003
  historyTimestamp: S,
@@ -3005,14 +3005,14 @@ function wh(t, e) {
3005
3005
  });
3006
3006
  else
3007
3007
  throw Error(`Protocol is not supported yet: ${n}`);
3008
- if (ne === "json")
3008
+ if (q === "json")
3009
3009
  d = d || new fh(), s = s || "text";
3010
- else if (ne === "msgpack") {
3010
+ else if (q === "msgpack") {
3011
3011
  if (s = "binary", !d)
3012
3012
  throw Error(
3013
3013
  "Msgpack encoder must be specified explicitly. Use `@anycable/msgpack-encoder` package or build your own"
3014
3014
  );
3015
- } else if (ne === "protobuf") {
3015
+ } else if (q === "protobuf") {
3016
3016
  if (s = s || "binary", !d)
3017
3017
  throw Error(
3018
3018
  "Protobuf encoder must be specified explicitly. Use `@anycable/protobuf-encoder` package or build your own"
@@ -3027,32 +3027,32 @@ function wh(t, e) {
3027
3027
  subprotocol: b,
3028
3028
  authStrategy: o,
3029
3029
  format: s
3030
- }), a && (l = new vh([l, ...a], { logger: c })), N && N.token && l.setToken(N.token, N.param || "jid"), m = m || Ru(f), h !== !1 && (h = h || new Mu({
3030
+ }), a && (l = new vh([l, ...a], { logger: c })), F && F.token && l.setToken(F.token, F.param || "jid"), m = m || Ru(f), h !== !1 && (h = h || new Mu({
3031
3031
  pingInterval: f,
3032
3032
  reconnectStrategy: m,
3033
3033
  maxMissingPings: g,
3034
3034
  maxReconnectAttempts: C,
3035
3035
  logger: c
3036
3036
  }));
3037
- let _ = { concurrentSubscribes: E }, P = new yh({
3037
+ let _ = { concurrentSubscribes: E }, O = new yh({
3038
3038
  protocol: n,
3039
3039
  transport: l,
3040
3040
  encoder: d,
3041
3041
  logger: c,
3042
3042
  lazy: p,
3043
3043
  hubOptions: _,
3044
- performFailures: x,
3045
- transportConfigurator: O
3044
+ performFailures: k,
3045
+ transportConfigurator: P
3046
3046
  });
3047
- return h && (h.watch(P), P.monitor = h), I && Sh(P, async () => {
3047
+ return h && (h.watch(O), O.monitor = h), I && Sh(O, async () => {
3048
3048
  try {
3049
3049
  await I(l);
3050
- } catch (B) {
3051
- return c.error("Failed to refresh authentication token: " + B), !1;
3050
+ } catch (V) {
3051
+ return c.error("Failed to refresh authentication token: " + V), !1;
3052
3052
  }
3053
- return P.connect().catch(() => {
3053
+ return O.connect().catch(() => {
3054
3054
  }), !0;
3055
- }), P;
3055
+ }), O;
3056
3056
  }
3057
3057
  function Sh(t, e) {
3058
3058
  let n = !1;
@@ -3250,7 +3250,7 @@ const Ht = {
3250
3250
  agentResponseFailed: "error.agentResponseFailed",
3251
3251
  sendMessageFallback: "error.sendMessageFailed",
3252
3252
  conversationClosed: "error.conversationClosed"
3253
- }, Vh = new Set(Object.values(Ht)), yy = (t, e) => Vh.has(t) ? e(t) : t, Iy = {
3253
+ }, Vh = new Set(Object.values(Ht)), Cy = (t, e) => Vh.has(t) ? e(t) : t, yy = {
3254
3254
  audio_playback_failed: "voice.audioPlaybackFailed",
3255
3255
  session_failed: "voice.sessionFailed",
3256
3256
  connection_closed: "voice.connectionClosed",
@@ -5024,8 +5024,8 @@ function Rf(t, e) {
5024
5024
  break;
5025
5025
  if (y.single === f && r[n].level === a) {
5026
5026
  y = r[n];
5027
- let E, x;
5028
- f ? (E = e.md.options.quotes[2], x = e.md.options.quotes[3]) : (E = e.md.options.quotes[0], x = e.md.options.quotes[1]), es(s, i, d.index, x), es(s, y.token, y.pos, E), r.length = n;
5027
+ let E, k;
5028
+ f ? (E = e.md.options.quotes[2], k = e.md.options.quotes[3]) : (E = e.md.options.quotes[0], k = e.md.options.quotes[1]), es(s, i, d.index, k), es(s, y.token, y.pos, E), r.length = n;
5029
5029
  continue e;
5030
5030
  }
5031
5031
  }
@@ -5232,7 +5232,7 @@ function Ff(t, e, n, r) {
5232
5232
  let b, I = 0;
5233
5233
  for (s = e + 2; s < n && !(t.sCount[s] < t.blkIndent); s++) {
5234
5234
  let S = !1;
5235
- for (let E = 0, x = h.length; E < x; E++)
5235
+ for (let E = 0, k = h.length; E < k; E++)
5236
5236
  if (h[E](t, s, n, !0)) {
5237
5237
  S = !0;
5238
5238
  break;
@@ -5246,10 +5246,10 @@ function Ff(t, e, n, r) {
5246
5246
  const y = t.push("tr_open", "tr", 1);
5247
5247
  y.map = [s, s + 1];
5248
5248
  for (let E = 0; E < d; E++) {
5249
- const x = t.push("td_open", "td", 1);
5250
- l[E] && (x.attrs = [["style", "text-align:" + l[E]]]);
5251
- const O = t.push("inline", "", 0);
5252
- O.content = c[E] ? c[E].trim() : "", O.children = [], t.push("td_close", "td", -1);
5249
+ const k = t.push("td_open", "td", 1);
5250
+ l[E] && (k.attrs = [["style", "text-align:" + l[E]]]);
5251
+ const P = t.push("inline", "", 0);
5252
+ P.content = c[E] ? c[E].trim() : "", P.children = [], t.push("td_close", "td", -1);
5253
5253
  }
5254
5254
  t.push("tr_close", "tr", -1);
5255
5255
  }
@@ -5317,18 +5317,18 @@ function Pf(t, e, n, r) {
5317
5317
  if (s = t.bMarks[f] + t.tShift[f], i = t.eMarks[f], s >= i)
5318
5318
  break;
5319
5319
  if (t.src.charCodeAt(s++) === 62 && !I) {
5320
- let y = t.sCount[f] + 1, E, x;
5321
- t.src.charCodeAt(s) === 32 ? (s++, y++, x = !1, E = !0) : t.src.charCodeAt(s) === 9 ? (E = !0, (t.bsCount[f] + y) % 4 === 3 ? (s++, y++, x = !1) : x = !0) : E = !1;
5322
- let O = y;
5320
+ let y = t.sCount[f] + 1, E, k;
5321
+ t.src.charCodeAt(s) === 32 ? (s++, y++, k = !1, E = !0) : t.src.charCodeAt(s) === 9 ? (E = !0, (t.bsCount[f] + y) % 4 === 3 ? (s++, y++, k = !1) : k = !0) : E = !1;
5322
+ let P = y;
5323
5323
  for (a.push(t.bMarks[f]), t.bMarks[f] = s; s < i; ) {
5324
- const N = t.src.charCodeAt(s);
5325
- if (Ee(N))
5326
- N === 9 ? O += 4 - (O + t.bsCount[f] + (x ? 1 : 0)) % 4 : O++;
5324
+ const F = t.src.charCodeAt(s);
5325
+ if (Ee(F))
5326
+ F === 9 ? P += 4 - (P + t.bsCount[f] + (k ? 1 : 0)) % 4 : P++;
5327
5327
  else
5328
5328
  break;
5329
5329
  s++;
5330
5330
  }
5331
- h = s >= i, u.push(t.bsCount[f]), t.bsCount[f] = t.sCount[f] + 1 + (E ? 1 : 0), c.push(t.sCount[f]), t.sCount[f] = O - y, l.push(t.tShift[f]), t.tShift[f] = s - t.bMarks[f];
5331
+ h = s >= i, u.push(t.bsCount[f]), t.bsCount[f] = t.sCount[f] + 1 + (E ? 1 : 0), c.push(t.sCount[f]), t.sCount[f] = P - y, l.push(t.tShift[f]), t.tShift[f] = s - t.bMarks[f];
5332
5332
  continue;
5333
5333
  }
5334
5334
  if (h)
@@ -5448,32 +5448,32 @@ function Vf(t, e, n, r) {
5448
5448
  const S = t.sCount[u] + h - (t.bMarks[u] + t.tShift[u]);
5449
5449
  let y = S;
5450
5450
  for (; i < s; ) {
5451
- const V = t.src.charCodeAt(i);
5452
- if (V === 9)
5451
+ const B = t.src.charCodeAt(i);
5452
+ if (B === 9)
5453
5453
  y += 4 - (y + t.bsCount[u]) % 4;
5454
- else if (V === 32)
5454
+ else if (B === 32)
5455
5455
  y++;
5456
5456
  else
5457
5457
  break;
5458
5458
  i++;
5459
5459
  }
5460
5460
  const E = i;
5461
- let x;
5462
- E >= s ? x = 1 : x = y - S, x > 4 && (x = 1);
5463
- const O = S + x;
5461
+ let k;
5462
+ E >= s ? k = 1 : k = y - S, k > 4 && (k = 1);
5463
+ const P = S + k;
5464
5464
  a = t.push("list_item_open", "li", 1), a.markup = String.fromCharCode(f);
5465
- const N = [u, 0];
5466
- a.map = N, d && (a.info = t.src.slice(o, h - 1));
5467
- const _ = t.tight, P = t.tShift[u], B = t.sCount[u], ne = t.listIndent;
5468
- if (t.listIndent = t.blkIndent, t.blkIndent = O, t.tight = !0, t.tShift[u] = E - t.bMarks[u], t.sCount[u] = y, E >= s && t.isEmpty(u + 1) ? t.line = Math.min(t.line + 2, n) : t.md.block.tokenize(t, u, n, !0), (!t.tight || C) && (c = !1), C = t.line - u > 1 && t.isEmpty(t.line - 1), t.blkIndent = t.listIndent, t.listIndent = ne, t.tShift[u] = P, t.sCount[u] = B, t.tight = _, a = t.push("list_item_close", "li", -1), a.markup = String.fromCharCode(f), u = t.line, N[1] = u, u >= n || t.sCount[u] < t.blkIndent || t.sCount[u] - t.blkIndent >= 4)
5465
+ const F = [u, 0];
5466
+ a.map = F, d && (a.info = t.src.slice(o, h - 1));
5467
+ const _ = t.tight, O = t.tShift[u], V = t.sCount[u], q = t.listIndent;
5468
+ if (t.listIndent = t.blkIndent, t.blkIndent = P, t.tight = !0, t.tShift[u] = E - t.bMarks[u], t.sCount[u] = y, E >= s && t.isEmpty(u + 1) ? t.line = Math.min(t.line + 2, n) : t.md.block.tokenize(t, u, n, !0), (!t.tight || C) && (c = !1), C = t.line - u > 1 && t.isEmpty(t.line - 1), t.blkIndent = t.listIndent, t.listIndent = q, t.tShift[u] = O, t.sCount[u] = V, t.tight = _, a = t.push("list_item_close", "li", -1), a.markup = String.fromCharCode(f), u = t.line, F[1] = u, u >= n || t.sCount[u] < t.blkIndent || t.sCount[u] - t.blkIndent >= 4)
5469
5469
  break;
5470
- let q = !1;
5471
- for (let V = 0, k = b.length; V < k; V++)
5472
- if (b[V](t, u, n, !0)) {
5473
- q = !0;
5470
+ let K = !1;
5471
+ for (let B = 0, x = b.length; B < x; B++)
5472
+ if (b[B](t, u, n, !0)) {
5473
+ K = !0;
5474
5474
  break;
5475
5475
  }
5476
- if (q)
5476
+ if (K)
5477
5477
  break;
5478
5478
  if (d) {
5479
5479
  if (h = da(t, u), h < 0)
@@ -5496,15 +5496,15 @@ function zf(t, e, n, r) {
5496
5496
  return null;
5497
5497
  let S = !1;
5498
5498
  if (t.sCount[b] - t.blkIndent > 3 && (S = !0), t.sCount[b] < 0 && (S = !0), !S) {
5499
- const x = t.md.block.ruler.getRules("reference"), O = t.parentType;
5499
+ const k = t.md.block.ruler.getRules("reference"), P = t.parentType;
5500
5500
  t.parentType = "reference";
5501
- let N = !1;
5502
- for (let _ = 0, P = x.length; _ < P; _++)
5503
- if (x[_](t, b, I, !0)) {
5504
- N = !0;
5501
+ let F = !1;
5502
+ for (let _ = 0, O = k.length; _ < O; _++)
5503
+ if (k[_](t, b, I, !0)) {
5504
+ F = !0;
5505
5505
  break;
5506
5506
  }
5507
- if (t.parentType = O, N)
5507
+ if (t.parentType = P, F)
5508
5508
  return null;
5509
5509
  }
5510
5510
  const y = t.bMarks[b] + t.tShift[b], E = t.eMarks[b];
@@ -7131,7 +7131,7 @@ function vc(t) {
7131
7131
  return e && t.type && dm.has(t.type) ? `${e}
7132
7132
  ` : e;
7133
7133
  }
7134
- function vy(t, e = 60) {
7134
+ function Iy(t, e = 60) {
7135
7135
  const n = po(t);
7136
7136
  if (!n) return "";
7137
7137
  const s = ("text" in n && typeof n.text == "string" ? n.text : Ic(n)).replace(/\s+/g, " ").trim();
@@ -7554,16 +7554,16 @@ const Se = /* @__PURE__ */ new Map(), He = /* @__PURE__ */ new Map(), _e = /* @_
7554
7554
  EXACT_ONLY: 3
7555
7555
  }, S = t.inactiveConversationRevalidation.get(e), y = s === "NEWER_OPEN" && r ? "NEWER_OPEN" : S && I[S] > I[s] ? S : s, E = new Map(
7556
7556
  t.inactiveConversationRevalidation
7557
- ).set(e, y), x = new Map(t.conversationScanSnapshots);
7558
- x.delete(e);
7559
- const O = new Set(
7557
+ ).set(e, y), k = new Map(t.conversationScanSnapshots);
7558
+ k.delete(e);
7559
+ const P = new Set(
7560
7560
  t.conversationScanCandidateIds
7561
7561
  );
7562
- O.delete(e);
7563
- const N = new Set(t.concealedMessageIds);
7562
+ P.delete(e);
7563
+ const F = new Set(t.concealedMessageIds);
7564
7564
  if (n)
7565
7565
  for (const _ of o)
7566
- N.add(_);
7566
+ F.add(_);
7567
7567
  return {
7568
7568
  conversations: t.conversations.filter(
7569
7569
  ({ id: _ }) => _ !== e
@@ -7575,12 +7575,12 @@ const Se = /* @__PURE__ */ new Map(), He = /* @__PURE__ */ new Map(), _e = /* @_
7575
7575
  refreshingThreadIds: p,
7576
7576
  assistantSuspendedConversationIds: h,
7577
7577
  concealedConversationIds: f,
7578
- concealedMessageIds: N,
7578
+ concealedMessageIds: F,
7579
7579
  inactiveConversationIds: m,
7580
7580
  inactiveConversationUpdatedAt: b,
7581
7581
  inactiveConversationRevalidation: E,
7582
- conversationScanCandidateIds: O,
7583
- conversationScanSnapshots: x,
7582
+ conversationScanCandidateIds: P,
7583
+ conversationScanSnapshots: k,
7584
7584
  typingByConversation: new Map(
7585
7585
  [...t.typingByConversation].filter(
7586
7586
  ([_]) => !_.startsWith(`${e}\0`)
@@ -8176,12 +8176,12 @@ const Se = /* @__PURE__ */ new Map(), He = /* @__PURE__ */ new Map(), _e = /* @_
8176
8176
  S.map(({ id: L }) => L)
8177
8177
  ), E = S.find(
8178
8178
  (L) => L.isCurrent
8179
- )?.id, x = l && (ye?.generation === l.generation || m.currentThreadId === l.conversationId) ? l.conversationId : void 0, O = m.sendInFlight ? m.pendingCustomerMessage?.conversationId ?? m.currentThreadId : void 0, N = m.sendInFlight ? m.currentThreadId : void 0, _ = d && $e === d ? m.currentThreadId : void 0, P = x ?? N ?? _ ?? (r || Pe !== c ? m.currentThreadId : void 0), B = new Set(
8179
+ )?.id, k = l && (ye?.generation === l.generation || m.currentThreadId === l.conversationId) ? l.conversationId : void 0, P = m.sendInFlight ? m.pendingCustomerMessage?.conversationId ?? m.currentThreadId : void 0, F = m.sendInFlight ? m.currentThreadId : void 0, _ = d && $e === d ? m.currentThreadId : void 0, O = k ?? F ?? _ ?? (r || Pe !== c ? m.currentThreadId : void 0), V = new Set(
8180
8180
  [
8181
- x,
8182
- O,
8183
- _,
8181
+ k,
8184
8182
  P,
8183
+ _,
8184
+ O,
8185
8185
  ...[...I].filter(
8186
8186
  (L) => Xe(
8187
8187
  L,
@@ -8193,35 +8193,35 @@ const Se = /* @__PURE__ */ new Map(), He = /* @__PURE__ */ new Map(), _e = /* @_
8193
8193
  m.pendingCustomerMessage?.conversationId
8194
8194
  ] : []
8195
8195
  ].filter((L) => !!L)
8196
- ), ne = (L) => Se.get(L)?.minimumRevision !== void 0 || _e.has(L);
8197
- let q = [
8196
+ ), q = (L) => Se.get(L)?.minimumRevision !== void 0 || _e.has(L);
8197
+ let K = [
8198
8198
  ...S,
8199
8199
  ...m.conversations.filter(
8200
- ({ id: L }) => !y.has(L) && (!C || B.has(L))
8200
+ ({ id: L }) => !y.has(L) && (!C || V.has(L))
8201
8201
  ).map(
8202
- (L) => E && !P ? { ...L, isCurrent: !1 } : L
8202
+ (L) => E && !O ? { ...L, isCurrent: !1 } : L
8203
8203
  )
8204
8204
  ];
8205
- P && (q = q.map((L) => ({
8205
+ O && (K = K.map((L) => ({
8206
8206
  ...L,
8207
- isCurrent: L.id === P
8207
+ isCurrent: L.id === O
8208
8208
  })));
8209
- const V = new Set(
8210
- q.filter(rs).map(({ id: L }) => L)
8211
- ), k = q.map(({ id: L }) => L), T = new Set(k);
8209
+ const B = new Set(
8210
+ K.filter(rs).map(({ id: L }) => L)
8211
+ ), x = K.map(({ id: L }) => L), R = new Set(x);
8212
8212
  let A = m;
8213
8213
  const v = [...I].filter(
8214
8214
  (L) => !y.has(L)
8215
- ), R = C ? v.filter(
8216
- (L) => !B.has(L)
8215
+ ), T = C ? v.filter(
8216
+ (L) => !V.has(L)
8217
8217
  ) : [], z = new Set(
8218
8218
  C ? [] : v
8219
8219
  ), G = /* @__PURE__ */ new Map();
8220
8220
  for (const L of v) {
8221
8221
  const Je = b.get(L);
8222
- Je && (!C || ne(L)) && G.set(L, Je), C && ne(L) && z.add(L);
8222
+ Je && (!C || q(L)) && G.set(L, Je), C && q(L) && z.add(L);
8223
8223
  }
8224
- for (const L of R)
8224
+ for (const L of T)
8225
8225
  e().actions.cancelThreadMessagesRequest(L), A.sendInFlight && (A.currentThreadId === L || A.pendingCustomerMessage?.conversationId === L) && (Mt += 1), ye?.conversationId === L && (ye.controller.abort(), ye = null), ct(L), Oe(L), A = {
8226
8226
  ...A,
8227
8227
  ...Vi(
@@ -8233,20 +8233,20 @@ const Se = /* @__PURE__ */ new Map(), He = /* @__PURE__ */ new Map(), _e = /* @_
8233
8233
  )
8234
8234
  };
8235
8235
  for (const [L, Je] of Se)
8236
- T.has(L) || n || Je.minimumRevision !== void 0 || (Je.controller.abort(), Se.delete(L), wn(L));
8236
+ R.has(L) || n || Je.minimumRevision !== void 0 || (Je.controller.abort(), Se.delete(L), wn(L));
8237
8237
  const X = new Set(
8238
8238
  A.concealedConversationIds
8239
- ), ee = new Set(
8239
+ ), te = new Set(
8240
8240
  A.inactiveConversationIds
8241
8241
  ), oe = new Map(
8242
8242
  A.inactiveConversationUpdatedAt
8243
8243
  ), ie = new Map(
8244
8244
  A.inactiveConversationRevalidation
8245
8245
  );
8246
- for (const L of T)
8247
- ee.delete(L), oe.delete(L), ie.delete(L);
8248
- const de = C ? /* @__PURE__ */ new Set([...T, ...B]) : /* @__PURE__ */ new Set([
8249
- ...T,
8246
+ for (const L of R)
8247
+ te.delete(L), oe.delete(L), ie.delete(L);
8248
+ const de = C ? /* @__PURE__ */ new Set([...R, ...V]) : /* @__PURE__ */ new Set([
8249
+ ...R,
8250
8250
  ...A.threadIds,
8251
8251
  ...z
8252
8252
  ]), pe = new Set(
@@ -8257,15 +8257,15 @@ const Se = /* @__PURE__ */ new Map(), He = /* @__PURE__ */ new Map(), _e = /* @_
8257
8257
  [...A.threadMessagesNextCursor].filter(
8258
8258
  ([L]) => de.has(L)
8259
8259
  )
8260
- ), Y = A.currentThreadId, me = P || E || (Y && de.has(Y) ? Y : void 0);
8261
- q = q.map((L) => ({
8260
+ ), $ = A.currentThreadId, me = O || E || ($ && de.has($) ? $ : void 0);
8261
+ K = K.map((L) => ({
8262
8262
  ...L,
8263
8263
  isCurrent: L.id === me
8264
8264
  }));
8265
8265
  const De = ns(
8266
8266
  A,
8267
8267
  fr(
8268
- wa(q, s),
8268
+ wa(K, s),
8269
8269
  A.scenarioChoiceLifecycleEvents
8270
8270
  )
8271
8271
  ), Le = is(
@@ -8276,17 +8276,17 @@ const Se = /* @__PURE__ */ new Map(), He = /* @__PURE__ */ new Map(), _e = /* @_
8276
8276
  De
8277
8277
  );
8278
8278
  t({
8279
- conversations: q,
8279
+ conversations: K,
8280
8280
  conversationsNextCursor: f,
8281
8281
  threadIds: [...de],
8282
8282
  loadedThreadIds: pe,
8283
8283
  threadMessagesNextCursor: ve,
8284
8284
  currentThreadId: me,
8285
8285
  currentThreadMessages: me === A.currentThreadId ? A.currentThreadMessages : [],
8286
- assistantSuspendedConversationIds: V,
8286
+ assistantSuspendedConversationIds: B,
8287
8287
  concealedConversationIds: X,
8288
8288
  concealedMessageIds: A.concealedMessageIds,
8289
- inactiveConversationIds: ee,
8289
+ inactiveConversationIds: te,
8290
8290
  inactiveConversationUpdatedAt: oe,
8291
8291
  inactiveConversationRevalidation: ie,
8292
8292
  conversationScanCandidateIds: z,
@@ -8298,7 +8298,7 @@ const Se = /* @__PURE__ */ new Map(), He = /* @__PURE__ */ new Map(), _e = /* @_
8298
8298
  A,
8299
8299
  me,
8300
8300
  ue,
8301
- !!(me && V.has(me))
8301
+ !!(me && B.has(me))
8302
8302
  ),
8303
8303
  sendInFlight: A.sendInFlight,
8304
8304
  conversationNavigationRequest: A.conversationNavigationRequest,
@@ -8314,7 +8314,7 @@ const Se = /* @__PURE__ */ new Map(), He = /* @__PURE__ */ new Map(), _e = /* @_
8314
8314
  )
8315
8315
  }), e().actions.updateThreads(), ss();
8316
8316
  for (const L of _e.keys())
8317
- T.has(L) ? e().actions.refreshResponderPresentation(L) : Kn(L);
8317
+ R.has(L) ? e().actions.refreshResponderPresentation(L) : Kn(L);
8318
8318
  me && !ye && !y.has(me) && e().actions.refreshResponderPresentation(
8319
8319
  me,
8320
8320
  void 0,
@@ -8343,53 +8343,53 @@ const Se = /* @__PURE__ */ new Map(), He = /* @__PURE__ */ new Map(), _e = /* @_
8343
8343
  return;
8344
8344
  let l = e();
8345
8345
  const d = c.items.filter(
8346
- (k) => !l.concealedConversationIds.has(k.id) && !Xe(
8347
- k.id,
8346
+ (x) => !l.concealedConversationIds.has(x.id) && !Xe(
8347
+ x.id,
8348
8348
  o
8349
- ) && ya(l, k)
8349
+ ) && ya(l, x)
8350
8350
  ), p = new Map(
8351
8351
  l.conversationScanSnapshots
8352
8352
  ), h = new Set(
8353
8353
  l.conversationScanCandidateIds
8354
8354
  ), f = new Map(
8355
8355
  l.conversations.map(
8356
- (k) => [k.id, k]
8356
+ (x) => [x.id, x]
8357
8357
  )
8358
8358
  ), m = /* @__PURE__ */ new Map();
8359
- for (const k of d) {
8360
- const T = m.get(k.id) ?? f.get(k.id) ?? p.get(k.id);
8359
+ for (const x of d) {
8360
+ const R = m.get(x.id) ?? f.get(x.id) ?? p.get(x.id);
8361
8361
  m.set(
8362
- k.id,
8363
- Nn(T, k).conversation
8362
+ x.id,
8363
+ Nn(R, x).conversation
8364
8364
  );
8365
8365
  }
8366
8366
  const g = [...m.values()];
8367
- for (const k of g)
8368
- ct(k.id), Oe(k.id);
8369
- for (const k of m.keys())
8370
- h.delete(k), p.delete(k);
8367
+ for (const x of g)
8368
+ ct(x.id), Oe(x.id);
8369
+ for (const x of m.keys())
8370
+ h.delete(x), p.delete(x);
8371
8371
  if (c.nextCursor === null) {
8372
- for (const k of [...h]) {
8373
- const T = p.get(k), A = Se.get(k)?.minimumRevision !== void 0 || _e.has(k), v = l.conversationScanAuthorityVersion ?? o, R = l.sendInFlight ? l.pendingCustomerMessage?.conversationId ?? l.currentThreadId : void 0;
8374
- if (ye?.conversationId === k || R === k || l.sendInFlight && l.currentThreadId === k || $e !== null && l.currentThreadId === k || Xe(
8375
- k,
8372
+ for (const x of [...h]) {
8373
+ const R = p.get(x), A = Se.get(x)?.minimumRevision !== void 0 || _e.has(x), v = l.conversationScanAuthorityVersion ?? o, T = l.sendInFlight ? l.pendingCustomerMessage?.conversationId ?? l.currentThreadId : void 0;
8374
+ if (ye?.conversationId === x || T === x || l.sendInFlight && l.currentThreadId === x || $e !== null && l.currentThreadId === x || Xe(
8375
+ x,
8376
8376
  v
8377
8377
  )) {
8378
- h.delete(k), p.delete(k);
8378
+ h.delete(x), p.delete(x);
8379
8379
  continue;
8380
8380
  }
8381
- l.actions.cancelThreadMessagesRequest(k), l.sendInFlight && (l.currentThreadId === k || l.pendingCustomerMessage?.conversationId === k) && (Mt += 1), ye?.conversationId === k && (ye.controller.abort(), ye = null);
8382
- const G = Se.get(k);
8383
- A || (wn(k), G?.controller.abort(), Se.delete(k)), ct(k), Oe(k), l = {
8381
+ l.actions.cancelThreadMessagesRequest(x), l.sendInFlight && (l.currentThreadId === x || l.pendingCustomerMessage?.conversationId === x) && (Mt += 1), ye?.conversationId === x && (ye.controller.abort(), ye = null);
8382
+ const G = Se.get(x);
8383
+ A || (wn(x), G?.controller.abort(), Se.delete(x)), ct(x), Oe(x), l = {
8384
8384
  ...l,
8385
8385
  ...Vi(
8386
8386
  l,
8387
- k,
8387
+ x,
8388
8388
  !1,
8389
- T?.updatedAt ?? null,
8389
+ R?.updatedAt ?? null,
8390
8390
  "ANY_OPEN"
8391
8391
  )
8392
- }, h.delete(k), p.delete(k), T && A && (h.add(k), p.set(k, T));
8392
+ }, h.delete(x), p.delete(x), R && A && (h.add(x), p.set(x, R));
8393
8393
  }
8394
8394
  l = {
8395
8395
  ...l,
@@ -8400,81 +8400,81 @@ const Se = /* @__PURE__ */ new Map(), He = /* @__PURE__ */ new Map(), _e = /* @_
8400
8400
  }
8401
8401
  const C = new Map(
8402
8402
  l.conversations.map(
8403
- (k) => [k.id, k]
8403
+ (x) => [x.id, x]
8404
8404
  )
8405
8405
  ), b = [
8406
8406
  ...l.conversations.map(
8407
- (k) => m.get(k.id) ?? k
8407
+ (x) => m.get(x.id) ?? x
8408
8408
  ),
8409
8409
  ...g.filter(
8410
- ({ id: k }) => !C.has(k)
8410
+ ({ id: x }) => !C.has(x)
8411
8411
  )
8412
8412
  ], I = g.find(
8413
- ({ isCurrent: k }) => k
8414
- )?.id, y = !!(I && !ye && !l.sendInFlight && $e === null && Pe === a) ? I : l.currentThreadId, E = b.map((k) => ({
8415
- ...k,
8416
- isCurrent: k.id === y
8417
- })), x = y !== l.currentThreadId;
8418
- x && (Pe += 1);
8419
- const O = new Set(
8413
+ ({ isCurrent: x }) => x
8414
+ )?.id, y = !!(I && !ye && !l.sendInFlight && $e === null && Pe === a) ? I : l.currentThreadId, E = b.map((x) => ({
8415
+ ...x,
8416
+ isCurrent: x.id === y
8417
+ })), k = y !== l.currentThreadId;
8418
+ k && (Pe += 1);
8419
+ const P = new Set(
8420
8420
  l.assistantSuspendedConversationIds
8421
- ), N = new Set(
8421
+ ), F = new Set(
8422
8422
  l.inactiveConversationIds
8423
8423
  ), _ = new Map(
8424
8424
  l.inactiveConversationUpdatedAt
8425
- ), P = new Map(
8425
+ ), O = new Map(
8426
8426
  l.inactiveConversationRevalidation
8427
8427
  );
8428
- for (const k of g)
8429
- N.delete(k.id), _.delete(k.id), P.delete(k.id), rs(k) ? O.add(k.id) : O.delete(k.id);
8430
- const B = ns(
8428
+ for (const x of g)
8429
+ F.delete(x.id), _.delete(x.id), O.delete(x.id), rs(x) ? P.add(x.id) : P.delete(x.id);
8430
+ const V = ns(
8431
8431
  l,
8432
8432
  fr(
8433
8433
  wa(g, n),
8434
8434
  l.scenarioChoiceLifecycleEvents
8435
8435
  )
8436
- ), ne = l.messages, q = as(
8436
+ ), q = l.messages, K = as(
8437
8437
  l.pendingCustomerMessage,
8438
- B
8439
- ), V = is(
8438
+ V
8439
+ ), B = is(
8440
8440
  l.messageStreams,
8441
- B
8441
+ V
8442
8442
  );
8443
8443
  t({
8444
8444
  conversations: E,
8445
8445
  currentThreadId: y,
8446
- currentThreadMessages: x ? [
8446
+ currentThreadMessages: k ? [
8447
8447
  ...y ? l.threads.get(y) ?? Fn : Fn
8448
8448
  ] : l.currentThreadMessages,
8449
- assistantSuspendedConversationIds: O,
8450
- inactiveConversationIds: N,
8449
+ assistantSuspendedConversationIds: P,
8450
+ inactiveConversationIds: F,
8451
8451
  inactiveConversationUpdatedAt: _,
8452
- inactiveConversationRevalidation: P,
8452
+ inactiveConversationRevalidation: O,
8453
8453
  conversationScanCandidateIds: h,
8454
8454
  conversationScanAuthorityVersion: c.nextCursor === null ? null : l.conversationScanAuthorityVersion,
8455
8455
  conversationScanSnapshots: p,
8456
8456
  conversationsNextCursor: c.nextCursor,
8457
8457
  threadIds: [
8458
8458
  ...l.threadIds,
8459
- ...g.map(({ id: k }) => k).filter((k) => !l.threadIds.includes(k))
8459
+ ...g.map(({ id: x }) => x).filter((x) => !l.threadIds.includes(x))
8460
8460
  ],
8461
- messageStreams: V,
8461
+ messageStreams: B,
8462
8462
  responsePhase: Xt(
8463
8463
  l,
8464
8464
  y,
8465
- q,
8466
- !!(y && O.has(y))
8465
+ K,
8466
+ !!(y && P.has(y))
8467
8467
  ),
8468
8468
  messages: pr(
8469
- ne,
8470
8469
  q,
8471
- new Set(V.keys())
8470
+ K,
8471
+ new Set(B.keys())
8472
8472
  ),
8473
8473
  pendingCustomerMessage: os(
8474
8474
  l.pendingCustomerMessage,
8475
- q
8475
+ K
8476
8476
  )
8477
- }), e().actions.updateThreads(), x && y && await e().actions.fetchThreadMessages(y);
8477
+ }), e().actions.updateThreads(), k && y && await e().actions.fetchThreadMessages(y);
8478
8478
  } catch (c) {
8479
8479
  if (!cr(c)) throw c;
8480
8480
  } finally {
@@ -8898,12 +8898,12 @@ const Se = /* @__PURE__ */ new Map(), He = /* @__PURE__ */ new Map(), _e = /* @_
8898
8898
  e().actions.handleMessage(E), e().actions.handleMessageDelta(n);
8899
8899
  return;
8900
8900
  }
8901
- const x = new Map(e().pendingMessageDeltas);
8902
- if (!x.has(n.messageId) && x.size >= fm) {
8903
- const O = x.keys().next().value;
8904
- O && x.delete(O);
8901
+ const k = new Map(e().pendingMessageDeltas);
8902
+ if (!k.has(n.messageId) && k.size >= fm) {
8903
+ const P = k.keys().next().value;
8904
+ P && k.delete(P);
8905
8905
  }
8906
- x.set(n.messageId, n), t({ pendingMessageDeltas: x });
8906
+ k.set(n.messageId, n), t({ pendingMessageDeltas: k });
8907
8907
  return;
8908
8908
  }
8909
8909
  const h = e().messages[p];
@@ -8936,7 +8936,7 @@ const Se = /* @__PURE__ */ new Map(), He = /* @__PURE__ */ new Map(), _e = /* @_
8936
8936
  latestMessageDate: b,
8937
8937
  responsePhase: C && y ? "idle" : e().responsePhase,
8938
8938
  messages: e().messages.map(
8939
- (E, x) => x === p ? {
8939
+ (E, k) => k === p ? {
8940
8940
  ...E,
8941
8941
  status: fe.Completed,
8942
8942
  content: Tc(n.text),
@@ -8977,62 +8977,62 @@ const Se = /* @__PURE__ */ new Map(), He = /* @__PURE__ */ new Map(), _e = /* @_
8977
8977
  text: I,
8978
8978
  done: !0
8979
8979
  }) : void 0, y = b ?? S, E = !!y || !Gi(o);
8980
- let x = o, O = !1;
8980
+ let k = o, P = !1;
8981
8981
  if (m !== -1) {
8982
- const v = g, R = xc(
8982
+ const v = g, T = xc(
8983
8983
  v,
8984
8984
  o
8985
- ), z = R.status === fe.Writing && wr(v), G = !C && Date.parse(v.updatedAt) > Date.parse(R.updatedAt), X = R.status === fe.Writing && !!y;
8986
- O = G || z, x = G || z ? {
8985
+ ), z = T.status === fe.Writing && wr(v), G = !C && Date.parse(v.updatedAt) > Date.parse(T.updatedAt), X = T.status === fe.Writing && !!y;
8986
+ P = G || z, k = G || z ? {
8987
8987
  ...v,
8988
8988
  author: Un(
8989
8989
  v.author,
8990
- R.author
8990
+ T.author
8991
8991
  )
8992
8992
  } : X ? {
8993
- ...R,
8993
+ ...T,
8994
8994
  author: Un(
8995
8995
  v.author,
8996
- R.author
8996
+ T.author
8997
8997
  ),
8998
8998
  status: y.done ? fe.Completed : fe.Writing,
8999
8999
  content: v.content,
9000
9000
  updatedAt: v.updatedAt,
9001
9001
  lastThreadMessageAt: v.lastThreadMessageAt
9002
9002
  } : {
9003
- ...R,
9003
+ ...T,
9004
9004
  author: Un(
9005
9005
  v.author,
9006
- R.author
9006
+ T.author
9007
9007
  )
9008
- }, C && x.attachments.length === 0 && v.attachments.length > 0 && (x = { ...x, attachments: v.attachments });
9008
+ }, C && k.attachments.length === 0 && v.attachments.length > 0 && (k = { ...k, attachments: v.attachments });
9009
9009
  }
9010
- const N = !!(g && (Ds(o.author) > Ds(g.author) || !g.author.role && o.author.role));
9011
- if (O && !N && !l)
9010
+ const F = !!(g && (Ds(o.author) > Ds(g.author) || !g.author.role && o.author.role));
9011
+ if (P && !F && !l)
9012
9012
  return "IGNORED";
9013
9013
  Oe(r);
9014
- const _ = !p && o.author.type === Te.Customer && m === -1, P = !!(c && (o.id === c.id || o.clientMessageId === c.id || y?.requestId === c.id)), B = !!(c && P);
9015
- P && o.author.type === Te.Customer && fi(
9014
+ const _ = !p && o.author.type === Te.Customer && m === -1, O = !!(c && (o.id === c.id || o.clientMessageId === c.id || y?.requestId === c.id)), V = !!(c && O);
9015
+ O && o.author.type === Te.Customer && fi(
9016
9016
  c.id,
9017
9017
  r,
9018
9018
  c.createdAt,
9019
9019
  o.id
9020
9020
  );
9021
- const ne = !!(!e().currentThreadId && B), q = e().currentThreadId === r || ne;
9022
- P && Oe(r), B && _ && x.attachments.length === 0 && c.attachments.length > 0 && (x = {
9023
- ...x,
9021
+ const q = !!(!e().currentThreadId && V), K = e().currentThreadId === r || q;
9022
+ O && Oe(r), V && _ && k.attachments.length === 0 && c.attachments.length > 0 && (k = {
9023
+ ...k,
9024
9024
  attachments: c.attachments
9025
9025
  });
9026
- const V = h && d ? Xt(e(), r, [x]) : e().responsePhase;
9026
+ const B = h && d ? Xt(e(), r, [k]) : e().responsePhase;
9027
9027
  t({
9028
- messages: E ? m === -1 ? [...e().messages, x] : e().messages.map(
9029
- (v, R) => R === m ? { ...x, agenticSteps: v.agenticSteps } : v
9028
+ messages: E ? m === -1 ? [...e().messages, k] : e().messages.map(
9029
+ (v, T) => T === m ? { ...k, agenticSteps: v.agenticSteps } : v
9030
9030
  ) : e().messages.filter(({ id: v }) => v !== o.id),
9031
- ...ne ? { currentThreadId: r } : {},
9032
- pendingCustomerMessage: B ? {
9031
+ ...q ? { currentThreadId: r } : {},
9032
+ pendingCustomerMessage: V ? {
9033
9033
  ...c,
9034
9034
  acknowledged: !0,
9035
- acceptanceConfirmed: c.acceptanceConfirmed === !0 || P,
9035
+ acceptanceConfirmed: c.acceptanceConfirmed === !0 || O,
9036
9036
  conversationId: c.conversationId ?? r,
9037
9037
  canonicalMessageId: _ ? o.id : c.canonicalMessageId
9038
9038
  } : c,
@@ -9043,13 +9043,13 @@ const Se = /* @__PURE__ */ new Map(), He = /* @__PURE__ */ new Map(), _e = /* @_
9043
9043
  )
9044
9044
  } : {}
9045
9045
  });
9046
- const k = new Map(e().messageStreams), T = new Map(e().pendingMessageDeltas);
9047
- d && (o.status === fe.Completed && p && y || k.delete(o.id), T.delete(o.id)), t({
9046
+ const x = new Map(e().messageStreams), R = new Map(e().pendingMessageDeltas);
9047
+ d && (o.status === fe.Completed && p && y || x.delete(o.id), R.delete(o.id)), t({
9048
9048
  threadIds: i ? [r, ...e().threadIds] : e().threadIds,
9049
- responsePhase: q ? h && d ? V : h && o.status === fe.Writing && e().responsePhase === "awaiting-first-token" ? "streaming" : e().responsePhase : e().responsePhase,
9049
+ responsePhase: K ? h && d ? B : h && o.status === fe.Writing && e().responsePhase === "awaiting-first-token" ? "streaming" : e().responsePhase : e().responsePhase,
9050
9050
  ...d ? {
9051
- messageStreams: k,
9052
- pendingMessageDeltas: T
9051
+ messageStreams: x,
9052
+ pendingMessageDeltas: R
9053
9053
  } : {}
9054
9054
  }), d && t({ latestMessageDate: o.updatedAt }), e().actions.updateThreads();
9055
9055
  const A = e().pendingMessageDeltas.get(o.id);
@@ -9057,7 +9057,7 @@ const Se = /* @__PURE__ */ new Map(), He = /* @__PURE__ */ new Map(), _e = /* @_
9057
9057
  const v = new Map(e().pendingMessageDeltas);
9058
9058
  v.delete(o.id), t({ pendingMessageDeltas: v }), e().actions.handleMessageDelta(A);
9059
9059
  }
9060
- return E ? m === -1 ? "INSERTED" : g?.status !== fe.Completed && x.status === fe.Completed || g !== void 0 && Em(g, x) ? "UPDATED" : "DUPLICATE" : "IGNORED";
9060
+ return E ? m === -1 ? "INSERTED" : g?.status !== fe.Completed && k.status === fe.Completed || g !== void 0 && Em(g, k) ? "UPDATED" : "DUPLICATE" : "IGNORED";
9061
9061
  },
9062
9062
  handleResponderPresentationChanged: (n) => {
9063
9063
  if (e().concealedConversationIds.has(n.conversationId)) return;
@@ -9175,43 +9175,43 @@ const Se = /* @__PURE__ */ new Map(), He = /* @__PURE__ */ new Map(), _e = /* @_
9175
9175
  e().inactiveConversationUpdatedAt
9176
9176
  );
9177
9177
  E.delete(h.id);
9178
- const x = new Map(
9178
+ const k = new Map(
9179
9179
  e().inactiveConversationRevalidation
9180
9180
  );
9181
- x.delete(h.id);
9182
- const O = new Map(
9181
+ k.delete(h.id);
9182
+ const P = new Map(
9183
9183
  e().conversationScanSnapshots
9184
9184
  );
9185
- O.delete(h.id);
9186
- const N = new Set(
9185
+ P.delete(h.id);
9186
+ const F = new Set(
9187
9187
  e().conversationScanCandidateIds
9188
9188
  );
9189
- N.delete(h.id);
9190
- const _ = e().currentThreadId, P = g ? e().conversations.map(
9191
- (B) => B.id === h.id ? {
9189
+ F.delete(h.id);
9190
+ const _ = e().currentThreadId, O = g ? e().conversations.map(
9191
+ (V) => V.id === h.id ? {
9192
9192
  ...b.conversation,
9193
9193
  isCurrent: h.id === _
9194
9194
  } : {
9195
- ...B,
9196
- isCurrent: B.id === _
9195
+ ...V,
9196
+ isCurrent: V.id === _
9197
9197
  }
9198
9198
  ) : [
9199
9199
  {
9200
9200
  ...b.conversation,
9201
9201
  isCurrent: h.id === _
9202
9202
  },
9203
- ...e().conversations.filter(({ id: B }) => B !== h.id).map((B) => ({
9204
- ...B,
9205
- isCurrent: B.id === _
9203
+ ...e().conversations.filter(({ id: V }) => V !== h.id).map((V) => ({
9204
+ ...V,
9205
+ isCurrent: V.id === _
9206
9206
  }))
9207
9207
  ];
9208
9208
  t({
9209
- conversations: P,
9209
+ conversations: O,
9210
9210
  inactiveConversationIds: y,
9211
9211
  inactiveConversationUpdatedAt: E,
9212
- inactiveConversationRevalidation: x,
9213
- conversationScanCandidateIds: N,
9214
- conversationScanSnapshots: O,
9212
+ inactiveConversationRevalidation: k,
9213
+ conversationScanCandidateIds: F,
9214
+ conversationScanSnapshots: P,
9215
9215
  threadIds: e().threadIds.includes(h.id) ? e().threadIds : [h.id, ...e().threadIds]
9216
9216
  }), e().actions.updateThreads();
9217
9217
  };
@@ -9410,7 +9410,7 @@ const Se = /* @__PURE__ */ new Map(), He = /* @__PURE__ */ new Map(), _e = /* @_
9410
9410
  c
9411
9411
  ), f = !!(a === void 0 && e().currentThreadId === p.conversationId && (e().pendingCustomerMessage?.id === c || h.has(p.conversationId))), m = Pe === o && (a === void 0 || e().currentThreadId === a) || f;
9412
9412
  if ([...h].some(
9413
- (N) => N !== p.conversationId
9413
+ (F) => F !== p.conversationId
9414
9414
  )) {
9415
9415
  d();
9416
9416
  return;
@@ -9447,8 +9447,8 @@ const Se = /* @__PURE__ */ new Map(), He = /* @__PURE__ */ new Map(), _e = /* @_
9447
9447
  S.delete(p.conversationId);
9448
9448
  const y = e().pendingCustomerMessage, E = new Set(
9449
9449
  e().assistantSuspendedConversationIds
9450
- ), x = e().conversations.find(
9451
- ({ id: N }) => N === p.conversationId
9450
+ ), k = e().conversations.find(
9451
+ ({ id: F }) => F === p.conversationId
9452
9452
  );
9453
9453
  fi(
9454
9454
  c,
@@ -9457,11 +9457,11 @@ const Se = /* @__PURE__ */ new Map(), He = /* @__PURE__ */ new Map(), _e = /* @_
9457
9457
  y?.canonicalMessageId ?? null
9458
9458
  ), bm(
9459
9459
  p.conversationId,
9460
- x,
9460
+ k,
9461
9461
  p.aiSuspension
9462
9462
  ), on.get(
9463
9463
  p.conversationId
9464
- )?.suspended ?? gm(x, p.aiSuspension) ? E.add(p.conversationId) : E.delete(p.conversationId), p.assistantAdmitted || ht.delete(p.conversationId), t({
9464
+ )?.suspended ?? gm(k, p.aiSuspension) ? E.add(p.conversationId) : E.delete(p.conversationId), p.assistantAdmitted || ht.delete(p.conversationId), t({
9465
9465
  ...m ? { currentThreadId: p.conversationId } : {},
9466
9466
  inactiveConversationIds: g,
9467
9467
  inactiveConversationUpdatedAt: C,
@@ -9480,10 +9480,10 @@ const Se = /* @__PURE__ */ new Map(), He = /* @__PURE__ */ new Map(), _e = /* @_
9480
9480
  readByAssistant: p.assistantAdmitted
9481
9481
  } : y
9482
9482
  });
9483
- for (const [N, _] of e().pendingMessageDeltas)
9483
+ for (const [F, _] of e().pendingMessageDeltas)
9484
9484
  if (_.requestId === c) {
9485
- const P = new Map(e().pendingMessageDeltas);
9486
- P.delete(N), t({ pendingMessageDeltas: P }), e().actions.handleMessageDelta(_);
9485
+ const O = new Map(e().pendingMessageDeltas);
9486
+ O.delete(F), t({ pendingMessageDeltas: O }), e().actions.handleMessageDelta(_);
9487
9487
  }
9488
9488
  p.assistantMessage && e().actions.handleMessage({
9489
9489
  ...p.assistantMessage,
@@ -9786,15 +9786,15 @@ const Se = /* @__PURE__ */ new Map(), He = /* @__PURE__ */ new Map(), _e = /* @_
9786
9786
  j.subscribe((t, e) => {
9787
9787
  t.conversations !== e.conversations && Bi(t.conversations);
9788
9788
  });
9789
- const Ay = () => j((t) => t.currentThreadId), Mm = () => j((t) => t.currentThreadMessages), wy = () => j((t) => t.threadsPreviews), Sy = () => j((t) => !!t.conversationsNextCursor), Ey = () => j((t) => t.isLoadingMoreConversations), Dm = () => j((t) => t.currentThreadId), ky = () => j((t) => t.currentThreadId ? t.conversations.find(({ id: e }) => e === t.currentThreadId)?.responderPresentation ?? Ss : Ss), xy = () => j(
9789
+ const vy = () => j((t) => t.currentThreadId), Mm = () => j((t) => t.currentThreadMessages), Ay = () => j((t) => t.threadsPreviews), wy = () => j((t) => !!t.conversationsNextCursor), Sy = () => j((t) => t.isLoadingMoreConversations), Dm = () => j((t) => t.currentThreadId), Ey = () => j((t) => t.currentThreadId ? t.conversations.find(({ id: e }) => e === t.currentThreadId)?.responderPresentation ?? Ss : Ss), ky = () => j(
9790
9790
  (t) => t.currentThreadId ? !t.refreshingThreadIds.has(t.currentThreadId) && !!t.threadMessagesNextCursor.get(t.currentThreadId) : !1
9791
- ), Ty = () => j(
9791
+ ), xy = () => j(
9792
9792
  (t) => t.currentThreadId ? t.loadingOlderThreadIds.has(t.currentThreadId) : !1
9793
- ), _m = () => j((t) => t.latestReadMessageDate), Fm = () => j((t) => t.latestMessageDate), Nm = () => j((t) => t.conversationNavigationRequest), Ry = () => j((t) => t.sendError), Lm = (t) => !!(t.currentThreadId && !t.loadedThreadIds.has(t.currentThreadId)), My = () => j(Lm), Dy = () => j((t) => t.responsePhase === "awaiting-first-token"), _y = () => j(
9793
+ ), _m = () => j((t) => t.latestReadMessageDate), Fm = () => j((t) => t.latestMessageDate), Nm = () => j((t) => t.conversationNavigationRequest), Ty = () => j((t) => t.sendError), Lm = (t) => !!(t.currentThreadId && !t.loadedThreadIds.has(t.currentThreadId)), Ry = () => j(Lm), My = () => j((t) => t.responsePhase === "awaiting-first-token"), Dy = () => j(
9794
9794
  (t) => t.sendInFlight || t.responsePhase !== "idle" || !!(t.pendingCustomerMessage && (t.pendingCustomerMessage.acceptanceConfirmed !== !0 || !t.pendingCustomerMessage.conversationId))
9795
- ), Pm = (t) => t.pendingCustomerMessage?.conversationId === t.currentThreadId ? t.pendingCustomerMessage : null, Fy = () => j(Pm), Ny = (t) => j((e) => e.messageStreams.get(t)), Om = (t, e) => t.currentThreadId ? t.typingByConversation.get(
9795
+ ), Pm = (t) => t.pendingCustomerMessage?.conversationId === t.currentThreadId ? t.pendingCustomerMessage : null, _y = () => j(Pm), Fy = (t) => j((e) => e.messageStreams.get(t)), Om = (t, e) => t.currentThreadId ? t.typingByConversation.get(
9796
9796
  Ac(t.currentThreadId, e)
9797
- ) ?? null : null, Ly = (t) => j((e) => Om(e, t)), Bm = (t) => {
9797
+ ) ?? null : null, Ny = (t) => j((e) => Om(e, t)), Bm = (t) => {
9798
9798
  if (!t.currentThreadId) return !1;
9799
9799
  if (t.assistantSuspendedConversationIds.has(t.currentThreadId))
9800
9800
  return !0;
@@ -12646,21 +12646,21 @@ const jc = Yn(void 0), hb = (t, e, n) => new Lh(t, e, n), fb = (t, e, n, r = {},
12646
12646
  () => new lb(t.customerInteractionSession.accessToken),
12647
12647
  [t.customerInteractionSession.accessToken]
12648
12648
  );
12649
- return K(() => () => m.dispose(), [m]), K(() => {
12649
+ return Y(() => () => m.dispose(), [m]), Y(() => {
12650
12650
  const g = t.customerInteractionSession.interactionSessionId;
12651
12651
  f.current !== g && (f.current = g, h.reset());
12652
12652
  }, [
12653
12653
  t.customerInteractionSession.interactionSessionId,
12654
12654
  h
12655
- ]), K(
12655
+ ]), Y(
12656
12656
  () => () => h.dispose(),
12657
12657
  [h]
12658
- ), K(() => {
12658
+ ), Y(() => {
12659
12659
  const g = () => {
12660
12660
  l($t.Available);
12661
12661
  }, C = () => {
12662
12662
  navigator.onLine && l(
12663
- (O) => O === $t.Offline ? $t.Available : O
12663
+ (P) => P === $t.Offline ? $t.Available : P
12664
12664
  );
12665
12665
  };
12666
12666
  let b = !0;
@@ -12670,66 +12670,66 @@ const jc = Yn(void 0), hb = (t, e, n) => new Lh(t, e, n), fb = (t, e, n, r = {},
12670
12670
  b = !0;
12671
12671
  }, y = s(
12672
12672
  wl(t.customerInteractionSession.accessToken),
12673
- (O) => {
12673
+ (P) => {
12674
12674
  g();
12675
- const N = j.getState().actions, _ = ag(O, {
12676
- messageActions: N,
12675
+ const F = j.getState().actions, _ = ag(P, {
12676
+ messageActions: F,
12677
12677
  commandRuntime: e,
12678
12678
  session: t.customerInteractionSession,
12679
12679
  realtimeMessageSource: b ? "HISTORY_REPLAY" : "LIVE",
12680
- sendAck: (B) => y.acknowledgeCommand(B),
12680
+ sendAck: (V) => y.acknowledgeCommand(V),
12681
12681
  onPresenceOnline: g,
12682
12682
  onScenarioConversation: u,
12683
12683
  onRealtimeMessage: i,
12684
- onScenarioChoiceLifecycle: (B) => {
12684
+ onScenarioChoiceLifecycle: (V) => {
12685
12685
  h.handleLifecycle(
12686
12686
  {
12687
12687
  principalId: t.customerInteractionSession.interactionSessionId,
12688
- inputRequestId: B.inputRequestId
12688
+ inputRequestId: V.inputRequestId
12689
12689
  },
12690
- B.lifecycle
12691
- ), o?.(B);
12690
+ V.lifecycle
12691
+ ), o?.(V);
12692
12692
  },
12693
- onScenarioChoiceSubmissionResult: (B) => {
12693
+ onScenarioChoiceSubmissionResult: (V) => {
12694
12694
  h.handleResult(
12695
12695
  t.customerInteractionSession.interactionSessionId,
12696
- B
12697
- ), a?.(B);
12696
+ V
12697
+ ), a?.(V);
12698
12698
  }
12699
- }), P = Mc(O);
12700
- P?.delivery && P.delivery.status !== "DELIVERED" && P.delivery.status !== "READ" && y.acknowledgeMessageDelivery({
12701
- messageId: P.id,
12699
+ }), O = Mc(P);
12700
+ O?.delivery && O.delivery.status !== "DELIVERED" && O.delivery.status !== "READ" && y.acknowledgeMessageDelivery({
12701
+ messageId: O.id,
12702
12702
  status: "delivered"
12703
12703
  }).catch(
12704
- (B) => re.warn("Message delivery acknowledgement failed", B)
12704
+ (V) => re.warn("Message delivery acknowledgement failed", V)
12705
12705
  ), _ && _.catch(
12706
- (B) => re.warn("Command acknowledgement failed", B)
12706
+ (V) => re.warn("Command acknowledgement failed", V)
12707
12707
  );
12708
12708
  },
12709
12709
  n
12710
12710
  );
12711
12711
  h.setTransport(
12712
- (O) => y.submitScenarioChoice(O)
12713
- ), y.channels.chat.on("info", (O) => {
12714
- (O.type === "history_received" || O.type === "history_not_found" || O.type === "confirm_history" || O.type === "reject_history") && I(), (O.type === "history_not_found" || O.type === "reject_history") && re.warn("Realtime history was rejected");
12712
+ (P) => y.submitScenarioChoice(P)
12713
+ ), y.channels.chat.on("info", (P) => {
12714
+ (P.type === "history_received" || P.type === "history_not_found" || P.type === "confirm_history" || P.type === "reject_history") && I(), (P.type === "history_not_found" || P.type === "reject_history") && re.warn("Realtime history was rejected");
12715
12715
  }), y.channels.chat.on("connect", () => {
12716
12716
  S(), console.info("[CableContext] Connected to the chat channel"), p(y), g();
12717
- }), y.channels.chat.on("disconnect", (O) => {
12718
- S(), j.getState().actions.clearTransientRealtimeState(), Us(O) && n?.(), l(
12717
+ }), y.channels.chat.on("disconnect", (P) => {
12718
+ S(), j.getState().actions.clearTransientRealtimeState(), Us(P) && n?.(), l(
12719
12719
  navigator.onLine ? $t.Unavailable : $t.Offline
12720
- ), console.warn("[CableContext] Disconnected from the chat channel", O);
12720
+ ), console.warn("[CableContext] Disconnected from the chat channel", P);
12721
12721
  });
12722
12722
  const E = () => {
12723
12723
  document.visibilityState === "visible" && C();
12724
- }, x = () => {
12724
+ }, k = () => {
12725
12725
  l($t.Offline);
12726
12726
  };
12727
- return window.addEventListener("online", C), window.addEventListener("offline", x), window.addEventListener("focus", C), document.addEventListener("visibilitychange", E), y.channels.chat.on("close", (O) => {
12728
- console.warn("[CableContext] Closed the chat channel", O);
12727
+ return window.addEventListener("online", C), window.addEventListener("offline", k), window.addEventListener("focus", C), document.addEventListener("visibilitychange", E), y.channels.chat.on("close", (P) => {
12728
+ console.warn("[CableContext] Closed the chat channel", P);
12729
12729
  }), () => {
12730
12730
  I(), y.unregister(), h.setTransport(
12731
12731
  () => Promise.reject(new Error("Cable is not ready"))
12732
- ), window.removeEventListener("online", C), window.removeEventListener("offline", x), window.removeEventListener("focus", C), document.removeEventListener("visibilitychange", E);
12732
+ ), window.removeEventListener("online", C), window.removeEventListener("offline", k), window.removeEventListener("focus", C), document.removeEventListener("visibilitychange", E);
12733
12733
  };
12734
12734
  }, [
12735
12735
  e,
@@ -12775,13 +12775,13 @@ const st = {
12775
12775
  voice: "/chat/voice",
12776
12776
  text: "/chat/text"
12777
12777
  };
12778
- function Oy(t) {
12778
+ function Py(t) {
12779
12779
  if (!t || typeof t != "object" || !("chatMode" in t))
12780
12780
  return null;
12781
12781
  const { chatMode: e } = t;
12782
12782
  return e === "text" || e === "voice" ? e : null;
12783
12783
  }
12784
- function By(t) {
12784
+ function Oy(t) {
12785
12785
  return Ao(t) ? "text" : "voice";
12786
12786
  }
12787
12787
  function Zi(t) {
@@ -12793,10 +12793,10 @@ function Ao(t) {
12793
12793
  function _a(t) {
12794
12794
  return t === st.voice || t.endsWith(st.voice) || Ao(t);
12795
12795
  }
12796
- function Vy(t, e) {
12796
+ function By(t, e) {
12797
12797
  return _a(t) && Zi(e) ? "forward" : Zi(t) && _a(e) ? "backward" : null;
12798
12798
  }
12799
- function zy(t) {
12799
+ function Vy(t) {
12800
12800
  return t === st.voice || t.endsWith(st.voice);
12801
12801
  }
12802
12802
  function gb(t) {
@@ -12807,12 +12807,12 @@ function Cb(t, e) {
12807
12807
  const n = U(e), r = t.customerInteractionSession, s = le(() => {
12808
12808
  Sl(r) && n.current.onSessionExpired();
12809
12809
  }, [r]);
12810
- K(() => {
12810
+ Y(() => {
12811
12811
  s();
12812
- }, [s]), K(() => {
12812
+ }, [s]), Y(() => {
12813
12813
  const i = () => s();
12814
12814
  return window.addEventListener("focus", i), () => window.removeEventListener("focus", i);
12815
- }, [s]), K(() => {
12815
+ }, [s]), Y(() => {
12816
12816
  const i = window.setInterval(s, bb);
12817
12817
  return () => window.clearInterval(i);
12818
12818
  }, [s]);
@@ -13137,18 +13137,18 @@ class Bb {
13137
13137
  }), this.active === I && (this.active = null));
13138
13138
  }, m = (y, E) => {
13139
13139
  if (c) return;
13140
- const x = s ? Ob(s) : null;
13141
- if (x === null || !Number.isFinite(y) || !s || y <= x) {
13140
+ const k = s ? Ob(s) : null;
13141
+ if (k === null || !Number.isFinite(y) || !s || y <= k) {
13142
13142
  E();
13143
13143
  return;
13144
13144
  }
13145
- const O = Math.min(
13145
+ const P = Math.min(
13146
13146
  Fb,
13147
- (y - x) / s.sampleRate * 1e3
13148
- ), N = setTimeout(() => {
13149
- u.delete(N), c || E();
13150
- }, O);
13151
- u.add(N);
13147
+ (y - k) / s.sampleRate * 1e3
13148
+ ), F = setTimeout(() => {
13149
+ u.delete(F), c || E();
13150
+ }, P);
13151
+ u.add(F);
13152
13152
  }, g = (y) => {
13153
13153
  if (!l) {
13154
13154
  l = !0;
@@ -13195,7 +13195,7 @@ class Bb {
13195
13195
  return;
13196
13196
  }
13197
13197
  if (!E.ok) throw E.error;
13198
- const x = E.stream;
13198
+ const k = E.stream;
13199
13199
  if (i = new AudioWorkletNode(s, "lola-pcm-playback", {
13200
13200
  numberOfInputs: 0,
13201
13201
  numberOfOutputs: 1,
@@ -13209,14 +13209,14 @@ class Bb {
13209
13209
  re.debug("Scenario speech playback started"), m(_.data.renderContextFrame, () => {
13210
13210
  try {
13211
13211
  n.onStarted?.();
13212
- } catch (P) {
13213
- re.warn("Speech playback started callback failed", P);
13212
+ } catch (O) {
13213
+ re.warn("Speech playback started callback failed", O);
13214
13214
  }
13215
13215
  });
13216
13216
  return;
13217
13217
  }
13218
13218
  if (_.data.type === "progress") {
13219
- const P = {
13219
+ const O = {
13220
13220
  sourceSample: _.data.sourceSample,
13221
13221
  renderContextFrame: _.data.renderContextFrame,
13222
13222
  mouthOpen: _.data.mouthOpen,
@@ -13224,20 +13224,20 @@ class Bb {
13224
13224
  };
13225
13225
  m(_.data.renderContextFrame, () => {
13226
13226
  try {
13227
- n.onProgress?.(P);
13228
- } catch (B) {
13229
- re.warn("Speech playback progress callback failed", B);
13227
+ n.onProgress?.(O);
13228
+ } catch (V) {
13229
+ re.warn("Speech playback progress callback failed", V);
13230
13230
  }
13231
13231
  });
13232
13232
  return;
13233
13233
  }
13234
13234
  if (_.data.type === "underrun" || _.data.type === "resumed") {
13235
- const P = _.data.type;
13235
+ const O = _.data.type;
13236
13236
  m(_.data.renderContextFrame, () => {
13237
13237
  try {
13238
- P === "underrun" ? n.onUnderrun?.() : n.onResumed?.();
13239
- } catch (B) {
13240
- re.warn("Speech playback lifecycle callback failed", B);
13238
+ O === "underrun" ? n.onUnderrun?.() : n.onResumed?.();
13239
+ } catch (V) {
13240
+ re.warn("Speech playback lifecycle callback failed", V);
13241
13241
  }
13242
13242
  });
13243
13243
  return;
@@ -13253,25 +13253,25 @@ class Bb {
13253
13253
  }, i.connect(s.destination), s.state !== "running")
13254
13254
  throw new Error("Audio playback was blocked");
13255
13255
  if (re.debug("Scenario speech stream opened"), c) {
13256
- await x.cancel();
13256
+ await k.cancel();
13257
13257
  return;
13258
13258
  }
13259
- o = x.getReader();
13260
- let O = 0, N = !1;
13259
+ o = k.getReader();
13260
+ let P = 0, F = !1;
13261
13261
  for (; !c; ) {
13262
- const { done: _, value: P } = await o.read();
13262
+ const { done: _, value: O } = await o.read();
13263
13263
  if (_) break;
13264
- if (!P.byteLength) continue;
13265
- N || (N = !0, re.debug(
13266
- `Scenario speech first PCM chunk received: ${P.byteLength} bytes`
13267
- )), O += P.byteLength;
13268
- const B = P.slice().buffer;
13269
- i.port.postMessage({ type: "chunk", bytes: B }, [B]);
13264
+ if (!O.byteLength) continue;
13265
+ F || (F = !0, re.debug(
13266
+ `Scenario speech first PCM chunk received: ${O.byteLength} bytes`
13267
+ )), P += O.byteLength;
13268
+ const V = O.slice().buffer;
13269
+ i.port.postMessage({ type: "chunk", bytes: V }, [V]);
13270
13270
  }
13271
13271
  if (c) return;
13272
- if (!O) throw new Error("Audio response is empty");
13272
+ if (!P) throw new Error("Audio response is empty");
13273
13273
  re.debug(
13274
- `Scenario speech stream completed: ${O} bytes`
13274
+ `Scenario speech stream completed: ${P} bytes`
13275
13275
  ), i.port.postMessage({ type: "end" });
13276
13276
  } catch (y) {
13277
13277
  a?.then(
@@ -13637,10 +13637,10 @@ const t1 = (t) => {
13637
13637
  super("Voice startup was cancelled");
13638
13638
  }
13639
13639
  }
13640
- const S = (T, A = !0) => {
13641
- A && (g = T), e().localStream?.getAudioTracks().forEach((v) => v.enabled = T), e().inputAudioNode?.port.postMessage({ type: "enabled", value: T }), t({
13642
- microphoneEnabled: T,
13643
- status: T ? "listening" : "idle",
13640
+ const S = (R, A = !0) => {
13641
+ A && (g = R), e().localStream?.getAudioTracks().forEach((v) => v.enabled = R), e().inputAudioNode?.port.postMessage({ type: "enabled", value: R }), t({
13642
+ microphoneEnabled: R,
13643
+ status: R ? "listening" : "idle",
13644
13644
  errorMessage: null,
13645
13645
  errorCode: null
13646
13646
  });
@@ -13653,18 +13653,18 @@ const t1 = (t) => {
13653
13653
  l = null, d = null, p = 0, c = 0, u = 0, a && clearTimeout(a), a = null, i = null, o = null, n.stop(), t({ assistantResponseInProgress: !1 });
13654
13654
  }, E = () => {
13655
13655
  a && clearTimeout(a);
13656
- const T = Math.max(0, u - performance.now());
13656
+ const R = Math.max(0, u - performance.now());
13657
13657
  a = setTimeout(() => {
13658
13658
  a = null, t((A) => ({
13659
13659
  assistantResponseInProgress: !1,
13660
13660
  status: A.microphoneEnabled ? "listening" : "idle"
13661
13661
  }));
13662
- }, T);
13663
- }, x = (T) => {
13662
+ }, R);
13663
+ }, k = (R) => {
13664
13664
  if (i) return;
13665
- const A = l ?? `xai-${T}-${h += 1}`;
13665
+ const A = l ?? `xai-${R}-${h += 1}`;
13666
13666
  let v;
13667
- const R = new ReadableStream({
13667
+ const T = new ReadableStream({
13668
13668
  start: (oe) => {
13669
13669
  v = oe;
13670
13670
  }
@@ -13673,11 +13673,11 @@ const t1 = (t) => {
13673
13673
  u,
13674
13674
  performance.now() + Pa
13675
13675
  ), t({ assistantResponseInProgress: !0 });
13676
- const z = () => n.playPcm16(async () => R, {
13676
+ const z = () => n.playPcm16(async () => T, {
13677
13677
  sampleRate: Dt,
13678
13678
  jitterBufferMs: Pa,
13679
13679
  onStarted: () => {
13680
- e().generation === T && (vt.dispatch({
13680
+ e().generation === R && (vt.dispatch({
13681
13681
  type: "playback-started",
13682
13682
  playbackId: A,
13683
13683
  sampleRate: Dt
@@ -13687,32 +13687,32 @@ const t1 = (t) => {
13687
13687
  onProgress: ({ sourceSample: oe, mouthOpen: ie }) => {
13688
13688
  p = Math.max(p, oe), vt.dispatch({ type: "playback-progress", playbackId: A, sourceSample: oe, mouthOpen: ie });
13689
13689
  }
13690
- }), G = o, X = l, ee = G ? (async () => (await G.catch(() => !1), e().generation !== T || X !== null && f.has(X) ? !1 : z()))() : z();
13691
- o = ee, ee.catch((oe) => {
13692
- e().generation === T && (re.warn("Voice audio playback failed", oe), t({
13690
+ }), G = o, X = l, te = G ? (async () => (await G.catch(() => !1), e().generation !== R || X !== null && f.has(X) ? !1 : z()))() : z();
13691
+ o = te, te.catch((oe) => {
13692
+ e().generation === R && (re.warn("Voice audio playback failed", oe), t({
13693
13693
  status: "error",
13694
13694
  errorMessage: null,
13695
13695
  errorCode: "audio_playback_failed",
13696
13696
  assistantResponseInProgress: !1
13697
13697
  }));
13698
13698
  }).finally(() => {
13699
- o === ee && (o = null, e().generation === T && t((oe) => ({
13699
+ o === te && (o = null, e().generation === R && t((oe) => ({
13700
13700
  assistantResponseInProgress: !1,
13701
13701
  status: oe.status === "error" ? "error" : oe.microphoneEnabled ? "listening" : "idle"
13702
13702
  })));
13703
13703
  });
13704
- }, O = (T, A, v) => {
13704
+ }, P = (R, A, v) => {
13705
13705
  if (e().generation === v)
13706
13706
  try {
13707
- switch (T) {
13707
+ switch (R) {
13708
13708
  case "input_audio_buffer.speech_started":
13709
13709
  {
13710
- const R = l, z = d, G = p;
13710
+ const T = l, z = d, G = p;
13711
13711
  y();
13712
13712
  const X = e();
13713
- R && z && X.socket?.connected && X.session && Fs(X.socket, "voice.playback.interrupt", {
13713
+ T && z && X.socket?.connected && X.session && Fs(X.socket, "voice.playback.interrupt", {
13714
13714
  voiceSessionId: X.session.voiceSessionId,
13715
- responseId: R,
13715
+ responseId: T,
13716
13716
  itemId: z,
13717
13717
  contentIndex: 0,
13718
13718
  playedAudioMs: G / Dt * 1e3,
@@ -13730,24 +13730,24 @@ const t1 = (t) => {
13730
13730
  });
13731
13731
  break;
13732
13732
  case "conversation.item.input_audio_transcription.updated": {
13733
- const R = ls(A, !0);
13733
+ const T = ls(A, !0);
13734
13734
  t({
13735
- customerMessageTranscript: R,
13736
- customerMessageTranscriptVisible: !!R
13735
+ customerMessageTranscript: T,
13736
+ customerMessageTranscriptVisible: !!T
13737
13737
  });
13738
13738
  break;
13739
13739
  }
13740
13740
  case "conversation.item.input_audio_transcription.completed": {
13741
- const R = ls(A, !0);
13741
+ const T = ls(A, !0);
13742
13742
  t({
13743
- customerMessageTranscript: R,
13744
- customerMessageTranscriptVisible: !!R
13743
+ customerMessageTranscript: T,
13744
+ customerMessageTranscriptVisible: !!T
13745
13745
  });
13746
13746
  break;
13747
13747
  }
13748
13748
  case "response.created": {
13749
- const R = Pn(A);
13750
- a && clearTimeout(a), a = null, l && R && l !== R && f.add(l), l = R, c = 0, t({
13749
+ const T = Pn(A);
13750
+ a && clearTimeout(a), a = null, l && T && l !== T && f.add(l), l = T, c = 0, t({
13751
13751
  errorMessage: null,
13752
13752
  errorCode: null,
13753
13753
  assistantResponseInProgress: !0,
@@ -13757,21 +13757,21 @@ const t1 = (t) => {
13757
13757
  break;
13758
13758
  }
13759
13759
  case "response.output_audio.delta": {
13760
- const R = Pn(A);
13761
- if (R && f.has(R) || l && R && R !== l)
13760
+ const T = Pn(A);
13761
+ if (T && f.has(T) || l && T && T !== l)
13762
13762
  break;
13763
- !l && R && (l = R), typeof A.item_id == "string" && (d = A.item_id);
13763
+ !l && T && (l = T), typeof A.item_id == "string" && (d = A.item_id);
13764
13764
  const z = s1(A);
13765
13765
  if (c += z.byteLength, c > Yb)
13766
13766
  throw new Error("Voice audio response is too large");
13767
- if (x(v), u = Math.max(performance.now(), u) + z.byteLength / 2 / Dt * 1e3, u - performance.now() > Jb)
13767
+ if (k(v), u = Math.max(performance.now(), u) + z.byteLength / 2 / Dt * 1e3, u - performance.now() > Jb)
13768
13768
  throw new Error("Voice audio buffer is too large");
13769
13769
  t({ status: "speaking", assistantResponseInProgress: !0 }), i.enqueue(z);
13770
13770
  break;
13771
13771
  }
13772
13772
  case "response.output_audio_transcript.delta": {
13773
- const R = Pn(A);
13774
- if (R && f.has(R) || l && R && R !== l)
13773
+ const T = Pn(A);
13774
+ if (T && f.has(T) || l && T && T !== l)
13775
13775
  break;
13776
13776
  const z = ls(A);
13777
13777
  t((G) => ({
@@ -13781,8 +13781,8 @@ const t1 = (t) => {
13781
13781
  break;
13782
13782
  }
13783
13783
  case "response.output_audio_transcript.done": {
13784
- const R = Pn(A);
13785
- if (R && f.has(R) || l && R && R !== l)
13784
+ const T = Pn(A);
13785
+ if (T && f.has(T) || l && T && T !== l)
13786
13786
  break;
13787
13787
  const z = ls(A, !0);
13788
13788
  t({
@@ -13792,44 +13792,44 @@ const t1 = (t) => {
13792
13792
  break;
13793
13793
  }
13794
13794
  case "response.output_audio.done": {
13795
- const R = Pn(A);
13796
- if (R && f.has(R) || l && R && R !== l)
13795
+ const T = Pn(A);
13796
+ if (T && f.has(T) || l && T && T !== l)
13797
13797
  break;
13798
13798
  i?.close(), i = null;
13799
13799
  break;
13800
13800
  }
13801
13801
  case "response.done": {
13802
- const R = Pn(A);
13803
- if (R && f.has(R) || l && R && R !== l)
13802
+ const T = Pn(A);
13803
+ if (T && f.has(T) || l && T && T !== l)
13804
13804
  break;
13805
13805
  i?.close(), i = null, l = null, c = 0, E();
13806
13806
  break;
13807
13807
  }
13808
13808
  case "error": {
13809
- const R = t1(A);
13809
+ const T = t1(A);
13810
13810
  y(), t((z) => ({
13811
13811
  status: z.microphoneEnabled ? "listening" : "idle",
13812
- errorMessage: R,
13813
- errorCode: R ? null : "session_failed"
13812
+ errorMessage: T,
13813
+ errorCode: T ? null : "session_failed"
13814
13814
  }));
13815
13815
  break;
13816
13816
  }
13817
13817
  }
13818
- } catch (R) {
13819
- re.warn(`Failed to handle voice event ${T}`, R), P("session_failed", "invalid_event");
13818
+ } catch (T) {
13819
+ re.warn(`Failed to handle voice event ${R}`, T), O("session_failed", "invalid_event");
13820
13820
  }
13821
- }, N = (T) => {
13822
- y(), T.inputAudioNode?.port.postMessage({ type: "enabled", value: !1 }), T.inputAudioNode && (T.inputAudioNode.port.onmessage = null, T.inputAudioNode.disconnect()), T.inputAudioContext?.close().catch(() => {
13823
- }), T.socket?.removeAllListeners(), T.socket?.disconnect(), za(T.localStream);
13824
- }, _ = (T, A, v, R) => {
13825
- R?.port.postMessage({ type: "enabled", value: !1 }), R && (R.port.onmessage = null, R.disconnect()), v?.close().catch(() => {
13826
- }), T?.removeAllListeners(), T?.disconnect(), za(A);
13827
- }, P = async (T, A) => {
13821
+ }, F = (R) => {
13822
+ y(), R.inputAudioNode?.port.postMessage({ type: "enabled", value: !1 }), R.inputAudioNode && (R.inputAudioNode.port.onmessage = null, R.inputAudioNode.disconnect()), R.inputAudioContext?.close().catch(() => {
13823
+ }), R.socket?.removeAllListeners(), R.socket?.disconnect(), za(R.localStream);
13824
+ }, _ = (R, A, v, T) => {
13825
+ T?.port.postMessage({ type: "enabled", value: !1 }), T && (T.port.onmessage = null, T.disconnect()), v?.close().catch(() => {
13826
+ }), R?.removeAllListeners(), R?.disconnect(), za(A);
13827
+ }, O = async (R, A) => {
13828
13828
  const v = e();
13829
- if (m = !1, g = !1, C += 1, b = !1, N(v), t({
13829
+ if (m = !1, g = !1, C += 1, b = !1, F(v), t({
13830
13830
  ...bn,
13831
13831
  status: "error",
13832
- errorCode: T,
13832
+ errorCode: R,
13833
13833
  generation: v.generation + 1
13834
13834
  }), v.session && v.config && v.api)
13835
13835
  try {
@@ -13839,18 +13839,18 @@ const t1 = (t) => {
13839
13839
  v.session.voiceSessionId,
13840
13840
  A
13841
13841
  );
13842
- } catch (R) {
13843
- re.warn("Failed to close invalid voice session", R);
13842
+ } catch (T) {
13843
+ re.warn("Failed to close invalid voice session", T);
13844
13844
  }
13845
- }, B = async (T, A, v) => {
13845
+ }, V = async (R, A, v) => {
13846
13846
  if (r || n.isPlaying || e().assistantResponseInProgress)
13847
13847
  throw new Error("Assistant is already speaking");
13848
13848
  r = !0;
13849
13849
  try {
13850
- const R = await T();
13850
+ const T = await R();
13851
13851
  if (e().generation !== A) return !1;
13852
13852
  const z = `intro-${A}-${h += 1}`;
13853
- return await n.play(R, {
13853
+ return await n.play(T, {
13854
13854
  onStarted: () => {
13855
13855
  e().generation === A && (vt.dispatch({
13856
13856
  type: "playback-started",
@@ -13871,7 +13871,7 @@ const t1 = (t) => {
13871
13871
  } finally {
13872
13872
  r = !1;
13873
13873
  }
13874
- }, ne = async (T, A, v, R, z) => {
13874
+ }, q = async (R, A, v, T, z) => {
13875
13875
  if (r || n.isPlaying || e().assistantResponseInProgress)
13876
13876
  throw new Error("Assistant is already speaking");
13877
13877
  r = !0;
@@ -13879,8 +13879,8 @@ const t1 = (t) => {
13879
13879
  let X;
13880
13880
  try {
13881
13881
  if (e().generation !== v) return !1;
13882
- const ee = Va(R);
13883
- return await n.playPcm16(T, {
13882
+ const te = Va(T);
13883
+ return await n.playPcm16(R, {
13884
13884
  sampleRate: A,
13885
13885
  onStarted: () => {
13886
13886
  if (e().generation !== v) {
@@ -13889,27 +13889,27 @@ const t1 = (t) => {
13889
13889
  }
13890
13890
  vt.dispatch({
13891
13891
  type: "playback-started",
13892
- playbackId: R,
13892
+ playbackId: T,
13893
13893
  sampleRate: A
13894
13894
  }), z && (X = Hb({
13895
13895
  source: z,
13896
13896
  runtime: vt,
13897
- playbackId: R,
13897
+ playbackId: T,
13898
13898
  sampleRate: A,
13899
13899
  signal: G.signal
13900
13900
  })), t({ status: "speaking", assistantResponseInProgress: !0 });
13901
13901
  },
13902
- onProgress: ee.onProgress,
13903
- onUnderrun: ee.onUnderrun,
13904
- onResumed: ee.onResumed,
13902
+ onProgress: te.onProgress,
13903
+ onUnderrun: te.onUnderrun,
13904
+ onResumed: te.onResumed,
13905
13905
  onStopped: (oe) => {
13906
- G.abort(), ee.onStopped?.(oe);
13906
+ G.abort(), te.onStopped?.(oe);
13907
13907
  }
13908
13908
  });
13909
13909
  } finally {
13910
13910
  G.abort(), await X, r = !1;
13911
13911
  }
13912
- }, q = async (T, A, v, R, z) => {
13912
+ }, K = async (R, A, v, T, z) => {
13913
13913
  const G = new AudioContext({ latencyHint: "interactive", sampleRate: Dt });
13914
13914
  let X = null;
13915
13915
  try {
@@ -13921,7 +13921,7 @@ const t1 = (t) => {
13921
13921
  "microphone_blocked",
13922
13922
  "Microphone processing was blocked"
13923
13923
  );
13924
- const ee = G.createMediaStreamSource(T);
13924
+ const te = G.createMediaStreamSource(R);
13925
13925
  X = new AudioWorkletNode(G, "lola-pcm-capture", {
13926
13926
  numberOfInputs: 1,
13927
13927
  numberOfOutputs: 1,
@@ -13938,15 +13938,15 @@ const t1 = (t) => {
13938
13938
  ...ve
13939
13939
  }),
13940
13940
  () => {
13941
- P("session_failed", "audio_rejected");
13941
+ O("session_failed", "audio_rejected");
13942
13942
  }
13943
13943
  );
13944
13944
  X.port.onmessage = (ve) => {
13945
- if (ve.data.type !== "chunk" || !(ve.data.bytes instanceof ArrayBuffer) || e().generation !== R || e().socket !== A || !e().microphoneEnabled || !A.connected)
13945
+ if (ve.data.type !== "chunk" || !(ve.data.bytes instanceof ArrayBuffer) || e().generation !== T || e().socket !== A || !e().microphoneEnabled || !A.connected)
13946
13946
  return;
13947
- const Y = new Uint8Array(ve.data.bytes);
13948
- if (Y.byteLength !== 4800) {
13949
- P("session_failed", "invalid_capture_frame");
13947
+ const $ = new Uint8Array(ve.data.bytes);
13948
+ if ($.byteLength !== 4800) {
13949
+ O("session_failed", "invalid_capture_frame");
13950
13950
  return;
13951
13951
  }
13952
13952
  de.enqueue({
@@ -13954,26 +13954,26 @@ const t1 = (t) => {
13954
13954
  captureStartSample: ie,
13955
13955
  sampleCount: 2400,
13956
13956
  capturedAtMonotonicMs: performance.now(),
13957
- audio: n1(Y)
13957
+ audio: n1($)
13958
13958
  }), ie += 2400;
13959
- }, X.port.postMessage({ type: "enabled", value: z }), ee.connect(X);
13959
+ }, X.port.postMessage({ type: "enabled", value: z }), te.connect(X);
13960
13960
  const pe = G.createGain();
13961
13961
  return pe.gain.value = 0, X.connect(pe), pe.connect(G.destination), { context: G, node: X };
13962
- } catch (ee) {
13962
+ } catch (te) {
13963
13963
  throw X?.disconnect(), await G.close().catch(() => {
13964
- }), ee;
13964
+ }), te;
13965
13965
  }
13966
- }, V = async (T, A) => {
13966
+ }, B = async (R, A) => {
13967
13967
  const v = e();
13968
- if (v.socket !== T || !v.config || !v.api || !m || b)
13968
+ if (v.socket !== R || !v.config || !v.api || !m || b)
13969
13969
  return;
13970
- const R = async (ie, de) => {
13970
+ const T = async (ie, de) => {
13971
13971
  if (m = !1, g = !1, C += 1, t({
13972
13972
  ...bn,
13973
13973
  status: "error",
13974
13974
  errorCode: ie,
13975
13975
  generation: v.generation + 1
13976
- }), N(v), v.session)
13976
+ }), F(v), v.session)
13977
13977
  try {
13978
13978
  await vn(
13979
13979
  v.config,
@@ -13992,18 +13992,18 @@ const t1 = (t) => {
13992
13992
  "voice session not found",
13993
13993
  "session renewed"
13994
13994
  ])).has(A)) {
13995
- await R("connection_closed", "socket_closed");
13995
+ await T("connection_closed", "socket_closed");
13996
13996
  return;
13997
13997
  }
13998
13998
  b = !0;
13999
- const { config: z, api: G, session: X } = v, ee = ++C, oe = v.generation + 1;
13999
+ const { config: z, api: G, session: X } = v, te = ++C, oe = v.generation + 1;
14000
14000
  if (t({
14001
14001
  ...bn,
14002
14002
  config: z,
14003
14003
  api: G,
14004
14004
  status: "connecting",
14005
14005
  generation: oe
14006
- }), N(v), X)
14006
+ }), F(v), X)
14007
14007
  try {
14008
14008
  await vn(
14009
14009
  z,
@@ -14014,40 +14014,40 @@ const t1 = (t) => {
14014
14014
  } catch (ie) {
14015
14015
  re.warn("Failed to close interrupted voice session", ie);
14016
14016
  }
14017
- if (!m || C !== ee) {
14017
+ if (!m || C !== te) {
14018
14018
  b = !1;
14019
14019
  return;
14020
14020
  }
14021
14021
  if (await new Promise(
14022
14022
  (ie) => setTimeout(ie, Qb)
14023
- ), !m || C !== ee) {
14023
+ ), !m || C !== te) {
14024
14024
  b = !1;
14025
14025
  return;
14026
14026
  }
14027
14027
  try {
14028
- await k(z, G, {
14028
+ await x(z, G, {
14029
14029
  enableMicrophone: g
14030
14030
  });
14031
14031
  } catch {
14032
14032
  } finally {
14033
14033
  b = !1;
14034
14034
  }
14035
- }, k = async (T, A, v = {}) => {
14035
+ }, x = async (R, A, v = {}) => {
14036
14036
  const {
14037
- session: R,
14037
+ session: T,
14038
14038
  loadSession: z,
14039
14039
  existingSessionId: G,
14040
14040
  scriptedIntro: X,
14041
- enableMicrophone: ee = g
14041
+ enableMicrophone: te = g
14042
14042
  } = v, oe = ++C, ie = e().generation + 1;
14043
14043
  t({
14044
14044
  ...bn,
14045
- config: T,
14045
+ config: R,
14046
14046
  api: A,
14047
14047
  status: "connecting",
14048
14048
  generation: ie
14049
14049
  });
14050
- let de = null, pe = null, ve = R ?? null, Y = null, me = null;
14050
+ let de = null, pe = null, ve = T ?? null, $ = null, me = null;
14051
14051
  const De = () => m && C === oe && e().generation === ie, Le = () => {
14052
14052
  if (!De()) throw new I();
14053
14053
  };
@@ -14075,11 +14075,11 @@ const t1 = (t) => {
14075
14075
  noiseSuppression: ue.noiseSuppression === !0,
14076
14076
  autoGainControl: ue.autoGainControl === !0
14077
14077
  }, Je = () => {
14078
- e().generation === ie && P("microphone_blocked", "microphone_track_ended");
14078
+ e().generation === ie && O("microphone_blocked", "microphone_track_ended");
14079
14079
  };
14080
14080
  ge.addEventListener?.("ended", Je, { once: !0 }), ge.addEventListener?.("mute", Je, { once: !0 }), de.getAudioTracks().forEach(
14081
- (qe) => qe.enabled = !X && ee
14082
- ), ve ??= z ? await z() : await h1(T, A), Le(), pe = o1(T, ve);
14081
+ (qe) => qe.enabled = !X && te
14082
+ ), ve ??= z ? await z() : await h1(R, A), Le(), pe = o1(R, ve);
14083
14083
  let Et = !1, ln = 1;
14084
14084
  pe.on(ve.websocket.serverEvent, (qe) => {
14085
14085
  try {
@@ -14088,12 +14088,12 @@ const t1 = (t) => {
14088
14088
  ve,
14089
14089
  ln
14090
14090
  );
14091
- ln += 1, O(dn.type, dn.event, ie);
14091
+ ln += 1, P(dn.type, dn.event, ie);
14092
14092
  } catch {
14093
- P("session_failed", "invalid_event");
14093
+ O("session_failed", "invalid_event");
14094
14094
  }
14095
14095
  }), pe.on("disconnect", (qe) => {
14096
- Et && V(pe, qe);
14096
+ Et && B(pe, qe);
14097
14097
  }), t({ session: ve, socket: pe, localStream: de });
14098
14098
  try {
14099
14099
  await a1(pe), Le(), await c1(pe, ve, L);
@@ -14101,20 +14101,20 @@ const t1 = (t) => {
14101
14101
  throw Us(qe) && A.onSessionExpired(), qe;
14102
14102
  }
14103
14103
  Et = !0, Le();
14104
- const Yt = await q(
14104
+ const Yt = await K(
14105
14105
  de,
14106
14106
  pe,
14107
14107
  ve,
14108
14108
  ie,
14109
- !X && ee
14109
+ !X && te
14110
14110
  );
14111
- if (Y = Yt.context, me = Yt.node, Le(), t({
14112
- inputAudioContext: Y,
14111
+ if ($ = Yt.context, me = Yt.node, Le(), t({
14112
+ inputAudioContext: $,
14113
14113
  inputAudioNode: me,
14114
- microphoneEnabled: !X && ee
14114
+ microphoneEnabled: !X && te
14115
14115
  }), X) {
14116
- if (!await B(
14117
- () => Tb(T, A, {
14116
+ if (!await V(
14117
+ () => Tb(R, A, {
14118
14118
  audioPath: X.path,
14119
14119
  method: "POST",
14120
14120
  mimeType: El
@@ -14124,19 +14124,19 @@ const t1 = (t) => {
14124
14124
  )) throw new I();
14125
14125
  Le();
14126
14126
  }
14127
- S(ee, !1), t({ assistantResponseInProgress: !1 });
14127
+ S(te, !1), t({ assistantResponseInProgress: !1 });
14128
14128
  } catch (ge) {
14129
14129
  _(
14130
14130
  pe,
14131
14131
  de,
14132
- Y,
14132
+ $,
14133
14133
  me
14134
14134
  );
14135
14135
  const ue = ve?.voiceSessionId ?? G;
14136
14136
  if (ue)
14137
14137
  try {
14138
14138
  await vn(
14139
- T,
14139
+ R,
14140
14140
  A,
14141
14141
  ue,
14142
14142
  ge instanceof I ? "cancelled" : "bootstrap_failed"
@@ -14162,64 +14162,64 @@ const t1 = (t) => {
14162
14162
  ...bn,
14163
14163
  generation: 0,
14164
14164
  actions: {
14165
- updateSession: async (T, A) => {
14165
+ updateSession: async (R, A) => {
14166
14166
  const v = e();
14167
- v.config && (t({ config: T, api: A }), v.socket && m && await V(v.socket, "session renewed"));
14167
+ v.config && (t({ config: R, api: A }), v.socket && m && await B(v.socket, "session renewed"));
14168
14168
  },
14169
- startListening: async (T, A) => {
14169
+ startListening: async (R, A) => {
14170
14170
  const v = e();
14171
14171
  if (v.status !== "connecting") {
14172
14172
  if (v.socket?.connected && v.session) {
14173
14173
  m = !0, S(!0);
14174
14174
  return;
14175
14175
  }
14176
- (v.socket || v.session) && await v.actions.endVoiceChat("restart_voice_session"), m = !0, g = !0, await k(T, A);
14176
+ (v.socket || v.session) && await v.actions.endVoiceChat("restart_voice_session"), m = !0, g = !0, await x(R, A);
14177
14177
  }
14178
14178
  },
14179
- offerConversation: (T) => {
14179
+ offerConversation: (R) => {
14180
14180
  const A = e();
14181
14181
  return A.pendingInvitation || A.socket || A.session ? Promise.reject(
14182
14182
  new Error("Another voice conversation is already active")
14183
- ) : new Promise((v, R) => {
14183
+ ) : new Promise((v, T) => {
14184
14184
  s = {
14185
- commandId: T.commandId,
14185
+ commandId: R.commandId,
14186
14186
  resolve: v,
14187
- reject: R
14187
+ reject: T
14188
14188
  }, t({
14189
- pendingInvitation: T,
14189
+ pendingInvitation: R,
14190
14190
  errorMessage: null,
14191
14191
  errorCode: null
14192
14192
  });
14193
14193
  });
14194
14194
  },
14195
- acceptConversation: async (T, A) => {
14196
- const v = e().pendingInvitation, R = s;
14197
- if (!v || R?.commandId !== v.commandId)
14195
+ acceptConversation: async (R, A) => {
14196
+ const v = e().pendingInvitation, T = s;
14197
+ if (!v || T?.commandId !== v.commandId)
14198
14198
  throw new Error("Voice invitation is no longer available");
14199
14199
  j.setState({
14200
14200
  currentThreadId: v.conversationId
14201
14201
  }), j.getState().actions.setCurrentThreadMessages(v.conversationId);
14202
14202
  try {
14203
- m = !0, g = !0, await k(T, A, {
14204
- loadSession: () => xb(T, A, v.voiceSessionId),
14203
+ m = !0, g = !0, await x(R, A, {
14204
+ loadSession: () => xb(R, A, v.voiceSessionId),
14205
14205
  existingSessionId: v.voiceSessionId,
14206
14206
  scriptedIntro: {
14207
14207
  path: v.introAudioPath,
14208
14208
  text: v.text
14209
14209
  }
14210
- }), s = null, R.resolve();
14210
+ }), s = null, T.resolve();
14211
14211
  } catch (z) {
14212
- throw s = null, R.reject(
14212
+ throw s = null, T.reject(
14213
14213
  z instanceof Error ? z : new Error("Voice session failed")
14214
14214
  ), z;
14215
14215
  }
14216
14216
  },
14217
- declineConversation: async (T, A) => {
14218
- const v = e().pendingInvitation, R = s;
14219
- if (s = null, t({ pendingInvitation: null }), R?.reject(new Error("Voice invitation was declined")), !!v)
14217
+ declineConversation: async (R, A) => {
14218
+ const v = e().pendingInvitation, T = s;
14219
+ if (s = null, t({ pendingInvitation: null }), T?.reject(new Error("Voice invitation was declined")), !!v)
14220
14220
  try {
14221
14221
  await vn(
14222
- T,
14222
+ R,
14223
14223
  A,
14224
14224
  v.voiceSessionId,
14225
14225
  "invitation_declined"
@@ -14228,19 +14228,19 @@ const t1 = (t) => {
14228
14228
  re.warn("Failed to decline Lola voice session", z);
14229
14229
  }
14230
14230
  },
14231
- speakText: async (T, A, v) => {
14232
- const R = e();
14233
- if (r || n.isPlaying || R.assistantResponseInProgress)
14231
+ speakText: async (R, A, v) => {
14232
+ const T = e();
14233
+ if (r || n.isPlaying || T.assistantResponseInProgress)
14234
14234
  throw new Error("Assistant is already speaking");
14235
- const z = R.generation, G = R.microphoneEnabled, X = R.status;
14236
- R.localStream?.getAudioTracks().forEach((ee) => ee.enabled = !1), R.inputAudioNode?.port.postMessage({
14235
+ const z = T.generation, G = T.microphoneEnabled, X = T.status;
14236
+ T.localStream?.getAudioTracks().forEach((te) => te.enabled = !1), T.inputAudioNode?.port.postMessage({
14237
14237
  type: "enabled",
14238
14238
  value: !1
14239
14239
  }), t({ microphoneEnabled: !1 });
14240
14240
  try {
14241
- if (!await ne(
14241
+ if (!await q(
14242
14242
  (oe) => Rb(
14243
- T,
14243
+ R,
14244
14244
  A,
14245
14245
  {
14246
14246
  audioPath: v.audioPath,
@@ -14258,7 +14258,7 @@ const t1 = (t) => {
14258
14258
  v.lipSync ? Dc : void 0
14259
14259
  )) throw new Error("Speech playback was cancelled");
14260
14260
  } finally {
14261
- e().generation === z && (e().localStream?.getAudioTracks().forEach((ee) => ee.enabled = G), e().inputAudioNode?.port.postMessage({
14261
+ e().generation === z && (e().localStream?.getAudioTracks().forEach((te) => te.enabled = G), e().inputAudioNode?.port.postMessage({
14262
14262
  type: "enabled",
14263
14263
  value: G
14264
14264
  }), t({
@@ -14269,7 +14269,7 @@ const t1 = (t) => {
14269
14269
  }
14270
14270
  },
14271
14271
  stopListening: () => S(!1),
14272
- endVoiceChat: async (T = "user_hangup") => {
14272
+ endVoiceChat: async (R = "user_hangup") => {
14273
14273
  const A = e();
14274
14274
  m = !1, g = !1, C += 1, b = !1, A.localStream?.getAudioTracks().forEach((G) => G.enabled = !1), A.inputAudioNode?.port.postMessage({
14275
14275
  type: "enabled",
@@ -14277,24 +14277,24 @@ const t1 = (t) => {
14277
14277
  });
14278
14278
  const v = s;
14279
14279
  s = null, v?.reject(new Error("Voice invitation was dismissed"));
14280
- let R = !1;
14280
+ let T = !1;
14281
14281
  try {
14282
- R = await l1(
14282
+ T = await l1(
14283
14283
  A.socket,
14284
14284
  A.session,
14285
- T
14285
+ R
14286
14286
  );
14287
14287
  } catch (G) {
14288
14288
  re.warn("Failed to disconnect Lola voice socket", G);
14289
14289
  }
14290
14290
  const z = A.generation + 1;
14291
- if (t({ ...bn, generation: z }), N(A), !R && A.session && A.config && A.api)
14291
+ if (t({ ...bn, generation: z }), F(A), !T && A.session && A.config && A.api)
14292
14292
  try {
14293
14293
  await vn(
14294
14294
  A.config,
14295
14295
  A.api,
14296
14296
  A.session.voiceSessionId,
14297
- T
14297
+ R
14298
14298
  );
14299
14299
  } catch (G) {
14300
14300
  re.warn("Failed to end Lola voice session", G);
@@ -14302,7 +14302,7 @@ const t1 = (t) => {
14302
14302
  }
14303
14303
  }
14304
14304
  };
14305
- }), Gy = () => vs((t) => t.actions);
14305
+ }), zy = () => vs((t) => t.actions);
14306
14306
  class Qc extends Error {
14307
14307
  constructor(e, n) {
14308
14308
  super(n), this.status = e;
@@ -15964,7 +15964,6 @@ class W1 {
15964
15964
  now;
15965
15965
  isDocumentVisible;
15966
15966
  diagnostics;
15967
- enabled;
15968
15967
  insertionSequence = 0;
15969
15968
  insertionOrder = /* @__PURE__ */ new Map();
15970
15969
  resolvedWhileOpeningKey = null;
@@ -15972,7 +15971,7 @@ class W1 {
15972
15971
  dragBaseSnapshot = null;
15973
15972
  dragTransientSnapshot = null;
15974
15973
  constructor(e) {
15975
- this.enabled = e.enabled, this.createId = e.createId ?? (() => crypto.randomUUID()), this.now = e.now ?? Date.now, this.isDocumentVisible = e.isDocumentVisible ?? (() => document.visibilityState === "visible"), this.diagnostics = e.diagnostics, this.state = Ha(e.principalSessionId);
15974
+ this.createId = e.createId ?? (() => crypto.randomUUID()), this.now = e.now ?? Date.now, this.isDocumentVisible = e.isDocumentVisible ?? (() => document.visibilityState === "visible"), this.diagnostics = e.diagnostics, this.state = Ha(e.principalSessionId);
15976
15975
  }
15977
15976
  getSnapshot = () => this.state;
15978
15977
  subscribe = (e) => (this.listeners.add(e), () => this.listeners.delete(e));
@@ -15980,9 +15979,6 @@ class W1 {
15980
15979
  setDiagnostics(e) {
15981
15980
  this.diagnostics = e;
15982
15981
  }
15983
- setEnabled(e) {
15984
- this.enabled = e, e || this.clear("ROUTING_CHANGED");
15985
- }
15986
15982
  setRouting(e) {
15987
15983
  this.routing = e, (e.chatOpen || !e.chromeVisible || !e.launcherVisible) && this.clear("ROUTING_CHANGED");
15988
15984
  }
@@ -16232,7 +16228,6 @@ class W1 {
16232
16228
  }));
16233
16229
  }
16234
16230
  admit(e) {
16235
- if (!this.enabled) return "INELIGIBLE";
16236
16231
  if (!this.isDocumentVisible())
16237
16232
  return this.rememberSeen(e.key), this.report("suppressed_hidden_document", e), "SUPPRESSED_HIDDEN_DOCUMENT";
16238
16233
  if (this.routing.chatOpen)
@@ -16495,40 +16490,39 @@ const Ha = (t) => ({
16495
16490
  config: e,
16496
16491
  api: n
16497
16492
  }) => {
16498
- const { t: r } = Tn(), [s, i] = he(!1), o = U(!1), [a, u] = he(null), [c, l] = he(!1), [d, p] = he(!1), [h, f] = he(!1), [m, g] = he(null), C = Dm(), [b, I] = he([]), [S, y] = he("idle"), [E, x] = he(
16493
+ const { t: r } = Tn(), [s, i] = he(!1), o = U(!1), [a, u] = he(null), [c, l] = he(!1), [d, p] = he(!1), [h, f] = he(!1), [m, g] = he(null), C = Dm(), [b, I] = he([]), [S, y] = he("idle"), [E, k] = he(
16499
16494
  null
16500
- ), [O, N] = he(null), [_, P] = he(
16495
+ ), [P, F] = he(null), [_, O] = he(
16501
16496
  null
16502
- ), [B, ne] = he(null), q = U(0), V = U(0), k = U(/* @__PURE__ */ new Map()), T = U(/* @__PURE__ */ new Map()), A = U(0), v = U(null), R = U([]), z = U(
16497
+ ), [V, q] = he(null), K = U(0), B = U(0), x = U(/* @__PURE__ */ new Map()), R = U(/* @__PURE__ */ new Map()), A = U(0), v = U(null), T = U([]), z = U(
16503
16498
  /* @__PURE__ */ new Map()
16504
16499
  ), G = U(
16505
16500
  e.customerInteractionSession.interactionSessionId
16506
- ), X = U(0), ee = U(0), oe = U(null), [ie, de] = he(
16501
+ ), X = U(0), te = U(0), oe = U(null), [ie, de] = he(
16507
16502
  () => !e.hideOpenButton
16508
16503
  ), pe = U(!e.hideOpenButton), ve = le((D) => {
16509
16504
  pe.current = D, de(D);
16510
- }, []), [Y] = he(
16505
+ }, []), [$] = he(
16511
16506
  () => new W1({
16512
- enabled: !!e.compactScenarioPreview?.enabled,
16513
16507
  principalSessionId: e.customerInteractionSession.interactionSessionId,
16514
16508
  diagnostics: (D, W) => re.debug(`[CompactPreview] ${D}`, W)
16515
16509
  })
16516
16510
  ), me = Vs(), De = le(
16517
16511
  (D) => {
16518
16512
  if (G.current === D) return !1;
16519
- G.current = D, X.current += 1, ee.current += 1, oe.current = null;
16513
+ G.current = D, X.current += 1, te.current += 1, oe.current = null;
16520
16514
  const W = v.current;
16521
- W?.leaseTimer !== null && W?.leaseTimer !== void 0 && window.clearTimeout(W.leaseTimer), v.current = null, R.current = [], z.current.clear(), q.current = 0, k.current.clear();
16522
- for (const Q of T.current.values())
16515
+ W?.leaseTimer !== null && W?.leaseTimer !== void 0 && window.clearTimeout(W.leaseTimer), v.current = null, T.current = [], z.current.clear(), K.current = 0, x.current.clear();
16516
+ for (const Q of R.current.values())
16523
16517
  Q.close();
16524
- return T.current.clear(), I([]), ne(null), y("idle"), x(null), N(null), P(null), l(!1), p(!1), f(!1), g(null), Yt(0), ve(!e.hideOpenButton), Y.replacePrincipal(D), n.scenarioInteractionRuntime.transitionSurface("CLOSED", {
16518
+ return R.current.clear(), I([]), q(null), y("idle"), k(null), F(null), O(null), l(!1), p(!1), f(!1), g(null), Yt(0), ve(!e.hideOpenButton), $.replacePrincipal(D), n.scenarioInteractionRuntime.transitionSurface("CLOSED", {
16525
16519
  actor: "SYSTEM",
16526
16520
  reason: "SYSTEM_RESTORE"
16527
16521
  }), o.current = !1, i(!1), u(null), !0;
16528
16522
  },
16529
16523
  [
16530
16524
  n.scenarioInteractionRuntime,
16531
- Y,
16525
+ $,
16532
16526
  e.hideOpenButton,
16533
16527
  ve
16534
16528
  ]
@@ -16538,11 +16532,11 @@ const Ha = (t) => ({
16538
16532
  );
16539
16533
  }, [n.scenarioInteractionRuntime, De]), ge = le(
16540
16534
  (D, W) => {
16541
- ee.current += 1, oe.current = null, Le();
16542
- const Q = Y.getSnapshot();
16543
- !D && Q.active && Q.exitReason === "OPENED_CHAT" && Y.restoreAfterError("");
16535
+ te.current += 1, oe.current = null, Le();
16536
+ const Q = $.getSnapshot();
16537
+ !D && Q.active && Q.exitReason === "OPENED_CHAT" && $.restoreAfterError("");
16544
16538
  const J = D ? !0 : e.hideOpenButton ? !1 : pe.current;
16545
- if (o.current = D, Y.setRouting({
16539
+ if (o.current = D, $.setRouting({
16546
16540
  chatOpen: D,
16547
16541
  chromeVisible: J,
16548
16542
  launcherVisible: !e.hideOpenButton
@@ -16557,7 +16551,7 @@ const Ha = (t) => ({
16557
16551
  },
16558
16552
  [
16559
16553
  n.scenarioInteractionRuntime,
16560
- Y,
16554
+ $,
16561
16555
  e.hideOpenButton,
16562
16556
  Le,
16563
16557
  ve
@@ -16565,12 +16559,12 @@ const Ha = (t) => ({
16565
16559
  ), ue = le(
16566
16560
  (D) => {
16567
16561
  Le();
16568
- const W = Y.getSnapshot(), Q = W.active;
16562
+ const W = $.getSnapshot(), Q = W.active;
16569
16563
  if (!Q) return null;
16570
16564
  if (W.phase === "EXITING" && W.exitReason === "OPENED_CHAT")
16571
16565
  return oe.current;
16572
- const J = ++ee.current, Z = Q.conversationId, ae = Q.principalSessionId, be = W.surfaceEpisodeId;
16573
- Y.beginExit("OPENED_CHAT");
16566
+ const J = ++te.current, Z = Q.conversationId, ae = Q.principalSessionId, be = W.surfaceEpisodeId;
16567
+ $.beginExit("OPENED_CHAT");
16574
16568
  const Me = j.getState(), Qe = Me.actions;
16575
16569
  let xe = null;
16576
16570
  const bt = (Me.currentThreadId === Q.conversationId ? Promise.resolve("SELECTED") : Promise.race([
@@ -16583,26 +16577,26 @@ const Ha = (t) => ({
16583
16577
  })
16584
16578
  ])).then((nt) => {
16585
16579
  if (nt === "TIMED_OUT") {
16586
- const Ke = Y.getSnapshot();
16587
- return ee.current !== J || Ke.active?.conversationId !== Z || Ke.principalSessionId !== ae || Ke.surfaceEpisodeId !== be || Ke.exitReason !== "OPENED_CHAT" || (ee.current += 1, Qe.cancelThreadMessagesRequest(Z), re.warn("Compact preview conversation selection timed out"), Y.restoreAfterError(r("compact.openFailed"))), !1;
16580
+ const Ke = $.getSnapshot();
16581
+ return te.current !== J || Ke.active?.conversationId !== Z || Ke.principalSessionId !== ae || Ke.surfaceEpisodeId !== be || Ke.exitReason !== "OPENED_CHAT" || (te.current += 1, Qe.cancelThreadMessagesRequest(Z), re.warn("Compact preview conversation selection timed out"), $.restoreAfterError(r("compact.openFailed"))), !1;
16588
16582
  }
16589
- const Ae = Y.getSnapshot();
16590
- return ee.current !== J || Ae.active?.conversationId !== Z || Ae.principalSessionId !== ae || Ae.surfaceEpisodeId !== be || Ae.exitReason !== "OPENED_CHAT" ? !1 : j.getState().currentThreadId !== Z ? (re.warn(
16583
+ const Ae = $.getSnapshot();
16584
+ return te.current !== J || Ae.active?.conversationId !== Z || Ae.principalSessionId !== ae || Ae.surfaceEpisodeId !== be || Ae.exitReason !== "OPENED_CHAT" ? !1 : j.getState().currentThreadId !== Z ? (re.warn(
16591
16585
  "Compact preview conversation selection was superseded"
16592
- ), Y.restoreAfterError(r("compact.openFailed")), !1) : (me(st.text), ge(!0, {
16586
+ ), $.restoreAfterError(r("compact.openFailed")), !1) : (me(st.text), ge(!0, {
16593
16587
  ...D,
16594
16588
  sourceCommandId: D.sourceCommandId ?? Ae.active?.attributionHandle ?? Q.attributionHandle
16595
16589
  }), !0);
16596
16590
  }).catch((nt) => {
16597
- const Ae = Y.getSnapshot();
16598
- return ee.current !== J || Ae.active?.conversationId !== Z || Ae.principalSessionId !== ae || Ae.surfaceEpisodeId !== be || (re.warn("Compact preview conversation selection failed", nt), Y.restoreAfterError(r("compact.openFailed"))), !1;
16591
+ const Ae = $.getSnapshot();
16592
+ return te.current !== J || Ae.active?.conversationId !== Z || Ae.principalSessionId !== ae || Ae.surfaceEpisodeId !== be || (re.warn("Compact preview conversation selection failed", nt), $.restoreAfterError(r("compact.openFailed"))), !1;
16599
16593
  }).finally(() => {
16600
16594
  xe !== null && window.clearTimeout(xe), oe.current === bt && (oe.current = null);
16601
16595
  });
16602
16596
  return oe.current = bt, bt;
16603
16597
  },
16604
16598
  [
16605
- Y,
16599
+ $,
16606
16600
  me,
16607
16601
  Le,
16608
16602
  r,
@@ -16620,57 +16614,53 @@ const Ha = (t) => ({
16620
16614
  ), Je = U(null), Et = ie, [ln, Yt] = he(0), [qe, dn] = he(
16621
16615
  () => window.innerWidth <= Fa
16622
16616
  );
16623
- Cb(e, n), K(() => {
16617
+ Cb(e, n), Y(() => {
16624
16618
  const D = e.customerInteractionSession.interactionSessionId;
16625
16619
  De(D);
16626
16620
  }, [
16627
16621
  e.customerInteractionSession.interactionSessionId,
16628
16622
  De
16629
- ]), K(() => {
16630
- Y.setEnabled(
16631
- !!e.compactScenarioPreview?.enabled
16632
- );
16633
- }, [Y, e.compactScenarioPreview?.enabled]), K(() => {
16634
- Y.setRouting({
16623
+ ]), Y(() => {
16624
+ $.setRouting({
16635
16625
  chatOpen: s,
16636
16626
  chromeVisible: Et,
16637
16627
  launcherVisible: !e.hideOpenButton
16638
16628
  });
16639
- }, [Y, e.hideOpenButton, Et, s]), K(() => {
16629
+ }, [$, e.hideOpenButton, Et, s]), Y(() => {
16640
16630
  vs.getState().actions.updateSession(e, n).catch((D) => re.warn("Voice session renewal failed", D));
16641
- }, [n, e]), K(() => {
16631
+ }, [n, e]), Y(() => {
16642
16632
  const D = () => {
16643
16633
  const W = window.innerWidth <= Fa;
16644
16634
  dn(W), W || l(!1);
16645
16635
  };
16646
16636
  return window.addEventListener("resize", D), () => window.removeEventListener("resize", D);
16647
- }, []), K(() => (n.registerSetOpen(L), () => {
16637
+ }, []), Y(() => (n.registerSetOpen(L), () => {
16648
16638
  n.registerSetOpen(null);
16649
- }), [n, L]), K(() => {
16639
+ }), [n, L]), Y(() => {
16650
16640
  u(n.scenarioInteractionRuntime.getSurfaceEpisodeId());
16651
16641
  }, [
16652
16642
  n.scenarioInteractionRuntime,
16653
16643
  e.customerInteractionSession.interactionSessionId
16654
16644
  ]);
16655
16645
  const Ze = le((D) => {
16656
- const W = R.current.filter(
16646
+ const W = T.current.filter(
16657
16647
  ({ context: Q }) => Q.commandId !== D
16658
16648
  );
16659
- R.current = W, I(W);
16649
+ T.current = W, I(W);
16660
16650
  }, []), tt = le(
16661
16651
  (D) => {
16662
16652
  const W = D.context.commandId;
16663
- k.current.delete(W), T.current.get(W)?.close(), T.current.delete(W), v.current?.commandId === W && (v.current.leaseTimer !== null && window.clearTimeout(v.current.leaseTimer), v.current = null, N(null)), B?.commandId === W && (Ga(
16653
+ x.current.delete(W), R.current.get(W)?.close(), R.current.delete(W), v.current?.commandId === W && (v.current.leaseTimer !== null && window.clearTimeout(v.current.leaseTimer), v.current = null, F(null)), V?.commandId === W && (Ga(
16664
16654
  e,
16665
16655
  n,
16666
- B.challengeId
16656
+ V.challengeId
16667
16657
  ).catch(
16668
16658
  (J) => re.warn("Telegram link challenge cancellation failed", J)
16669
- ), ne(null)), E === W && (x(null), y("idle"), P(null)), Ze(W);
16659
+ ), q(null)), E === W && (k(null), y("idle"), O(null)), Ze(W);
16670
16660
  },
16671
- [n, e, E, Ze, B]
16661
+ [n, e, E, Ze, V]
16672
16662
  );
16673
- K(() => {
16663
+ Y(() => {
16674
16664
  const D = b.flatMap((Z) => {
16675
16665
  const ae = Z.context.expiresAt ? Date.parse(Z.context.expiresAt) : Number.NaN;
16676
16666
  return Number.isFinite(ae) ? [{ expiresAt: ae, target: Z }] : [];
@@ -16680,7 +16670,7 @@ const Ha = (t) => ({
16680
16670
  const Z = Date.now();
16681
16671
  for (const { expiresAt: ae, target: be } of D) {
16682
16672
  if (ae > Z) break;
16683
- R.current.some(
16673
+ T.current.some(
16684
16674
  ({ context: Me }) => Me.commandId === be.context.commandId
16685
16675
  ) && tt(be);
16686
16676
  }
@@ -16700,70 +16690,70 @@ const Ha = (t) => ({
16700
16690
  return J(), () => {
16701
16691
  Q !== void 0 && window.clearTimeout(Q);
16702
16692
  };
16703
- }, [b, tt]), K(() => (Y.setDiagnostics((D, W) => {
16693
+ }, [b, tt]), Y(() => ($.setDiagnostics((D, W) => {
16704
16694
  if (re.debug(`[CompactPreview] ${D}`, W), D === "expired" && W?.kind === "CTA" && typeof W.subjectId == "string") {
16705
- const Q = R.current.find(
16695
+ const Q = T.current.find(
16706
16696
  ({ context: J }) => J.commandId === W.subjectId
16707
16697
  );
16708
16698
  Q && tt(Q);
16709
16699
  }
16710
- }), () => Y.setDiagnostics(void 0)), [tt, Y]);
16700
+ }), () => $.setDiagnostics(void 0)), [tt, $]);
16711
16701
  const Ut = le(
16712
16702
  async (D) => {
16713
- const W = X.current, Q = ++V.current;
16714
- k.current.set(D.commandId, Q);
16703
+ const W = X.current, Q = ++B.current;
16704
+ x.current.set(D.commandId, Q);
16715
16705
  const J = () => {
16716
16706
  const ae = D.expiresAt ? Date.parse(D.expiresAt) : Number.NaN;
16717
- return W === X.current && k.current.get(D.commandId) === Q && R.current.some(
16707
+ return W === X.current && x.current.get(D.commandId) === Q && T.current.some(
16718
16708
  ({ context: be }) => be.commandId === D.commandId
16719
16709
  ) && (!Number.isFinite(ae) || ae > Date.now());
16720
16710
  };
16721
- if (B && B.commandId !== D.commandId)
16711
+ if (V && V.commandId !== D.commandId)
16722
16712
  throw new Error("Another Telegram connection is awaiting confirmation");
16723
- if (!B) {
16713
+ if (!V) {
16724
16714
  const ae = window.open("about:blank", "_blank");
16725
- ae && (ae.opener = null, T.current.set(D.commandId, ae)), x(D.commandId), y("creating"), P(null);
16715
+ ae && (ae.opener = null, R.current.set(D.commandId, ae)), k(D.commandId), y("creating"), O(null);
16726
16716
  try {
16727
16717
  const be = await p1(
16728
16718
  e,
16729
16719
  n,
16730
- [D.commandId, q.current || null].filter((Me) => Me !== null).join(":")
16720
+ [D.commandId, K.current || null].filter((Me) => Me !== null).join(":")
16731
16721
  );
16732
- return J() ? (ae && !ae.closed && (ae.location.href = be.deepLink), ne({
16722
+ return J() ? (ae && !ae.closed && (ae.location.href = be.deepLink), q({
16733
16723
  commandId: D.commandId,
16734
16724
  challengeId: be.id,
16735
16725
  botUsername: be.botUsername,
16736
16726
  deepLink: be.deepLink,
16737
16727
  manualCommand: be.manualCommand
16738
- }), y("awaiting_confirmation"), P(
16728
+ }), y("awaiting_confirmation"), O(
16739
16729
  ae ? "cta.telegramPopupOpened" : "cta.telegramPopupBlocked"
16740
- ), "AWAITING_CONFIRMATION") : (ae?.close(), T.current.delete(D.commandId), Ga(e, n, be.id).catch(
16730
+ ), "AWAITING_CONFIRMATION") : (ae?.close(), R.current.delete(D.commandId), Ga(e, n, be.id).catch(
16741
16731
  (Me) => re.warn(
16742
16732
  "Stale Telegram link challenge cancellation failed",
16743
16733
  Me
16744
16734
  )
16745
16735
  ), "AWAITING_CONFIRMATION");
16746
16736
  } catch (be) {
16747
- if (ae?.close(), T.current.delete(D.commandId), !J())
16737
+ if (ae?.close(), R.current.delete(D.commandId), !J())
16748
16738
  return "AWAITING_CONFIRMATION";
16749
- throw y("idle"), P("cta.telegramLinkFailed"), be;
16739
+ throw y("idle"), O("cta.telegramLinkFailed"), be;
16750
16740
  }
16751
16741
  }
16752
- y("confirming"), P(null);
16742
+ y("confirming"), O(null);
16753
16743
  const Z = await m1(
16754
16744
  e,
16755
16745
  n,
16756
- B.challengeId
16746
+ V.challengeId
16757
16747
  );
16758
16748
  if (!J())
16759
16749
  return "AWAITING_CONFIRMATION";
16760
16750
  if (Z.linked || Z.challengeStatus === "CONFIRMED")
16761
- return ne(null), y("idle"), x(null), k.current.delete(D.commandId), T.current.delete(D.commandId), Ze(D.commandId), "COMPLETED";
16751
+ return q(null), y("idle"), k(null), x.current.delete(D.commandId), R.current.delete(D.commandId), Ze(D.commandId), "COMPLETED";
16762
16752
  if (Z.challengeStatus === "PENDING_CONFIRMATION") {
16763
16753
  const ae = await g1(
16764
16754
  e,
16765
16755
  n,
16766
- B.challengeId
16756
+ V.challengeId
16767
16757
  );
16768
16758
  if (!J())
16769
16759
  return "AWAITING_CONFIRMATION";
@@ -16771,11 +16761,11 @@ const Ha = (t) => ({
16771
16761
  throw new Error(
16772
16762
  "Telegram link confirmation did not activate the link"
16773
16763
  );
16774
- return ne(null), y("idle"), x(null), k.current.delete(D.commandId), T.current.delete(D.commandId), Ze(D.commandId), "COMPLETED";
16764
+ return q(null), y("idle"), k(null), x.current.delete(D.commandId), R.current.delete(D.commandId), Ze(D.commandId), "COMPLETED";
16775
16765
  }
16776
- return Z.challengeStatus === "EXPIRED" || Z.challengeStatus === "REVOKED" ? (q.current += 1, ne(null), y("idle"), P("cta.telegramLinkExpired"), "AWAITING_CONFIRMATION") : (y("awaiting_confirmation"), P("cta.telegramPressStart"), "AWAITING_CONFIRMATION");
16766
+ return Z.challengeStatus === "EXPIRED" || Z.challengeStatus === "REVOKED" ? (K.current += 1, q(null), y("idle"), O("cta.telegramLinkExpired"), "AWAITING_CONFIRMATION") : (y("awaiting_confirmation"), O("cta.telegramPressStart"), "AWAITING_CONFIRMATION");
16777
16767
  },
16778
- [n, e, Ze, B]
16768
+ [n, e, Ze, V]
16779
16769
  ), kt = le(
16780
16770
  (D) => {
16781
16771
  const W = n.scenarioInteractionRuntime.getPrincipalSessionId();
@@ -16790,48 +16780,48 @@ const Ha = (t) => ({
16790
16780
  principalSessionId: W,
16791
16781
  threadId: be,
16792
16782
  afterMessageId: Qe ? Z.id : xe.at(-1)?.id ?? null
16793
- }, bt = R.current.findIndex(
16783
+ }, bt = T.current.findIndex(
16794
16784
  ({ context: Ct }) => Ct.commandId === Me.commandId
16795
- ), nt = bt === -1 ? [...R.current, Tt] : R.current.map(
16785
+ ), nt = bt === -1 ? [...T.current, Tt] : T.current.map(
16796
16786
  (Ct, Ke) => Ke === bt ? Tt : Ct
16797
16787
  );
16798
16788
  let Ae;
16799
16789
  if (nt.length > ja) {
16800
16790
  const Ct = new Set(
16801
16791
  [
16802
- Y.getSnapshot().active,
16803
- ...Y.getSnapshot().queue
16792
+ $.getSnapshot().active,
16793
+ ...$.getSnapshot().queue
16804
16794
  ].filter((Jt) => Jt?.kind === "CTA").map((Jt) => Jt.subjectId)
16805
16795
  ), Ke = /* @__PURE__ */ new Set([
16806
16796
  v.current?.commandId,
16807
16797
  E,
16808
- B?.commandId,
16798
+ V?.commandId,
16809
16799
  ...Ct
16810
16800
  ]), Kr = nt.findIndex(
16811
16801
  ({ context: Jt }) => Jt.commandId !== Me.commandId && !Ke.has(Jt.commandId)
16812
16802
  );
16813
16803
  Kr >= 0 && ([Ae] = nt.splice(Kr, 1));
16814
16804
  }
16815
- R.current = nt, I(nt), Ae && (k.current.delete(Ae.context.commandId), T.current.get(Ae.context.commandId)?.close(), T.current.delete(Ae.context.commandId), re.warn("Evicted stale CTA after reaching the retention limit", {
16805
+ T.current = nt, I(nt), Ae && (x.current.delete(Ae.context.commandId), R.current.get(Ae.context.commandId)?.close(), R.current.delete(Ae.context.commandId), re.warn("Evicted stale CTA after reaching the retention limit", {
16816
16806
  commandId: Ae.context.commandId,
16817
16807
  limit: ja
16818
- })), D.conversationId && Y.receiveCta(Me);
16808
+ })), D.conversationId && $.receiveCta(Me);
16819
16809
  },
16820
16810
  [
16821
16811
  n.scenarioInteractionRuntime,
16822
- Y,
16812
+ $,
16823
16813
  E,
16824
16814
  De,
16825
- B?.commandId
16815
+ V?.commandId
16826
16816
  ]
16827
16817
  );
16828
- K(() => n.commandRuntime.setInternalHandlers({
16818
+ Y(() => n.commandRuntime.setInternalHandlers({
16829
16819
  setAssistantVisible: (D, W) => {
16830
16820
  ve(D), D || ge(!1, {
16831
16821
  actor: "SCENARIO",
16832
16822
  reason: "SCENARIO_COMMAND",
16833
16823
  sourceCommandId: W
16834
- }), Y.setRouting({
16824
+ }), $.setRouting({
16835
16825
  chatOpen: D ? o.current : !1,
16836
16826
  chromeVisible: D,
16837
16827
  launcherVisible: !e.hideOpenButton
@@ -16868,7 +16858,7 @@ const Ha = (t) => ({
16868
16858
  }
16869
16859
  }), [
16870
16860
  n,
16871
- Y,
16861
+ $,
16872
16862
  e,
16873
16863
  Ut,
16874
16864
  me,
@@ -16912,7 +16902,7 @@ const Ha = (t) => ({
16912
16902
  commandId: Z.commandId,
16913
16903
  leaseTimer: null
16914
16904
  };
16915
- v.current = Me, N(Z.commandId);
16905
+ v.current = Me, F(Z.commandId);
16916
16906
  const Qe = new Promise(
16917
16907
  (xe) => {
16918
16908
  Me.leaseTimer = window.setTimeout(() => {
@@ -16920,11 +16910,11 @@ const Ha = (t) => ({
16920
16910
  xe(wi);
16921
16911
  return;
16922
16912
  }
16923
- v.current = null, N(null), Z.action === "connect_telegram" && (k.current.delete(Z.commandId), T.current.get(
16913
+ v.current = null, F(null), Z.action === "connect_telegram" && (x.current.delete(Z.commandId), R.current.get(
16924
16914
  Z.commandId
16925
- )?.close(), T.current.delete(Z.commandId), x(
16915
+ )?.close(), R.current.delete(Z.commandId), k(
16926
16916
  (bt) => bt === Z.commandId ? null : bt
16927
- ), y("idle"), P(null)), Ze(Z.commandId), xe(wi);
16917
+ ), y("idle"), O(null)), Ze(Z.commandId), xe(wi);
16928
16918
  }, Z1);
16929
16919
  }
16930
16920
  );
@@ -16938,17 +16928,17 @@ const Ha = (t) => ({
16938
16928
  n.commandRuntime.executeCtaAction(Z),
16939
16929
  Qe
16940
16930
  ]);
16941
- return xe === wi || ae !== X.current ? "TERMINAL_FAILURE" : R.current.some(
16931
+ return xe === wi || ae !== X.current ? "TERMINAL_FAILURE" : T.current.some(
16942
16932
  ({ context: Tt }) => Tt.commandId === Z.commandId
16943
- ) ? xe === "COMPLETED" || xe === "TERMINAL_FAILURE" ? (Ze(Z.commandId), E === Z.commandId && (x(null), y("idle"), P(null)), xe) : xe === "RETRYABLE_FAILURE" ? (y(B ? "awaiting_confirmation" : "idle"), P(
16933
+ ) ? xe === "COMPLETED" || xe === "TERMINAL_FAILURE" ? (Ze(Z.commandId), E === Z.commandId && (k(null), y("idle"), O(null)), xe) : xe === "RETRYABLE_FAILURE" ? (y(V ? "awaiting_confirmation" : "idle"), O(
16944
16934
  Z.action === "connect_telegram" ? "cta.telegramConnectFailed" : null
16945
16935
  ), "RETRYABLE_FAILURE") : "AWAITING_CONFIRMATION" : xe;
16946
16936
  } catch (xe) {
16947
- return re.error("CTA action failed", xe), ae !== X.current || !R.current.some(
16937
+ return re.error("CTA action failed", xe), ae !== X.current || !T.current.some(
16948
16938
  ({ context: Tt }) => Tt.commandId === Z.commandId
16949
16939
  ) || Ze(Z.commandId), "TERMINAL_FAILURE";
16950
16940
  } finally {
16951
- Me.leaseTimer !== null && (window.clearTimeout(Me.leaseTimer), Me.leaseTimer = null), ae === X.current && v.current?.token === be && (v.current = null, N(null));
16941
+ Me.leaseTimer !== null && (window.clearTimeout(Me.leaseTimer), Me.leaseTimer = null), ae === X.current && v.current?.token === be && (v.current = null, F(null));
16952
16942
  }
16953
16943
  },
16954
16944
  [
@@ -16961,7 +16951,7 @@ const Ha = (t) => ({
16961
16951
  Ze,
16962
16952
  mt,
16963
16953
  De,
16964
- B
16954
+ V
16965
16955
  ]
16966
16956
  ), at = le(
16967
16957
  (D, W) => {
@@ -16987,7 +16977,7 @@ const Ha = (t) => ({
16987
16977
  ({ context: Z }) => Z.commandId === D
16988
16978
  ), Q = E === D, J = Q ? S === "creating" ? r("cta.preparingLink") : S === "awaiting_confirmation" ? r("cta.confirmTelegram") : S === "confirming" ? r("cta.confirming") : W?.context.label ?? null : W?.context.label ?? null;
16989
16979
  return {
16990
- busy: O === D || Q && (S === "creating" || S === "confirming"),
16980
+ busy: P === D || Q && (S === "creating" || S === "confirming"),
16991
16981
  buttonLabel: J,
16992
16982
  feedback: Q && _ ? r(_) : null
16993
16983
  };
@@ -16995,7 +16985,7 @@ const Ha = (t) => ({
16995
16985
  [
16996
16986
  b,
16997
16987
  _,
16998
- O,
16988
+ P,
16999
16989
  S,
17000
16990
  E,
17001
16991
  r
@@ -17025,11 +17015,11 @@ const Ha = (t) => ({
17025
17015
  ctaBusy: xt.busy,
17026
17016
  ctaButtonLabel: xt.buttonLabel,
17027
17017
  ctaFeedback: xt.feedback,
17028
- ctaTelegramBotUsername: B && B.commandId === je?.context.commandId ? B.botUsername : null,
17029
- ctaTelegramDeepLink: B && B.commandId === je?.context.commandId ? B.deepLink : null,
17030
- ctaManualCommand: B && B.commandId === je?.context.commandId ? B.manualCommand : null,
17018
+ ctaTelegramBotUsername: V && V.commandId === je?.context.commandId ? V.botUsername : null,
17019
+ ctaTelegramDeepLink: V && V.commandId === je?.context.commandId ? V.deepLink : null,
17020
+ ctaManualCommand: V && V.commandId === je?.context.commandId ? V.manualCommand : null,
17031
17021
  hasUnreadCta: Zr,
17032
- compactPreviewController: Y,
17022
+ compactPreviewController: $,
17033
17023
  getCtaPresentation: nr,
17034
17024
  executeCta: Ue,
17035
17025
  dismissCta: at
@@ -17155,12 +17145,12 @@ function $1(t, e, n, r, s) {
17155
17145
  0,
17156
17146
  u - (t.y + Fe + fs)
17157
17147
  ), g = (I, S) => {
17158
- const y = I === "above" ? t.y - fs - d : t.y + Fe + fs, E = Vt(y, o, u - d), x = { x: h, y: E, width: c, height: d }, O = Math.max(0, d - S);
17148
+ const y = I === "above" ? t.y - fs - d : t.y + Fe + fs, E = Vt(y, o, u - d), k = { x: h, y: E, width: c, height: d }, P = Math.max(0, d - S);
17159
17149
  return {
17160
17150
  placement: I,
17161
17151
  y: E,
17162
- avoidanceFailed: !!(s && nC(x, s)),
17163
- score: O * c * 2 + (s ? tC(x, s) : 0)
17152
+ avoidanceFailed: !!(s && nC(k, s)),
17153
+ score: P * c * 2 + (s ? tC(k, s) : 0)
17164
17154
  };
17165
17155
  }, C = f >= m ? [g("above", f), g("below", m)] : [
17166
17156
  g("below", m),
@@ -17327,27 +17317,27 @@ function lC({
17327
17317
  onCompactPreviewCollapse: m,
17328
17318
  children: g
17329
17319
  }) {
17330
- const { direction: C, locale: b, t: I } = Tn(), [S] = he(() => Ei(h)), [y, E] = he(S.launcher), [x, O] = he(S.panel), [N, _] = he(null), [P, B] = he(!1), [ne, q] = he(0), [V, k] = he({
17320
+ const { direction: C, locale: b, t: I } = Tn(), [S] = he(() => Ei(h)), [y, E] = he(S.launcher), [k, P] = he(S.panel), [F, _] = he(null), [O, V] = he(!1), [q, K] = he(0), [B, x] = he({
17331
17321
  width: 320,
17332
17322
  height: 220
17333
- }), [T, A] = he(null), [v, R] = he(dC), z = U({ launcher: y, panel: x }), G = U({
17323
+ }), [R, A] = he(null), [v, T] = he(dC), z = U({ launcher: y, panel: k }), G = U({
17334
17324
  launcher: S.launcherDock,
17335
- panel: x
17336
- }), X = U(!1), ee = U(null), oe = U(null), ie = U(null), de = U(null), pe = U(null), ve = U(null), Y = U(!1), me = U(null), De = U(!1), Le = U(null), ge = U(null), ue = U(null), L = U(null), Je = U(null), Et = U(null), ln = U(null), Yt = U(r), qe = U(t), dn = U(!1), Ze = U(!1), tt = U(null), Ut = U(null), kt = U(null), Xr = U({
17325
+ panel: k
17326
+ }), X = U(!1), te = U(null), oe = U(null), ie = U(null), de = U(null), pe = U(null), ve = U(null), $ = U(!1), me = U(null), De = U(!1), Le = U(null), ge = U(null), ue = U(null), L = U(null), Je = U(null), Et = U(null), ln = U(null), Yt = U(r), qe = U(t), dn = U(!1), Ze = U(!1), tt = U(null), Ut = U(null), kt = U(null), Xr = U({
17337
17327
  drag: !1,
17338
17328
  focusCollision: !1
17339
17329
  }), Zr = U(!1), je = U(h), jr = Ki(), Rn = U(f), mt = !!c;
17340
- K(() => {
17330
+ Y(() => {
17341
17331
  Rn.current = f;
17342
17332
  }, [f]);
17343
17333
  const Ue = le(
17344
17334
  () => Q1(zn(), v),
17345
17335
  [v]
17346
17336
  ), at = le(
17347
- (w, F, $ = !1) => {
17348
- const te = Xr.current;
17349
- te[w] = F;
17350
- const ce = te.drag || te.focusCollision, Ce = Je.current;
17337
+ (w, N, ee = !1) => {
17338
+ const ne = Xr.current;
17339
+ ne[w] = N;
17340
+ const ce = ne.drag || ne.focusCollision, Ce = Je.current;
17351
17341
  if (Ce)
17352
17342
  if (ce) {
17353
17343
  const we = Ce.getRootNode(), ke = we instanceof ShadowRoot ? we.activeElement : document.activeElement;
@@ -17359,48 +17349,48 @@ function lC({
17359
17349
  Ce.dataset.suspended = "true", Ce.setAttribute("aria-hidden", "true"), Ce.inert = !0;
17360
17350
  } else
17361
17351
  Ce.removeAttribute("data-suspended"), Ce.removeAttribute("aria-hidden"), Ce.inert = !1;
17362
- Zr.current !== ce && (Zr.current = ce, kt.current !== null && (window.clearTimeout(kt.current), kt.current = null), $ ? kt.current = window.setTimeout(() => {
17352
+ Zr.current !== ce && (Zr.current = ce, kt.current !== null && (window.clearTimeout(kt.current), kt.current = null), ee ? kt.current = window.setTimeout(() => {
17363
17353
  kt.current = null, Rn.current?.(ce);
17364
17354
  }, 0) : Rn.current?.(ce));
17365
17355
  },
17366
17356
  []
17367
17357
  );
17368
- K(() => {
17358
+ Y(() => {
17369
17359
  const w = window.matchMedia?.("(prefers-reduced-motion: reduce)");
17370
17360
  if (!w) return;
17371
- const F = () => {
17361
+ const N = () => {
17372
17362
  !w.matches || !pe.current || (pe.current.cancel(), pe.current = null, de.current !== null && (window.clearTimeout(de.current), de.current = null), at("drag", !1, !0));
17373
17363
  };
17374
- return w.addEventListener?.("change", F), () => w.removeEventListener?.("change", F);
17364
+ return w.addEventListener?.("change", N), () => w.removeEventListener?.("change", N);
17375
17365
  }, [at]), Cn(() => {
17376
17366
  const w = ge.current;
17377
17367
  if (!w) return;
17378
- const F = () => {
17379
- const $ = hC(w);
17380
- R(
17381
- (te) => fC(te, $) ? te : $
17368
+ const N = () => {
17369
+ const ee = hC(w);
17370
+ T(
17371
+ (ne) => fC(ne, ee) ? ne : ee
17382
17372
  );
17383
17373
  };
17384
- return F(), window.addEventListener("resize", F), window.visualViewport?.addEventListener("resize", F), window.visualViewport?.addEventListener("scroll", F), () => {
17385
- window.removeEventListener("resize", F), window.visualViewport?.removeEventListener("resize", F), window.visualViewport?.removeEventListener("scroll", F);
17374
+ return N(), window.addEventListener("resize", N), window.visualViewport?.addEventListener("resize", N), window.visualViewport?.addEventListener("scroll", N), () => {
17375
+ window.removeEventListener("resize", N), window.visualViewport?.removeEventListener("resize", N), window.visualViewport?.removeEventListener("scroll", N);
17386
17376
  };
17387
17377
  }, []);
17388
17378
  const nr = le((w) => {
17389
17379
  z.current = { ...z.current, launcher: w }, E(w);
17390
17380
  }, []), xt = le(
17391
- (w, F = !0) => {
17392
- const $ = Er(w, Ue());
17393
- F && (G.current = {
17381
+ (w, N = !0) => {
17382
+ const ee = Er(w, Ue());
17383
+ N && (G.current = {
17394
17384
  ...G.current,
17395
17385
  launcher: w
17396
- }), nr($);
17386
+ }), nr(ee);
17397
17387
  },
17398
17388
  [Ue, nr]
17399
- ), gt = le((w, F = !0) => {
17400
- z.current = { ...z.current, panel: w }, F && (G.current = {
17389
+ ), gt = le((w, N = !0) => {
17390
+ z.current = { ...z.current, panel: w }, N && (G.current = {
17401
17391
  ...G.current,
17402
17392
  panel: w
17403
- }), O(w);
17393
+ }), P(w);
17404
17394
  }, []), D = le(() => {
17405
17395
  const w = G.current;
17406
17396
  Ja(
@@ -17416,31 +17406,31 @@ function lC({
17416
17406
  Cn(() => {
17417
17407
  const w = je.current;
17418
17408
  if (!Ya(w, zn())) return;
17419
- const F = Ei(w);
17409
+ const N = Ei(w);
17420
17410
  G.current = {
17421
- launcher: F.launcherDock,
17422
- panel: F.panel
17411
+ launcher: N.launcherDock,
17412
+ panel: N.panel
17423
17413
  }, z.current = {
17424
- launcher: F.launcher,
17425
- panel: F.panel
17426
- }, E(F.launcher), O(F.panel);
17427
- }, []), K(() => {
17414
+ launcher: N.launcher,
17415
+ panel: N.panel
17416
+ }, E(N.launcher), P(N.panel);
17417
+ }, []), Y(() => {
17428
17418
  if (je.current === h) return;
17429
17419
  const w = window.requestAnimationFrame(() => {
17430
17420
  je.current = h, Ya(h, zn());
17431
- const F = Ei(h);
17421
+ const N = Ei(h);
17432
17422
  G.current = {
17433
- launcher: F.launcherDock,
17434
- panel: F.panel
17423
+ launcher: N.launcherDock,
17424
+ panel: N.panel
17435
17425
  }, z.current = {
17436
- launcher: F.launcher,
17437
- panel: F.panel
17438
- }, E(F.launcher), O(F.panel);
17426
+ launcher: N.launcher,
17427
+ panel: N.panel
17428
+ }, E(N.launcher), P(N.panel);
17439
17429
  });
17440
17430
  return () => window.cancelAnimationFrame(w);
17441
17431
  }, [h]);
17442
17432
  const W = le(
17443
- (w, F, $, te = !0) => {
17433
+ (w, N, ee, ne = !0) => {
17444
17434
  switch (w) {
17445
17435
  case "launcher":
17446
17436
  return;
@@ -17448,64 +17438,64 @@ function lC({
17448
17438
  gt(
17449
17439
  Lr(
17450
17440
  {
17451
- ...F,
17452
- x: F.x + $.x,
17453
- y: F.y + $.y
17441
+ ...N,
17442
+ x: N.x + ee.x,
17443
+ y: N.y + ee.y
17454
17444
  },
17455
17445
  Ue()
17456
17446
  ),
17457
- te
17447
+ ne
17458
17448
  );
17459
17449
  return;
17460
17450
  default:
17461
17451
  gt(
17462
17452
  eC(
17463
- F,
17464
- $,
17453
+ N,
17454
+ ee,
17465
17455
  w === "northWestCorner" ? "corner" : w,
17466
17456
  Ue()
17467
17457
  ),
17468
- te
17458
+ ne
17469
17459
  );
17470
17460
  }
17471
17461
  },
17472
17462
  [Ue, gt]
17473
17463
  );
17474
- K(() => {
17475
- if (!N) return;
17476
- const w = document.body.style.cursor, F = document.body.style.userSelect;
17477
- document.body.style.cursor = cC[N.kind], document.body.style.userSelect = "none";
17478
- const $ = (we) => {
17479
- if (we.pointerId !== N.pointerId) return;
17464
+ Y(() => {
17465
+ if (!F) return;
17466
+ const w = document.body.style.cursor, N = document.body.style.userSelect;
17467
+ document.body.style.cursor = cC[F.kind], document.body.style.userSelect = "none";
17468
+ const ee = (we) => {
17469
+ if (we.pointerId !== F.pointerId) return;
17480
17470
  const ke = {
17481
- x: we.clientX - N.startPointer.x,
17482
- y: we.clientY - N.startPointer.y
17471
+ x: we.clientX - F.startPointer.x,
17472
+ y: we.clientY - F.startPointer.y
17483
17473
  }, Rt = Math.hypot(ke.x, ke.y);
17484
17474
  if (!(!X.current && Rt < Qa)) {
17485
- if (Rt >= Qa && (ie.current !== null && (window.clearTimeout(ie.current), ie.current = null), !X.current && N.kind === "launcher" && (de.current !== null && (window.clearTimeout(de.current), de.current = null), at("drag", !0)), X.current = !0), N.kind === "launcher") {
17475
+ if (Rt >= Qa && (ie.current !== null && (window.clearTimeout(ie.current), ie.current = null), !X.current && F.kind === "launcher" && (de.current !== null && (window.clearTimeout(de.current), de.current = null), at("drag", !0)), X.current = !0), F.kind === "launcher") {
17486
17476
  const sr = kr(
17487
17477
  {
17488
- x: N.startLauncher.x + ke.x,
17489
- y: N.startLauncher.y + ke.y
17478
+ x: F.startLauncher.x + ke.x,
17479
+ y: F.startLauncher.y + ke.y
17490
17480
  },
17491
- N.viewport
17481
+ F.viewport
17492
17482
  );
17493
- ee.current = sr, ue.current && oe.current === null && (oe.current = window.requestAnimationFrame(
17483
+ te.current = sr, ue.current && oe.current === null && (oe.current = window.requestAnimationFrame(
17494
17484
  () => {
17495
17485
  oe.current = null;
17496
- const hn = ee.current;
17486
+ const hn = te.current;
17497
17487
  !hn || !ue.current || (ue.current.style.transform = `translate3d(${hn.x}px, ${hn.y}px, 0)`);
17498
17488
  }
17499
17489
  ));
17500
17490
  return;
17501
17491
  }
17502
- W(N.kind, N.startPanel, ke, !1);
17492
+ W(F.kind, F.startPanel, ke, !1);
17503
17493
  }
17504
- }, te = (we, ke) => {
17505
- if (!(we.pointerId !== N.pointerId || De.current)) {
17506
- if (De.current = !0, ie.current !== null && (window.clearTimeout(ie.current), ie.current = null), oe.current !== null && (window.cancelAnimationFrame(oe.current), oe.current = null), N.kind === "launcher") {
17507
- const Rt = ee.current;
17508
- ee.current = null;
17494
+ }, ne = (we, ke) => {
17495
+ if (!(we.pointerId !== F.pointerId || De.current)) {
17496
+ if (De.current = !0, ie.current !== null && (window.clearTimeout(ie.current), ie.current = null), oe.current !== null && (window.cancelAnimationFrame(oe.current), oe.current = null), F.kind === "launcher") {
17497
+ const Rt = te.current;
17498
+ te.current = null;
17509
17499
  const sr = Ue();
17510
17500
  let Mn = Er(
17511
17501
  G.current.launcher,
@@ -17547,30 +17537,30 @@ function lC({
17547
17537
  }, hn) : _o = !0), Ut.current !== null && window.clearTimeout(Ut.current), Ut.current = window.setTimeout(() => {
17548
17538
  Ut.current = null, E(Mn), _(null), _o && at("drag", !1);
17549
17539
  }, 0);
17550
- } else ke ? gt(z.current.panel) : gt(N.startPanel, !1);
17551
- N.kind === "launcher" && X.current && (Y.current = !0, me.current !== null && window.clearTimeout(me.current), me.current = window.setTimeout(() => {
17552
- Y.current = !1, me.current = null;
17553
- }, 0)), ke && D(), N.kind !== "launcher" && _(null), document.body.style.cursor = w, document.body.style.userSelect = F, ge.current?.classList.remove("is-interacting");
17540
+ } else ke ? gt(z.current.panel) : gt(F.startPanel, !1);
17541
+ F.kind === "launcher" && X.current && ($.current = !0, me.current !== null && window.clearTimeout(me.current), me.current = window.setTimeout(() => {
17542
+ $.current = !1, me.current = null;
17543
+ }, 0)), ke && D(), F.kind !== "launcher" && _(null), document.body.style.cursor = w, document.body.style.userSelect = N, ge.current?.classList.remove("is-interacting");
17554
17544
  }
17555
- }, ce = (we) => te(we, !0), Ce = (we) => te(we, !1);
17556
- return document.addEventListener("pointermove", $), document.addEventListener("pointerup", ce), document.addEventListener("pointercancel", Ce), document.addEventListener("lostpointercapture", Ce), () => {
17557
- document.body.style.cursor = w, document.body.style.userSelect = F, document.removeEventListener("pointermove", $), document.removeEventListener("pointerup", ce), document.removeEventListener("pointercancel", Ce), document.removeEventListener("lostpointercapture", Ce);
17545
+ }, ce = (we) => ne(we, !0), Ce = (we) => ne(we, !1);
17546
+ return document.addEventListener("pointermove", ee), document.addEventListener("pointerup", ce), document.addEventListener("pointercancel", Ce), document.addEventListener("lostpointercapture", Ce), () => {
17547
+ document.body.style.cursor = w, document.body.style.userSelect = N, document.removeEventListener("pointermove", ee), document.removeEventListener("pointerup", ce), document.removeEventListener("pointercancel", Ce), document.removeEventListener("lostpointercapture", Ce);
17558
17548
  };
17559
17549
  }, [
17560
17550
  W,
17561
17551
  xt,
17562
17552
  Ue,
17563
- N,
17553
+ F,
17564
17554
  D,
17565
17555
  gt,
17566
17556
  at
17567
17557
  ]), Cn(() => {
17568
17558
  const w = Le.current;
17569
17559
  if (!w) return;
17570
- const F = w.getBoundingClientRect(), $ = ln.current, te = Yt.current !== r;
17571
- if (ln.current = F, Yt.current = r, !t || !n || !te || !$ || typeof w.animate != "function" || window.matchMedia?.("(prefers-reduced-motion: reduce)").matches)
17560
+ const N = w.getBoundingClientRect(), ee = ln.current, ne = Yt.current !== r;
17561
+ if (ln.current = N, Yt.current = r, !t || !n || !ne || !ee || typeof w.animate != "function" || window.matchMedia?.("(prefers-reduced-motion: reduce)").matches)
17572
17562
  return;
17573
- const ce = $.width / Math.max(1, F.width), Ce = $.height / Math.max(1, F.height), we = $.left - F.left, ke = $.top - F.top;
17563
+ const ce = ee.width / Math.max(1, N.width), Ce = ee.height / Math.max(1, N.height), we = ee.left - N.left, ke = ee.top - N.top;
17574
17564
  w.animate(
17575
17565
  [
17576
17566
  {
@@ -17589,42 +17579,42 @@ function lC({
17589
17579
  easing: "cubic-bezier(0.16, 1, 0.3, 1)"
17590
17580
  }
17591
17581
  );
17592
- }, [r, n, t, x.height, x.width, x.x, x.y]), Cn(() => {
17582
+ }, [r, n, t, k.height, k.width, k.x, k.y]), Cn(() => {
17593
17583
  const w = qe.current;
17594
17584
  if (qe.current = t, !w || t) return;
17595
- const F = Le.current, $ = F?.getRootNode(), te = $ instanceof ShadowRoot ? $.activeElement : document.activeElement;
17596
- if (!(te instanceof HTMLElement) || !F?.contains(te))
17585
+ const N = Le.current, ee = N?.getRootNode(), ne = ee instanceof ShadowRoot ? ee.activeElement : document.activeElement;
17586
+ if (!(ne instanceof HTMLElement) || !N?.contains(ne))
17597
17587
  return;
17598
17588
  const ce = L.current;
17599
17589
  if (ce && !s) {
17600
17590
  ce.focus({ preventScroll: !0 });
17601
17591
  return;
17602
17592
  }
17603
- te.blur();
17593
+ ne.blur();
17604
17594
  }, [s, t]), Cn(() => {
17605
- const w = mt && !p, F = dn.current;
17606
- dn.current = w, !(!F || w) && Ze.current && (Ze.current = !1, t ? Le.current?.querySelector(
17595
+ const w = mt && !p, N = dn.current;
17596
+ dn.current = w, !(!N || w) && Ze.current && (Ze.current = !1, t ? Le.current?.querySelector(
17607
17597
  'button:not([disabled]), a[href], input:not([disabled]), textarea:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])'
17608
17598
  )?.focus({ preventScroll: !0 }) : L.current?.focus({ preventScroll: !0 }));
17609
17599
  }, [p, mt, t]), Cn(() => {
17610
- const F = Je.current?.firstElementChild;
17611
- if (!mt || !(F instanceof HTMLElement)) return;
17612
- const $ = () => {
17613
- const ce = F.getBoundingClientRect(), Ce = F.offsetWidth || ce.width, we = F.offsetHeight || ce.height;
17614
- Ce <= 0 || we <= 0 || k(
17600
+ const N = Je.current?.firstElementChild;
17601
+ if (!mt || !(N instanceof HTMLElement)) return;
17602
+ const ee = () => {
17603
+ const ce = N.getBoundingClientRect(), Ce = N.offsetWidth || ce.width, we = N.offsetHeight || ce.height;
17604
+ Ce <= 0 || we <= 0 || x(
17615
17605
  (ke) => Math.abs(ke.width - Ce) < 1 && Math.abs(ke.height - we) < 1 ? ke : { width: Ce, height: we }
17616
17606
  );
17617
17607
  };
17618
- if ($(), typeof ResizeObserver != "function") return;
17619
- const te = new ResizeObserver($);
17620
- return te.observe(F), () => te.disconnect();
17621
- }, [mt]), K(() => {
17608
+ if (ee(), typeof ResizeObserver != "function") return;
17609
+ const ne = new ResizeObserver(ee);
17610
+ return ne.observe(N), () => ne.disconnect();
17611
+ }, [mt]), Y(() => {
17622
17612
  if (!mt) return;
17623
17613
  const w = () => {
17624
17614
  tt.current = null;
17625
- const $ = ge.current, te = $?.getRootNode();
17626
- let ce = te instanceof ShadowRoot ? te.activeElement : document.activeElement;
17627
- if (!ce && te instanceof ShadowRoot && document.activeElement !== te.host && (ce = document.activeElement), !(ce instanceof HTMLElement) || $?.contains(ce) || te instanceof ShadowRoot && ce === te.host) {
17615
+ const ee = ge.current, ne = ee?.getRootNode();
17616
+ let ce = ne instanceof ShadowRoot ? ne.activeElement : document.activeElement;
17617
+ if (!ce && ne instanceof ShadowRoot && document.activeElement !== ne.host && (ce = document.activeElement), !(ce instanceof HTMLElement) || ee?.contains(ce) || ne instanceof ShadowRoot && ce === ne.host) {
17628
17618
  A((ke) => ke === null ? ke : null);
17629
17619
  return;
17630
17620
  }
@@ -17637,29 +17627,29 @@ function lC({
17637
17627
  A(
17638
17628
  (ke) => pC(ke, we) ? ke : we
17639
17629
  );
17640
- }, F = () => {
17630
+ }, N = () => {
17641
17631
  tt.current === null && (tt.current = window.requestAnimationFrame(
17642
17632
  w
17643
17633
  ));
17644
17634
  };
17645
- return F(), document.addEventListener("focusin", F), document.addEventListener("focusout", F), window.addEventListener("scroll", F, !0), window.addEventListener("resize", F), window.visualViewport?.addEventListener("resize", F), window.visualViewport?.addEventListener("scroll", F), () => {
17646
- document.removeEventListener("focusin", F), document.removeEventListener("focusout", F), window.removeEventListener("scroll", F, !0), window.removeEventListener("resize", F), window.visualViewport?.removeEventListener(
17635
+ return N(), document.addEventListener("focusin", N), document.addEventListener("focusout", N), window.addEventListener("scroll", N, !0), window.addEventListener("resize", N), window.visualViewport?.addEventListener("resize", N), window.visualViewport?.addEventListener("scroll", N), () => {
17636
+ document.removeEventListener("focusin", N), document.removeEventListener("focusout", N), window.removeEventListener("scroll", N, !0), window.removeEventListener("resize", N), window.visualViewport?.removeEventListener(
17647
17637
  "resize",
17648
- F
17638
+ N
17649
17639
  ), window.visualViewport?.removeEventListener(
17650
17640
  "scroll",
17651
- F
17641
+ N
17652
17642
  ), tt.current !== null && (window.cancelAnimationFrame(tt.current), tt.current = null);
17653
17643
  };
17654
- }, [mt]), K(
17644
+ }, [mt]), Y(
17655
17645
  () => () => {
17656
17646
  me.current !== null && window.clearTimeout(me.current), ie.current !== null && window.clearTimeout(ie.current), de.current !== null && window.clearTimeout(de.current), pe.current?.cancel(), pe.current = null, ve.current?.(), oe.current !== null && window.cancelAnimationFrame(oe.current), Ut.current !== null && window.clearTimeout(Ut.current), kt.current !== null && window.clearTimeout(kt.current), Rn.current?.(!1);
17657
17647
  },
17658
17648
  []
17659
- ), K(() => {
17649
+ ), Y(() => {
17660
17650
  const w = () => {
17661
- const F = G.current;
17662
- xt(F.launcher, !1), gt(Lr(F.panel, Ue()), !1);
17651
+ const N = G.current;
17652
+ xt(N.launcher, !1), gt(Lr(N.panel, Ue()), !1);
17663
17653
  };
17664
17654
  return w(), window.addEventListener("resize", w), window.visualViewport?.addEventListener("resize", w), window.visualViewport?.addEventListener("scroll", w), () => {
17665
17655
  window.removeEventListener("resize", w), window.visualViewport?.removeEventListener("resize", w), window.visualViewport?.removeEventListener("scroll", w);
@@ -17667,43 +17657,43 @@ function lC({
17667
17657
  }, [xt, Ue, gt]);
17668
17658
  const Q = (w) => {
17669
17659
  Et.current?.querySelectorAll('[role="menuitem"]').item(w)?.focus({ preventScroll: !0 });
17670
- }, J = (w, F) => {
17671
- if (w.button !== 0 || w.isPrimary === !1 || r && F !== "launcher")
17660
+ }, J = (w, N) => {
17661
+ if (w.button !== 0 || w.isPrimary === !1 || r && N !== "launcher")
17672
17662
  return;
17673
- w.preventDefault(), w.stopPropagation(), B(!1);
17674
- const $ = w.currentTarget;
17675
- typeof $.setPointerCapture == "function" && $.setPointerCapture(w.pointerId);
17676
- let te = z.current.launcher;
17677
- if (F === "launcher" && pe.current && ue.current) {
17663
+ w.preventDefault(), w.stopPropagation(), V(!1);
17664
+ const ee = w.currentTarget;
17665
+ typeof ee.setPointerCapture == "function" && ee.setPointerCapture(w.pointerId);
17666
+ let ne = z.current.launcher;
17667
+ if (N === "launcher" && pe.current && ue.current) {
17678
17668
  const ce = Ue(), Ce = ue.current.getBoundingClientRect(), we = kr(
17679
17669
  { x: Ce.left, y: Ce.top },
17680
17670
  ce
17681
17671
  );
17682
- pe.current.cancel(), pe.current = null, de.current !== null && (window.clearTimeout(de.current), de.current = null), at("drag", !1, !0), te = we, z.current = { ...z.current, launcher: we }, ue.current.style.transform = `translate3d(${we.x}px, ${we.y}px, 0)`, E(we);
17672
+ pe.current.cancel(), pe.current = null, de.current !== null && (window.clearTimeout(de.current), de.current = null), at("drag", !1, !0), ne = we, z.current = { ...z.current, launcher: we }, ue.current.style.transform = `translate3d(${we.x}px, ${we.y}px, 0)`, E(we);
17683
17673
  }
17684
- X.current = !1, De.current = !1, ee.current = null, F === "launcher" && ue.current && (ue.current.style.willChange = "transform", ie.current !== null && window.clearTimeout(ie.current), ie.current = window.setTimeout(() => {
17685
- ie.current = null, De.current = !0, Y.current = !0;
17674
+ X.current = !1, De.current = !1, te.current = null, N === "launcher" && ue.current && (ue.current.style.willChange = "transform", ie.current !== null && window.clearTimeout(ie.current), ie.current = window.setTimeout(() => {
17675
+ ie.current = null, De.current = !0, $.current = !0;
17686
17676
  const ce = () => {
17687
17677
  document.removeEventListener("pointerup", ce), document.removeEventListener("pointercancel", ce), document.removeEventListener("lostpointercapture", ce), ve.current = null, me.current !== null && window.clearTimeout(me.current), me.current = window.setTimeout(() => {
17688
- Y.current = !1, me.current = null;
17678
+ $.current = !1, me.current = null;
17689
17679
  }, 0);
17690
17680
  };
17691
17681
  ve.current = () => {
17692
17682
  document.removeEventListener("pointerup", ce), document.removeEventListener("pointercancel", ce), document.removeEventListener("lostpointercapture", ce), ve.current = null;
17693
- }, document.addEventListener("pointerup", ce), document.addEventListener("pointercancel", ce), document.addEventListener("lostpointercapture", ce), ue.current?.style.removeProperty("will-change"), _(null), q(0), B(!0), window.requestAnimationFrame(() => {
17683
+ }, document.addEventListener("pointerup", ce), document.addEventListener("pointercancel", ce), document.addEventListener("lostpointercapture", ce), ue.current?.style.removeProperty("will-change"), _(null), K(0), V(!0), window.requestAnimationFrame(() => {
17694
17684
  Q(0);
17695
17685
  });
17696
17686
  }, 520)), _({
17697
- kind: F,
17687
+ kind: N,
17698
17688
  pointerId: w.pointerId,
17699
17689
  startPointer: { x: w.clientX, y: w.clientY },
17700
- startLauncher: te,
17690
+ startLauncher: ne,
17701
17691
  startPanel: z.current.panel,
17702
17692
  viewport: Ue()
17703
17693
  });
17704
17694
  }, Z = () => {
17705
- if (Y.current) {
17706
- Y.current = !1;
17695
+ if ($.current) {
17696
+ $.current = !1;
17707
17697
  return;
17708
17698
  }
17709
17699
  const w = ol(
@@ -17721,53 +17711,53 @@ function lC({
17721
17711
  zn()
17722
17712
  ), e(!0);
17723
17713
  }, ae = (w) => {
17724
- const F = w.shiftKey ? $a * 3 : $a;
17725
- return w.key === "ArrowLeft" ? { x: -F, y: 0 } : w.key === "ArrowRight" ? { x: F, y: 0 } : w.key === "ArrowUp" ? { x: 0, y: -F } : w.key === "ArrowDown" ? { x: 0, y: F } : null;
17726
- }, be = (w, F) => {
17727
- const $ = ae(w);
17728
- if ($) {
17729
- if (w.preventDefault(), w.stopPropagation(), F === "launcher") {
17730
- const te = G.current.launcher;
17714
+ const N = w.shiftKey ? $a * 3 : $a;
17715
+ return w.key === "ArrowLeft" ? { x: -N, y: 0 } : w.key === "ArrowRight" ? { x: N, y: 0 } : w.key === "ArrowUp" ? { x: 0, y: -N } : w.key === "ArrowDown" ? { x: 0, y: N } : null;
17716
+ }, be = (w, N) => {
17717
+ const ee = ae(w);
17718
+ if (ee) {
17719
+ if (w.preventDefault(), w.stopPropagation(), N === "launcher") {
17720
+ const ne = G.current.launcher;
17731
17721
  if (w.key === "ArrowLeft" || w.key === "ArrowRight")
17732
17722
  xt({
17733
- ...te,
17723
+ ...ne,
17734
17724
  side: w.key === "ArrowLeft" ? "LEFT" : "RIGHT"
17735
17725
  });
17736
17726
  else {
17737
17727
  const ce = kr(
17738
17728
  {
17739
17729
  ...z.current.launcher,
17740
- y: z.current.launcher.y + $.y
17730
+ y: z.current.launcher.y + ee.y
17741
17731
  },
17742
17732
  Ue()
17743
17733
  );
17744
17734
  xt({
17745
- side: te.side,
17735
+ side: ne.side,
17746
17736
  yRatio: Hn(ce, Ue()).yRatio
17747
17737
  });
17748
17738
  }
17749
17739
  D();
17750
17740
  return;
17751
17741
  }
17752
- W(F, z.current.panel, $), D();
17742
+ W(N, z.current.panel, ee), D();
17753
17743
  }
17754
17744
  }, Me = () => {
17755
- ie.current !== null && (window.clearTimeout(ie.current), ie.current = null), q(0), B(!0), window.requestAnimationFrame(() => {
17745
+ ie.current !== null && (window.clearTimeout(ie.current), ie.current = null), K(0), V(!0), window.requestAnimationFrame(() => {
17756
17746
  Q(0);
17757
17747
  });
17758
17748
  }, Qe = (w) => {
17759
17749
  xt({
17760
17750
  ...G.current.launcher,
17761
17751
  ...w
17762
- }), D(), B(!1), L.current?.focus({ preventScroll: !0 });
17763
- }, xe = (w, F) => {
17764
- const $ = ae(w);
17765
- $ && (w.preventDefault(), w.stopPropagation(), W(F, z.current.panel, $), D());
17752
+ }), D(), V(!1), L.current?.focus({ preventScroll: !0 });
17753
+ }, xe = (w, N) => {
17754
+ const ee = ae(w);
17755
+ ee && (w.preventDefault(), w.stopPropagation(), W(N, z.current.panel, ee), D());
17766
17756
  }, Tt = n && t && r ? { top: 0, left: 0 } : {
17767
- left: x.x,
17768
- top: x.y,
17769
- width: x.width,
17770
- height: x.height
17757
+ left: k.x,
17758
+ top: k.y,
17759
+ width: k.width,
17760
+ height: k.height
17771
17761
  }, bt = {
17772
17762
  left: 0,
17773
17763
  top: 0,
@@ -17779,18 +17769,18 @@ function lC({
17779
17769
  height: Fe
17780
17770
  }, Ae = Ue(), Ct = Hn(y, Ae).side, Ke = $1(
17781
17771
  y,
17782
- V,
17772
+ B,
17783
17773
  Ae,
17784
17774
  Ct,
17785
- T
17775
+ R
17786
17776
  ), Kr = Ke.placement, Jt = {
17787
17777
  left: 0,
17788
17778
  top: 0,
17789
17779
  width: Ke.width,
17790
17780
  maxHeight: Ke.maxHeight,
17791
17781
  transform: `translate3d(${Ke.x}px, ${Ke.y}px, 0)`
17792
- }, rr = !!(c && T && Ke.avoidanceFailed);
17793
- K(() => (at("focusCollision", rr), () => at("focusCollision", !1)), [rr, at]);
17782
+ }, rr = !!(c && R && Ke.avoidanceFailed);
17783
+ Y(() => (at("focusCollision", rr), () => at("focusCollision", !1)), [rr, at]);
17794
17784
  const pl = 7 + (c && d ? 1 : 0), ti = Math.min(184, Math.max(1, Ae.width - 24)), Yr = Math.min(
17795
17785
  pl * 44 + 2,
17796
17786
  Math.max(1, Ae.height - 24)
@@ -17812,30 +17802,30 @@ function lC({
17812
17802
  width: ti,
17813
17803
  maxHeight: Yr
17814
17804
  }, gl = (w) => {
17815
- const F = Array.from(
17805
+ const N = Array.from(
17816
17806
  Et.current?.querySelectorAll(
17817
17807
  '[role="menuitem"]'
17818
17808
  ) ?? []
17819
17809
  );
17820
17810
  if (w.key === "Escape" && !w.defaultPrevented) {
17821
- w.preventDefault(), w.stopPropagation(), B(!1), L.current?.focus({ preventScroll: !0 });
17811
+ w.preventDefault(), w.stopPropagation(), V(!1), L.current?.focus({ preventScroll: !0 });
17822
17812
  return;
17823
17813
  }
17824
17814
  if (w.key === "Tab" && !w.defaultPrevented) {
17825
- B(!1);
17815
+ V(!1);
17826
17816
  return;
17827
17817
  }
17828
- const $ = Math.max(
17818
+ const ee = Math.max(
17829
17819
  0,
17830
- F.indexOf(document.activeElement)
17831
- ), te = w.key === "ArrowDown" ? ($ + 1) % F.length : w.key === "ArrowUp" ? ($ - 1 + F.length) % F.length : w.key === "Home" ? 0 : w.key === "End" ? F.length - 1 : null;
17832
- te === null || !F[te] || (w.preventDefault(), w.stopPropagation(), q(te), F[te].focus({ preventScroll: !0 }));
17820
+ N.indexOf(document.activeElement)
17821
+ ), ne = w.key === "ArrowDown" ? (ee + 1) % N.length : w.key === "ArrowUp" ? (ee - 1 + N.length) % N.length : w.key === "Home" ? 0 : w.key === "End" ? N.length - 1 : null;
17822
+ ne === null || !N[ne] || (w.preventDefault(), w.stopPropagation(), K(ne), N[ne].focus({ preventScroll: !0 }));
17833
17823
  };
17834
17824
  return /* @__PURE__ */ lt(
17835
17825
  "div",
17836
17826
  {
17837
17827
  ref: ge,
17838
- className: `bridge-ai-chat-widget pointer-events-none fixed inset-0 z-[9999999] ${N ? "is-interacting" : ""}`,
17828
+ className: `bridge-ai-chat-widget pointer-events-none fixed inset-0 z-[9999999] ${F ? "is-interacting" : ""}`,
17839
17829
  "data-mobile": n,
17840
17830
  "data-preview-active": !!c,
17841
17831
  dir: C,
@@ -17863,12 +17853,12 @@ function lC({
17863
17853
  style: Tt,
17864
17854
  inert: t ? void 0 : !0,
17865
17855
  onPointerDownCapture: (w) => {
17866
- const F = w.target;
17867
- t && F.closest("[data-lola-drag-handle]") && J(w, "panel");
17856
+ const N = w.target;
17857
+ t && N.closest("[data-lola-drag-handle]") && J(w, "panel");
17868
17858
  },
17869
17859
  onKeyDownCapture: (w) => {
17870
- const F = w.target;
17871
- t && F.closest("[data-lola-drag-handle]") && be(w, "panel");
17860
+ const N = w.target;
17861
+ t && N.closest("[data-lola-drag-handle]") && be(w, "panel");
17872
17862
  },
17873
17863
  children: [
17874
17864
  /* @__PURE__ */ H("div", { className: "chat-widget-panel absolute inset-0 overflow-hidden rounded-[inherit] outline outline-black/9", children: g }),
@@ -17926,8 +17916,8 @@ function lC({
17926
17916
  Ze.current = !0;
17927
17917
  },
17928
17918
  onBlurCapture: (w) => {
17929
- const F = w.relatedTarget;
17930
- F instanceof HTMLElement && !w.currentTarget.contains(F) && (Ze.current = !1);
17919
+ const N = w.relatedTarget;
17920
+ N instanceof HTMLElement && !w.currentTarget.contains(N) && (Ze.current = !1);
17931
17921
  },
17932
17922
  children: c
17933
17923
  }
@@ -17973,7 +17963,7 @@ function lC({
17973
17963
  )
17974
17964
  }
17975
17965
  ),
17976
- P && /* @__PURE__ */ lt(
17966
+ O && /* @__PURE__ */ lt(
17977
17967
  "div",
17978
17968
  {
17979
17969
  ref: Et,
@@ -17985,20 +17975,20 @@ function lC({
17985
17975
  style: ml,
17986
17976
  onKeyDown: gl,
17987
17977
  onFocusCapture: (w) => {
17988
- const F = w.target.closest(
17978
+ const N = w.target.closest(
17989
17979
  '[role="menuitem"]'
17990
17980
  );
17991
- if (!(F instanceof HTMLButtonElement)) return;
17992
- const te = Array.from(
17981
+ if (!(N instanceof HTMLButtonElement)) return;
17982
+ const ne = Array.from(
17993
17983
  w.currentTarget.querySelectorAll(
17994
17984
  '[role="menuitem"]'
17995
17985
  )
17996
- ).indexOf(F);
17997
- te >= 0 && q(te);
17986
+ ).indexOf(N);
17987
+ ne >= 0 && K(ne);
17998
17988
  },
17999
17989
  onBlurCapture: (w) => {
18000
- const F = w.relatedTarget;
18001
- (!(F instanceof Node) || !w.currentTarget.contains(F)) && B(!1);
17990
+ const N = w.relatedTarget;
17991
+ (!(N instanceof Node) || !w.currentTarget.contains(N)) && V(!1);
18002
17992
  },
18003
17993
  children: [
18004
17994
  /* @__PURE__ */ H(
@@ -18006,7 +17996,7 @@ function lC({
18006
17996
  {
18007
17997
  type: "button",
18008
17998
  role: "menuitem",
18009
- tabIndex: ne === 0 ? 0 : -1,
17999
+ tabIndex: q === 0 ? 0 : -1,
18010
18000
  onClick: () => Qe({ side: "LEFT" }),
18011
18001
  children: I("compact.moveLeft")
18012
18002
  }
@@ -18016,7 +18006,7 @@ function lC({
18016
18006
  {
18017
18007
  type: "button",
18018
18008
  role: "menuitem",
18019
- tabIndex: ne === 1 ? 0 : -1,
18009
+ tabIndex: q === 1 ? 0 : -1,
18020
18010
  onClick: () => Qe({ side: "RIGHT" }),
18021
18011
  children: I("compact.moveRight")
18022
18012
  }
@@ -18026,7 +18016,7 @@ function lC({
18026
18016
  {
18027
18017
  type: "button",
18028
18018
  role: "menuitem",
18029
- tabIndex: ne === 2 ? 0 : -1,
18019
+ tabIndex: q === 2 ? 0 : -1,
18030
18020
  onClick: () => Qe({
18031
18021
  yRatio: Math.max(
18032
18022
  0,
@@ -18041,7 +18031,7 @@ function lC({
18041
18031
  {
18042
18032
  type: "button",
18043
18033
  role: "menuitem",
18044
- tabIndex: ne === 3 ? 0 : -1,
18034
+ tabIndex: q === 3 ? 0 : -1,
18045
18035
  onClick: () => Qe({
18046
18036
  yRatio: Math.min(
18047
18037
  1,
@@ -18056,7 +18046,7 @@ function lC({
18056
18046
  {
18057
18047
  type: "button",
18058
18048
  role: "menuitem",
18059
- tabIndex: ne === 4 ? 0 : -1,
18049
+ tabIndex: q === 4 ? 0 : -1,
18060
18050
  onClick: () => Qe({ yRatio: 0 }),
18061
18051
  children: I("compact.moveTop")
18062
18052
  }
@@ -18066,7 +18056,7 @@ function lC({
18066
18056
  {
18067
18057
  type: "button",
18068
18058
  role: "menuitem",
18069
- tabIndex: ne === 5 ? 0 : -1,
18059
+ tabIndex: q === 5 ? 0 : -1,
18070
18060
  onClick: () => Qe({ yRatio: 0.5 }),
18071
18061
  children: I("compact.moveMiddle")
18072
18062
  }
@@ -18076,7 +18066,7 @@ function lC({
18076
18066
  {
18077
18067
  type: "button",
18078
18068
  role: "menuitem",
18079
- tabIndex: ne === 6 ? 0 : -1,
18069
+ tabIndex: q === 6 ? 0 : -1,
18080
18070
  onClick: () => Qe({ yRatio: 1 }),
18081
18071
  children: I("compact.moveBottom")
18082
18072
  }
@@ -18086,9 +18076,9 @@ function lC({
18086
18076
  {
18087
18077
  type: "button",
18088
18078
  role: "menuitem",
18089
- tabIndex: ne === 7 ? 0 : -1,
18079
+ tabIndex: q === 7 ? 0 : -1,
18090
18080
  onClick: () => {
18091
- m(), B(!1), L.current?.focus({ preventScroll: !0 });
18081
+ m(), V(!1), L.current?.focus({ preventScroll: !0 });
18092
18082
  },
18093
18083
  children: I("compact.collapseQuestion")
18094
18084
  }
@@ -18185,53 +18175,53 @@ function bC() {
18185
18175
  isAvatarCoveredByChatList: o,
18186
18176
  assistantRef: a
18187
18177
  } = Hr(), u = wt(), c = Vm(), d = Zi(u.pathname) && o || c, p = U(null), h = U(null), f = U(null), m = e && n && !d, g = U(m);
18188
- return g.current = m, K(() => {
18178
+ return g.current = m, Y(() => {
18189
18179
  const C = p.current, b = h.current;
18190
18180
  if (!C || !b) return;
18191
18181
  let I = !1;
18192
- const S = (N) => {
18193
- const _ = N.detail ?? 0;
18182
+ const S = (F) => {
18183
+ const _ = F.detail ?? 0;
18194
18184
  s(Math.min(_, 0.99));
18195
18185
  };
18196
18186
  let y = null;
18197
- const E = new ResizeObserver((N) => {
18187
+ const E = new ResizeObserver((F) => {
18198
18188
  if (!g.current) return;
18199
- const _ = N.at(-1);
18189
+ const _ = F.at(-1);
18200
18190
  if (!_) return;
18201
- const { width: P, height: B } = _.contentRect;
18191
+ const { width: O, height: V } = _.contentRect;
18202
18192
  y !== null && window.clearTimeout(y), y = window.setTimeout(() => {
18203
- a.current?.onResize(P, B), y = null;
18193
+ a.current?.onResize(O, V), y = null;
18204
18194
  }, 80);
18205
18195
  });
18206
- let x = null;
18207
- const O = r.onAvatarLoadStarted();
18208
- return import("./Avatar-C6dvOio6.js").then(({ Avatar: N }) => {
18196
+ let k = null;
18197
+ const P = r.onAvatarLoadStarted();
18198
+ return import("./Avatar-BA284XB-.js").then(({ Avatar: F }) => {
18209
18199
  if (I) return;
18210
18200
  const _ = {
18211
18201
  ...r,
18212
- onAvatarReady: (P) => {
18213
- !I && a.current === x && (s(1), x && f.current && x.applyLipSyncSnapshot(f.current), O.onAvatarReady(P));
18202
+ onAvatarReady: (O) => {
18203
+ !I && a.current === k && (s(1), k && f.current && k.applyLipSyncSnapshot(f.current), P.onAvatarReady(O));
18214
18204
  },
18215
- onAvatarLoadFailed: (P) => {
18216
- !I && a.current === x && O.onAvatarLoadFailed(P);
18205
+ onAvatarLoadFailed: (O) => {
18206
+ !I && a.current === k && P.onAvatarLoadFailed(O);
18217
18207
  }
18218
18208
  };
18219
- x = new N(C, b, _), x.setRenderingEnabled(g.current), a.current = x, x.addEventListener("loading_progress", S), E.observe(C);
18220
- }).catch((N) => {
18221
- I || O.onAvatarLoadFailed(N);
18209
+ k = new F(C, b, _), k.setRenderingEnabled(g.current), a.current = k, k.addEventListener("loading_progress", S), E.observe(C);
18210
+ }).catch((F) => {
18211
+ I || P.onAvatarLoadFailed(F);
18222
18212
  }), () => {
18223
- I = !0, x?.cancelBackgroundPreload(), x?.setRenderingEnabled(!1), x?.removeEventListener("loading_progress", S), x && a.current === x && (a.current = null, O.onAvatarLoadFailed(
18213
+ I = !0, k?.cancelBackgroundPreload(), k?.setRenderingEnabled(!1), k?.removeEventListener("loading_progress", S), k && a.current === k && (a.current = null, P.onAvatarLoadFailed(
18224
18214
  new Error("Avatar was unmounted before animation playback")
18225
18215
  )), y !== null && window.clearTimeout(y), E.disconnect();
18226
18216
  };
18227
- }, [r, a, s]), K(() => {
18217
+ }, [r, a, s]), Y(() => {
18228
18218
  const C = () => {
18229
18219
  a.current?.setRenderingEnabled(
18230
18220
  m && document.visibilityState !== "hidden"
18231
18221
  );
18232
18222
  };
18233
18223
  return C(), document.addEventListener("visibilitychange", C), () => document.removeEventListener("visibilitychange", C);
18234
- }, [a, m]), K(() => vt.subscribe((C) => {
18224
+ }, [a, m]), Y(() => vt.subscribe((C) => {
18235
18225
  f.current = C, a.current?.applyLipSyncSnapshot(C);
18236
18226
  }), [a]), /* @__PURE__ */ lt("div", { className: "pointer-events-none absolute inset-0 z-0", children: [
18237
18227
  /* @__PURE__ */ H("div", { className: "absolute inset-0 bg-black/8" }),
@@ -18474,7 +18464,7 @@ class AC {
18474
18464
  ].join(":");
18475
18465
  }
18476
18466
  }
18477
- const Mo = Yn(null), qy = () => Or(Mo)?.resolver ?? null, Uy = (t) => {
18467
+ const Mo = Yn(null), Gy = () => Or(Mo)?.resolver ?? null, qy = (t) => {
18478
18468
  const e = Or(
18479
18469
  Mo
18480
18470
  )?.authorizedConversationIds;
@@ -18502,16 +18492,16 @@ function wC({
18502
18492
  }),
18503
18493
  [r, i]
18504
18494
  );
18505
- return K(() => {
18495
+ return Y(() => {
18506
18496
  const c = eu(e);
18507
18497
  o.current !== c && (o.current = c, i.replaceSession(e, n));
18508
- }, [n, e, i]), K(() => {
18498
+ }, [n, e, i]), Y(() => {
18509
18499
  if (r === void 0) return;
18510
18500
  const c = new Set(r);
18511
18501
  for (const l of a.current)
18512
18502
  c.has(l) || i.purgeConversation(l);
18513
18503
  a.current = c;
18514
- }, [r, i]), K(() => () => i.destroy(), [i]), /* @__PURE__ */ H(Mo.Provider, { value: u, children: t });
18504
+ }, [r, i]), Y(() => () => i.destroy(), [i]), /* @__PURE__ */ H(Mo.Provider, { value: u, children: t });
18515
18505
  }
18516
18506
  const SC = 32, EC = 192, kC = 32, xC = 24, TC = 16, RC = 1.5, MC = 100, DC = 120;
18517
18507
  let tu;
@@ -18534,7 +18524,7 @@ const _C = (t) => t ? [t] : [], dl = (t) => typeof Intl.Segmenter != "function"
18534
18524
  for (; r < t.length && On(t[r]); ) r += 1;
18535
18525
  }
18536
18526
  return r - e;
18537
- }, Wy = ({
18527
+ }, Uy = ({
18538
18528
  characterIntervalMs: t = SC,
18539
18529
  segment: e = dl
18540
18530
  } = {}) => {
@@ -18587,8 +18577,8 @@ const _C = (t) => t ? [t] : [], dl = (t) => typeof Intl.Segmenter != "function"
18587
18577
  if (l) {
18588
18578
  if (l.firstTimestamp ??= g, g - l.firstTimestamp < DC)
18589
18579
  return null;
18590
- const N = l.target, _ = l.text;
18591
- l = null, m(N, _);
18580
+ const F = l.target, _ = l.text;
18581
+ l = null, m(F, _);
18592
18582
  }
18593
18583
  if (f()) return null;
18594
18584
  if (c)
@@ -18601,11 +18591,11 @@ const _C = (t) => t ? [t] : [], dl = (t) => typeof Intl.Segmenter != "function"
18601
18591
  MC
18602
18592
  );
18603
18593
  if (a = g, o = Math.min(RC, o + S / I), Math.floor(o) < 1) return null;
18604
- const E = b ? Math.ceil(C / u) : 1, x = b ? FC(n, s.length, E) : E, O = n.slice(
18594
+ const E = b ? Math.ceil(C / u) : 1, k = b ? FC(n, s.length, E) : E, P = n.slice(
18605
18595
  s.length,
18606
- s.length + x
18596
+ s.length + k
18607
18597
  );
18608
- return s = s.concat(O), o = Math.max(0, o - 1), b && (u -= 1), s.length === n.length && (o = 0, a = null, u = 0), h(O);
18598
+ return s = s.concat(P), o = Math.max(0, o - 1), b && (u -= 1), s.length === n.length && (o = 0, a = null, u = 0), h(P);
18609
18599
  },
18610
18600
  flush() {
18611
18601
  return l && (n = l.target, r = l.text, l = null), f() && p.animatedText === "" ? null : (s = n.slice(), o = 0, a = null, u = 0, c = !1, h());
@@ -18688,31 +18678,12 @@ const fl = (t) => t.displayMode !== "DIRECT" || t.kind !== "INFO", HC = (t) => {
18688
18678
  zC,
18689
18679
  Math.max(VC, r)
18690
18680
  );
18691
- };
18692
- function XC(t, e) {
18693
- K(() => {
18694
- if (!t) return;
18695
- const n = window.matchMedia?.(
18696
- "(prefers-reduced-motion: reduce)"
18697
- ), r = () => {
18698
- document.visibilityState === "hidden" && e();
18699
- }, s = () => {
18700
- n?.matches && e();
18701
- };
18702
- return r(), s(), document.addEventListener("visibilitychange", r), n?.addEventListener?.("change", s), () => {
18703
- document.removeEventListener("visibilitychange", r), n?.removeEventListener?.(
18704
- "change",
18705
- s
18706
- );
18707
- };
18708
- }, [t, e]);
18709
- }
18710
- const ZC = {
18681
+ }, XC = {
18711
18682
  region: "Assistant update",
18712
18683
  dismiss: "Dismiss message",
18713
18684
  openChat: "Open in chat",
18714
18685
  choices: "Choose an answer"
18715
- }, jC = bl(function({
18686
+ }, ZC = bl(function({
18716
18687
  candidate: e,
18717
18688
  phase: n,
18718
18689
  onDismiss: r,
@@ -18729,50 +18700,48 @@ const ZC = {
18729
18700
  labels: f
18730
18701
  }) {
18731
18702
  const m = un(() => hl(e), [e]), g = Ki(), C = U(null), b = U(null), [I, S] = he(() => /* @__PURE__ */ new Set()), y = le((q) => {
18732
- S((V) => {
18733
- if (V.has(q)) return V;
18734
- const k = new Set(V);
18735
- if (k.add(q), k.size > 64) {
18736
- const T = k.values().next().value;
18737
- T !== void 0 && k.delete(T);
18703
+ S((K) => {
18704
+ if (K.has(q)) return K;
18705
+ const B = new Set(K);
18706
+ if (B.add(q), B.size > 64) {
18707
+ const x = B.values().next().value;
18708
+ x !== void 0 && B.delete(x);
18738
18709
  }
18739
- return k;
18710
+ return B;
18740
18711
  });
18741
18712
  }, []), E = e.kind === "CHOICE" ? e.choice.options.find(
18742
18713
  ({ presentation: q }) => q === "PRIMARY"
18743
- )?.id : void 0, x = un(() => {
18744
- if (n === "EXITING") return [];
18714
+ )?.id : void 0, k = un(() => {
18715
+ if (n !== "INTERACTIVE") return [];
18745
18716
  if (e.kind === "CTA" && e.cta.attention === "NUDGE_ONCE")
18746
18717
  return [e.key];
18747
18718
  if (e.kind !== "CHOICE") return [];
18748
18719
  const q = e.choice.options.find(
18749
- ({ id: V, presentation: k, attention: T }) => V === E && k === "PRIMARY" && T === "NUDGE_ONCE"
18720
+ ({ id: K, presentation: B, attention: x }) => K === E && B === "PRIMARY" && x === "NUDGE_ONCE"
18750
18721
  );
18751
18722
  return q ? [`${e.key}:${q.id}`] : [];
18752
- }, [e, n, E]), O = le(() => {
18753
- for (const q of x) y(q);
18754
- }, [x, y]), N = x.some(
18755
- (q) => !I.has(q)
18756
- );
18757
- if (XC(N, O), Cn(() => {
18758
- const q = C.current, V = b.current;
18759
- if (e.displayMode === "ACTION_ONLY" || !q || !V || !a)
18723
+ }, [e, n, E]), P = le(() => {
18724
+ for (const q of k) y(q);
18725
+ }, [k, y]);
18726
+ if (Cn(() => {
18727
+ const q = C.current, K = b.current;
18728
+ if (e.displayMode === "ACTION_ONLY" || !q || !K || !a)
18760
18729
  return;
18761
- let k = !1;
18762
- const T = () => {
18763
- if (k) return;
18764
- const v = q.closest(".compact-preview-anchor"), R = v ? Number.parseFloat(v.style.maxHeight) : Number.NaN, z = q.getBoundingClientRect().height, G = Math.max(
18730
+ let B = !1;
18731
+ const x = () => {
18732
+ if (B) return;
18733
+ const A = q.closest(".compact-preview-anchor"), v = A ? Number.parseFloat(A.style.maxHeight) : Number.NaN, T = q.getBoundingClientRect().height, z = Math.max(
18765
18734
  q.scrollHeight,
18766
18735
  q.offsetHeight,
18767
- z
18736
+ T
18768
18737
  );
18769
- (Number.isFinite(R) && G > R + 0.5 || e.displayMode === "DIRECT" && YC(V) > KC) && (k = !0, a());
18738
+ (Number.isFinite(v) && z > v + 0.5 || e.displayMode === "DIRECT" && KC(K) > jC) && (B = !0, a());
18770
18739
  };
18771
- if (T(), typeof ResizeObserver != "function") return;
18772
- const A = new ResizeObserver(T);
18773
- return A.observe(V), A.observe(q), () => A.disconnect();
18740
+ if (x(), typeof ResizeObserver != "function") return;
18741
+ const R = new ResizeObserver(x);
18742
+ return R.observe(K), R.observe(q), () => R.disconnect();
18774
18743
  }, [e.displayMode, e.key, a]), n === "IDLE" || n === "GAP") return null;
18775
- const _ = { ...ZC, ...f }, P = u || c || n === "ENTERING" || n === "EXITING", B = fl(e), ne = {
18744
+ const F = { ...XC, ...f }, _ = u || c || n === "ENTERING" || n === "EXITING", O = fl(e), V = {
18776
18745
  "--compact-preview-actions-delay": `${m.actionsDelayMs}ms`
18777
18746
  };
18778
18747
  return /* @__PURE__ */ lt(
@@ -18781,16 +18750,14 @@ const ZC = {
18781
18750
  ref: C,
18782
18751
  className: "compact-scenario-preview",
18783
18752
  role: "region",
18784
- "aria-label": _.region,
18753
+ "aria-label": F.region,
18785
18754
  "aria-describedby": g,
18786
18755
  "aria-busy": c || void 0,
18787
18756
  "data-kind": e.kind,
18788
18757
  "data-phase": n,
18789
18758
  "data-display-mode": e.displayMode,
18790
18759
  "data-phrase-count": m.phraseCount,
18791
- style: ne,
18792
- onFocusCapture: O,
18793
- onPointerDownCapture: O,
18760
+ style: V,
18794
18761
  onKeyDown: (q) => {
18795
18762
  q.key !== "Escape" || q.defaultPrevented || (q.preventDefault(), q.stopPropagation(), r());
18796
18763
  },
@@ -18810,44 +18777,43 @@ const ZC = {
18810
18777
  {
18811
18778
  className: "compact-scenario-preview__dismiss",
18812
18779
  type: "button",
18813
- "aria-label": _.dismiss,
18814
- disabled: P,
18780
+ "aria-label": F.dismiss,
18781
+ disabled: _,
18815
18782
  onClick: r,
18816
18783
  children: /* @__PURE__ */ H("span", { "aria-hidden": "true", children: "×" })
18817
18784
  }
18818
18785
  ),
18819
- B && /* @__PURE__ */ H("div", { className: "compact-scenario-preview__actions", children: e.displayMode !== "DIRECT" ? /* @__PURE__ */ H(
18786
+ O && /* @__PURE__ */ H("div", { className: "compact-scenario-preview__actions", children: e.displayMode !== "DIRECT" ? /* @__PURE__ */ H(
18820
18787
  "button",
18821
18788
  {
18822
18789
  className: "compact-scenario-preview__action",
18823
18790
  type: "button",
18824
18791
  "data-action": "open-chat",
18825
18792
  "data-presentation": "PRIMARY",
18826
- disabled: P,
18793
+ disabled: _,
18827
18794
  onClick: s,
18828
- children: _.openChat
18795
+ children: F.openChat
18829
18796
  }
18830
18797
  ) : e.kind === "CHOICE" ? /* @__PURE__ */ H(
18831
18798
  "div",
18832
18799
  {
18833
18800
  className: "compact-scenario-preview__choice-group",
18834
18801
  role: "group",
18835
- "aria-label": _.choices,
18802
+ "aria-label": F.choices,
18836
18803
  children: e.choice.options.map((q) => {
18837
- const V = p === q.id, k = q.presentation === "PRIMARY" && q.id === E ? "PRIMARY" : "TERTIARY", T = `${e.key}:${q.id}`, A = k === "PRIMARY" && q.attention === "NUDGE_ONCE" && n !== "EXITING" && !I.has(T) ? "NUDGE_ONCE" : "NONE";
18804
+ const K = p === q.id, B = q.presentation === "PRIMARY" && q.id === E ? "PRIMARY" : "TERTIARY", x = `${e.key}:${q.id}`, R = B === "PRIMARY" && q.attention === "NUDGE_ONCE" && n === "INTERACTIVE" && !I.has(x) ? "NUDGE_ONCE" : "NONE";
18838
18805
  return /* @__PURE__ */ H(
18839
18806
  "button",
18840
18807
  {
18841
18808
  className: "compact-scenario-preview__action",
18842
18809
  type: "button",
18843
18810
  "data-option-id": q.id,
18844
- "data-presentation": k,
18845
- "data-attention": A,
18846
- "aria-pressed": V || void 0,
18847
- disabled: P || !!(p && !V),
18848
- onAnimationEnd: () => y(T),
18811
+ "data-presentation": B,
18812
+ "data-attention": R,
18813
+ "aria-pressed": K || void 0,
18814
+ disabled: _ || !!(p && !K),
18849
18815
  onClick: () => {
18850
- y(T), i(q.id);
18816
+ P(), i(q.id);
18851
18817
  },
18852
18818
  children: q.label
18853
18819
  },
@@ -18862,12 +18828,11 @@ const ZC = {
18862
18828
  type: "button",
18863
18829
  "data-action": "cta",
18864
18830
  "data-presentation": "PRIMARY",
18865
- "data-attention": n === "EXITING" || I.has(e.key) ? "NONE" : e.cta.attention,
18831
+ "data-attention": n !== "INTERACTIVE" || I.has(e.key) ? "NONE" : e.cta.attention,
18866
18832
  "aria-busy": c || void 0,
18867
- disabled: P,
18868
- onAnimationEnd: () => y(e.key),
18833
+ disabled: _,
18869
18834
  onClick: () => {
18870
- y(e.key), o();
18835
+ P(), o();
18871
18836
  },
18872
18837
  children: l ?? e.cta.label
18873
18838
  },
@@ -18877,8 +18842,8 @@ const ZC = {
18877
18842
  ]
18878
18843
  }
18879
18844
  );
18880
- }), KC = 4;
18881
- function YC(t) {
18845
+ }), jC = 4;
18846
+ function KC(t) {
18882
18847
  const e = t.ownerDocument.createRange();
18883
18848
  e.selectNodeContents(t);
18884
18849
  const n = [], r = Number.parseFloat(
@@ -18888,8 +18853,8 @@ function YC(t) {
18888
18853
  o.width <= 0 || o.height <= 0 || n.some((a) => Math.abs(a - o.top) < s) || n.push(o.top);
18889
18854
  return n.length > 0 ? n.length : Number.isFinite(r) && r > 0 ? Math.ceil(t.scrollHeight / r) : 0;
18890
18855
  }
18891
- const su = 160, JC = 500, iu = 4e3;
18892
- function QC({
18856
+ const su = 160, YC = 500, iu = 4e3;
18857
+ function JC({
18893
18858
  controller: t,
18894
18859
  snapshot: e,
18895
18860
  onOpenChat: n
@@ -18905,136 +18870,136 @@ function QC({
18905
18870
  }),
18906
18871
  [b, e.principalSessionId]
18907
18872
  ), y = le(
18908
- (V) => l.subscribe(S, V),
18873
+ (B) => l.subscribe(S, B),
18909
18874
  [S, l]
18910
18875
  ), E = le(
18911
18876
  () => l.getSnapshot(S),
18912
18877
  [S, l]
18913
- ), x = ou(
18878
+ ), k = ou(
18914
18879
  y,
18915
18880
  E,
18916
18881
  E
18917
- ), O = le(() => {
18882
+ ), P = le(() => {
18918
18883
  b && t.forceOpenInChat(b.key);
18919
- }, [b, t]), N = le(() => {
18920
- const V = f.current;
18921
- m.current !== null && (window.clearTimeout(m.current), m.current = null), V.startedAtMs !== null && (V.remainingMs = Math.max(
18884
+ }, [b, t]), F = le(() => {
18885
+ const B = f.current;
18886
+ m.current !== null && (window.clearTimeout(m.current), m.current = null), B.startedAtMs !== null && (B.remainingMs = Math.max(
18922
18887
  0,
18923
- V.remainingMs - (Date.now() - V.startedAtMs)
18924
- ), V.startedAtMs = null);
18888
+ B.remainingMs - (Date.now() - B.startedAtMs)
18889
+ ), B.startedAtMs = null);
18925
18890
  }, []), _ = le(() => {
18926
- const V = t.getSnapshot(), k = V.active, T = f.current;
18927
- if (V.phase !== "ENTERING" || !k) {
18928
- N(), T.candidateKey = null, T.remainingMs = 0;
18891
+ const B = t.getSnapshot(), x = B.active, R = f.current;
18892
+ if (B.phase !== "ENTERING" || !x) {
18893
+ F(), R.candidateKey = null, R.remainingMs = 0;
18929
18894
  return;
18930
18895
  }
18931
- if (T.candidateKey !== k.key && (N(), T.candidateKey = k.key, T.remainingMs = HC(k)), !(V.dragSuspended || m.current !== null)) {
18932
- if (s || T.remainingMs <= 0) {
18933
- T.remainingMs = 0, t.markInteractive();
18896
+ if (R.candidateKey !== x.key && (F(), R.candidateKey = x.key, R.remainingMs = HC(x)), !(B.dragSuspended || m.current !== null)) {
18897
+ if (s || R.remainingMs <= 0) {
18898
+ R.remainingMs = 0, t.markInteractive();
18934
18899
  return;
18935
18900
  }
18936
- T.startedAtMs = Date.now(), m.current = window.setTimeout(() => {
18937
- m.current = null, T.remainingMs = 0, T.startedAtMs = null, t.markInteractive();
18938
- }, T.remainingMs);
18901
+ R.startedAtMs = Date.now(), m.current = window.setTimeout(() => {
18902
+ m.current = null, R.remainingMs = 0, R.startedAtMs = null, t.markInteractive();
18903
+ }, R.remainingMs);
18939
18904
  }
18940
- }, [t, N, s]);
18941
- K(() => {
18942
- const V = window.matchMedia?.("(prefers-reduced-motion: reduce)");
18943
- if (!V) return;
18944
- const k = () => i(V.matches);
18945
- return k(), V.addEventListener?.("change", k), () => V.removeEventListener?.("change", k);
18946
- }, []), K(() => {
18947
- const V = e.surfaceEpisodeId;
18948
- if (!(!V || !b))
18949
- return o.scenarioInteractionRuntime.openCompactSurfaceEpisode(V), () => {
18950
- o.scenarioInteractionRuntime.closeCompactSurfaceEpisode(V);
18905
+ }, [t, F, s]);
18906
+ Y(() => {
18907
+ const B = window.matchMedia?.("(prefers-reduced-motion: reduce)");
18908
+ if (!B) return;
18909
+ const x = () => i(B.matches);
18910
+ return x(), B.addEventListener?.("change", x), () => B.removeEventListener?.("change", x);
18911
+ }, []), Y(() => {
18912
+ const B = e.surfaceEpisodeId;
18913
+ if (!(!B || !b))
18914
+ return o.scenarioInteractionRuntime.openCompactSurfaceEpisode(B), () => {
18915
+ o.scenarioInteractionRuntime.closeCompactSurfaceEpisode(B);
18951
18916
  };
18952
- }, [b, o.scenarioInteractionRuntime, e.surfaceEpisodeId]), K(() => (N(), _(), N), [
18917
+ }, [b, o.scenarioInteractionRuntime, e.surfaceEpisodeId]), Y(() => (F(), _(), F), [
18953
18918
  b?.key,
18954
- N,
18919
+ F,
18955
18920
  s,
18956
18921
  _,
18957
18922
  e.phase
18958
- ]), K(
18959
- () => t.subscribeDragSuspension((V) => {
18960
- V ? (N(), p.current?.pause()) : (_(), p.current?.resume());
18923
+ ]), Y(
18924
+ () => t.subscribeDragSuspension((B) => {
18925
+ B ? (F(), p.current?.pause()) : (_(), p.current?.resume());
18961
18926
  }),
18962
- [t, N, _]
18963
- ), K(() => {
18927
+ [t, F, _]
18928
+ ), Y(() => {
18964
18929
  g.current = null, C.current !== null && (window.clearTimeout(C.current), C.current = null);
18965
- }, [b?.key]), K(
18930
+ }, [b?.key]), Y(
18966
18931
  () => () => {
18967
- N(), C.current !== null && window.clearTimeout(C.current);
18932
+ F(), C.current !== null && window.clearTimeout(C.current);
18968
18933
  },
18969
- [N]
18970
- ), K(() => {
18934
+ [F]
18935
+ ), Y(() => {
18971
18936
  if (e.phase !== "EXITING" || !b || e.exitReason === "ACTIVATED" || e.exitReason === "OPENED_CHAT")
18972
18937
  return;
18973
18938
  if (e.exitReason === "ANSWERED" && b.kind === "CHOICE") {
18974
- if (x.status === "error") {
18939
+ if (k.status === "error") {
18975
18940
  t.restoreAfterError(r("compact.answerFailed"));
18976
18941
  return;
18977
18942
  }
18978
- if (x.status !== "terminal") return;
18943
+ if (k.status !== "terminal") return;
18979
18944
  }
18980
- const V = window.setTimeout(
18945
+ const B = window.setTimeout(
18981
18946
  () => t.completeExit(),
18982
18947
  s ? 0 : su
18983
18948
  );
18984
- return () => window.clearTimeout(V);
18949
+ return () => window.clearTimeout(B);
18985
18950
  }, [
18986
18951
  b,
18987
- x.status,
18952
+ k.status,
18988
18953
  t,
18989
18954
  s,
18990
18955
  e.exitReason,
18991
18956
  e.phase,
18992
18957
  r
18993
- ]), K(() => {
18994
- const V = [b, ...e.queue].flatMap((A) => A?.deadlineAtMs === null || !A ? [] : [A.deadlineAtMs]).sort((A, v) => A - v)[0];
18995
- if (V === void 0) return;
18996
- let k = null;
18997
- const T = () => {
18998
- const A = V - Date.now();
18958
+ ]), Y(() => {
18959
+ const B = [b, ...e.queue].flatMap((A) => A?.deadlineAtMs === null || !A ? [] : [A.deadlineAtMs]).sort((A, v) => A - v)[0];
18960
+ if (B === void 0) return;
18961
+ let x = null;
18962
+ const R = () => {
18963
+ const A = B - Date.now();
18999
18964
  if (A <= 0) {
19000
18965
  t.expireDue();
19001
18966
  return;
19002
18967
  }
19003
- k = window.setTimeout(
19004
- T,
18968
+ x = window.setTimeout(
18969
+ R,
19005
18970
  Math.min(A + 1, 2147483647)
19006
18971
  );
19007
18972
  };
19008
- return T(), () => {
19009
- k !== null && window.clearTimeout(k);
18973
+ return R(), () => {
18974
+ x !== null && window.clearTimeout(x);
19010
18975
  };
19011
- }, [b, t, e.queue]), K(() => {
19012
- const V = d.current, k = e.surfaceEpisodeId;
19013
- if (!V || !b || !k || e.dragSuspended || e.phase === "EXITING")
18976
+ }, [b, t, e.queue]), Y(() => {
18977
+ const B = d.current, x = e.surfaceEpisodeId;
18978
+ if (!B || !b || !x || e.dragSuspended || e.phase === "EXITING")
19014
18979
  return;
19015
- const T = $C(b), A = `${k}:${T.subjectKind}:${T.subjectId}`;
18980
+ const R = QC(b), A = `${x}:${R.subjectKind}:${R.subjectId}`;
19016
18981
  if (h.current.has(A)) return;
19017
- let v = null, R, z = !1;
18982
+ let v = null, T, z = !1;
19018
18983
  const G = () => {
19019
18984
  z || (v = Rl({
19020
- element: V,
18985
+ element: B,
19021
18986
  isActive: () => {
19022
18987
  const X = t.getSnapshot();
19023
- return X.active?.key === b.key && X.surfaceEpisodeId === k && !X.dragSuspended && X.phase !== "EXITING";
18988
+ return X.active?.key === b.key && X.surfaceEpisodeId === x && !X.dragSuspended && X.phase !== "EXITING";
19024
18989
  },
19025
18990
  onPresented: () => {
19026
18991
  o.scenarioInteractionRuntime.recordCompactPresented(
19027
- T,
19028
- k
19029
- ) ? (h.current.add(A), h.current.size > 64 && (h.current = /* @__PURE__ */ new Set([A]))) : R = window.setTimeout(
18992
+ R,
18993
+ x
18994
+ ) ? (h.current.add(A), h.current.size > 64 && (h.current = /* @__PURE__ */ new Set([A]))) : T = window.setTimeout(
19030
18995
  G,
19031
- JC
18996
+ YC
19032
18997
  );
19033
18998
  }
19034
18999
  }), p.current = v);
19035
19000
  };
19036
19001
  return G(), () => {
19037
- z = !0, v?.(), p.current === v && (p.current = null), R !== void 0 && window.clearTimeout(R);
19002
+ z = !0, v?.(), p.current === v && (p.current = null), T !== void 0 && window.clearTimeout(T);
19038
19003
  };
19039
19004
  }, [
19040
19005
  b,
@@ -19044,30 +19009,30 @@ function QC({
19044
19009
  e.phase,
19045
19010
  e.surfaceEpisodeId
19046
19011
  ]);
19047
- const P = le(() => {
19048
- const V = t.getSnapshot(), k = V.active;
19049
- if (!(!k || V.phase !== "ENTERING" && V.phase !== "INTERACTIVE") && (t.beginExit(
19050
- k.kind === "CHOICE" ? "COLLAPSED" : "DISMISSED"
19051
- ), k.kind === "CTA" && !a(
19052
- k.cta.commandId,
19053
- V.surfaceEpisodeId ?? void 0
19012
+ const O = le(() => {
19013
+ const B = t.getSnapshot(), x = B.active;
19014
+ if (!(!x || B.phase !== "ENTERING" && B.phase !== "INTERACTIVE") && (t.beginExit(
19015
+ x.kind === "CHOICE" ? "COLLAPSED" : "DISMISSED"
19016
+ ), x.kind === "CTA" && !a(
19017
+ x.cta.commandId,
19018
+ B.surfaceEpisodeId ?? void 0
19054
19019
  ))) {
19055
19020
  t.restoreAfterError(r("compact.actionFailed"));
19056
19021
  return;
19057
19022
  }
19058
19023
  }, [t, a, r]);
19059
- if (K(() => {
19060
- const V = (k) => {
19061
- k.key !== "Escape" || k.defaultPrevented || P();
19024
+ if (Y(() => {
19025
+ const B = (x) => {
19026
+ x.key !== "Escape" || x.defaultPrevented || O();
19062
19027
  };
19063
- return window.addEventListener("keydown", V), () => window.removeEventListener("keydown", V);
19064
- }, [P]), !b || e.phase === "IDLE" || e.phase === "GAP")
19028
+ return window.addEventListener("keydown", B), () => window.removeEventListener("keydown", B);
19029
+ }, [O]), !b || e.phase === "IDLE" || e.phase === "GAP")
19065
19030
  return null;
19066
- const B = (V) => {
19031
+ const V = (B) => {
19067
19032
  b.kind !== "CHOICE" || e.phase !== "INTERACTIVE" || (l.submit({
19068
19033
  principalId: e.principalSessionId,
19069
19034
  inputRequestId: b.choice.inputRequestId,
19070
- optionId: V,
19035
+ optionId: B,
19071
19036
  ...e.surfaceEpisodeId ? {
19072
19037
  presentationContext: {
19073
19038
  surface: "COMPACT_PREVIEW",
@@ -19075,11 +19040,11 @@ function QC({
19075
19040
  }
19076
19041
  } : {}
19077
19042
  }), t.beginExit("ANSWERED"));
19078
- }, ne = () => {
19043
+ }, q = () => {
19079
19044
  if (b.kind !== "CTA" || e.phase !== "INTERACTIVE" || I.busy || g.current === b.key)
19080
19045
  return;
19081
19046
  g.current = b.key;
19082
- const V = b.key, k = Date.now(), T = u(
19047
+ const B = b.key, x = Date.now(), R = u(
19083
19048
  b.cta.commandId,
19084
19049
  e.surfaceEpisodeId ?? void 0
19085
19050
  );
@@ -19089,12 +19054,12 @@ function QC({
19089
19054
  () => {
19090
19055
  C.current = null;
19091
19056
  const v = t.getSnapshot();
19092
- v.active?.key === V && v.exitReason === "ACTIVATED" && (g.current = null, t.completeExit());
19057
+ v.active?.key === B && v.exitReason === "ACTIVATED" && (g.current = null, t.completeExit());
19093
19058
  },
19094
19059
  Math.min(iu, A)
19095
- ), T.catch(() => "TERMINAL_FAILURE").then((v) => {
19096
- const R = t.getSnapshot();
19097
- if (!(R.active?.key !== V || R.exitReason !== "ACTIVATED"))
19060
+ ), R.catch(() => "TERMINAL_FAILURE").then((v) => {
19061
+ const T = t.getSnapshot();
19062
+ if (!(T.active?.key !== B || T.exitReason !== "ACTIVATED"))
19098
19063
  if (v === "RETRYABLE_FAILURE")
19099
19064
  C.current !== null && (window.clearTimeout(C.current), C.current = null), g.current = null, t.restoreAfterError(r("compact.actionFailed"));
19100
19065
  else if (v === "AWAITING_CONFIRMATION")
@@ -19102,18 +19067,18 @@ function QC({
19102
19067
  else {
19103
19068
  const z = Math.max(
19104
19069
  0,
19105
- (s ? 0 : su) - (Date.now() - k)
19070
+ (s ? 0 : su) - (Date.now() - x)
19106
19071
  );
19107
19072
  C.current !== null && window.clearTimeout(C.current), C.current = window.setTimeout(() => {
19108
19073
  C.current = null;
19109
19074
  const G = t.getSnapshot();
19110
- G.active?.key === V && G.exitReason === "ACTIVATED" && t.completeExit();
19075
+ G.active?.key === B && G.exitReason === "ACTIVATED" && t.completeExit();
19111
19076
  }, z);
19112
19077
  }
19113
19078
  });
19114
- }, q = e.error || (b.kind === "CTA" ? I.feedback : null) || (b.kind === "CHOICE" && x.status === "error" ? r("compact.answerFailed") : null);
19079
+ }, K = e.error || (b.kind === "CTA" ? I.feedback : null) || (b.kind === "CHOICE" && k.status === "error" ? r("compact.answerFailed") : null);
19115
19080
  return /* @__PURE__ */ H("div", { ref: d, "data-lola-compact-preview-observation": !0, children: /* @__PURE__ */ H(
19116
- jC,
19081
+ ZC,
19117
19082
  {
19118
19083
  candidate: b,
19119
19084
  phase: e.phase,
@@ -19123,23 +19088,23 @@ function QC({
19123
19088
  coalescedLabel: b.coalescedCount > 0 ? r("compact.moreMessages", {
19124
19089
  count: b.coalescedCount
19125
19090
  }) : null,
19126
- selectedChoiceOptionId: b.kind === "CHOICE" ? x.selectedOptionId : null,
19127
- feedback: q,
19128
- onRenderedOverflow: O,
19091
+ selectedChoiceOptionId: b.kind === "CHOICE" ? k.selectedOptionId : null,
19092
+ feedback: K,
19093
+ onRenderedOverflow: P,
19129
19094
  labels: {
19130
19095
  region: r("compact.region"),
19131
19096
  dismiss: r("compact.dismiss"),
19132
19097
  openChat: b.kind === "CHOICE" ? r("compact.openQuestion") : r("compact.openMessage"),
19133
19098
  choices: r("compact.choices")
19134
19099
  },
19135
- onDismiss: P,
19100
+ onDismiss: O,
19136
19101
  onOpenChat: n,
19137
- onChoice: B,
19138
- onCta: ne
19102
+ onChoice: V,
19103
+ onCta: q
19139
19104
  }
19140
19105
  ) });
19141
19106
  }
19142
- function $C(t) {
19107
+ function QC(t) {
19143
19108
  return {
19144
19109
  subjectKind: t.kind === "INFO" ? "MESSAGE" : t.kind === "CHOICE" ? "CHOICE" : "CTA",
19145
19110
  subjectId: t.subjectId,
@@ -19147,7 +19112,7 @@ function $C(t) {
19147
19112
  ...t.kind === "INFO" && t.message.ordinal !== void 0 ? { presentationOrdinal: t.message.ordinal } : {}
19148
19113
  };
19149
19114
  }
19150
- const ey = 250, ty = yl(() => import("./ChatWidgetContent-BYZ7Qq06.js")), ny = (t) => {
19115
+ const $C = 250, ey = yl(() => import("./ChatWidgetContent-CdHhVe7P.js")), ty = (t) => {
19151
19116
  const e = /* @__PURE__ */ new Set(), n = t.getSnapshot(), r = new Set(
19152
19117
  [n.active, ...n.queue].flatMap(
19153
19118
  (s) => s?.messageId ? [s.messageId] : []
@@ -19156,11 +19121,11 @@ const ey = 250, ty = yl(() => import("./ChatWidgetContent-BYZ7Qq06.js")), ny = (
19156
19121
  for (const s of j.getState().messages)
19157
19122
  e.has(s.id) || !Xn(s) && !r.has(s.id) || (e.add(s.id), t.receiveMessage(s, "HISTORY_REPLAY"));
19158
19123
  }, Cr = (t, e) => {
19159
- t.then(() => ny(e)).catch(
19124
+ t.then(() => ty(e)).catch(
19160
19125
  (n) => console.warn("[ChatWidget] Message history recovery failed", n)
19161
19126
  );
19162
19127
  };
19163
- function ry() {
19128
+ function ny() {
19164
19129
  const {
19165
19130
  open: t,
19166
19131
  transitionSurface: e,
@@ -19177,35 +19142,35 @@ function ry() {
19177
19142
  g
19178
19143
  )?.inputRequestId, S = U(void 0), y = U(null), {
19179
19144
  clearTransientRealtimeState: E,
19180
- disposeMessageStore: x,
19181
- initMessageStore: O,
19182
- recoverMessages: N,
19145
+ disposeMessageStore: k,
19146
+ initMessageStore: P,
19147
+ recoverMessages: F,
19183
19148
  updateConfig: _
19184
- } = zm(), P = ou(
19149
+ } = zm(), O = ou(
19185
19150
  l.subscribe,
19186
19151
  l.getSnapshot,
19187
19152
  l.getSnapshot
19188
19153
  );
19189
- K(() => {
19190
- if (P.phase !== "GAP") return;
19154
+ Y(() => {
19155
+ if (O.phase !== "GAP") return;
19191
19156
  const A = window.setTimeout(
19192
19157
  () => l.promoteNext(),
19193
- ey
19158
+ $C
19194
19159
  );
19195
19160
  return () => window.clearTimeout(A);
19196
- }, [l, P.phase]);
19197
- const B = U({
19161
+ }, [l, O.phase]);
19162
+ const V = U({
19198
19163
  api: a,
19199
19164
  compactPreviewController: l,
19200
19165
  config: o,
19201
- disposeMessageStore: x,
19202
- initMessageStore: O
19203
- }), ne = U({
19166
+ disposeMessageStore: k,
19167
+ initMessageStore: P
19168
+ }), q = U({
19204
19169
  accessToken: o.customerInteractionSession.accessToken,
19205
19170
  interactionSessionId: o.customerInteractionSession.interactionSessionId
19206
19171
  });
19207
- K(() => {
19208
- const A = B.current;
19172
+ Y(() => {
19173
+ const A = V.current;
19209
19174
  return Cr(
19210
19175
  A.initMessageStore(
19211
19176
  A.config,
@@ -19213,38 +19178,38 @@ function ry() {
19213
19178
  ),
19214
19179
  A.compactPreviewController
19215
19180
  ), () => A.disposeMessageStore();
19216
- }, []), K(() => {
19217
- const A = ne.current, v = o.customerInteractionSession;
19218
- if (ne.current = {
19181
+ }, []), Y(() => {
19182
+ const A = q.current, v = o.customerInteractionSession;
19183
+ if (q.current = {
19219
19184
  accessToken: v.accessToken,
19220
19185
  interactionSessionId: v.interactionSessionId
19221
19186
  }, A.interactionSessionId !== v.interactionSessionId) {
19222
- Cr(O(o, a), l);
19187
+ Cr(P(o, a), l);
19223
19188
  return;
19224
19189
  }
19225
- _(o, a), A.accessToken !== v.accessToken && Cr(N(), l);
19190
+ _(o, a), A.accessToken !== v.accessToken && Cr(F(), l);
19226
19191
  }, [
19227
19192
  a,
19228
19193
  l,
19229
19194
  o,
19230
- O,
19231
- N,
19195
+ P,
19196
+ F,
19232
19197
  _
19233
- ]), K(() => {
19198
+ ]), Y(() => {
19234
19199
  !I || S.current === I || (S.current = I, f(st.text));
19235
- }, [f, I]), K(() => {
19200
+ }, [f, I]), Y(() => {
19236
19201
  !b || y.current === b.sequence || (y.current = b.sequence, gb(m.pathname) && f(st.text));
19237
- }, [b, m.pathname, f]), K(() => {
19202
+ }, [b, m.pathname, f]), Y(() => {
19238
19203
  if (!d?.channels.chat) return;
19239
19204
  const A = d.channels.chat.on(
19240
19205
  "connect",
19241
- (R) => {
19242
- (R.reconnect || R.restored) && (E(), Cr(N(), l));
19206
+ (T) => {
19207
+ (T.reconnect || T.restored) && (E(), Cr(F(), l));
19243
19208
  }
19244
19209
  ), v = d.channels.chat.on(
19245
19210
  "info",
19246
- (R) => {
19247
- (R.type === "history_not_found" || R.type === "reject_history") && (E(), Cr(N(), l));
19211
+ (T) => {
19212
+ (T.type === "history_not_found" || T.type === "reject_history") && (E(), Cr(F(), l));
19248
19213
  }
19249
19214
  );
19250
19215
  return () => {
@@ -19254,29 +19219,29 @@ function ry() {
19254
19219
  d?.channels.chat,
19255
19220
  E,
19256
19221
  l,
19257
- N
19222
+ F
19258
19223
  ]);
19259
- const q = le(() => {
19224
+ const K = le(() => {
19260
19225
  const A = {
19261
19226
  actor: "USER",
19262
19227
  reason: "USER_LAUNCHER"
19263
19228
  };
19264
19229
  n(A) || e(!0, A);
19265
- }, [n, e]), V = le(
19230
+ }, [n, e]), B = le(
19266
19231
  (A) => l.setDragSuspended(A),
19267
19232
  [l]
19268
- ), k = le(() => {
19233
+ ), x = le(() => {
19269
19234
  l.getSnapshot().active?.kind === "CHOICE" && l.beginExit("COLLAPSED");
19270
- }, [l]), T = un(
19271
- () => P.active ? /* @__PURE__ */ H(
19272
- QC,
19235
+ }, [l]), R = un(
19236
+ () => O.active ? /* @__PURE__ */ H(
19237
+ JC,
19273
19238
  {
19274
19239
  controller: l,
19275
- snapshot: P,
19276
- onOpenChat: q
19240
+ snapshot: O,
19241
+ onOpenChat: K
19277
19242
  }
19278
19243
  ) : null,
19279
- [l, P, q]
19244
+ [l, O, K]
19280
19245
  );
19281
19246
  return /* @__PURE__ */ H(
19282
19247
  wC,
@@ -19296,7 +19261,7 @@ function ry() {
19296
19261
  open: t,
19297
19262
  onOpenChange: (A) => {
19298
19263
  if (A && l.getSnapshot().active) {
19299
- q();
19264
+ K();
19300
19265
  return;
19301
19266
  }
19302
19267
  e(A, {
@@ -19311,21 +19276,20 @@ function ry() {
19311
19276
  launcherImageSrc: ll,
19312
19277
  unreadIndicator: /* @__PURE__ */ H(gC, { descriptionId: h }),
19313
19278
  launcherDescriptionId: h,
19314
- compactPreview: T,
19315
- compactPreviewAnnouncement: P.active ? [
19316
- P.active.text || (P.active.kind === "CTA" ? P.active.cta.label : ""),
19317
- P.active.coalescedCount > 0 ? p("compact.moreMessages", {
19318
- count: P.active.coalescedCount
19279
+ compactPreview: R,
19280
+ compactPreviewAnnouncement: O.active ? [
19281
+ O.active.text || (O.active.kind === "CTA" ? O.active.cta.label : ""),
19282
+ O.active.coalescedCount > 0 ? p("compact.moreMessages", {
19283
+ count: O.active.coalescedCount
19319
19284
  }) : ""
19320
19285
  ].filter(Boolean).join(". ") : "",
19321
- compactPreviewCollapsible: P.active?.kind === "CHOICE",
19322
- compactPreviewSuspended: P.dragSuspended,
19323
- storageScope: o.compactScenarioPreview?.enabled ? o.compactScenarioPreview.storageNamespace?.trim() || null : void 0,
19324
- onLauncherDragSuspended: V,
19325
- onCompactPreviewCollapse: k,
19286
+ compactPreviewCollapsible: O.active?.kind === "CHOICE",
19287
+ compactPreviewSuspended: O.dragSuspended,
19288
+ onLauncherDragSuspended: B,
19289
+ onCompactPreviewCollapse: x,
19326
19290
  children: [
19327
19291
  /* @__PURE__ */ H(bC, {}),
19328
- s && /* @__PURE__ */ H(Cl, { fallback: null, children: /* @__PURE__ */ H(ty, {}) })
19292
+ s && /* @__PURE__ */ H(Cl, { fallback: null, children: /* @__PURE__ */ H(ey, {}) })
19329
19293
  ]
19330
19294
  }
19331
19295
  )
@@ -19334,11 +19298,11 @@ function ry() {
19334
19298
  }
19335
19299
  );
19336
19300
  }
19337
- const sy = Yn(null), Ri = {
19301
+ const ry = Yn(null), Ri = {
19338
19302
  didCatch: !1,
19339
19303
  error: null
19340
19304
  };
19341
- class iy extends Il {
19305
+ class sy extends Il {
19342
19306
  constructor(e) {
19343
19307
  super(e), this.resetErrorBoundary = this.resetErrorBoundary.bind(this), this.state = Ri;
19344
19308
  }
@@ -19357,7 +19321,7 @@ class iy extends Il {
19357
19321
  }
19358
19322
  componentDidUpdate(e, n) {
19359
19323
  const { didCatch: r } = this.state, { resetKeys: s } = this.props;
19360
- r && n.error !== null && oy(e.resetKeys, s) && (this.props.onReset?.({
19324
+ r && n.error !== null && iy(e.resetKeys, s) && (this.props.onReset?.({
19361
19325
  next: s,
19362
19326
  prev: e.resetKeys,
19363
19327
  reason: "keys"
@@ -19381,7 +19345,7 @@ class iy extends Il {
19381
19345
  throw o;
19382
19346
  }
19383
19347
  return No(
19384
- sy.Provider,
19348
+ ry.Provider,
19385
19349
  {
19386
19350
  value: {
19387
19351
  didCatch: i,
@@ -19393,21 +19357,21 @@ class iy extends Il {
19393
19357
  );
19394
19358
  }
19395
19359
  }
19396
- function oy(t = [], e = []) {
19360
+ function iy(t = [], e = []) {
19397
19361
  return t.length !== e.length || t.some((n, r) => !Object.is(n, e[r]));
19398
19362
  }
19399
- function ay({
19363
+ function oy({
19400
19364
  children: t,
19401
19365
  locale: e
19402
19366
  }) {
19403
19367
  const n = un(() => el(e), [e]);
19404
19368
  return /* @__PURE__ */ H(tl.Provider, { value: n, children: t });
19405
19369
  }
19406
- function uy({ reset: t }) {
19370
+ function ay({ reset: t }) {
19407
19371
  const { t: e } = Tn();
19408
19372
  return /* @__PURE__ */ H("button", { type: "button", onClick: t, children: e("app.restart") });
19409
19373
  }
19410
- function cy({
19374
+ function uy({
19411
19375
  config: t,
19412
19376
  api: e,
19413
19377
  children: n,
@@ -19450,45 +19414,44 @@ function cy({
19450
19414
  }
19451
19415
  );
19452
19416
  }
19453
- function ly({ config: t, api: e }) {
19417
+ function cy({ config: t, api: e }) {
19454
19418
  const [n, r] = he(t), [s, i] = he(t.locale);
19455
- return K(() => (e.registerSetSession((o) => {
19419
+ return Y(() => (e.registerSetSession((o) => {
19456
19420
  r((a) => ({
19457
19421
  ...a,
19458
19422
  customerInteractionSession: o
19459
19423
  }));
19460
- }), () => e.registerSetSession(null)), [e]), K(() => (e.registerSetLocale(i), () => e.registerSetLocale(null)), [e]), /* @__PURE__ */ H(ay, { locale: s, children: /* @__PURE__ */ H(
19461
- iy,
19424
+ }), () => e.registerSetSession(null)), [e]), Y(() => (e.registerSetLocale(i), () => e.registerSetLocale(null)), [e]), /* @__PURE__ */ H(oy, { locale: s, children: /* @__PURE__ */ H(
19425
+ sy,
19462
19426
  {
19463
- fallbackRender: ({ resetErrorBoundary: o }) => /* @__PURE__ */ H(uy, { reset: o }),
19427
+ fallbackRender: ({ resetErrorBoundary: o }) => /* @__PURE__ */ H(ay, { reset: o }),
19464
19428
  onError: (o, a) => {
19465
19429
  re.error("Widget render failed", o, a.componentStack);
19466
19430
  },
19467
- children: /* @__PURE__ */ H(Ed, { children: /* @__PURE__ */ H(j1, { config: n, api: e, children: /* @__PURE__ */ H(cy, { config: n, api: e, children: /* @__PURE__ */ H(ry, {}) }) }) })
19431
+ children: /* @__PURE__ */ H(Ed, { children: /* @__PURE__ */ H(j1, { config: n, api: e, children: /* @__PURE__ */ H(uy, { config: n, api: e, children: /* @__PURE__ */ H(ny, {}) }) }) })
19468
19432
  }
19469
19433
  ) });
19470
19434
  }
19471
- function dy(t, e, n) {
19435
+ function ly(t, e, n) {
19472
19436
  const r = Ml(t);
19473
- return r.render(/* @__PURE__ */ H(ly, { config: { ...e }, api: n })), r;
19437
+ return r.render(/* @__PURE__ */ H(cy, { config: { ...e }, api: n })), r;
19474
19438
  }
19475
- const Hy = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
19439
+ const Wy = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
19476
19440
  __proto__: null,
19477
- mountWidget: dy
19441
+ mountWidget: ly
19478
19442
  }, Symbol.toStringTag, { value: "Module" }));
19479
19443
  export {
19480
- Hy as $,
19481
- Ly as A,
19482
- Vm as B,
19444
+ Vm as A,
19445
+ Ey as B,
19483
19446
  st as C,
19484
- ky as D,
19485
- Fy as E,
19486
- Mm as F,
19487
- yy as G,
19488
- wt as H,
19489
- By as I,
19490
- zy as J,
19491
- mb as K,
19447
+ _y as D,
19448
+ Mm as E,
19449
+ Cy as F,
19450
+ wt as G,
19451
+ Oy as H,
19452
+ Vy as I,
19453
+ mb as J,
19454
+ Iy as K,
19492
19455
  vy as L,
19493
19456
  fe as M,
19494
19457
  $t as N,
@@ -19497,38 +19460,38 @@ export {
19497
19460
  wy as Q,
19498
19461
  Sy as R,
19499
19462
  P1 as S,
19500
- Ey as T,
19501
- Oy as U,
19502
- Iy as V,
19503
- Vy as W,
19504
- Zi as X,
19505
- by as Y,
19506
- kd as Z,
19507
- gy as _,
19463
+ Py as T,
19464
+ By as U,
19465
+ yy as V,
19466
+ Zi as W,
19467
+ gy as X,
19468
+ kd as Y,
19469
+ my as Z,
19470
+ Wy as _,
19508
19471
  Hr as a,
19509
- XC as b,
19510
- Vs as c,
19511
- Kc as d,
19512
- Gy as e,
19513
- vs as f,
19514
- Ht as g,
19515
- Wy as h,
19472
+ Vs as b,
19473
+ Kc as c,
19474
+ zy as d,
19475
+ vs as e,
19476
+ Ht as f,
19477
+ Uy as g,
19478
+ Gy as h,
19516
19479
  qy as i,
19517
- Uy as j,
19518
- zm as k,
19480
+ zm as j,
19481
+ Fy as k,
19519
19482
  ll as l,
19520
19483
  Ts as m,
19521
- Ny as n,
19522
- Dm as o,
19523
- Xn as p,
19524
- qu as q,
19484
+ Dm as n,
19485
+ Xn as o,
19486
+ qu as p,
19487
+ Uu as q,
19525
19488
  hm as r,
19526
- Uu as s,
19527
- Ry as t,
19489
+ Ty as s,
19490
+ My as t,
19528
19491
  Tn as u,
19529
- Dy as v,
19530
- My as w,
19492
+ Ry as v,
19493
+ ky as w,
19531
19494
  xy as x,
19532
- Ty as y,
19533
- _y as z
19495
+ Dy as y,
19496
+ Ny as z
19534
19497
  };