@livelayer/react 0.5.8 → 0.5.10

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