@livelayer/react 0.2.2 → 0.2.4
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.js +1 -1
- package/dist/index.mjs +600 -588
- package/dist/styles.css +18 -3
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsxs as
|
|
3
|
-
import { Component as
|
|
4
|
-
import { LiveKitSession as
|
|
5
|
-
import { createLocalAudioTrack as
|
|
6
|
-
class
|
|
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 {
|
|
7
7
|
constructor() {
|
|
8
8
|
super(...arguments), this.state = { hasError: !1, error: null }, this.reset = () => {
|
|
9
9
|
this.setState({ hasError: !1, error: null });
|
|
@@ -13,12 +13,12 @@ class rt extends Ze {
|
|
|
13
13
|
return { hasError: !0, error: n };
|
|
14
14
|
}
|
|
15
15
|
componentDidCatch(n, i) {
|
|
16
|
-
var
|
|
17
|
-
(r = (
|
|
16
|
+
var l, r;
|
|
17
|
+
(r = (l = this.props).onError) == null || r.call(l, n, i);
|
|
18
18
|
}
|
|
19
19
|
render() {
|
|
20
20
|
var n;
|
|
21
|
-
return this.state.hasError ? this.props.fallback ? this.props.fallback : /* @__PURE__ */
|
|
21
|
+
return this.state.hasError ? this.props.fallback ? this.props.fallback : /* @__PURE__ */ _("div", { className: "ll-error-boundary", role: "alert", children: [
|
|
22
22
|
/* @__PURE__ */ e("p", { className: "ll-error-boundary__title", children: "Widget crashed" }),
|
|
23
23
|
/* @__PURE__ */ e("p", { className: "ll-error-boundary__message", children: ((n = this.state.error) == null ? void 0 : n.message) || "Something went wrong." }),
|
|
24
24
|
/* @__PURE__ */ e(
|
|
@@ -33,26 +33,26 @@ class rt extends Ze {
|
|
|
33
33
|
] }) : this.props.children;
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
|
-
function
|
|
37
|
-
const [n, i] =
|
|
38
|
-
R.current = t.onDataMessage,
|
|
39
|
-
const
|
|
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
40
|
onConnectionStateChange: (y) => {
|
|
41
41
|
i(y), y === "connected" && D(null);
|
|
42
42
|
},
|
|
43
43
|
onAgentStateChange: r,
|
|
44
44
|
onTranscript: (y) => c([...y]),
|
|
45
45
|
onAgentConfig: d,
|
|
46
|
-
onAudioTrack: (y) =>
|
|
47
|
-
onVideoTrack: (y) =>
|
|
48
|
-
onVideoTrackRemoved: () =>
|
|
46
|
+
onAudioTrack: (y) => a(y),
|
|
47
|
+
onVideoTrack: (y) => p(y),
|
|
48
|
+
onVideoTrackRemoved: () => p(null),
|
|
49
49
|
onError: (y) => D(y),
|
|
50
50
|
onDataMessage: (y) => {
|
|
51
51
|
var A;
|
|
52
52
|
(A = R.current) == null || A.call(R, y);
|
|
53
53
|
},
|
|
54
|
-
onResumabilityChange:
|
|
55
|
-
},
|
|
54
|
+
onResumabilityChange: b
|
|
55
|
+
}, x = new tt(
|
|
56
56
|
{
|
|
57
57
|
agentId: t.agentId,
|
|
58
58
|
baseUrl: t.baseUrl,
|
|
@@ -60,11 +60,11 @@ function it(t) {
|
|
|
60
60
|
sessionEndpoint: t.sessionEndpoint,
|
|
61
61
|
sessionBody: t.sessionBody
|
|
62
62
|
},
|
|
63
|
-
|
|
63
|
+
w
|
|
64
64
|
);
|
|
65
|
-
return E.current =
|
|
65
|
+
return E.current = x, i("idle"), r("idle"), c([]), d(null), p(null), a(null), b(!1), D(null), () => {
|
|
66
66
|
var y;
|
|
67
|
-
(y =
|
|
67
|
+
(y = x.destroy) == null || y.call(x), E.current = null;
|
|
68
68
|
};
|
|
69
69
|
}, [
|
|
70
70
|
t.agentId,
|
|
@@ -73,29 +73,29 @@ function it(t) {
|
|
|
73
73
|
t.sessionEndpoint,
|
|
74
74
|
JSON.stringify(t.sessionBody ?? {})
|
|
75
75
|
]);
|
|
76
|
-
const T =
|
|
77
|
-
const
|
|
78
|
-
if (
|
|
76
|
+
const T = g(async () => {
|
|
77
|
+
const w = E.current;
|
|
78
|
+
if (w)
|
|
79
79
|
try {
|
|
80
|
-
await
|
|
81
|
-
} catch (
|
|
82
|
-
throw D(
|
|
80
|
+
await w.connect();
|
|
81
|
+
} catch (x) {
|
|
82
|
+
throw D(x instanceof Error ? x.message : String(x)), x;
|
|
83
83
|
}
|
|
84
|
-
}, []), z =
|
|
85
|
-
const
|
|
86
|
-
|
|
87
|
-
}, []), I =
|
|
88
|
-
var
|
|
89
|
-
return ((
|
|
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;
|
|
90
90
|
}, []);
|
|
91
91
|
return {
|
|
92
92
|
connectionState: n,
|
|
93
|
-
agentState:
|
|
94
|
-
transcript:
|
|
93
|
+
agentState: l,
|
|
94
|
+
transcript: s,
|
|
95
95
|
agentConfig: m,
|
|
96
|
-
videoElement:
|
|
97
|
-
audioElement:
|
|
98
|
-
canResume:
|
|
96
|
+
videoElement: f,
|
|
97
|
+
audioElement: o,
|
|
98
|
+
canResume: C,
|
|
99
99
|
error: N,
|
|
100
100
|
connect: T,
|
|
101
101
|
disconnect: z,
|
|
@@ -104,33 +104,33 @@ function it(t) {
|
|
|
104
104
|
};
|
|
105
105
|
}
|
|
106
106
|
function ot() {
|
|
107
|
-
const t =
|
|
108
|
-
const
|
|
109
|
-
if (!
|
|
110
|
-
|
|
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;
|
|
111
111
|
return;
|
|
112
112
|
}
|
|
113
|
-
(!
|
|
114
|
-
new ArrayBuffer(
|
|
113
|
+
(!s.current || s.current.length !== o.frequencyBinCount) && (s.current = new Uint8Array(
|
|
114
|
+
new ArrayBuffer(o.frequencyBinCount)
|
|
115
115
|
));
|
|
116
|
-
const
|
|
117
|
-
|
|
118
|
-
let
|
|
119
|
-
for (let N = 0; N <
|
|
120
|
-
const
|
|
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
121
|
for (const N of r.current)
|
|
122
122
|
try {
|
|
123
|
-
N(
|
|
123
|
+
N(b);
|
|
124
124
|
} catch (D) {
|
|
125
125
|
console.error("[useAudioLevel] subscriber threw:", D);
|
|
126
126
|
}
|
|
127
|
-
|
|
128
|
-
}, []), m =
|
|
127
|
+
l.current = requestAnimationFrame(c);
|
|
128
|
+
}, []), m = g(() => {
|
|
129
129
|
if (t.current || typeof window > "u" || typeof AudioContext > "u") return;
|
|
130
|
-
const
|
|
131
|
-
|
|
132
|
-
}, []), d =
|
|
133
|
-
(
|
|
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
134
|
if (m(), !(!t.current || !n.current)) {
|
|
135
135
|
if (i.current) {
|
|
136
136
|
try {
|
|
@@ -140,29 +140,29 @@ function ot() {
|
|
|
140
140
|
i.current = null;
|
|
141
141
|
}
|
|
142
142
|
try {
|
|
143
|
-
const
|
|
144
|
-
|
|
145
|
-
} catch (
|
|
146
|
-
console.warn("[useAudioLevel] createMediaElementSource failed:",
|
|
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);
|
|
147
147
|
return;
|
|
148
148
|
}
|
|
149
|
-
|
|
149
|
+
l.current === null && (l.current = requestAnimationFrame(c));
|
|
150
150
|
}
|
|
151
151
|
},
|
|
152
152
|
[m, c]
|
|
153
|
-
),
|
|
154
|
-
if (
|
|
153
|
+
), f = g(() => {
|
|
154
|
+
if (l.current !== null && (cancelAnimationFrame(l.current), l.current = null), i.current) {
|
|
155
155
|
try {
|
|
156
156
|
i.current.disconnect();
|
|
157
157
|
} catch {
|
|
158
158
|
}
|
|
159
159
|
i.current = null;
|
|
160
160
|
}
|
|
161
|
-
}, []),
|
|
162
|
-
r.current.delete(
|
|
161
|
+
}, []), p = g((o) => (r.current.add(o), () => {
|
|
162
|
+
r.current.delete(o);
|
|
163
163
|
}), []);
|
|
164
|
-
return
|
|
165
|
-
if (
|
|
164
|
+
return S(() => () => {
|
|
165
|
+
if (f(), n.current) {
|
|
166
166
|
try {
|
|
167
167
|
n.current.disconnect();
|
|
168
168
|
} catch {
|
|
@@ -176,60 +176,60 @@ function ot() {
|
|
|
176
176
|
}
|
|
177
177
|
t.current = null;
|
|
178
178
|
}
|
|
179
|
-
r.current.clear(),
|
|
180
|
-
}, [
|
|
179
|
+
r.current.clear(), s.current = null;
|
|
180
|
+
}, [f]), { attach: d, detach: f, subscribe: p };
|
|
181
181
|
}
|
|
182
|
-
function
|
|
183
|
-
const [t, n] =
|
|
184
|
-
if (r.current &&
|
|
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) {
|
|
185
185
|
try {
|
|
186
|
-
await
|
|
186
|
+
await s.current.localParticipant.unpublishTrack(r.current);
|
|
187
187
|
} catch {
|
|
188
188
|
}
|
|
189
189
|
r.current.stop(), r.current = null;
|
|
190
190
|
}
|
|
191
|
-
|
|
191
|
+
s.current = p, l(null);
|
|
192
192
|
try {
|
|
193
|
-
const
|
|
193
|
+
const o = await nt({
|
|
194
194
|
echoCancellation: !0,
|
|
195
195
|
noiseSuppression: !0
|
|
196
196
|
});
|
|
197
|
-
await
|
|
198
|
-
} catch (
|
|
199
|
-
const
|
|
200
|
-
throw
|
|
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;
|
|
201
201
|
}
|
|
202
|
-
}, []), m =
|
|
203
|
-
const
|
|
204
|
-
|
|
205
|
-
}, []), d =
|
|
206
|
-
const
|
|
207
|
-
if (
|
|
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) {
|
|
208
208
|
try {
|
|
209
|
-
|
|
209
|
+
o.localParticipant.unpublishTrack(p);
|
|
210
210
|
} catch {
|
|
211
211
|
}
|
|
212
|
-
|
|
212
|
+
p.stop();
|
|
213
213
|
}
|
|
214
|
-
r.current = null,
|
|
215
|
-
}, []),
|
|
214
|
+
r.current = null, s.current = null, n(!1);
|
|
215
|
+
}, []), f = g(() => l(null), []);
|
|
216
216
|
return {
|
|
217
217
|
isMuted: t,
|
|
218
218
|
micError: i,
|
|
219
219
|
toggleMute: m,
|
|
220
220
|
setupMic: c,
|
|
221
221
|
teardownMic: d,
|
|
222
|
-
clearError:
|
|
222
|
+
clearError: f
|
|
223
223
|
};
|
|
224
224
|
}
|
|
225
|
-
const
|
|
226
|
-
function
|
|
227
|
-
const [t, n] =
|
|
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
228
|
d.current = E;
|
|
229
|
-
}, []),
|
|
230
|
-
const E = d.current, R =
|
|
229
|
+
}, []), o = g(() => {
|
|
230
|
+
const E = d.current, R = f.current;
|
|
231
231
|
if (R && E) {
|
|
232
|
-
const T = E.localParticipant.getTrackPublication(
|
|
232
|
+
const T = E.localParticipant.getTrackPublication(We.Source.Camera);
|
|
233
233
|
if (T != null && T.track) {
|
|
234
234
|
try {
|
|
235
235
|
E.localParticipant.unpublishTrack(T.track);
|
|
@@ -239,18 +239,18 @@ function st() {
|
|
|
239
239
|
} else
|
|
240
240
|
R.stop();
|
|
241
241
|
}
|
|
242
|
-
|
|
243
|
-
}, []),
|
|
242
|
+
f.current = null, s(null), n(!1);
|
|
243
|
+
}, []), a = g(async (E) => {
|
|
244
244
|
const R = d.current;
|
|
245
245
|
if (R) {
|
|
246
|
-
|
|
246
|
+
l(null);
|
|
247
247
|
try {
|
|
248
|
-
const T = { ...
|
|
248
|
+
const T = { ...st };
|
|
249
249
|
E && (T.deviceId = E);
|
|
250
|
-
const z = await
|
|
251
|
-
await R.localParticipant.publishTrack(z),
|
|
250
|
+
const z = await rt(T);
|
|
251
|
+
await R.localParticipant.publishTrack(z), f.current = z;
|
|
252
252
|
const I = z.attach();
|
|
253
|
-
|
|
253
|
+
s(I), n(!0), E && m(E);
|
|
254
254
|
try {
|
|
255
255
|
R.localParticipant.publishData(
|
|
256
256
|
new TextEncoder().encode(JSON.stringify({ type: "user_camera_on" })),
|
|
@@ -260,55 +260,55 @@ function st() {
|
|
|
260
260
|
}
|
|
261
261
|
} catch (T) {
|
|
262
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
|
-
|
|
263
|
+
l(z);
|
|
264
264
|
}
|
|
265
265
|
}
|
|
266
|
-
}, []),
|
|
267
|
-
t ?
|
|
268
|
-
}, [t, c,
|
|
269
|
-
|
|
270
|
-
}, [
|
|
271
|
-
|
|
272
|
-
}, [
|
|
273
|
-
return
|
|
274
|
-
|
|
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();
|
|
275
275
|
}, []), {
|
|
276
276
|
isEnabled: t,
|
|
277
277
|
error: i,
|
|
278
278
|
previewEl: r,
|
|
279
279
|
activeDeviceId: c,
|
|
280
|
-
toggle:
|
|
281
|
-
switchDevice:
|
|
282
|
-
attachRoom:
|
|
280
|
+
toggle: C,
|
|
281
|
+
switchDevice: b,
|
|
282
|
+
attachRoom: p,
|
|
283
283
|
teardown: N,
|
|
284
284
|
clearError: D
|
|
285
285
|
};
|
|
286
286
|
}
|
|
287
|
-
function
|
|
288
|
-
const [t, n] =
|
|
289
|
-
c.current =
|
|
290
|
-
}, []), d =
|
|
291
|
-
const
|
|
292
|
-
if (
|
|
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
293
|
if (t) {
|
|
294
294
|
try {
|
|
295
|
-
await
|
|
295
|
+
await a.localParticipant.setScreenShareEnabled(!1);
|
|
296
296
|
} catch {
|
|
297
297
|
}
|
|
298
298
|
d(), n(!1);
|
|
299
299
|
return;
|
|
300
300
|
}
|
|
301
|
-
|
|
301
|
+
l(null);
|
|
302
302
|
try {
|
|
303
|
-
await
|
|
304
|
-
let
|
|
305
|
-
const
|
|
306
|
-
const N =
|
|
303
|
+
await a.localParticipant.setScreenShareEnabled(!0);
|
|
304
|
+
let C = 0;
|
|
305
|
+
const b = () => {
|
|
306
|
+
const N = a.localParticipant.getTrackPublication(We.Source.ScreenShare);
|
|
307
307
|
if (N != null && N.track) {
|
|
308
308
|
const D = N.track.attach();
|
|
309
|
-
|
|
309
|
+
s(D), n(!0);
|
|
310
310
|
try {
|
|
311
|
-
|
|
311
|
+
a.localParticipant.publishData(
|
|
312
312
|
new TextEncoder().encode(JSON.stringify({ type: "user_screen_share_on" })),
|
|
313
313
|
{ reliable: !0 }
|
|
314
314
|
);
|
|
@@ -316,67 +316,64 @@ function ct() {
|
|
|
316
316
|
}
|
|
317
317
|
return;
|
|
318
318
|
}
|
|
319
|
-
|
|
319
|
+
C++ < 10 ? setTimeout(b, 100) : n(!0);
|
|
320
320
|
};
|
|
321
|
-
|
|
322
|
-
} catch (
|
|
323
|
-
const
|
|
324
|
-
|
|
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);
|
|
325
325
|
}
|
|
326
326
|
}
|
|
327
|
-
}, [t, d]),
|
|
328
|
-
const
|
|
329
|
-
if (
|
|
327
|
+
}, [t, d]), p = g(() => {
|
|
328
|
+
const a = c.current;
|
|
329
|
+
if (a && t)
|
|
330
330
|
try {
|
|
331
|
-
|
|
331
|
+
a.localParticipant.setScreenShareEnabled(!1);
|
|
332
332
|
} catch {
|
|
333
333
|
}
|
|
334
|
-
d(), n(!1),
|
|
335
|
-
}, [t, d]),
|
|
336
|
-
return { isEnabled: t, error: i, previewEl: r, toggle:
|
|
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 };
|
|
337
337
|
}
|
|
338
|
-
function
|
|
339
|
-
const [t, n] =
|
|
338
|
+
function ut() {
|
|
339
|
+
const [t, n] = k([]), [i, l] = k([]), r = g(async () => {
|
|
340
340
|
if (!(typeof navigator > "u" || !navigator.mediaDevices))
|
|
341
341
|
try {
|
|
342
|
-
const
|
|
343
|
-
n(
|
|
342
|
+
const s = await navigator.mediaDevices.enumerateDevices();
|
|
343
|
+
n(s.filter((c) => c.kind === "audioinput")), l(s.filter((c) => c.kind === "videoinput"));
|
|
344
344
|
} catch {
|
|
345
345
|
}
|
|
346
346
|
}, []);
|
|
347
|
-
return
|
|
347
|
+
return S(() => {
|
|
348
348
|
if (r(), typeof navigator > "u" || !navigator.mediaDevices) return;
|
|
349
|
-
const
|
|
350
|
-
return navigator.mediaDevices.addEventListener("devicechange",
|
|
349
|
+
const s = () => void r();
|
|
350
|
+
return navigator.mediaDevices.addEventListener("devicechange", s), () => navigator.mediaDevices.removeEventListener("devicechange", s);
|
|
351
351
|
}, [r]), { mics: t, cameras: i, refresh: r };
|
|
352
352
|
}
|
|
353
|
-
function
|
|
354
|
-
const [
|
|
355
|
-
return
|
|
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
356
|
if (i || !t) {
|
|
357
357
|
d(!1);
|
|
358
358
|
return;
|
|
359
359
|
}
|
|
360
|
-
const
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
if (!b.ok) {
|
|
368
|
-
const _ = await b.json().catch(() => ({}));
|
|
369
|
-
throw new Error(_.error || `HTTP ${b.status}`);
|
|
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}`);
|
|
370
367
|
}
|
|
371
|
-
return
|
|
372
|
-
}).then((
|
|
373
|
-
r(
|
|
374
|
-
}).catch((
|
|
375
|
-
|
|
376
|
-
}), () =>
|
|
377
|
-
}, [t, n, i]), { info:
|
|
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 };
|
|
378
375
|
}
|
|
379
|
-
function
|
|
376
|
+
function pt(t) {
|
|
380
377
|
if (typeof window > "u") return null;
|
|
381
378
|
try {
|
|
382
379
|
return window.localStorage.getItem(t);
|
|
@@ -384,67 +381,67 @@ function ht(t) {
|
|
|
384
381
|
return null;
|
|
385
382
|
}
|
|
386
383
|
}
|
|
387
|
-
function
|
|
384
|
+
function mt(t, n) {
|
|
388
385
|
if (!(typeof window > "u"))
|
|
389
386
|
try {
|
|
390
387
|
window.localStorage.setItem(t, n);
|
|
391
388
|
} catch {
|
|
392
389
|
}
|
|
393
390
|
}
|
|
394
|
-
function
|
|
391
|
+
function ft({
|
|
395
392
|
value: t,
|
|
396
393
|
defaultValue: n = "expanded",
|
|
397
394
|
onChange: i
|
|
398
395
|
} = {}) {
|
|
399
|
-
const
|
|
396
|
+
const l = t !== void 0, [r, s] = k(n), c = l ? t : r, m = g(
|
|
400
397
|
(d) => {
|
|
401
|
-
d !== c && (
|
|
398
|
+
d !== c && (l || s(d), i == null || i(d));
|
|
402
399
|
},
|
|
403
|
-
[c,
|
|
400
|
+
[c, l, i]
|
|
404
401
|
);
|
|
405
402
|
return [c, m];
|
|
406
403
|
}
|
|
407
|
-
const
|
|
408
|
-
function
|
|
409
|
-
return t &&
|
|
404
|
+
const gt = ["hidden", "minimized", "expanded"];
|
|
405
|
+
function vt(t) {
|
|
406
|
+
return t && gt.includes(t) ? t : null;
|
|
410
407
|
}
|
|
411
|
-
function
|
|
408
|
+
function yt({
|
|
412
409
|
value: t,
|
|
413
410
|
defaultValue: n = "expanded",
|
|
414
411
|
onChange: i,
|
|
415
|
-
persistKey:
|
|
412
|
+
persistKey: l = "ll-widget",
|
|
416
413
|
disablePersistence: r = !1
|
|
417
414
|
} = {}) {
|
|
418
|
-
const
|
|
415
|
+
const s = `${l}:display-mode`, c = M(!1), [m, d] = ft({
|
|
419
416
|
value: t,
|
|
420
417
|
defaultValue: n,
|
|
421
|
-
onChange: (
|
|
422
|
-
t === void 0 && !r &&
|
|
418
|
+
onChange: (f) => {
|
|
419
|
+
t === void 0 && !r && mt(s, f), i == null || i(f);
|
|
423
420
|
}
|
|
424
421
|
});
|
|
425
|
-
return
|
|
422
|
+
return S(() => {
|
|
426
423
|
if (c.current || (c.current = !0, r || t !== void 0)) return;
|
|
427
|
-
const
|
|
428
|
-
|
|
424
|
+
const f = vt(pt(s));
|
|
425
|
+
f && f !== m && d(f);
|
|
429
426
|
}, []), [m, d];
|
|
430
427
|
}
|
|
431
|
-
const
|
|
432
|
-
function
|
|
433
|
-
const [n, i] =
|
|
434
|
-
return
|
|
428
|
+
const _t = 640;
|
|
429
|
+
function bt(t = _t) {
|
|
430
|
+
const [n, i] = k(!1);
|
|
431
|
+
return S(() => {
|
|
435
432
|
if (t === !1) {
|
|
436
433
|
i(!1);
|
|
437
434
|
return;
|
|
438
435
|
}
|
|
439
436
|
if (typeof window > "u" || typeof window.matchMedia > "u")
|
|
440
437
|
return;
|
|
441
|
-
const
|
|
442
|
-
return
|
|
443
|
-
r.removeListener(
|
|
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);
|
|
444
441
|
});
|
|
445
442
|
}, [t]), n;
|
|
446
443
|
}
|
|
447
|
-
const Pe = ({ muted: t = !1, className: n }) => t ? /* @__PURE__ */
|
|
444
|
+
const Pe = ({ muted: t = !1, className: n }) => t ? /* @__PURE__ */ _(
|
|
448
445
|
"svg",
|
|
449
446
|
{
|
|
450
447
|
className: n,
|
|
@@ -490,7 +487,7 @@ const Pe = ({ muted: t = !1, className: n }) => t ? /* @__PURE__ */ w(
|
|
|
490
487
|
}
|
|
491
488
|
)
|
|
492
489
|
}
|
|
493
|
-
),
|
|
490
|
+
), Be = ({ className: t }) => /* @__PURE__ */ e(
|
|
494
491
|
"svg",
|
|
495
492
|
{
|
|
496
493
|
className: t,
|
|
@@ -508,7 +505,7 @@ const Pe = ({ muted: t = !1, className: n }) => t ? /* @__PURE__ */ w(
|
|
|
508
505
|
}
|
|
509
506
|
)
|
|
510
507
|
}
|
|
511
|
-
),
|
|
508
|
+
), wt = ({ className: t }) => /* @__PURE__ */ e(
|
|
512
509
|
"svg",
|
|
513
510
|
{
|
|
514
511
|
className: t,
|
|
@@ -519,12 +516,12 @@ const Pe = ({ muted: t = !1, className: n }) => t ? /* @__PURE__ */ w(
|
|
|
519
516
|
"aria-hidden": "true",
|
|
520
517
|
children: /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M6 18L18 6M6 6l12 12" })
|
|
521
518
|
}
|
|
522
|
-
),
|
|
519
|
+
), kt = {
|
|
523
520
|
left: 180,
|
|
524
521
|
right: 0,
|
|
525
522
|
up: -90,
|
|
526
523
|
down: 90
|
|
527
|
-
},
|
|
524
|
+
}, xt = ({ direction: t = "right", className: n }) => /* @__PURE__ */ e(
|
|
528
525
|
"svg",
|
|
529
526
|
{
|
|
530
527
|
className: n,
|
|
@@ -532,19 +529,19 @@ const Pe = ({ muted: t = !1, className: n }) => t ? /* @__PURE__ */ w(
|
|
|
532
529
|
viewBox: "0 0 24 24",
|
|
533
530
|
stroke: "currentColor",
|
|
534
531
|
strokeWidth: 2,
|
|
535
|
-
style: { transform: `rotate(${
|
|
532
|
+
style: { transform: `rotate(${kt[t]}deg)` },
|
|
536
533
|
"aria-hidden": "true",
|
|
537
534
|
children: /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M9 6l6 6-6 6" })
|
|
538
535
|
}
|
|
539
536
|
);
|
|
540
|
-
function
|
|
537
|
+
function Ct(t) {
|
|
541
538
|
return t === "top-left" || t === "bottom-left" ? "left" : "right";
|
|
542
539
|
}
|
|
543
|
-
const
|
|
544
|
-
function
|
|
540
|
+
const Fe = "ll-hidden-tab-center-y", Nt = 5, Ue = 16;
|
|
541
|
+
function Et() {
|
|
545
542
|
if (typeof window > "u") return null;
|
|
546
543
|
try {
|
|
547
|
-
const t = window.localStorage.getItem(
|
|
544
|
+
const t = window.localStorage.getItem(Fe);
|
|
548
545
|
if (!t) return null;
|
|
549
546
|
const n = Number.parseFloat(t);
|
|
550
547
|
return Number.isFinite(n) ? n : null;
|
|
@@ -552,96 +549,96 @@ function Nt() {
|
|
|
552
549
|
return null;
|
|
553
550
|
}
|
|
554
551
|
}
|
|
555
|
-
function
|
|
552
|
+
function $e(t) {
|
|
556
553
|
if (!(typeof window > "u"))
|
|
557
554
|
try {
|
|
558
|
-
window.localStorage.setItem(
|
|
555
|
+
window.localStorage.setItem(Fe, String(t));
|
|
559
556
|
} catch {
|
|
560
557
|
}
|
|
561
558
|
}
|
|
562
|
-
const
|
|
559
|
+
const St = ({
|
|
563
560
|
position: t,
|
|
564
561
|
isMobile: n,
|
|
565
562
|
isSpeaking: i,
|
|
566
|
-
onExpand:
|
|
563
|
+
onExpand: l,
|
|
567
564
|
label: r = "Open widget"
|
|
568
565
|
}) => {
|
|
569
|
-
const
|
|
570
|
-
(
|
|
571
|
-
if (typeof window > "u") return
|
|
572
|
-
const
|
|
573
|
-
return A < y ? Math.max(y,
|
|
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));
|
|
574
571
|
},
|
|
575
572
|
[m]
|
|
576
573
|
);
|
|
577
|
-
|
|
578
|
-
const
|
|
579
|
-
|
|
580
|
-
const
|
|
581
|
-
|
|
574
|
+
S(() => {
|
|
575
|
+
const w = Et();
|
|
576
|
+
f(b(w ?? window.innerHeight / 2));
|
|
577
|
+
const x = () => {
|
|
578
|
+
f((y) => y === null ? null : b(y));
|
|
582
579
|
};
|
|
583
|
-
return window.addEventListener("resize",
|
|
584
|
-
}, [
|
|
585
|
-
const N =
|
|
586
|
-
(
|
|
587
|
-
if (!(
|
|
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) {
|
|
588
585
|
try {
|
|
589
|
-
|
|
586
|
+
w.currentTarget.setPointerCapture(w.pointerId);
|
|
590
587
|
} catch {
|
|
591
588
|
}
|
|
592
|
-
|
|
593
|
-
startClientY:
|
|
589
|
+
a.current = {
|
|
590
|
+
startClientY: w.clientY,
|
|
594
591
|
startCenterY: d,
|
|
595
592
|
moved: !1
|
|
596
593
|
};
|
|
597
594
|
}
|
|
598
595
|
},
|
|
599
596
|
[d]
|
|
600
|
-
), D =
|
|
601
|
-
(
|
|
602
|
-
const
|
|
603
|
-
if (!
|
|
604
|
-
const y =
|
|
605
|
-
!
|
|
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));
|
|
606
603
|
},
|
|
607
|
-
[
|
|
608
|
-
), E =
|
|
609
|
-
(
|
|
610
|
-
const
|
|
611
|
-
if (
|
|
604
|
+
[b]
|
|
605
|
+
), E = g(
|
|
606
|
+
(w) => {
|
|
607
|
+
const x = a.current;
|
|
608
|
+
if (x) {
|
|
612
609
|
try {
|
|
613
|
-
|
|
610
|
+
w.currentTarget.releasePointerCapture(w.pointerId);
|
|
614
611
|
} catch {
|
|
615
612
|
}
|
|
616
|
-
|
|
613
|
+
a.current = null, x.moved && (o(!1), C.current = !0, f((y) => (y !== null && $e(y), y)));
|
|
617
614
|
}
|
|
618
615
|
},
|
|
619
616
|
[]
|
|
620
|
-
), R =
|
|
621
|
-
if (
|
|
622
|
-
|
|
617
|
+
), R = g(() => {
|
|
618
|
+
if (C.current) {
|
|
619
|
+
C.current = !1;
|
|
623
620
|
return;
|
|
624
621
|
}
|
|
625
|
-
|
|
626
|
-
}, [
|
|
627
|
-
(
|
|
628
|
-
if (
|
|
629
|
-
|
|
630
|
-
const
|
|
631
|
-
|
|
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) => {
|
|
632
629
|
if (y === null) return y;
|
|
633
|
-
const A =
|
|
634
|
-
return
|
|
630
|
+
const A = b(y + x);
|
|
631
|
+
return $e(A), A;
|
|
635
632
|
});
|
|
636
633
|
}
|
|
637
634
|
},
|
|
638
|
-
[
|
|
635
|
+
[b]
|
|
639
636
|
), z = [
|
|
640
637
|
"ll-hidden",
|
|
641
|
-
`ll-hidden--${
|
|
638
|
+
`ll-hidden--${s}`,
|
|
642
639
|
n ? "ll-hidden--mobile" : "ll-hidden--desktop",
|
|
643
640
|
i ? "ll-hidden--speaking" : null,
|
|
644
|
-
|
|
641
|
+
p ? "is-dragging" : null
|
|
645
642
|
].filter(Boolean).join(" "), I = d === null ? void 0 : { top: `${d - m / 2}px`, transform: "none" };
|
|
646
643
|
return /* @__PURE__ */ e(
|
|
647
644
|
"button",
|
|
@@ -657,59 +654,59 @@ const Et = ({
|
|
|
657
654
|
"aria-label": r,
|
|
658
655
|
"data-position": t,
|
|
659
656
|
style: I,
|
|
660
|
-
children: /* @__PURE__ */ e(
|
|
657
|
+
children: /* @__PURE__ */ e(xt, { direction: c, className: "ll-hidden__chevron" })
|
|
661
658
|
}
|
|
662
659
|
);
|
|
663
|
-
},
|
|
660
|
+
}, Mt = ({
|
|
664
661
|
audioLevel: t,
|
|
665
662
|
bars: n = 20,
|
|
666
663
|
maxHeight: i = 20,
|
|
667
|
-
minHeight:
|
|
664
|
+
minHeight: l = 4,
|
|
668
665
|
className: r,
|
|
669
|
-
barClassName:
|
|
666
|
+
barClassName: s
|
|
670
667
|
}) => {
|
|
671
|
-
const c =
|
|
672
|
-
const
|
|
673
|
-
return Array.from({ length: n }, (
|
|
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);
|
|
674
671
|
}, [n]);
|
|
675
|
-
|
|
676
|
-
for (let
|
|
677
|
-
const
|
|
678
|
-
if (!
|
|
679
|
-
const
|
|
680
|
-
|
|
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`;
|
|
681
678
|
}
|
|
682
|
-
}), [t, n, i,
|
|
683
|
-
const
|
|
684
|
-
return /* @__PURE__ */ e("div", { ref: c, className:
|
|
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(
|
|
685
682
|
"div",
|
|
686
683
|
{
|
|
687
|
-
ref: (
|
|
688
|
-
m.current[
|
|
684
|
+
ref: (a) => {
|
|
685
|
+
m.current[o] = a;
|
|
689
686
|
},
|
|
690
|
-
className: ["ll-waveform__bar",
|
|
691
|
-
style: { height: `${
|
|
687
|
+
className: ["ll-waveform__bar", s].filter(Boolean).join(" "),
|
|
688
|
+
style: { height: `${l}px` }
|
|
692
689
|
},
|
|
693
|
-
|
|
690
|
+
o
|
|
694
691
|
)) });
|
|
695
692
|
}, Lt = ({
|
|
696
693
|
position: t,
|
|
697
694
|
isMobile: n,
|
|
698
695
|
agentName: i,
|
|
699
|
-
avatarImageUrl:
|
|
696
|
+
avatarImageUrl: l,
|
|
700
697
|
agentState: r,
|
|
701
|
-
isMuted:
|
|
698
|
+
isMuted: s,
|
|
702
699
|
audioLevel: c,
|
|
703
700
|
onExpand: m,
|
|
704
701
|
onToggleMute: d,
|
|
705
|
-
onClose:
|
|
702
|
+
onClose: f
|
|
706
703
|
}) => n ? /* @__PURE__ */ e(
|
|
707
704
|
"div",
|
|
708
705
|
{
|
|
709
706
|
className: "ll-minimized ll-minimized--mobile",
|
|
710
707
|
role: "region",
|
|
711
708
|
"aria-label": `${i} widget`,
|
|
712
|
-
children: /* @__PURE__ */
|
|
709
|
+
children: /* @__PURE__ */ _(
|
|
713
710
|
"button",
|
|
714
711
|
{
|
|
715
712
|
type: "button",
|
|
@@ -717,19 +714,19 @@ const Et = ({
|
|
|
717
714
|
onClick: m,
|
|
718
715
|
"aria-label": `Expand ${i} widget`,
|
|
719
716
|
children: [
|
|
720
|
-
|
|
717
|
+
l ? (
|
|
721
718
|
// eslint-disable-next-line @next/next/no-img-element
|
|
722
719
|
/* @__PURE__ */ e(
|
|
723
720
|
"img",
|
|
724
721
|
{
|
|
725
|
-
src:
|
|
722
|
+
src: l,
|
|
726
723
|
alt: i,
|
|
727
724
|
className: "ll-minimized__avatar"
|
|
728
725
|
}
|
|
729
726
|
)
|
|
730
727
|
) : /* @__PURE__ */ e("div", { className: "ll-minimized__avatar ll-minimized__avatar--placeholder" }),
|
|
731
728
|
/* @__PURE__ */ e(
|
|
732
|
-
|
|
729
|
+
Mt,
|
|
733
730
|
{
|
|
734
731
|
audioLevel: c,
|
|
735
732
|
bars: 16,
|
|
@@ -738,24 +735,24 @@ const Et = ({
|
|
|
738
735
|
}
|
|
739
736
|
),
|
|
740
737
|
/* @__PURE__ */ e("span", { className: "ll-minimized__name", children: i }),
|
|
741
|
-
/* @__PURE__ */
|
|
738
|
+
/* @__PURE__ */ _("div", { className: "ll-minimized__controls", children: [
|
|
742
739
|
/* @__PURE__ */ e(
|
|
743
740
|
"span",
|
|
744
741
|
{
|
|
745
742
|
className: "ll-minimized__btn",
|
|
746
743
|
role: "button",
|
|
747
744
|
tabIndex: 0,
|
|
748
|
-
onClick: (
|
|
749
|
-
|
|
745
|
+
onClick: (p) => {
|
|
746
|
+
p.stopPropagation(), d();
|
|
750
747
|
},
|
|
751
|
-
onKeyDown: (
|
|
752
|
-
(
|
|
748
|
+
onKeyDown: (p) => {
|
|
749
|
+
(p.key === "Enter" || p.key === " ") && (p.stopPropagation(), p.preventDefault(), d());
|
|
753
750
|
},
|
|
754
|
-
"aria-label":
|
|
755
|
-
children: /* @__PURE__ */ e(Pe, { muted:
|
|
751
|
+
"aria-label": s ? "Unmute microphone" : "Mute microphone",
|
|
752
|
+
children: /* @__PURE__ */ e(Pe, { muted: s, className: "ll-minimized__icon" })
|
|
756
753
|
}
|
|
757
754
|
),
|
|
758
|
-
/* @__PURE__ */ e(
|
|
755
|
+
/* @__PURE__ */ e(Be, { className: "ll-minimized__icon ll-minimized__icon--expand" })
|
|
759
756
|
] })
|
|
760
757
|
]
|
|
761
758
|
}
|
|
@@ -768,31 +765,31 @@ const Et = ({
|
|
|
768
765
|
"data-position": t,
|
|
769
766
|
role: "region",
|
|
770
767
|
"aria-label": `${i} widget`,
|
|
771
|
-
children: /* @__PURE__ */
|
|
772
|
-
|
|
768
|
+
children: /* @__PURE__ */ _("div", { className: "ll-minimized__surface", children: [
|
|
769
|
+
l ? (
|
|
773
770
|
// eslint-disable-next-line @next/next/no-img-element
|
|
774
771
|
/* @__PURE__ */ e(
|
|
775
772
|
"img",
|
|
776
773
|
{
|
|
777
|
-
src:
|
|
774
|
+
src: l,
|
|
778
775
|
alt: i,
|
|
779
776
|
className: "ll-minimized__avatar"
|
|
780
777
|
}
|
|
781
778
|
)
|
|
782
779
|
) : /* @__PURE__ */ e("div", { className: "ll-minimized__avatar ll-minimized__avatar--placeholder" }),
|
|
783
|
-
/* @__PURE__ */
|
|
780
|
+
/* @__PURE__ */ _("div", { className: "ll-minimized__meta", children: [
|
|
784
781
|
/* @__PURE__ */ e("span", { className: "ll-minimized__name", children: i }),
|
|
785
782
|
/* @__PURE__ */ e("span", { className: "ll-minimized__state", children: r === "speaking" ? "Speaking" : r === "thinking" ? "Thinking" : "Listening" })
|
|
786
783
|
] }),
|
|
787
|
-
/* @__PURE__ */
|
|
784
|
+
/* @__PURE__ */ _("div", { className: "ll-minimized__controls", children: [
|
|
788
785
|
/* @__PURE__ */ e(
|
|
789
786
|
"button",
|
|
790
787
|
{
|
|
791
788
|
type: "button",
|
|
792
789
|
className: "ll-minimized__btn",
|
|
793
790
|
onClick: d,
|
|
794
|
-
"aria-label":
|
|
795
|
-
children: /* @__PURE__ */ e(Pe, { muted:
|
|
791
|
+
"aria-label": s ? "Unmute microphone" : "Mute microphone",
|
|
792
|
+
children: /* @__PURE__ */ e(Pe, { muted: s, className: "ll-minimized__icon" })
|
|
796
793
|
}
|
|
797
794
|
),
|
|
798
795
|
/* @__PURE__ */ e(
|
|
@@ -802,7 +799,7 @@ const Et = ({
|
|
|
802
799
|
className: "ll-minimized__btn",
|
|
803
800
|
onClick: m,
|
|
804
801
|
"aria-label": `Expand ${i} widget`,
|
|
805
|
-
children: /* @__PURE__ */ e(
|
|
802
|
+
children: /* @__PURE__ */ e(Be, { className: "ll-minimized__icon" })
|
|
806
803
|
}
|
|
807
804
|
),
|
|
808
805
|
/* @__PURE__ */ e(
|
|
@@ -810,23 +807,23 @@ const Et = ({
|
|
|
810
807
|
{
|
|
811
808
|
type: "button",
|
|
812
809
|
className: "ll-minimized__btn ll-minimized__btn--close",
|
|
813
|
-
onClick:
|
|
810
|
+
onClick: f,
|
|
814
811
|
"aria-label": "Close widget",
|
|
815
|
-
children: /* @__PURE__ */ e(
|
|
812
|
+
children: /* @__PURE__ */ e(wt, { className: "ll-minimized__icon" })
|
|
816
813
|
}
|
|
817
814
|
)
|
|
818
815
|
] })
|
|
819
816
|
] })
|
|
820
817
|
}
|
|
821
|
-
),
|
|
818
|
+
), It = ({
|
|
822
819
|
src: t,
|
|
823
820
|
alt: n,
|
|
824
821
|
preCannedPlaying: i = !1,
|
|
825
|
-
className:
|
|
822
|
+
className: l,
|
|
826
823
|
style: r
|
|
827
824
|
}) => {
|
|
828
|
-
const [
|
|
829
|
-
if (
|
|
825
|
+
const [s, c] = k(!1), m = M(t);
|
|
826
|
+
if (S(() => {
|
|
830
827
|
m.current !== t && (m.current = t, c(!1));
|
|
831
828
|
}, [t]), !t) return null;
|
|
832
829
|
const d = {
|
|
@@ -838,7 +835,7 @@ const Et = ({
|
|
|
838
835
|
objectPosition: "top",
|
|
839
836
|
transition: "opacity 500ms ease, transform 500ms ease",
|
|
840
837
|
transform: i ? "scale(1.02)" : "scale(1)",
|
|
841
|
-
opacity:
|
|
838
|
+
opacity: s ? 1 : 0,
|
|
842
839
|
...r
|
|
843
840
|
};
|
|
844
841
|
return (
|
|
@@ -848,7 +845,7 @@ const Et = ({
|
|
|
848
845
|
{
|
|
849
846
|
src: t,
|
|
850
847
|
alt: n,
|
|
851
|
-
className:
|
|
848
|
+
className: l,
|
|
852
849
|
style: d,
|
|
853
850
|
loading: "eager",
|
|
854
851
|
fetchpriority: "high",
|
|
@@ -856,22 +853,22 @@ const Et = ({
|
|
|
856
853
|
}
|
|
857
854
|
)
|
|
858
855
|
);
|
|
859
|
-
},
|
|
856
|
+
}, At = ({
|
|
860
857
|
position: t,
|
|
861
858
|
isMobile: n,
|
|
862
859
|
agentName: i,
|
|
863
|
-
avatarImageUrl:
|
|
860
|
+
avatarImageUrl: l,
|
|
864
861
|
idleLoopUrl: r,
|
|
865
|
-
greeting:
|
|
862
|
+
greeting: s,
|
|
866
863
|
branding: c,
|
|
867
864
|
teamMembers: m,
|
|
868
865
|
currentTeamMemberId: d,
|
|
869
|
-
isSwitchingTeamMember:
|
|
870
|
-
teamSwitcherOpen:
|
|
871
|
-
onToggleTeamSwitcher:
|
|
872
|
-
onSelectTeamMember:
|
|
873
|
-
languageMenuOpen:
|
|
874
|
-
onToggleLanguageMenu:
|
|
866
|
+
isSwitchingTeamMember: f,
|
|
867
|
+
teamSwitcherOpen: p,
|
|
868
|
+
onToggleTeamSwitcher: o,
|
|
869
|
+
onSelectTeamMember: a,
|
|
870
|
+
languageMenuOpen: C,
|
|
871
|
+
onToggleLanguageMenu: b,
|
|
875
872
|
connectionState: N,
|
|
876
873
|
agentState: D,
|
|
877
874
|
transcript: E,
|
|
@@ -879,13 +876,13 @@ const Et = ({
|
|
|
879
876
|
needsUserGesture: T,
|
|
880
877
|
error: z,
|
|
881
878
|
isMuted: I,
|
|
882
|
-
micError:
|
|
883
|
-
micDevices:
|
|
879
|
+
micError: w,
|
|
880
|
+
micDevices: x,
|
|
884
881
|
isCameraEnabled: y,
|
|
885
882
|
cameraPreviewEl: A,
|
|
886
883
|
cameraDevices: X,
|
|
887
884
|
activeCameraId: ne,
|
|
888
|
-
isScreenShareEnabled:
|
|
885
|
+
isScreenShareEnabled: $,
|
|
889
886
|
screenPreviewEl: j,
|
|
890
887
|
isSpeakerMuted: F,
|
|
891
888
|
allowCamera: re,
|
|
@@ -893,68 +890,68 @@ const Et = ({
|
|
|
893
890
|
allowTyping: be,
|
|
894
891
|
avatarVideoContainerRef: we,
|
|
895
892
|
onConnect: ge,
|
|
896
|
-
onDisconnect:
|
|
893
|
+
onDisconnect: ue,
|
|
897
894
|
onRetry: ke,
|
|
898
895
|
onResumeAudio: xe,
|
|
899
896
|
onToggleMute: Q,
|
|
900
|
-
onToggleCamera:
|
|
897
|
+
onToggleCamera: U,
|
|
901
898
|
onSwitchCameraDevice: ve,
|
|
902
899
|
onToggleScreenShare: Z,
|
|
903
900
|
onToggleSpeaker: G,
|
|
904
901
|
onSendMessage: ee,
|
|
905
|
-
onMinimize:
|
|
902
|
+
onMinimize: ie,
|
|
906
903
|
onClose: V,
|
|
907
904
|
onClearMicError: K
|
|
908
905
|
}) => {
|
|
909
906
|
var ye;
|
|
910
|
-
const O = E.length > 0 ? E[E.length - 1] : null, Y = ((m == null ? void 0 : m.length) ?? 0) > 1,
|
|
911
|
-
|
|
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(() => {
|
|
912
909
|
const h = pe.current;
|
|
913
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)));
|
|
914
|
-
}, [A]),
|
|
911
|
+
}, [A]), S(() => {
|
|
915
912
|
const h = oe.current;
|
|
916
913
|
h && (h.innerHTML = "", j && (j.style.width = "100%", j.style.height = "100%", j.style.objectFit = "contain", h.appendChild(j)));
|
|
917
914
|
}, [j]);
|
|
918
|
-
const [q,
|
|
919
|
-
|
|
920
|
-
if (!q && !
|
|
915
|
+
const [q, ae] = k(!1), [se, J] = k(!1);
|
|
916
|
+
S(() => {
|
|
917
|
+
if (!q && !se && !C && !p) return;
|
|
921
918
|
const h = () => {
|
|
922
|
-
|
|
919
|
+
ae(!1), J(!1), C && b(), p && o();
|
|
923
920
|
};
|
|
924
921
|
return document.addEventListener("click", h), () => document.removeEventListener("click", h);
|
|
925
922
|
}, [
|
|
926
923
|
q,
|
|
927
|
-
|
|
924
|
+
se,
|
|
925
|
+
C,
|
|
926
|
+
p,
|
|
928
927
|
b,
|
|
929
|
-
|
|
930
|
-
_,
|
|
931
|
-
s
|
|
928
|
+
o
|
|
932
929
|
]);
|
|
933
|
-
const [
|
|
930
|
+
const [ce, de] = k(""), B = g(
|
|
934
931
|
(h) => {
|
|
935
932
|
h.preventDefault();
|
|
936
|
-
const W =
|
|
937
|
-
W && (ee(W),
|
|
933
|
+
const W = ce.trim();
|
|
934
|
+
W && (ee(W), de(""));
|
|
938
935
|
},
|
|
939
|
-
[
|
|
940
|
-
),
|
|
936
|
+
[ce, ee]
|
|
937
|
+
), u = c.productName || "Live Layer", me = H && (O != null && O.text) ? O.text : s || "", Ce = [
|
|
941
938
|
"ll-expanded",
|
|
942
939
|
n ? "ll-expanded--mobile" : "ll-expanded--desktop"
|
|
943
940
|
].join(" ");
|
|
944
|
-
return /* @__PURE__ */
|
|
941
|
+
return /* @__PURE__ */ _(
|
|
945
942
|
"div",
|
|
946
943
|
{
|
|
947
944
|
className: Ce,
|
|
948
945
|
"data-position": t,
|
|
949
|
-
"data-state": H ? "connected" :
|
|
946
|
+
"data-state": H ? "connected" : le ? "connecting" : "idle",
|
|
950
947
|
role: "dialog",
|
|
951
948
|
"aria-label": `${i} widget`,
|
|
952
949
|
children: [
|
|
953
|
-
/* @__PURE__ */
|
|
954
|
-
|
|
955
|
-
|
|
950
|
+
/* @__PURE__ */ _("div", { className: "ll-expanded__bg", children: [
|
|
951
|
+
l ? /* @__PURE__ */ e(
|
|
952
|
+
It,
|
|
956
953
|
{
|
|
957
|
-
src:
|
|
954
|
+
src: l,
|
|
958
955
|
alt: i,
|
|
959
956
|
className: "ll-expanded__bg-img"
|
|
960
957
|
}
|
|
@@ -972,11 +969,11 @@ const Et = ({
|
|
|
972
969
|
)
|
|
973
970
|
] }),
|
|
974
971
|
/* @__PURE__ */ e("div", { ref: we, className: "ll-expanded__video" }),
|
|
975
|
-
N === "connecting" && /* @__PURE__ */
|
|
972
|
+
N === "connecting" && /* @__PURE__ */ _("div", { className: "ll-expanded__overlay ll-expanded__overlay--connecting", children: [
|
|
976
973
|
/* @__PURE__ */ e("div", { className: "ll-expanded__spinner" }),
|
|
977
|
-
/* @__PURE__ */ e("p", { className: "ll-expanded__overlay-text", children:
|
|
974
|
+
/* @__PURE__ */ e("p", { className: "ll-expanded__overlay-text", children: f ? "Switching..." : "Connecting..." })
|
|
978
975
|
] }),
|
|
979
|
-
T && H && /* @__PURE__ */
|
|
976
|
+
T && H && /* @__PURE__ */ _(
|
|
980
977
|
"button",
|
|
981
978
|
{
|
|
982
979
|
type: "button",
|
|
@@ -988,37 +985,37 @@ const Et = ({
|
|
|
988
985
|
]
|
|
989
986
|
}
|
|
990
987
|
),
|
|
991
|
-
|
|
992
|
-
/* @__PURE__ */
|
|
993
|
-
/* @__PURE__ */
|
|
994
|
-
/* @__PURE__ */
|
|
988
|
+
le ? /* @__PURE__ */ _("div", { className: "ll-expanded__topbar", children: [
|
|
989
|
+
/* @__PURE__ */ _("div", { className: "ll-expanded__topbar-left", children: [
|
|
990
|
+
/* @__PURE__ */ _("div", { className: "ll-expanded__pill-wrap", children: [
|
|
991
|
+
/* @__PURE__ */ _(
|
|
995
992
|
"button",
|
|
996
993
|
{
|
|
997
994
|
type: "button",
|
|
998
995
|
className: "ll-hpill",
|
|
999
996
|
onClick: (h) => {
|
|
1000
|
-
Y && (h.stopPropagation(),
|
|
997
|
+
Y && (h.stopPropagation(), o());
|
|
1001
998
|
},
|
|
1002
999
|
"aria-haspopup": Y ? "listbox" : void 0,
|
|
1003
|
-
"aria-expanded": Y ?
|
|
1000
|
+
"aria-expanded": Y ? p : void 0,
|
|
1004
1001
|
children: [
|
|
1005
1002
|
/* @__PURE__ */ e("span", { className: "ll-hpill__label", children: i }),
|
|
1006
1003
|
Y && /* @__PURE__ */ e(_e, {})
|
|
1007
1004
|
]
|
|
1008
1005
|
}
|
|
1009
1006
|
),
|
|
1010
|
-
Y &&
|
|
1007
|
+
Y && p && /* @__PURE__ */ e(
|
|
1011
1008
|
"div",
|
|
1012
1009
|
{
|
|
1013
1010
|
className: "ll-hmenu",
|
|
1014
1011
|
onClick: (h) => h.stopPropagation(),
|
|
1015
1012
|
role: "listbox",
|
|
1016
|
-
children: m == null ? void 0 : m.map((h) => /* @__PURE__ */
|
|
1013
|
+
children: m == null ? void 0 : m.map((h) => /* @__PURE__ */ _(
|
|
1017
1014
|
"button",
|
|
1018
1015
|
{
|
|
1019
1016
|
type: "button",
|
|
1020
1017
|
className: `ll-hmenu__item ${h.id === d ? "is-active" : ""}`,
|
|
1021
|
-
onClick: () =>
|
|
1018
|
+
onClick: () => a(h.id),
|
|
1022
1019
|
role: "option",
|
|
1023
1020
|
"aria-selected": h.id === d,
|
|
1024
1021
|
children: [
|
|
@@ -1039,24 +1036,24 @@ const Et = ({
|
|
|
1039
1036
|
}
|
|
1040
1037
|
)
|
|
1041
1038
|
] }),
|
|
1042
|
-
/* @__PURE__ */
|
|
1043
|
-
/* @__PURE__ */
|
|
1039
|
+
/* @__PURE__ */ _("div", { className: "ll-expanded__pill-wrap", children: [
|
|
1040
|
+
/* @__PURE__ */ _(
|
|
1044
1041
|
"button",
|
|
1045
1042
|
{
|
|
1046
1043
|
type: "button",
|
|
1047
1044
|
className: "ll-hpill",
|
|
1048
1045
|
onClick: (h) => {
|
|
1049
|
-
h.stopPropagation(),
|
|
1046
|
+
h.stopPropagation(), b();
|
|
1050
1047
|
},
|
|
1051
1048
|
"aria-haspopup": "listbox",
|
|
1052
|
-
"aria-expanded":
|
|
1049
|
+
"aria-expanded": C,
|
|
1053
1050
|
children: [
|
|
1054
1051
|
/* @__PURE__ */ e("span", { className: "ll-hpill__label", children: "English" }),
|
|
1055
1052
|
/* @__PURE__ */ e(_e, {})
|
|
1056
1053
|
]
|
|
1057
1054
|
}
|
|
1058
1055
|
),
|
|
1059
|
-
|
|
1056
|
+
C && /* @__PURE__ */ e(
|
|
1060
1057
|
"div",
|
|
1061
1058
|
{
|
|
1062
1059
|
className: "ll-hmenu",
|
|
@@ -1083,37 +1080,50 @@ const Et = ({
|
|
|
1083
1080
|
}
|
|
1084
1081
|
)
|
|
1085
1082
|
] }),
|
|
1086
|
-
/* @__PURE__ */
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1083
|
+
/* @__PURE__ */ _("div", { className: "ll-expanded__header-actions", children: [
|
|
1084
|
+
/* @__PURE__ */ e(
|
|
1085
|
+
"button",
|
|
1086
|
+
{
|
|
1087
|
+
type: "button",
|
|
1088
|
+
className: "ll-hbtn",
|
|
1089
|
+
onClick: ie,
|
|
1090
|
+
"aria-label": "Minimize widget",
|
|
1091
|
+
title: "Minimize",
|
|
1092
|
+
children: /* @__PURE__ */ e(Ve, {})
|
|
1093
|
+
}
|
|
1094
|
+
),
|
|
1095
|
+
/* @__PURE__ */ e(
|
|
1096
|
+
"button",
|
|
1097
|
+
{
|
|
1098
|
+
type: "button",
|
|
1099
|
+
className: "ll-hbtn ll-hbtn--danger",
|
|
1100
|
+
onClick: V,
|
|
1101
|
+
"aria-label": "End conversation",
|
|
1102
|
+
title: "End conversation",
|
|
1103
|
+
children: /* @__PURE__ */ e(je, {})
|
|
1104
|
+
}
|
|
1105
|
+
)
|
|
1106
|
+
] })
|
|
1097
1107
|
] }) : (
|
|
1098
1108
|
// Idle-state header with Live Layer product name + minimize/close
|
|
1099
|
-
/* @__PURE__ */
|
|
1100
|
-
/* @__PURE__ */ e("span", { className: "ll-expanded__brand", children:
|
|
1101
|
-
/* @__PURE__ */
|
|
1109
|
+
/* @__PURE__ */ _("div", { className: "ll-expanded__header ll-expanded__header--idle", children: [
|
|
1110
|
+
/* @__PURE__ */ e("span", { className: "ll-expanded__brand", children: u }),
|
|
1111
|
+
/* @__PURE__ */ _("div", { className: "ll-expanded__header-actions", children: [
|
|
1102
1112
|
/* @__PURE__ */ e(
|
|
1103
1113
|
"button",
|
|
1104
1114
|
{
|
|
1105
1115
|
type: "button",
|
|
1106
1116
|
className: "ll-hbtn ll-hbtn--ghost",
|
|
1107
|
-
onClick:
|
|
1117
|
+
onClick: ie,
|
|
1108
1118
|
"aria-label": "Minimize widget",
|
|
1109
|
-
children: /* @__PURE__ */ e(
|
|
1119
|
+
children: /* @__PURE__ */ e(Ve, {})
|
|
1110
1120
|
}
|
|
1111
1121
|
),
|
|
1112
1122
|
/* @__PURE__ */ e(
|
|
1113
1123
|
"button",
|
|
1114
1124
|
{
|
|
1115
1125
|
type: "button",
|
|
1116
|
-
className: "ll-hbtn ll-hbtn--
|
|
1126
|
+
className: "ll-hbtn ll-hbtn--danger",
|
|
1117
1127
|
onClick: V,
|
|
1118
1128
|
"aria-label": "Close widget",
|
|
1119
1129
|
children: /* @__PURE__ */ e(je, {})
|
|
@@ -1122,7 +1132,7 @@ const Et = ({
|
|
|
1122
1132
|
] })
|
|
1123
1133
|
] })
|
|
1124
1134
|
),
|
|
1125
|
-
he && /* @__PURE__ */
|
|
1135
|
+
he && /* @__PURE__ */ _(
|
|
1126
1136
|
"button",
|
|
1127
1137
|
{
|
|
1128
1138
|
type: "button",
|
|
@@ -1136,49 +1146,49 @@ const Et = ({
|
|
|
1136
1146
|
]
|
|
1137
1147
|
}
|
|
1138
1148
|
),
|
|
1139
|
-
/* @__PURE__ */
|
|
1149
|
+
/* @__PURE__ */ _(
|
|
1140
1150
|
"div",
|
|
1141
1151
|
{
|
|
1142
|
-
className: `ll-expanded__pip ${
|
|
1152
|
+
className: `ll-expanded__pip ${le && (y || $) ? "is-visible" : ""}`,
|
|
1143
1153
|
children: [
|
|
1144
1154
|
/* @__PURE__ */ e(
|
|
1145
1155
|
"div",
|
|
1146
1156
|
{
|
|
1147
1157
|
ref: oe,
|
|
1148
|
-
className:
|
|
1158
|
+
className: $ ? "ll-expanded__pip-host" : "ll-expanded__pip-host is-hidden"
|
|
1149
1159
|
}
|
|
1150
1160
|
),
|
|
1151
1161
|
/* @__PURE__ */ e(
|
|
1152
1162
|
"div",
|
|
1153
1163
|
{
|
|
1154
1164
|
ref: pe,
|
|
1155
|
-
className:
|
|
1165
|
+
className: !$ && y ? "ll-expanded__pip-host" : "ll-expanded__pip-host is-hidden"
|
|
1156
1166
|
}
|
|
1157
1167
|
)
|
|
1158
1168
|
]
|
|
1159
1169
|
}
|
|
1160
1170
|
),
|
|
1161
|
-
|
|
1171
|
+
le ? /* @__PURE__ */ _("div", { className: "ll-expanded__bottom", children: [
|
|
1162
1172
|
me && /* @__PURE__ */ e("div", { className: "ll-expanded__transcript", children: /* @__PURE__ */ e("p", { className: "ll-expanded__transcript-text", children: me }) }),
|
|
1163
|
-
/* @__PURE__ */
|
|
1173
|
+
/* @__PURE__ */ _("div", { className: "ll-toolbar", onClick: (h) => h.stopPropagation(), children: [
|
|
1164
1174
|
P && /* @__PURE__ */ e(
|
|
1165
1175
|
"button",
|
|
1166
1176
|
{
|
|
1167
1177
|
type: "button",
|
|
1168
|
-
className: `ll-tool ${
|
|
1178
|
+
className: `ll-tool ${$ ? "is-on" : ""}`,
|
|
1169
1179
|
onClick: Z,
|
|
1170
|
-
"aria-label":
|
|
1171
|
-
title:
|
|
1180
|
+
"aria-label": $ ? "Stop sharing screen" : "Share screen",
|
|
1181
|
+
title: $ ? "Stop sharing" : "Share screen",
|
|
1172
1182
|
children: /* @__PURE__ */ e(Dt, {})
|
|
1173
1183
|
}
|
|
1174
1184
|
),
|
|
1175
|
-
re && /* @__PURE__ */
|
|
1185
|
+
re && /* @__PURE__ */ _("div", { className: "ll-tool-split", children: [
|
|
1176
1186
|
/* @__PURE__ */ e(
|
|
1177
1187
|
"button",
|
|
1178
1188
|
{
|
|
1179
1189
|
type: "button",
|
|
1180
1190
|
className: `ll-tool ll-tool--left ${y ? "is-on" : ""}`,
|
|
1181
|
-
onClick:
|
|
1191
|
+
onClick: U,
|
|
1182
1192
|
"aria-label": y ? "Turn off camera" : "Turn on camera",
|
|
1183
1193
|
title: y ? "Stop camera" : "Start camera",
|
|
1184
1194
|
children: /* @__PURE__ */ e(Rt, {})
|
|
@@ -1190,16 +1200,16 @@ const Et = ({
|
|
|
1190
1200
|
type: "button",
|
|
1191
1201
|
className: `ll-tool ll-tool--right ${y ? "is-on" : ""}`,
|
|
1192
1202
|
onClick: (h) => {
|
|
1193
|
-
h.stopPropagation(), J((W) => !W),
|
|
1203
|
+
h.stopPropagation(), J((W) => !W), ae(!1);
|
|
1194
1204
|
},
|
|
1195
1205
|
"aria-label": "Camera devices",
|
|
1196
1206
|
"aria-haspopup": "listbox",
|
|
1197
|
-
"aria-expanded":
|
|
1207
|
+
"aria-expanded": se,
|
|
1198
1208
|
children: /* @__PURE__ */ e(_e, {})
|
|
1199
1209
|
}
|
|
1200
1210
|
),
|
|
1201
|
-
|
|
1202
|
-
|
|
1211
|
+
se && X.length > 0 && /* @__PURE__ */ e(
|
|
1212
|
+
Oe,
|
|
1203
1213
|
{
|
|
1204
1214
|
label: "Camera",
|
|
1205
1215
|
devices: X,
|
|
@@ -1210,7 +1220,7 @@ const Et = ({
|
|
|
1210
1220
|
}
|
|
1211
1221
|
)
|
|
1212
1222
|
] }),
|
|
1213
|
-
/* @__PURE__ */
|
|
1223
|
+
/* @__PURE__ */ _("div", { className: "ll-tool-split", children: [
|
|
1214
1224
|
/* @__PURE__ */ e(
|
|
1215
1225
|
"button",
|
|
1216
1226
|
{
|
|
@@ -1228,7 +1238,7 @@ const Et = ({
|
|
|
1228
1238
|
type: "button",
|
|
1229
1239
|
className: `ll-tool ll-tool--right ${I ? "is-muted" : ""}`,
|
|
1230
1240
|
onClick: (h) => {
|
|
1231
|
-
h.stopPropagation(),
|
|
1241
|
+
h.stopPropagation(), ae((W) => !W), J(!1);
|
|
1232
1242
|
},
|
|
1233
1243
|
"aria-label": "Microphone devices",
|
|
1234
1244
|
"aria-haspopup": "listbox",
|
|
@@ -1236,13 +1246,13 @@ const Et = ({
|
|
|
1236
1246
|
children: /* @__PURE__ */ e(_e, {})
|
|
1237
1247
|
}
|
|
1238
1248
|
),
|
|
1239
|
-
q &&
|
|
1240
|
-
|
|
1249
|
+
q && x.length > 0 && /* @__PURE__ */ e(
|
|
1250
|
+
Oe,
|
|
1241
1251
|
{
|
|
1242
1252
|
label: "Microphone",
|
|
1243
|
-
devices:
|
|
1253
|
+
devices: x,
|
|
1244
1254
|
activeId: "",
|
|
1245
|
-
onPick: () =>
|
|
1255
|
+
onPick: () => ae(!1)
|
|
1246
1256
|
}
|
|
1247
1257
|
)
|
|
1248
1258
|
] }),
|
|
@@ -1258,19 +1268,19 @@ const Et = ({
|
|
|
1258
1268
|
}
|
|
1259
1269
|
)
|
|
1260
1270
|
] }),
|
|
1261
|
-
be && /* @__PURE__ */
|
|
1271
|
+
be && /* @__PURE__ */ _("form", { className: "ll-message-input", onSubmit: B, children: [
|
|
1262
1272
|
/* @__PURE__ */ e(
|
|
1263
1273
|
"input",
|
|
1264
1274
|
{
|
|
1265
1275
|
type: "text",
|
|
1266
1276
|
className: "ll-message-input__field",
|
|
1267
1277
|
placeholder: "Message...",
|
|
1268
|
-
value:
|
|
1269
|
-
onChange: (h) =>
|
|
1278
|
+
value: ce,
|
|
1279
|
+
onChange: (h) => de(h.target.value),
|
|
1270
1280
|
"aria-label": "Message the agent"
|
|
1271
1281
|
}
|
|
1272
1282
|
),
|
|
1273
|
-
|
|
1283
|
+
ce.trim() && /* @__PURE__ */ e(
|
|
1274
1284
|
"button",
|
|
1275
1285
|
{
|
|
1276
1286
|
type: "submit",
|
|
@@ -1285,18 +1295,18 @@ const Et = ({
|
|
|
1285
1295
|
{
|
|
1286
1296
|
type: "button",
|
|
1287
1297
|
className: "ll-expanded__end",
|
|
1288
|
-
onClick:
|
|
1298
|
+
onClick: ue,
|
|
1289
1299
|
children: "End conversation"
|
|
1290
1300
|
}
|
|
1291
1301
|
)
|
|
1292
1302
|
] }) : (
|
|
1293
1303
|
// Idle-state footer: start button + greeting
|
|
1294
|
-
|
|
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 }) }) })
|
|
1295
1305
|
),
|
|
1296
1306
|
(() => {
|
|
1297
|
-
if (
|
|
1298
|
-
return /* @__PURE__ */
|
|
1299
|
-
/* @__PURE__ */ e("span", { children:
|
|
1307
|
+
if (w && N !== "error")
|
|
1308
|
+
return /* @__PURE__ */ _("div", { className: "ll-expanded__banner", role: "alert", children: [
|
|
1309
|
+
/* @__PURE__ */ e("span", { children: w }),
|
|
1300
1310
|
/* @__PURE__ */ e(
|
|
1301
1311
|
"button",
|
|
1302
1312
|
{
|
|
@@ -1310,7 +1320,7 @@ const Et = ({
|
|
|
1310
1320
|
] });
|
|
1311
1321
|
if (!z || N !== "error") return null;
|
|
1312
1322
|
let h = "Failed to connect", W = "Try again";
|
|
1313
|
-
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__ */
|
|
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: [
|
|
1314
1324
|
/* @__PURE__ */ e("span", { children: h }),
|
|
1315
1325
|
/* @__PURE__ */ e(
|
|
1316
1326
|
"button",
|
|
@@ -1331,29 +1341,29 @@ function _e() {
|
|
|
1331
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" }) });
|
|
1332
1342
|
}
|
|
1333
1343
|
function je() {
|
|
1334
|
-
return /* @__PURE__ */
|
|
1344
|
+
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: [
|
|
1335
1345
|
/* @__PURE__ */ e("line", { x1: "18", y1: "6", x2: "6", y2: "18" }),
|
|
1336
1346
|
/* @__PURE__ */ e("line", { x1: "6", y1: "6", x2: "18", y2: "18" })
|
|
1337
1347
|
] });
|
|
1338
1348
|
}
|
|
1339
|
-
function
|
|
1349
|
+
function Ve() {
|
|
1340
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" }) });
|
|
1341
1351
|
}
|
|
1342
1352
|
function Dt() {
|
|
1343
|
-
return /* @__PURE__ */
|
|
1353
|
+
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: [
|
|
1344
1354
|
/* @__PURE__ */ e("rect", { x: "2", y: "3", width: "20", height: "14", rx: "2" }),
|
|
1345
1355
|
/* @__PURE__ */ e("line", { x1: "8", y1: "21", x2: "16", y2: "21" }),
|
|
1346
1356
|
/* @__PURE__ */ e("line", { x1: "12", y1: "17", x2: "12", y2: "21" })
|
|
1347
1357
|
] });
|
|
1348
1358
|
}
|
|
1349
1359
|
function Rt() {
|
|
1350
|
-
return /* @__PURE__ */
|
|
1360
|
+
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: [
|
|
1351
1361
|
/* @__PURE__ */ e("path", { d: "M23 7l-7 5 7 5V7z" }),
|
|
1352
1362
|
/* @__PURE__ */ e("rect", { x: "1", y: "5", width: "15", height: "14", rx: "2" })
|
|
1353
1363
|
] });
|
|
1354
1364
|
}
|
|
1355
1365
|
function Tt({ muted: t }) {
|
|
1356
|
-
return /* @__PURE__ */
|
|
1366
|
+
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: [
|
|
1357
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" }),
|
|
1358
1368
|
/* @__PURE__ */ e("path", { d: "M19 10v2a7 7 0 0 1-14 0v-2" }),
|
|
1359
1369
|
/* @__PURE__ */ e("line", { x1: "12", y1: "19", x2: "12", y2: "23" }),
|
|
@@ -1361,21 +1371,21 @@ function Tt({ muted: t }) {
|
|
|
1361
1371
|
] });
|
|
1362
1372
|
}
|
|
1363
1373
|
function zt({ muted: t }) {
|
|
1364
|
-
return /* @__PURE__ */
|
|
1374
|
+
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: [
|
|
1365
1375
|
/* @__PURE__ */ e("polygon", { points: "11 5 6 9 2 9 2 15 6 15 11 19 11 5" }),
|
|
1366
|
-
t ? /* @__PURE__ */ e("line", { x1: "23", y1: "9", x2: "17", y2: "15" }) : /* @__PURE__ */
|
|
1376
|
+
t ? /* @__PURE__ */ e("line", { x1: "23", y1: "9", x2: "17", y2: "15" }) : /* @__PURE__ */ _(Ze, { children: [
|
|
1367
1377
|
/* @__PURE__ */ e("path", { d: "M19.07 4.93a10 10 0 0 1 0 14.14" }),
|
|
1368
1378
|
/* @__PURE__ */ e("path", { d: "M15.54 8.46a5 5 0 0 1 0 7.07" })
|
|
1369
1379
|
] })
|
|
1370
1380
|
] });
|
|
1371
1381
|
}
|
|
1372
1382
|
function Pt() {
|
|
1373
|
-
return /* @__PURE__ */
|
|
1383
|
+
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: [
|
|
1374
1384
|
/* @__PURE__ */ e("line", { x1: "5", y1: "12", x2: "19", y2: "12" }),
|
|
1375
1385
|
/* @__PURE__ */ e("polyline", { points: "12 5 19 12 12 19" })
|
|
1376
1386
|
] });
|
|
1377
1387
|
}
|
|
1378
|
-
const
|
|
1388
|
+
const Oe = ({ label: t, devices: n, activeId: i, onPick: l }) => /* @__PURE__ */ _(
|
|
1379
1389
|
"div",
|
|
1380
1390
|
{
|
|
1381
1391
|
className: "ll-device-menu",
|
|
@@ -1383,27 +1393,27 @@ const Ve = ({ label: t, devices: n, activeId: i, onPick: o }) => /* @__PURE__ */
|
|
|
1383
1393
|
role: "listbox",
|
|
1384
1394
|
children: [
|
|
1385
1395
|
/* @__PURE__ */ e("p", { className: "ll-device-menu__label", children: t }),
|
|
1386
|
-
n.map((r,
|
|
1396
|
+
n.map((r, s) => {
|
|
1387
1397
|
const c = i === r.deviceId;
|
|
1388
|
-
return /* @__PURE__ */
|
|
1398
|
+
return /* @__PURE__ */ _(
|
|
1389
1399
|
"button",
|
|
1390
1400
|
{
|
|
1391
1401
|
type: "button",
|
|
1392
1402
|
className: `ll-device-menu__item ${c ? "is-active" : ""}`,
|
|
1393
|
-
onClick: () =>
|
|
1403
|
+
onClick: () => l(r.deviceId),
|
|
1394
1404
|
role: "option",
|
|
1395
1405
|
"aria-selected": c,
|
|
1396
1406
|
children: [
|
|
1397
1407
|
c && /* @__PURE__ */ e("span", { className: "ll-device-menu__dot", children: "●" }),
|
|
1398
|
-
/* @__PURE__ */ e("span", { className: "ll-device-menu__name", children: r.label || `${t} ${
|
|
1408
|
+
/* @__PURE__ */ e("span", { className: "ll-device-menu__name", children: r.label || `${t} ${s + 1}` })
|
|
1399
1409
|
]
|
|
1400
1410
|
},
|
|
1401
|
-
r.deviceId ||
|
|
1411
|
+
r.deviceId || s
|
|
1402
1412
|
);
|
|
1403
1413
|
})
|
|
1404
1414
|
]
|
|
1405
1415
|
}
|
|
1406
|
-
),
|
|
1416
|
+
), Bt = /* @__PURE__ */ new Set([
|
|
1407
1417
|
"agent_state",
|
|
1408
1418
|
"avatar_stream_ready",
|
|
1409
1419
|
"avatar_active",
|
|
@@ -1413,23 +1423,23 @@ const Ve = ({ label: t, devices: n, activeId: i, onPick: o }) => /* @__PURE__ */
|
|
|
1413
1423
|
"idle_warning",
|
|
1414
1424
|
"idle_timeout"
|
|
1415
1425
|
]);
|
|
1416
|
-
function
|
|
1426
|
+
function Ut(t) {
|
|
1417
1427
|
var Ie, Ae, De, Re, Te, ze;
|
|
1418
1428
|
const {
|
|
1419
1429
|
agentId: n,
|
|
1420
1430
|
apiKey: i,
|
|
1421
|
-
baseUrl:
|
|
1431
|
+
baseUrl: l = "https://app.livelayer.studio",
|
|
1422
1432
|
sessionEndpoint: r,
|
|
1423
|
-
sessionBody:
|
|
1433
|
+
sessionBody: s,
|
|
1424
1434
|
autoConnect: c = !1,
|
|
1425
1435
|
displayMode: m,
|
|
1426
1436
|
defaultDisplayMode: d = "expanded",
|
|
1427
|
-
onDisplayModeChange:
|
|
1428
|
-
position:
|
|
1429
|
-
mobileBreakpoint:
|
|
1430
|
-
persistKey:
|
|
1431
|
-
disablePersistence:
|
|
1432
|
-
teamMembers:
|
|
1437
|
+
onDisplayModeChange: f,
|
|
1438
|
+
position: p = "bottom-right",
|
|
1439
|
+
mobileBreakpoint: o = 640,
|
|
1440
|
+
persistKey: a = "ll-widget",
|
|
1441
|
+
disablePersistence: C = !1,
|
|
1442
|
+
teamMembers: b,
|
|
1433
1443
|
currentTeamMemberId: N,
|
|
1434
1444
|
onTeamMemberChange: D,
|
|
1435
1445
|
idleLoopUrl: E,
|
|
@@ -1437,13 +1447,13 @@ function Bt(t) {
|
|
|
1437
1447
|
avatarImageUrl: T,
|
|
1438
1448
|
agentName: z,
|
|
1439
1449
|
branding: I = {},
|
|
1440
|
-
allowCamera:
|
|
1441
|
-
allowScreenShare:
|
|
1450
|
+
allowCamera: w = !0,
|
|
1451
|
+
allowScreenShare: x = !0,
|
|
1442
1452
|
allowTyping: y = !0,
|
|
1443
1453
|
onConnect: A,
|
|
1444
1454
|
onDisconnect: X,
|
|
1445
1455
|
onTranscript: ne,
|
|
1446
|
-
onAgentState:
|
|
1456
|
+
onAgentState: $,
|
|
1447
1457
|
onConnectionStateChange: j,
|
|
1448
1458
|
onAgentEvent: F,
|
|
1449
1459
|
onAgentCommand: re,
|
|
@@ -1451,37 +1461,37 @@ function Bt(t) {
|
|
|
1451
1461
|
className: be,
|
|
1452
1462
|
style: we,
|
|
1453
1463
|
zIndex: ge = 2147483647
|
|
1454
|
-
} = t,
|
|
1464
|
+
} = t, ue = N !== void 0, [ke, xe] = k(() => {
|
|
1455
1465
|
var v;
|
|
1456
|
-
return N ?? ((v =
|
|
1457
|
-
}), Q =
|
|
1458
|
-
() => (
|
|
1459
|
-
[
|
|
1460
|
-
), ve = (
|
|
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({
|
|
1461
1471
|
value: m,
|
|
1462
1472
|
defaultValue: d,
|
|
1463
|
-
onChange:
|
|
1464
|
-
persistKey:
|
|
1465
|
-
disablePersistence:
|
|
1466
|
-
}), ee =
|
|
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(
|
|
1467
1477
|
(v) => {
|
|
1468
|
-
const
|
|
1469
|
-
!
|
|
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));
|
|
1470
1480
|
},
|
|
1471
1481
|
[re, F]
|
|
1472
|
-
),
|
|
1482
|
+
), B = lt({
|
|
1473
1483
|
agentId: P ? "__controlled__" : ve,
|
|
1474
|
-
baseUrl:
|
|
1484
|
+
baseUrl: l,
|
|
1475
1485
|
apiKey: i,
|
|
1476
1486
|
sessionEndpoint: r,
|
|
1477
|
-
sessionBody:
|
|
1478
|
-
onDataMessage: P ? void 0 :
|
|
1487
|
+
sessionBody: s,
|
|
1488
|
+
onDataMessage: P ? void 0 : de
|
|
1479
1489
|
});
|
|
1480
|
-
|
|
1490
|
+
S(() => {
|
|
1481
1491
|
if (P != null && P.subscribeToDataMessages)
|
|
1482
|
-
return P.subscribeToDataMessages(
|
|
1483
|
-
}, [P,
|
|
1484
|
-
const
|
|
1492
|
+
return P.subscribeToDataMessages(de);
|
|
1493
|
+
}, [P, de]);
|
|
1494
|
+
const u = Se(() => P ? {
|
|
1485
1495
|
connectionState: P.connectionState,
|
|
1486
1496
|
agentState: P.agentState,
|
|
1487
1497
|
transcript: P.transcript,
|
|
@@ -1497,130 +1507,132 @@ function Bt(t) {
|
|
|
1497
1507
|
// Dummy getRoom for shape compatibility — controlled consumers own the Room.
|
|
1498
1508
|
// Internal session's getRoom returns null when no real connect has happened,
|
|
1499
1509
|
// so we reuse its reference for type consistency.
|
|
1500
|
-
getRoom:
|
|
1510
|
+
getRoom: B.getRoom,
|
|
1501
1511
|
isControlled: !0
|
|
1502
1512
|
} : {
|
|
1503
|
-
connectionState:
|
|
1504
|
-
agentState:
|
|
1505
|
-
transcript:
|
|
1506
|
-
videoElement:
|
|
1507
|
-
audioElement:
|
|
1508
|
-
canResume:
|
|
1509
|
-
error:
|
|
1510
|
-
agentConfig:
|
|
1511
|
-
connect:
|
|
1512
|
-
disconnect:
|
|
1513
|
-
getRoom:
|
|
1513
|
+
connectionState: B.connectionState,
|
|
1514
|
+
agentState: B.agentState,
|
|
1515
|
+
transcript: B.transcript,
|
|
1516
|
+
videoElement: B.videoElement,
|
|
1517
|
+
audioElement: B.audioElement,
|
|
1518
|
+
canResume: B.canResume,
|
|
1519
|
+
error: B.error,
|
|
1520
|
+
agentConfig: B.agentConfig,
|
|
1521
|
+
connect: B.connect,
|
|
1522
|
+
disconnect: B.disconnect,
|
|
1523
|
+
getRoom: B.getRoom,
|
|
1514
1524
|
isControlled: !1
|
|
1515
|
-
}, [P,
|
|
1516
|
-
|
|
1517
|
-
const v =
|
|
1518
|
-
if (!(!v || !
|
|
1519
|
-
return
|
|
1520
|
-
v.parentNode ===
|
|
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);
|
|
1521
1531
|
};
|
|
1522
|
-
}, [
|
|
1523
|
-
const v =
|
|
1532
|
+
}, [u.videoElement]), S(() => {
|
|
1533
|
+
const v = u.audioElement;
|
|
1524
1534
|
if (!v) return;
|
|
1525
|
-
|
|
1526
|
-
const
|
|
1527
|
-
return
|
|
1535
|
+
ie.attach(v);
|
|
1536
|
+
const L = v.play();
|
|
1537
|
+
return L && typeof L.catch == "function" && L.catch((te) => {
|
|
1528
1538
|
(te == null ? void 0 : te.name) === "NotAllowedError" && H(!0);
|
|
1529
1539
|
}), () => {
|
|
1530
|
-
|
|
1540
|
+
ie.detach();
|
|
1531
1541
|
};
|
|
1532
|
-
}, [
|
|
1533
|
-
if (
|
|
1534
|
-
const v =
|
|
1542
|
+
}, [u.audioElement]), S(() => {
|
|
1543
|
+
if (u.isControlled || u.connectionState !== "connected") return;
|
|
1544
|
+
const v = u.getRoom();
|
|
1535
1545
|
if (v)
|
|
1536
1546
|
return V.setupMic(v).catch(() => {
|
|
1537
1547
|
}), K.attachRoom(v), O.attachRoom(v), Y.refresh(), () => {
|
|
1538
1548
|
V.teardownMic(), K.teardown(), O.teardown();
|
|
1539
1549
|
};
|
|
1540
|
-
}, [
|
|
1541
|
-
const v =
|
|
1550
|
+
}, [u.isControlled, u.connectionState]), S(() => {
|
|
1551
|
+
const v = u.audioElement;
|
|
1542
1552
|
v && (v.muted = J);
|
|
1543
|
-
}, [
|
|
1544
|
-
const Ce =
|
|
1545
|
-
const
|
|
1546
|
-
if (
|
|
1553
|
+
}, [u.audioElement, J]);
|
|
1554
|
+
const Ce = g((v) => {
|
|
1555
|
+
const L = u.getRoom();
|
|
1556
|
+
if (L)
|
|
1547
1557
|
try {
|
|
1548
1558
|
const te = new TextEncoder().encode(
|
|
1549
1559
|
JSON.stringify({ type: "user_message", text: v })
|
|
1550
1560
|
);
|
|
1551
|
-
|
|
1561
|
+
L.localParticipant.publishData(te, { reliable: !0 });
|
|
1552
1562
|
} catch {
|
|
1553
1563
|
}
|
|
1554
|
-
}, [
|
|
1555
|
-
|
|
1564
|
+
}, [u]), ye = g(() => {
|
|
1565
|
+
ce((v) => !v);
|
|
1556
1566
|
}, []);
|
|
1557
|
-
|
|
1558
|
-
j == null || j(
|
|
1559
|
-
}, [
|
|
1560
|
-
ne == null || ne(
|
|
1561
|
-
}, [
|
|
1562
|
-
|
|
1563
|
-
}, [
|
|
1564
|
-
const h =
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
}, [c,
|
|
1568
|
-
const W =
|
|
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(
|
|
1569
1579
|
(v) => {
|
|
1570
|
-
const
|
|
1571
|
-
|
|
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)));
|
|
1572
1582
|
},
|
|
1573
1583
|
[
|
|
1574
|
-
|
|
1584
|
+
b,
|
|
1575
1585
|
Q,
|
|
1576
|
-
|
|
1577
|
-
|
|
1586
|
+
u,
|
|
1587
|
+
ue,
|
|
1578
1588
|
D
|
|
1579
1589
|
]
|
|
1580
1590
|
);
|
|
1581
|
-
|
|
1582
|
-
he &&
|
|
1583
|
-
}, [
|
|
1591
|
+
S(() => {
|
|
1592
|
+
he && u.connectionState === "connected" && pe(!1);
|
|
1593
|
+
}, [u.connectionState, he]), S(() => {
|
|
1584
1594
|
if (!oe) return;
|
|
1585
|
-
const v = (
|
|
1586
|
-
|
|
1595
|
+
const v = (L) => {
|
|
1596
|
+
L.key === "Escape" && q(!1);
|
|
1587
1597
|
};
|
|
1588
1598
|
return window.addEventListener("keydown", v), () => window.removeEventListener("keydown", v);
|
|
1589
1599
|
}, [oe]);
|
|
1590
|
-
const
|
|
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(
|
|
1591
1601
|
() => G("minimized"),
|
|
1592
1602
|
[G]
|
|
1593
|
-
),
|
|
1594
|
-
|
|
1603
|
+
), Le = g(() => {
|
|
1604
|
+
u.disconnect(), G("hidden");
|
|
1605
|
+
}, [u, G]), Je = g(() => {
|
|
1606
|
+
const v = u.audioElement;
|
|
1595
1607
|
v && v.play().then(() => H(!1)).catch(() => {
|
|
1596
1608
|
});
|
|
1597
|
-
}, [
|
|
1598
|
-
H(!1),
|
|
1599
|
-
}, [
|
|
1609
|
+
}, [u.audioElement]), Xe = g(() => {
|
|
1610
|
+
H(!1), u.connect();
|
|
1611
|
+
}, [u]), fe = {
|
|
1600
1612
|
...we,
|
|
1601
1613
|
zIndex: ge
|
|
1602
1614
|
};
|
|
1603
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);
|
|
1604
|
-
const
|
|
1616
|
+
const Qe = [
|
|
1605
1617
|
"ll-widget",
|
|
1606
1618
|
`ll-widget--${Z}`,
|
|
1607
1619
|
`ll-widget--${ee ? "mobile" : "desktop"}`,
|
|
1608
1620
|
be
|
|
1609
1621
|
].filter(Boolean).join(" ");
|
|
1610
|
-
return /* @__PURE__ */
|
|
1622
|
+
return /* @__PURE__ */ _(
|
|
1611
1623
|
"div",
|
|
1612
1624
|
{
|
|
1613
|
-
className:
|
|
1625
|
+
className: Qe,
|
|
1614
1626
|
style: fe,
|
|
1615
1627
|
"data-display-mode": Z,
|
|
1616
|
-
"data-position":
|
|
1628
|
+
"data-position": p,
|
|
1617
1629
|
children: [
|
|
1618
1630
|
Z === "hidden" && /* @__PURE__ */ e(
|
|
1619
|
-
|
|
1631
|
+
St,
|
|
1620
1632
|
{
|
|
1621
|
-
position:
|
|
1633
|
+
position: p,
|
|
1622
1634
|
isMobile: ee,
|
|
1623
|
-
isSpeaking:
|
|
1635
|
+
isSpeaking: u.agentState === "speaking",
|
|
1624
1636
|
onExpand: () => G("expanded"),
|
|
1625
1637
|
label: `Open ${Ee} widget`
|
|
1626
1638
|
}
|
|
@@ -1628,37 +1640,37 @@ function Bt(t) {
|
|
|
1628
1640
|
Z === "minimized" && /* @__PURE__ */ e(
|
|
1629
1641
|
Lt,
|
|
1630
1642
|
{
|
|
1631
|
-
position:
|
|
1643
|
+
position: p,
|
|
1632
1644
|
isMobile: ee,
|
|
1633
1645
|
agentName: Ee,
|
|
1634
|
-
avatarImageUrl:
|
|
1635
|
-
agentState:
|
|
1646
|
+
avatarImageUrl: Me,
|
|
1647
|
+
agentState: u.agentState,
|
|
1636
1648
|
isMuted: V.isMuted,
|
|
1637
|
-
audioLevel:
|
|
1638
|
-
onExpand:
|
|
1649
|
+
audioLevel: ie,
|
|
1650
|
+
onExpand: He,
|
|
1639
1651
|
onToggleMute: V.toggleMute,
|
|
1640
|
-
onClose:
|
|
1652
|
+
onClose: Le
|
|
1641
1653
|
}
|
|
1642
1654
|
),
|
|
1643
1655
|
Z === "expanded" && /* @__PURE__ */ e(
|
|
1644
|
-
|
|
1656
|
+
At,
|
|
1645
1657
|
{
|
|
1646
|
-
position:
|
|
1658
|
+
position: p,
|
|
1647
1659
|
isMobile: ee,
|
|
1648
1660
|
agentName: Ee,
|
|
1649
|
-
avatarImageUrl:
|
|
1650
|
-
idleLoopUrl:
|
|
1651
|
-
greeting:
|
|
1661
|
+
avatarImageUrl: Me,
|
|
1662
|
+
idleLoopUrl: Ke,
|
|
1663
|
+
greeting: Ye,
|
|
1652
1664
|
branding: I,
|
|
1653
|
-
teamMembers:
|
|
1665
|
+
teamMembers: b,
|
|
1654
1666
|
currentTeamMemberId: Q,
|
|
1655
1667
|
isSwitchingTeamMember: he,
|
|
1656
1668
|
teamSwitcherOpen: oe,
|
|
1657
1669
|
onToggleTeamSwitcher: () => q((v) => !v),
|
|
1658
1670
|
onSelectTeamMember: W,
|
|
1659
|
-
connectionState:
|
|
1660
|
-
agentState:
|
|
1661
|
-
transcript:
|
|
1671
|
+
connectionState: u.connectionState,
|
|
1672
|
+
agentState: u.agentState,
|
|
1673
|
+
transcript: u.transcript,
|
|
1662
1674
|
isMuted: V.isMuted,
|
|
1663
1675
|
micDevices: Y.mics,
|
|
1664
1676
|
isCameraEnabled: K.isEnabled,
|
|
@@ -1668,28 +1680,28 @@ function Bt(t) {
|
|
|
1668
1680
|
isScreenShareEnabled: O.isEnabled,
|
|
1669
1681
|
screenPreviewEl: O.previewEl,
|
|
1670
1682
|
isSpeakerMuted: J,
|
|
1671
|
-
allowCamera:
|
|
1672
|
-
allowScreenShare:
|
|
1683
|
+
allowCamera: w,
|
|
1684
|
+
allowScreenShare: x,
|
|
1673
1685
|
allowTyping: y,
|
|
1674
|
-
languageMenuOpen:
|
|
1675
|
-
onToggleLanguageMenu: () =>
|
|
1676
|
-
needsUserGesture:
|
|
1677
|
-
canResume:
|
|
1686
|
+
languageMenuOpen: ae,
|
|
1687
|
+
onToggleLanguageMenu: () => se((v) => !v),
|
|
1688
|
+
needsUserGesture: le,
|
|
1689
|
+
canResume: u.canResume,
|
|
1678
1690
|
micError: V.micError,
|
|
1679
|
-
error:
|
|
1691
|
+
error: u.error,
|
|
1680
1692
|
avatarVideoContainerRef: me,
|
|
1681
|
-
onConnect: () => void
|
|
1682
|
-
onDisconnect: () =>
|
|
1683
|
-
onRetry:
|
|
1684
|
-
onResumeAudio:
|
|
1693
|
+
onConnect: () => void u.connect(),
|
|
1694
|
+
onDisconnect: () => u.disconnect(),
|
|
1695
|
+
onRetry: Xe,
|
|
1696
|
+
onResumeAudio: Je,
|
|
1685
1697
|
onToggleMute: V.toggleMute,
|
|
1686
1698
|
onToggleCamera: () => void K.toggle(),
|
|
1687
1699
|
onSwitchCameraDevice: (v) => void K.switchDevice(v),
|
|
1688
1700
|
onToggleScreenShare: () => void O.toggle(),
|
|
1689
1701
|
onToggleSpeaker: ye,
|
|
1690
1702
|
onSendMessage: Ce,
|
|
1691
|
-
onMinimize:
|
|
1692
|
-
onClose:
|
|
1703
|
+
onMinimize: qe,
|
|
1704
|
+
onClose: Le,
|
|
1693
1705
|
onClearMicError: V.clearError
|
|
1694
1706
|
}
|
|
1695
1707
|
)
|
|
@@ -1698,66 +1710,66 @@ function Bt(t) {
|
|
|
1698
1710
|
);
|
|
1699
1711
|
}
|
|
1700
1712
|
function Ft(t) {
|
|
1701
|
-
return /* @__PURE__ */ e(
|
|
1713
|
+
return /* @__PURE__ */ e(it, { children: /* @__PURE__ */ e(Ut, { ...t }) });
|
|
1702
1714
|
}
|
|
1703
1715
|
const Gt = ({
|
|
1704
1716
|
agentId: t,
|
|
1705
1717
|
baseUrl: n,
|
|
1706
1718
|
apiKey: i,
|
|
1707
|
-
mode:
|
|
1719
|
+
mode: l,
|
|
1708
1720
|
onAgentEvent: r,
|
|
1709
|
-
className:
|
|
1721
|
+
className: s,
|
|
1710
1722
|
style: c
|
|
1711
1723
|
}) => {
|
|
1712
|
-
const m =
|
|
1713
|
-
|
|
1714
|
-
const
|
|
1715
|
-
var
|
|
1716
|
-
const
|
|
1717
|
-
(
|
|
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);
|
|
1718
1730
|
}, []);
|
|
1719
|
-
return
|
|
1720
|
-
const
|
|
1721
|
-
if (!
|
|
1722
|
-
const
|
|
1723
|
-
return
|
|
1724
|
-
|
|
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;
|
|
1725
1737
|
};
|
|
1726
|
-
}, [t]),
|
|
1727
|
-
d.current && (
|
|
1728
|
-
}, [
|
|
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 });
|
|
1729
1741
|
};
|
|
1730
1742
|
function Kt() {
|
|
1731
|
-
const [t, n] =
|
|
1732
|
-
n((
|
|
1733
|
-
const c =
|
|
1743
|
+
const [t, n] = k([]), i = g((r) => {
|
|
1744
|
+
n((s) => {
|
|
1745
|
+
const c = s.findIndex((m) => m.id === r.id);
|
|
1734
1746
|
if (c >= 0) {
|
|
1735
|
-
const m =
|
|
1747
|
+
const m = s.slice();
|
|
1736
1748
|
return m[c] = r, m;
|
|
1737
1749
|
}
|
|
1738
|
-
return [...
|
|
1750
|
+
return [...s, r];
|
|
1739
1751
|
});
|
|
1740
|
-
}, []),
|
|
1752
|
+
}, []), l = g(() => n([]), []);
|
|
1741
1753
|
return {
|
|
1742
1754
|
entries: t,
|
|
1743
1755
|
pushSegment: i,
|
|
1744
|
-
clear:
|
|
1756
|
+
clear: l,
|
|
1745
1757
|
latest: t.length > 0 ? t[t.length - 1] : null
|
|
1746
1758
|
};
|
|
1747
1759
|
}
|
|
1748
1760
|
export {
|
|
1749
1761
|
Ft as AvatarWidget,
|
|
1750
|
-
|
|
1762
|
+
it as ErrorBoundary,
|
|
1751
1763
|
Gt as LiveLayerWidget,
|
|
1752
|
-
|
|
1764
|
+
ht as useAgentInfo,
|
|
1753
1765
|
ot as useAudioLevel,
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
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,
|
|
1762
1774
|
Kt as useTranscript
|
|
1763
1775
|
};
|