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

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