@livelayer/react 0.5.24-debug.4 → 0.6.0

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