@livelayer/react 0.5.23 → 0.5.24-debug.1

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.
Files changed (3) hide show
  1. package/dist/index.js +3 -3
  2. package/dist/index.mjs +1389 -1291
  3. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -1,9 +1,9 @@
1
1
  "use client";
2
- import { jsxs as _, jsx as n, Fragment as St } from "react/jsx-runtime";
3
- import { Component as mn, useState as S, useRef as A, useEffect as N, useCallback as L, useMemo as ut, forwardRef as Ct, createElement as gn } from "react";
4
- import { LiveKitSession as yn } from "@livelayer/sdk";
5
- import { createLocalAudioTrack as vn, Track as en, createLocalVideoTrack as bn } from "livekit-client";
6
- class wn extends mn {
2
+ import { jsxs as x, jsx as n, Fragment as Ct } from "react/jsx-runtime";
3
+ import { Component as bn, useState as E, useRef as A, useEffect as M, useCallback as S, useMemo as gt, forwardRef as Nt, createElement as vn } from "react";
4
+ import { LiveKitSession as wn } from "@livelayer/sdk";
5
+ import { createLocalAudioTrack as _n, Track as rn, createLocalVideoTrack as xn } from "livekit-client";
6
+ class kn extends bn {
7
7
  constructor() {
8
8
  super(...arguments), this.state = { hasError: !1, error: null }, this.reset = () => {
9
9
  this.setState({ hasError: !1, error: null });
@@ -13,12 +13,12 @@ class wn extends mn {
13
13
  return { hasError: !0, error: t };
14
14
  }
15
15
  componentDidCatch(t, r) {
16
- var i, o;
17
- (o = (i = this.props).onError) == null || o.call(i, t, r);
16
+ var o, i;
17
+ (i = (o = this.props).onError) == null || i.call(o, t, r);
18
18
  }
19
19
  render() {
20
20
  var t;
21
- return this.state.hasError ? this.props.fallback ? this.props.fallback : /* @__PURE__ */ _("div", { className: "ll-error-boundary", role: "alert", children: [
21
+ return this.state.hasError ? this.props.fallback ? this.props.fallback : /* @__PURE__ */ x("div", { className: "ll-error-boundary", role: "alert", children: [
22
22
  /* @__PURE__ */ n("p", { className: "ll-error-boundary__title", children: "Widget crashed" }),
23
23
  /* @__PURE__ */ n("p", { className: "ll-error-boundary__message", children: ((t = this.state.error) == null ? void 0 : t.message) || "Something went wrong." }),
24
24
  /* @__PURE__ */ n(
@@ -33,26 +33,26 @@ class wn extends mn {
33
33
  ] }) : this.props.children;
34
34
  }
35
35
  }
36
- function _n(e) {
37
- const [t, r] = S("idle"), [i, o] = S("idle"), [l, c] = S([]), [u, f] = S(null), [y, b] = S(null), [s, a] = S(null), [x, E] = S(!1), [C, v] = S(null), w = A(null), H = A(e.onDataMessage);
38
- H.current = e.onDataMessage, N(() => {
39
- const R = {
40
- onConnectionStateChange: (z) => {
41
- r(z), z === "connected" && v(null);
36
+ function Ln(e) {
37
+ const [t, r] = E("idle"), [o, i] = E("idle"), [l, d] = E([]), [u, f] = E(null), [y, w] = E(null), [s, a] = E(null), [L, D] = E(!1), [C, v] = E(null), _ = A(null), O = A(e.onDataMessage);
38
+ O.current = e.onDataMessage, M(() => {
39
+ const I = {
40
+ onConnectionStateChange: (B) => {
41
+ r(B), B === "connected" && v(null);
42
42
  },
43
- onAgentStateChange: o,
44
- onTranscript: (z) => c([...z]),
43
+ onAgentStateChange: i,
44
+ onTranscript: (B) => d([...B]),
45
45
  onAgentConfig: f,
46
- onAudioTrack: (z) => a(z),
47
- onVideoTrack: (z) => b(z),
48
- onVideoTrackRemoved: () => b(null),
49
- onError: (z) => v(z),
50
- onDataMessage: (z) => {
51
- var M;
52
- (M = H.current) == null || M.call(H, z);
46
+ onAudioTrack: (B) => a(B),
47
+ onVideoTrack: (B) => w(B),
48
+ onVideoTrackRemoved: () => w(null),
49
+ onError: (B) => v(B),
50
+ onDataMessage: (B) => {
51
+ var P;
52
+ (P = O.current) == null || P.call(O, B);
53
53
  },
54
- onResumabilityChange: E
55
- }, W = new yn(
54
+ onResumabilityChange: D
55
+ }, q = new wn(
56
56
  {
57
57
  agentId: e.agentId,
58
58
  baseUrl: e.baseUrl,
@@ -60,11 +60,11 @@ function _n(e) {
60
60
  sessionEndpoint: e.sessionEndpoint,
61
61
  sessionBody: e.sessionBody
62
62
  },
63
- R
63
+ I
64
64
  );
65
- return w.current = W, r("idle"), o("idle"), c([]), f(null), b(null), a(null), E(!1), v(null), () => {
66
- var z;
67
- (z = W.destroy) == null || z.call(W), w.current = null;
65
+ return _.current = q, r("idle"), i("idle"), d([]), f(null), w(null), a(null), D(!1), v(null), () => {
66
+ var B;
67
+ (B = q.destroy) == null || B.call(q), _.current = null;
68
68
  };
69
69
  }, [
70
70
  e.agentId,
@@ -73,41 +73,41 @@ function _n(e) {
73
73
  e.sessionEndpoint,
74
74
  JSON.stringify(e.sessionBody ?? {})
75
75
  ]);
76
- const T = L(async () => {
77
- const R = w.current;
78
- if (R)
76
+ const $ = S(async () => {
77
+ const I = _.current;
78
+ if (I)
79
79
  try {
80
- await R.connect();
81
- } catch (W) {
82
- throw v(W instanceof Error ? W.message : String(W)), W;
80
+ await I.connect();
81
+ } catch (q) {
82
+ throw v(q instanceof Error ? q.message : String(q)), q;
83
83
  }
84
- }, []), q = L(() => {
85
- const R = w.current;
86
- R && R.disconnect();
87
- }, []), m = L(() => {
88
- var R;
89
- return ((R = w.current) == null ? void 0 : R.getRoom()) ?? null;
84
+ }, []), U = S(() => {
85
+ const I = _.current;
86
+ I && I.disconnect();
87
+ }, []), m = S(() => {
88
+ var I;
89
+ return ((I = _.current) == null ? void 0 : I.getRoom()) ?? null;
90
90
  }, []);
91
91
  return {
92
92
  connectionState: t,
93
- agentState: i,
93
+ agentState: o,
94
94
  transcript: l,
95
95
  agentConfig: u,
96
96
  videoElement: y,
97
97
  audioElement: s,
98
- canResume: x,
98
+ canResume: L,
99
99
  error: C,
100
- connect: T,
101
- disconnect: q,
100
+ connect: $,
101
+ disconnect: U,
102
102
  getRoom: m,
103
- session: w.current
103
+ session: _.current
104
104
  };
105
105
  }
106
- function xn() {
107
- const e = A(null), t = A(null), r = A(null), i = A(null), o = A(/* @__PURE__ */ new Set()), l = A(null), c = L(() => {
106
+ function Sn() {
107
+ const e = A(null), t = A(null), r = A(null), o = A(null), i = A(/* @__PURE__ */ new Set()), l = A(null), d = S(() => {
108
108
  const s = t.current;
109
109
  if (!s) {
110
- i.current = null;
110
+ o.current = null;
111
111
  return;
112
112
  }
113
113
  (!l.current || l.current.length !== s.frequencyBinCount) && (l.current = new Uint8Array(
@@ -115,21 +115,21 @@ function xn() {
115
115
  ));
116
116
  const a = l.current;
117
117
  s.getByteFrequencyData(a);
118
- let x = 0;
119
- for (let C = 0; C < a.length; C++) x += a[C];
120
- const E = x / a.length / 255;
121
- for (const C of o.current)
118
+ let L = 0;
119
+ for (let C = 0; C < a.length; C++) L += a[C];
120
+ const D = L / a.length / 255;
121
+ for (const C of i.current)
122
122
  try {
123
- C(E);
123
+ C(D);
124
124
  } catch (v) {
125
125
  console.error("[useAudioLevel] subscriber threw:", v);
126
126
  }
127
- i.current = requestAnimationFrame(c);
128
- }, []), u = L(() => {
127
+ o.current = requestAnimationFrame(d);
128
+ }, []), u = S(() => {
129
129
  if (e.current || typeof window > "u" || typeof AudioContext > "u") return;
130
130
  const s = new AudioContext(), a = s.createAnalyser();
131
131
  a.fftSize = 64, a.connect(s.destination), e.current = s, t.current = a;
132
- }, []), f = L(
132
+ }, []), f = S(
133
133
  (s) => {
134
134
  if (u(), !(!e.current || !t.current)) {
135
135
  if (r.current) {
@@ -146,22 +146,22 @@ function xn() {
146
146
  console.warn("[useAudioLevel] createMediaElementSource failed:", a);
147
147
  return;
148
148
  }
149
- i.current === null && (i.current = requestAnimationFrame(c));
149
+ o.current === null && (o.current = requestAnimationFrame(d));
150
150
  }
151
151
  },
152
- [u, c]
153
- ), y = L(() => {
154
- if (i.current !== null && (cancelAnimationFrame(i.current), i.current = null), r.current) {
152
+ [u, d]
153
+ ), y = S(() => {
154
+ if (o.current !== null && (cancelAnimationFrame(o.current), o.current = null), r.current) {
155
155
  try {
156
156
  r.current.disconnect();
157
157
  } catch {
158
158
  }
159
159
  r.current = null;
160
160
  }
161
- }, []), b = L((s) => (o.current.add(s), () => {
162
- o.current.delete(s);
161
+ }, []), w = S((s) => (i.current.add(s), () => {
162
+ i.current.delete(s);
163
163
  }), []);
164
- return N(() => () => {
164
+ return M(() => () => {
165
165
  if (y(), t.current) {
166
166
  try {
167
167
  t.current.disconnect();
@@ -176,40 +176,40 @@ function xn() {
176
176
  }
177
177
  e.current = null;
178
178
  }
179
- o.current.clear(), l.current = null;
180
- }, [y]), { attach: f, detach: y, subscribe: b };
179
+ i.current.clear(), l.current = null;
180
+ }, [y]), { attach: f, detach: y, subscribe: w };
181
181
  }
182
- function kn() {
183
- const [e, t] = S(!1), [r, i] = S(null), o = A(null), l = A(null), c = L(
182
+ function En() {
183
+ const [e, t] = E(!1), [r, o] = E(null), i = A(null), l = A(null), d = S(
184
184
  async (s, a) => {
185
- if (o.current && l.current) {
185
+ if (i.current && l.current) {
186
186
  try {
187
- await l.current.localParticipant.unpublishTrack(o.current);
187
+ await l.current.localParticipant.unpublishTrack(i.current);
188
188
  } catch {
189
189
  }
190
- o.current.stop(), o.current = null;
190
+ i.current.stop(), i.current = null;
191
191
  }
192
- l.current = s, i(null);
192
+ l.current = s, o(null);
193
193
  try {
194
- const x = await vn({
194
+ const L = await _n({
195
195
  echoCancellation: !0,
196
196
  noiseSuppression: !0
197
197
  });
198
- a != null && a.startMuted && await x.mute(), await s.localParticipant.publishTrack(x), o.current = x, t(x.isMuted);
199
- } catch (x) {
200
- const E = x instanceof Error && x.name === "NotAllowedError" ? "Enable your microphone to talk with the agent." : "Microphone unavailable. Check browser permissions and try again.";
201
- throw i(E), x;
198
+ a != null && a.startMuted && await L.mute(), await s.localParticipant.publishTrack(L), i.current = L, t(L.isMuted);
199
+ } catch (L) {
200
+ const D = L instanceof Error && L.name === "NotAllowedError" ? "Enable your microphone to talk with the agent." : "Microphone unavailable. Check browser permissions and try again.";
201
+ throw o(D), L;
202
202
  }
203
203
  },
204
204
  []
205
- ), u = L(() => {
206
- const s = o.current;
205
+ ), u = S(() => {
206
+ const s = i.current;
207
207
  s && (s.isMuted ? (s.unmute(), t(!1)) : (s.mute(), t(!0)));
208
- }, []), f = L((s) => {
209
- const a = o.current;
208
+ }, []), f = S((s) => {
209
+ const a = i.current;
210
210
  a && (s && !a.isMuted ? (a.mute(), t(!0)) : !s && a.isMuted && (a.unmute(), t(!1)));
211
- }, []), y = L(() => {
212
- const s = o.current, a = l.current;
211
+ }, []), y = S(() => {
212
+ const s = i.current, a = l.current;
213
213
  if (s && a) {
214
214
  try {
215
215
  a.localParticipant.unpublishTrack(s);
@@ -217,85 +217,85 @@ function kn() {
217
217
  }
218
218
  s.stop();
219
219
  }
220
- o.current = null, l.current = null, t(!1);
221
- }, []), b = L(() => i(null), []);
220
+ i.current = null, l.current = null, t(!1);
221
+ }, []), w = S(() => o(null), []);
222
222
  return {
223
223
  isMuted: e,
224
224
  micError: r,
225
225
  toggleMute: u,
226
226
  setMuted: f,
227
- setupMic: c,
227
+ setupMic: d,
228
228
  teardownMic: y,
229
- clearError: b
229
+ clearError: w
230
230
  };
231
231
  }
232
- const Ln = { resolution: { width: 640, height: 480, frameRate: 24 } };
233
- function Sn() {
234
- const [e, t] = S(!1), [r, i] = S(null), [o, l] = S(null), [c, u] = S(""), f = A(null), y = A(null), b = L((w) => {
235
- f.current = w;
236
- }, []), s = L(() => {
237
- const w = f.current, H = y.current;
238
- if (H && w) {
239
- const T = w.localParticipant.getTrackPublication(en.Source.Camera);
240
- if (T != null && T.track) {
232
+ const Cn = { resolution: { width: 640, height: 480, frameRate: 24 } };
233
+ function Nn() {
234
+ const [e, t] = E(!1), [r, o] = E(null), [i, l] = E(null), [d, u] = E(""), f = A(null), y = A(null), w = S((_) => {
235
+ f.current = _;
236
+ }, []), s = S(() => {
237
+ const _ = f.current, O = y.current;
238
+ if (O && _) {
239
+ const $ = _.localParticipant.getTrackPublication(rn.Source.Camera);
240
+ if ($ != null && $.track) {
241
241
  try {
242
- w.localParticipant.unpublishTrack(T.track);
242
+ _.localParticipant.unpublishTrack($.track);
243
243
  } catch {
244
244
  }
245
- T.track.stop();
245
+ $.track.stop();
246
246
  } else
247
- H.stop();
247
+ O.stop();
248
248
  }
249
249
  y.current = null, l(null), t(!1);
250
- }, []), a = L(async (w) => {
251
- const H = f.current;
252
- if (H) {
253
- i(null);
250
+ }, []), a = S(async (_) => {
251
+ const O = f.current;
252
+ if (O) {
253
+ o(null);
254
254
  try {
255
- const T = { ...Ln };
256
- w && (T.deviceId = w);
257
- const q = await bn(T);
258
- await H.localParticipant.publishTrack(q), y.current = q;
259
- const m = q.attach();
260
- l(m), t(!0), w && u(w);
255
+ const $ = { ...Cn };
256
+ _ && ($.deviceId = _);
257
+ const U = await xn($);
258
+ await O.localParticipant.publishTrack(U), y.current = U;
259
+ const m = U.attach();
260
+ l(m), t(!0), _ && u(_);
261
261
  try {
262
- H.localParticipant.publishData(
262
+ O.localParticipant.publishData(
263
263
  new TextEncoder().encode(JSON.stringify({ type: "user_camera_on" })),
264
264
  { reliable: !0 }
265
265
  );
266
266
  } catch {
267
267
  }
268
- } catch (T) {
269
- const q = T instanceof Error && T.name === "NotAllowedError" ? "Enable your camera in the browser to share video." : "Camera unavailable. Check permissions and try again.";
270
- i(q);
268
+ } catch ($) {
269
+ const U = $ instanceof Error && $.name === "NotAllowedError" ? "Enable your camera in the browser to share video." : "Camera unavailable. Check permissions and try again.";
270
+ o(U);
271
271
  }
272
272
  }
273
- }, []), x = L(async () => {
274
- e ? s() : await a(c || void 0);
275
- }, [e, c, s, a]), E = L(async (w) => {
276
- s(), await a(w);
277
- }, [s, a]), C = L(() => {
278
- s(), f.current = null, i(null), u("");
279
- }, [s]), v = L(() => i(null), []);
280
- return N(() => () => {
273
+ }, []), L = S(async () => {
274
+ e ? s() : await a(d || void 0);
275
+ }, [e, d, s, a]), D = S(async (_) => {
276
+ s(), await a(_);
277
+ }, [s, a]), C = S(() => {
278
+ s(), f.current = null, o(null), u("");
279
+ }, [s]), v = S(() => o(null), []);
280
+ return M(() => () => {
281
281
  y.current && y.current.stop();
282
282
  }, []), {
283
283
  isEnabled: e,
284
284
  error: r,
285
- previewEl: o,
286
- activeDeviceId: c,
287
- toggle: x,
288
- switchDevice: E,
289
- attachRoom: b,
285
+ previewEl: i,
286
+ activeDeviceId: d,
287
+ toggle: L,
288
+ switchDevice: D,
289
+ attachRoom: w,
290
290
  teardown: C,
291
291
  clearError: v
292
292
  };
293
293
  }
294
- function Cn() {
295
- const [e, t] = S(!1), [r, i] = S(null), [o, l] = S(null), c = A(null), u = L((a) => {
296
- c.current = a;
297
- }, []), f = L(() => l(null), []), y = L(async () => {
298
- const a = c.current;
294
+ function An() {
295
+ const [e, t] = E(!1), [r, o] = E(null), [i, l] = E(null), d = A(null), u = S((a) => {
296
+ d.current = a;
297
+ }, []), f = S(() => l(null), []), y = S(async () => {
298
+ const a = d.current;
299
299
  if (a) {
300
300
  if (e) {
301
301
  try {
@@ -305,12 +305,12 @@ function Cn() {
305
305
  f(), t(!1);
306
306
  return;
307
307
  }
308
- i(null);
308
+ o(null);
309
309
  try {
310
310
  await a.localParticipant.setScreenShareEnabled(!0);
311
- let x = 0;
312
- const E = () => {
313
- const C = a.localParticipant.getTrackPublication(en.Source.ScreenShare);
311
+ let L = 0;
312
+ const D = () => {
313
+ const C = a.localParticipant.getTrackPublication(rn.Source.ScreenShare);
314
314
  if (C != null && C.track) {
315
315
  const v = C.track.attach();
316
316
  l(v), t(!0);
@@ -323,49 +323,49 @@ function Cn() {
323
323
  }
324
324
  return;
325
325
  }
326
- x++ < 10 ? setTimeout(E, 100) : t(!0);
326
+ L++ < 10 ? setTimeout(D, 100) : t(!0);
327
327
  };
328
- E();
329
- } catch (x) {
330
- const E = x instanceof Error ? x.name : "";
331
- E !== "NotAllowedError" && E !== "AbortError" && i("Screen share unavailable. Try again."), t(!1);
328
+ D();
329
+ } catch (L) {
330
+ const D = L instanceof Error ? L.name : "";
331
+ D !== "NotAllowedError" && D !== "AbortError" && o("Screen share unavailable. Try again."), t(!1);
332
332
  }
333
333
  }
334
- }, [e, f]), b = L(() => {
335
- const a = c.current;
334
+ }, [e, f]), w = S(() => {
335
+ const a = d.current;
336
336
  if (a && e)
337
337
  try {
338
338
  a.localParticipant.setScreenShareEnabled(!1);
339
339
  } catch {
340
340
  }
341
- f(), t(!1), i(null), c.current = null;
342
- }, [e, f]), s = L(() => i(null), []);
343
- return { isEnabled: e, error: r, previewEl: o, toggle: y, attachRoom: u, teardown: b, clearError: s };
341
+ f(), t(!1), o(null), d.current = null;
342
+ }, [e, f]), s = S(() => o(null), []);
343
+ return { isEnabled: e, error: r, previewEl: i, toggle: y, attachRoom: u, teardown: w, clearError: s };
344
344
  }
345
- function En() {
346
- const [e, t] = S([]), [r, i] = S([]), o = L(async () => {
345
+ function Dn() {
346
+ const [e, t] = E([]), [r, o] = E([]), i = S(async () => {
347
347
  if (!(typeof navigator > "u" || !navigator.mediaDevices))
348
348
  try {
349
349
  const l = await navigator.mediaDevices.enumerateDevices();
350
- t(l.filter((c) => c.kind === "audioinput")), i(l.filter((c) => c.kind === "videoinput"));
350
+ t(l.filter((d) => d.kind === "audioinput")), o(l.filter((d) => d.kind === "videoinput"));
351
351
  } catch {
352
352
  }
353
353
  }, []);
354
- return N(() => {
355
- if (o(), typeof navigator > "u" || !navigator.mediaDevices) return;
356
- const l = () => void o();
354
+ return M(() => {
355
+ if (i(), typeof navigator > "u" || !navigator.mediaDevices) return;
356
+ const l = () => void i();
357
357
  return navigator.mediaDevices.addEventListener("devicechange", l), () => navigator.mediaDevices.removeEventListener("devicechange", l);
358
- }, [o]), { mics: e, cameras: r, refresh: o };
358
+ }, [i]), { mics: e, cameras: r, refresh: i };
359
359
  }
360
- function Nn(e, t, r = !1) {
361
- const [i, o] = S(null), [l, c] = S(null), [u, f] = S(!r && !!e);
362
- return N(() => {
360
+ function Rn(e, t, r = !1) {
361
+ const [o, i] = E(null), [l, d] = E(null), [u, f] = E(!r && !!e);
362
+ return M(() => {
363
363
  if (r || !e) {
364
364
  f(!1);
365
365
  return;
366
366
  }
367
- const y = new AbortController(), b = t || "https://app.livelayer.studio";
368
- return f(!0), c(null), fetch(`${b}/api/widget/agent/${encodeURIComponent(e)}`, {
367
+ const y = new AbortController(), w = t || "https://app.livelayer.studio";
368
+ return f(!0), d(null), fetch(`${w}/api/widget/agent/${encodeURIComponent(e)}`, {
369
369
  signal: y.signal
370
370
  }).then(async (s) => {
371
371
  if (!s.ok) {
@@ -374,13 +374,13 @@ function Nn(e, t, r = !1) {
374
374
  }
375
375
  return s.json();
376
376
  }).then((s) => {
377
- y.signal.aborted || (o(s), f(!1));
377
+ y.signal.aborted || (i(s), f(!1));
378
378
  }).catch((s) => {
379
- y.signal.aborted || (c(s instanceof Error ? s.message : "Agent lookup failed"), f(!1));
379
+ y.signal.aborted || (d(s instanceof Error ? s.message : "Agent lookup failed"), f(!1));
380
380
  }), () => y.abort();
381
- }, [e, t, r]), { info: i, error: l, loading: u };
381
+ }, [e, t, r]), { info: o, error: l, loading: u };
382
382
  }
383
- function An(e) {
383
+ function Mn(e) {
384
384
  if (typeof window > "u") return null;
385
385
  try {
386
386
  return window.localStorage.getItem(e);
@@ -388,127 +388,127 @@ function An(e) {
388
388
  return null;
389
389
  }
390
390
  }
391
- function Rn(e, t) {
391
+ function Tn(e, t) {
392
392
  if (!(typeof window > "u"))
393
393
  try {
394
394
  window.localStorage.setItem(e, t);
395
395
  } catch {
396
396
  }
397
397
  }
398
- function Mn({
398
+ function In({
399
399
  value: e,
400
400
  defaultValue: t = "expanded",
401
401
  onChange: r
402
402
  } = {}) {
403
- const i = e !== void 0, [o, l] = S(t), c = i ? e : o, u = L(
403
+ const o = e !== void 0, [i, l] = E(t), d = o ? e : i, u = S(
404
404
  (f) => {
405
- f !== c && (i || l(f), r == null || r(f));
405
+ f !== d && (o || l(f), r == null || r(f));
406
406
  },
407
- [c, i, r]
407
+ [d, o, r]
408
408
  );
409
- return [c, u];
409
+ return [d, u];
410
410
  }
411
- const In = ["hidden", "minimized", "expanded"];
412
- function Tn(e) {
413
- return e && In.includes(e) ? e : null;
411
+ const Pn = ["hidden", "minimized", "expanded"];
412
+ function $n(e) {
413
+ return e && Pn.includes(e) ? e : null;
414
414
  }
415
- function Dn({
415
+ function Bn({
416
416
  value: e,
417
417
  defaultValue: t = "expanded",
418
418
  onChange: r,
419
- persistKey: i = "ll-widget",
420
- disablePersistence: o = !1
419
+ persistKey: o = "ll-widget",
420
+ disablePersistence: i = !1
421
421
  } = {}) {
422
- const l = `${i}:display-mode`, c = A(!1), [u, f] = Mn({
422
+ const l = `${o}:display-mode`, d = A(!1), [u, f] = In({
423
423
  value: e,
424
424
  defaultValue: t,
425
425
  onChange: (y) => {
426
- e === void 0 && !o && Rn(l, y), r == null || r(y);
426
+ e === void 0 && !i && Tn(l, y), r == null || r(y);
427
427
  }
428
428
  });
429
- return N(() => {
430
- if (c.current || (c.current = !0, o || e !== void 0)) return;
431
- const y = Tn(An(l));
429
+ return M(() => {
430
+ if (d.current || (d.current = !0, i || e !== void 0)) return;
431
+ const y = $n(Mn(l));
432
432
  y && y !== u && f(y);
433
433
  }, []), [u, f];
434
434
  }
435
- const Pn = 640;
436
- function $n(e = Pn) {
437
- const [t, r] = S(!1);
438
- return N(() => {
435
+ const zn = 640;
436
+ function On(e = zn) {
437
+ const [t, r] = E(!1);
438
+ return M(() => {
439
439
  if (e === !1) {
440
440
  r(!1);
441
441
  return;
442
442
  }
443
443
  if (typeof window > "u" || typeof window.matchMedia > "u")
444
444
  return;
445
- const i = `(max-width: ${e - 1}px)`, o = window.matchMedia(i), l = () => r(o.matches);
446
- return l(), typeof o.addEventListener == "function" ? (o.addEventListener("change", l), () => o.removeEventListener("change", l)) : (o.addListener(l), () => {
447
- o.removeListener(l);
445
+ const o = `(max-width: ${e - 1}px)`, i = window.matchMedia(o), l = () => r(i.matches);
446
+ return l(), typeof i.addEventListener == "function" ? (i.addEventListener("change", l), () => i.removeEventListener("change", l)) : (i.addListener(l), () => {
447
+ i.removeListener(l);
448
448
  });
449
449
  }, [e]), t;
450
450
  }
451
- const Ot = "__llHistoryPatched", ft = "ll:pathname";
452
- function zn() {
453
- if (typeof window > "u" || window.history[Ot]) return;
451
+ const Ht = "__llHistoryPatched", yt = "ll:pathname";
452
+ function Un() {
453
+ if (typeof window > "u" || window.history[Ht]) return;
454
454
  const e = window.history.pushState, t = window.history.replaceState;
455
455
  window.history.pushState = function(...r) {
456
- const i = e.apply(this, r);
457
- return window.dispatchEvent(new Event(ft)), i;
456
+ const o = e.apply(this, r);
457
+ return window.dispatchEvent(new Event(yt)), o;
458
458
  }, window.history.replaceState = function(...r) {
459
- const i = t.apply(this, r);
460
- return window.dispatchEvent(new Event(ft)), i;
461
- }, window.history[Ot] = !0;
459
+ const o = t.apply(this, r);
460
+ return window.dispatchEvent(new Event(yt)), o;
461
+ }, window.history[Ht] = !0;
462
462
  }
463
- function Ht() {
463
+ function Vt() {
464
464
  return typeof window > "u" ? "/" : window.location.pathname || "/";
465
465
  }
466
- function On(e) {
467
- const [t, r] = S(
468
- () => e ?? Ht()
466
+ function Hn(e) {
467
+ const [t, r] = E(
468
+ () => e ?? Vt()
469
469
  );
470
- return N(() => {
470
+ return M(() => {
471
471
  if (e !== void 0) return;
472
- zn();
473
- const i = () => r(Ht());
474
- return i(), window.addEventListener("popstate", i), window.addEventListener(ft, i), () => {
475
- window.removeEventListener("popstate", i), window.removeEventListener(ft, i);
472
+ Un();
473
+ const o = () => r(Vt());
474
+ return o(), window.addEventListener("popstate", o), window.addEventListener(yt, o), () => {
475
+ window.removeEventListener("popstate", o), window.removeEventListener(yt, o);
476
476
  };
477
477
  }, [e]), e ?? t;
478
478
  }
479
- const qt = /* @__PURE__ */ new Map(), Hn = /[\\^$+?.()|{}[\]]/g;
479
+ const qt = /* @__PURE__ */ new Map(), Vn = /[\\^$+?.()|{}[\]]/g;
480
480
  function qn(e) {
481
- return e.replace(Hn, "\\$&");
481
+ return e.replace(Vn, "\\$&");
482
482
  }
483
- function Bn(e) {
483
+ function Wn(e) {
484
484
  const t = qt.get(e);
485
485
  if (t) return t;
486
- const r = e.length > 1 && e.endsWith("/") ? e.slice(0, -1) : e, i = "", o = "", l = r.replace(/\*\*/g, i).replace(/\*/g, o), u = qn(l).replace(new RegExp(`\\/${i}`, "g"), "(?:\\/.*)?").replace(new RegExp(i, "g"), ".*").replace(new RegExp(o, "g"), "[^/]+"), f = new RegExp(`^${u}\\/?$`);
486
+ const r = e.length > 1 && e.endsWith("/") ? e.slice(0, -1) : e, o = "", i = "", l = r.replace(/\*\*/g, o).replace(/\*/g, i), u = qn(l).replace(new RegExp(`\\/${o}`, "g"), "(?:\\/.*)?").replace(new RegExp(o, "g"), ".*").replace(new RegExp(i, "g"), "[^/]+"), f = new RegExp(`^${u}\\/?$`);
487
487
  return qt.set(e, f), f;
488
488
  }
489
- function Wn(e, t) {
489
+ function Gn(e, t) {
490
490
  const r = t.length > 1 && t.endsWith("/") ? t.slice(0, -1) : t;
491
- return Bn(e).test(r);
491
+ return Wn(e).test(r);
492
492
  }
493
493
  function Fn(e, t) {
494
- return typeof e == "function" ? e(t) : e instanceof RegExp ? e.test(t) : Wn(e, t);
494
+ return typeof e == "function" ? e(t) : e instanceof RegExp ? e.test(t) : Gn(e, t);
495
495
  }
496
- function Bt(e, t) {
496
+ function Wt(e, t) {
497
497
  if (!e || e.length === 0) return !1;
498
498
  for (const r of e)
499
499
  if (Fn(r, t)) return !0;
500
500
  return !1;
501
501
  }
502
- function Un(e, t, r) {
503
- return e === void 0 ? !0 : Bt(r, e) ? !1 : t && t.length > 0 ? Bt(t, e) : !0;
504
- }
505
502
  function jn(e, t, r) {
506
- return ut(
507
- () => Un(e, t, r),
503
+ return e === void 0 ? !0 : Wt(r, e) ? !1 : t && t.length > 0 ? Wt(t, e) : !0;
504
+ }
505
+ function Jn(e, t, r) {
506
+ return gt(
507
+ () => jn(e, t, r),
508
508
  [e, t, r]
509
509
  );
510
510
  }
511
- const Wt = ({ muted: e = !1, className: t }) => e ? /* @__PURE__ */ _(
511
+ const Gt = ({ muted: e = !1, className: t }) => e ? /* @__PURE__ */ x(
512
512
  "svg",
513
513
  {
514
514
  className: t,
@@ -572,7 +572,7 @@ const Wt = ({ muted: e = !1, className: t }) => e ? /* @__PURE__ */ _(
572
572
  }
573
573
  )
574
574
  }
575
- ), Vn = ({ className: e }) => /* @__PURE__ */ n(
575
+ ), Yn = ({ className: e }) => /* @__PURE__ */ n(
576
576
  "svg",
577
577
  {
578
578
  className: e,
@@ -583,12 +583,12 @@ const Wt = ({ muted: e = !1, className: t }) => e ? /* @__PURE__ */ _(
583
583
  "aria-hidden": "true",
584
584
  children: /* @__PURE__ */ n("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M6 18L18 6M6 6l12 12" })
585
585
  }
586
- ), Yn = {
586
+ ), Kn = {
587
587
  left: 180,
588
588
  right: 0,
589
589
  up: -90,
590
590
  down: 90
591
- }, Ut = ({ direction: e = "right", className: t }) => /* @__PURE__ */ n(
591
+ }, jt = ({ direction: e = "right", className: t }) => /* @__PURE__ */ n(
592
592
  "svg",
593
593
  {
594
594
  className: t,
@@ -596,19 +596,19 @@ const Wt = ({ muted: e = !1, className: t }) => e ? /* @__PURE__ */ _(
596
596
  viewBox: "0 0 24 24",
597
597
  stroke: "currentColor",
598
598
  strokeWidth: 2,
599
- style: { transform: `rotate(${Yn[e]}deg)` },
599
+ style: { transform: `rotate(${Kn[e]}deg)` },
600
600
  "aria-hidden": "true",
601
601
  children: /* @__PURE__ */ n("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M9 6l6 6-6 6" })
602
602
  }
603
603
  );
604
- function Jn(e) {
604
+ function Xn(e) {
605
605
  return e === "top-left" || e === "bottom-left" ? "left" : "right";
606
606
  }
607
- const tn = "ll-hidden-tab-center-y", Kn = 5, jt = 16;
608
- function Xn() {
607
+ const on = "ll-hidden-tab-center-y", Qn = 5, Jt = 16;
608
+ function Zn() {
609
609
  if (typeof window > "u") return null;
610
610
  try {
611
- const e = window.localStorage.getItem(tn);
611
+ const e = window.localStorage.getItem(on);
612
612
  if (!e) return null;
613
613
  const t = Number.parseFloat(e);
614
614
  return Number.isFinite(t) ? t : null;
@@ -616,122 +616,122 @@ function Xn() {
616
616
  return null;
617
617
  }
618
618
  }
619
- function Vt(e) {
619
+ function Yt(e) {
620
620
  if (!(typeof window > "u"))
621
621
  try {
622
- window.localStorage.setItem(tn, String(e));
622
+ window.localStorage.setItem(on, String(e));
623
623
  } catch {
624
624
  }
625
625
  }
626
- const Gn = ({
626
+ const er = ({
627
627
  position: e,
628
628
  isMobile: t,
629
629
  isSpeaking: r,
630
- onExpand: i,
631
- label: o = "Open widget",
630
+ onExpand: o,
631
+ label: i = "Open widget",
632
632
  avatarImageUrl: l,
633
- agentName: c
633
+ agentName: d
634
634
  }) => {
635
- const u = Jn(e), f = u === "right" ? "left" : "right", y = t ? 80 : 72, b = !!l, [s, a] = S(null), [x, E] = S(!1), C = A(null), v = A(!1), w = L(
636
- (M) => {
637
- if (typeof window > "u") return M;
638
- const B = y / 2, F = jt + B, G = window.innerHeight - jt - B;
639
- return G < F ? Math.max(F, M) : Math.max(F, Math.min(G, M));
635
+ const u = Xn(e), f = u === "right" ? "left" : "right", y = t ? 80 : 72, w = !!l, [s, a] = E(null), [L, D] = E(!1), C = A(null), v = A(!1), _ = S(
636
+ (P) => {
637
+ if (typeof window > "u") return P;
638
+ const H = y / 2, G = Jt + H, Z = window.innerHeight - Jt - H;
639
+ return Z < G ? Math.max(G, P) : Math.max(G, Math.min(Z, P));
640
640
  },
641
641
  [y]
642
642
  );
643
- N(() => {
644
- const M = Xn();
645
- a(w(M ?? window.innerHeight / 2));
646
- const B = () => {
647
- a((F) => F === null ? null : w(F));
643
+ M(() => {
644
+ const P = Zn();
645
+ a(_(P ?? window.innerHeight / 2));
646
+ const H = () => {
647
+ a((G) => G === null ? null : _(G));
648
648
  };
649
- return window.addEventListener("resize", B), () => window.removeEventListener("resize", B);
650
- }, [w]);
651
- const H = L(
652
- (M) => {
653
- if (!(M.pointerType === "mouse" && M.button !== 0) && s !== null) {
649
+ return window.addEventListener("resize", H), () => window.removeEventListener("resize", H);
650
+ }, [_]);
651
+ const O = S(
652
+ (P) => {
653
+ if (!(P.pointerType === "mouse" && P.button !== 0) && s !== null) {
654
654
  try {
655
- M.currentTarget.setPointerCapture(M.pointerId);
655
+ P.currentTarget.setPointerCapture(P.pointerId);
656
656
  } catch {
657
657
  }
658
658
  C.current = {
659
- startClientY: M.clientY,
659
+ startClientY: P.clientY,
660
660
  startCenterY: s,
661
661
  moved: !1
662
662
  };
663
663
  }
664
664
  },
665
665
  [s]
666
- ), T = L(
667
- (M) => {
668
- const B = C.current;
669
- if (!B) return;
670
- const F = M.clientY - B.startClientY;
671
- !B.moved && Math.abs(F) > Kn && (B.moved = !0, E(!0)), B.moved && a(w(B.startCenterY + F));
666
+ ), $ = S(
667
+ (P) => {
668
+ const H = C.current;
669
+ if (!H) return;
670
+ const G = P.clientY - H.startClientY;
671
+ !H.moved && Math.abs(G) > Qn && (H.moved = !0, D(!0)), H.moved && a(_(H.startCenterY + G));
672
672
  },
673
- [w]
674
- ), q = L(
675
- (M) => {
676
- const B = C.current;
677
- if (B) {
673
+ [_]
674
+ ), U = S(
675
+ (P) => {
676
+ const H = C.current;
677
+ if (H) {
678
678
  try {
679
- M.currentTarget.releasePointerCapture(M.pointerId);
679
+ P.currentTarget.releasePointerCapture(P.pointerId);
680
680
  } catch {
681
681
  }
682
- C.current = null, B.moved && (E(!1), v.current = !0, a((F) => (F !== null && Vt(F), F)));
682
+ C.current = null, H.moved && (D(!1), v.current = !0, a((G) => (G !== null && Yt(G), G)));
683
683
  }
684
684
  },
685
685
  []
686
- ), m = L(() => {
686
+ ), m = S(() => {
687
687
  if (v.current) {
688
688
  v.current = !1;
689
689
  return;
690
690
  }
691
- i();
692
- }, [i]), R = L(
693
- (M) => {
694
- if (M.key === "ArrowUp" || M.key === "ArrowDown") {
695
- M.preventDefault();
696
- const B = M.key === "ArrowUp" ? -8 : 8;
697
- a((F) => {
698
- if (F === null) return F;
699
- const G = w(F + B);
700
- return Vt(G), G;
691
+ o();
692
+ }, [o]), I = S(
693
+ (P) => {
694
+ if (P.key === "ArrowUp" || P.key === "ArrowDown") {
695
+ P.preventDefault();
696
+ const H = P.key === "ArrowUp" ? -8 : 8;
697
+ a((G) => {
698
+ if (G === null) return G;
699
+ const Z = _(G + H);
700
+ return Yt(Z), Z;
701
701
  });
702
702
  }
703
703
  },
704
- [w]
705
- ), W = [
704
+ [_]
705
+ ), q = [
706
706
  "ll-hidden",
707
707
  `ll-hidden--${u}`,
708
708
  t ? "ll-hidden--mobile" : "ll-hidden--desktop",
709
709
  r ? "ll-hidden--speaking" : null,
710
- x ? "is-dragging" : null,
711
- b ? "ll-hidden--with-avatar" : null
712
- ].filter(Boolean).join(" "), z = s === null ? void 0 : { top: `${s - y / 2}px`, transform: "none" };
710
+ L ? "is-dragging" : null,
711
+ w ? "ll-hidden--with-avatar" : null
712
+ ].filter(Boolean).join(" "), B = s === null ? void 0 : { top: `${s - y / 2}px`, transform: "none" };
713
713
  return /* @__PURE__ */ n(
714
714
  "button",
715
715
  {
716
716
  type: "button",
717
- className: W,
718
- onPointerDown: H,
719
- onPointerMove: T,
720
- onPointerUp: q,
721
- onPointerCancel: q,
717
+ className: q,
718
+ onPointerDown: O,
719
+ onPointerMove: $,
720
+ onPointerUp: U,
721
+ onPointerCancel: U,
722
722
  onClick: m,
723
- onKeyDown: R,
724
- "aria-label": o,
723
+ onKeyDown: I,
724
+ "aria-label": i,
725
725
  "data-position": e,
726
- style: z,
727
- children: b ? (
726
+ style: B,
727
+ children: w ? (
728
728
  // Layout: tiny chevron flush against the inward edge (peeks out
729
729
  // as the click affordance), then the circular avatar photo
730
730
  // taking the rest of the tab. Reinforces "this is an
731
731
  // avatar-based experience" even when collapsed.
732
- /* @__PURE__ */ _(St, { children: [
732
+ /* @__PURE__ */ x(Ct, { children: [
733
733
  /* @__PURE__ */ n(
734
- Ut,
734
+ jt,
735
735
  {
736
736
  direction: f,
737
737
  className: "ll-hidden__chevron ll-hidden__chevron--mini"
@@ -741,14 +741,14 @@ const Gn = ({
741
741
  "img",
742
742
  {
743
743
  src: l,
744
- alt: c ? `${c} avatar` : "Agent avatar",
744
+ alt: d ? `${d} avatar` : "Agent avatar",
745
745
  className: "ll-hidden__avatar",
746
746
  draggable: !1
747
747
  }
748
748
  )
749
749
  ] })
750
750
  ) : /* @__PURE__ */ n(
751
- Ut,
751
+ jt,
752
752
  {
753
753
  direction: f,
754
754
  className: "ll-hidden__chevron"
@@ -756,46 +756,46 @@ const Gn = ({
756
756
  )
757
757
  }
758
758
  );
759
- }, Qn = ({
759
+ }, tr = ({
760
760
  audioLevel: e,
761
761
  bars: t = 20,
762
762
  maxHeight: r = 20,
763
- minHeight: i = 4,
764
- className: o,
763
+ minHeight: o = 4,
764
+ className: i,
765
765
  barClassName: l
766
766
  }) => {
767
- const c = A(null), u = A([]), f = ut(() => {
768
- const b = (Math.sqrt(5) - 1) / 2;
769
- return Array.from({ length: t }, (s, a) => 0.5 + a * b % 1 * 0.5);
767
+ const d = A(null), u = A([]), f = gt(() => {
768
+ const w = (Math.sqrt(5) - 1) / 2;
769
+ return Array.from({ length: t }, (s, a) => 0.5 + a * w % 1 * 0.5);
770
770
  }, [t]);
771
- N(() => e.subscribe((s) => {
771
+ M(() => e.subscribe((s) => {
772
772
  for (let a = 0; a < t; a++) {
773
- const x = u.current[a];
774
- if (!x) continue;
775
- const E = Math.max(i, s * r * f[a]);
776
- x.style.height = `${E}px`;
773
+ const L = u.current[a];
774
+ if (!L) continue;
775
+ const D = Math.max(o, s * r * f[a]);
776
+ L.style.height = `${D}px`;
777
777
  }
778
- }), [e, t, r, i, f]);
779
- const y = ["ll-waveform", o].filter(Boolean).join(" ");
780
- return /* @__PURE__ */ n("div", { ref: c, className: y, "aria-hidden": "true", children: Array.from({ length: t }, (b, s) => /* @__PURE__ */ n(
778
+ }), [e, t, r, o, f]);
779
+ const y = ["ll-waveform", i].filter(Boolean).join(" ");
780
+ return /* @__PURE__ */ n("div", { ref: d, className: y, "aria-hidden": "true", children: Array.from({ length: t }, (w, s) => /* @__PURE__ */ n(
781
781
  "div",
782
782
  {
783
783
  ref: (a) => {
784
784
  u.current[s] = a;
785
785
  },
786
786
  className: ["ll-waveform__bar", l].filter(Boolean).join(" "),
787
- style: { height: `${i}px` }
787
+ style: { height: `${o}px` }
788
788
  },
789
789
  s
790
790
  )) });
791
- }, Zn = ({
791
+ }, nr = ({
792
792
  position: e,
793
793
  isMobile: t,
794
794
  agentName: r,
795
- avatarImageUrl: i,
796
- agentState: o,
795
+ avatarImageUrl: o,
796
+ agentState: i,
797
797
  isMuted: l,
798
- audioLevel: c,
798
+ audioLevel: d,
799
799
  onExpand: u,
800
800
  onToggleMute: f,
801
801
  onClose: y
@@ -805,7 +805,7 @@ const Gn = ({
805
805
  className: "ll-minimized ll-minimized--mobile",
806
806
  role: "region",
807
807
  "aria-label": `${r} widget`,
808
- children: /* @__PURE__ */ _(
808
+ children: /* @__PURE__ */ x(
809
809
  "button",
810
810
  {
811
811
  type: "button",
@@ -813,42 +813,42 @@ const Gn = ({
813
813
  onClick: u,
814
814
  "aria-label": `Expand ${r} widget`,
815
815
  children: [
816
- i ? (
816
+ o ? (
817
817
  // eslint-disable-next-line @next/next/no-img-element
818
818
  /* @__PURE__ */ n(
819
819
  "img",
820
820
  {
821
- src: i,
821
+ src: o,
822
822
  alt: r,
823
823
  className: "ll-minimized__avatar"
824
824
  }
825
825
  )
826
826
  ) : /* @__PURE__ */ n("div", { className: "ll-minimized__avatar ll-minimized__avatar--placeholder" }),
827
827
  /* @__PURE__ */ n(
828
- Qn,
828
+ tr,
829
829
  {
830
- audioLevel: c,
830
+ audioLevel: d,
831
831
  bars: 16,
832
832
  maxHeight: 18,
833
833
  className: "ll-minimized__waveform"
834
834
  }
835
835
  ),
836
836
  /* @__PURE__ */ n("span", { className: "ll-minimized__name", children: r }),
837
- /* @__PURE__ */ _("div", { className: "ll-minimized__controls", children: [
837
+ /* @__PURE__ */ x("div", { className: "ll-minimized__controls", children: [
838
838
  /* @__PURE__ */ n(
839
839
  "span",
840
840
  {
841
841
  className: "ll-minimized__btn",
842
842
  role: "button",
843
843
  tabIndex: 0,
844
- onClick: (b) => {
845
- b.stopPropagation(), f();
844
+ onClick: (w) => {
845
+ w.stopPropagation(), f();
846
846
  },
847
- onKeyDown: (b) => {
848
- (b.key === "Enter" || b.key === " ") && (b.stopPropagation(), b.preventDefault(), f());
847
+ onKeyDown: (w) => {
848
+ (w.key === "Enter" || w.key === " ") && (w.stopPropagation(), w.preventDefault(), f());
849
849
  },
850
850
  "aria-label": l ? "Unmute microphone" : "Mute microphone",
851
- children: /* @__PURE__ */ n(Wt, { muted: l, className: "ll-minimized__icon" })
851
+ children: /* @__PURE__ */ n(Gt, { muted: l, className: "ll-minimized__icon" })
852
852
  }
853
853
  ),
854
854
  /* @__PURE__ */ n(Ft, { className: "ll-minimized__icon ll-minimized__icon--expand" })
@@ -864,23 +864,23 @@ const Gn = ({
864
864
  "data-position": e,
865
865
  role: "region",
866
866
  "aria-label": `${r} widget`,
867
- children: /* @__PURE__ */ _("div", { className: "ll-minimized__surface", children: [
868
- i ? (
867
+ children: /* @__PURE__ */ x("div", { className: "ll-minimized__surface", children: [
868
+ o ? (
869
869
  // eslint-disable-next-line @next/next/no-img-element
870
870
  /* @__PURE__ */ n(
871
871
  "img",
872
872
  {
873
- src: i,
873
+ src: o,
874
874
  alt: r,
875
875
  className: "ll-minimized__avatar"
876
876
  }
877
877
  )
878
878
  ) : /* @__PURE__ */ n("div", { className: "ll-minimized__avatar ll-minimized__avatar--placeholder" }),
879
- /* @__PURE__ */ _("div", { className: "ll-minimized__meta", children: [
879
+ /* @__PURE__ */ x("div", { className: "ll-minimized__meta", children: [
880
880
  /* @__PURE__ */ n("span", { className: "ll-minimized__name", children: r }),
881
- /* @__PURE__ */ n("span", { className: "ll-minimized__state", children: o === "speaking" ? "Speaking" : o === "thinking" ? "Thinking" : "Listening" })
881
+ /* @__PURE__ */ n("span", { className: "ll-minimized__state", children: i === "speaking" ? "Speaking" : i === "thinking" ? "Thinking" : "Listening" })
882
882
  ] }),
883
- /* @__PURE__ */ _("div", { className: "ll-minimized__controls", children: [
883
+ /* @__PURE__ */ x("div", { className: "ll-minimized__controls", children: [
884
884
  /* @__PURE__ */ n(
885
885
  "button",
886
886
  {
@@ -888,7 +888,7 @@ const Gn = ({
888
888
  className: "ll-minimized__btn",
889
889
  onClick: f,
890
890
  "aria-label": l ? "Unmute microphone" : "Mute microphone",
891
- children: /* @__PURE__ */ n(Wt, { muted: l, className: "ll-minimized__icon" })
891
+ children: /* @__PURE__ */ n(Gt, { muted: l, className: "ll-minimized__icon" })
892
892
  }
893
893
  ),
894
894
  /* @__PURE__ */ n(
@@ -908,22 +908,22 @@ const Gn = ({
908
908
  className: "ll-minimized__btn ll-minimized__btn--close",
909
909
  onClick: y,
910
910
  "aria-label": "Close widget",
911
- children: /* @__PURE__ */ n(Vn, { className: "ll-minimized__icon" })
911
+ children: /* @__PURE__ */ n(Yn, { className: "ll-minimized__icon" })
912
912
  }
913
913
  )
914
914
  ] })
915
915
  ] })
916
916
  }
917
- ), er = ({
917
+ ), rr = ({
918
918
  src: e,
919
919
  alt: t,
920
920
  preCannedPlaying: r = !1,
921
- className: i,
922
- style: o
921
+ className: o,
922
+ style: i
923
923
  }) => {
924
- const [l, c] = S(!1), u = A(e);
925
- if (N(() => {
926
- u.current !== e && (u.current = e, c(!1));
924
+ const [l, d] = E(!1), u = A(e);
925
+ if (M(() => {
926
+ u.current !== e && (u.current = e, d(!1));
927
927
  }, [e]), !e) return null;
928
928
  const f = {
929
929
  position: "absolute",
@@ -935,7 +935,7 @@ const Gn = ({
935
935
  transition: "opacity 500ms ease, transform 500ms ease",
936
936
  transform: r ? "scale(1.02)" : "scale(1)",
937
937
  opacity: l ? 1 : 0,
938
- ...o
938
+ ...i
939
939
  };
940
940
  return (
941
941
  // eslint-disable-next-line @next/next/no-img-element
@@ -944,156 +944,156 @@ const Gn = ({
944
944
  {
945
945
  src: e,
946
946
  alt: t,
947
- className: i,
947
+ className: o,
948
948
  style: f,
949
949
  loading: "eager",
950
950
  fetchPriority: "high",
951
- onLoad: () => c(!0)
951
+ onLoad: () => d(!0)
952
952
  }
953
953
  )
954
954
  );
955
- }, tr = ({
955
+ }, or = ({
956
956
  position: e,
957
957
  isMobile: t,
958
958
  agentName: r,
959
- avatarImageUrl: i,
960
- idleLoopUrl: o,
959
+ avatarImageUrl: o,
960
+ idleLoopUrl: i,
961
961
  greeting: l,
962
- branding: c,
962
+ branding: d,
963
963
  teamMembers: u,
964
964
  currentTeamMemberId: f,
965
965
  isSwitchingTeamMember: y,
966
- teamSwitcherOpen: b,
966
+ teamSwitcherOpen: w,
967
967
  onToggleTeamSwitcher: s,
968
968
  onSelectTeamMember: a,
969
- languageMenuOpen: x,
970
- onToggleLanguageMenu: E,
969
+ languageMenuOpen: L,
970
+ onToggleLanguageMenu: D,
971
971
  connectionState: C,
972
972
  agentState: v,
973
- transcript: w,
974
- canResume: H,
975
- needsUserGesture: T,
976
- error: q,
973
+ transcript: _,
974
+ canResume: O,
975
+ needsUserGesture: $,
976
+ error: U,
977
977
  isMuted: m,
978
- micError: R,
979
- micDevices: W,
980
- isCameraEnabled: z,
981
- cameraPreviewEl: M,
982
- cameraDevices: B,
983
- activeCameraId: F,
984
- isScreenShareEnabled: G,
985
- screenPreviewEl: ie,
986
- isSpeakerMuted: _e,
987
- allowCamera: tt,
988
- allowScreenShare: nt,
989
- allowTyping: rt,
990
- avatarVideoContainerRef: it,
991
- agentVideoEl: re,
992
- micGateOpen: ce,
993
- onConnect: xe,
994
- onDisconnect: Ne,
995
- onRetry: Ae,
996
- onResumeAudio: Re,
997
- onToggleMute: Me,
978
+ micError: I,
979
+ micDevices: q,
980
+ isCameraEnabled: B,
981
+ cameraPreviewEl: P,
982
+ cameraDevices: H,
983
+ activeCameraId: G,
984
+ isScreenShareEnabled: Z,
985
+ screenPreviewEl: le,
986
+ isSpeakerMuted: Le,
987
+ allowCamera: rt,
988
+ allowScreenShare: ot,
989
+ allowTyping: it,
990
+ avatarVideoContainerRef: lt,
991
+ agentVideoEl: ie,
992
+ micGateOpen: pe,
993
+ onConnect: Se,
994
+ onDisconnect: De,
995
+ onRetry: Re,
996
+ onResumeAudio: Me,
997
+ onToggleMute: Te,
998
998
  onToggleCamera: Ie,
999
- onSwitchCameraDevice: J,
1000
- onToggleScreenShare: ht,
1001
- onToggleSpeaker: mt,
1002
- onSendMessage: ot,
1003
- onMinimize: de,
1004
- onClose: Te,
1005
- onClearMicError: Fe
999
+ onSwitchCameraDevice: Y,
1000
+ onToggleScreenShare: vt,
1001
+ onToggleSpeaker: wt,
1002
+ onSendMessage: at,
1003
+ onMinimize: ae,
1004
+ onClose: Pe,
1005
+ onClearMicError: We
1006
1006
  }) => {
1007
- var Oe;
1008
- const ke = ((u == null ? void 0 : u.length) ?? 0) > 1, De = C === "connecting" || C === "connected", X = C === "connected", ee = C === "idle" || C === "disconnected" || C === "error", [Pe, oe] = S(!1);
1009
- N(() => {
1010
- if (!re) {
1011
- oe(!1);
1007
+ var Ue;
1008
+ const Ee = ((u == null ? void 0 : u.length) ?? 0) > 1, $e = C === "connecting" || C === "connected", Q = C === "connected", ne = C === "idle" || C === "disconnected" || C === "error", [Be, se] = E(!1);
1009
+ M(() => {
1010
+ if (!ie) {
1011
+ se(!1);
1012
1012
  return;
1013
1013
  }
1014
- if (!re.paused && re.readyState >= 2) {
1015
- oe(!0);
1014
+ if (!ie.paused && ie.readyState >= 2) {
1015
+ se(!0);
1016
1016
  return;
1017
1017
  }
1018
- oe(!1);
1019
- const p = () => oe(!0);
1020
- return re.addEventListener("playing", p), re.addEventListener("loadeddata", p), () => {
1021
- re.removeEventListener("playing", p), re.removeEventListener("loadeddata", p);
1018
+ se(!1);
1019
+ const p = () => se(!0);
1020
+ return ie.addEventListener("playing", p), ie.addEventListener("loadeddata", p), () => {
1021
+ ie.removeEventListener("playing", p), ie.removeEventListener("loadeddata", p);
1022
1022
  };
1023
- }, [re]);
1024
- const [ue, Le] = S(!1);
1025
- N(() => {
1026
- if (!X) {
1027
- Le(!1);
1023
+ }, [ie]);
1024
+ const [he, Ce] = E(!1);
1025
+ M(() => {
1026
+ if (!Q) {
1027
+ Ce(!1);
1028
1028
  return;
1029
1029
  }
1030
- if (Pe) return;
1031
- const p = setTimeout(() => Le(!0), 8e3);
1030
+ if (Be) return;
1031
+ const p = setTimeout(() => Ce(!0), 8e3);
1032
1032
  return () => clearTimeout(p);
1033
- }, [X, Pe]);
1034
- const Ue = C === "connecting" || X && !!i && !Pe && !ue, te = A(null), le = A(null);
1035
- N(() => {
1036
- const p = te.current;
1037
- p && (p.innerHTML = "", M && (M.style.width = "100%", M.style.height = "100%", M.style.objectFit = "cover", M.style.transform = "scaleX(-1)", p.appendChild(M)));
1038
- }, [M]), N(() => {
1039
- const p = le.current;
1040
- p && (p.innerHTML = "", ie && (ie.style.width = "100%", ie.style.height = "100%", ie.style.objectFit = "contain", p.appendChild(ie)));
1041
- }, [ie]);
1042
- const [ae, pe] = S(!1), [$e, he] = S(!1);
1043
- N(() => {
1044
- if (!ae && !$e && !x && !b) return;
1033
+ }, [Q, Be]);
1034
+ const Ge = C === "connecting" || Q && !!o && !Be && !he, re = A(null), ce = A(null);
1035
+ M(() => {
1036
+ const p = re.current;
1037
+ p && (p.innerHTML = "", P && (P.style.width = "100%", P.style.height = "100%", P.style.objectFit = "cover", P.style.transform = "scaleX(-1)", p.appendChild(P)));
1038
+ }, [P]), M(() => {
1039
+ const p = ce.current;
1040
+ p && (p.innerHTML = "", le && (le.style.width = "100%", le.style.height = "100%", le.style.objectFit = "contain", p.appendChild(le)));
1041
+ }, [le]);
1042
+ const [de, me] = E(!1), [ze, ge] = E(!1);
1043
+ M(() => {
1044
+ if (!de && !ze && !L && !w) return;
1045
1045
  const p = () => {
1046
- pe(!1), he(!1), x && E(), b && s();
1046
+ me(!1), ge(!1), L && D(), w && s();
1047
1047
  };
1048
1048
  return document.addEventListener("click", p), () => document.removeEventListener("click", p);
1049
1049
  }, [
1050
- ae,
1051
- $e,
1052
- x,
1053
- b,
1054
- E,
1050
+ de,
1051
+ ze,
1052
+ L,
1053
+ w,
1054
+ D,
1055
1055
  s
1056
1056
  ]);
1057
- const [me, je] = S(""), Ve = L(
1057
+ const [ye, Fe] = E(""), je = S(
1058
1058
  (p) => {
1059
1059
  p.preventDefault();
1060
- const K = me.trim();
1061
- K && (ot(K), je(""));
1060
+ const K = ye.trim();
1061
+ K && (at(K), Fe(""));
1062
1062
  },
1063
- [me, ot]
1064
- ), Ye = c.productName || "Live Layer";
1065
- let ge = null, ye = null;
1066
- for (let p = w.length - 1; p >= 0; p--) {
1067
- const K = w[p];
1068
- if (!ge && K.role === "agent" ? ge = K : !ye && K.role === "user" && (ye = K), ge && ye) break;
1063
+ [ye, at]
1064
+ ), Je = d.productName || "Live Layer";
1065
+ let be = null, ve = null;
1066
+ for (let p = _.length - 1; p >= 0; p--) {
1067
+ const K = _[p];
1068
+ if (!be && K.role === "agent" ? be = K : !ve && K.role === "user" && (ve = K), be && ve) break;
1069
1069
  }
1070
- const ze = X ? (ge == null ? void 0 : ge.text) || null : l || null, lt = X && (ye == null ? void 0 : ye.text) || null, Je = [
1070
+ const Oe = Q ? (be == null ? void 0 : be.text) || null : l || null, st = Q && (ve == null ? void 0 : ve.text) || null, Ye = [
1071
1071
  "ll-expanded",
1072
1072
  t ? "ll-expanded--mobile" : "ll-expanded--desktop"
1073
1073
  ].join(" ");
1074
- return /* @__PURE__ */ _(
1074
+ return /* @__PURE__ */ x(
1075
1075
  "div",
1076
1076
  {
1077
- className: Je,
1077
+ className: Ye,
1078
1078
  "data-position": e,
1079
- "data-state": X ? "connected" : De ? "connecting" : "idle",
1079
+ "data-state": Q ? "connected" : $e ? "connecting" : "idle",
1080
1080
  role: "dialog",
1081
1081
  "aria-label": `${r} widget`,
1082
1082
  children: [
1083
- /* @__PURE__ */ _("div", { className: "ll-expanded__bg", children: [
1084
- i ? /* @__PURE__ */ n(
1085
- er,
1083
+ /* @__PURE__ */ x("div", { className: "ll-expanded__bg", children: [
1084
+ o ? /* @__PURE__ */ n(
1085
+ rr,
1086
1086
  {
1087
- src: i,
1087
+ src: o,
1088
1088
  alt: r,
1089
1089
  className: "ll-expanded__bg-img"
1090
1090
  }
1091
- ) : /* @__PURE__ */ n("div", { className: "ll-expanded__bg-fallback", children: /* @__PURE__ */ n("span", { className: "ll-expanded__bg-initial", children: ((Oe = r == null ? void 0 : r.charAt(0)) == null ? void 0 : Oe.toUpperCase()) || "A" }) }),
1092
- o && !X && /* @__PURE__ */ n(
1091
+ ) : /* @__PURE__ */ n("div", { className: "ll-expanded__bg-fallback", children: /* @__PURE__ */ n("span", { className: "ll-expanded__bg-initial", children: ((Ue = r == null ? void 0 : r.charAt(0)) == null ? void 0 : Ue.toUpperCase()) || "A" }) }),
1092
+ i && !Q && /* @__PURE__ */ n(
1093
1093
  "video",
1094
1094
  {
1095
1095
  className: "ll-expanded__bg-idle",
1096
- src: o,
1096
+ src: i,
1097
1097
  autoPlay: !0,
1098
1098
  loop: !0,
1099
1099
  muted: !0,
@@ -1101,49 +1101,49 @@ const Gn = ({
1101
1101
  }
1102
1102
  )
1103
1103
  ] }),
1104
- /* @__PURE__ */ n("div", { ref: it, className: "ll-expanded__video" }),
1105
- Ue && /* @__PURE__ */ _("div", { className: "ll-expanded__overlay ll-expanded__overlay--connecting", children: [
1104
+ /* @__PURE__ */ n("div", { ref: lt, className: "ll-expanded__video" }),
1105
+ Ge && /* @__PURE__ */ x("div", { className: "ll-expanded__overlay ll-expanded__overlay--connecting", children: [
1106
1106
  /* @__PURE__ */ n("div", { className: "ll-expanded__spinner" }),
1107
1107
  /* @__PURE__ */ n("p", { className: "ll-expanded__overlay-text", children: y ? "Switching..." : "Connecting..." })
1108
1108
  ] }),
1109
- T && X && /* @__PURE__ */ _(
1109
+ $ && Q && /* @__PURE__ */ x(
1110
1110
  "button",
1111
1111
  {
1112
1112
  type: "button",
1113
1113
  className: "ll-expanded__overlay ll-expanded__overlay--gesture",
1114
- onClick: Re,
1114
+ onClick: Me,
1115
1115
  children: [
1116
1116
  /* @__PURE__ */ n("svg", { width: "32", height: "32", viewBox: "0 0 24 24", fill: "currentColor", "aria-hidden": !0, children: /* @__PURE__ */ n("path", { d: "M3 9v6h4l5 5V4L7 9H3zm13.54.12a5 5 0 0 1 0 5.76l-1.41-1.41a3 3 0 0 0 0-2.94L16.54 9.12z" }) }),
1117
1117
  /* @__PURE__ */ n("p", { className: "ll-expanded__overlay-text", children: "Tap to enable audio" })
1118
1118
  ]
1119
1119
  }
1120
1120
  ),
1121
- De ? /* @__PURE__ */ _("div", { className: "ll-expanded__topbar", children: [
1122
- /* @__PURE__ */ _("div", { className: "ll-expanded__topbar-left", children: [
1123
- /* @__PURE__ */ _("div", { className: "ll-expanded__pill-wrap", children: [
1124
- /* @__PURE__ */ _(
1121
+ $e ? /* @__PURE__ */ x("div", { className: "ll-expanded__topbar", children: [
1122
+ /* @__PURE__ */ x("div", { className: "ll-expanded__topbar-left", children: [
1123
+ /* @__PURE__ */ x("div", { className: "ll-expanded__pill-wrap", children: [
1124
+ /* @__PURE__ */ x(
1125
1125
  "button",
1126
1126
  {
1127
1127
  type: "button",
1128
1128
  className: "ll-hpill",
1129
1129
  onClick: (p) => {
1130
- ke && (p.stopPropagation(), s());
1130
+ Ee && (p.stopPropagation(), s());
1131
1131
  },
1132
- "aria-haspopup": ke ? "listbox" : void 0,
1133
- "aria-expanded": ke ? b : void 0,
1132
+ "aria-haspopup": Ee ? "listbox" : void 0,
1133
+ "aria-expanded": Ee ? w : void 0,
1134
1134
  children: [
1135
1135
  /* @__PURE__ */ n("span", { className: "ll-hpill__label", children: r }),
1136
- ke && /* @__PURE__ */ n(st, {})
1136
+ Ee && /* @__PURE__ */ n(pt, {})
1137
1137
  ]
1138
1138
  }
1139
1139
  ),
1140
- ke && b && /* @__PURE__ */ n(
1140
+ Ee && w && /* @__PURE__ */ n(
1141
1141
  "div",
1142
1142
  {
1143
1143
  className: "ll-hmenu",
1144
1144
  onClick: (p) => p.stopPropagation(),
1145
1145
  role: "listbox",
1146
- children: u == null ? void 0 : u.map((p) => /* @__PURE__ */ _(
1146
+ children: u == null ? void 0 : u.map((p) => /* @__PURE__ */ x(
1147
1147
  "button",
1148
1148
  {
1149
1149
  type: "button",
@@ -1169,26 +1169,26 @@ const Gn = ({
1169
1169
  }
1170
1170
  )
1171
1171
  ] }),
1172
- /* @__PURE__ */ _("div", { className: "ll-expanded__pill-wrap", children: [
1173
- /* @__PURE__ */ _(
1172
+ /* @__PURE__ */ x("div", { className: "ll-expanded__pill-wrap", children: [
1173
+ /* @__PURE__ */ x(
1174
1174
  "button",
1175
1175
  {
1176
1176
  type: "button",
1177
1177
  className: "ll-hpill ll-hpill--compact",
1178
1178
  onClick: (p) => {
1179
- p.stopPropagation(), E();
1179
+ p.stopPropagation(), D();
1180
1180
  },
1181
1181
  "aria-haspopup": "listbox",
1182
- "aria-expanded": x,
1182
+ "aria-expanded": L,
1183
1183
  "aria-label": "Language: English",
1184
1184
  title: "Language: English",
1185
1185
  children: [
1186
1186
  /* @__PURE__ */ n("span", { className: "ll-hpill__label", children: "EN" }),
1187
- /* @__PURE__ */ n(st, {})
1187
+ /* @__PURE__ */ n(pt, {})
1188
1188
  ]
1189
1189
  }
1190
1190
  ),
1191
- x && /* @__PURE__ */ n(
1191
+ L && /* @__PURE__ */ n(
1192
1192
  "div",
1193
1193
  {
1194
1194
  className: "ll-hmenu",
@@ -1215,16 +1215,16 @@ const Gn = ({
1215
1215
  }
1216
1216
  )
1217
1217
  ] }),
1218
- /* @__PURE__ */ _("div", { className: "ll-expanded__header-actions", children: [
1218
+ /* @__PURE__ */ x("div", { className: "ll-expanded__header-actions", children: [
1219
1219
  /* @__PURE__ */ n(
1220
1220
  "button",
1221
1221
  {
1222
1222
  type: "button",
1223
1223
  className: "ll-hbtn",
1224
- onClick: de,
1224
+ onClick: ae,
1225
1225
  "aria-label": "Minimize widget",
1226
1226
  title: "Minimize",
1227
- children: /* @__PURE__ */ n(Jt, {})
1227
+ children: /* @__PURE__ */ n(Xt, {})
1228
1228
  }
1229
1229
  ),
1230
1230
  /* @__PURE__ */ n(
@@ -1232,26 +1232,26 @@ const Gn = ({
1232
1232
  {
1233
1233
  type: "button",
1234
1234
  className: "ll-hbtn ll-hbtn--danger",
1235
- onClick: Te,
1235
+ onClick: Pe,
1236
1236
  "aria-label": "End call",
1237
1237
  title: "End call",
1238
- children: /* @__PURE__ */ n(Yt, {})
1238
+ children: /* @__PURE__ */ n(Kt, {})
1239
1239
  }
1240
1240
  )
1241
1241
  ] })
1242
1242
  ] }) : (
1243
1243
  // Idle-state header with Live Layer product name + minimize/close
1244
- /* @__PURE__ */ _("div", { className: "ll-expanded__header ll-expanded__header--idle", children: [
1245
- /* @__PURE__ */ n("span", { className: "ll-expanded__brand", children: Ye }),
1246
- /* @__PURE__ */ _("div", { className: "ll-expanded__header-actions", children: [
1244
+ /* @__PURE__ */ x("div", { className: "ll-expanded__header ll-expanded__header--idle", children: [
1245
+ /* @__PURE__ */ n("span", { className: "ll-expanded__brand", children: Je }),
1246
+ /* @__PURE__ */ x("div", { className: "ll-expanded__header-actions", children: [
1247
1247
  /* @__PURE__ */ n(
1248
1248
  "button",
1249
1249
  {
1250
1250
  type: "button",
1251
1251
  className: "ll-hbtn ll-hbtn--ghost",
1252
- onClick: de,
1252
+ onClick: ae,
1253
1253
  "aria-label": "Minimize widget",
1254
- children: /* @__PURE__ */ n(Jt, {})
1254
+ children: /* @__PURE__ */ n(Xt, {})
1255
1255
  }
1256
1256
  ),
1257
1257
  /* @__PURE__ */ n(
@@ -1259,23 +1259,23 @@ const Gn = ({
1259
1259
  {
1260
1260
  type: "button",
1261
1261
  className: "ll-hbtn ll-hbtn--danger",
1262
- onClick: Te,
1262
+ onClick: Pe,
1263
1263
  "aria-label": "Close widget",
1264
- children: /* @__PURE__ */ n(Yt, {})
1264
+ children: /* @__PURE__ */ n(Kt, {})
1265
1265
  }
1266
1266
  )
1267
1267
  ] })
1268
1268
  ] })
1269
1269
  ),
1270
- ee && /* @__PURE__ */ (() => {
1271
- const p = H ? "Restart paused session" : C === "disconnected" ? "Reconnect to agent" : "Start video call", K = H ? "Pick up where you left off" : null;
1272
- return /* @__PURE__ */ _(St, { children: [
1273
- C === "idle" && !H && !q && /* @__PURE__ */ _(
1270
+ ne && /* @__PURE__ */ (() => {
1271
+ const p = O ? "Restart paused session" : C === "disconnected" ? "Reconnect to agent" : "Start video call", K = O ? "Pick up where you left off" : null;
1272
+ return /* @__PURE__ */ x(Ct, { children: [
1273
+ C === "idle" && !O && !U && /* @__PURE__ */ x(
1274
1274
  "button",
1275
1275
  {
1276
1276
  type: "button",
1277
1277
  className: "ll-expanded__play",
1278
- onClick: xe,
1278
+ onClick: Se,
1279
1279
  "aria-label": p,
1280
1280
  children: [
1281
1281
  /* @__PURE__ */ n("div", { className: "ll-expanded__play-circle", children: /* @__PURE__ */ n("svg", { width: "22", height: "22", viewBox: "0 0 24 24", fill: "currentColor", "aria-hidden": !0, children: /* @__PURE__ */ n("polygon", { points: "6 3 20 12 6 21 6 3" }) }) }),
@@ -1283,7 +1283,7 @@ const Gn = ({
1283
1283
  ]
1284
1284
  }
1285
1285
  ),
1286
- /* @__PURE__ */ _("div", { className: "ll-expanded__bottom ll-expanded__bottom--idle", children: [
1286
+ /* @__PURE__ */ x("div", { className: "ll-expanded__bottom ll-expanded__bottom--idle", children: [
1287
1287
  l && /* @__PURE__ */ n("div", { className: "ll-expanded__transcript", children: /* @__PURE__ */ n("p", { className: "ll-expanded__transcript-text", children: l }) }),
1288
1288
  K && /* @__PURE__ */ n("p", { className: "ll-expanded__cta-sublabel", children: K }),
1289
1289
  /* @__PURE__ */ n(
@@ -1291,7 +1291,7 @@ const Gn = ({
1291
1291
  {
1292
1292
  type: "button",
1293
1293
  className: "ll-expanded__cta",
1294
- onClick: xe,
1294
+ onClick: Se,
1295
1295
  "aria-label": p,
1296
1296
  children: p
1297
1297
  }
@@ -1299,110 +1299,110 @@ const Gn = ({
1299
1299
  ] })
1300
1300
  ] });
1301
1301
  })(),
1302
- /* @__PURE__ */ _(
1302
+ /* @__PURE__ */ x(
1303
1303
  "div",
1304
1304
  {
1305
- className: `ll-expanded__pip ${De && (z || G) ? "is-visible" : ""}`,
1305
+ className: `ll-expanded__pip ${$e && (B || Z) ? "is-visible" : ""}`,
1306
1306
  children: [
1307
1307
  /* @__PURE__ */ n(
1308
1308
  "div",
1309
1309
  {
1310
- ref: le,
1311
- className: G ? "ll-expanded__pip-host" : "ll-expanded__pip-host is-hidden"
1310
+ ref: ce,
1311
+ className: Z ? "ll-expanded__pip-host" : "ll-expanded__pip-host is-hidden"
1312
1312
  }
1313
1313
  ),
1314
1314
  /* @__PURE__ */ n(
1315
1315
  "div",
1316
1316
  {
1317
- ref: te,
1318
- className: !G && z ? "ll-expanded__pip-host" : "ll-expanded__pip-host is-hidden"
1317
+ ref: re,
1318
+ className: !Z && B ? "ll-expanded__pip-host" : "ll-expanded__pip-host is-hidden"
1319
1319
  }
1320
1320
  )
1321
1321
  ]
1322
1322
  }
1323
1323
  ),
1324
- De ? /* @__PURE__ */ _("div", { className: "ll-expanded__bottom", children: [
1325
- ze && /* @__PURE__ */ n(
1324
+ $e ? /* @__PURE__ */ x("div", { className: "ll-expanded__bottom", children: [
1325
+ Oe && /* @__PURE__ */ n(
1326
1326
  "div",
1327
1327
  {
1328
1328
  className: "ll-expanded__transcript ll-expanded__transcript--agent",
1329
1329
  "data-role": "agent",
1330
- children: /* @__PURE__ */ n("p", { className: "ll-expanded__transcript-text", children: ze })
1330
+ children: /* @__PURE__ */ n("p", { className: "ll-expanded__transcript-text", children: Oe })
1331
1331
  }
1332
1332
  ),
1333
- lt && /* @__PURE__ */ n(
1333
+ st && /* @__PURE__ */ n(
1334
1334
  "div",
1335
1335
  {
1336
1336
  className: "ll-expanded__transcript ll-expanded__transcript--user",
1337
1337
  "data-role": "user",
1338
- children: /* @__PURE__ */ n("p", { className: "ll-expanded__transcript-text", children: lt })
1338
+ children: /* @__PURE__ */ n("p", { className: "ll-expanded__transcript-text", children: st })
1339
1339
  }
1340
1340
  ),
1341
- /* @__PURE__ */ _("div", { className: "ll-toolbar", onClick: (p) => p.stopPropagation(), children: [
1342
- nt && /* @__PURE__ */ n(
1341
+ /* @__PURE__ */ x("div", { className: "ll-toolbar", onClick: (p) => p.stopPropagation(), children: [
1342
+ ot && /* @__PURE__ */ n(
1343
1343
  "button",
1344
1344
  {
1345
1345
  type: "button",
1346
- className: `ll-tool ${G ? "is-on" : ""}`,
1347
- onClick: ht,
1348
- "aria-label": G ? "Stop sharing screen" : "Share screen",
1349
- title: G ? "Stop sharing" : "Share screen",
1350
- children: /* @__PURE__ */ n(nr, {})
1346
+ className: `ll-tool ${Z ? "is-on" : ""}`,
1347
+ onClick: vt,
1348
+ "aria-label": Z ? "Stop sharing screen" : "Share screen",
1349
+ title: Z ? "Stop sharing" : "Share screen",
1350
+ children: /* @__PURE__ */ n(ir, {})
1351
1351
  }
1352
1352
  ),
1353
- tt && /* @__PURE__ */ _("div", { className: "ll-tool-split", children: [
1353
+ rt && /* @__PURE__ */ x("div", { className: "ll-tool-split", children: [
1354
1354
  /* @__PURE__ */ n(
1355
1355
  "button",
1356
1356
  {
1357
1357
  type: "button",
1358
- className: `ll-tool ll-tool--left ${z ? "is-on" : ""}`,
1358
+ className: `ll-tool ll-tool--left ${B ? "is-on" : ""}`,
1359
1359
  onClick: Ie,
1360
- "aria-label": z ? "Turn off camera" : "Turn on camera",
1361
- title: z ? "Stop camera" : "Start camera",
1362
- children: /* @__PURE__ */ n(rr, {})
1360
+ "aria-label": B ? "Turn off camera" : "Turn on camera",
1361
+ title: B ? "Stop camera" : "Start camera",
1362
+ children: /* @__PURE__ */ n(lr, {})
1363
1363
  }
1364
1364
  ),
1365
1365
  /* @__PURE__ */ n(
1366
1366
  "button",
1367
1367
  {
1368
1368
  type: "button",
1369
- className: `ll-tool ll-tool--right ${z ? "is-on" : ""}`,
1369
+ className: `ll-tool ll-tool--right ${B ? "is-on" : ""}`,
1370
1370
  onClick: (p) => {
1371
- p.stopPropagation(), he((K) => !K), pe(!1);
1371
+ p.stopPropagation(), ge((K) => !K), me(!1);
1372
1372
  },
1373
1373
  "aria-label": "Camera devices",
1374
1374
  "aria-haspopup": "listbox",
1375
- "aria-expanded": $e,
1376
- children: /* @__PURE__ */ n(st, {})
1375
+ "aria-expanded": ze,
1376
+ children: /* @__PURE__ */ n(pt, {})
1377
1377
  }
1378
1378
  ),
1379
- $e && B.length > 0 && /* @__PURE__ */ n(
1380
- Kt,
1379
+ ze && H.length > 0 && /* @__PURE__ */ n(
1380
+ Qt,
1381
1381
  {
1382
1382
  label: "Camera",
1383
- devices: B,
1384
- activeId: F,
1383
+ devices: H,
1384
+ activeId: G,
1385
1385
  onPick: (p) => {
1386
- he(!1), J(p);
1386
+ ge(!1), Y(p);
1387
1387
  }
1388
1388
  }
1389
1389
  )
1390
1390
  ] }),
1391
- /* @__PURE__ */ _(
1391
+ /* @__PURE__ */ x(
1392
1392
  "div",
1393
1393
  {
1394
- className: `ll-tool-split${!ce && X ? " ll-tool-split--gated" : ""}`,
1394
+ className: `ll-tool-split${!pe && Q ? " ll-tool-split--gated" : ""}`,
1395
1395
  children: [
1396
1396
  /* @__PURE__ */ n(
1397
1397
  "button",
1398
1398
  {
1399
1399
  type: "button",
1400
1400
  className: `ll-tool ll-tool--left ${m ? "is-muted" : ""}`,
1401
- onClick: Me,
1402
- disabled: !ce && X,
1403
- "aria-label": !ce && X ? "Microphone enables once the agent finishes its greeting" : m ? "Unmute microphone" : "Mute microphone",
1404
- title: !ce && X ? "Mic enables after greeting" : m ? "Unmute" : "Mute",
1405
- children: /* @__PURE__ */ n(ir, { muted: m })
1401
+ onClick: Te,
1402
+ disabled: !pe && Q,
1403
+ "aria-label": !pe && Q ? "Microphone enables once the agent finishes its greeting" : m ? "Unmute microphone" : "Mute microphone",
1404
+ title: !pe && Q ? "Mic enables after greeting" : m ? "Unmute" : "Mute",
1405
+ children: /* @__PURE__ */ n(ar, { muted: m })
1406
1406
  }
1407
1407
  ),
1408
1408
  /* @__PURE__ */ n(
@@ -1411,21 +1411,21 @@ const Gn = ({
1411
1411
  type: "button",
1412
1412
  className: `ll-tool ll-tool--right ${m ? "is-muted" : ""}`,
1413
1413
  onClick: (p) => {
1414
- p.stopPropagation(), pe((K) => !K), he(!1);
1414
+ p.stopPropagation(), me((K) => !K), ge(!1);
1415
1415
  },
1416
1416
  "aria-label": "Microphone devices",
1417
1417
  "aria-haspopup": "listbox",
1418
- "aria-expanded": ae,
1419
- children: /* @__PURE__ */ n(st, {})
1418
+ "aria-expanded": de,
1419
+ children: /* @__PURE__ */ n(pt, {})
1420
1420
  }
1421
1421
  ),
1422
- ae && W.length > 0 && /* @__PURE__ */ n(
1423
- Kt,
1422
+ de && q.length > 0 && /* @__PURE__ */ n(
1423
+ Qt,
1424
1424
  {
1425
1425
  label: "Microphone",
1426
- devices: W,
1426
+ devices: q,
1427
1427
  activeId: "",
1428
- onPick: () => pe(!1)
1428
+ onPick: () => me(!1)
1429
1429
  }
1430
1430
  )
1431
1431
  ]
@@ -1435,11 +1435,11 @@ const Gn = ({
1435
1435
  "button",
1436
1436
  {
1437
1437
  type: "button",
1438
- className: `ll-tool ${_e ? "is-muted" : ""}`,
1439
- onClick: mt,
1440
- "aria-label": _e ? "Unmute speaker" : "Mute speaker",
1441
- title: _e ? "Unmute speaker" : "Mute speaker",
1442
- children: /* @__PURE__ */ n(or, { muted: _e })
1438
+ className: `ll-tool ${Le ? "is-muted" : ""}`,
1439
+ onClick: wt,
1440
+ "aria-label": Le ? "Unmute speaker" : "Mute speaker",
1441
+ title: Le ? "Unmute speaker" : "Mute speaker",
1442
+ children: /* @__PURE__ */ n(sr, { muted: Le })
1443
1443
  }
1444
1444
  ),
1445
1445
  /* @__PURE__ */ n(
@@ -1447,61 +1447,61 @@ const Gn = ({
1447
1447
  {
1448
1448
  type: "button",
1449
1449
  className: "ll-tool ll-tool--danger",
1450
- onClick: Ne,
1450
+ onClick: De,
1451
1451
  "aria-label": "End conversation",
1452
1452
  title: "End conversation",
1453
- children: /* @__PURE__ */ n(ar, {})
1453
+ children: /* @__PURE__ */ n(dr, {})
1454
1454
  }
1455
1455
  )
1456
1456
  ] }),
1457
- rt && /* @__PURE__ */ _("form", { className: "ll-message-input", onSubmit: Ve, children: [
1457
+ it && /* @__PURE__ */ x("form", { className: "ll-message-input", onSubmit: je, children: [
1458
1458
  /* @__PURE__ */ n(
1459
1459
  "input",
1460
1460
  {
1461
1461
  type: "text",
1462
1462
  className: "ll-message-input__field",
1463
1463
  placeholder: "Message...",
1464
- value: me,
1465
- onChange: (p) => je(p.target.value),
1464
+ value: ye,
1465
+ onChange: (p) => Fe(p.target.value),
1466
1466
  "aria-label": "Message the agent"
1467
1467
  }
1468
1468
  ),
1469
- me.trim() && /* @__PURE__ */ n(
1469
+ ye.trim() && /* @__PURE__ */ n(
1470
1470
  "button",
1471
1471
  {
1472
1472
  type: "submit",
1473
1473
  className: "ll-message-input__send",
1474
1474
  "aria-label": "Send message",
1475
- children: /* @__PURE__ */ n(lr, {})
1475
+ children: /* @__PURE__ */ n(cr, {})
1476
1476
  }
1477
1477
  )
1478
1478
  ] })
1479
1479
  ] }) : null,
1480
1480
  (() => {
1481
- if (R && C !== "error")
1482
- return /* @__PURE__ */ _("div", { className: "ll-expanded__banner", role: "alert", children: [
1483
- /* @__PURE__ */ n("span", { children: R }),
1481
+ if (I && C !== "error")
1482
+ return /* @__PURE__ */ x("div", { className: "ll-expanded__banner", role: "alert", children: [
1483
+ /* @__PURE__ */ n("span", { children: I }),
1484
1484
  /* @__PURE__ */ n(
1485
1485
  "button",
1486
1486
  {
1487
1487
  type: "button",
1488
1488
  className: "ll-expanded__banner-x",
1489
- onClick: Fe,
1489
+ onClick: We,
1490
1490
  "aria-label": "Dismiss",
1491
1491
  children: "×"
1492
1492
  }
1493
1493
  )
1494
1494
  ] });
1495
- if (!q || C !== "error") return null;
1495
+ if (!U || C !== "error") return null;
1496
1496
  let p = "Failed to connect", K = "Try again";
1497
- return q === "MIC_PERMISSION_DENIED" ? p = "Microphone blocked. Allow access to talk." : q === "MIC_NOT_FOUND" ? p = "No microphone found. Plug one in + retry." : q === "MIC_UNAVAILABLE" ? p = "Mic unavailable. Check other apps using it." : q === "AGENT_TIMEOUT" ? p = "Agent didn't pick up. Try again." : q === "CONNECT_FAILED" ? p = "Connection failed. Check your network." : q.length < 80 && (p = q), /* @__PURE__ */ _("div", { className: "ll-expanded__banner ll-expanded__banner--error", role: "alert", children: [
1497
+ return U === "MIC_PERMISSION_DENIED" ? p = "Microphone blocked. Allow access to talk." : U === "MIC_NOT_FOUND" ? p = "No microphone found. Plug one in + retry." : U === "MIC_UNAVAILABLE" ? p = "Mic unavailable. Check other apps using it." : U === "AGENT_TIMEOUT" ? p = "Agent didn't pick up. Try again." : U === "CONNECT_FAILED" ? p = "Connection failed. Check your network." : U.length < 80 && (p = U), /* @__PURE__ */ x("div", { className: "ll-expanded__banner ll-expanded__banner--error", role: "alert", children: [
1498
1498
  /* @__PURE__ */ n("span", { children: p }),
1499
1499
  /* @__PURE__ */ n(
1500
1500
  "button",
1501
1501
  {
1502
1502
  type: "button",
1503
1503
  className: "ll-expanded__banner-retry",
1504
- onClick: Ae,
1504
+ onClick: Re,
1505
1505
  children: K
1506
1506
  }
1507
1507
  )
@@ -1511,55 +1511,55 @@ const Gn = ({
1511
1511
  }
1512
1512
  );
1513
1513
  };
1514
- function st() {
1514
+ function pt() {
1515
1515
  return /* @__PURE__ */ n("svg", { width: "12", height: "12", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", "aria-hidden": !0, children: /* @__PURE__ */ n("polyline", { points: "6 9 12 15 18 9" }) });
1516
1516
  }
1517
- function Yt() {
1518
- return /* @__PURE__ */ _("svg", { width: "12", height: "12", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", strokeLinecap: "round", "aria-hidden": !0, children: [
1517
+ function Kt() {
1518
+ return /* @__PURE__ */ x("svg", { width: "12", height: "12", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", strokeLinecap: "round", "aria-hidden": !0, children: [
1519
1519
  /* @__PURE__ */ n("line", { x1: "18", y1: "6", x2: "6", y2: "18" }),
1520
1520
  /* @__PURE__ */ n("line", { x1: "6", y1: "6", x2: "18", y2: "18" })
1521
1521
  ] });
1522
1522
  }
1523
- function Jt() {
1523
+ function Xt() {
1524
1524
  return /* @__PURE__ */ n("svg", { width: "12", height: "12", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", strokeLinecap: "round", "aria-hidden": !0, children: /* @__PURE__ */ n("line", { x1: "5", y1: "12", x2: "19", y2: "12" }) });
1525
1525
  }
1526
- function nr() {
1527
- return /* @__PURE__ */ _("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": !0, children: [
1526
+ function ir() {
1527
+ return /* @__PURE__ */ x("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": !0, children: [
1528
1528
  /* @__PURE__ */ n("rect", { x: "2", y: "3", width: "20", height: "14", rx: "2" }),
1529
1529
  /* @__PURE__ */ n("line", { x1: "8", y1: "21", x2: "16", y2: "21" }),
1530
1530
  /* @__PURE__ */ n("line", { x1: "12", y1: "17", x2: "12", y2: "21" })
1531
1531
  ] });
1532
1532
  }
1533
- function rr() {
1534
- return /* @__PURE__ */ _("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": !0, children: [
1533
+ function lr() {
1534
+ return /* @__PURE__ */ x("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": !0, children: [
1535
1535
  /* @__PURE__ */ n("path", { d: "M23 7l-7 5 7 5V7z" }),
1536
1536
  /* @__PURE__ */ n("rect", { x: "1", y: "5", width: "15", height: "14", rx: "2" })
1537
1537
  ] });
1538
1538
  }
1539
- function ir({ muted: e }) {
1540
- return /* @__PURE__ */ _("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": !0, children: [
1539
+ function ar({ muted: e }) {
1540
+ return /* @__PURE__ */ x("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": !0, children: [
1541
1541
  /* @__PURE__ */ n("path", { d: "M12 1a3 3 0 0 0-3 3v8a3 3 0 0 0 6 0V4a3 3 0 0 0-3-3z" }),
1542
1542
  /* @__PURE__ */ n("path", { d: "M19 10v2a7 7 0 0 1-14 0v-2" }),
1543
1543
  /* @__PURE__ */ n("line", { x1: "12", y1: "19", x2: "12", y2: "23" }),
1544
1544
  e && /* @__PURE__ */ n("line", { x1: "1", y1: "1", x2: "23", y2: "23" })
1545
1545
  ] });
1546
1546
  }
1547
- function or({ muted: e }) {
1548
- return /* @__PURE__ */ _("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": !0, children: [
1547
+ function sr({ muted: e }) {
1548
+ return /* @__PURE__ */ x("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": !0, children: [
1549
1549
  /* @__PURE__ */ n("polygon", { points: "11 5 6 9 2 9 2 15 6 15 11 19 11 5" }),
1550
- e ? /* @__PURE__ */ n("line", { x1: "23", y1: "9", x2: "17", y2: "15" }) : /* @__PURE__ */ _(St, { children: [
1550
+ e ? /* @__PURE__ */ n("line", { x1: "23", y1: "9", x2: "17", y2: "15" }) : /* @__PURE__ */ x(Ct, { children: [
1551
1551
  /* @__PURE__ */ n("path", { d: "M19.07 4.93a10 10 0 0 1 0 14.14" }),
1552
1552
  /* @__PURE__ */ n("path", { d: "M15.54 8.46a5 5 0 0 1 0 7.07" })
1553
1553
  ] })
1554
1554
  ] });
1555
1555
  }
1556
- function lr() {
1557
- return /* @__PURE__ */ _("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": !0, children: [
1556
+ function cr() {
1557
+ return /* @__PURE__ */ x("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": !0, children: [
1558
1558
  /* @__PURE__ */ n("line", { x1: "5", y1: "12", x2: "19", y2: "12" }),
1559
1559
  /* @__PURE__ */ n("polyline", { points: "12 5 19 12 12 19" })
1560
1560
  ] });
1561
1561
  }
1562
- function ar() {
1562
+ function dr() {
1563
1563
  return /* @__PURE__ */ n("svg", { width: "16", height: "16", viewBox: "-4 -4 32 32", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": !0, children: /* @__PURE__ */ n(
1564
1564
  "path",
1565
1565
  {
@@ -1568,49 +1568,49 @@ function ar() {
1568
1568
  }
1569
1569
  ) });
1570
1570
  }
1571
- const Kt = ({ label: e, devices: t, activeId: r, onPick: i }) => /* @__PURE__ */ _(
1571
+ const Qt = ({ label: e, devices: t, activeId: r, onPick: o }) => /* @__PURE__ */ x(
1572
1572
  "div",
1573
1573
  {
1574
1574
  className: "ll-device-menu",
1575
- onClick: (o) => o.stopPropagation(),
1575
+ onClick: (i) => i.stopPropagation(),
1576
1576
  role: "listbox",
1577
1577
  children: [
1578
1578
  /* @__PURE__ */ n("p", { className: "ll-device-menu__label", children: e }),
1579
- t.map((o, l) => {
1580
- const c = r === o.deviceId;
1581
- return /* @__PURE__ */ _(
1579
+ t.map((i, l) => {
1580
+ const d = r === i.deviceId;
1581
+ return /* @__PURE__ */ x(
1582
1582
  "button",
1583
1583
  {
1584
1584
  type: "button",
1585
- className: `ll-device-menu__item ${c ? "is-active" : ""}`,
1586
- onClick: () => i(o.deviceId),
1585
+ className: `ll-device-menu__item ${d ? "is-active" : ""}`,
1586
+ onClick: () => o(i.deviceId),
1587
1587
  role: "option",
1588
- "aria-selected": c,
1588
+ "aria-selected": d,
1589
1589
  children: [
1590
- c && /* @__PURE__ */ n("span", { className: "ll-device-menu__dot", children: "●" }),
1591
- /* @__PURE__ */ n("span", { className: "ll-device-menu__name", children: o.label || `${e} ${l + 1}` })
1590
+ d && /* @__PURE__ */ n("span", { className: "ll-device-menu__dot", children: "●" }),
1591
+ /* @__PURE__ */ n("span", { className: "ll-device-menu__name", children: i.label || `${e} ${l + 1}` })
1592
1592
  ]
1593
1593
  },
1594
- o.deviceId || l
1594
+ i.deviceId || l
1595
1595
  );
1596
1596
  })
1597
1597
  ]
1598
1598
  }
1599
- ), sr = [
1599
+ ), ur = [
1600
1600
  '[data-ll-private="true"]',
1601
1601
  ".ll-widget"
1602
1602
  ];
1603
- function Et(e) {
1603
+ function At(e) {
1604
1604
  let t = e;
1605
1605
  for (; t; ) {
1606
- for (const r of sr)
1606
+ for (const r of ur)
1607
1607
  if (t.matches(r)) return !0;
1608
1608
  t = t.parentElement;
1609
1609
  }
1610
1610
  return !1;
1611
1611
  }
1612
- function pt(e) {
1613
- if (Et(e)) return !1;
1612
+ function bt(e) {
1613
+ if (At(e)) return !1;
1614
1614
  if (e instanceof HTMLInputElement) {
1615
1615
  if (e.type === "password") return !1;
1616
1616
  const t = (e.getAttribute("autocomplete") || "").toLowerCase();
@@ -1618,7 +1618,7 @@ function pt(e) {
1618
1618
  }
1619
1619
  return !0;
1620
1620
  }
1621
- const ct = 4096, cr = 20, dr = 20, ur = 10, fr = 10, pr = 30, Xt = 500, hr = [
1621
+ const ht = 4096, fr = 20, pr = 20, hr = 10, mr = 10, gr = 30, Zt = 500, yr = [
1622
1622
  '[data-ll-private="true"]',
1623
1623
  ".ll-widget",
1624
1624
  "script",
@@ -1626,24 +1626,24 @@ const ct = 4096, cr = 20, dr = 20, ur = 10, fr = 10, pr = 30, Xt = 500, hr = [
1626
1626
  "noscript",
1627
1627
  "iframe"
1628
1628
  ];
1629
- function Ze(e) {
1629
+ function et(e) {
1630
1630
  if (e.getAttribute("aria-hidden") === "true" || e.hasAttribute("hidden")) return !0;
1631
1631
  let t = e;
1632
1632
  for (; t; ) {
1633
- for (const r of hr)
1633
+ for (const r of yr)
1634
1634
  if (t.matches(r)) return !0;
1635
1635
  t = t.parentElement;
1636
1636
  }
1637
1637
  return !1;
1638
1638
  }
1639
- function et(e) {
1639
+ function tt(e) {
1640
1640
  if (typeof window > "u") return !0;
1641
1641
  const t = e.getBoundingClientRect();
1642
1642
  if (t.width <= 0 || t.height <= 0) return !1;
1643
- const r = window.innerHeight || document.documentElement.clientHeight, i = window.innerWidth || document.documentElement.clientWidth;
1644
- return t.bottom > 0 && t.right > 0 && t.top < r && t.left < i;
1643
+ const r = window.innerHeight || document.documentElement.clientHeight, o = window.innerWidth || document.documentElement.clientWidth;
1644
+ return t.bottom > 0 && t.right > 0 && t.top < r && t.left < o;
1645
1645
  }
1646
- function Gt(e) {
1646
+ function en(e) {
1647
1647
  const t = e.getAttribute("id");
1648
1648
  if (t) {
1649
1649
  const l = document.querySelector(`label[for="${CSS.escape(t)}"]`);
@@ -1651,18 +1651,18 @@ function Gt(e) {
1651
1651
  }
1652
1652
  const r = e.getAttribute("aria-label");
1653
1653
  if (r) return r.trim();
1654
- const i = e.getAttribute("placeholder");
1655
- if (i) return i.trim();
1656
- const o = e.closest("label");
1657
- return o != null && o.textContent ? o.textContent.trim() : "";
1654
+ const o = e.getAttribute("placeholder");
1655
+ if (o) return o.trim();
1656
+ const i = e.closest("label");
1657
+ return i != null && i.textContent ? i.textContent.trim() : "";
1658
1658
  }
1659
- function Ee(e, t) {
1659
+ function Ae(e, t) {
1660
1660
  return e.length <= t ? e : e.slice(0, t - 1) + "…";
1661
1661
  }
1662
- function qe(e) {
1662
+ function He(e) {
1663
1663
  return e.length;
1664
1664
  }
1665
- function mr(e, t = {}) {
1665
+ function br(e, t = {}) {
1666
1666
  const r = t.doc ?? (typeof document < "u" ? document : null);
1667
1667
  if (!r)
1668
1668
  return {
@@ -1676,39 +1676,39 @@ function mr(e, t = {}) {
1676
1676
  forms: [],
1677
1677
  extras: e
1678
1678
  };
1679
- const i = typeof window < "u" && window.location.href || "", o = typeof window < "u" && window.location.pathname || "/", l = r.title || "", c = Array.from(
1679
+ const o = typeof window < "u" && window.location.href || "", i = typeof window < "u" && window.location.pathname || "/", l = r.title || "", d = Array.from(
1680
1680
  r.querySelectorAll("[data-ll-region]")
1681
1681
  ), u = [];
1682
- for (const m of c) {
1683
- if (u.length >= ur) break;
1684
- if (Ze(m) || !et(m)) continue;
1685
- const R = m.getAttribute("data-ll-region") ?? "", W = m.getAttribute("data-ll-intent") ?? void 0, z = Ee(
1682
+ for (const m of d) {
1683
+ if (u.length >= hr) break;
1684
+ if (et(m) || !tt(m)) continue;
1685
+ const I = m.getAttribute("data-ll-region") ?? "", q = m.getAttribute("data-ll-intent") ?? void 0, B = Ae(
1686
1686
  (m.innerText || m.textContent || "").trim(),
1687
- Xt * 2
1687
+ Zt * 2
1688
1688
  );
1689
- !R || !z || u.push({ id: R, intent: W, text: z });
1689
+ !I || !B || u.push({ id: I, intent: q, text: B });
1690
1690
  }
1691
- const f = [], y = ["H1", "H2", "H3", "H4", "H5", "H6"], b = Array.from(
1691
+ const f = [], y = ["H1", "H2", "H3", "H4", "H5", "H6"], w = Array.from(
1692
1692
  r.querySelectorAll("h1, h2, h3, h4, h5, h6")
1693
1693
  );
1694
- for (const m of b) {
1695
- if (Ze(m) || !et(m)) continue;
1696
- const R = (m.textContent || "").trim();
1697
- R && f.push(`${m.tagName}: ${Ee(R, 200)}`);
1694
+ for (const m of w) {
1695
+ if (et(m) || !tt(m)) continue;
1696
+ const I = (m.textContent || "").trim();
1697
+ I && f.push(`${m.tagName}: ${Ae(I, 200)}`);
1698
1698
  }
1699
1699
  const s = Array.from(r.querySelectorAll("p, li"));
1700
1700
  for (const m of s) {
1701
- if (Ze(m) || !et(m) || y.includes(m.tagName)) continue;
1702
- const R = (m.textContent || "").trim();
1703
- R.length > 10 && f.push(Ee(R, Xt));
1701
+ if (et(m) || !tt(m) || y.includes(m.tagName)) continue;
1702
+ const I = (m.textContent || "").trim();
1703
+ I.length > 10 && f.push(Ae(I, Zt));
1704
1704
  }
1705
1705
  const a = f.join(`
1706
- `), x = [], E = Array.from(r.querySelectorAll("a[href]"));
1707
- for (const m of E) {
1708
- if (x.length >= cr) break;
1709
- if (Ze(m) || !et(m)) continue;
1710
- const R = m.getAttribute("href") || "", W = (m.textContent || "").trim();
1711
- !R || !W || x.push({ href: R, text: Ee(W, 100) });
1706
+ `), L = [], D = Array.from(r.querySelectorAll("a[href]"));
1707
+ for (const m of D) {
1708
+ if (L.length >= fr) break;
1709
+ if (et(m) || !tt(m)) continue;
1710
+ const I = m.getAttribute("href") || "", q = (m.textContent || "").trim();
1711
+ !I || !q || L.push({ href: I, text: Ae(q, 100) });
1712
1712
  }
1713
1713
  const C = [], v = Array.from(
1714
1714
  r.querySelectorAll(
@@ -1716,65 +1716,65 @@ function mr(e, t = {}) {
1716
1716
  )
1717
1717
  );
1718
1718
  for (const m of v) {
1719
- if (C.length >= dr) break;
1720
- if (Ze(m) || !pt(m) || !et(m)) continue;
1721
- const R = Gt(m), W = m instanceof HTMLInputElement ? m.type : m.tagName.toLowerCase();
1722
- R && C.push({ label: Ee(R, 100), type: W });
1719
+ if (C.length >= pr) break;
1720
+ if (et(m) || !bt(m) || !tt(m)) continue;
1721
+ const I = en(m), q = m instanceof HTMLInputElement ? m.type : m.tagName.toLowerCase();
1722
+ I && C.push({ label: Ae(I, 100), type: q });
1723
1723
  }
1724
- const w = Array.from(
1724
+ const _ = Array.from(
1725
1725
  r.querySelectorAll("[data-ll-form]")
1726
- ), H = [];
1727
- for (const m of w) {
1728
- if (H.length >= fr) break;
1729
- if (Et(m)) continue;
1730
- const R = m.getAttribute("data-ll-form") || "";
1731
- if (!R) continue;
1732
- const W = m.getAttribute("data-ll-intent") || void 0, z = Array.from(
1726
+ ), O = [];
1727
+ for (const m of _) {
1728
+ if (O.length >= mr) break;
1729
+ if (At(m)) continue;
1730
+ const I = m.getAttribute("data-ll-form") || "";
1731
+ if (!I) continue;
1732
+ const q = m.getAttribute("data-ll-intent") || void 0, B = Array.from(
1733
1733
  m.querySelectorAll(
1734
1734
  "[data-ll-field]"
1735
1735
  )
1736
- ), M = [];
1737
- for (const B of z) {
1738
- if (M.length >= pr) break;
1739
- if (!pt(B)) continue;
1740
- const F = B.getAttribute("data-ll-field") || "";
1741
- if (!F) continue;
1742
- const G = Gt(B) || F, ie = B instanceof HTMLInputElement ? B.type : B.tagName.toLowerCase();
1743
- M.push({ name: F, label: Ee(G, 100), type: ie });
1736
+ ), P = [];
1737
+ for (const H of B) {
1738
+ if (P.length >= gr) break;
1739
+ if (!bt(H)) continue;
1740
+ const G = H.getAttribute("data-ll-field") || "";
1741
+ if (!G) continue;
1742
+ const Z = en(H) || G, le = H instanceof HTMLInputElement ? H.type : H.tagName.toLowerCase();
1743
+ P.push({ name: G, label: Ae(Z, 100), type: le });
1744
1744
  }
1745
- H.push({ id: R, intent: W, fields: M });
1745
+ O.push({ id: I, intent: q, fields: P });
1746
1746
  }
1747
- const T = {
1748
- url: i,
1747
+ const $ = {
1748
+ url: o,
1749
1749
  title: l,
1750
- pathname: o,
1750
+ pathname: i,
1751
1751
  regions: u,
1752
1752
  visibleText: a,
1753
- visibleLinks: x,
1753
+ visibleLinks: L,
1754
1754
  visibleFields: C,
1755
- forms: H,
1755
+ forms: O,
1756
1756
  extras: e
1757
1757
  };
1758
- let q = qe(JSON.stringify(T.regions)) + qe(T.visibleText) + qe(JSON.stringify(T.visibleLinks)) + qe(JSON.stringify(T.visibleFields));
1759
- for (; q > ct && T.visibleFields.length > 0; )
1760
- T.visibleFields.pop(), q = qe(JSON.stringify(T.visibleFields));
1761
- for (; q > ct && T.visibleLinks.length > 0; )
1762
- T.visibleLinks.pop(), q -= 80;
1763
- return qe(T.visibleText) > ct && (T.visibleText = Ee(T.visibleText, ct - 100)), T;
1764
- }
1765
- let Be = null;
1766
- function kt(e, t = {}) {
1767
- const r = Date.now(), o = `${typeof window < "u" && window.location.pathname || "/"}::${typeof window < "u" ? window.scrollY : 0}`;
1768
- if (Be && Be.key === o && r - Be.at < 1e3)
1769
- return Be.ctx;
1770
- const l = mr(e, t);
1771
- return Be = { key: o, at: r, ctx: l }, l;
1772
- }
1773
- function gr() {
1774
- Be = null;
1775
- }
1776
- const yr = 200;
1777
- function vr(e) {
1758
+ let U = He(JSON.stringify($.regions)) + He($.visibleText) + He(JSON.stringify($.visibleLinks)) + He(JSON.stringify($.visibleFields));
1759
+ for (; U > ht && $.visibleFields.length > 0; )
1760
+ $.visibleFields.pop(), U = He(JSON.stringify($.visibleFields));
1761
+ for (; U > ht && $.visibleLinks.length > 0; )
1762
+ $.visibleLinks.pop(), U -= 80;
1763
+ return He($.visibleText) > ht && ($.visibleText = Ae($.visibleText, ht - 100)), $;
1764
+ }
1765
+ let Ve = null;
1766
+ function mt(e, t = {}) {
1767
+ const r = Date.now(), i = `${typeof window < "u" && window.location.pathname || "/"}::${typeof window < "u" ? window.scrollY : 0}`;
1768
+ if (Ve && Ve.key === i && r - Ve.at < 1e3)
1769
+ return Ve.ctx;
1770
+ const l = br(e, t);
1771
+ return Ve = { key: i, at: r, ctx: l }, l;
1772
+ }
1773
+ function vr() {
1774
+ Ve = null;
1775
+ }
1776
+ const wr = 200;
1777
+ function _r(e) {
1778
1778
  const t = String(e.href || "");
1779
1779
  return {
1780
1780
  href: t,
@@ -1784,18 +1784,18 @@ function vr(e) {
1784
1784
  description: e.description
1785
1785
  };
1786
1786
  }
1787
- function br(e) {
1787
+ function xr(e) {
1788
1788
  return !(!e || e.startsWith("#") || e.startsWith("javascript:") || e.startsWith("mailto:") || e.startsWith("tel:"));
1789
1789
  }
1790
- function wr(e) {
1790
+ function kr(e) {
1791
1791
  const t = e ?? (typeof document < "u" ? document : null);
1792
1792
  if (!t) return [];
1793
- const r = typeof window < "u" && window.location.origin || "", i = /* @__PURE__ */ new Set(), o = [], l = Array.from(t.querySelectorAll("a[href]"));
1794
- for (const c of l) {
1795
- if (o.length >= yr) break;
1796
- if (Et(c)) continue;
1797
- const u = c.getAttribute("href") || "";
1798
- if (!br(u)) continue;
1793
+ const r = typeof window < "u" && window.location.origin || "", o = /* @__PURE__ */ new Set(), i = [], l = Array.from(t.querySelectorAll("a[href]"));
1794
+ for (const d of l) {
1795
+ if (i.length >= wr) break;
1796
+ if (At(d)) continue;
1797
+ const u = d.getAttribute("href") || "";
1798
+ if (!xr(u)) continue;
1799
1799
  let f = u, y = !0;
1800
1800
  try {
1801
1801
  if (typeof window < "u") {
@@ -1805,42 +1805,42 @@ function wr(e) {
1805
1805
  } catch {
1806
1806
  continue;
1807
1807
  }
1808
- if (i.has(f)) continue;
1809
- i.add(f);
1810
- const b = (c.textContent || "").trim().slice(0, 120);
1811
- o.push({ href: f, text: b, internal: y });
1808
+ if (o.has(f)) continue;
1809
+ o.add(f);
1810
+ const w = (d.textContent || "").trim().slice(0, 120);
1811
+ i.push({ href: f, text: w, internal: y });
1812
1812
  }
1813
- return o;
1813
+ return i;
1814
1814
  }
1815
- let We = null;
1816
- const _r = 5e3;
1817
- function dt() {
1815
+ let qe = null;
1816
+ const Lr = 5e3;
1817
+ function nt() {
1818
1818
  const e = Date.now(), t = typeof window < "u" && window.location.pathname || "/";
1819
- if (We && We.pathname === t && e - We.at < _r)
1820
- return We.routes;
1821
- const r = wr();
1822
- return We = { at: e, pathname: t, routes: r }, r;
1819
+ if (qe && qe.pathname === t && e - qe.at < Lr)
1820
+ return qe.routes;
1821
+ const r = kr();
1822
+ return qe = { at: e, pathname: t, routes: r }, r;
1823
1823
  }
1824
- function xr() {
1825
- We = null;
1824
+ function Sr() {
1825
+ qe = null;
1826
1826
  }
1827
- function kr(e, t) {
1828
- const r = e instanceof HTMLInputElement ? HTMLInputElement.prototype : e instanceof HTMLTextAreaElement ? HTMLTextAreaElement.prototype : HTMLSelectElement.prototype, i = Object.getOwnPropertyDescriptor(r, "value"), o = i == null ? void 0 : i.set;
1829
- o ? o.call(e, t) : e.value = t;
1827
+ function Er(e, t) {
1828
+ const r = e instanceof HTMLInputElement ? HTMLInputElement.prototype : e instanceof HTMLTextAreaElement ? HTMLTextAreaElement.prototype : HTMLSelectElement.prototype, o = Object.getOwnPropertyDescriptor(r, "value"), i = o == null ? void 0 : o.set;
1829
+ i ? i.call(e, t) : e.value = t;
1830
1830
  }
1831
- function Lr(e, t, r = {}) {
1832
- const i = r.triggerInput ?? !0, o = r.triggerChange ?? !0;
1831
+ function Cr(e, t, r = {}) {
1832
+ const o = r.triggerInput ?? !0, i = r.triggerChange ?? !0;
1833
1833
  if (e instanceof HTMLInputElement && (e.type === "checkbox" || e.type === "radio")) {
1834
1834
  const l = Object.getOwnPropertyDescriptor(
1835
1835
  HTMLInputElement.prototype,
1836
1836
  "checked"
1837
- ), c = l == null ? void 0 : l.set, u = t === "true" || t === "1" || t === "on";
1838
- c ? c.call(e, u) : e.checked = u, i && e.dispatchEvent(new Event("input", { bubbles: !0 })), o && e.dispatchEvent(new Event("change", { bubbles: !0 }));
1837
+ ), d = l == null ? void 0 : l.set, u = t === "true" || t === "1" || t === "on";
1838
+ d ? d.call(e, u) : e.checked = u, o && e.dispatchEvent(new Event("input", { bubbles: !0 })), i && e.dispatchEvent(new Event("change", { bubbles: !0 }));
1839
1839
  return;
1840
1840
  }
1841
- kr(e, t), i && e.dispatchEvent(new Event("input", { bubbles: !0 })), o && e.dispatchEvent(new Event("change", { bubbles: !0 }));
1841
+ Er(e, t), o && e.dispatchEvent(new Event("input", { bubbles: !0 })), i && e.dispatchEvent(new Event("change", { bubbles: !0 }));
1842
1842
  }
1843
- function Sr() {
1843
+ function Nr() {
1844
1844
  if (typeof window > "u" || typeof document > "u")
1845
1845
  return !1;
1846
1846
  const e = document.scrollingElement || document.documentElement;
@@ -1848,44 +1848,44 @@ function Sr() {
1848
1848
  const t = window.getComputedStyle(e);
1849
1849
  return !(t.overflowY === "hidden" || t.overflowY === "clip");
1850
1850
  }
1851
- function Cr(e) {
1851
+ function Ar(e) {
1852
1852
  if (!(e instanceof HTMLElement)) return !1;
1853
1853
  const r = window.getComputedStyle(e).overflowY;
1854
1854
  return !(r !== "auto" && r !== "scroll" || e.scrollHeight <= e.clientHeight + 2);
1855
1855
  }
1856
- function Er() {
1856
+ function Dr() {
1857
1857
  if (typeof document > "u") return null;
1858
1858
  const e = Array.from(
1859
1859
  document.querySelectorAll("body, body *")
1860
1860
  );
1861
1861
  let t = null, r = 0;
1862
- for (const i of e) {
1863
- if (!Cr(i)) continue;
1864
- const o = i.getBoundingClientRect();
1865
- if (o.bottom <= 0 || o.top >= window.innerHeight || o.right <= 0 || o.left >= window.innerWidth || o.width <= 0 || o.height <= 0 || i.closest(".ll-widget")) continue;
1866
- const l = o.width * o.height;
1867
- l > r && (r = l, t = i);
1862
+ for (const o of e) {
1863
+ if (!Ar(o)) continue;
1864
+ const i = o.getBoundingClientRect();
1865
+ if (i.bottom <= 0 || i.top >= window.innerHeight || i.right <= 0 || i.left >= window.innerWidth || i.width <= 0 || i.height <= 0 || o.closest(".ll-widget")) continue;
1866
+ const l = i.width * i.height;
1867
+ l > r && (r = l, t = o);
1868
1868
  }
1869
1869
  return t;
1870
1870
  }
1871
- function Nr() {
1871
+ function Rr() {
1872
1872
  if (typeof window > "u")
1873
1873
  return null;
1874
- if (Sr()) return window;
1875
- const e = Er();
1874
+ if (Nr()) return window;
1875
+ const e = Dr();
1876
1876
  return e || window;
1877
1877
  }
1878
- function Qt(e) {
1878
+ function tn(e) {
1879
1879
  return e instanceof Window ? e.innerHeight || 0 : e.clientHeight || 0;
1880
1880
  }
1881
- function Ar(e) {
1881
+ function Mr(e) {
1882
1882
  var t, r;
1883
1883
  return e instanceof Window ? typeof document > "u" ? 0 : Math.max(
1884
1884
  ((t = document.body) == null ? void 0 : t.scrollHeight) ?? 0,
1885
1885
  ((r = document.documentElement) == null ? void 0 : r.scrollHeight) ?? 0
1886
1886
  ) : e.scrollHeight - e.clientHeight;
1887
1887
  }
1888
- const Rr = /* @__PURE__ */ new Set([
1888
+ const Tr = /* @__PURE__ */ new Set([
1889
1889
  "agent_state",
1890
1890
  "avatar_stream_ready",
1891
1891
  "avatar_active",
@@ -1906,995 +1906,1093 @@ const Rr = /* @__PURE__ */ new Set([
1906
1906
  "fill_form",
1907
1907
  "focus_field",
1908
1908
  "submit_form",
1909
- "request_routes"
1909
+ "request_routes",
1910
+ // 0.5.24 — agent asks the widget to (re)push its state. Triggers
1911
+ // the same push logic as a pathname change, used to fix the race
1912
+ // where the agent's listener attaches AFTER the widget's first push.
1913
+ "request_initial_sync"
1910
1914
  ]);
1911
- function Mr(e) {
1912
- var Mt, It, Tt, Dt, Pt, $t, zt;
1915
+ function Ir(e) {
1916
+ var It, Pt, $t, Bt, zt, Ot, Ut;
1913
1917
  const {
1914
1918
  agentId: t,
1915
1919
  apiKey: r,
1916
- baseUrl: i = "https://app.livelayer.studio",
1917
- sessionEndpoint: o,
1920
+ baseUrl: o = "https://app.livelayer.studio",
1921
+ sessionEndpoint: i,
1918
1922
  sessionBody: l,
1919
- autoConnect: c = !1,
1923
+ autoConnect: d = !1,
1920
1924
  displayMode: u,
1921
1925
  defaultDisplayMode: f = "expanded",
1922
1926
  onDisplayModeChange: y,
1923
- position: b = "bottom-right",
1927
+ position: w = "bottom-right",
1924
1928
  mobileBreakpoint: s = 640,
1925
1929
  persistKey: a = "ll-widget",
1926
- disablePersistence: x = !1,
1927
- teamMembers: E,
1930
+ disablePersistence: L = !1,
1931
+ teamMembers: D,
1928
1932
  currentTeamMemberId: C,
1929
1933
  onTeamMemberChange: v,
1930
- idleLoopUrl: w,
1931
- greeting: H,
1932
- avatarImageUrl: T,
1933
- agentName: q,
1934
+ idleLoopUrl: _,
1935
+ greeting: O,
1936
+ avatarImageUrl: $,
1937
+ agentName: U,
1934
1938
  branding: m = {},
1935
- allowCamera: R = !0,
1936
- allowScreenShare: W = !0,
1937
- allowTyping: z = !0,
1938
- showOn: M,
1939
- hideOn: B,
1940
- pathname: F,
1941
- onNavigate: G,
1942
- onScrollToSelector: ie,
1943
- getPageContext: _e,
1944
- pageContextExtras: tt,
1945
- getRoutes: nt,
1946
- onScrollPage: rt,
1947
- onClick: it,
1948
- capabilities: re,
1949
- onConnect: ce,
1950
- onDisconnect: xe,
1951
- onTranscript: Ne,
1952
- onAgentState: Ae,
1953
- onConnectionStateChange: Re,
1954
- onAgentEvent: Me,
1939
+ allowCamera: I = !0,
1940
+ allowScreenShare: q = !0,
1941
+ allowTyping: B = !0,
1942
+ showOn: P,
1943
+ hideOn: H,
1944
+ pathname: G,
1945
+ onNavigate: Z,
1946
+ onScrollToSelector: le,
1947
+ getPageContext: Le,
1948
+ pageContextExtras: rt,
1949
+ getRoutes: ot,
1950
+ onScrollPage: it,
1951
+ onClick: lt,
1952
+ capabilities: ie,
1953
+ onConnect: pe,
1954
+ onDisconnect: Se,
1955
+ onTranscript: De,
1956
+ onAgentState: Re,
1957
+ onConnectionStateChange: Me,
1958
+ onAgentEvent: Te,
1955
1959
  onAgentCommand: Ie,
1956
- controlledSession: J,
1957
- className: ht,
1958
- style: mt,
1959
- zIndex: ot = 2147483647
1960
- } = e, de = On(F), Te = jn(de, M, B);
1961
- N(() => {
1962
- gr(), xr();
1963
- }, [de]);
1964
- const Fe = C !== void 0, [ke, De] = S(() => {
1960
+ controlledSession: Y,
1961
+ className: vt,
1962
+ style: wt,
1963
+ zIndex: at = 2147483647
1964
+ } = e, ae = Hn(G), Pe = Jn(ae, P, H);
1965
+ M(() => {
1966
+ vr(), Sr();
1967
+ }, [ae]);
1968
+ const We = C !== void 0, [Ee, $e] = E(() => {
1965
1969
  var h;
1966
- return C ?? ((h = E == null ? void 0 : E[0]) == null ? void 0 : h.id);
1967
- }), X = Fe ? C : ke, ee = ut(
1968
- () => (E == null ? void 0 : E.find((h) => h.id === X)) ?? null,
1969
- [E, X]
1970
- ), Pe = (ee == null ? void 0 : ee.agentId) ?? t, [oe, ue] = Dn({
1970
+ return C ?? ((h = D == null ? void 0 : D[0]) == null ? void 0 : h.id);
1971
+ }), Q = We ? C : Ee, ne = gt(
1972
+ () => (D == null ? void 0 : D.find((h) => h.id === Q)) ?? null,
1973
+ [D, Q]
1974
+ ), Be = (ne == null ? void 0 : ne.agentId) ?? t, [se, he] = Bn({
1971
1975
  value: u,
1972
1976
  defaultValue: f,
1973
1977
  onChange: y,
1974
1978
  persistKey: a,
1975
- disablePersistence: x
1976
- }), Le = $n(s), Ue = xn(), te = kn(), le = Sn(), ae = Cn(), pe = En(), [$e, he] = S(!1), [me, je] = S(!1), [Ve, Ye] = S(!1), [ge, ye] = S(!1), [ze, lt] = S(!1), Je = A(G), Oe = A(ie), p = A(rt), K = A(it), gt = A(_e), yt = A(tt), vt = A(nt), bt = A(re), ne = A(null);
1977
- Je.current = G, Oe.current = ie, p.current = rt, K.current = it, gt.current = _e, yt.current = tt, vt.current = nt, bt.current = re;
1978
- function ve(h) {
1979
- const d = bt.current;
1980
- return d ? d.includes(h) : !0;
1979
+ disablePersistence: L
1980
+ }), Ce = On(s), Ge = Sn(), re = En(), ce = Nn(), de = An(), me = Dn(), [ze, ge] = E(!1), [ye, Fe] = E(!1), [je, Je] = E(!1), [be, ve] = E(!1), [Oe, st] = E(!1), Ye = A(Z), Ue = A(le), p = A(it), K = A(lt), _t = A(Le), ct = A(rt), dt = A(ot), xt = A(ie), oe = A(null), ut = A(null), Dt = A(void 0);
1981
+ Dt.current = ae, Ye.current = Z, Ue.current = le, p.current = it, K.current = lt, _t.current = Le, ct.current = rt, dt.current = ot, xt.current = ie;
1982
+ function we(h) {
1983
+ const c = xt.current;
1984
+ return c ? c.includes(h) : !0;
1981
1985
  }
1982
- function be(h, d) {
1986
+ function _e(h, c) {
1983
1987
  console.warn(
1984
- `[LiveLayer] Agent command "${h}" blocked — capability "${d}" not in allowlist. See https://livelayer.studio/docs/react/capabilities`
1988
+ `[LiveLayer] Agent command "${h}" blocked — capability "${c}" not in allowlist. See https://livelayer.studio/docs/react/capabilities`
1985
1989
  );
1986
1990
  }
1987
- const Ke = L(
1991
+ const Ke = S(
1988
1992
  (h) => {
1989
- var Z, Se, fe, He, we;
1990
- const d = h;
1991
- if (!(!d.type || typeof d.type != "string")) {
1992
- if (Me == null || Me({ eventName: d.type, data: h }), d.type === "navigate") {
1993
- if (!ve("navigate")) {
1994
- be("navigate", "navigate");
1993
+ var J, ue, te, xe, ke, X;
1994
+ const c = h;
1995
+ if (!(!c.type || typeof c.type != "string")) {
1996
+ if (Te == null || Te({ eventName: c.type, data: h }), c.type === "bot_ready" || c.type === "request_initial_sync") {
1997
+ console.log(
1998
+ `[NAV-DEBUG][widget] received ${c.type} → triggering pushSnapshot`
1999
+ );
2000
+ try {
2001
+ (J = ut.current) == null || J.call(ut);
2002
+ } catch (b) {
2003
+ console.warn("[NAV-DEBUG][widget] pushSnapshot threw:", b);
2004
+ }
2005
+ }
2006
+ if (c.type === "navigate") {
2007
+ if (!we("navigate")) {
2008
+ _e("navigate", "navigate");
1995
2009
  return;
1996
2010
  }
1997
- const k = typeof d.href == "string" ? d.href : null;
1998
- if (!k) {
2011
+ const b = typeof c.href == "string" ? c.href : null;
2012
+ if (!b) {
1999
2013
  console.warn(
2000
2014
  `[LiveLayer] Agent emitted "navigate" without href. Skipping. Check your agent's tool schema. See https://livelayer.studio/docs/errors/navigate-missing-href`
2001
2015
  );
2002
2016
  return;
2003
2017
  }
2004
- if (Je.current) {
2018
+ if (Ye.current) {
2005
2019
  try {
2006
- Je.current(k);
2007
- } catch (I) {
2020
+ Ye.current(b);
2021
+ } catch (k) {
2008
2022
  console.warn(
2009
- `[LiveLayer] onNavigate threw for "${k}". Falling back. Error:`,
2010
- I
2023
+ `[LiveLayer] onNavigate threw for "${b}". Falling back. Error:`,
2024
+ k
2011
2025
  );
2012
2026
  }
2013
2027
  return;
2014
2028
  }
2015
2029
  if (typeof document < "u") {
2016
- const I = document.querySelector(
2017
- `a[href="${k.replace(/"/g, '\\"')}"]`
2030
+ const k = document.querySelector(
2031
+ `a[href="${b.replace(/"/g, '\\"')}"]`
2018
2032
  );
2019
- if (I) {
2020
- I.click();
2033
+ if (k) {
2034
+ k.click();
2021
2035
  return;
2022
2036
  }
2023
2037
  }
2024
2038
  if (typeof window < "u" && typeof history < "u")
2025
2039
  try {
2026
- history.pushState({}, "", k), window.dispatchEvent(new PopStateEvent("popstate"));
2027
- } catch (I) {
2040
+ history.pushState({}, "", b), window.dispatchEvent(new PopStateEvent("popstate"));
2041
+ } catch (k) {
2028
2042
  console.warn(
2029
- `[LiveLayer] history.pushState fallback failed for "${k}". Pass an onNavigate prop to use your router directly. See https://livelayer.studio/docs/react/navigation`,
2030
- I
2043
+ `[LiveLayer] history.pushState fallback failed for "${b}". Pass an onNavigate prop to use your router directly. See https://livelayer.studio/docs/react/navigation`,
2044
+ k
2031
2045
  );
2032
2046
  }
2033
2047
  return;
2034
2048
  }
2035
- if (d.type === "scroll_to") {
2036
- if (!ve("scroll")) {
2037
- be("scroll_to", "scroll");
2049
+ if (c.type === "scroll_to") {
2050
+ if (!we("scroll")) {
2051
+ _e("scroll_to", "scroll");
2038
2052
  return;
2039
2053
  }
2040
- const k = typeof d.selector == "string" ? d.selector : null;
2041
- if (!k) return;
2042
- const I = d.behavior === "instant" ? "instant" : "smooth";
2043
- if (Oe.current) {
2054
+ const b = typeof c.selector == "string" ? c.selector : null;
2055
+ if (!b) return;
2056
+ const k = c.behavior === "instant" ? "instant" : "smooth";
2057
+ if (Ue.current) {
2044
2058
  try {
2045
- Oe.current(
2046
- k,
2047
- I
2059
+ Ue.current(
2060
+ b,
2061
+ k
2048
2062
  );
2049
- } catch (D) {
2050
- console.warn("[LiveLayer] onScrollToSelector threw.", D);
2063
+ } catch (R) {
2064
+ console.warn("[LiveLayer] onScrollToSelector threw.", R);
2051
2065
  }
2052
2066
  return;
2053
2067
  }
2054
2068
  if (typeof document < "u") {
2055
- let D = null;
2069
+ let R = null;
2056
2070
  try {
2057
- D = document.querySelector(k);
2071
+ R = document.querySelector(b);
2058
2072
  } catch {
2059
2073
  console.warn(
2060
- `[LiveLayer] scroll_to: invalid selector "${k}".`
2074
+ `[LiveLayer] scroll_to: invalid selector "${b}".`
2061
2075
  );
2062
2076
  return;
2063
2077
  }
2064
- if (!D) {
2078
+ if (!R) {
2065
2079
  console.warn(
2066
- `[LiveLayer] scroll_to: no element matched "${k}". The user may be on a different page. See https://livelayer.studio/docs/errors/scroll-no-match`
2080
+ `[LiveLayer] scroll_to: no element matched "${b}". The user may be on a different page. See https://livelayer.studio/docs/errors/scroll-no-match`
2067
2081
  );
2068
2082
  return;
2069
2083
  }
2070
- D.scrollIntoView({
2071
- behavior: I,
2084
+ R.scrollIntoView({
2085
+ behavior: k,
2072
2086
  block: "start"
2073
2087
  });
2074
2088
  }
2075
2089
  return;
2076
2090
  }
2077
- if (d.type === "request_page_context") {
2078
- if (!ve("read_page")) {
2079
- be("request_page_context", "read_page");
2091
+ if (c.type === "request_page_context") {
2092
+ if (!we("read_page")) {
2093
+ _e("request_page_context", "read_page");
2080
2094
  return;
2081
2095
  }
2082
- const k = typeof d.requestId == "string" ? d.requestId : void 0, I = (Z = ne.current) == null ? void 0 : Z.call(ne), D = (V) => {
2083
- const P = I, Y = P == null ? void 0 : P.localParticipant;
2084
- if (Y != null && Y.publishData)
2096
+ const b = typeof c.requestId == "string" ? c.requestId : void 0, k = (ue = oe.current) == null ? void 0 : ue.call(oe), R = (j) => {
2097
+ const T = k, F = T == null ? void 0 : T.localParticipant;
2098
+ if (F != null && F.publishData)
2085
2099
  try {
2086
- const O = k ? { ...V, requestId: k } : V, Q = new TextEncoder().encode(JSON.stringify(O));
2087
- Y.publishData(Q, { reliable: !0 });
2088
- } catch (O) {
2089
- console.warn("[LiveLayer] publishData failed.", O);
2100
+ const z = b ? { ...j, requestId: b } : j, ee = new TextEncoder().encode(JSON.stringify(z));
2101
+ F.publishData(ee, { reliable: !0 });
2102
+ } catch (z) {
2103
+ console.warn("[LiveLayer] publishData failed.", z);
2090
2104
  }
2091
- }, $ = yt.current, j = gt.current;
2105
+ }, N = ct.current, W = _t.current;
2092
2106
  try {
2093
- if (j) {
2094
- const V = j($);
2095
- if (V instanceof Promise) {
2096
- D({ type: "page_context_pending" }), V.then((P) => D({ type: "page_context", context: P })).catch((P) => {
2107
+ if (W) {
2108
+ const j = W(N);
2109
+ if (j instanceof Promise) {
2110
+ R({ type: "page_context_pending" }), j.then((T) => R({ type: "page_context", context: T })).catch((T) => {
2097
2111
  console.warn(
2098
2112
  "[LiveLayer] getPageContext rejected; falling back to default walker.",
2099
- P
2100
- ), D({
2113
+ T
2114
+ ), R({
2101
2115
  type: "page_context",
2102
- context: kt($)
2116
+ context: mt(N)
2103
2117
  });
2104
2118
  });
2105
2119
  return;
2106
2120
  }
2107
- D({ type: "page_context", context: V });
2121
+ R({ type: "page_context", context: j });
2108
2122
  return;
2109
2123
  }
2110
- D({
2124
+ R({
2111
2125
  type: "page_context",
2112
- context: kt($)
2126
+ context: mt(N)
2113
2127
  });
2114
- } catch (V) {
2128
+ } catch (j) {
2115
2129
  console.warn(
2116
2130
  "[LiveLayer] page-context extraction threw. Sending empty context.",
2117
- V
2118
- ), D({
2131
+ j
2132
+ ), R({
2119
2133
  type: "page_context",
2120
- context: { url: "", title: "", pathname: "/", regions: [], visibleText: "", visibleLinks: [], visibleFields: [], forms: [], extras: $ }
2134
+ context: { url: "", title: "", pathname: "/", regions: [], visibleText: "", visibleLinks: [], visibleFields: [], forms: [], extras: N }
2121
2135
  });
2122
2136
  }
2123
2137
  return;
2124
2138
  }
2125
- if (d.type === "scroll_page") {
2126
- if (!ve("scroll")) {
2127
- be("scroll_page", "scroll");
2139
+ if (c.type === "scroll_page") {
2140
+ if (!we("scroll")) {
2141
+ _e("scroll_page", "scroll");
2128
2142
  return;
2129
2143
  }
2130
- const k = d.direction;
2131
- if (k !== "up" && k !== "down" && k !== "top" && k !== "bottom") {
2144
+ const b = c.direction;
2145
+ if (b !== "up" && b !== "down" && b !== "top" && b !== "bottom") {
2132
2146
  console.warn(
2133
- `[LiveLayer] scroll_page: invalid direction "${String(k)}". Expected up | down | top | bottom.`
2147
+ `[LiveLayer] scroll_page: invalid direction "${String(b)}". Expected up | down | top | bottom.`
2134
2148
  );
2135
2149
  return;
2136
2150
  }
2137
- const I = d.behavior === "instant" ? "instant" : "smooth";
2151
+ const k = c.behavior === "instant" ? "instant" : "smooth";
2138
2152
  if (p.current) {
2139
2153
  try {
2140
2154
  p.current(
2141
- k,
2142
- I
2155
+ b,
2156
+ k
2143
2157
  );
2144
- } catch (P) {
2145
- console.warn("[LiveLayer] onScrollPage threw.", P);
2158
+ } catch (T) {
2159
+ console.warn("[LiveLayer] onScrollPage threw.", T);
2146
2160
  }
2147
2161
  return;
2148
2162
  }
2149
2163
  if (typeof window > "u") return;
2150
- const D = { behavior: I }, $ = Nr(), j = (P) => {
2151
- $ instanceof Window ? $.scrollBy({ top: P, ...D }) : $.scrollBy({ top: P, ...D });
2152
- }, V = (P) => {
2153
- $ instanceof Window ? $.scrollTo({ top: P, ...D }) : $.scrollTo({ top: P, ...D });
2164
+ const R = { behavior: k }, N = Rr(), W = (T) => {
2165
+ N instanceof Window ? N.scrollBy({ top: T, ...R }) : N.scrollBy({ top: T, ...R });
2166
+ }, j = (T) => {
2167
+ N instanceof Window ? N.scrollTo({ top: T, ...R }) : N.scrollTo({ top: T, ...R });
2154
2168
  };
2155
- k === "up" ? j(-Qt($)) : k === "down" ? j(Qt($)) : V(k === "top" ? 0 : Ar($));
2169
+ b === "up" ? W(-tn(N)) : b === "down" ? W(tn(N)) : j(b === "top" ? 0 : Mr(N));
2156
2170
  return;
2157
2171
  }
2158
- if (d.type === "click") {
2159
- if (!ve("click")) {
2160
- be("click", "click");
2172
+ if (c.type === "click") {
2173
+ if (!we("click")) {
2174
+ _e("click", "click");
2161
2175
  return;
2162
2176
  }
2163
- const k = typeof d.selector == "string" ? d.selector : null;
2164
- if (!k) {
2177
+ const b = typeof c.selector == "string" ? c.selector : null;
2178
+ if (!b) {
2165
2179
  console.warn("[LiveLayer] click: missing selector.");
2166
2180
  return;
2167
2181
  }
2168
2182
  if (K.current) {
2169
2183
  try {
2170
- K.current(k);
2171
- } catch (D) {
2172
- console.warn("[LiveLayer] onClick threw.", D);
2184
+ K.current(b);
2185
+ } catch (R) {
2186
+ console.warn("[LiveLayer] onClick threw.", R);
2173
2187
  }
2174
2188
  return;
2175
2189
  }
2176
2190
  if (typeof document > "u") return;
2177
- let I = null;
2191
+ let k = null;
2178
2192
  try {
2179
- I = document.querySelector(k);
2193
+ k = document.querySelector(b);
2180
2194
  } catch {
2181
2195
  console.warn(
2182
- `[LiveLayer] click: invalid selector "${k}".`
2196
+ `[LiveLayer] click: invalid selector "${b}".`
2183
2197
  );
2184
2198
  return;
2185
2199
  }
2186
- if (!I) {
2200
+ if (!k) {
2187
2201
  console.warn(
2188
- `[LiveLayer] click: no element matched "${k}". See https://livelayer.studio/docs/errors/click-no-match`
2202
+ `[LiveLayer] click: no element matched "${b}". See https://livelayer.studio/docs/errors/click-no-match`
2189
2203
  );
2190
2204
  return;
2191
2205
  }
2192
- if (I.closest('[data-ll-private="true"], .ll-widget')) {
2206
+ if (k.closest('[data-ll-private="true"], .ll-widget')) {
2193
2207
  console.warn(
2194
2208
  "[LiveLayer] click: refusing to click element inside a private subtree."
2195
2209
  );
2196
2210
  return;
2197
2211
  }
2198
- (Se = I.click) == null || Se.call(I);
2212
+ (te = k.click) == null || te.call(k);
2199
2213
  return;
2200
2214
  }
2201
- if (d.type === "fill_form" || d.type === "focus_field") {
2202
- if (!ve("fill_forms")) {
2203
- be(d.type, "fill_forms");
2215
+ if (c.type === "fill_form" || c.type === "focus_field") {
2216
+ if (!we("fill_forms")) {
2217
+ _e(c.type, "fill_forms");
2204
2218
  return;
2205
2219
  }
2206
2220
  if (typeof document > "u") return;
2207
- const k = typeof d.requestId == "string" ? d.requestId : void 0, I = (fe = ne.current) == null ? void 0 : fe.call(ne), D = (O) => {
2208
- if (d.type !== "fill_form") return;
2209
- const Q = I, se = Q == null ? void 0 : Q.localParticipant;
2210
- if (se != null && se.publishData)
2221
+ const b = typeof c.requestId == "string" ? c.requestId : void 0, k = (xe = oe.current) == null ? void 0 : xe.call(oe), R = (z) => {
2222
+ if (c.type !== "fill_form") return;
2223
+ const ee = k, fe = ee == null ? void 0 : ee.localParticipant;
2224
+ if (fe != null && fe.publishData)
2211
2225
  try {
2212
- const Ce = k ? { ...O, requestId: k } : O, hn = new TextEncoder().encode(JSON.stringify(Ce));
2213
- se.publishData(hn, { reliable: !0 });
2214
- } catch (Ce) {
2215
- console.warn("[LiveLayer] publishData failed.", Ce);
2226
+ const Ne = b ? { ...z, requestId: b } : z, yn = new TextEncoder().encode(JSON.stringify(Ne));
2227
+ fe.publishData(yn, { reliable: !0 });
2228
+ } catch (Ne) {
2229
+ console.warn("[LiveLayer] publishData failed.", Ne);
2216
2230
  }
2217
- }, $ = typeof d.formId == "string" ? d.formId : null;
2218
- if (!$) {
2219
- console.warn(`[LiveLayer] ${d.type}: missing formId.`), D({ type: "fill_form_result", ok: !1, reason: "missing formId" });
2231
+ }, N = typeof c.formId == "string" ? c.formId : null;
2232
+ if (!N) {
2233
+ console.warn(`[LiveLayer] ${c.type}: missing formId.`), R({ type: "fill_form_result", ok: !1, reason: "missing formId" });
2220
2234
  return;
2221
2235
  }
2222
- const j = document.querySelector(
2223
- `[data-ll-form="${$.replace(/"/g, '\\"')}"]`
2236
+ const W = document.querySelector(
2237
+ `[data-ll-form="${N.replace(/"/g, '\\"')}"]`
2224
2238
  );
2225
- if (!j) {
2239
+ if (!W) {
2226
2240
  console.warn(
2227
- `[LiveLayer] ${d.type}: no form with data-ll-form="${$}". Tag your form with <LiveLayerForm id> or data-ll-form. See https://livelayer.studio/docs/react/forms`
2228
- ), D({
2241
+ `[LiveLayer] ${c.type}: no form with data-ll-form="${N}". Tag your form with <LiveLayerForm id> or data-ll-form. See https://livelayer.studio/docs/react/forms`
2242
+ ), R({
2229
2243
  type: "fill_form_result",
2230
2244
  ok: !1,
2231
- reason: `no form with data-ll-form="${$}" on this page`,
2232
- formId: $
2245
+ reason: `no form with data-ll-form="${N}" on this page`,
2246
+ formId: N
2233
2247
  });
2234
2248
  return;
2235
2249
  }
2236
- if (j.closest('[data-ll-private="true"], .ll-widget')) {
2250
+ if (W.closest('[data-ll-private="true"], .ll-widget')) {
2237
2251
  console.warn(
2238
- `[LiveLayer] ${d.type}: refusing to touch a form in a private subtree.`
2239
- ), D({
2252
+ `[LiveLayer] ${c.type}: refusing to touch a form in a private subtree.`
2253
+ ), R({
2240
2254
  type: "fill_form_result",
2241
2255
  ok: !1,
2242
2256
  reason: "form is in a private subtree (data-ll-private)",
2243
- formId: $
2257
+ formId: N
2244
2258
  });
2245
2259
  return;
2246
2260
  }
2247
- if (d.type === "focus_field") {
2248
- const O = typeof d.fieldName == "string" ? d.fieldName : null;
2249
- if (!O) {
2261
+ if (c.type === "focus_field") {
2262
+ const z = typeof c.fieldName == "string" ? c.fieldName : null;
2263
+ if (!z) {
2250
2264
  console.warn("[LiveLayer] focus_field: missing fieldName.");
2251
2265
  return;
2252
2266
  }
2253
- const Q = j.querySelector(`[data-ll-field="${O.replace(/"/g, '\\"')}"]`);
2254
- if (!Q) {
2267
+ const ee = W.querySelector(`[data-ll-field="${z.replace(/"/g, '\\"')}"]`);
2268
+ if (!ee) {
2255
2269
  console.warn(
2256
- `[LiveLayer] focus_field: no field "${O}" in form "${$}".`
2270
+ `[LiveLayer] focus_field: no field "${z}" in form "${N}".`
2257
2271
  );
2258
2272
  return;
2259
2273
  }
2260
- if (!pt(Q)) {
2274
+ if (!bt(ee)) {
2261
2275
  console.warn(
2262
- `[LiveLayer] focus_field: field "${O}" is privacy-protected and not focusable.`
2276
+ `[LiveLayer] focus_field: field "${z}" is privacy-protected and not focusable.`
2263
2277
  );
2264
2278
  return;
2265
2279
  }
2266
- Q.focus();
2280
+ ee.focus();
2267
2281
  return;
2268
2282
  }
2269
- const V = d.values && typeof d.values == "object" ? d.values : null;
2270
- if (!V) {
2271
- console.warn("[LiveLayer] fill_form: missing or invalid values."), D({
2283
+ const j = c.values && typeof c.values == "object" ? c.values : null;
2284
+ if (!j) {
2285
+ console.warn("[LiveLayer] fill_form: missing or invalid values."), R({
2272
2286
  type: "fill_form_result",
2273
2287
  ok: !1,
2274
2288
  reason: "missing or invalid values",
2275
- formId: $
2289
+ formId: N
2276
2290
  });
2277
2291
  return;
2278
2292
  }
2279
- const P = [], Y = [];
2280
- for (const [O, Q] of Object.entries(V)) {
2281
- if (typeof Q != "string") continue;
2282
- const se = j.querySelector(`[data-ll-field="${O.replace(/"/g, '\\"')}"]`);
2283
- if (!se) {
2293
+ const T = [], F = [];
2294
+ for (const [z, ee] of Object.entries(j)) {
2295
+ if (typeof ee != "string") continue;
2296
+ const fe = W.querySelector(`[data-ll-field="${z.replace(/"/g, '\\"')}"]`);
2297
+ if (!fe) {
2284
2298
  console.warn(
2285
- `[LiveLayer] fill_form: no field "${O}" in form "${$}". Skipping.`
2286
- ), Y.push(O);
2299
+ `[LiveLayer] fill_form: no field "${z}" in form "${N}". Skipping.`
2300
+ ), F.push(z);
2287
2301
  continue;
2288
2302
  }
2289
- if (!pt(se)) {
2303
+ if (!bt(fe)) {
2290
2304
  console.warn(
2291
- `[LiveLayer] fill_form: field "${O}" is privacy-protected (password / cc-* / private). Skipping.`
2292
- ), Y.push(O);
2305
+ `[LiveLayer] fill_form: field "${z}" is privacy-protected (password / cc-* / private). Skipping.`
2306
+ ), F.push(z);
2293
2307
  continue;
2294
2308
  }
2295
2309
  try {
2296
- Lr(se, Q), P.push(O);
2297
- } catch (Ce) {
2310
+ Cr(fe, ee), T.push(z);
2311
+ } catch (Ne) {
2298
2312
  console.warn(
2299
- `[LiveLayer] fill_form: failed to set "${O}".`,
2300
- Ce
2301
- ), Y.push(O);
2313
+ `[LiveLayer] fill_form: failed to set "${z}".`,
2314
+ Ne
2315
+ ), F.push(z);
2302
2316
  }
2303
2317
  }
2304
- D({
2318
+ R({
2305
2319
  type: "fill_form_result",
2306
- ok: P.length > 0,
2307
- formId: $,
2308
- filled: P,
2309
- skipped: Y,
2310
- reason: P.length === 0 ? `none of the requested fields exist on this form (skipped: ${Y.join(", ")})` : void 0
2320
+ ok: T.length > 0,
2321
+ formId: N,
2322
+ filled: T,
2323
+ skipped: F,
2324
+ reason: T.length === 0 ? `none of the requested fields exist on this form (skipped: ${F.join(", ")})` : void 0
2311
2325
  });
2312
2326
  return;
2313
2327
  }
2314
- if (d.type === "submit_form") {
2315
- if (!ve("submit_forms")) {
2316
- be("submit_form", "submit_forms");
2328
+ if (c.type === "submit_form") {
2329
+ if (!we("submit_forms")) {
2330
+ _e("submit_form", "submit_forms");
2317
2331
  return;
2318
2332
  }
2319
2333
  if (typeof document > "u") return;
2320
- const k = typeof d.formId == "string" ? d.formId : null;
2321
- if (!k) {
2334
+ const b = typeof c.formId == "string" ? c.formId : null;
2335
+ if (!b) {
2322
2336
  console.warn("[LiveLayer] submit_form: missing formId.");
2323
2337
  return;
2324
2338
  }
2325
- const I = document.querySelector(
2326
- `[data-ll-form="${k.replace(/"/g, '\\"')}"]`
2339
+ const k = document.querySelector(
2340
+ `[data-ll-form="${b.replace(/"/g, '\\"')}"]`
2327
2341
  );
2328
- if (!I) {
2342
+ if (!k) {
2329
2343
  console.warn(
2330
- `[LiveLayer] submit_form: no form with data-ll-form="${k}".`
2344
+ `[LiveLayer] submit_form: no form with data-ll-form="${b}".`
2331
2345
  );
2332
2346
  return;
2333
2347
  }
2334
- if (I.closest('[data-ll-private="true"], .ll-widget')) {
2348
+ if (k.closest('[data-ll-private="true"], .ll-widget')) {
2335
2349
  console.warn(
2336
2350
  "[LiveLayer] submit_form: refusing to submit a form in a private subtree."
2337
2351
  );
2338
2352
  return;
2339
2353
  }
2340
- const D = typeof d.requestId == "string" ? d.requestId : void 0, $ = (He = ne.current) == null ? void 0 : He.call(ne), j = (Y) => {
2341
- const O = $, Q = O == null ? void 0 : O.localParticipant;
2342
- if (Q != null && Q.publishData)
2354
+ const R = typeof c.requestId == "string" ? c.requestId : void 0, N = (ke = oe.current) == null ? void 0 : ke.call(oe), W = (F) => {
2355
+ const z = N, ee = z == null ? void 0 : z.localParticipant;
2356
+ if (ee != null && ee.publishData)
2343
2357
  try {
2344
- const se = D ? { ...Y, requestId: D } : Y, Ce = new TextEncoder().encode(JSON.stringify(se));
2345
- Q.publishData(Ce, { reliable: !0 });
2358
+ const fe = R ? { ...F, requestId: R } : F, Ne = new TextEncoder().encode(JSON.stringify(fe));
2359
+ ee.publishData(Ne, { reliable: !0 });
2346
2360
  } catch {
2347
2361
  }
2348
2362
  };
2349
- let V = !1;
2350
- const P = () => {
2351
- V = !0, j({ type: "form_submitted", formId: k });
2363
+ let j = !1;
2364
+ const T = () => {
2365
+ j = !0, W({ type: "form_submitted", formId: b });
2352
2366
  };
2353
- I.addEventListener("submit", P, { once: !0 });
2367
+ k.addEventListener("submit", T, { once: !0 });
2354
2368
  try {
2355
- typeof I.requestSubmit == "function" ? I.requestSubmit() : I.submit();
2356
- } catch (Y) {
2357
- console.warn("[LiveLayer] submit_form: requestSubmit threw.", Y), I.removeEventListener("submit", P), j({
2369
+ typeof k.requestSubmit == "function" ? k.requestSubmit() : k.submit();
2370
+ } catch (F) {
2371
+ console.warn("[LiveLayer] submit_form: requestSubmit threw.", F), k.removeEventListener("submit", T), W({
2358
2372
  type: "form_submit_blocked",
2359
- formId: k,
2373
+ formId: b,
2360
2374
  reason: "exception"
2361
2375
  });
2362
2376
  return;
2363
2377
  }
2364
2378
  setTimeout(() => {
2365
- V || (I.removeEventListener("submit", P), j({
2379
+ j || (k.removeEventListener("submit", T), W({
2366
2380
  type: "form_submit_blocked",
2367
- formId: k,
2381
+ formId: b,
2368
2382
  reason: "validation"
2369
2383
  }));
2370
2384
  }, 500);
2371
2385
  return;
2372
2386
  }
2373
- if (d.type === "request_routes") {
2374
- if (!ve("read_page")) {
2375
- be("request_routes", "read_page");
2387
+ if (c.type === "request_routes") {
2388
+ if (!we("read_page")) {
2389
+ _e("request_routes", "read_page");
2376
2390
  return;
2377
2391
  }
2378
- const k = typeof d.requestId == "string" ? d.requestId : void 0, D = (we = ne.current) == null ? void 0 : we.call(ne), $ = D == null ? void 0 : D.localParticipant;
2379
- if (!($ != null && $.publishData)) return;
2380
- const j = (P) => {
2392
+ const b = typeof c.requestId == "string" ? c.requestId : void 0, R = (X = oe.current) == null ? void 0 : X.call(oe), N = R == null ? void 0 : R.localParticipant;
2393
+ if (!(N != null && N.publishData)) return;
2394
+ const W = (T) => {
2381
2395
  try {
2382
- const Y = k ? { type: "routes", routes: P, requestId: k } : { type: "routes", routes: P }, O = new TextEncoder().encode(JSON.stringify(Y));
2383
- $.publishData(O, { reliable: !0 });
2384
- } catch (Y) {
2385
- console.warn("[LiveLayer] request_routes: publishData failed.", Y);
2396
+ const F = b ? { type: "routes", routes: T, requestId: b } : { type: "routes", routes: T }, z = new TextEncoder().encode(JSON.stringify(F));
2397
+ N.publishData(z, { reliable: !0 });
2398
+ } catch (F) {
2399
+ console.warn("[LiveLayer] request_routes: publishData failed.", F);
2386
2400
  }
2387
- }, V = vt.current;
2388
- if (V) {
2401
+ }, j = dt.current;
2402
+ if (j) {
2389
2403
  try {
2390
- const P = V(), Y = (O) => {
2391
- if (!Array.isArray(O)) {
2392
- j([]);
2404
+ const T = j(), F = (z) => {
2405
+ if (!Array.isArray(z)) {
2406
+ W([]);
2393
2407
  return;
2394
2408
  }
2395
- j(O.map(vr).slice(0, 200));
2409
+ W(z.map(_r).slice(0, 200));
2396
2410
  };
2397
- P instanceof Promise ? P.then(Y).catch((O) => {
2411
+ T instanceof Promise ? T.then(F).catch((z) => {
2398
2412
  console.warn(
2399
2413
  "[LiveLayer] getRoutes rejected; falling back to DOM walker.",
2400
- O
2401
- ), j(dt());
2402
- }) : Y(P);
2403
- } catch (P) {
2414
+ z
2415
+ ), W(nt());
2416
+ }) : F(T);
2417
+ } catch (T) {
2404
2418
  console.warn(
2405
2419
  "[LiveLayer] getRoutes threw; falling back to DOM walker.",
2406
- P
2407
- ), j(dt());
2420
+ T
2421
+ ), W(nt());
2408
2422
  }
2409
2423
  return;
2410
2424
  }
2411
2425
  try {
2412
- j(dt());
2413
- } catch (P) {
2414
- console.warn("[LiveLayer] request_routes: extractRoutes threw.", P);
2426
+ W(nt());
2427
+ } catch (T) {
2428
+ console.warn("[LiveLayer] request_routes: extractRoutes threw.", T);
2415
2429
  }
2416
2430
  return;
2417
2431
  }
2418
- Rr.has(d.type) || Ie == null || Ie(d);
2432
+ Tr.has(c.type) || Ie == null || Ie(c);
2419
2433
  }
2420
2434
  },
2421
- [Ie, Me]
2422
- ), U = _n({
2423
- agentId: J ? "__controlled__" : Pe,
2424
- baseUrl: i,
2435
+ [Ie, Te]
2436
+ ), V = Ln({
2437
+ agentId: Y ? "__controlled__" : Be,
2438
+ baseUrl: o,
2425
2439
  apiKey: r,
2426
- sessionEndpoint: o,
2440
+ sessionEndpoint: i,
2427
2441
  sessionBody: l,
2428
- onDataMessage: J ? void 0 : Ke
2442
+ onDataMessage: Y ? void 0 : Ke
2429
2443
  });
2430
- N(() => {
2431
- if (J != null && J.subscribeToDataMessages)
2432
- return J.subscribeToDataMessages(Ke);
2433
- }, [J, Ke]), ne.current = () => {
2444
+ M(() => {
2445
+ if (Y != null && Y.subscribeToDataMessages)
2446
+ return Y.subscribeToDataMessages(Ke);
2447
+ }, [Y, Ke]), oe.current = () => {
2434
2448
  var h;
2435
- return (h = U.getRoom) == null ? void 0 : h.call(U);
2436
- }, N(() => {
2437
- var Se;
2438
- if (!de) return;
2439
- const h = (Se = U.getRoom) == null ? void 0 : Se.call(U), d = h == null ? void 0 : h.localParticipant;
2440
- if (!(d != null && d.publishData)) return;
2449
+ return (h = V.getRoom) == null ? void 0 : h.call(V);
2450
+ }, ut.current = () => {
2451
+ var ue, te, xe, ke;
2452
+ const h = Dt.current;
2453
+ if (!h) {
2454
+ console.log("[NAV-DEBUG][widget] pushSnapshot bailed: no pathname");
2455
+ return;
2456
+ }
2457
+ const c = (ue = V.getRoom) == null ? void 0 : ue.call(V), J = c == null ? void 0 : c.localParticipant;
2458
+ if (!(J != null && J.publishData)) {
2459
+ console.log(
2460
+ "[NAV-DEBUG][widget] pushSnapshot bailed: no publishData (not connected)"
2461
+ );
2462
+ return;
2463
+ }
2441
2464
  try {
2442
- const fe = new TextEncoder().encode(
2443
- JSON.stringify({ type: "pathname", pathname: de })
2465
+ J.publishData(
2466
+ new TextEncoder().encode(JSON.stringify({ type: "pathname", pathname: h })),
2467
+ { reliable: !0 }
2444
2468
  );
2445
- d.publishData(fe, { reliable: !0 });
2446
- } catch {
2469
+ } catch (X) {
2470
+ console.warn("[NAV-DEBUG][widget] pushSnapshot pathname threw:", X);
2447
2471
  }
2448
- const Z = setTimeout(async () => {
2449
- var fe;
2472
+ try {
2473
+ const X = mt(ct.current);
2474
+ J.publishData(
2475
+ new TextEncoder().encode(
2476
+ JSON.stringify({ type: "page_context_push", pathname: h, context: X })
2477
+ ),
2478
+ { reliable: !0 }
2479
+ ), console.log(
2480
+ `[NAV-DEBUG][widget] pushSnapshot page_context_push sent (regions=${((te = X.regions) == null ? void 0 : te.length) ?? 0} forms=${((xe = X.forms) == null ? void 0 : xe.length) ?? 0} links=${((ke = X.visibleLinks) == null ? void 0 : ke.length) ?? 0})`
2481
+ );
2482
+ } catch (X) {
2483
+ console.warn("[NAV-DEBUG][widget] pushSnapshot page_context threw:", X);
2484
+ }
2485
+ (async () => {
2450
2486
  try {
2451
- const He = (fe = U.getRoom) == null ? void 0 : fe.call(U), we = He == null ? void 0 : He.localParticipant;
2452
- if (!(we != null && we.publishData)) return;
2453
- const k = kt(yt.current);
2487
+ const X = dt.current;
2488
+ let b = [];
2489
+ if (X) {
2490
+ const k = X(), R = k instanceof Promise ? await k : k;
2491
+ b = Array.isArray(R) ? R.slice(0, 200) : [];
2492
+ } else
2493
+ b = nt();
2494
+ J.publishData(
2495
+ new TextEncoder().encode(JSON.stringify({ type: "routes_push", routes: b })),
2496
+ { reliable: !0 }
2497
+ ), console.log(
2498
+ `[NAV-DEBUG][widget] pushSnapshot routes_push sent (${b.length} routes)`
2499
+ );
2500
+ } catch (X) {
2501
+ console.warn("[NAV-DEBUG][widget] pushSnapshot routes threw:", X);
2502
+ }
2503
+ })();
2504
+ }, M(() => {
2505
+ var ue;
2506
+ if (console.log(
2507
+ `[NAV-DEBUG][widget] pathname-effect fired pathname=${ae} connState=${V.connectionState} t=${Date.now()}`
2508
+ ), !ae) {
2509
+ console.log("[NAV-DEBUG][widget] effect bailed: no pathname");
2510
+ return;
2511
+ }
2512
+ const h = (ue = V.getRoom) == null ? void 0 : ue.call(V), c = h == null ? void 0 : h.localParticipant;
2513
+ if (console.log(
2514
+ `[NAV-DEBUG][widget] immediate-push state: room=${!!h} lp=${!!c} publishData=${!!(c != null && c.publishData)}`
2515
+ ), !(c != null && c.publishData)) {
2516
+ console.log("[NAV-DEBUG][widget] effect bailed: no publishData (not connected yet)");
2517
+ return;
2518
+ }
2519
+ try {
2520
+ const te = new TextEncoder().encode(
2521
+ JSON.stringify({ type: "pathname", pathname: ae })
2522
+ );
2523
+ c.publishData(te, { reliable: !0 }), console.log(`[NAV-DEBUG][widget] pathname push sent (${te.byteLength} bytes)`);
2524
+ } catch (te) {
2525
+ console.warn("[NAV-DEBUG][widget] pathname push threw:", te);
2526
+ }
2527
+ const J = setTimeout(async () => {
2528
+ var te, xe, ke, X;
2529
+ console.log("[NAV-DEBUG][widget] settle timer fired (250ms after pathname-effect)");
2530
+ try {
2531
+ const b = (te = V.getRoom) == null ? void 0 : te.call(V), k = b == null ? void 0 : b.localParticipant;
2532
+ if (console.log(
2533
+ `[NAV-DEBUG][widget] settle-time state: room=${!!b} lp=${!!k} publishData=${!!(k != null && k.publishData)}`
2534
+ ), !(k != null && k.publishData)) {
2535
+ console.log("[NAV-DEBUG][widget] settle bailed: no publishData");
2536
+ return;
2537
+ }
2538
+ const R = mt(ct.current);
2539
+ console.log(
2540
+ `[NAV-DEBUG][widget] page_context built: regions=${((xe = R.regions) == null ? void 0 : xe.length) ?? 0} forms=${((ke = R.forms) == null ? void 0 : ke.length) ?? 0} links=${((X = R.visibleLinks) == null ? void 0 : X.length) ?? 0}`
2541
+ );
2454
2542
  try {
2455
- const I = new TextEncoder().encode(
2456
- JSON.stringify({ type: "page_context_push", pathname: de, context: k })
2543
+ const N = new TextEncoder().encode(
2544
+ JSON.stringify({ type: "page_context_push", pathname: ae, context: R })
2457
2545
  );
2458
- we.publishData(I, { reliable: !0 });
2459
- } catch {
2546
+ k.publishData(N, { reliable: !0 }), console.log(
2547
+ `[NAV-DEBUG][widget] page_context_push SENT (${N.byteLength} bytes)`
2548
+ );
2549
+ } catch (N) {
2550
+ console.warn("[NAV-DEBUG][widget] page_context_push threw:", N);
2460
2551
  }
2461
2552
  try {
2462
- const I = vt.current;
2463
- let D = [];
2464
- if (I) {
2465
- const j = I(), V = j instanceof Promise ? await j : j;
2466
- D = Array.isArray(V) ? V.slice(0, 200) : [];
2553
+ const N = dt.current;
2554
+ let W = [];
2555
+ if (N) {
2556
+ console.log("[NAV-DEBUG][widget] routes: calling custom getRoutes()");
2557
+ const T = N(), F = T instanceof Promise ? await T : T;
2558
+ W = Array.isArray(F) ? F.slice(0, 200) : [], console.log(`[NAV-DEBUG][widget] routes: custom returned ${W.length}`);
2467
2559
  } else
2468
- D = dt();
2469
- const $ = new TextEncoder().encode(
2470
- JSON.stringify({ type: "routes_push", routes: D })
2560
+ console.log("[NAV-DEBUG][widget] routes: walking DOM (no custom getRoutes)"), W = nt(), console.log(`[NAV-DEBUG][widget] routes: DOM walk returned ${W.length}`);
2561
+ const j = new TextEncoder().encode(
2562
+ JSON.stringify({ type: "routes_push", routes: W })
2471
2563
  );
2472
- we.publishData($, { reliable: !0 });
2473
- } catch {
2564
+ k.publishData(j, { reliable: !0 }), console.log(
2565
+ `[NAV-DEBUG][widget] routes_push SENT (${j.byteLength} bytes, ${W.length} routes)`
2566
+ );
2567
+ } catch (N) {
2568
+ console.warn("[NAV-DEBUG][widget] routes_push threw:", N);
2474
2569
  }
2475
- } catch {
2570
+ } catch (b) {
2571
+ console.warn("[NAV-DEBUG][widget] settle outer threw:", b);
2476
2572
  }
2477
2573
  }, 250);
2478
- return () => clearTimeout(Z);
2479
- }, [de, U, U.connectionState]), N(() => {
2480
- var Z;
2574
+ return () => {
2575
+ clearTimeout(J);
2576
+ };
2577
+ }, [ae, V, V.connectionState]), M(() => {
2578
+ var J;
2481
2579
  if (typeof window > "u") return;
2482
- const h = ((Z = window.location) == null ? void 0 : Z.hostname) || "";
2580
+ const h = ((J = window.location) == null ? void 0 : J.hostname) || "";
2483
2581
  if (h === "localhost" || h === "127.0.0.1" || h === "0.0.0.0" || h.endsWith(".local") || h.endsWith(".test"))
2484
- return window.__livelayerSimulateCommand = (Se) => {
2582
+ return window.__livelayerSimulateCommand = (ue) => {
2485
2583
  try {
2486
- Ke(Se);
2487
- } catch (fe) {
2488
- console.warn("[LiveLayer] simulate-command threw:", fe);
2584
+ Ke(ue);
2585
+ } catch (te) {
2586
+ console.warn("[LiveLayer] simulate-command threw:", te);
2489
2587
  }
2490
2588
  }, () => {
2491
2589
  delete window.__livelayerSimulateCommand;
2492
2590
  };
2493
2591
  }, [Ke]);
2494
- const g = ut(() => J ? {
2495
- connectionState: J.connectionState,
2496
- agentState: J.agentState,
2497
- transcript: J.transcript,
2498
- videoElement: J.videoElement,
2499
- audioElement: J.audioElement,
2500
- canResume: J.canResume,
2501
- error: J.error,
2592
+ const g = gt(() => Y ? {
2593
+ connectionState: Y.connectionState,
2594
+ agentState: Y.agentState,
2595
+ transcript: Y.transcript,
2596
+ videoElement: Y.videoElement,
2597
+ audioElement: Y.audioElement,
2598
+ canResume: Y.canResume,
2599
+ error: Y.error,
2502
2600
  agentConfig: null,
2503
2601
  connect: async () => {
2504
- await J.onConnect();
2602
+ await Y.onConnect();
2505
2603
  },
2506
- disconnect: () => J.onDisconnect(),
2604
+ disconnect: () => Y.onDisconnect(),
2507
2605
  // Dummy getRoom for shape compatibility — controlled consumers own the Room.
2508
2606
  // Internal session's getRoom returns null when no real connect has happened,
2509
2607
  // so we reuse its reference for type consistency.
2510
- getRoom: U.getRoom,
2608
+ getRoom: V.getRoom,
2511
2609
  isControlled: !0
2512
2610
  } : {
2513
- connectionState: U.connectionState,
2514
- agentState: U.agentState,
2515
- transcript: U.transcript,
2516
- videoElement: U.videoElement,
2517
- audioElement: U.audioElement,
2518
- canResume: U.canResume,
2519
- error: U.error,
2520
- agentConfig: U.agentConfig,
2521
- connect: U.connect,
2522
- disconnect: U.disconnect,
2523
- getRoom: U.getRoom,
2611
+ connectionState: V.connectionState,
2612
+ agentState: V.agentState,
2613
+ transcript: V.transcript,
2614
+ videoElement: V.videoElement,
2615
+ audioElement: V.audioElement,
2616
+ canResume: V.canResume,
2617
+ error: V.error,
2618
+ agentConfig: V.agentConfig,
2619
+ connect: V.connect,
2620
+ disconnect: V.disconnect,
2621
+ getRoom: V.getRoom,
2524
2622
  isControlled: !1
2525
- }, [J, U]), Nt = A(null);
2526
- N(() => {
2527
- const h = g.videoElement, d = Nt.current;
2528
- if (!(!h || !d))
2529
- return d.appendChild(h), () => {
2530
- h.parentNode === d && d.removeChild(h);
2623
+ }, [Y, V]), Rt = A(null);
2624
+ M(() => {
2625
+ const h = g.videoElement, c = Rt.current;
2626
+ if (!(!h || !c))
2627
+ return c.appendChild(h), () => {
2628
+ h.parentNode === c && c.removeChild(h);
2531
2629
  };
2532
- }, [g.videoElement]), N(() => {
2630
+ }, [g.videoElement]), M(() => {
2533
2631
  const h = g.audioElement;
2534
2632
  if (!h) return;
2535
- Ue.attach(h);
2536
- const d = h.play();
2537
- return d && typeof d.catch == "function" && d.catch((Z) => {
2538
- (Z == null ? void 0 : Z.name) === "NotAllowedError" && he(!0);
2633
+ Ge.attach(h);
2634
+ const c = h.play();
2635
+ return c && typeof c.catch == "function" && c.catch((J) => {
2636
+ (J == null ? void 0 : J.name) === "NotAllowedError" && ge(!0);
2539
2637
  }), () => {
2540
- Ue.detach();
2638
+ Ge.detach();
2541
2639
  };
2542
- }, [g.audioElement]), N(() => {
2640
+ }, [g.audioElement]), M(() => {
2543
2641
  if (g.isControlled || g.connectionState !== "connected") return;
2544
2642
  const h = g.getRoom();
2545
2643
  if (h)
2546
- return te.setupMic(h, { startMuted: !0 }).catch(() => {
2547
- }), le.attachRoom(h), ae.attachRoom(h), pe.refresh(), () => {
2548
- te.teardownMic(), le.teardown(), ae.teardown();
2644
+ return re.setupMic(h, { startMuted: !0 }).catch(() => {
2645
+ }), ce.attachRoom(h), de.attachRoom(h), me.refresh(), () => {
2646
+ re.teardownMic(), ce.teardown(), de.teardown();
2549
2647
  };
2550
2648
  }, [g.isControlled, g.connectionState]);
2551
- const [Xe, wt] = S(!1), _t = A("idle");
2552
- N(() => {
2649
+ const [Xe, kt] = E(!1), Lt = A("idle");
2650
+ M(() => {
2553
2651
  if (g.connectionState === "idle" || g.connectionState === "disconnected") {
2554
- wt(!1), _t.current = "idle";
2652
+ kt(!1), Lt.current = "idle";
2555
2653
  return;
2556
2654
  }
2557
- !Xe && _t.current === "speaking" && g.agentState !== "speaking" && (wt(!0), te.setMuted(!1)), _t.current = g.agentState;
2558
- }, [g.agentState, g.connectionState, Xe]), N(() => {
2655
+ !Xe && Lt.current === "speaking" && g.agentState !== "speaking" && (kt(!0), re.setMuted(!1)), Lt.current = g.agentState;
2656
+ }, [g.agentState, g.connectionState, Xe]), M(() => {
2559
2657
  if (g.connectionState !== "connected" || Xe) return;
2560
2658
  const h = setTimeout(() => {
2561
- wt(!0), te.setMuted(!1);
2659
+ kt(!0), re.setMuted(!1);
2562
2660
  }, 4e3);
2563
2661
  return () => clearTimeout(h);
2564
- }, [g.connectionState, Xe]), N(() => {
2662
+ }, [g.connectionState, Xe]), M(() => {
2565
2663
  const h = g.audioElement;
2566
- h && (h.muted = ze);
2567
- }, [g.audioElement, ze]);
2568
- const nn = L((h) => {
2569
- const d = g.getRoom();
2570
- if (d)
2664
+ h && (h.muted = Oe);
2665
+ }, [g.audioElement, Oe]);
2666
+ const ln = S((h) => {
2667
+ const c = g.getRoom();
2668
+ if (c)
2571
2669
  try {
2572
- const Z = new TextEncoder().encode(
2670
+ const J = new TextEncoder().encode(
2573
2671
  JSON.stringify({ type: "user_message", text: h })
2574
2672
  );
2575
- d.localParticipant.publishData(Z, { reliable: !0 });
2673
+ c.localParticipant.publishData(J, { reliable: !0 });
2576
2674
  } catch {
2577
2675
  }
2578
- }, [g]), rn = L(() => {
2579
- lt((h) => !h);
2676
+ }, [g]), an = S(() => {
2677
+ st((h) => !h);
2580
2678
  }, []);
2581
- N(() => {
2582
- Re == null || Re(g.connectionState), g.connectionState === "connected" ? ce == null || ce() : g.connectionState === "disconnected" && (xe == null || xe());
2583
- }, [g.connectionState, ce, xe, Re]), N(() => {
2584
- Ne == null || Ne(g.transcript);
2585
- }, [g.transcript, Ne]), N(() => {
2586
- Ae == null || Ae(g.agentState);
2587
- }, [g.agentState, Ae]);
2588
- const At = A(!1);
2589
- N(() => {
2590
- g.isControlled || !c || At.current || Te && g.connectionState === "idle" && (At.current = !0, g.connect());
2591
- }, [c, g.connectionState, g, Te]);
2592
- const on = L(
2679
+ M(() => {
2680
+ Me == null || Me(g.connectionState), g.connectionState === "connected" ? pe == null || pe() : g.connectionState === "disconnected" && (Se == null || Se());
2681
+ }, [g.connectionState, pe, Se, Me]), M(() => {
2682
+ De == null || De(g.transcript);
2683
+ }, [g.transcript, De]), M(() => {
2684
+ Re == null || Re(g.agentState);
2685
+ }, [g.agentState, Re]);
2686
+ const Mt = A(!1);
2687
+ M(() => {
2688
+ g.isControlled || !d || Mt.current || Pe && g.connectionState === "idle" && (Mt.current = !0, g.connect());
2689
+ }, [d, g.connectionState, g, Pe]);
2690
+ const sn = S(
2593
2691
  (h) => {
2594
- const d = E == null ? void 0 : E.find((Z) => Z.id === h);
2595
- d && (Ye(!1), h !== X && (je(!0), g.disconnect(), Fe || De(h), v == null || v(d)));
2692
+ const c = D == null ? void 0 : D.find((J) => J.id === h);
2693
+ c && (Je(!1), h !== Q && (Fe(!0), g.disconnect(), We || $e(h), v == null || v(c)));
2596
2694
  },
2597
2695
  [
2598
- E,
2599
- X,
2696
+ D,
2697
+ Q,
2600
2698
  g,
2601
- Fe,
2699
+ We,
2602
2700
  v
2603
2701
  ]
2604
2702
  );
2605
- N(() => {
2606
- me && g.connectionState === "connected" && je(!1);
2607
- }, [g.connectionState, me]), N(() => {
2608
- if (!Ve) return;
2609
- const h = (d) => {
2610
- d.key === "Escape" && Ye(!1);
2703
+ M(() => {
2704
+ ye && g.connectionState === "connected" && Fe(!1);
2705
+ }, [g.connectionState, ye]), M(() => {
2706
+ if (!je) return;
2707
+ const h = (c) => {
2708
+ c.key === "Escape" && Je(!1);
2611
2709
  };
2612
2710
  return window.addEventListener("keydown", h), () => window.removeEventListener("keydown", h);
2613
- }, [Ve]);
2614
- const ln = !!T || !!(ee != null && ee.avatarImageUrl) || g.isControlled, Ge = Nn(Pe, i, ln);
2615
- re === void 0 && ((Mt = Ge.info) != null && Mt.capabilities) && (bt.current = Ge.info.capabilities);
2616
- const at = (ee == null ? void 0 : ee.name) ?? q ?? ((It = g.agentConfig) == null ? void 0 : It.name) ?? ((Tt = Ge.info) == null ? void 0 : Tt.name) ?? "Live Layer", xt = (ee == null ? void 0 : ee.avatarImageUrl) ?? T ?? ((Dt = g.agentConfig) == null ? void 0 : Dt.avatarImageUrl) ?? ((Pt = Ge.info) == null ? void 0 : Pt.avatarImageUrl) ?? null, an = w ?? (($t = g.agentConfig) == null ? void 0 : $t.idleLoopUrl) ?? ((zt = Ge.info) == null ? void 0 : zt.idleLoopUrl) ?? null, sn = H ?? null, cn = L(() => ue("expanded"), [ue]), dn = L(
2617
- () => ue("minimized"),
2618
- [ue]
2619
- ), Rt = L(() => {
2620
- g.disconnect(), ue("hidden");
2621
- }, [g, ue]), un = L(() => {
2711
+ }, [je]);
2712
+ const cn = !!$ || !!(ne != null && ne.avatarImageUrl) || g.isControlled, Qe = Rn(Be, o, cn);
2713
+ ie === void 0 && ((It = Qe.info) != null && It.capabilities) && (xt.current = Qe.info.capabilities);
2714
+ const ft = (ne == null ? void 0 : ne.name) ?? U ?? ((Pt = g.agentConfig) == null ? void 0 : Pt.name) ?? (($t = Qe.info) == null ? void 0 : $t.name) ?? "Live Layer", St = (ne == null ? void 0 : ne.avatarImageUrl) ?? $ ?? ((Bt = g.agentConfig) == null ? void 0 : Bt.avatarImageUrl) ?? ((zt = Qe.info) == null ? void 0 : zt.avatarImageUrl) ?? null, dn = _ ?? ((Ot = g.agentConfig) == null ? void 0 : Ot.idleLoopUrl) ?? ((Ut = Qe.info) == null ? void 0 : Ut.idleLoopUrl) ?? null, un = O ?? null, fn = S(() => he("expanded"), [he]), pn = S(
2715
+ () => he("minimized"),
2716
+ [he]
2717
+ ), Tt = S(() => {
2718
+ g.disconnect(), he("hidden");
2719
+ }, [g, he]), hn = S(() => {
2622
2720
  const h = g.audioElement;
2623
- h && h.play().then(() => he(!1)).catch(() => {
2721
+ h && h.play().then(() => ge(!1)).catch(() => {
2624
2722
  });
2625
- }, [g.audioElement]), fn = L(() => {
2626
- he(!1), g.connect();
2627
- }, [g]), Qe = {
2628
- ...mt,
2629
- zIndex: ot
2723
+ }, [g.audioElement]), mn = S(() => {
2724
+ ge(!1), g.connect();
2725
+ }, [g]), Ze = {
2726
+ ...wt,
2727
+ zIndex: at
2630
2728
  };
2631
- m.primaryColor && (Qe["--ll-color-primary"] = m.primaryColor), m.accentColor && (Qe["--ll-color-accent"] = m.accentColor), m.backgroundColor && (Qe["--ll-color-bg"] = m.backgroundColor), m.textColor && (Qe["--ll-color-fg"] = m.textColor);
2632
- const pn = [
2729
+ m.primaryColor && (Ze["--ll-color-primary"] = m.primaryColor), m.accentColor && (Ze["--ll-color-accent"] = m.accentColor), m.backgroundColor && (Ze["--ll-color-bg"] = m.backgroundColor), m.textColor && (Ze["--ll-color-fg"] = m.textColor);
2730
+ const gn = [
2633
2731
  "ll-widget",
2634
- `ll-widget--${oe}`,
2635
- `ll-widget--${Le ? "mobile" : "desktop"}`,
2636
- ht
2732
+ `ll-widget--${se}`,
2733
+ `ll-widget--${Ce ? "mobile" : "desktop"}`,
2734
+ vt
2637
2735
  ].filter(Boolean).join(" ");
2638
- return Te ? /* @__PURE__ */ _(
2736
+ return Pe ? /* @__PURE__ */ x(
2639
2737
  "div",
2640
2738
  {
2641
- className: pn,
2642
- style: Qe,
2643
- "data-display-mode": oe,
2644
- "data-position": b,
2739
+ className: gn,
2740
+ style: Ze,
2741
+ "data-display-mode": se,
2742
+ "data-position": w,
2645
2743
  children: [
2646
- oe === "hidden" && /* @__PURE__ */ n(
2647
- Gn,
2744
+ se === "hidden" && /* @__PURE__ */ n(
2745
+ er,
2648
2746
  {
2649
- position: b,
2650
- isMobile: Le,
2747
+ position: w,
2748
+ isMobile: Ce,
2651
2749
  isSpeaking: g.agentState === "speaking",
2652
- onExpand: () => ue("expanded"),
2653
- label: `Open ${at} widget`,
2654
- avatarImageUrl: xt,
2655
- agentName: at
2750
+ onExpand: () => he("expanded"),
2751
+ label: `Open ${ft} widget`,
2752
+ avatarImageUrl: St,
2753
+ agentName: ft
2656
2754
  }
2657
2755
  ),
2658
- oe === "minimized" && /* @__PURE__ */ n(
2659
- Zn,
2756
+ se === "minimized" && /* @__PURE__ */ n(
2757
+ nr,
2660
2758
  {
2661
- position: b,
2662
- isMobile: Le,
2663
- agentName: at,
2664
- avatarImageUrl: xt,
2759
+ position: w,
2760
+ isMobile: Ce,
2761
+ agentName: ft,
2762
+ avatarImageUrl: St,
2665
2763
  agentState: g.agentState,
2666
- isMuted: te.isMuted,
2667
- audioLevel: Ue,
2668
- onExpand: cn,
2669
- onToggleMute: te.toggleMute,
2670
- onClose: Rt
2764
+ isMuted: re.isMuted,
2765
+ audioLevel: Ge,
2766
+ onExpand: fn,
2767
+ onToggleMute: re.toggleMute,
2768
+ onClose: Tt
2671
2769
  }
2672
2770
  ),
2673
- oe === "expanded" && /* @__PURE__ */ n(
2674
- tr,
2771
+ se === "expanded" && /* @__PURE__ */ n(
2772
+ or,
2675
2773
  {
2676
- position: b,
2677
- isMobile: Le,
2678
- agentName: at,
2679
- avatarImageUrl: xt,
2680
- idleLoopUrl: an,
2681
- greeting: sn,
2774
+ position: w,
2775
+ isMobile: Ce,
2776
+ agentName: ft,
2777
+ avatarImageUrl: St,
2778
+ idleLoopUrl: dn,
2779
+ greeting: un,
2682
2780
  branding: m,
2683
- teamMembers: E,
2684
- currentTeamMemberId: X,
2685
- isSwitchingTeamMember: me,
2686
- teamSwitcherOpen: Ve,
2687
- onToggleTeamSwitcher: () => Ye((h) => !h),
2688
- onSelectTeamMember: on,
2781
+ teamMembers: D,
2782
+ currentTeamMemberId: Q,
2783
+ isSwitchingTeamMember: ye,
2784
+ teamSwitcherOpen: je,
2785
+ onToggleTeamSwitcher: () => Je((h) => !h),
2786
+ onSelectTeamMember: sn,
2689
2787
  connectionState: g.connectionState,
2690
2788
  agentState: g.agentState,
2691
2789
  transcript: g.transcript,
2692
- isMuted: te.isMuted,
2693
- micDevices: pe.mics,
2694
- isCameraEnabled: le.isEnabled,
2695
- cameraPreviewEl: le.previewEl,
2696
- cameraDevices: pe.cameras,
2697
- activeCameraId: le.activeDeviceId,
2698
- isScreenShareEnabled: ae.isEnabled,
2699
- screenPreviewEl: ae.previewEl,
2700
- isSpeakerMuted: ze,
2701
- allowCamera: R,
2702
- allowScreenShare: W,
2703
- allowTyping: z,
2704
- languageMenuOpen: ge,
2705
- onToggleLanguageMenu: () => ye((h) => !h),
2706
- needsUserGesture: $e,
2790
+ isMuted: re.isMuted,
2791
+ micDevices: me.mics,
2792
+ isCameraEnabled: ce.isEnabled,
2793
+ cameraPreviewEl: ce.previewEl,
2794
+ cameraDevices: me.cameras,
2795
+ activeCameraId: ce.activeDeviceId,
2796
+ isScreenShareEnabled: de.isEnabled,
2797
+ screenPreviewEl: de.previewEl,
2798
+ isSpeakerMuted: Oe,
2799
+ allowCamera: I,
2800
+ allowScreenShare: q,
2801
+ allowTyping: B,
2802
+ languageMenuOpen: be,
2803
+ onToggleLanguageMenu: () => ve((h) => !h),
2804
+ needsUserGesture: ze,
2707
2805
  canResume: g.canResume,
2708
- micError: te.micError,
2806
+ micError: re.micError,
2709
2807
  error: g.error,
2710
- avatarVideoContainerRef: Nt,
2808
+ avatarVideoContainerRef: Rt,
2711
2809
  agentVideoEl: g.videoElement,
2712
2810
  micGateOpen: g.isControlled ? !0 : Xe,
2713
2811
  onConnect: () => void g.connect(),
2714
2812
  onDisconnect: () => g.disconnect(),
2715
- onRetry: fn,
2716
- onResumeAudio: un,
2717
- onToggleMute: te.toggleMute,
2718
- onToggleCamera: () => void le.toggle(),
2719
- onSwitchCameraDevice: (h) => void le.switchDevice(h),
2720
- onToggleScreenShare: () => void ae.toggle(),
2721
- onToggleSpeaker: rn,
2722
- onSendMessage: nn,
2723
- onMinimize: dn,
2724
- onClose: Rt,
2725
- onClearMicError: te.clearError
2813
+ onRetry: mn,
2814
+ onResumeAudio: hn,
2815
+ onToggleMute: re.toggleMute,
2816
+ onToggleCamera: () => void ce.toggle(),
2817
+ onSwitchCameraDevice: (h) => void ce.switchDevice(h),
2818
+ onToggleScreenShare: () => void de.toggle(),
2819
+ onToggleSpeaker: an,
2820
+ onSendMessage: ln,
2821
+ onMinimize: pn,
2822
+ onClose: Tt,
2823
+ onClearMicError: re.clearError
2726
2824
  }
2727
2825
  )
2728
2826
  ]
2729
2827
  }
2730
2828
  ) : null;
2731
2829
  }
2732
- function Hr(e) {
2733
- return /* @__PURE__ */ n(wn, { children: /* @__PURE__ */ n(Mr, { ...e }) });
2830
+ function Vr(e) {
2831
+ return /* @__PURE__ */ n(kn, { children: /* @__PURE__ */ n(Ir, { ...e }) });
2734
2832
  }
2735
2833
  const qr = ({
2736
2834
  agentId: e,
2737
2835
  baseUrl: t,
2738
2836
  apiKey: r,
2739
- mode: i,
2740
- onAgentEvent: o,
2837
+ mode: o,
2838
+ onAgentEvent: i,
2741
2839
  className: l,
2742
- style: c
2840
+ style: d
2743
2841
  }) => {
2744
- const u = A(null), f = A(null), y = A(o);
2745
- y.current = o;
2746
- const b = L((s) => {
2747
- var x;
2842
+ const u = A(null), f = A(null), y = A(i);
2843
+ y.current = i;
2844
+ const w = S((s) => {
2845
+ var L;
2748
2846
  const a = s.detail;
2749
- (x = y.current) == null || x.call(y, a);
2847
+ (L = y.current) == null || L.call(y, a);
2750
2848
  }, []);
2751
- return N(() => {
2849
+ return M(() => {
2752
2850
  const s = u.current;
2753
2851
  if (!s) return;
2754
2852
  const a = document.createElement("livelayer-widget");
2755
- return a.setAttribute("agent-id", e), t && a.setAttribute("base-url", t), r && a.setAttribute("api-key", r), i && a.setAttribute("mode", i), a.addEventListener("agent-event", b), s.appendChild(a), f.current = a, () => {
2756
- a.removeEventListener("agent-event", b), s.removeChild(a), f.current = null;
2853
+ return a.setAttribute("agent-id", e), t && a.setAttribute("base-url", t), r && a.setAttribute("api-key", r), o && a.setAttribute("mode", o), a.addEventListener("agent-event", w), s.appendChild(a), f.current = a, () => {
2854
+ a.removeEventListener("agent-event", w), s.removeChild(a), f.current = null;
2757
2855
  };
2758
- }, [e]), N(() => {
2759
- f.current && (i ? f.current.setAttribute("mode", i) : f.current.removeAttribute("mode"));
2760
- }, [i]), /* @__PURE__ */ n("div", { ref: u, className: l, style: c });
2761
- }, Br = Ct(
2762
- function({ id: t, intent: r, as: i = "div", className: o, style: l, children: c }, u) {
2763
- return gn(
2764
- i,
2856
+ }, [e]), M(() => {
2857
+ f.current && (o ? f.current.setAttribute("mode", o) : f.current.removeAttribute("mode"));
2858
+ }, [o]), /* @__PURE__ */ n("div", { ref: u, className: l, style: d });
2859
+ }, Wr = Nt(
2860
+ function({ id: t, intent: r, as: o = "div", className: i, style: l, children: d }, u) {
2861
+ return vn(
2862
+ o,
2765
2863
  {
2766
2864
  ref: u,
2767
2865
  "data-ll-region": t,
2768
2866
  "data-ll-intent": r,
2769
- className: o,
2867
+ className: i,
2770
2868
  style: l
2771
2869
  },
2772
- c
2870
+ d
2773
2871
  );
2774
2872
  }
2775
- ), Wr = Ct(
2776
- function({ id: t, intent: r, children: i, ...o }, l) {
2873
+ ), Gr = Nt(
2874
+ function({ id: t, intent: r, children: o, ...i }, l) {
2777
2875
  return /* @__PURE__ */ n(
2778
2876
  "form",
2779
2877
  {
2780
2878
  ref: l,
2781
2879
  "data-ll-form": t,
2782
2880
  "data-ll-intent": r,
2783
- ...o,
2784
- children: i
2881
+ ...i,
2882
+ children: o
2785
2883
  }
2786
2884
  );
2787
2885
  }
2788
- ), Fr = Ct(
2886
+ ), Fr = Nt(
2789
2887
  function(t, r) {
2790
- const { name: i, label: o, labelClassName: l } = t, c = { name: i, "data-ll-field": i };
2888
+ const { name: o, label: i, labelClassName: l } = t, d = { name: o, "data-ll-field": o };
2791
2889
  let u;
2792
2890
  if ("as" in t && t.as === "textarea") {
2793
- const { name: f, label: y, labelClassName: b, as: s, ...a } = t;
2891
+ const { name: f, label: y, labelClassName: w, as: s, ...a } = t;
2794
2892
  u = /* @__PURE__ */ n(
2795
2893
  "textarea",
2796
2894
  {
2797
2895
  ref: r,
2798
- ...c,
2896
+ ...d,
2799
2897
  ...a
2800
2898
  }
2801
2899
  );
2802
2900
  } else if ("as" in t && t.as === "select") {
2803
- const { name: f, label: y, labelClassName: b, as: s, children: a, ...x } = t;
2901
+ const { name: f, label: y, labelClassName: w, as: s, children: a, ...L } = t;
2804
2902
  u = /* @__PURE__ */ n(
2805
2903
  "select",
2806
2904
  {
2807
2905
  ref: r,
2808
- ...c,
2809
- ...x,
2906
+ ...d,
2907
+ ...L,
2810
2908
  children: a
2811
2909
  }
2812
2910
  );
2813
2911
  } else {
2814
- const { name: f, label: y, labelClassName: b, as: s, ...a } = t;
2912
+ const { name: f, label: y, labelClassName: w, as: s, ...a } = t;
2815
2913
  u = /* @__PURE__ */ n(
2816
2914
  "input",
2817
2915
  {
2818
2916
  ref: r,
2819
- ...c,
2917
+ ...d,
2820
2918
  ...a
2821
2919
  }
2822
2920
  );
2823
2921
  }
2824
- return o === void 0 ? u : /* @__PURE__ */ _("label", { className: l, children: [
2825
- o,
2922
+ return i === void 0 ? u : /* @__PURE__ */ x("label", { className: l, children: [
2923
+ i,
2826
2924
  u
2827
2925
  ] });
2828
2926
  }
2829
2927
  );
2830
- let Zt = 1;
2831
- function Ur({
2928
+ let nn = 1;
2929
+ function jr({
2832
2930
  onMount: e,
2833
2931
  defaultOpen: t = !1,
2834
2932
  storageKey: r = "ll-debug-open"
2835
2933
  }) {
2836
- const [i, o] = S(t), [l, c] = S([]), [u, f] = S(""), [y, b] = S(!1), s = A(/* @__PURE__ */ new Set()), a = A([]), x = A(y);
2837
- x.current = y, N(() => {
2934
+ const [o, i] = E(t), [l, d] = E([]), [u, f] = E(""), [y, w] = E(!1), s = A(/* @__PURE__ */ new Set()), a = A([]), L = A(y);
2935
+ L.current = y, M(() => {
2838
2936
  try {
2839
2937
  const v = localStorage.getItem(r);
2840
- v === "1" && o(!0), v === "0" && o(!1);
2938
+ v === "1" && i(!0), v === "0" && i(!1);
2841
2939
  } catch {
2842
2940
  }
2843
- }, [r]), N(() => {
2941
+ }, [r]), M(() => {
2844
2942
  try {
2845
- localStorage.setItem(r, i ? "1" : "0");
2943
+ localStorage.setItem(r, o ? "1" : "0");
2846
2944
  } catch {
2847
2945
  }
2848
- }, [i, r]), N(() => {
2849
- const v = (w) => {
2850
- (w.metaKey || w.ctrlKey) && w.shiftKey && w.key.toLowerCase() === "l" && (w.preventDefault(), o((H) => !H));
2946
+ }, [o, r]), M(() => {
2947
+ const v = (_) => {
2948
+ (_.metaKey || _.ctrlKey) && _.shiftKey && _.key.toLowerCase() === "l" && (_.preventDefault(), i((O) => !O));
2851
2949
  };
2852
2950
  return window.addEventListener("keydown", v), () => window.removeEventListener("keydown", v);
2853
- }, []), N(() => {
2951
+ }, []), M(() => {
2854
2952
  const v = setInterval(() => {
2855
- if (a.current.length === 0 || x.current) return;
2856
- const w = a.current.splice(0, a.current.length);
2857
- c(
2858
- (H) => [...w.reverse(), ...H].slice(0, 200)
2953
+ if (a.current.length === 0 || L.current) return;
2954
+ const _ = a.current.splice(0, a.current.length);
2955
+ d(
2956
+ (O) => [..._.reverse(), ...O].slice(0, 200)
2859
2957
  );
2860
2958
  }, 100);
2861
2959
  return () => clearInterval(v);
2862
2960
  }, []);
2863
- const E = A(!1);
2864
- if (N(() => {
2865
- !e || E.current || (E.current = !0, e((v) => {
2961
+ const D = A(!1);
2962
+ if (M(() => {
2963
+ !e || D.current || (D.current = !0, e((v) => {
2866
2964
  a.current.push({
2867
- id: Zt++,
2965
+ id: nn++,
2868
2966
  ts: Date.now(),
2869
2967
  kind: "event",
2870
2968
  type: v.eventName,
2871
2969
  data: v.data
2872
2970
  });
2873
2971
  }));
2874
- }, [e]), N(() => {
2875
- const v = console.warn, w = console.log, H = (T, q) => function(...m) {
2972
+ }, [e]), M(() => {
2973
+ const v = console.warn, _ = console.log, O = ($, U) => function(...m) {
2876
2974
  try {
2877
- const R = typeof m[0] == "string" ? m[0] : "";
2878
- R.startsWith("[LiveLayer]") && a.current.push({
2879
- id: Zt++,
2975
+ const I = typeof m[0] == "string" ? m[0] : "";
2976
+ I.startsWith("[LiveLayer]") && a.current.push({
2977
+ id: nn++,
2880
2978
  ts: Date.now(),
2881
- kind: T,
2882
- type: R.slice(0, 120),
2883
- data: { args: m.slice(1).map((W) => Tr(W)) }
2979
+ kind: $,
2980
+ type: I.slice(0, 120),
2981
+ data: { args: m.slice(1).map((q) => $r(q)) }
2884
2982
  });
2885
2983
  } catch {
2886
2984
  }
2887
- return q.apply(this, m);
2985
+ return U.apply(this, m);
2888
2986
  };
2889
- return console.warn = H("warn", v), console.log = H("log", w), () => {
2890
- console.warn = v, console.log = w;
2987
+ return console.warn = O("warn", v), console.log = O("log", _), () => {
2988
+ console.warn = v, console.log = _;
2891
2989
  };
2892
- }, []), !i)
2990
+ }, []), !o)
2893
2991
  return /* @__PURE__ */ n(
2894
2992
  "button",
2895
2993
  {
2896
2994
  type: "button",
2897
- onClick: () => o(!0),
2995
+ onClick: () => i(!0),
2898
2996
  title: "Open LiveLayer debug panel (Cmd/Ctrl + Shift + L)",
2899
2997
  "aria-label": "Open LiveLayer debug panel",
2900
2998
  style: {
@@ -2918,10 +3016,10 @@ function Ur({
2918
3016
  );
2919
3017
  const C = l.filter((v) => {
2920
3018
  if (!u) return !0;
2921
- const w = u.toLowerCase();
2922
- return v.type.toLowerCase().includes(w) || JSON.stringify(v.data || {}).toLowerCase().includes(w);
3019
+ const _ = u.toLowerCase();
3020
+ return v.type.toLowerCase().includes(_) || JSON.stringify(v.data || {}).toLowerCase().includes(_);
2923
3021
  });
2924
- return /* @__PURE__ */ _(
3022
+ return /* @__PURE__ */ x(
2925
3023
  "div",
2926
3024
  {
2927
3025
  style: {
@@ -2943,7 +3041,7 @@ function Ur({
2943
3041
  overflow: "hidden"
2944
3042
  },
2945
3043
  children: [
2946
- /* @__PURE__ */ _(
3044
+ /* @__PURE__ */ x(
2947
3045
  "div",
2948
3046
  {
2949
3047
  style: {
@@ -2956,7 +3054,7 @@ function Ur({
2956
3054
  },
2957
3055
  children: [
2958
3056
  /* @__PURE__ */ n("span", { style: { fontWeight: 600, fontSize: 12 }, children: "LiveLayer debug" }),
2959
- /* @__PURE__ */ _("span", { style: { fontSize: 10, color: "rgba(255,255,255,0.4)" }, children: [
3057
+ /* @__PURE__ */ x("span", { style: { fontSize: 10, color: "rgba(255,255,255,0.4)" }, children: [
2960
3058
  l.length,
2961
3059
  " event",
2962
3060
  l.length === 1 ? "" : "s"
@@ -2966,8 +3064,8 @@ function Ur({
2966
3064
  "button",
2967
3065
  {
2968
3066
  type: "button",
2969
- onClick: () => b((v) => !v),
2970
- style: Lt(y ? "#f59e0b" : "transparent"),
3067
+ onClick: () => w((v) => !v),
3068
+ style: Et(y ? "#f59e0b" : "transparent"),
2971
3069
  title: "Pause / resume capture",
2972
3070
  children: y ? "▶ resume" : "⏸ pause"
2973
3071
  }
@@ -2977,9 +3075,9 @@ function Ur({
2977
3075
  {
2978
3076
  type: "button",
2979
3077
  onClick: () => {
2980
- c([]), a.current = [];
3078
+ d([]), a.current = [];
2981
3079
  },
2982
- style: Lt("transparent"),
3080
+ style: Et("transparent"),
2983
3081
  title: "Clear buffer",
2984
3082
  children: "clear"
2985
3083
  }
@@ -2988,8 +3086,8 @@ function Ur({
2988
3086
  "button",
2989
3087
  {
2990
3088
  type: "button",
2991
- onClick: () => o(!1),
2992
- style: Lt("transparent"),
3089
+ onClick: () => i(!1),
3090
+ style: Et("transparent"),
2993
3091
  "aria-label": "Close",
2994
3092
  title: "Close (Cmd/Ctrl + Shift + L)",
2995
3093
  children: "✕"
@@ -3025,7 +3123,7 @@ function Ur({
3025
3123
  overflowY: "auto",
3026
3124
  padding: "0 8px 8px"
3027
3125
  },
3028
- children: C.length === 0 ? /* @__PURE__ */ _(
3126
+ children: C.length === 0 ? /* @__PURE__ */ x(
3029
3127
  "div",
3030
3128
  {
3031
3129
  style: {
@@ -3056,12 +3154,12 @@ function Ur({
3056
3154
  ]
3057
3155
  }
3058
3156
  ) : C.map((v) => /* @__PURE__ */ n(
3059
- Ir,
3157
+ Pr,
3060
3158
  {
3061
3159
  entry: v,
3062
3160
  expanded: s.current.has(v.id),
3063
3161
  onToggle: () => {
3064
- s.current.has(v.id) ? s.current.delete(v.id) : s.current.add(v.id), c((w) => [...w]);
3162
+ s.current.has(v.id) ? s.current.delete(v.id) : s.current.add(v.id), d((_) => [..._]);
3065
3163
  }
3066
3164
  },
3067
3165
  v.id
@@ -3072,15 +3170,15 @@ function Ur({
3072
3170
  }
3073
3171
  );
3074
3172
  }
3075
- function Ir({
3173
+ function Pr({
3076
3174
  entry: e,
3077
3175
  expanded: t,
3078
3176
  onToggle: r
3079
3177
  }) {
3080
- const i = e.kind === "warn" ? "#f59e0b" : e.type.startsWith("[LiveLayer]") ? "#94a3b8" : e.type === "navigate" || e.type === "scroll_page" || e.type === "scroll_to" || e.type === "click" ? "#22c55e" : e.type === "fill_form" || e.type === "submit_form" || e.type === "focus_field" ? "#a78bfa" : e.type === "request_page_context" || e.type === "request_routes" ? "#38bdf8" : e.type === "agent_state" ? "#facc15" : "#cbd5e1", o = new Date(e.ts).toLocaleTimeString("en-US", {
3178
+ const o = e.kind === "warn" ? "#f59e0b" : e.type.startsWith("[LiveLayer]") ? "#94a3b8" : e.type === "navigate" || e.type === "scroll_page" || e.type === "scroll_to" || e.type === "click" ? "#22c55e" : e.type === "fill_form" || e.type === "submit_form" || e.type === "focus_field" ? "#a78bfa" : e.type === "request_page_context" || e.type === "request_routes" ? "#38bdf8" : e.type === "agent_state" ? "#facc15" : "#cbd5e1", i = new Date(e.ts).toLocaleTimeString("en-US", {
3081
3179
  hour12: !1
3082
3180
  });
3083
- return /* @__PURE__ */ _(
3181
+ return /* @__PURE__ */ x(
3084
3182
  "button",
3085
3183
  {
3086
3184
  type: "button",
@@ -3098,7 +3196,7 @@ function Ir({
3098
3196
  lineHeight: 1.4
3099
3197
  },
3100
3198
  children: [
3101
- /* @__PURE__ */ _("div", { style: { display: "flex", alignItems: "center", gap: 6 }, children: [
3199
+ /* @__PURE__ */ x("div", { style: { display: "flex", alignItems: "center", gap: 6 }, children: [
3102
3200
  /* @__PURE__ */ n(
3103
3201
  "span",
3104
3202
  {
@@ -3107,14 +3205,14 @@ function Ir({
3107
3205
  fontVariantNumeric: "tabular-nums",
3108
3206
  fontSize: 10
3109
3207
  },
3110
- children: o
3208
+ children: i
3111
3209
  }
3112
3210
  ),
3113
3211
  /* @__PURE__ */ n(
3114
3212
  "span",
3115
3213
  {
3116
3214
  style: {
3117
- color: i,
3215
+ color: o,
3118
3216
  fontWeight: 600,
3119
3217
  flexShrink: 0
3120
3218
  },
@@ -3142,7 +3240,7 @@ function Ir({
3142
3240
  }
3143
3241
  );
3144
3242
  }
3145
- function Lt(e) {
3243
+ function Et(e) {
3146
3244
  return {
3147
3245
  background: e,
3148
3246
  color: "#fff",
@@ -3153,59 +3251,59 @@ function Lt(e) {
3153
3251
  cursor: "pointer"
3154
3252
  };
3155
3253
  }
3156
- function Tr(e) {
3254
+ function $r(e) {
3157
3255
  try {
3158
3256
  return e instanceof Error ? { message: e.message, stack: e.stack } : (JSON.stringify(e), e);
3159
3257
  } catch {
3160
3258
  return String(e);
3161
3259
  }
3162
3260
  }
3163
- function jr() {
3164
- const [e, t] = S([]), r = L((o) => {
3261
+ function Jr() {
3262
+ const [e, t] = E([]), r = S((i) => {
3165
3263
  t((l) => {
3166
- const c = l.findIndex((u) => u.id === o.id);
3167
- if (c >= 0) {
3264
+ const d = l.findIndex((u) => u.id === i.id);
3265
+ if (d >= 0) {
3168
3266
  const u = l.slice();
3169
- return u[c] = o, u;
3267
+ return u[d] = i, u;
3170
3268
  }
3171
- return [...l, o];
3269
+ return [...l, i];
3172
3270
  });
3173
- }, []), i = L(() => t([]), []);
3271
+ }, []), o = S(() => t([]), []);
3174
3272
  return {
3175
3273
  entries: e,
3176
3274
  pushSegment: r,
3177
- clear: i,
3275
+ clear: o,
3178
3276
  latest: e.length > 0 ? e[e.length - 1] : null
3179
3277
  };
3180
3278
  }
3181
3279
  export {
3182
- Hr as AvatarWidget,
3183
- wn as ErrorBoundary,
3184
- Ur as LiveLayerDebugPanel,
3280
+ Vr as AvatarWidget,
3281
+ kn as ErrorBoundary,
3282
+ jr as LiveLayerDebugPanel,
3185
3283
  Fr as LiveLayerField,
3186
- Wr as LiveLayerForm,
3187
- Br as LiveLayerRegion,
3284
+ Gr as LiveLayerForm,
3285
+ Wr as LiveLayerRegion,
3188
3286
  qr as LiveLayerWidget,
3189
- gr as clearPageContextCache,
3190
- xr as clearRoutesCache,
3191
- mr as extractPageContext,
3192
- wr as extractRoutes,
3193
- kt as getCachedPageContext,
3194
- dt as getCachedRoutes,
3287
+ vr as clearPageContextCache,
3288
+ Sr as clearRoutesCache,
3289
+ br as extractPageContext,
3290
+ kr as extractRoutes,
3291
+ mt as getCachedPageContext,
3292
+ nt as getCachedRoutes,
3195
3293
  Fn as matchesPattern,
3196
- vr as normalizeRouteInput,
3197
- Un as shouldRenderAtPath,
3198
- Nn as useAgentInfo,
3199
- xn as useAudioLevel,
3200
- Sn as useCameraState,
3201
- Mn as useDisplayMode,
3202
- Dn as useDisplayModePersistence,
3203
- $n as useIsMobile,
3204
- _n as useLiveKitSession,
3205
- En as useMediaDevices,
3206
- kn as useMicrophoneState,
3207
- On as usePathname,
3208
- jn as useRouteMatch,
3209
- Cn as useScreenShareState,
3210
- jr as useTranscript
3294
+ _r as normalizeRouteInput,
3295
+ jn as shouldRenderAtPath,
3296
+ Rn as useAgentInfo,
3297
+ Sn as useAudioLevel,
3298
+ Nn as useCameraState,
3299
+ In as useDisplayMode,
3300
+ Bn as useDisplayModePersistence,
3301
+ On as useIsMobile,
3302
+ Ln as useLiveKitSession,
3303
+ Dn as useMediaDevices,
3304
+ En as useMicrophoneState,
3305
+ Hn as usePathname,
3306
+ Jn as useRouteMatch,
3307
+ An as useScreenShareState,
3308
+ Jr as useTranscript
3211
3309
  };