@livelayer/react 0.5.24-debug.2 → 0.5.24-debug.3

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