@livelayer/react 0.2.5 → 0.3.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 _, jsx as e, Fragment as Ze } from "react/jsx-runtime";
3
- import { Component as et, useState as k, useRef as M, useEffect as S, useCallback as g, useMemo as Se } from "react";
4
- import { LiveKitSession as tt } from "@livelayer/sdk";
5
- import { createLocalAudioTrack as nt, Track as We, createLocalVideoTrack as rt } from "livekit-client";
6
- class it extends et {
2
+ import { jsxs as _, jsx as t, Fragment as _t } from "react/jsx-runtime";
3
+ import { Component as Dt, useState as C, useRef as A, useEffect as I, useCallback as y, useMemo as De, forwardRef as zt, createElement as $t } from "react";
4
+ import { LiveKitSession as Bt } from "@livelayer/sdk";
5
+ import { createLocalAudioTrack as Ut, Track as xt, createLocalVideoTrack as Ot } from "livekit-client";
6
+ class Ht extends Dt {
7
7
  constructor() {
8
8
  super(...arguments), this.state = { hasError: !1, error: null }, this.reset = () => {
9
9
  this.setState({ hasError: !1, error: null });
@@ -12,16 +12,16 @@ class it extends et {
12
12
  static getDerivedStateFromError(n) {
13
13
  return { hasError: !0, error: n };
14
14
  }
15
- componentDidCatch(n, i) {
16
- var l, r;
17
- (r = (l = this.props).onError) == null || r.call(l, n, i);
15
+ componentDidCatch(n, r) {
16
+ var i, o;
17
+ (o = (i = this.props).onError) == null || o.call(i, n, r);
18
18
  }
19
19
  render() {
20
20
  var n;
21
21
  return this.state.hasError ? this.props.fallback ? this.props.fallback : /* @__PURE__ */ _("div", { className: "ll-error-boundary", role: "alert", children: [
22
- /* @__PURE__ */ e("p", { className: "ll-error-boundary__title", children: "Widget crashed" }),
23
- /* @__PURE__ */ e("p", { className: "ll-error-boundary__message", children: ((n = this.state.error) == null ? void 0 : n.message) || "Something went wrong." }),
24
- /* @__PURE__ */ e(
22
+ /* @__PURE__ */ t("p", { className: "ll-error-boundary__title", children: "Widget crashed" }),
23
+ /* @__PURE__ */ t("p", { className: "ll-error-boundary__message", children: ((n = this.state.error) == null ? void 0 : n.message) || "Something went wrong." }),
24
+ /* @__PURE__ */ t(
25
25
  "button",
26
26
  {
27
27
  type: "button",
@@ -33,282 +33,282 @@ class it extends et {
33
33
  ] }) : this.props.children;
34
34
  }
35
35
  }
36
- function lt(t) {
37
- const [n, i] = k("idle"), [l, r] = k("idle"), [s, c] = k([]), [m, d] = k(null), [f, p] = k(null), [o, a] = k(null), [C, b] = k(!1), [N, D] = k(null), E = M(null), R = M(t.onDataMessage);
38
- R.current = t.onDataMessage, S(() => {
39
- const w = {
40
- onConnectionStateChange: (y) => {
41
- i(y), y === "connected" && D(null);
36
+ function jt(e) {
37
+ const [n, r] = C("idle"), [i, o] = C("idle"), [l, d] = C([]), [u, s] = C(null), [g, f] = C(null), [a, c] = C(null), [S, x] = C(!1), [E, P] = C(null), b = A(null), T = A(e.onDataMessage);
38
+ T.current = e.onDataMessage, I(() => {
39
+ const k = {
40
+ onConnectionStateChange: (w) => {
41
+ r(w), w === "connected" && P(null);
42
42
  },
43
- onAgentStateChange: r,
44
- onTranscript: (y) => c([...y]),
45
- onAgentConfig: d,
46
- onAudioTrack: (y) => a(y),
47
- onVideoTrack: (y) => p(y),
48
- onVideoTrackRemoved: () => p(null),
49
- onError: (y) => D(y),
50
- onDataMessage: (y) => {
51
- var A;
52
- (A = R.current) == null || A.call(R, y);
43
+ onAgentStateChange: o,
44
+ onTranscript: (w) => d([...w]),
45
+ onAgentConfig: s,
46
+ onAudioTrack: (w) => c(w),
47
+ onVideoTrack: (w) => f(w),
48
+ onVideoTrackRemoved: () => f(null),
49
+ onError: (w) => P(w),
50
+ onDataMessage: (w) => {
51
+ var z;
52
+ (z = T.current) == null || z.call(T, w);
53
53
  },
54
- onResumabilityChange: b
55
- }, x = new tt(
54
+ onResumabilityChange: x
55
+ }, L = new Bt(
56
56
  {
57
- agentId: t.agentId,
58
- baseUrl: t.baseUrl,
59
- apiKey: t.apiKey,
60
- sessionEndpoint: t.sessionEndpoint,
61
- sessionBody: t.sessionBody
57
+ agentId: e.agentId,
58
+ baseUrl: e.baseUrl,
59
+ apiKey: e.apiKey,
60
+ sessionEndpoint: e.sessionEndpoint,
61
+ sessionBody: e.sessionBody
62
62
  },
63
- w
63
+ k
64
64
  );
65
- return E.current = x, i("idle"), r("idle"), c([]), d(null), p(null), a(null), b(!1), D(null), () => {
66
- var y;
67
- (y = x.destroy) == null || y.call(x), E.current = null;
65
+ return b.current = L, r("idle"), o("idle"), d([]), s(null), f(null), c(null), x(!1), P(null), () => {
66
+ var w;
67
+ (w = L.destroy) == null || w.call(L), b.current = null;
68
68
  };
69
69
  }, [
70
- t.agentId,
71
- t.baseUrl,
72
- t.apiKey,
73
- t.sessionEndpoint,
74
- JSON.stringify(t.sessionBody ?? {})
70
+ e.agentId,
71
+ e.baseUrl,
72
+ e.apiKey,
73
+ e.sessionEndpoint,
74
+ JSON.stringify(e.sessionBody ?? {})
75
75
  ]);
76
- const T = g(async () => {
77
- const w = E.current;
78
- if (w)
76
+ const p = y(async () => {
77
+ const k = b.current;
78
+ if (k)
79
79
  try {
80
- await w.connect();
81
- } catch (x) {
82
- throw D(x instanceof Error ? x.message : String(x)), x;
80
+ await k.connect();
81
+ } catch (L) {
82
+ throw P(L instanceof Error ? L.message : String(L)), L;
83
83
  }
84
- }, []), z = g(() => {
85
- const w = E.current;
86
- w && w.disconnect();
87
- }, []), I = g(() => {
88
- var w;
89
- return ((w = E.current) == null ? void 0 : w.getRoom()) ?? null;
84
+ }, []), N = y(() => {
85
+ const k = b.current;
86
+ k && k.disconnect();
87
+ }, []), R = y(() => {
88
+ var k;
89
+ return ((k = b.current) == null ? void 0 : k.getRoom()) ?? null;
90
90
  }, []);
91
91
  return {
92
92
  connectionState: n,
93
- agentState: l,
94
- transcript: s,
95
- agentConfig: m,
96
- videoElement: f,
97
- audioElement: o,
98
- canResume: C,
99
- error: N,
100
- connect: T,
101
- disconnect: z,
102
- getRoom: I,
103
- session: E.current
93
+ agentState: i,
94
+ transcript: l,
95
+ agentConfig: u,
96
+ videoElement: g,
97
+ audioElement: a,
98
+ canResume: S,
99
+ error: E,
100
+ connect: p,
101
+ disconnect: N,
102
+ getRoom: R,
103
+ session: b.current
104
104
  };
105
105
  }
106
- function ot() {
107
- const t = M(null), n = M(null), i = M(null), l = M(null), r = M(/* @__PURE__ */ new Set()), s = M(null), c = g(() => {
108
- const o = n.current;
109
- if (!o) {
110
- l.current = null;
106
+ function Ft() {
107
+ const e = A(null), n = A(null), r = A(null), i = A(null), o = A(/* @__PURE__ */ new Set()), l = A(null), d = y(() => {
108
+ const a = n.current;
109
+ if (!a) {
110
+ i.current = null;
111
111
  return;
112
112
  }
113
- (!s.current || s.current.length !== o.frequencyBinCount) && (s.current = new Uint8Array(
114
- new ArrayBuffer(o.frequencyBinCount)
113
+ (!l.current || l.current.length !== a.frequencyBinCount) && (l.current = new Uint8Array(
114
+ new ArrayBuffer(a.frequencyBinCount)
115
115
  ));
116
- const a = s.current;
117
- o.getByteFrequencyData(a);
118
- let C = 0;
119
- for (let N = 0; N < a.length; N++) C += a[N];
120
- const b = C / a.length / 255;
121
- for (const N of r.current)
116
+ const c = l.current;
117
+ a.getByteFrequencyData(c);
118
+ let S = 0;
119
+ for (let E = 0; E < c.length; E++) S += c[E];
120
+ const x = S / c.length / 255;
121
+ for (const E of o.current)
122
122
  try {
123
- N(b);
124
- } catch (D) {
125
- console.error("[useAudioLevel] subscriber threw:", D);
123
+ E(x);
124
+ } catch (P) {
125
+ console.error("[useAudioLevel] subscriber threw:", P);
126
126
  }
127
- l.current = requestAnimationFrame(c);
128
- }, []), m = g(() => {
129
- if (t.current || typeof window > "u" || typeof AudioContext > "u") return;
130
- const o = new AudioContext(), a = o.createAnalyser();
131
- a.fftSize = 64, a.connect(o.destination), t.current = o, n.current = a;
132
- }, []), d = g(
133
- (o) => {
134
- if (m(), !(!t.current || !n.current)) {
135
- if (i.current) {
127
+ i.current = requestAnimationFrame(d);
128
+ }, []), u = y(() => {
129
+ if (e.current || typeof window > "u" || typeof AudioContext > "u") return;
130
+ const a = new AudioContext(), c = a.createAnalyser();
131
+ c.fftSize = 64, c.connect(a.destination), e.current = a, n.current = c;
132
+ }, []), s = y(
133
+ (a) => {
134
+ if (u(), !(!e.current || !n.current)) {
135
+ if (r.current) {
136
136
  try {
137
- i.current.disconnect();
137
+ r.current.disconnect();
138
138
  } catch {
139
139
  }
140
- i.current = null;
140
+ r.current = null;
141
141
  }
142
142
  try {
143
- const a = t.current.createMediaElementSource(o);
144
- a.connect(n.current), i.current = a;
145
- } catch (a) {
146
- console.warn("[useAudioLevel] createMediaElementSource failed:", a);
143
+ const c = e.current.createMediaElementSource(a);
144
+ c.connect(n.current), r.current = c;
145
+ } catch (c) {
146
+ console.warn("[useAudioLevel] createMediaElementSource failed:", c);
147
147
  return;
148
148
  }
149
- l.current === null && (l.current = requestAnimationFrame(c));
149
+ i.current === null && (i.current = requestAnimationFrame(d));
150
150
  }
151
151
  },
152
- [m, c]
153
- ), f = g(() => {
154
- if (l.current !== null && (cancelAnimationFrame(l.current), l.current = null), i.current) {
152
+ [u, d]
153
+ ), g = y(() => {
154
+ if (i.current !== null && (cancelAnimationFrame(i.current), i.current = null), r.current) {
155
155
  try {
156
- i.current.disconnect();
156
+ r.current.disconnect();
157
157
  } catch {
158
158
  }
159
- i.current = null;
159
+ r.current = null;
160
160
  }
161
- }, []), p = g((o) => (r.current.add(o), () => {
162
- r.current.delete(o);
161
+ }, []), f = y((a) => (o.current.add(a), () => {
162
+ o.current.delete(a);
163
163
  }), []);
164
- return S(() => () => {
165
- if (f(), n.current) {
164
+ return I(() => () => {
165
+ if (g(), n.current) {
166
166
  try {
167
167
  n.current.disconnect();
168
168
  } catch {
169
169
  }
170
170
  n.current = null;
171
171
  }
172
- if (t.current) {
172
+ if (e.current) {
173
173
  try {
174
- t.current.close();
174
+ e.current.close();
175
175
  } catch {
176
176
  }
177
- t.current = null;
177
+ e.current = null;
178
178
  }
179
- r.current.clear(), s.current = null;
180
- }, [f]), { attach: d, detach: f, subscribe: p };
179
+ o.current.clear(), l.current = null;
180
+ }, [g]), { attach: s, detach: g, subscribe: f };
181
181
  }
182
- function at() {
183
- const [t, n] = k(!1), [i, l] = k(null), r = M(null), s = M(null), c = g(async (p) => {
184
- if (r.current && s.current) {
182
+ function Vt() {
183
+ const [e, n] = C(!1), [r, i] = C(null), o = A(null), l = A(null), d = y(async (f) => {
184
+ if (o.current && l.current) {
185
185
  try {
186
- await s.current.localParticipant.unpublishTrack(r.current);
186
+ await l.current.localParticipant.unpublishTrack(o.current);
187
187
  } catch {
188
188
  }
189
- r.current.stop(), r.current = null;
189
+ o.current.stop(), o.current = null;
190
190
  }
191
- s.current = p, l(null);
191
+ l.current = f, i(null);
192
192
  try {
193
- const o = await nt({
193
+ const a = await Ut({
194
194
  echoCancellation: !0,
195
195
  noiseSuppression: !0
196
196
  });
197
- await p.localParticipant.publishTrack(o), r.current = o, n(o.isMuted);
198
- } catch (o) {
199
- const a = o instanceof Error && o.name === "NotAllowedError" ? "Enable your microphone to talk with the agent." : "Microphone unavailable. Check browser permissions and try again.";
200
- throw l(a), o;
197
+ await f.localParticipant.publishTrack(a), o.current = a, n(a.isMuted);
198
+ } catch (a) {
199
+ const c = a instanceof Error && a.name === "NotAllowedError" ? "Enable your microphone to talk with the agent." : "Microphone unavailable. Check browser permissions and try again.";
200
+ throw i(c), a;
201
201
  }
202
- }, []), m = g(() => {
203
- const p = r.current;
204
- p && (p.isMuted ? (p.unmute(), n(!1)) : (p.mute(), n(!0)));
205
- }, []), d = g(() => {
206
- const p = r.current, o = s.current;
207
- if (p && o) {
202
+ }, []), u = y(() => {
203
+ const f = o.current;
204
+ f && (f.isMuted ? (f.unmute(), n(!1)) : (f.mute(), n(!0)));
205
+ }, []), s = y(() => {
206
+ const f = o.current, a = l.current;
207
+ if (f && a) {
208
208
  try {
209
- o.localParticipant.unpublishTrack(p);
209
+ a.localParticipant.unpublishTrack(f);
210
210
  } catch {
211
211
  }
212
- p.stop();
212
+ f.stop();
213
213
  }
214
- r.current = null, s.current = null, n(!1);
215
- }, []), f = g(() => l(null), []);
214
+ o.current = null, l.current = null, n(!1);
215
+ }, []), g = y(() => i(null), []);
216
216
  return {
217
- isMuted: t,
218
- micError: i,
219
- toggleMute: m,
220
- setupMic: c,
221
- teardownMic: d,
222
- clearError: f
217
+ isMuted: e,
218
+ micError: r,
219
+ toggleMute: u,
220
+ setupMic: d,
221
+ teardownMic: s,
222
+ clearError: g
223
223
  };
224
224
  }
225
- const st = { resolution: { width: 640, height: 480, frameRate: 24 } };
226
- function ct() {
227
- const [t, n] = k(!1), [i, l] = k(null), [r, s] = k(null), [c, m] = k(""), d = M(null), f = M(null), p = g((E) => {
228
- d.current = E;
229
- }, []), o = g(() => {
230
- const E = d.current, R = f.current;
231
- if (R && E) {
232
- const T = E.localParticipant.getTrackPublication(We.Source.Camera);
233
- if (T != null && T.track) {
225
+ const Wt = { resolution: { width: 640, height: 480, frameRate: 24 } };
226
+ function qt() {
227
+ const [e, n] = C(!1), [r, i] = C(null), [o, l] = C(null), [d, u] = C(""), s = A(null), g = A(null), f = y((b) => {
228
+ s.current = b;
229
+ }, []), a = y(() => {
230
+ const b = s.current, T = g.current;
231
+ if (T && b) {
232
+ const p = b.localParticipant.getTrackPublication(xt.Source.Camera);
233
+ if (p != null && p.track) {
234
234
  try {
235
- E.localParticipant.unpublishTrack(T.track);
235
+ b.localParticipant.unpublishTrack(p.track);
236
236
  } catch {
237
237
  }
238
- T.track.stop();
238
+ p.track.stop();
239
239
  } else
240
- R.stop();
240
+ T.stop();
241
241
  }
242
- f.current = null, s(null), n(!1);
243
- }, []), a = g(async (E) => {
244
- const R = d.current;
245
- if (R) {
246
- l(null);
242
+ g.current = null, l(null), n(!1);
243
+ }, []), c = y(async (b) => {
244
+ const T = s.current;
245
+ if (T) {
246
+ i(null);
247
247
  try {
248
- const T = { ...st };
249
- E && (T.deviceId = E);
250
- const z = await rt(T);
251
- await R.localParticipant.publishTrack(z), f.current = z;
252
- const I = z.attach();
253
- s(I), n(!0), E && m(E);
248
+ const p = { ...Wt };
249
+ b && (p.deviceId = b);
250
+ const N = await Ot(p);
251
+ await T.localParticipant.publishTrack(N), g.current = N;
252
+ const R = N.attach();
253
+ l(R), n(!0), b && u(b);
254
254
  try {
255
- R.localParticipant.publishData(
255
+ T.localParticipant.publishData(
256
256
  new TextEncoder().encode(JSON.stringify({ type: "user_camera_on" })),
257
257
  { reliable: !0 }
258
258
  );
259
259
  } catch {
260
260
  }
261
- } catch (T) {
262
- const z = T instanceof Error && T.name === "NotAllowedError" ? "Enable your camera in the browser to share video." : "Camera unavailable. Check permissions and try again.";
263
- l(z);
261
+ } catch (p) {
262
+ const N = p instanceof Error && p.name === "NotAllowedError" ? "Enable your camera in the browser to share video." : "Camera unavailable. Check permissions and try again.";
263
+ i(N);
264
264
  }
265
265
  }
266
- }, []), C = g(async () => {
267
- t ? o() : await a(c || void 0);
268
- }, [t, c, o, a]), b = g(async (E) => {
269
- o(), await a(E);
270
- }, [o, a]), N = g(() => {
271
- o(), d.current = null, l(null), m("");
272
- }, [o]), D = g(() => l(null), []);
273
- return S(() => () => {
274
- f.current && f.current.stop();
266
+ }, []), S = y(async () => {
267
+ e ? a() : await c(d || void 0);
268
+ }, [e, d, a, c]), x = y(async (b) => {
269
+ a(), await c(b);
270
+ }, [a, c]), E = y(() => {
271
+ a(), s.current = null, i(null), u("");
272
+ }, [a]), P = y(() => i(null), []);
273
+ return I(() => () => {
274
+ g.current && g.current.stop();
275
275
  }, []), {
276
- isEnabled: t,
277
- error: i,
278
- previewEl: r,
279
- activeDeviceId: c,
280
- toggle: C,
281
- switchDevice: b,
282
- attachRoom: p,
283
- teardown: N,
284
- clearError: D
276
+ isEnabled: e,
277
+ error: r,
278
+ previewEl: o,
279
+ activeDeviceId: d,
280
+ toggle: S,
281
+ switchDevice: x,
282
+ attachRoom: f,
283
+ teardown: E,
284
+ clearError: P
285
285
  };
286
286
  }
287
- function dt() {
288
- const [t, n] = k(!1), [i, l] = k(null), [r, s] = k(null), c = M(null), m = g((a) => {
289
- c.current = a;
290
- }, []), d = g(() => s(null), []), f = g(async () => {
291
- const a = c.current;
292
- if (a) {
293
- if (t) {
287
+ function Gt() {
288
+ const [e, n] = C(!1), [r, i] = C(null), [o, l] = C(null), d = A(null), u = y((c) => {
289
+ d.current = c;
290
+ }, []), s = y(() => l(null), []), g = y(async () => {
291
+ const c = d.current;
292
+ if (c) {
293
+ if (e) {
294
294
  try {
295
- await a.localParticipant.setScreenShareEnabled(!1);
295
+ await c.localParticipant.setScreenShareEnabled(!1);
296
296
  } catch {
297
297
  }
298
- d(), n(!1);
298
+ s(), n(!1);
299
299
  return;
300
300
  }
301
- l(null);
301
+ i(null);
302
302
  try {
303
- await a.localParticipant.setScreenShareEnabled(!0);
304
- let C = 0;
305
- const b = () => {
306
- const N = a.localParticipant.getTrackPublication(We.Source.ScreenShare);
307
- if (N != null && N.track) {
308
- const D = N.track.attach();
309
- s(D), n(!0);
303
+ await c.localParticipant.setScreenShareEnabled(!0);
304
+ let S = 0;
305
+ const x = () => {
306
+ const E = c.localParticipant.getTrackPublication(xt.Source.ScreenShare);
307
+ if (E != null && E.track) {
308
+ const P = E.track.attach();
309
+ l(P), n(!0);
310
310
  try {
311
- a.localParticipant.publishData(
311
+ c.localParticipant.publishData(
312
312
  new TextEncoder().encode(JSON.stringify({ type: "user_screen_share_on" })),
313
313
  { reliable: !0 }
314
314
  );
@@ -316,132 +316,192 @@ function dt() {
316
316
  }
317
317
  return;
318
318
  }
319
- C++ < 10 ? setTimeout(b, 100) : n(!0);
319
+ S++ < 10 ? setTimeout(x, 100) : n(!0);
320
320
  };
321
- b();
322
- } catch (C) {
323
- const b = C instanceof Error ? C.name : "";
324
- b !== "NotAllowedError" && b !== "AbortError" && l("Screen share unavailable. Try again."), n(!1);
321
+ x();
322
+ } catch (S) {
323
+ const x = S instanceof Error ? S.name : "";
324
+ x !== "NotAllowedError" && x !== "AbortError" && i("Screen share unavailable. Try again."), n(!1);
325
325
  }
326
326
  }
327
- }, [t, d]), p = g(() => {
328
- const a = c.current;
329
- if (a && t)
327
+ }, [e, s]), f = y(() => {
328
+ const c = d.current;
329
+ if (c && e)
330
330
  try {
331
- a.localParticipant.setScreenShareEnabled(!1);
331
+ c.localParticipant.setScreenShareEnabled(!1);
332
332
  } catch {
333
333
  }
334
- d(), n(!1), l(null), c.current = null;
335
- }, [t, d]), o = g(() => l(null), []);
336
- return { isEnabled: t, error: i, previewEl: r, toggle: f, attachRoom: m, teardown: p, clearError: o };
334
+ s(), n(!1), i(null), d.current = null;
335
+ }, [e, s]), a = y(() => i(null), []);
336
+ return { isEnabled: e, error: r, previewEl: o, toggle: g, attachRoom: u, teardown: f, clearError: a };
337
337
  }
338
- function ut() {
339
- const [t, n] = k([]), [i, l] = k([]), r = g(async () => {
338
+ function Yt() {
339
+ const [e, n] = C([]), [r, i] = C([]), o = y(async () => {
340
340
  if (!(typeof navigator > "u" || !navigator.mediaDevices))
341
341
  try {
342
- const s = await navigator.mediaDevices.enumerateDevices();
343
- n(s.filter((c) => c.kind === "audioinput")), l(s.filter((c) => c.kind === "videoinput"));
342
+ const l = await navigator.mediaDevices.enumerateDevices();
343
+ n(l.filter((d) => d.kind === "audioinput")), i(l.filter((d) => d.kind === "videoinput"));
344
344
  } catch {
345
345
  }
346
346
  }, []);
347
- return S(() => {
348
- if (r(), typeof navigator > "u" || !navigator.mediaDevices) return;
349
- const s = () => void r();
350
- return navigator.mediaDevices.addEventListener("devicechange", s), () => navigator.mediaDevices.removeEventListener("devicechange", s);
351
- }, [r]), { mics: t, cameras: i, refresh: r };
347
+ return I(() => {
348
+ if (o(), typeof navigator > "u" || !navigator.mediaDevices) return;
349
+ const l = () => void o();
350
+ return navigator.mediaDevices.addEventListener("devicechange", l), () => navigator.mediaDevices.removeEventListener("devicechange", l);
351
+ }, [o]), { mics: e, cameras: r, refresh: o };
352
352
  }
353
- function ht(t, n, i = !1) {
354
- const [l, r] = k(null), [s, c] = k(null), [m, d] = k(!i && !!t);
355
- return S(() => {
356
- if (i || !t) {
357
- d(!1);
353
+ function Kt(e, n, r = !1) {
354
+ const [i, o] = C(null), [l, d] = C(null), [u, s] = C(!r && !!e);
355
+ return I(() => {
356
+ if (r || !e) {
357
+ s(!1);
358
358
  return;
359
359
  }
360
- const f = new AbortController(), p = n || "https://app.livelayer.studio";
361
- return d(!0), c(null), fetch(`${p}/api/widget/agent/${encodeURIComponent(t)}`, {
362
- signal: f.signal
363
- }).then(async (o) => {
364
- if (!o.ok) {
365
- const a = await o.json().catch(() => ({}));
366
- throw new Error(a.error || `HTTP ${o.status}`);
360
+ const g = new AbortController(), f = n || "https://app.livelayer.studio";
361
+ return s(!0), d(null), fetch(`${f}/api/widget/agent/${encodeURIComponent(e)}`, {
362
+ signal: g.signal
363
+ }).then(async (a) => {
364
+ if (!a.ok) {
365
+ const c = await a.json().catch(() => ({}));
366
+ throw new Error(c.error || `HTTP ${a.status}`);
367
367
  }
368
- return o.json();
369
- }).then((o) => {
370
- f.signal.aborted || (r(o), d(!1));
371
- }).catch((o) => {
372
- f.signal.aborted || (c(o instanceof Error ? o.message : "Agent lookup failed"), d(!1));
373
- }), () => f.abort();
374
- }, [t, n, i]), { info: l, error: s, loading: m };
368
+ return a.json();
369
+ }).then((a) => {
370
+ g.signal.aborted || (o(a), s(!1));
371
+ }).catch((a) => {
372
+ g.signal.aborted || (d(a instanceof Error ? a.message : "Agent lookup failed"), s(!1));
373
+ }), () => g.abort();
374
+ }, [e, n, r]), { info: i, error: l, loading: u };
375
375
  }
376
- function pt(t) {
376
+ function Xt(e) {
377
377
  if (typeof window > "u") return null;
378
378
  try {
379
- return window.localStorage.getItem(t);
379
+ return window.localStorage.getItem(e);
380
380
  } catch {
381
381
  return null;
382
382
  }
383
383
  }
384
- function mt(t, n) {
384
+ function Jt(e, n) {
385
385
  if (!(typeof window > "u"))
386
386
  try {
387
- window.localStorage.setItem(t, n);
387
+ window.localStorage.setItem(e, n);
388
388
  } catch {
389
389
  }
390
390
  }
391
- function ft({
392
- value: t,
391
+ function Qt({
392
+ value: e,
393
393
  defaultValue: n = "expanded",
394
- onChange: i
394
+ onChange: r
395
395
  } = {}) {
396
- const l = t !== void 0, [r, s] = k(n), c = l ? t : r, m = g(
397
- (d) => {
398
- d !== c && (l || s(d), i == null || i(d));
396
+ const i = e !== void 0, [o, l] = C(n), d = i ? e : o, u = y(
397
+ (s) => {
398
+ s !== d && (i || l(s), r == null || r(s));
399
399
  },
400
- [c, l, i]
400
+ [d, i, r]
401
401
  );
402
- return [c, m];
402
+ return [d, u];
403
403
  }
404
- const gt = ["hidden", "minimized", "expanded"];
405
- function vt(t) {
406
- return t && gt.includes(t) ? t : null;
404
+ const Zt = ["hidden", "minimized", "expanded"];
405
+ function en(e) {
406
+ return e && Zt.includes(e) ? e : null;
407
407
  }
408
- function yt({
409
- value: t,
408
+ function tn({
409
+ value: e,
410
410
  defaultValue: n = "expanded",
411
- onChange: i,
412
- persistKey: l = "ll-widget",
413
- disablePersistence: r = !1
411
+ onChange: r,
412
+ persistKey: i = "ll-widget",
413
+ disablePersistence: o = !1
414
414
  } = {}) {
415
- const s = `${l}:display-mode`, c = M(!1), [m, d] = ft({
416
- value: t,
415
+ const l = `${i}:display-mode`, d = A(!1), [u, s] = Qt({
416
+ value: e,
417
417
  defaultValue: n,
418
- onChange: (f) => {
419
- t === void 0 && !r && mt(s, f), i == null || i(f);
418
+ onChange: (g) => {
419
+ e === void 0 && !o && Jt(l, g), r == null || r(g);
420
420
  }
421
421
  });
422
- return S(() => {
423
- if (c.current || (c.current = !0, r || t !== void 0)) return;
424
- const f = vt(pt(s));
425
- f && f !== m && d(f);
426
- }, []), [m, d];
422
+ return I(() => {
423
+ if (d.current || (d.current = !0, o || e !== void 0)) return;
424
+ const g = en(Xt(l));
425
+ g && g !== u && s(g);
426
+ }, []), [u, s];
427
427
  }
428
- const _t = 640;
429
- function bt(t = _t) {
430
- const [n, i] = k(!1);
431
- return S(() => {
432
- if (t === !1) {
433
- i(!1);
428
+ const nn = 640;
429
+ function rn(e = nn) {
430
+ const [n, r] = C(!1);
431
+ return I(() => {
432
+ if (e === !1) {
433
+ r(!1);
434
434
  return;
435
435
  }
436
436
  if (typeof window > "u" || typeof window.matchMedia > "u")
437
437
  return;
438
- const l = `(max-width: ${t - 1}px)`, r = window.matchMedia(l), s = () => i(r.matches);
439
- return s(), typeof r.addEventListener == "function" ? (r.addEventListener("change", s), () => r.removeEventListener("change", s)) : (r.addListener(s), () => {
440
- r.removeListener(s);
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);
441
441
  });
442
- }, [t]), n;
442
+ }, [e]), n;
443
+ }
444
+ const ct = "__llHistoryPatched", ze = "ll:pathname";
445
+ function on() {
446
+ if (typeof window > "u" || window.history[ct]) return;
447
+ const e = window.history.pushState, n = window.history.replaceState;
448
+ window.history.pushState = function(...r) {
449
+ const i = e.apply(this, r);
450
+ return window.dispatchEvent(new Event(ze)), i;
451
+ }, window.history.replaceState = function(...r) {
452
+ const i = n.apply(this, r);
453
+ return window.dispatchEvent(new Event(ze)), i;
454
+ }, window.history[ct] = !0;
455
+ }
456
+ function st() {
457
+ return typeof window > "u" ? "/" : window.location.pathname || "/";
458
+ }
459
+ function ln(e) {
460
+ const [n, r] = C(
461
+ () => e ?? st()
462
+ );
463
+ return I(() => {
464
+ if (e !== void 0) return;
465
+ on();
466
+ const i = () => r(st());
467
+ return i(), window.addEventListener("popstate", i), window.addEventListener(ze, i), () => {
468
+ window.removeEventListener("popstate", i), window.removeEventListener(ze, i);
469
+ };
470
+ }, [e]), e ?? n;
471
+ }
472
+ const dt = /* @__PURE__ */ new Map(), an = /[\\^$+?.()|{}[\]]/g;
473
+ function cn(e) {
474
+ return e.replace(an, "\\$&");
475
+ }
476
+ function sn(e) {
477
+ const n = dt.get(e);
478
+ if (n) return n;
479
+ const r = e.length > 1 && e.endsWith("/") ? e.slice(0, -1) : e, i = "", o = "", l = r.replace(/\*\*/g, i).replace(/\*/g, o), u = cn(l).replace(new RegExp(`\\/${i}`, "g"), "(?:\\/.*)?").replace(new RegExp(i, "g"), ".*").replace(new RegExp(o, "g"), "[^/]+"), s = new RegExp(`^${u}\\/?$`);
480
+ return dt.set(e, s), s;
481
+ }
482
+ function dn(e, n) {
483
+ const r = n.length > 1 && n.endsWith("/") ? n.slice(0, -1) : n;
484
+ return sn(e).test(r);
485
+ }
486
+ function un(e, n) {
487
+ return typeof e == "function" ? e(n) : e instanceof RegExp ? e.test(n) : dn(e, n);
488
+ }
489
+ function ut(e, n) {
490
+ if (!e || e.length === 0) return !1;
491
+ for (const r of e)
492
+ if (un(r, n)) return !0;
493
+ return !1;
494
+ }
495
+ function hn(e, n, r) {
496
+ return e === void 0 ? !0 : ut(r, e) ? !1 : n && n.length > 0 ? ut(n, e) : !0;
497
+ }
498
+ function fn(e, n, r) {
499
+ return De(
500
+ () => hn(e, n, r),
501
+ [e, n, r]
502
+ );
443
503
  }
444
- const Pe = ({ muted: t = !1, className: n }) => t ? /* @__PURE__ */ _(
504
+ const ht = ({ muted: e = !1, className: n }) => e ? /* @__PURE__ */ _(
445
505
  "svg",
446
506
  {
447
507
  className: n,
@@ -451,7 +511,7 @@ const Pe = ({ muted: t = !1, className: n }) => t ? /* @__PURE__ */ _(
451
511
  strokeWidth: 2,
452
512
  "aria-hidden": "true",
453
513
  children: [
454
- /* @__PURE__ */ e(
514
+ /* @__PURE__ */ t(
455
515
  "path",
456
516
  {
457
517
  strokeLinecap: "round",
@@ -459,7 +519,7 @@ const Pe = ({ muted: t = !1, className: n }) => t ? /* @__PURE__ */ _(
459
519
  d: "M5.586 15H4a1 1 0 01-1-1v-4a1 1 0 011-1h1.586l4.707-4.707C10.923 3.663 12 4.109 12 5v14c0 .891-1.077 1.337-1.707.707L5.586 15z"
460
520
  }
461
521
  ),
462
- /* @__PURE__ */ e(
522
+ /* @__PURE__ */ t(
463
523
  "path",
464
524
  {
465
525
  strokeLinecap: "round",
@@ -469,7 +529,7 @@ const Pe = ({ muted: t = !1, className: n }) => t ? /* @__PURE__ */ _(
469
529
  )
470
530
  ]
471
531
  }
472
- ) : /* @__PURE__ */ e(
532
+ ) : /* @__PURE__ */ t(
473
533
  "svg",
474
534
  {
475
535
  className: n,
@@ -478,7 +538,7 @@ const Pe = ({ muted: t = !1, className: n }) => t ? /* @__PURE__ */ _(
478
538
  stroke: "currentColor",
479
539
  strokeWidth: 2,
480
540
  "aria-hidden": "true",
481
- children: /* @__PURE__ */ e(
541
+ children: /* @__PURE__ */ t(
482
542
  "path",
483
543
  {
484
544
  strokeLinecap: "round",
@@ -487,16 +547,16 @@ const Pe = ({ muted: t = !1, className: n }) => t ? /* @__PURE__ */ _(
487
547
  }
488
548
  )
489
549
  }
490
- ), Be = ({ className: t }) => /* @__PURE__ */ e(
550
+ ), ft = ({ className: e }) => /* @__PURE__ */ t(
491
551
  "svg",
492
552
  {
493
- className: t,
553
+ className: e,
494
554
  fill: "none",
495
555
  viewBox: "0 0 24 24",
496
556
  stroke: "currentColor",
497
557
  strokeWidth: 2,
498
558
  "aria-hidden": "true",
499
- children: /* @__PURE__ */ e(
559
+ children: /* @__PURE__ */ t(
500
560
  "path",
501
561
  {
502
562
  strokeLinecap: "round",
@@ -505,23 +565,23 @@ const Pe = ({ muted: t = !1, className: n }) => t ? /* @__PURE__ */ _(
505
565
  }
506
566
  )
507
567
  }
508
- ), wt = ({ className: t }) => /* @__PURE__ */ e(
568
+ ), pn = ({ className: e }) => /* @__PURE__ */ t(
509
569
  "svg",
510
570
  {
511
- className: t,
571
+ className: e,
512
572
  fill: "none",
513
573
  viewBox: "0 0 24 24",
514
574
  stroke: "currentColor",
515
575
  strokeWidth: 2,
516
576
  "aria-hidden": "true",
517
- children: /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M6 18L18 6M6 6l12 12" })
577
+ children: /* @__PURE__ */ t("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M6 18L18 6M6 6l12 12" })
518
578
  }
519
- ), kt = {
579
+ ), mn = {
520
580
  left: 180,
521
581
  right: 0,
522
582
  up: -90,
523
583
  down: 90
524
- }, xt = ({ direction: t = "right", className: n }) => /* @__PURE__ */ e(
584
+ }, gn = ({ direction: e = "right", className: n }) => /* @__PURE__ */ t(
525
585
  "svg",
526
586
  {
527
587
  className: n,
@@ -529,304 +589,304 @@ const Pe = ({ muted: t = !1, className: n }) => t ? /* @__PURE__ */ _(
529
589
  viewBox: "0 0 24 24",
530
590
  stroke: "currentColor",
531
591
  strokeWidth: 2,
532
- style: { transform: `rotate(${kt[t]}deg)` },
592
+ style: { transform: `rotate(${mn[e]}deg)` },
533
593
  "aria-hidden": "true",
534
- children: /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M9 6l6 6-6 6" })
594
+ children: /* @__PURE__ */ t("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M9 6l6 6-6 6" })
535
595
  }
536
596
  );
537
- function Ct(t) {
538
- return t === "top-left" || t === "bottom-left" ? "left" : "right";
597
+ function vn(e) {
598
+ return e === "top-left" || e === "bottom-left" ? "left" : "right";
539
599
  }
540
- const Fe = "ll-hidden-tab-center-y", Nt = 5, Ue = 16;
541
- function Et() {
600
+ const kt = "ll-hidden-tab-center-y", yn = 5, pt = 16;
601
+ function bn() {
542
602
  if (typeof window > "u") return null;
543
603
  try {
544
- const t = window.localStorage.getItem(Fe);
545
- if (!t) return null;
546
- const n = Number.parseFloat(t);
604
+ const e = window.localStorage.getItem(kt);
605
+ if (!e) return null;
606
+ const n = Number.parseFloat(e);
547
607
  return Number.isFinite(n) ? n : null;
548
608
  } catch {
549
609
  return null;
550
610
  }
551
611
  }
552
- function $e(t) {
612
+ function mt(e) {
553
613
  if (!(typeof window > "u"))
554
614
  try {
555
- window.localStorage.setItem(Fe, String(t));
615
+ window.localStorage.setItem(kt, String(e));
556
616
  } catch {
557
617
  }
558
618
  }
559
- const St = ({
560
- position: t,
619
+ const wn = ({
620
+ position: e,
561
621
  isMobile: n,
562
- isSpeaking: i,
563
- onExpand: l,
564
- label: r = "Open widget"
622
+ isSpeaking: r,
623
+ onExpand: i,
624
+ label: o = "Open widget"
565
625
  }) => {
566
- const s = Ct(t), c = s === "right" ? "left" : "right", m = n ? 80 : 72, [d, f] = k(null), [p, o] = k(!1), a = M(null), C = M(!1), b = g(
567
- (w) => {
568
- if (typeof window > "u") return w;
569
- const x = m / 2, y = Ue + x, A = window.innerHeight - Ue - x;
570
- return A < y ? Math.max(y, w) : Math.max(y, Math.min(A, w));
626
+ const l = vn(e), d = l === "right" ? "left" : "right", u = n ? 80 : 72, [s, g] = C(null), [f, a] = C(!1), c = A(null), S = A(!1), x = y(
627
+ (k) => {
628
+ if (typeof window > "u") return k;
629
+ const L = u / 2, w = pt + L, z = window.innerHeight - pt - L;
630
+ return z < w ? Math.max(w, k) : Math.max(w, Math.min(z, k));
571
631
  },
572
- [m]
632
+ [u]
573
633
  );
574
- S(() => {
575
- const w = Et();
576
- f(b(w ?? window.innerHeight / 2));
577
- const x = () => {
578
- f((y) => y === null ? null : b(y));
634
+ I(() => {
635
+ const k = bn();
636
+ g(x(k ?? window.innerHeight / 2));
637
+ const L = () => {
638
+ g((w) => w === null ? null : x(w));
579
639
  };
580
- return window.addEventListener("resize", x), () => window.removeEventListener("resize", x);
581
- }, [b]);
582
- const N = g(
583
- (w) => {
584
- if (!(w.pointerType === "mouse" && w.button !== 0) && d !== null) {
640
+ return window.addEventListener("resize", L), () => window.removeEventListener("resize", L);
641
+ }, [x]);
642
+ const E = y(
643
+ (k) => {
644
+ if (!(k.pointerType === "mouse" && k.button !== 0) && s !== null) {
585
645
  try {
586
- w.currentTarget.setPointerCapture(w.pointerId);
646
+ k.currentTarget.setPointerCapture(k.pointerId);
587
647
  } catch {
588
648
  }
589
- a.current = {
590
- startClientY: w.clientY,
591
- startCenterY: d,
649
+ c.current = {
650
+ startClientY: k.clientY,
651
+ startCenterY: s,
592
652
  moved: !1
593
653
  };
594
654
  }
595
655
  },
596
- [d]
597
- ), D = g(
598
- (w) => {
599
- const x = a.current;
600
- if (!x) return;
601
- const y = w.clientY - x.startClientY;
602
- !x.moved && Math.abs(y) > Nt && (x.moved = !0, o(!0)), x.moved && f(b(x.startCenterY + y));
656
+ [s]
657
+ ), P = y(
658
+ (k) => {
659
+ const L = c.current;
660
+ if (!L) return;
661
+ const w = k.clientY - L.startClientY;
662
+ !L.moved && Math.abs(w) > yn && (L.moved = !0, a(!0)), L.moved && g(x(L.startCenterY + w));
603
663
  },
604
- [b]
605
- ), E = g(
606
- (w) => {
607
- const x = a.current;
608
- if (x) {
664
+ [x]
665
+ ), b = y(
666
+ (k) => {
667
+ const L = c.current;
668
+ if (L) {
609
669
  try {
610
- w.currentTarget.releasePointerCapture(w.pointerId);
670
+ k.currentTarget.releasePointerCapture(k.pointerId);
611
671
  } catch {
612
672
  }
613
- a.current = null, x.moved && (o(!1), C.current = !0, f((y) => (y !== null && $e(y), y)));
673
+ c.current = null, L.moved && (a(!1), S.current = !0, g((w) => (w !== null && mt(w), w)));
614
674
  }
615
675
  },
616
676
  []
617
- ), R = g(() => {
618
- if (C.current) {
619
- C.current = !1;
677
+ ), T = y(() => {
678
+ if (S.current) {
679
+ S.current = !1;
620
680
  return;
621
681
  }
622
- l();
623
- }, [l]), T = g(
624
- (w) => {
625
- if (w.key === "ArrowUp" || w.key === "ArrowDown") {
626
- w.preventDefault();
627
- const x = w.key === "ArrowUp" ? -8 : 8;
628
- f((y) => {
629
- if (y === null) return y;
630
- const A = b(y + x);
631
- return $e(A), A;
682
+ i();
683
+ }, [i]), p = y(
684
+ (k) => {
685
+ if (k.key === "ArrowUp" || k.key === "ArrowDown") {
686
+ k.preventDefault();
687
+ const L = k.key === "ArrowUp" ? -8 : 8;
688
+ g((w) => {
689
+ if (w === null) return w;
690
+ const z = x(w + L);
691
+ return mt(z), z;
632
692
  });
633
693
  }
634
694
  },
635
- [b]
636
- ), z = [
695
+ [x]
696
+ ), N = [
637
697
  "ll-hidden",
638
- `ll-hidden--${s}`,
698
+ `ll-hidden--${l}`,
639
699
  n ? "ll-hidden--mobile" : "ll-hidden--desktop",
640
- i ? "ll-hidden--speaking" : null,
641
- p ? "is-dragging" : null
642
- ].filter(Boolean).join(" "), I = d === null ? void 0 : { top: `${d - m / 2}px`, transform: "none" };
643
- return /* @__PURE__ */ e(
700
+ r ? "ll-hidden--speaking" : null,
701
+ f ? "is-dragging" : null
702
+ ].filter(Boolean).join(" "), R = s === null ? void 0 : { top: `${s - u / 2}px`, transform: "none" };
703
+ return /* @__PURE__ */ t(
644
704
  "button",
645
705
  {
646
706
  type: "button",
647
- className: z,
648
- onPointerDown: N,
649
- onPointerMove: D,
650
- onPointerUp: E,
651
- onPointerCancel: E,
652
- onClick: R,
653
- onKeyDown: T,
654
- "aria-label": r,
655
- "data-position": t,
656
- style: I,
657
- children: /* @__PURE__ */ e(xt, { direction: c, className: "ll-hidden__chevron" })
707
+ className: N,
708
+ onPointerDown: E,
709
+ onPointerMove: P,
710
+ onPointerUp: b,
711
+ onPointerCancel: b,
712
+ onClick: T,
713
+ onKeyDown: p,
714
+ "aria-label": o,
715
+ "data-position": e,
716
+ style: R,
717
+ children: /* @__PURE__ */ t(gn, { direction: d, className: "ll-hidden__chevron" })
658
718
  }
659
719
  );
660
- }, Mt = ({
661
- audioLevel: t,
720
+ }, _n = ({
721
+ audioLevel: e,
662
722
  bars: n = 20,
663
- maxHeight: i = 20,
664
- minHeight: l = 4,
665
- className: r,
666
- barClassName: s
723
+ maxHeight: r = 20,
724
+ minHeight: i = 4,
725
+ className: o,
726
+ barClassName: l
667
727
  }) => {
668
- const c = M(null), m = M([]), d = Se(() => {
669
- const p = (Math.sqrt(5) - 1) / 2;
670
- return Array.from({ length: n }, (o, a) => 0.5 + a * p % 1 * 0.5);
728
+ const d = A(null), u = A([]), s = De(() => {
729
+ const f = (Math.sqrt(5) - 1) / 2;
730
+ return Array.from({ length: n }, (a, c) => 0.5 + c * f % 1 * 0.5);
671
731
  }, [n]);
672
- S(() => t.subscribe((o) => {
673
- for (let a = 0; a < n; a++) {
674
- const C = m.current[a];
675
- if (!C) continue;
676
- const b = Math.max(l, o * i * d[a]);
677
- C.style.height = `${b}px`;
732
+ I(() => e.subscribe((a) => {
733
+ for (let c = 0; c < n; c++) {
734
+ const S = u.current[c];
735
+ if (!S) continue;
736
+ const x = Math.max(i, a * r * s[c]);
737
+ S.style.height = `${x}px`;
678
738
  }
679
- }), [t, n, i, l, d]);
680
- const f = ["ll-waveform", r].filter(Boolean).join(" ");
681
- return /* @__PURE__ */ e("div", { ref: c, className: f, "aria-hidden": "true", children: Array.from({ length: n }, (p, o) => /* @__PURE__ */ e(
739
+ }), [e, n, r, i, s]);
740
+ const g = ["ll-waveform", o].filter(Boolean).join(" ");
741
+ return /* @__PURE__ */ t("div", { ref: d, className: g, "aria-hidden": "true", children: Array.from({ length: n }, (f, a) => /* @__PURE__ */ t(
682
742
  "div",
683
743
  {
684
- ref: (a) => {
685
- m.current[o] = a;
744
+ ref: (c) => {
745
+ u.current[a] = c;
686
746
  },
687
- className: ["ll-waveform__bar", s].filter(Boolean).join(" "),
688
- style: { height: `${l}px` }
747
+ className: ["ll-waveform__bar", l].filter(Boolean).join(" "),
748
+ style: { height: `${i}px` }
689
749
  },
690
- o
750
+ a
691
751
  )) });
692
- }, Lt = ({
693
- position: t,
752
+ }, xn = ({
753
+ position: e,
694
754
  isMobile: n,
695
- agentName: i,
696
- avatarImageUrl: l,
697
- agentState: r,
698
- isMuted: s,
699
- audioLevel: c,
700
- onExpand: m,
701
- onToggleMute: d,
702
- onClose: f
703
- }) => n ? /* @__PURE__ */ e(
755
+ agentName: r,
756
+ avatarImageUrl: i,
757
+ agentState: o,
758
+ isMuted: l,
759
+ audioLevel: d,
760
+ onExpand: u,
761
+ onToggleMute: s,
762
+ onClose: g
763
+ }) => n ? /* @__PURE__ */ t(
704
764
  "div",
705
765
  {
706
766
  className: "ll-minimized ll-minimized--mobile",
707
767
  role: "region",
708
- "aria-label": `${i} widget`,
768
+ "aria-label": `${r} widget`,
709
769
  children: /* @__PURE__ */ _(
710
770
  "button",
711
771
  {
712
772
  type: "button",
713
773
  className: "ll-minimized__surface",
714
- onClick: m,
715
- "aria-label": `Expand ${i} widget`,
774
+ onClick: u,
775
+ "aria-label": `Expand ${r} widget`,
716
776
  children: [
717
- l ? (
777
+ i ? (
718
778
  // eslint-disable-next-line @next/next/no-img-element
719
- /* @__PURE__ */ e(
779
+ /* @__PURE__ */ t(
720
780
  "img",
721
781
  {
722
- src: l,
723
- alt: i,
782
+ src: i,
783
+ alt: r,
724
784
  className: "ll-minimized__avatar"
725
785
  }
726
786
  )
727
- ) : /* @__PURE__ */ e("div", { className: "ll-minimized__avatar ll-minimized__avatar--placeholder" }),
728
- /* @__PURE__ */ e(
729
- Mt,
787
+ ) : /* @__PURE__ */ t("div", { className: "ll-minimized__avatar ll-minimized__avatar--placeholder" }),
788
+ /* @__PURE__ */ t(
789
+ _n,
730
790
  {
731
- audioLevel: c,
791
+ audioLevel: d,
732
792
  bars: 16,
733
793
  maxHeight: 18,
734
794
  className: "ll-minimized__waveform"
735
795
  }
736
796
  ),
737
- /* @__PURE__ */ e("span", { className: "ll-minimized__name", children: i }),
797
+ /* @__PURE__ */ t("span", { className: "ll-minimized__name", children: r }),
738
798
  /* @__PURE__ */ _("div", { className: "ll-minimized__controls", children: [
739
- /* @__PURE__ */ e(
799
+ /* @__PURE__ */ t(
740
800
  "span",
741
801
  {
742
802
  className: "ll-minimized__btn",
743
803
  role: "button",
744
804
  tabIndex: 0,
745
- onClick: (p) => {
746
- p.stopPropagation(), d();
805
+ onClick: (f) => {
806
+ f.stopPropagation(), s();
747
807
  },
748
- onKeyDown: (p) => {
749
- (p.key === "Enter" || p.key === " ") && (p.stopPropagation(), p.preventDefault(), d());
808
+ onKeyDown: (f) => {
809
+ (f.key === "Enter" || f.key === " ") && (f.stopPropagation(), f.preventDefault(), s());
750
810
  },
751
- "aria-label": s ? "Unmute microphone" : "Mute microphone",
752
- children: /* @__PURE__ */ e(Pe, { muted: s, className: "ll-minimized__icon" })
811
+ "aria-label": l ? "Unmute microphone" : "Mute microphone",
812
+ children: /* @__PURE__ */ t(ht, { muted: l, className: "ll-minimized__icon" })
753
813
  }
754
814
  ),
755
- /* @__PURE__ */ e(Be, { className: "ll-minimized__icon ll-minimized__icon--expand" })
815
+ /* @__PURE__ */ t(ft, { className: "ll-minimized__icon ll-minimized__icon--expand" })
756
816
  ] })
757
817
  ]
758
818
  }
759
819
  )
760
820
  }
761
- ) : /* @__PURE__ */ e(
821
+ ) : /* @__PURE__ */ t(
762
822
  "div",
763
823
  {
764
824
  className: "ll-minimized ll-minimized--desktop",
765
- "data-position": t,
825
+ "data-position": e,
766
826
  role: "region",
767
- "aria-label": `${i} widget`,
827
+ "aria-label": `${r} widget`,
768
828
  children: /* @__PURE__ */ _("div", { className: "ll-minimized__surface", children: [
769
- l ? (
829
+ i ? (
770
830
  // eslint-disable-next-line @next/next/no-img-element
771
- /* @__PURE__ */ e(
831
+ /* @__PURE__ */ t(
772
832
  "img",
773
833
  {
774
- src: l,
775
- alt: i,
834
+ src: i,
835
+ alt: r,
776
836
  className: "ll-minimized__avatar"
777
837
  }
778
838
  )
779
- ) : /* @__PURE__ */ e("div", { className: "ll-minimized__avatar ll-minimized__avatar--placeholder" }),
839
+ ) : /* @__PURE__ */ t("div", { className: "ll-minimized__avatar ll-minimized__avatar--placeholder" }),
780
840
  /* @__PURE__ */ _("div", { className: "ll-minimized__meta", children: [
781
- /* @__PURE__ */ e("span", { className: "ll-minimized__name", children: i }),
782
- /* @__PURE__ */ e("span", { className: "ll-minimized__state", children: r === "speaking" ? "Speaking" : r === "thinking" ? "Thinking" : "Listening" })
841
+ /* @__PURE__ */ t("span", { className: "ll-minimized__name", children: r }),
842
+ /* @__PURE__ */ t("span", { className: "ll-minimized__state", children: o === "speaking" ? "Speaking" : o === "thinking" ? "Thinking" : "Listening" })
783
843
  ] }),
784
844
  /* @__PURE__ */ _("div", { className: "ll-minimized__controls", children: [
785
- /* @__PURE__ */ e(
845
+ /* @__PURE__ */ t(
786
846
  "button",
787
847
  {
788
848
  type: "button",
789
849
  className: "ll-minimized__btn",
790
- onClick: d,
791
- "aria-label": s ? "Unmute microphone" : "Mute microphone",
792
- children: /* @__PURE__ */ e(Pe, { muted: s, className: "ll-minimized__icon" })
850
+ onClick: s,
851
+ "aria-label": l ? "Unmute microphone" : "Mute microphone",
852
+ children: /* @__PURE__ */ t(ht, { muted: l, className: "ll-minimized__icon" })
793
853
  }
794
854
  ),
795
- /* @__PURE__ */ e(
855
+ /* @__PURE__ */ t(
796
856
  "button",
797
857
  {
798
858
  type: "button",
799
859
  className: "ll-minimized__btn",
800
- onClick: m,
801
- "aria-label": `Expand ${i} widget`,
802
- children: /* @__PURE__ */ e(Be, { className: "ll-minimized__icon" })
860
+ onClick: u,
861
+ "aria-label": `Expand ${r} widget`,
862
+ children: /* @__PURE__ */ t(ft, { className: "ll-minimized__icon" })
803
863
  }
804
864
  ),
805
- /* @__PURE__ */ e(
865
+ /* @__PURE__ */ t(
806
866
  "button",
807
867
  {
808
868
  type: "button",
809
869
  className: "ll-minimized__btn ll-minimized__btn--close",
810
- onClick: f,
870
+ onClick: g,
811
871
  "aria-label": "Close widget",
812
- children: /* @__PURE__ */ e(wt, { className: "ll-minimized__icon" })
872
+ children: /* @__PURE__ */ t(pn, { className: "ll-minimized__icon" })
813
873
  }
814
874
  )
815
875
  ] })
816
876
  ] })
817
877
  }
818
- ), It = ({
819
- src: t,
878
+ ), kn = ({
879
+ src: e,
820
880
  alt: n,
821
- preCannedPlaying: i = !1,
822
- className: l,
823
- style: r
881
+ preCannedPlaying: r = !1,
882
+ className: i,
883
+ style: o
824
884
  }) => {
825
- const [s, c] = k(!1), m = M(t);
826
- if (S(() => {
827
- m.current !== t && (m.current = t, c(!1));
828
- }, [t]), !t) return null;
829
- const d = {
885
+ const [l, d] = C(!1), u = A(e);
886
+ if (I(() => {
887
+ u.current !== e && (u.current = e, d(!1));
888
+ }, [e]), !e) return null;
889
+ const s = {
830
890
  position: "absolute",
831
891
  inset: 0,
832
892
  width: "100%",
@@ -834,133 +894,133 @@ const St = ({
834
894
  objectFit: "cover",
835
895
  objectPosition: "top",
836
896
  transition: "opacity 500ms ease, transform 500ms ease",
837
- transform: i ? "scale(1.02)" : "scale(1)",
838
- opacity: s ? 1 : 0,
839
- ...r
897
+ transform: r ? "scale(1.02)" : "scale(1)",
898
+ opacity: l ? 1 : 0,
899
+ ...o
840
900
  };
841
901
  return (
842
902
  // eslint-disable-next-line @next/next/no-img-element
843
- /* @__PURE__ */ e(
903
+ /* @__PURE__ */ t(
844
904
  "img",
845
905
  {
846
- src: t,
906
+ src: e,
847
907
  alt: n,
848
- className: l,
849
- style: d,
908
+ className: i,
909
+ style: s,
850
910
  loading: "eager",
851
911
  fetchpriority: "high",
852
- onLoad: () => c(!0)
912
+ onLoad: () => d(!0)
853
913
  }
854
914
  )
855
915
  );
856
- }, At = ({
857
- position: t,
916
+ }, Cn = ({
917
+ position: e,
858
918
  isMobile: n,
859
- agentName: i,
860
- avatarImageUrl: l,
861
- idleLoopUrl: r,
862
- greeting: s,
863
- branding: c,
864
- teamMembers: m,
865
- currentTeamMemberId: d,
866
- isSwitchingTeamMember: f,
867
- teamSwitcherOpen: p,
868
- onToggleTeamSwitcher: o,
869
- onSelectTeamMember: a,
870
- languageMenuOpen: C,
871
- onToggleLanguageMenu: b,
872
- connectionState: N,
873
- agentState: D,
874
- transcript: E,
875
- canResume: R,
876
- needsUserGesture: T,
877
- error: z,
878
- isMuted: I,
879
- micError: w,
880
- micDevices: x,
881
- isCameraEnabled: y,
882
- cameraPreviewEl: A,
883
- cameraDevices: X,
884
- activeCameraId: ne,
885
- isScreenShareEnabled: $,
886
- screenPreviewEl: j,
887
- isSpeakerMuted: F,
888
- allowCamera: re,
889
- allowScreenShare: P,
890
- allowTyping: be,
891
- avatarVideoContainerRef: we,
892
- onConnect: ge,
893
- onDisconnect: ue,
894
- onRetry: ke,
895
- onResumeAudio: xe,
896
- onToggleMute: Q,
897
- onToggleCamera: U,
898
- onSwitchCameraDevice: ve,
899
- onToggleScreenShare: Z,
900
- onToggleSpeaker: G,
901
- onSendMessage: ee,
902
- onMinimize: ie,
903
- onClose: V,
904
- onClearMicError: K
919
+ agentName: r,
920
+ avatarImageUrl: i,
921
+ idleLoopUrl: o,
922
+ greeting: l,
923
+ branding: d,
924
+ teamMembers: u,
925
+ currentTeamMemberId: s,
926
+ isSwitchingTeamMember: g,
927
+ teamSwitcherOpen: f,
928
+ onToggleTeamSwitcher: a,
929
+ onSelectTeamMember: c,
930
+ languageMenuOpen: S,
931
+ onToggleLanguageMenu: x,
932
+ connectionState: E,
933
+ agentState: P,
934
+ transcript: b,
935
+ canResume: T,
936
+ needsUserGesture: p,
937
+ error: N,
938
+ isMuted: R,
939
+ micError: k,
940
+ micDevices: L,
941
+ isCameraEnabled: w,
942
+ cameraPreviewEl: z,
943
+ cameraDevices: Ee,
944
+ activeCameraId: $e,
945
+ isScreenShareEnabled: K,
946
+ screenPreviewEl: X,
947
+ isSpeakerMuted: Z,
948
+ allowCamera: Ne,
949
+ allowScreenShare: oe,
950
+ allowTyping: le,
951
+ avatarVideoContainerRef: ae,
952
+ onConnect: ee,
953
+ onDisconnect: ce,
954
+ onRetry: se,
955
+ onResumeAudio: de,
956
+ onToggleMute: D,
957
+ onToggleCamera: Be,
958
+ onSwitchCameraDevice: Ue,
959
+ onToggleScreenShare: Oe,
960
+ onToggleSpeaker: Se,
961
+ onSendMessage: ue,
962
+ onMinimize: he,
963
+ onClose: Le,
964
+ onClearMicError: He
905
965
  }) => {
906
- var ye;
907
- const O = E.length > 0 ? E[E.length - 1] : null, Y = ((m == null ? void 0 : m.length) ?? 0) > 1, le = N === "connecting" || N === "connected", H = N === "connected", he = N === "idle" || N === "disconnected" || N === "error", pe = M(null), oe = M(null);
908
- S(() => {
909
- const h = pe.current;
910
- h && (h.innerHTML = "", A && (A.style.width = "100%", A.style.height = "100%", A.style.objectFit = "cover", A.style.transform = "scaleX(-1)", h.appendChild(A)));
911
- }, [A]), S(() => {
912
- const h = oe.current;
913
- h && (h.innerHTML = "", j && (j.style.width = "100%", j.style.height = "100%", j.style.objectFit = "contain", h.appendChild(j)));
914
- }, [j]);
915
- const [q, ae] = k(!1), [se, J] = k(!1);
916
- S(() => {
917
- if (!q && !se && !C && !p) return;
966
+ var Me;
967
+ const V = b.length > 0 ? b[b.length - 1] : null, $ = ((u == null ? void 0 : u.length) ?? 0) > 1, te = E === "connecting" || E === "connected", W = E === "connected", J = E === "idle" || E === "disconnected" || E === "error", ne = A(null), fe = A(null);
968
+ I(() => {
969
+ const h = ne.current;
970
+ h && (h.innerHTML = "", z && (z.style.width = "100%", z.style.height = "100%", z.style.objectFit = "cover", z.style.transform = "scaleX(-1)", h.appendChild(z)));
971
+ }, [z]), I(() => {
972
+ const h = fe.current;
973
+ h && (h.innerHTML = "", X && (X.style.width = "100%", X.style.height = "100%", X.style.objectFit = "contain", h.appendChild(X)));
974
+ }, [X]);
975
+ const [j, F] = C(!1), [q, Q] = C(!1);
976
+ I(() => {
977
+ if (!j && !q && !S && !f) return;
918
978
  const h = () => {
919
- ae(!1), J(!1), C && b(), p && o();
979
+ F(!1), Q(!1), S && x(), f && a();
920
980
  };
921
981
  return document.addEventListener("click", h), () => document.removeEventListener("click", h);
922
982
  }, [
983
+ j,
923
984
  q,
924
- se,
925
- C,
926
- p,
927
- b,
928
- o
985
+ S,
986
+ f,
987
+ x,
988
+ a
929
989
  ]);
930
- const [ce, de] = k(""), B = g(
990
+ const [pe, me] = C(""), we = y(
931
991
  (h) => {
932
992
  h.preventDefault();
933
- const W = ce.trim();
934
- W && (ee(W), de(""));
993
+ const O = pe.trim();
994
+ O && (ue(O), me(""));
935
995
  },
936
- [ce, ee]
937
- ), u = c.productName || "Live Layer", me = H && (O != null && O.text) ? O.text : s || "", Ce = [
996
+ [pe, ue]
997
+ ), Ae = d.productName || "Live Layer", ge = W && (V != null && V.text) ? V.text : l || "", _e = [
938
998
  "ll-expanded",
939
999
  n ? "ll-expanded--mobile" : "ll-expanded--desktop"
940
1000
  ].join(" ");
941
1001
  return /* @__PURE__ */ _(
942
1002
  "div",
943
1003
  {
944
- className: Ce,
945
- "data-position": t,
946
- "data-state": H ? "connected" : le ? "connecting" : "idle",
1004
+ className: _e,
1005
+ "data-position": e,
1006
+ "data-state": W ? "connected" : te ? "connecting" : "idle",
947
1007
  role: "dialog",
948
- "aria-label": `${i} widget`,
1008
+ "aria-label": `${r} widget`,
949
1009
  children: [
950
1010
  /* @__PURE__ */ _("div", { className: "ll-expanded__bg", children: [
951
- l ? /* @__PURE__ */ e(
952
- It,
1011
+ i ? /* @__PURE__ */ t(
1012
+ kn,
953
1013
  {
954
- src: l,
955
- alt: i,
1014
+ src: i,
1015
+ alt: r,
956
1016
  className: "ll-expanded__bg-img"
957
1017
  }
958
- ) : /* @__PURE__ */ e("div", { className: "ll-expanded__bg-fallback", children: /* @__PURE__ */ e("span", { className: "ll-expanded__bg-initial", children: ((ye = i == null ? void 0 : i.charAt(0)) == null ? void 0 : ye.toUpperCase()) || "A" }) }),
959
- r && !H && /* @__PURE__ */ e(
1018
+ ) : /* @__PURE__ */ t("div", { className: "ll-expanded__bg-fallback", children: /* @__PURE__ */ t("span", { className: "ll-expanded__bg-initial", children: ((Me = r == null ? void 0 : r.charAt(0)) == null ? void 0 : Me.toUpperCase()) || "A" }) }),
1019
+ o && !W && /* @__PURE__ */ t(
960
1020
  "video",
961
1021
  {
962
1022
  className: "ll-expanded__bg-idle",
963
- src: r,
1023
+ src: o,
964
1024
  autoPlay: !0,
965
1025
  loop: !0,
966
1026
  muted: !0,
@@ -968,24 +1028,24 @@ const St = ({
968
1028
  }
969
1029
  )
970
1030
  ] }),
971
- /* @__PURE__ */ e("div", { ref: we, className: "ll-expanded__video" }),
972
- N === "connecting" && /* @__PURE__ */ _("div", { className: "ll-expanded__overlay ll-expanded__overlay--connecting", children: [
973
- /* @__PURE__ */ e("div", { className: "ll-expanded__spinner" }),
974
- /* @__PURE__ */ e("p", { className: "ll-expanded__overlay-text", children: f ? "Switching..." : "Connecting..." })
1031
+ /* @__PURE__ */ t("div", { ref: ae, className: "ll-expanded__video" }),
1032
+ E === "connecting" && /* @__PURE__ */ _("div", { className: "ll-expanded__overlay ll-expanded__overlay--connecting", children: [
1033
+ /* @__PURE__ */ t("div", { className: "ll-expanded__spinner" }),
1034
+ /* @__PURE__ */ t("p", { className: "ll-expanded__overlay-text", children: g ? "Switching..." : "Connecting..." })
975
1035
  ] }),
976
- T && H && /* @__PURE__ */ _(
1036
+ p && W && /* @__PURE__ */ _(
977
1037
  "button",
978
1038
  {
979
1039
  type: "button",
980
1040
  className: "ll-expanded__overlay ll-expanded__overlay--gesture",
981
- onClick: xe,
1041
+ onClick: de,
982
1042
  children: [
983
- /* @__PURE__ */ e("svg", { width: "32", height: "32", viewBox: "0 0 24 24", fill: "currentColor", "aria-hidden": !0, children: /* @__PURE__ */ e("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" }) }),
984
- /* @__PURE__ */ e("p", { className: "ll-expanded__overlay-text", children: "Tap to enable audio" })
1043
+ /* @__PURE__ */ t("svg", { width: "32", height: "32", viewBox: "0 0 24 24", fill: "currentColor", "aria-hidden": !0, children: /* @__PURE__ */ t("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" }) }),
1044
+ /* @__PURE__ */ t("p", { className: "ll-expanded__overlay-text", children: "Tap to enable audio" })
985
1045
  ]
986
1046
  }
987
1047
  ),
988
- le ? /* @__PURE__ */ _("div", { className: "ll-expanded__topbar", children: [
1048
+ te ? /* @__PURE__ */ _("div", { className: "ll-expanded__topbar", children: [
989
1049
  /* @__PURE__ */ _("div", { className: "ll-expanded__topbar-left", children: [
990
1050
  /* @__PURE__ */ _("div", { className: "ll-expanded__pill-wrap", children: [
991
1051
  /* @__PURE__ */ _(
@@ -994,32 +1054,32 @@ const St = ({
994
1054
  type: "button",
995
1055
  className: "ll-hpill",
996
1056
  onClick: (h) => {
997
- Y && (h.stopPropagation(), o());
1057
+ $ && (h.stopPropagation(), a());
998
1058
  },
999
- "aria-haspopup": Y ? "listbox" : void 0,
1000
- "aria-expanded": Y ? p : void 0,
1059
+ "aria-haspopup": $ ? "listbox" : void 0,
1060
+ "aria-expanded": $ ? f : void 0,
1001
1061
  children: [
1002
- /* @__PURE__ */ e("span", { className: "ll-hpill__label", children: i }),
1003
- Y && /* @__PURE__ */ e(_e, {})
1062
+ /* @__PURE__ */ t("span", { className: "ll-hpill__label", children: r }),
1063
+ $ && /* @__PURE__ */ t(Te, {})
1004
1064
  ]
1005
1065
  }
1006
1066
  ),
1007
- Y && p && /* @__PURE__ */ e(
1067
+ $ && f && /* @__PURE__ */ t(
1008
1068
  "div",
1009
1069
  {
1010
1070
  className: "ll-hmenu",
1011
1071
  onClick: (h) => h.stopPropagation(),
1012
1072
  role: "listbox",
1013
- children: m == null ? void 0 : m.map((h) => /* @__PURE__ */ _(
1073
+ children: u == null ? void 0 : u.map((h) => /* @__PURE__ */ _(
1014
1074
  "button",
1015
1075
  {
1016
1076
  type: "button",
1017
- className: `ll-hmenu__item ${h.id === d ? "is-active" : ""}`,
1018
- onClick: () => a(h.id),
1077
+ className: `ll-hmenu__item ${h.id === s ? "is-active" : ""}`,
1078
+ onClick: () => c(h.id),
1019
1079
  role: "option",
1020
- "aria-selected": h.id === d,
1080
+ "aria-selected": h.id === s,
1021
1081
  children: [
1022
- h.avatarImageUrl && /* @__PURE__ */ e(
1082
+ h.avatarImageUrl && /* @__PURE__ */ t(
1023
1083
  "img",
1024
1084
  {
1025
1085
  src: h.avatarImageUrl,
@@ -1027,8 +1087,8 @@ const St = ({
1027
1087
  className: "ll-hmenu__avatar"
1028
1088
  }
1029
1089
  ),
1030
- /* @__PURE__ */ e("span", { className: "ll-hmenu__name", children: h.name }),
1031
- h.role && /* @__PURE__ */ e("span", { className: "ll-hmenu__role", children: h.role })
1090
+ /* @__PURE__ */ t("span", { className: "ll-hmenu__name", children: h.name }),
1091
+ h.role && /* @__PURE__ */ t("span", { className: "ll-hmenu__role", children: h.role })
1032
1092
  ]
1033
1093
  },
1034
1094
  h.id
@@ -1041,294 +1101,311 @@ const St = ({
1041
1101
  "button",
1042
1102
  {
1043
1103
  type: "button",
1044
- className: "ll-hpill",
1104
+ className: "ll-hpill ll-hpill--compact",
1045
1105
  onClick: (h) => {
1046
- h.stopPropagation(), b();
1106
+ h.stopPropagation(), x();
1047
1107
  },
1048
1108
  "aria-haspopup": "listbox",
1049
- "aria-expanded": C,
1109
+ "aria-expanded": S,
1110
+ "aria-label": "Language: English",
1111
+ title: "Language: English",
1050
1112
  children: [
1051
- /* @__PURE__ */ e("span", { className: "ll-hpill__label", children: "English" }),
1052
- /* @__PURE__ */ e(_e, {})
1113
+ /* @__PURE__ */ t("span", { className: "ll-hpill__label", children: "EN" }),
1114
+ /* @__PURE__ */ t(Te, {})
1053
1115
  ]
1054
1116
  }
1055
1117
  ),
1056
- C && /* @__PURE__ */ e(
1118
+ S && /* @__PURE__ */ t(
1057
1119
  "div",
1058
1120
  {
1059
1121
  className: "ll-hmenu",
1060
1122
  onClick: (h) => h.stopPropagation(),
1061
1123
  role: "listbox",
1062
- children: /* @__PURE__ */ e(
1124
+ children: /* @__PURE__ */ t(
1063
1125
  "button",
1064
1126
  {
1065
1127
  type: "button",
1066
1128
  className: "ll-hmenu__item is-active",
1067
1129
  role: "option",
1068
1130
  "aria-selected": !0,
1069
- children: /* @__PURE__ */ e("span", { className: "ll-hmenu__name", children: "English" })
1131
+ children: /* @__PURE__ */ t("span", { className: "ll-hmenu__name", children: "English" })
1070
1132
  }
1071
1133
  )
1072
1134
  }
1073
1135
  )
1074
1136
  ] }),
1075
- /* @__PURE__ */ e(
1137
+ /* @__PURE__ */ t(
1076
1138
  "span",
1077
1139
  {
1078
- className: `ll-expanded__state ll-expanded__state--${D}`,
1079
- children: D
1140
+ className: `ll-expanded__state ll-expanded__state--${P}`,
1141
+ children: P
1080
1142
  }
1081
1143
  )
1082
1144
  ] }),
1083
1145
  /* @__PURE__ */ _("div", { className: "ll-expanded__header-actions", children: [
1084
- /* @__PURE__ */ e(
1146
+ /* @__PURE__ */ t(
1085
1147
  "button",
1086
1148
  {
1087
1149
  type: "button",
1088
1150
  className: "ll-hbtn",
1089
- onClick: ie,
1151
+ onClick: he,
1090
1152
  "aria-label": "Minimize widget",
1091
1153
  title: "Minimize",
1092
- children: /* @__PURE__ */ e(Ve, {})
1154
+ children: /* @__PURE__ */ t(vt, {})
1093
1155
  }
1094
1156
  ),
1095
- /* @__PURE__ */ e(
1157
+ /* @__PURE__ */ t(
1096
1158
  "button",
1097
1159
  {
1098
1160
  type: "button",
1099
1161
  className: "ll-hbtn ll-hbtn--danger",
1100
- onClick: V,
1101
- "aria-label": "End conversation",
1102
- title: "End conversation",
1103
- children: /* @__PURE__ */ e(je, {})
1162
+ onClick: Le,
1163
+ "aria-label": "End call",
1164
+ title: "End call",
1165
+ children: /* @__PURE__ */ t(gt, {})
1104
1166
  }
1105
1167
  )
1106
1168
  ] })
1107
1169
  ] }) : (
1108
1170
  // Idle-state header with Live Layer product name + minimize/close
1109
1171
  /* @__PURE__ */ _("div", { className: "ll-expanded__header ll-expanded__header--idle", children: [
1110
- /* @__PURE__ */ e("span", { className: "ll-expanded__brand", children: u }),
1172
+ /* @__PURE__ */ t("span", { className: "ll-expanded__brand", children: Ae }),
1111
1173
  /* @__PURE__ */ _("div", { className: "ll-expanded__header-actions", children: [
1112
- /* @__PURE__ */ e(
1174
+ /* @__PURE__ */ t(
1113
1175
  "button",
1114
1176
  {
1115
1177
  type: "button",
1116
1178
  className: "ll-hbtn ll-hbtn--ghost",
1117
- onClick: ie,
1179
+ onClick: he,
1118
1180
  "aria-label": "Minimize widget",
1119
- children: /* @__PURE__ */ e(Ve, {})
1181
+ children: /* @__PURE__ */ t(vt, {})
1120
1182
  }
1121
1183
  ),
1122
- /* @__PURE__ */ e(
1184
+ /* @__PURE__ */ t(
1123
1185
  "button",
1124
1186
  {
1125
1187
  type: "button",
1126
1188
  className: "ll-hbtn ll-hbtn--danger",
1127
- onClick: V,
1189
+ onClick: Le,
1128
1190
  "aria-label": "Close widget",
1129
- children: /* @__PURE__ */ e(je, {})
1191
+ children: /* @__PURE__ */ t(gt, {})
1130
1192
  }
1131
1193
  )
1132
1194
  ] })
1133
1195
  ] })
1134
1196
  ),
1135
- he && /* @__PURE__ */ _(
1136
- "button",
1137
- {
1138
- type: "button",
1139
- className: "ll-expanded__play",
1140
- onClick: ge,
1141
- "aria-label": R ? "Resume session" : "Start video call",
1142
- children: [
1143
- /* @__PURE__ */ e("div", { className: "ll-expanded__play-circle", children: /* @__PURE__ */ e("svg", { width: "22", height: "22", viewBox: "0 0 24 24", fill: "currentColor", "aria-hidden": !0, children: /* @__PURE__ */ e("polygon", { points: "6 3 20 12 6 21 6 3" }) }) }),
1144
- /* @__PURE__ */ e("span", { className: "ll-expanded__play-label", children: R ? "Restart session" : "Start video call" }),
1145
- R && /* @__PURE__ */ e("span", { className: "ll-expanded__play-sublabel", children: "Pick up where you left off" })
1146
- ]
1147
- }
1148
- ),
1197
+ J && /* @__PURE__ */ (() => {
1198
+ const h = T ? "Restart paused session" : E === "disconnected" ? "Reconnect to agent" : "Start video call", O = T ? "Pick up where you left off" : null;
1199
+ return /* @__PURE__ */ _(_t, { children: [
1200
+ E === "idle" && !T && !N && /* @__PURE__ */ _(
1201
+ "button",
1202
+ {
1203
+ type: "button",
1204
+ className: "ll-expanded__play",
1205
+ onClick: ee,
1206
+ "aria-label": h,
1207
+ children: [
1208
+ /* @__PURE__ */ t("div", { className: "ll-expanded__play-circle", children: /* @__PURE__ */ t("svg", { width: "22", height: "22", viewBox: "0 0 24 24", fill: "currentColor", "aria-hidden": !0, children: /* @__PURE__ */ t("polygon", { points: "6 3 20 12 6 21 6 3" }) }) }),
1209
+ /* @__PURE__ */ t("span", { className: "ll-expanded__play-label", children: h })
1210
+ ]
1211
+ }
1212
+ ),
1213
+ /* @__PURE__ */ _("div", { className: "ll-expanded__bottom ll-expanded__bottom--idle", children: [
1214
+ l && /* @__PURE__ */ t("div", { className: "ll-expanded__transcript", children: /* @__PURE__ */ t("p", { className: "ll-expanded__transcript-text", children: l }) }),
1215
+ O && /* @__PURE__ */ t("p", { className: "ll-expanded__cta-sublabel", children: O }),
1216
+ /* @__PURE__ */ t(
1217
+ "button",
1218
+ {
1219
+ type: "button",
1220
+ className: "ll-expanded__cta",
1221
+ onClick: ee,
1222
+ "aria-label": h,
1223
+ children: h
1224
+ }
1225
+ )
1226
+ ] })
1227
+ ] });
1228
+ })(),
1149
1229
  /* @__PURE__ */ _(
1150
1230
  "div",
1151
1231
  {
1152
- className: `ll-expanded__pip ${le && (y || $) ? "is-visible" : ""}`,
1232
+ className: `ll-expanded__pip ${te && (w || K) ? "is-visible" : ""}`,
1153
1233
  children: [
1154
- /* @__PURE__ */ e(
1234
+ /* @__PURE__ */ t(
1155
1235
  "div",
1156
1236
  {
1157
- ref: oe,
1158
- className: $ ? "ll-expanded__pip-host" : "ll-expanded__pip-host is-hidden"
1237
+ ref: fe,
1238
+ className: K ? "ll-expanded__pip-host" : "ll-expanded__pip-host is-hidden"
1159
1239
  }
1160
1240
  ),
1161
- /* @__PURE__ */ e(
1241
+ /* @__PURE__ */ t(
1162
1242
  "div",
1163
1243
  {
1164
- ref: pe,
1165
- className: !$ && y ? "ll-expanded__pip-host" : "ll-expanded__pip-host is-hidden"
1244
+ ref: ne,
1245
+ className: !K && w ? "ll-expanded__pip-host" : "ll-expanded__pip-host is-hidden"
1166
1246
  }
1167
1247
  )
1168
1248
  ]
1169
1249
  }
1170
1250
  ),
1171
- le ? /* @__PURE__ */ _("div", { className: "ll-expanded__bottom", children: [
1172
- me && /* @__PURE__ */ e("div", { className: "ll-expanded__transcript", children: /* @__PURE__ */ e("p", { className: "ll-expanded__transcript-text", children: me }) }),
1251
+ te ? /* @__PURE__ */ _("div", { className: "ll-expanded__bottom", children: [
1252
+ ge && /* @__PURE__ */ t("div", { className: "ll-expanded__transcript", children: /* @__PURE__ */ t("p", { className: "ll-expanded__transcript-text", children: ge }) }),
1173
1253
  /* @__PURE__ */ _("div", { className: "ll-toolbar", onClick: (h) => h.stopPropagation(), children: [
1174
- P && /* @__PURE__ */ e(
1254
+ oe && /* @__PURE__ */ t(
1175
1255
  "button",
1176
1256
  {
1177
1257
  type: "button",
1178
- className: `ll-tool ${$ ? "is-on" : ""}`,
1179
- onClick: Z,
1180
- "aria-label": $ ? "Stop sharing screen" : "Share screen",
1181
- title: $ ? "Stop sharing" : "Share screen",
1182
- children: /* @__PURE__ */ e(Dt, {})
1258
+ className: `ll-tool ${K ? "is-on" : ""}`,
1259
+ onClick: Oe,
1260
+ "aria-label": K ? "Stop sharing screen" : "Share screen",
1261
+ title: K ? "Stop sharing" : "Share screen",
1262
+ children: /* @__PURE__ */ t(En, {})
1183
1263
  }
1184
1264
  ),
1185
- re && /* @__PURE__ */ _("div", { className: "ll-tool-split", children: [
1186
- /* @__PURE__ */ e(
1265
+ Ne && /* @__PURE__ */ _("div", { className: "ll-tool-split", children: [
1266
+ /* @__PURE__ */ t(
1187
1267
  "button",
1188
1268
  {
1189
1269
  type: "button",
1190
- className: `ll-tool ll-tool--left ${y ? "is-on" : ""}`,
1191
- onClick: U,
1192
- "aria-label": y ? "Turn off camera" : "Turn on camera",
1193
- title: y ? "Stop camera" : "Start camera",
1194
- children: /* @__PURE__ */ e(Rt, {})
1270
+ className: `ll-tool ll-tool--left ${w ? "is-on" : ""}`,
1271
+ onClick: Be,
1272
+ "aria-label": w ? "Turn off camera" : "Turn on camera",
1273
+ title: w ? "Stop camera" : "Start camera",
1274
+ children: /* @__PURE__ */ t(Nn, {})
1195
1275
  }
1196
1276
  ),
1197
- /* @__PURE__ */ e(
1277
+ /* @__PURE__ */ t(
1198
1278
  "button",
1199
1279
  {
1200
1280
  type: "button",
1201
- className: `ll-tool ll-tool--right ${y ? "is-on" : ""}`,
1281
+ className: `ll-tool ll-tool--right ${w ? "is-on" : ""}`,
1202
1282
  onClick: (h) => {
1203
- h.stopPropagation(), J((W) => !W), ae(!1);
1283
+ h.stopPropagation(), Q((O) => !O), F(!1);
1204
1284
  },
1205
1285
  "aria-label": "Camera devices",
1206
1286
  "aria-haspopup": "listbox",
1207
- "aria-expanded": se,
1208
- children: /* @__PURE__ */ e(_e, {})
1287
+ "aria-expanded": q,
1288
+ children: /* @__PURE__ */ t(Te, {})
1209
1289
  }
1210
1290
  ),
1211
- se && X.length > 0 && /* @__PURE__ */ e(
1212
- Oe,
1291
+ q && Ee.length > 0 && /* @__PURE__ */ t(
1292
+ yt,
1213
1293
  {
1214
1294
  label: "Camera",
1215
- devices: X,
1216
- activeId: ne,
1295
+ devices: Ee,
1296
+ activeId: $e,
1217
1297
  onPick: (h) => {
1218
- J(!1), ve(h);
1298
+ Q(!1), Ue(h);
1219
1299
  }
1220
1300
  }
1221
1301
  )
1222
1302
  ] }),
1223
1303
  /* @__PURE__ */ _("div", { className: "ll-tool-split", children: [
1224
- /* @__PURE__ */ e(
1304
+ /* @__PURE__ */ t(
1225
1305
  "button",
1226
1306
  {
1227
1307
  type: "button",
1228
- className: `ll-tool ll-tool--left ${I ? "is-muted" : ""}`,
1229
- onClick: Q,
1230
- "aria-label": I ? "Unmute microphone" : "Mute microphone",
1231
- title: I ? "Unmute" : "Mute",
1232
- children: /* @__PURE__ */ e(Tt, { muted: I })
1308
+ className: `ll-tool ll-tool--left ${R ? "is-muted" : ""}`,
1309
+ onClick: D,
1310
+ "aria-label": R ? "Unmute microphone" : "Mute microphone",
1311
+ title: R ? "Unmute" : "Mute",
1312
+ children: /* @__PURE__ */ t(Sn, { muted: R })
1233
1313
  }
1234
1314
  ),
1235
- /* @__PURE__ */ e(
1315
+ /* @__PURE__ */ t(
1236
1316
  "button",
1237
1317
  {
1238
1318
  type: "button",
1239
- className: `ll-tool ll-tool--right ${I ? "is-muted" : ""}`,
1319
+ className: `ll-tool ll-tool--right ${R ? "is-muted" : ""}`,
1240
1320
  onClick: (h) => {
1241
- h.stopPropagation(), ae((W) => !W), J(!1);
1321
+ h.stopPropagation(), F((O) => !O), Q(!1);
1242
1322
  },
1243
1323
  "aria-label": "Microphone devices",
1244
1324
  "aria-haspopup": "listbox",
1245
- "aria-expanded": q,
1246
- children: /* @__PURE__ */ e(_e, {})
1325
+ "aria-expanded": j,
1326
+ children: /* @__PURE__ */ t(Te, {})
1247
1327
  }
1248
1328
  ),
1249
- q && x.length > 0 && /* @__PURE__ */ e(
1250
- Oe,
1329
+ j && L.length > 0 && /* @__PURE__ */ t(
1330
+ yt,
1251
1331
  {
1252
1332
  label: "Microphone",
1253
- devices: x,
1333
+ devices: L,
1254
1334
  activeId: "",
1255
- onPick: () => ae(!1)
1335
+ onPick: () => F(!1)
1256
1336
  }
1257
1337
  )
1258
1338
  ] }),
1259
- /* @__PURE__ */ e(
1339
+ /* @__PURE__ */ t(
1260
1340
  "button",
1261
1341
  {
1262
1342
  type: "button",
1263
- className: `ll-tool ${F ? "is-muted" : ""}`,
1264
- onClick: G,
1265
- "aria-label": F ? "Unmute speaker" : "Mute speaker",
1266
- title: F ? "Unmute speaker" : "Mute speaker",
1267
- children: /* @__PURE__ */ e(zt, { muted: F })
1343
+ className: `ll-tool ${Z ? "is-muted" : ""}`,
1344
+ onClick: Se,
1345
+ "aria-label": Z ? "Unmute speaker" : "Mute speaker",
1346
+ title: Z ? "Unmute speaker" : "Mute speaker",
1347
+ children: /* @__PURE__ */ t(Ln, { muted: Z })
1268
1348
  }
1269
1349
  )
1270
1350
  ] }),
1271
- be && /* @__PURE__ */ _("form", { className: "ll-message-input", onSubmit: B, children: [
1272
- /* @__PURE__ */ e(
1351
+ le && /* @__PURE__ */ _("form", { className: "ll-message-input", onSubmit: we, children: [
1352
+ /* @__PURE__ */ t(
1273
1353
  "input",
1274
1354
  {
1275
1355
  type: "text",
1276
1356
  className: "ll-message-input__field",
1277
1357
  placeholder: "Message...",
1278
- value: ce,
1279
- onChange: (h) => de(h.target.value),
1358
+ value: pe,
1359
+ onChange: (h) => me(h.target.value),
1280
1360
  "aria-label": "Message the agent"
1281
1361
  }
1282
1362
  ),
1283
- ce.trim() && /* @__PURE__ */ e(
1363
+ pe.trim() && /* @__PURE__ */ t(
1284
1364
  "button",
1285
1365
  {
1286
1366
  type: "submit",
1287
1367
  className: "ll-message-input__send",
1288
1368
  "aria-label": "Send message",
1289
- children: /* @__PURE__ */ e(Pt, {})
1369
+ children: /* @__PURE__ */ t(An, {})
1290
1370
  }
1291
1371
  )
1292
1372
  ] }),
1293
- /* @__PURE__ */ e(
1373
+ /* @__PURE__ */ t(
1294
1374
  "button",
1295
1375
  {
1296
1376
  type: "button",
1297
1377
  className: "ll-expanded__end",
1298
- onClick: ue,
1378
+ onClick: ce,
1299
1379
  children: "End conversation"
1300
1380
  }
1301
1381
  )
1302
- ] }) : (
1303
- // Idle-state footer: start button + greeting
1304
- s && /* @__PURE__ */ e("div", { className: "ll-expanded__bottom ll-expanded__bottom--idle", children: /* @__PURE__ */ e("div", { className: "ll-expanded__transcript", children: /* @__PURE__ */ e("p", { className: "ll-expanded__transcript-text", children: s }) }) })
1305
- ),
1382
+ ] }) : null,
1306
1383
  (() => {
1307
- if (w && N !== "error")
1384
+ if (k && E !== "error")
1308
1385
  return /* @__PURE__ */ _("div", { className: "ll-expanded__banner", role: "alert", children: [
1309
- /* @__PURE__ */ e("span", { children: w }),
1310
- /* @__PURE__ */ e(
1386
+ /* @__PURE__ */ t("span", { children: k }),
1387
+ /* @__PURE__ */ t(
1311
1388
  "button",
1312
1389
  {
1313
1390
  type: "button",
1314
1391
  className: "ll-expanded__banner-x",
1315
- onClick: K,
1392
+ onClick: He,
1316
1393
  "aria-label": "Dismiss",
1317
1394
  children: "×"
1318
1395
  }
1319
1396
  )
1320
1397
  ] });
1321
- if (!z || N !== "error") return null;
1322
- let h = "Failed to connect", W = "Try again";
1323
- return z === "MIC_PERMISSION_DENIED" ? h = "Microphone blocked. Allow access to talk." : z === "MIC_NOT_FOUND" ? h = "No microphone found. Plug one in + retry." : z === "MIC_UNAVAILABLE" ? h = "Mic unavailable. Check other apps using it." : z === "AGENT_TIMEOUT" ? h = "Agent didn't pick up. Try again." : z === "CONNECT_FAILED" ? h = "Connection failed. Check your network." : z.length < 80 && (h = z), /* @__PURE__ */ _("div", { className: "ll-expanded__banner ll-expanded__banner--error", role: "alert", children: [
1324
- /* @__PURE__ */ e("span", { children: h }),
1325
- /* @__PURE__ */ e(
1398
+ if (!N || E !== "error") return null;
1399
+ let h = "Failed to connect", O = "Try again";
1400
+ return N === "MIC_PERMISSION_DENIED" ? h = "Microphone blocked. Allow access to talk." : N === "MIC_NOT_FOUND" ? h = "No microphone found. Plug one in + retry." : N === "MIC_UNAVAILABLE" ? h = "Mic unavailable. Check other apps using it." : N === "AGENT_TIMEOUT" ? h = "Agent didn't pick up. Try again." : N === "CONNECT_FAILED" ? h = "Connection failed. Check your network." : N.length < 80 && (h = N), /* @__PURE__ */ _("div", { className: "ll-expanded__banner ll-expanded__banner--error", role: "alert", children: [
1401
+ /* @__PURE__ */ t("span", { children: h }),
1402
+ /* @__PURE__ */ t(
1326
1403
  "button",
1327
1404
  {
1328
1405
  type: "button",
1329
1406
  className: "ll-expanded__banner-retry",
1330
- onClick: ke,
1331
- children: W
1407
+ onClick: se,
1408
+ children: O
1332
1409
  }
1333
1410
  )
1334
1411
  ] });
@@ -1337,83 +1414,218 @@ const St = ({
1337
1414
  }
1338
1415
  );
1339
1416
  };
1340
- function _e() {
1341
- return /* @__PURE__ */ e("svg", { width: "12", height: "12", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", "aria-hidden": !0, children: /* @__PURE__ */ e("polyline", { points: "6 9 12 15 18 9" }) });
1417
+ function Te() {
1418
+ return /* @__PURE__ */ t("svg", { width: "12", height: "12", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", "aria-hidden": !0, children: /* @__PURE__ */ t("polyline", { points: "6 9 12 15 18 9" }) });
1342
1419
  }
1343
- function je() {
1420
+ function gt() {
1344
1421
  return /* @__PURE__ */ _("svg", { width: "12", height: "12", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", strokeLinecap: "round", "aria-hidden": !0, children: [
1345
- /* @__PURE__ */ e("line", { x1: "18", y1: "6", x2: "6", y2: "18" }),
1346
- /* @__PURE__ */ e("line", { x1: "6", y1: "6", x2: "18", y2: "18" })
1422
+ /* @__PURE__ */ t("line", { x1: "18", y1: "6", x2: "6", y2: "18" }),
1423
+ /* @__PURE__ */ t("line", { x1: "6", y1: "6", x2: "18", y2: "18" })
1347
1424
  ] });
1348
1425
  }
1349
- function Ve() {
1350
- return /* @__PURE__ */ e("svg", { width: "12", height: "12", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", strokeLinecap: "round", "aria-hidden": !0, children: /* @__PURE__ */ e("line", { x1: "5", y1: "12", x2: "19", y2: "12" }) });
1426
+ function vt() {
1427
+ return /* @__PURE__ */ t("svg", { width: "12", height: "12", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", strokeLinecap: "round", "aria-hidden": !0, children: /* @__PURE__ */ t("line", { x1: "5", y1: "12", x2: "19", y2: "12" }) });
1351
1428
  }
1352
- function Dt() {
1429
+ function En() {
1353
1430
  return /* @__PURE__ */ _("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": !0, children: [
1354
- /* @__PURE__ */ e("rect", { x: "2", y: "3", width: "20", height: "14", rx: "2" }),
1355
- /* @__PURE__ */ e("line", { x1: "8", y1: "21", x2: "16", y2: "21" }),
1356
- /* @__PURE__ */ e("line", { x1: "12", y1: "17", x2: "12", y2: "21" })
1431
+ /* @__PURE__ */ t("rect", { x: "2", y: "3", width: "20", height: "14", rx: "2" }),
1432
+ /* @__PURE__ */ t("line", { x1: "8", y1: "21", x2: "16", y2: "21" }),
1433
+ /* @__PURE__ */ t("line", { x1: "12", y1: "17", x2: "12", y2: "21" })
1357
1434
  ] });
1358
1435
  }
1359
- function Rt() {
1436
+ function Nn() {
1360
1437
  return /* @__PURE__ */ _("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": !0, children: [
1361
- /* @__PURE__ */ e("path", { d: "M23 7l-7 5 7 5V7z" }),
1362
- /* @__PURE__ */ e("rect", { x: "1", y: "5", width: "15", height: "14", rx: "2" })
1438
+ /* @__PURE__ */ t("path", { d: "M23 7l-7 5 7 5V7z" }),
1439
+ /* @__PURE__ */ t("rect", { x: "1", y: "5", width: "15", height: "14", rx: "2" })
1363
1440
  ] });
1364
1441
  }
1365
- function Tt({ muted: t }) {
1442
+ function Sn({ muted: e }) {
1366
1443
  return /* @__PURE__ */ _("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": !0, children: [
1367
- /* @__PURE__ */ e("path", { d: "M12 1a3 3 0 0 0-3 3v8a3 3 0 0 0 6 0V4a3 3 0 0 0-3-3z" }),
1368
- /* @__PURE__ */ e("path", { d: "M19 10v2a7 7 0 0 1-14 0v-2" }),
1369
- /* @__PURE__ */ e("line", { x1: "12", y1: "19", x2: "12", y2: "23" }),
1370
- t && /* @__PURE__ */ e("line", { x1: "1", y1: "1", x2: "23", y2: "23" })
1444
+ /* @__PURE__ */ t("path", { d: "M12 1a3 3 0 0 0-3 3v8a3 3 0 0 0 6 0V4a3 3 0 0 0-3-3z" }),
1445
+ /* @__PURE__ */ t("path", { d: "M19 10v2a7 7 0 0 1-14 0v-2" }),
1446
+ /* @__PURE__ */ t("line", { x1: "12", y1: "19", x2: "12", y2: "23" }),
1447
+ e && /* @__PURE__ */ t("line", { x1: "1", y1: "1", x2: "23", y2: "23" })
1371
1448
  ] });
1372
1449
  }
1373
- function zt({ muted: t }) {
1450
+ function Ln({ muted: e }) {
1374
1451
  return /* @__PURE__ */ _("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": !0, children: [
1375
- /* @__PURE__ */ e("polygon", { points: "11 5 6 9 2 9 2 15 6 15 11 19 11 5" }),
1376
- t ? /* @__PURE__ */ e("line", { x1: "23", y1: "9", x2: "17", y2: "15" }) : /* @__PURE__ */ _(Ze, { children: [
1377
- /* @__PURE__ */ e("path", { d: "M19.07 4.93a10 10 0 0 1 0 14.14" }),
1378
- /* @__PURE__ */ e("path", { d: "M15.54 8.46a5 5 0 0 1 0 7.07" })
1452
+ /* @__PURE__ */ t("polygon", { points: "11 5 6 9 2 9 2 15 6 15 11 19 11 5" }),
1453
+ e ? /* @__PURE__ */ t("line", { x1: "23", y1: "9", x2: "17", y2: "15" }) : /* @__PURE__ */ _(_t, { children: [
1454
+ /* @__PURE__ */ t("path", { d: "M19.07 4.93a10 10 0 0 1 0 14.14" }),
1455
+ /* @__PURE__ */ t("path", { d: "M15.54 8.46a5 5 0 0 1 0 7.07" })
1379
1456
  ] })
1380
1457
  ] });
1381
1458
  }
1382
- function Pt() {
1459
+ function An() {
1383
1460
  return /* @__PURE__ */ _("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": !0, children: [
1384
- /* @__PURE__ */ e("line", { x1: "5", y1: "12", x2: "19", y2: "12" }),
1385
- /* @__PURE__ */ e("polyline", { points: "12 5 19 12 12 19" })
1461
+ /* @__PURE__ */ t("line", { x1: "5", y1: "12", x2: "19", y2: "12" }),
1462
+ /* @__PURE__ */ t("polyline", { points: "12 5 19 12 12 19" })
1386
1463
  ] });
1387
1464
  }
1388
- const Oe = ({ label: t, devices: n, activeId: i, onPick: l }) => /* @__PURE__ */ _(
1465
+ const yt = ({ label: e, devices: n, activeId: r, onPick: i }) => /* @__PURE__ */ _(
1389
1466
  "div",
1390
1467
  {
1391
1468
  className: "ll-device-menu",
1392
- onClick: (r) => r.stopPropagation(),
1469
+ onClick: (o) => o.stopPropagation(),
1393
1470
  role: "listbox",
1394
1471
  children: [
1395
- /* @__PURE__ */ e("p", { className: "ll-device-menu__label", children: t }),
1396
- n.map((r, s) => {
1397
- const c = i === r.deviceId;
1472
+ /* @__PURE__ */ t("p", { className: "ll-device-menu__label", children: e }),
1473
+ n.map((o, l) => {
1474
+ const d = r === o.deviceId;
1398
1475
  return /* @__PURE__ */ _(
1399
1476
  "button",
1400
1477
  {
1401
1478
  type: "button",
1402
- className: `ll-device-menu__item ${c ? "is-active" : ""}`,
1403
- onClick: () => l(r.deviceId),
1479
+ className: `ll-device-menu__item ${d ? "is-active" : ""}`,
1480
+ onClick: () => i(o.deviceId),
1404
1481
  role: "option",
1405
- "aria-selected": c,
1482
+ "aria-selected": d,
1406
1483
  children: [
1407
- c && /* @__PURE__ */ e("span", { className: "ll-device-menu__dot", children: "●" }),
1408
- /* @__PURE__ */ e("span", { className: "ll-device-menu__name", children: r.label || `${t} ${s + 1}` })
1484
+ d && /* @__PURE__ */ t("span", { className: "ll-device-menu__dot", children: "●" }),
1485
+ /* @__PURE__ */ t("span", { className: "ll-device-menu__name", children: o.label || `${e} ${l + 1}` })
1409
1486
  ]
1410
1487
  },
1411
- r.deviceId || s
1488
+ o.deviceId || l
1412
1489
  );
1413
1490
  })
1414
1491
  ]
1415
1492
  }
1416
- ), Bt = /* @__PURE__ */ new Set([
1493
+ ), Pe = 4096, Mn = 20, Rn = 20, In = 10, bt = 500, Tn = [
1494
+ '[data-ll-private="true"]',
1495
+ ".ll-widget",
1496
+ "script",
1497
+ "style",
1498
+ "noscript",
1499
+ "iframe"
1500
+ ];
1501
+ function ke(e) {
1502
+ if (e.getAttribute("aria-hidden") === "true" || e.hasAttribute("hidden")) return !0;
1503
+ let n = e;
1504
+ for (; n; ) {
1505
+ for (const r of Tn)
1506
+ if (n.matches(r)) return !0;
1507
+ n = n.parentElement;
1508
+ }
1509
+ return !1;
1510
+ }
1511
+ function Ce(e) {
1512
+ if (typeof window > "u") return !0;
1513
+ const n = e.getBoundingClientRect();
1514
+ if (n.width <= 0 || n.height <= 0) return !1;
1515
+ const r = window.innerHeight || document.documentElement.clientHeight, i = window.innerWidth || document.documentElement.clientWidth;
1516
+ return n.bottom > 0 && n.right > 0 && n.top < r && n.left < i;
1517
+ }
1518
+ function Pn(e) {
1519
+ if (e.type === "password") return !0;
1520
+ const n = (e.getAttribute("autocomplete") || "").toLowerCase();
1521
+ return !!(n === "off" || n.startsWith("cc-"));
1522
+ }
1523
+ function Dn(e) {
1524
+ const n = e.getAttribute("id");
1525
+ if (n) {
1526
+ const l = document.querySelector(`label[for="${CSS.escape(n)}"]`);
1527
+ if (l != null && l.textContent) return l.textContent.trim();
1528
+ }
1529
+ const r = e.getAttribute("aria-label");
1530
+ if (r) return r.trim();
1531
+ const i = e.getAttribute("placeholder");
1532
+ if (i) return i.trim();
1533
+ const o = e.closest("label");
1534
+ return o != null && o.textContent ? o.textContent.trim() : "";
1535
+ }
1536
+ function ve(e, n) {
1537
+ return e.length <= n ? e : e.slice(0, n - 1) + "…";
1538
+ }
1539
+ function ye(e) {
1540
+ return e.length;
1541
+ }
1542
+ function zn(e, n = {}) {
1543
+ const r = n.doc ?? (typeof document < "u" ? document : null);
1544
+ if (!r)
1545
+ return {
1546
+ url: "",
1547
+ title: "",
1548
+ pathname: "/",
1549
+ regions: [],
1550
+ visibleText: "",
1551
+ visibleLinks: [],
1552
+ visibleFields: [],
1553
+ extras: e
1554
+ };
1555
+ const i = typeof window < "u" && window.location.href || "", o = typeof window < "u" && window.location.pathname || "/", l = r.title || "", d = Array.from(
1556
+ r.querySelectorAll("[data-ll-region]")
1557
+ ), u = [];
1558
+ for (const p of d) {
1559
+ if (u.length >= In) break;
1560
+ if (ke(p) || !Ce(p)) continue;
1561
+ const N = p.getAttribute("data-ll-region") ?? "", R = p.getAttribute("data-ll-intent") ?? void 0, k = ve(
1562
+ (p.innerText || p.textContent || "").trim(),
1563
+ bt * 2
1564
+ );
1565
+ !N || !k || u.push({ id: N, intent: R, text: k });
1566
+ }
1567
+ const s = [], g = ["H1", "H2", "H3", "H4", "H5", "H6"], f = Array.from(
1568
+ r.querySelectorAll("h1, h2, h3, h4, h5, h6")
1569
+ );
1570
+ for (const p of f) {
1571
+ if (ke(p) || !Ce(p)) continue;
1572
+ const N = (p.textContent || "").trim();
1573
+ N && s.push(`${p.tagName}: ${ve(N, 200)}`);
1574
+ }
1575
+ const a = Array.from(r.querySelectorAll("p, li"));
1576
+ for (const p of a) {
1577
+ if (ke(p) || !Ce(p) || g.includes(p.tagName)) continue;
1578
+ const N = (p.textContent || "").trim();
1579
+ N.length > 10 && s.push(ve(N, bt));
1580
+ }
1581
+ const c = s.join(`
1582
+ `), S = [], x = Array.from(r.querySelectorAll("a[href]"));
1583
+ for (const p of x) {
1584
+ if (S.length >= Mn) break;
1585
+ if (ke(p) || !Ce(p)) continue;
1586
+ const N = p.getAttribute("href") || "", R = (p.textContent || "").trim();
1587
+ !N || !R || S.push({ href: N, text: ve(R, 100) });
1588
+ }
1589
+ const E = [], P = Array.from(
1590
+ r.querySelectorAll(
1591
+ "input, textarea, select"
1592
+ )
1593
+ );
1594
+ for (const p of P) {
1595
+ if (E.length >= Rn) break;
1596
+ if (ke(p) || p instanceof HTMLInputElement && Pn(p) || !Ce(p)) continue;
1597
+ const N = Dn(p), R = p instanceof HTMLInputElement ? p.type : p.tagName.toLowerCase();
1598
+ N && E.push({ label: ve(N, 100), type: R });
1599
+ }
1600
+ const b = {
1601
+ url: i,
1602
+ title: l,
1603
+ pathname: o,
1604
+ regions: u,
1605
+ visibleText: c,
1606
+ visibleLinks: S,
1607
+ visibleFields: E,
1608
+ extras: e
1609
+ };
1610
+ let T = ye(JSON.stringify(b.regions)) + ye(b.visibleText) + ye(JSON.stringify(b.visibleLinks)) + ye(JSON.stringify(b.visibleFields));
1611
+ for (; T > Pe && b.visibleFields.length > 0; )
1612
+ b.visibleFields.pop(), T = ye(JSON.stringify(b.visibleFields));
1613
+ for (; T > Pe && b.visibleLinks.length > 0; )
1614
+ b.visibleLinks.pop(), T -= 80;
1615
+ return ye(b.visibleText) > Pe && (b.visibleText = ve(b.visibleText, Pe - 100)), b;
1616
+ }
1617
+ let be = null;
1618
+ function wt(e, n = {}) {
1619
+ const r = Date.now(), o = `${typeof window < "u" && window.location.pathname || "/"}::${typeof window < "u" ? window.scrollY : 0}`;
1620
+ if (be && be.key === o && r - be.at < 1e3)
1621
+ return be.ctx;
1622
+ const l = zn(e, n);
1623
+ return be = { key: o, at: r, ctx: l }, l;
1624
+ }
1625
+ function $n() {
1626
+ be = null;
1627
+ }
1628
+ const Bn = /* @__PURE__ */ new Set([
1417
1629
  "agent_state",
1418
1630
  "avatar_stream_ready",
1419
1631
  "avatar_active",
@@ -1421,89 +1633,235 @@ const Oe = ({ label: t, devices: n, activeId: i, onPick: l }) => /* @__PURE__ */
1421
1633
  "bot_ready",
1422
1634
  "agent_error",
1423
1635
  "idle_warning",
1424
- "idle_timeout"
1636
+ "idle_timeout",
1637
+ // 0.3.0 — page-aware commands. Handled internally by the widget.
1638
+ // Consumers who want observability subscribe via onAgentEvent (which
1639
+ // fires for every message including these).
1640
+ "navigate",
1641
+ "scroll_to",
1642
+ "request_page_context"
1425
1643
  ]);
1426
- function Ut(t) {
1427
- var Ie, Ae, De, Re, Te, ze;
1644
+ function Un(e) {
1645
+ var tt, nt, rt, it, ot, lt;
1428
1646
  const {
1429
1647
  agentId: n,
1430
- apiKey: i,
1431
- baseUrl: l = "https://app.livelayer.studio",
1432
- sessionEndpoint: r,
1433
- sessionBody: s,
1434
- autoConnect: c = !1,
1435
- displayMode: m,
1436
- defaultDisplayMode: d = "expanded",
1437
- onDisplayModeChange: f,
1438
- position: p = "bottom-right",
1439
- mobileBreakpoint: o = 640,
1440
- persistKey: a = "ll-widget",
1441
- disablePersistence: C = !1,
1442
- teamMembers: b,
1443
- currentTeamMemberId: N,
1444
- onTeamMemberChange: D,
1445
- idleLoopUrl: E,
1446
- greeting: R,
1447
- avatarImageUrl: T,
1448
- agentName: z,
1449
- branding: I = {},
1450
- allowCamera: w = !0,
1451
- allowScreenShare: x = !0,
1452
- allowTyping: y = !0,
1453
- onConnect: A,
1454
- onDisconnect: X,
1455
- onTranscript: ne,
1456
- onAgentState: $,
1457
- onConnectionStateChange: j,
1458
- onAgentEvent: F,
1459
- onAgentCommand: re,
1460
- controlledSession: P,
1461
- className: be,
1462
- style: we,
1463
- zIndex: ge = 2147483647
1464
- } = t, ue = N !== void 0, [ke, xe] = k(() => {
1648
+ apiKey: r,
1649
+ baseUrl: i = "https://app.livelayer.studio",
1650
+ sessionEndpoint: o,
1651
+ sessionBody: l,
1652
+ autoConnect: d = !1,
1653
+ displayMode: u,
1654
+ defaultDisplayMode: s = "expanded",
1655
+ onDisplayModeChange: g,
1656
+ position: f = "bottom-right",
1657
+ mobileBreakpoint: a = 640,
1658
+ persistKey: c = "ll-widget",
1659
+ disablePersistence: S = !1,
1660
+ teamMembers: x,
1661
+ currentTeamMemberId: E,
1662
+ onTeamMemberChange: P,
1663
+ idleLoopUrl: b,
1664
+ greeting: T,
1665
+ avatarImageUrl: p,
1666
+ agentName: N,
1667
+ branding: R = {},
1668
+ allowCamera: k = !0,
1669
+ allowScreenShare: L = !0,
1670
+ allowTyping: w = !0,
1671
+ showOn: z,
1672
+ hideOn: Ee,
1673
+ pathname: $e,
1674
+ onNavigate: K,
1675
+ onScrollToSelector: X,
1676
+ getPageContext: Z,
1677
+ pageContextExtras: Ne,
1678
+ onConnect: oe,
1679
+ onDisconnect: le,
1680
+ onTranscript: ae,
1681
+ onAgentState: ee,
1682
+ onConnectionStateChange: ce,
1683
+ onAgentEvent: se,
1684
+ onAgentCommand: de,
1685
+ controlledSession: D,
1686
+ className: Be,
1687
+ style: Ue,
1688
+ zIndex: Oe = 2147483647
1689
+ } = e, Se = ln($e), ue = fn(Se, z, Ee);
1690
+ I(() => {
1691
+ $n();
1692
+ }, [Se]);
1693
+ const he = E !== void 0, [Le, He] = C(() => {
1465
1694
  var v;
1466
- return N ?? ((v = b == null ? void 0 : b[0]) == null ? void 0 : v.id);
1467
- }), Q = ue ? N : ke, U = Se(
1468
- () => (b == null ? void 0 : b.find((v) => v.id === Q)) ?? null,
1469
- [b, Q]
1470
- ), ve = (U == null ? void 0 : U.agentId) ?? n, [Z, G] = yt({
1471
- value: m,
1472
- defaultValue: d,
1473
- onChange: f,
1474
- persistKey: a,
1475
- disablePersistence: C
1476
- }), ee = bt(o), ie = ot(), V = at(), K = ct(), O = dt(), Y = ut(), [le, H] = k(!1), [he, pe] = k(!1), [oe, q] = k(!1), [ae, se] = k(!1), [J, ce] = k(!1), de = g(
1695
+ return E ?? ((v = x == null ? void 0 : x[0]) == null ? void 0 : v.id);
1696
+ }), V = he ? E : Le, $ = De(
1697
+ () => (x == null ? void 0 : x.find((v) => v.id === V)) ?? null,
1698
+ [x, V]
1699
+ ), te = ($ == null ? void 0 : $.agentId) ?? n, [W, J] = tn({
1700
+ value: u,
1701
+ defaultValue: s,
1702
+ onChange: g,
1703
+ persistKey: c,
1704
+ disablePersistence: S
1705
+ }), ne = rn(a), fe = Ft(), j = Vt(), F = qt(), q = Gt(), Q = Yt(), [pe, me] = C(!1), [we, Ae] = C(!1), [ge, _e] = C(!1), [Me, h] = C(!1), [O, Ye] = C(!1), je = A(K), Fe = A(X), Ke = A(Z), Xe = A(Ne), Re = A(null);
1706
+ je.current = K, Fe.current = X, Ke.current = Z, Xe.current = Ne;
1707
+ const Ve = y(
1477
1708
  (v) => {
1478
- const L = v;
1479
- !L.type || typeof L.type != "string" || (F == null || F({ eventName: L.type, data: v }), Bt.has(L.type) || re == null || re(L));
1709
+ var G;
1710
+ const M = v;
1711
+ if (!(!M.type || typeof M.type != "string")) {
1712
+ if (se == null || se({ eventName: M.type, data: v }), M.type === "navigate") {
1713
+ const H = typeof M.href == "string" ? M.href : null;
1714
+ if (!H) {
1715
+ console.warn(
1716
+ `[LiveLayer] Agent emitted "navigate" without href. Skipping. Check your agent's tool schema. See https://livelayer.studio/docs/errors/navigate-missing-href`
1717
+ );
1718
+ return;
1719
+ }
1720
+ if (je.current) {
1721
+ try {
1722
+ je.current(H);
1723
+ } catch (U) {
1724
+ console.warn(
1725
+ `[LiveLayer] onNavigate threw for "${H}". Falling back. Error:`,
1726
+ U
1727
+ );
1728
+ }
1729
+ return;
1730
+ }
1731
+ if (typeof document < "u") {
1732
+ const U = document.querySelector(
1733
+ `a[href="${H.replace(/"/g, '\\"')}"]`
1734
+ );
1735
+ if (U) {
1736
+ U.click();
1737
+ return;
1738
+ }
1739
+ }
1740
+ if (typeof window < "u" && typeof history < "u")
1741
+ try {
1742
+ history.pushState({}, "", H), window.dispatchEvent(new PopStateEvent("popstate"));
1743
+ } catch (U) {
1744
+ console.warn(
1745
+ `[LiveLayer] history.pushState fallback failed for "${H}". Pass an onNavigate prop to use your router directly. See https://livelayer.studio/docs/react/navigation`,
1746
+ U
1747
+ );
1748
+ }
1749
+ return;
1750
+ }
1751
+ if (M.type === "scroll_to") {
1752
+ const H = typeof M.selector == "string" ? M.selector : null;
1753
+ if (!H) return;
1754
+ const U = M.behavior === "instant" ? "instant" : "smooth";
1755
+ if (Fe.current) {
1756
+ try {
1757
+ Fe.current(
1758
+ H,
1759
+ U
1760
+ );
1761
+ } catch (Y) {
1762
+ console.warn("[LiveLayer] onScrollToSelector threw.", Y);
1763
+ }
1764
+ return;
1765
+ }
1766
+ if (typeof document < "u") {
1767
+ let Y = null;
1768
+ try {
1769
+ Y = document.querySelector(H);
1770
+ } catch {
1771
+ console.warn(
1772
+ `[LiveLayer] scroll_to: invalid selector "${H}".`
1773
+ );
1774
+ return;
1775
+ }
1776
+ if (!Y) {
1777
+ console.warn(
1778
+ `[LiveLayer] scroll_to: no element matched "${H}". The user may be on a different page. See https://livelayer.studio/docs/errors/scroll-no-match`
1779
+ );
1780
+ return;
1781
+ }
1782
+ Y.scrollIntoView({
1783
+ behavior: U,
1784
+ block: "start"
1785
+ });
1786
+ }
1787
+ return;
1788
+ }
1789
+ if (M.type === "request_page_context") {
1790
+ const H = (G = Re.current) == null ? void 0 : G.call(Re), U = (re) => {
1791
+ const ie = H, Ie = ie == null ? void 0 : ie.localParticipant;
1792
+ if (Ie != null && Ie.publishData)
1793
+ try {
1794
+ const Ge = new TextEncoder().encode(JSON.stringify(re));
1795
+ Ie.publishData(Ge, { reliable: !0 });
1796
+ } catch (Ge) {
1797
+ console.warn("[LiveLayer] publishData failed.", Ge);
1798
+ }
1799
+ }, Y = Xe.current, at = Ke.current;
1800
+ try {
1801
+ if (at) {
1802
+ const re = at(Y);
1803
+ if (re instanceof Promise) {
1804
+ U({ type: "page_context_pending" }), re.then((ie) => U({ type: "page_context", context: ie })).catch((ie) => {
1805
+ console.warn(
1806
+ "[LiveLayer] getPageContext rejected; falling back to default walker.",
1807
+ ie
1808
+ ), U({
1809
+ type: "page_context",
1810
+ context: wt(Y)
1811
+ });
1812
+ });
1813
+ return;
1814
+ }
1815
+ U({ type: "page_context", context: re });
1816
+ return;
1817
+ }
1818
+ U({
1819
+ type: "page_context",
1820
+ context: wt(Y)
1821
+ });
1822
+ } catch (re) {
1823
+ console.warn(
1824
+ "[LiveLayer] page-context extraction threw. Sending empty context.",
1825
+ re
1826
+ ), U({
1827
+ type: "page_context",
1828
+ context: { url: "", title: "", pathname: "/", regions: [], visibleText: "", visibleLinks: [], visibleFields: [], extras: Y }
1829
+ });
1830
+ }
1831
+ return;
1832
+ }
1833
+ Bn.has(M.type) || de == null || de(M);
1834
+ }
1480
1835
  },
1481
- [re, F]
1482
- ), B = lt({
1483
- agentId: P ? "__controlled__" : ve,
1484
- baseUrl: l,
1485
- apiKey: i,
1486
- sessionEndpoint: r,
1487
- sessionBody: s,
1488
- onDataMessage: P ? void 0 : de
1836
+ [de, se]
1837
+ ), B = jt({
1838
+ agentId: D ? "__controlled__" : te,
1839
+ baseUrl: i,
1840
+ apiKey: r,
1841
+ sessionEndpoint: o,
1842
+ sessionBody: l,
1843
+ onDataMessage: D ? void 0 : Ve
1489
1844
  });
1490
- S(() => {
1491
- if (P != null && P.subscribeToDataMessages)
1492
- return P.subscribeToDataMessages(de);
1493
- }, [P, de]);
1494
- const u = Se(() => P ? {
1495
- connectionState: P.connectionState,
1496
- agentState: P.agentState,
1497
- transcript: P.transcript,
1498
- videoElement: P.videoElement,
1499
- audioElement: P.audioElement,
1500
- canResume: P.canResume,
1501
- error: P.error,
1845
+ I(() => {
1846
+ if (D != null && D.subscribeToDataMessages)
1847
+ return D.subscribeToDataMessages(Ve);
1848
+ }, [D, Ve]), Re.current = () => {
1849
+ var v;
1850
+ return (v = B.getRoom) == null ? void 0 : v.call(B);
1851
+ };
1852
+ const m = De(() => D ? {
1853
+ connectionState: D.connectionState,
1854
+ agentState: D.agentState,
1855
+ transcript: D.transcript,
1856
+ videoElement: D.videoElement,
1857
+ audioElement: D.audioElement,
1858
+ canResume: D.canResume,
1859
+ error: D.error,
1502
1860
  agentConfig: null,
1503
1861
  connect: async () => {
1504
- await P.onConnect();
1862
+ await D.onConnect();
1505
1863
  },
1506
- disconnect: () => P.onDisconnect(),
1864
+ disconnect: () => D.onDisconnect(),
1507
1865
  // Dummy getRoom for shape compatibility — controlled consumers own the Room.
1508
1866
  // Internal session's getRoom returns null when no real connect has happened,
1509
1867
  // so we reuse its reference for type consistency.
@@ -1522,254 +1880,276 @@ function Ut(t) {
1522
1880
  disconnect: B.disconnect,
1523
1881
  getRoom: B.getRoom,
1524
1882
  isControlled: !1
1525
- }, [P, B]), me = M(null);
1526
- S(() => {
1527
- const v = u.videoElement, L = me.current;
1528
- if (!(!v || !L))
1529
- return L.appendChild(v), () => {
1530
- v.parentNode === L && L.removeChild(v);
1883
+ }, [D, B]), Je = A(null);
1884
+ I(() => {
1885
+ const v = m.videoElement, M = Je.current;
1886
+ if (!(!v || !M))
1887
+ return M.appendChild(v), () => {
1888
+ v.parentNode === M && M.removeChild(v);
1531
1889
  };
1532
- }, [u.videoElement]), S(() => {
1533
- const v = u.audioElement;
1890
+ }, [m.videoElement]), I(() => {
1891
+ const v = m.audioElement;
1534
1892
  if (!v) return;
1535
- ie.attach(v);
1536
- const L = v.play();
1537
- return L && typeof L.catch == "function" && L.catch((te) => {
1538
- (te == null ? void 0 : te.name) === "NotAllowedError" && H(!0);
1893
+ fe.attach(v);
1894
+ const M = v.play();
1895
+ return M && typeof M.catch == "function" && M.catch((G) => {
1896
+ (G == null ? void 0 : G.name) === "NotAllowedError" && me(!0);
1539
1897
  }), () => {
1540
- ie.detach();
1898
+ fe.detach();
1541
1899
  };
1542
- }, [u.audioElement]), S(() => {
1543
- if (u.isControlled || u.connectionState !== "connected") return;
1544
- const v = u.getRoom();
1900
+ }, [m.audioElement]), I(() => {
1901
+ if (m.isControlled || m.connectionState !== "connected") return;
1902
+ const v = m.getRoom();
1545
1903
  if (v)
1546
- return V.setupMic(v).catch(() => {
1547
- }), K.attachRoom(v), O.attachRoom(v), Y.refresh(), () => {
1548
- V.teardownMic(), K.teardown(), O.teardown();
1904
+ return j.setupMic(v).catch(() => {
1905
+ }), F.attachRoom(v), q.attachRoom(v), Q.refresh(), () => {
1906
+ j.teardownMic(), F.teardown(), q.teardown();
1549
1907
  };
1550
- }, [u.isControlled, u.connectionState]), S(() => {
1551
- const v = u.audioElement;
1552
- v && (v.muted = J);
1553
- }, [u.audioElement, J]);
1554
- const Ce = g((v) => {
1555
- const L = u.getRoom();
1556
- if (L)
1908
+ }, [m.isControlled, m.connectionState]), I(() => {
1909
+ const v = m.audioElement;
1910
+ v && (v.muted = O);
1911
+ }, [m.audioElement, O]);
1912
+ const Ct = y((v) => {
1913
+ const M = m.getRoom();
1914
+ if (M)
1557
1915
  try {
1558
- const te = new TextEncoder().encode(
1916
+ const G = new TextEncoder().encode(
1559
1917
  JSON.stringify({ type: "user_message", text: v })
1560
1918
  );
1561
- L.localParticipant.publishData(te, { reliable: !0 });
1919
+ M.localParticipant.publishData(G, { reliable: !0 });
1562
1920
  } catch {
1563
1921
  }
1564
- }, [u]), ye = g(() => {
1565
- ce((v) => !v);
1922
+ }, [m]), Et = y(() => {
1923
+ Ye((v) => !v);
1566
1924
  }, []);
1567
- S(() => {
1568
- j == null || j(u.connectionState), u.connectionState === "connected" ? A == null || A() : u.connectionState === "disconnected" && (X == null || X());
1569
- }, [u.connectionState, A, X, j]), S(() => {
1570
- ne == null || ne(u.transcript);
1571
- }, [u.transcript, ne]), S(() => {
1572
- $ == null || $(u.agentState);
1573
- }, [u.agentState, $]);
1574
- const h = M(!1);
1575
- S(() => {
1576
- u.isControlled || !c || h.current || u.connectionState === "idle" && (h.current = !0, u.connect());
1577
- }, [c, u.connectionState, u]);
1578
- const W = g(
1925
+ I(() => {
1926
+ ce == null || ce(m.connectionState), m.connectionState === "connected" ? oe == null || oe() : m.connectionState === "disconnected" && (le == null || le());
1927
+ }, [m.connectionState, oe, le, ce]), I(() => {
1928
+ ae == null || ae(m.transcript);
1929
+ }, [m.transcript, ae]), I(() => {
1930
+ ee == null || ee(m.agentState);
1931
+ }, [m.agentState, ee]);
1932
+ const Qe = A(!1);
1933
+ I(() => {
1934
+ m.isControlled || !d || Qe.current || ue && m.connectionState === "idle" && (Qe.current = !0, m.connect());
1935
+ }, [d, m.connectionState, m, ue]);
1936
+ const Nt = y(
1579
1937
  (v) => {
1580
- const L = b == null ? void 0 : b.find((te) => te.id === v);
1581
- L && (q(!1), v !== Q && (pe(!0), u.disconnect(), ue || xe(v), D == null || D(L)));
1938
+ const M = x == null ? void 0 : x.find((G) => G.id === v);
1939
+ M && (_e(!1), v !== V && (Ae(!0), m.disconnect(), he || He(v), P == null || P(M)));
1582
1940
  },
1583
1941
  [
1584
- b,
1585
- Q,
1586
- u,
1587
- ue,
1588
- D
1942
+ x,
1943
+ V,
1944
+ m,
1945
+ he,
1946
+ P
1589
1947
  ]
1590
1948
  );
1591
- S(() => {
1592
- he && u.connectionState === "connected" && pe(!1);
1593
- }, [u.connectionState, he]), S(() => {
1594
- if (!oe) return;
1595
- const v = (L) => {
1596
- L.key === "Escape" && q(!1);
1949
+ I(() => {
1950
+ we && m.connectionState === "connected" && Ae(!1);
1951
+ }, [m.connectionState, we]), I(() => {
1952
+ if (!ge) return;
1953
+ const v = (M) => {
1954
+ M.key === "Escape" && _e(!1);
1597
1955
  };
1598
1956
  return window.addEventListener("keydown", v), () => window.removeEventListener("keydown", v);
1599
- }, [oe]);
1600
- const Ge = !!T || !!(U != null && U.avatarImageUrl) || u.isControlled, Ne = ht(ve, l, Ge), Ee = (U == null ? void 0 : U.name) ?? z ?? ((Ie = u.agentConfig) == null ? void 0 : Ie.name) ?? ((Ae = Ne.info) == null ? void 0 : Ae.name) ?? "Live Layer", Me = (U == null ? void 0 : U.avatarImageUrl) ?? T ?? ((De = u.agentConfig) == null ? void 0 : De.avatarImageUrl) ?? ((Re = Ne.info) == null ? void 0 : Re.avatarImageUrl) ?? null, Ke = E ?? ((Te = u.agentConfig) == null ? void 0 : Te.idleLoopUrl) ?? ((ze = Ne.info) == null ? void 0 : ze.idleLoopUrl) ?? null, Ye = R ?? null, He = g(() => G("expanded"), [G]), qe = g(
1601
- () => G("minimized"),
1602
- [G]
1603
- ), Le = g(() => {
1604
- u.disconnect(), G("hidden");
1605
- }, [u, G]), Je = g(() => {
1606
- const v = u.audioElement;
1607
- v && v.play().then(() => H(!1)).catch(() => {
1957
+ }, [ge]);
1958
+ const St = !!p || !!($ != null && $.avatarImageUrl) || m.isControlled, We = Kt(te, i, St), qe = ($ == null ? void 0 : $.name) ?? N ?? ((tt = m.agentConfig) == null ? void 0 : tt.name) ?? ((nt = We.info) == null ? void 0 : nt.name) ?? "Live Layer", Ze = ($ == null ? void 0 : $.avatarImageUrl) ?? p ?? ((rt = m.agentConfig) == null ? void 0 : rt.avatarImageUrl) ?? ((it = We.info) == null ? void 0 : it.avatarImageUrl) ?? null, Lt = b ?? ((ot = m.agentConfig) == null ? void 0 : ot.idleLoopUrl) ?? ((lt = We.info) == null ? void 0 : lt.idleLoopUrl) ?? null, At = T ?? null, Mt = y(() => J("expanded"), [J]), Rt = y(
1959
+ () => J("minimized"),
1960
+ [J]
1961
+ ), et = y(() => {
1962
+ m.disconnect(), J("hidden");
1963
+ }, [m, J]), It = y(() => {
1964
+ const v = m.audioElement;
1965
+ v && v.play().then(() => me(!1)).catch(() => {
1608
1966
  });
1609
- }, [u.audioElement]), Xe = g(() => {
1610
- H(!1), u.connect();
1611
- }, [u]), fe = {
1612
- ...we,
1613
- zIndex: ge
1967
+ }, [m.audioElement]), Tt = y(() => {
1968
+ me(!1), m.connect();
1969
+ }, [m]), xe = {
1970
+ ...Ue,
1971
+ zIndex: Oe
1614
1972
  };
1615
- I.primaryColor && (fe["--ll-color-primary"] = I.primaryColor), I.accentColor && (fe["--ll-color-accent"] = I.accentColor), I.backgroundColor && (fe["--ll-color-bg"] = I.backgroundColor), I.textColor && (fe["--ll-color-fg"] = I.textColor);
1616
- const Qe = [
1973
+ R.primaryColor && (xe["--ll-color-primary"] = R.primaryColor), R.accentColor && (xe["--ll-color-accent"] = R.accentColor), R.backgroundColor && (xe["--ll-color-bg"] = R.backgroundColor), R.textColor && (xe["--ll-color-fg"] = R.textColor);
1974
+ const Pt = [
1617
1975
  "ll-widget",
1618
- `ll-widget--${Z}`,
1619
- `ll-widget--${ee ? "mobile" : "desktop"}`,
1620
- be
1976
+ `ll-widget--${W}`,
1977
+ `ll-widget--${ne ? "mobile" : "desktop"}`,
1978
+ Be
1621
1979
  ].filter(Boolean).join(" ");
1622
- return /* @__PURE__ */ _(
1980
+ return ue ? /* @__PURE__ */ _(
1623
1981
  "div",
1624
1982
  {
1625
- className: Qe,
1626
- style: fe,
1627
- "data-display-mode": Z,
1628
- "data-position": p,
1983
+ className: Pt,
1984
+ style: xe,
1985
+ "data-display-mode": W,
1986
+ "data-position": f,
1629
1987
  children: [
1630
- Z === "hidden" && /* @__PURE__ */ e(
1631
- St,
1988
+ W === "hidden" && /* @__PURE__ */ t(
1989
+ wn,
1632
1990
  {
1633
- position: p,
1634
- isMobile: ee,
1635
- isSpeaking: u.agentState === "speaking",
1636
- onExpand: () => G("expanded"),
1637
- label: `Open ${Ee} widget`
1991
+ position: f,
1992
+ isMobile: ne,
1993
+ isSpeaking: m.agentState === "speaking",
1994
+ onExpand: () => J("expanded"),
1995
+ label: `Open ${qe} widget`
1638
1996
  }
1639
1997
  ),
1640
- Z === "minimized" && /* @__PURE__ */ e(
1641
- Lt,
1998
+ W === "minimized" && /* @__PURE__ */ t(
1999
+ xn,
1642
2000
  {
1643
- position: p,
1644
- isMobile: ee,
1645
- agentName: Ee,
1646
- avatarImageUrl: Me,
1647
- agentState: u.agentState,
1648
- isMuted: V.isMuted,
1649
- audioLevel: ie,
1650
- onExpand: He,
1651
- onToggleMute: V.toggleMute,
1652
- onClose: Le
2001
+ position: f,
2002
+ isMobile: ne,
2003
+ agentName: qe,
2004
+ avatarImageUrl: Ze,
2005
+ agentState: m.agentState,
2006
+ isMuted: j.isMuted,
2007
+ audioLevel: fe,
2008
+ onExpand: Mt,
2009
+ onToggleMute: j.toggleMute,
2010
+ onClose: et
1653
2011
  }
1654
2012
  ),
1655
- Z === "expanded" && /* @__PURE__ */ e(
1656
- At,
2013
+ W === "expanded" && /* @__PURE__ */ t(
2014
+ Cn,
1657
2015
  {
1658
- position: p,
1659
- isMobile: ee,
1660
- agentName: Ee,
1661
- avatarImageUrl: Me,
1662
- idleLoopUrl: Ke,
1663
- greeting: Ye,
1664
- branding: I,
1665
- teamMembers: b,
1666
- currentTeamMemberId: Q,
1667
- isSwitchingTeamMember: he,
1668
- teamSwitcherOpen: oe,
1669
- onToggleTeamSwitcher: () => q((v) => !v),
1670
- onSelectTeamMember: W,
1671
- connectionState: u.connectionState,
1672
- agentState: u.agentState,
1673
- transcript: u.transcript,
1674
- isMuted: V.isMuted,
1675
- micDevices: Y.mics,
1676
- isCameraEnabled: K.isEnabled,
1677
- cameraPreviewEl: K.previewEl,
1678
- cameraDevices: Y.cameras,
1679
- activeCameraId: K.activeDeviceId,
1680
- isScreenShareEnabled: O.isEnabled,
1681
- screenPreviewEl: O.previewEl,
1682
- isSpeakerMuted: J,
1683
- allowCamera: w,
1684
- allowScreenShare: x,
1685
- allowTyping: y,
1686
- languageMenuOpen: ae,
1687
- onToggleLanguageMenu: () => se((v) => !v),
1688
- needsUserGesture: le,
1689
- canResume: u.canResume,
1690
- micError: V.micError,
1691
- error: u.error,
1692
- avatarVideoContainerRef: me,
1693
- onConnect: () => void u.connect(),
1694
- onDisconnect: () => u.disconnect(),
1695
- onRetry: Xe,
1696
- onResumeAudio: Je,
1697
- onToggleMute: V.toggleMute,
1698
- onToggleCamera: () => void K.toggle(),
1699
- onSwitchCameraDevice: (v) => void K.switchDevice(v),
1700
- onToggleScreenShare: () => void O.toggle(),
1701
- onToggleSpeaker: ye,
1702
- onSendMessage: Ce,
1703
- onMinimize: qe,
1704
- onClose: Le,
1705
- onClearMicError: V.clearError
2016
+ position: f,
2017
+ isMobile: ne,
2018
+ agentName: qe,
2019
+ avatarImageUrl: Ze,
2020
+ idleLoopUrl: Lt,
2021
+ greeting: At,
2022
+ branding: R,
2023
+ teamMembers: x,
2024
+ currentTeamMemberId: V,
2025
+ isSwitchingTeamMember: we,
2026
+ teamSwitcherOpen: ge,
2027
+ onToggleTeamSwitcher: () => _e((v) => !v),
2028
+ onSelectTeamMember: Nt,
2029
+ connectionState: m.connectionState,
2030
+ agentState: m.agentState,
2031
+ transcript: m.transcript,
2032
+ isMuted: j.isMuted,
2033
+ micDevices: Q.mics,
2034
+ isCameraEnabled: F.isEnabled,
2035
+ cameraPreviewEl: F.previewEl,
2036
+ cameraDevices: Q.cameras,
2037
+ activeCameraId: F.activeDeviceId,
2038
+ isScreenShareEnabled: q.isEnabled,
2039
+ screenPreviewEl: q.previewEl,
2040
+ isSpeakerMuted: O,
2041
+ allowCamera: k,
2042
+ allowScreenShare: L,
2043
+ allowTyping: w,
2044
+ languageMenuOpen: Me,
2045
+ onToggleLanguageMenu: () => h((v) => !v),
2046
+ needsUserGesture: pe,
2047
+ canResume: m.canResume,
2048
+ micError: j.micError,
2049
+ error: m.error,
2050
+ avatarVideoContainerRef: Je,
2051
+ onConnect: () => void m.connect(),
2052
+ onDisconnect: () => m.disconnect(),
2053
+ onRetry: Tt,
2054
+ onResumeAudio: It,
2055
+ onToggleMute: j.toggleMute,
2056
+ onToggleCamera: () => void F.toggle(),
2057
+ onSwitchCameraDevice: (v) => void F.switchDevice(v),
2058
+ onToggleScreenShare: () => void q.toggle(),
2059
+ onToggleSpeaker: Et,
2060
+ onSendMessage: Ct,
2061
+ onMinimize: Rt,
2062
+ onClose: et,
2063
+ onClearMicError: j.clearError
1706
2064
  }
1707
2065
  )
1708
2066
  ]
1709
2067
  }
1710
- );
2068
+ ) : null;
1711
2069
  }
1712
- function Ft(t) {
1713
- return /* @__PURE__ */ e(it, { children: /* @__PURE__ */ e(Ut, { ...t }) });
2070
+ function Wn(e) {
2071
+ return /* @__PURE__ */ t(Ht, { children: /* @__PURE__ */ t(Un, { ...e }) });
1714
2072
  }
1715
- const Gt = ({
1716
- agentId: t,
2073
+ const qn = ({
2074
+ agentId: e,
1717
2075
  baseUrl: n,
1718
- apiKey: i,
1719
- mode: l,
1720
- onAgentEvent: r,
1721
- className: s,
1722
- style: c
2076
+ apiKey: r,
2077
+ mode: i,
2078
+ onAgentEvent: o,
2079
+ className: l,
2080
+ style: d
1723
2081
  }) => {
1724
- const m = M(null), d = M(null), f = M(r);
1725
- f.current = r;
1726
- const p = g((o) => {
1727
- var C;
1728
- const a = o.detail;
1729
- (C = f.current) == null || C.call(f, a);
2082
+ const u = A(null), s = A(null), g = A(o);
2083
+ g.current = o;
2084
+ const f = y((a) => {
2085
+ var S;
2086
+ const c = a.detail;
2087
+ (S = g.current) == null || S.call(g, c);
1730
2088
  }, []);
1731
- return S(() => {
1732
- const o = m.current;
1733
- if (!o) return;
1734
- const a = document.createElement("livelayer-widget");
1735
- return a.setAttribute("agent-id", t), n && a.setAttribute("base-url", n), i && a.setAttribute("api-key", i), l && a.setAttribute("mode", l), a.addEventListener("agent-event", p), o.appendChild(a), d.current = a, () => {
1736
- a.removeEventListener("agent-event", p), o.removeChild(a), d.current = null;
2089
+ return I(() => {
2090
+ const a = u.current;
2091
+ if (!a) return;
2092
+ const c = document.createElement("livelayer-widget");
2093
+ return c.setAttribute("agent-id", e), n && c.setAttribute("base-url", n), r && c.setAttribute("api-key", r), i && c.setAttribute("mode", i), c.addEventListener("agent-event", f), a.appendChild(c), s.current = c, () => {
2094
+ c.removeEventListener("agent-event", f), a.removeChild(c), s.current = null;
1737
2095
  };
1738
- }, [t]), S(() => {
1739
- d.current && (l ? d.current.setAttribute("mode", l) : d.current.removeAttribute("mode"));
1740
- }, [l]), /* @__PURE__ */ e("div", { ref: m, className: s, style: c });
1741
- };
1742
- function Kt() {
1743
- const [t, n] = k([]), i = g((r) => {
1744
- n((s) => {
1745
- const c = s.findIndex((m) => m.id === r.id);
1746
- if (c >= 0) {
1747
- const m = s.slice();
1748
- return m[c] = r, m;
2096
+ }, [e]), I(() => {
2097
+ s.current && (i ? s.current.setAttribute("mode", i) : s.current.removeAttribute("mode"));
2098
+ }, [i]), /* @__PURE__ */ t("div", { ref: u, className: l, style: d });
2099
+ }, Gn = zt(
2100
+ function({ id: n, intent: r, as: i = "div", className: o, style: l, children: d }, u) {
2101
+ return $t(
2102
+ i,
2103
+ {
2104
+ ref: u,
2105
+ "data-ll-region": n,
2106
+ "data-ll-intent": r,
2107
+ className: o,
2108
+ style: l
2109
+ },
2110
+ d
2111
+ );
2112
+ }
2113
+ );
2114
+ function Yn() {
2115
+ const [e, n] = C([]), r = y((o) => {
2116
+ n((l) => {
2117
+ const d = l.findIndex((u) => u.id === o.id);
2118
+ if (d >= 0) {
2119
+ const u = l.slice();
2120
+ return u[d] = o, u;
1749
2121
  }
1750
- return [...s, r];
2122
+ return [...l, o];
1751
2123
  });
1752
- }, []), l = g(() => n([]), []);
2124
+ }, []), i = y(() => n([]), []);
1753
2125
  return {
1754
- entries: t,
1755
- pushSegment: i,
1756
- clear: l,
1757
- latest: t.length > 0 ? t[t.length - 1] : null
2126
+ entries: e,
2127
+ pushSegment: r,
2128
+ clear: i,
2129
+ latest: e.length > 0 ? e[e.length - 1] : null
1758
2130
  };
1759
2131
  }
1760
2132
  export {
1761
- Ft as AvatarWidget,
1762
- it as ErrorBoundary,
1763
- Gt as LiveLayerWidget,
1764
- ht as useAgentInfo,
1765
- ot as useAudioLevel,
1766
- ct as useCameraState,
1767
- ft as useDisplayMode,
1768
- yt as useDisplayModePersistence,
1769
- bt as useIsMobile,
1770
- lt as useLiveKitSession,
1771
- ut as useMediaDevices,
1772
- at as useMicrophoneState,
1773
- dt as useScreenShareState,
1774
- Kt as useTranscript
2133
+ Wn as AvatarWidget,
2134
+ Ht as ErrorBoundary,
2135
+ Gn as LiveLayerRegion,
2136
+ qn as LiveLayerWidget,
2137
+ $n as clearPageContextCache,
2138
+ zn as extractPageContext,
2139
+ wt as getCachedPageContext,
2140
+ un as matchesPattern,
2141
+ hn as shouldRenderAtPath,
2142
+ Kt as useAgentInfo,
2143
+ Ft as useAudioLevel,
2144
+ qt as useCameraState,
2145
+ Qt as useDisplayMode,
2146
+ tn as useDisplayModePersistence,
2147
+ rn as useIsMobile,
2148
+ jt as useLiveKitSession,
2149
+ Yt as useMediaDevices,
2150
+ Vt as useMicrophoneState,
2151
+ ln as usePathname,
2152
+ fn as useRouteMatch,
2153
+ Gt as useScreenShareState,
2154
+ Yn as useTranscript
1775
2155
  };