@livelayer/react 0.9.6 → 0.9.7
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 +2 -2
- package/dist/index.mjs +208 -207
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsxs as v, jsx as n, Fragment as ot } from "react/jsx-runtime";
|
|
3
|
-
import { Component as In, useState as C, useRef as A, useEffect as
|
|
3
|
+
import { Component as In, useState as C, useRef as A, useEffect as T, useCallback as E, useMemo as Ue, useLayoutEffect as Tn, forwardRef as lt, useImperativeHandle as Mn, createElement as Dn } from "react";
|
|
4
4
|
import { LiveKitSession as Pn } from "@livelayer/sdk";
|
|
5
5
|
import { createLocalAudioTrack as $n, Track as dn, createLocalVideoTrack as zn } from "livekit-client";
|
|
6
6
|
import { createPortal as On } from "react-dom";
|
|
@@ -35,9 +35,9 @@ class Hn extends In {
|
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
function Wn(e) {
|
|
38
|
-
const [t, r] = C("idle"), [i, o] = C("idle"), [l, s] = C([]), [a, d] = C(null), [f, _] = C(null), [u, c] = C(null), [
|
|
39
|
-
S.current = e.onDataMessage,
|
|
40
|
-
const
|
|
38
|
+
const [t, r] = C("idle"), [i, o] = C("idle"), [l, s] = C([]), [a, d] = C(null), [f, _] = C(null), [u, c] = C(null), [I, L] = C(!1), [b, y] = C(null), m = A(null), S = A(e.onDataMessage);
|
|
39
|
+
S.current = e.onDataMessage, T(() => {
|
|
40
|
+
const R = {
|
|
41
41
|
onConnectionStateChange: (q) => {
|
|
42
42
|
r(q), q === "connected" && y(null);
|
|
43
43
|
},
|
|
@@ -61,7 +61,7 @@ function Wn(e) {
|
|
|
61
61
|
sessionEndpoint: e.sessionEndpoint,
|
|
62
62
|
sessionBody: e.sessionBody
|
|
63
63
|
},
|
|
64
|
-
|
|
64
|
+
R
|
|
65
65
|
);
|
|
66
66
|
return m.current = B, r("idle"), o("idle"), s([]), d(null), _(null), c(null), L(!1), y(null), () => {
|
|
67
67
|
var q;
|
|
@@ -74,20 +74,20 @@ function Wn(e) {
|
|
|
74
74
|
e.sessionEndpoint,
|
|
75
75
|
JSON.stringify(e.sessionBody ?? {})
|
|
76
76
|
]);
|
|
77
|
-
const
|
|
78
|
-
const
|
|
79
|
-
if (
|
|
77
|
+
const $ = E(async () => {
|
|
78
|
+
const R = m.current;
|
|
79
|
+
if (R)
|
|
80
80
|
try {
|
|
81
|
-
await
|
|
81
|
+
await R.connect();
|
|
82
82
|
} catch (B) {
|
|
83
83
|
throw y(B instanceof Error ? B.message : String(B)), B;
|
|
84
84
|
}
|
|
85
|
-
}, []),
|
|
86
|
-
const
|
|
87
|
-
|
|
85
|
+
}, []), D = E(() => {
|
|
86
|
+
const R = m.current;
|
|
87
|
+
R && R.disconnect();
|
|
88
88
|
}, []), x = E(() => {
|
|
89
|
-
var
|
|
90
|
-
return ((
|
|
89
|
+
var R;
|
|
90
|
+
return ((R = m.current) == null ? void 0 : R.getRoom()) ?? null;
|
|
91
91
|
}, []);
|
|
92
92
|
return {
|
|
93
93
|
connectionState: t,
|
|
@@ -96,10 +96,10 @@ function Wn(e) {
|
|
|
96
96
|
agentConfig: a,
|
|
97
97
|
videoElement: f,
|
|
98
98
|
audioElement: u,
|
|
99
|
-
canResume:
|
|
99
|
+
canResume: I,
|
|
100
100
|
error: b,
|
|
101
|
-
connect:
|
|
102
|
-
disconnect:
|
|
101
|
+
connect: $,
|
|
102
|
+
disconnect: D,
|
|
103
103
|
getRoom: x,
|
|
104
104
|
session: m.current
|
|
105
105
|
};
|
|
@@ -116,9 +116,9 @@ function Bn() {
|
|
|
116
116
|
));
|
|
117
117
|
const c = l.current;
|
|
118
118
|
u.getByteFrequencyData(c);
|
|
119
|
-
let
|
|
120
|
-
for (let b = 0; b < c.length; b++)
|
|
121
|
-
const L =
|
|
119
|
+
let I = 0;
|
|
120
|
+
for (let b = 0; b < c.length; b++) I += c[b];
|
|
121
|
+
const L = I / c.length / 255;
|
|
122
122
|
for (const b of o.current)
|
|
123
123
|
try {
|
|
124
124
|
b(L);
|
|
@@ -162,7 +162,7 @@ function Bn() {
|
|
|
162
162
|
}, []), _ = E((u) => (o.current.add(u), () => {
|
|
163
163
|
o.current.delete(u);
|
|
164
164
|
}), []);
|
|
165
|
-
return
|
|
165
|
+
return T(() => () => {
|
|
166
166
|
if (f(), t.current) {
|
|
167
167
|
try {
|
|
168
168
|
t.current.disconnect();
|
|
@@ -238,7 +238,7 @@ function qn() {
|
|
|
238
238
|
L.stop();
|
|
239
239
|
}
|
|
240
240
|
s.current = null, a.current = null, t(!1), i("");
|
|
241
|
-
}, []),
|
|
241
|
+
}, []), I = E(() => l(null), []);
|
|
242
242
|
return {
|
|
243
243
|
isMuted: e,
|
|
244
244
|
activeDeviceId: r,
|
|
@@ -248,7 +248,7 @@ function qn() {
|
|
|
248
248
|
attachRoom: f,
|
|
249
249
|
switchDevice: _,
|
|
250
250
|
teardownMic: c,
|
|
251
|
-
clearError:
|
|
251
|
+
clearError: I
|
|
252
252
|
};
|
|
253
253
|
}
|
|
254
254
|
const Fn = { resolution: { width: 640, height: 480, frameRate: 24 } };
|
|
@@ -256,17 +256,18 @@ function Un() {
|
|
|
256
256
|
const [e, t] = C(!1), [r, i] = C(null), [o, l] = C(null), [s, a] = C(""), d = A(null), f = A(null), _ = E((m) => {
|
|
257
257
|
d.current = m;
|
|
258
258
|
}, []), u = E(() => {
|
|
259
|
+
var $;
|
|
259
260
|
const m = d.current, S = f.current;
|
|
260
261
|
if (S && m) {
|
|
261
|
-
const D = m.localParticipant.getTrackPublication(dn.Source.Camera);
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
}
|
|
269
|
-
|
|
262
|
+
const D = m.localParticipant.getTrackPublication(dn.Source.Camera), R = (D == null ? void 0 : D.track) ?? S;
|
|
263
|
+
try {
|
|
264
|
+
m.localParticipant.unpublishTrack(R);
|
|
265
|
+
} catch {
|
|
266
|
+
}
|
|
267
|
+
try {
|
|
268
|
+
($ = R.stop) == null || $.call(R);
|
|
269
|
+
} catch {
|
|
270
|
+
}
|
|
270
271
|
}
|
|
271
272
|
f.current = null, l(null), t(!1);
|
|
272
273
|
}, []), c = E(async (m) => {
|
|
@@ -274,11 +275,11 @@ function Un() {
|
|
|
274
275
|
if (S) {
|
|
275
276
|
i(null);
|
|
276
277
|
try {
|
|
277
|
-
const
|
|
278
|
-
m && (
|
|
279
|
-
const
|
|
280
|
-
await S.localParticipant.publishTrack(
|
|
281
|
-
const x =
|
|
278
|
+
const $ = { ...Fn };
|
|
279
|
+
m && ($.deviceId = m);
|
|
280
|
+
const D = await zn($);
|
|
281
|
+
await S.localParticipant.publishTrack(D), f.current = D;
|
|
282
|
+
const x = D.attach();
|
|
282
283
|
l(x), t(!0), m && a(m);
|
|
283
284
|
try {
|
|
284
285
|
S.localParticipant.publishData(
|
|
@@ -287,26 +288,26 @@ function Un() {
|
|
|
287
288
|
);
|
|
288
289
|
} catch {
|
|
289
290
|
}
|
|
290
|
-
} catch (
|
|
291
|
-
const
|
|
292
|
-
i(
|
|
291
|
+
} catch ($) {
|
|
292
|
+
const D = $ instanceof Error && $.name === "NotAllowedError" ? "Enable your camera in the browser to share video." : "Camera unavailable. Check permissions and try again.";
|
|
293
|
+
i(D);
|
|
293
294
|
}
|
|
294
295
|
}
|
|
295
|
-
}, []),
|
|
296
|
+
}, []), I = E(async () => {
|
|
296
297
|
e ? u() : await c(s || void 0);
|
|
297
298
|
}, [e, s, u, c]), L = E(async (m) => {
|
|
298
299
|
u(), await c(m);
|
|
299
300
|
}, [u, c]), b = E(() => {
|
|
300
301
|
u(), d.current = null, i(null), a("");
|
|
301
302
|
}, [u]), y = E(() => i(null), []);
|
|
302
|
-
return
|
|
303
|
+
return T(() => () => {
|
|
303
304
|
f.current && f.current.stop();
|
|
304
305
|
}, []), {
|
|
305
306
|
isEnabled: e,
|
|
306
307
|
error: r,
|
|
307
308
|
previewEl: o,
|
|
308
309
|
activeDeviceId: s,
|
|
309
|
-
toggle:
|
|
310
|
+
toggle: I,
|
|
310
311
|
switchDevice: L,
|
|
311
312
|
attachRoom: _,
|
|
312
313
|
teardown: b,
|
|
@@ -330,7 +331,7 @@ function jn() {
|
|
|
330
331
|
i(null);
|
|
331
332
|
try {
|
|
332
333
|
await c.localParticipant.setScreenShareEnabled(!0);
|
|
333
|
-
let
|
|
334
|
+
let I = 0;
|
|
334
335
|
const L = () => {
|
|
335
336
|
const b = c.localParticipant.getTrackPublication(dn.Source.ScreenShare);
|
|
336
337
|
if (b != null && b.track) {
|
|
@@ -345,11 +346,11 @@ function jn() {
|
|
|
345
346
|
}
|
|
346
347
|
return;
|
|
347
348
|
}
|
|
348
|
-
|
|
349
|
+
I++ < 10 ? setTimeout(L, 100) : t(!0);
|
|
349
350
|
};
|
|
350
351
|
L();
|
|
351
|
-
} catch (
|
|
352
|
-
const L =
|
|
352
|
+
} catch (I) {
|
|
353
|
+
const L = I instanceof Error ? I.name : "";
|
|
353
354
|
L !== "NotAllowedError" && L !== "AbortError" && i("Screen share unavailable. Try again."), t(!1);
|
|
354
355
|
}
|
|
355
356
|
}
|
|
@@ -373,7 +374,7 @@ function Vn() {
|
|
|
373
374
|
} catch {
|
|
374
375
|
}
|
|
375
376
|
}, []);
|
|
376
|
-
return
|
|
377
|
+
return T(() => {
|
|
377
378
|
if (o(), typeof navigator > "u" || !navigator.mediaDevices) return;
|
|
378
379
|
const l = () => void o();
|
|
379
380
|
return navigator.mediaDevices.addEventListener("devicechange", l), () => navigator.mediaDevices.removeEventListener("devicechange", l);
|
|
@@ -381,7 +382,7 @@ function Vn() {
|
|
|
381
382
|
}
|
|
382
383
|
function Yn(e, t, r = !1) {
|
|
383
384
|
const [i, o] = C(null), [l, s] = C(null), [a, d] = C(!r && !!e);
|
|
384
|
-
return
|
|
385
|
+
return T(() => {
|
|
385
386
|
if (r || !e) {
|
|
386
387
|
d(!1);
|
|
387
388
|
return;
|
|
@@ -448,7 +449,7 @@ function Zn({
|
|
|
448
449
|
e === void 0 && !o && Jn(l, f), r == null || r(f);
|
|
449
450
|
}
|
|
450
451
|
});
|
|
451
|
-
return
|
|
452
|
+
return T(() => {
|
|
452
453
|
if (s.current || (s.current = !0, o || e !== void 0)) return;
|
|
453
454
|
const f = Qn(Gn(l));
|
|
454
455
|
f && f !== a && d(f);
|
|
@@ -457,7 +458,7 @@ function Zn({
|
|
|
457
458
|
const er = 640;
|
|
458
459
|
function tr(e = er) {
|
|
459
460
|
const [t, r] = C(!1);
|
|
460
|
-
return
|
|
461
|
+
return T(() => {
|
|
461
462
|
if (e === !1) {
|
|
462
463
|
r(!1);
|
|
463
464
|
return;
|
|
@@ -489,7 +490,7 @@ function rr(e) {
|
|
|
489
490
|
const [t, r] = C(
|
|
490
491
|
() => e ?? Vt()
|
|
491
492
|
);
|
|
492
|
-
return
|
|
493
|
+
return T(() => {
|
|
493
494
|
if (e !== void 0) return;
|
|
494
495
|
nr();
|
|
495
496
|
const i = () => r(Vt());
|
|
@@ -582,7 +583,7 @@ function fr(e) {
|
|
|
582
583
|
},
|
|
583
584
|
[r, t.thinking]
|
|
584
585
|
);
|
|
585
|
-
return
|
|
586
|
+
return T(() => () => {
|
|
586
587
|
if (i.current) {
|
|
587
588
|
try {
|
|
588
589
|
i.current.pause();
|
|
@@ -719,7 +720,7 @@ const vr = ({
|
|
|
719
720
|
avatarImageUrl: l,
|
|
720
721
|
agentName: s
|
|
721
722
|
}) => {
|
|
722
|
-
const a = mr(e), d = a === "right" ? "left" : "right", f = t ? 80 : 72, _ = !!l, [u, c] = C(null), [
|
|
723
|
+
const a = mr(e), d = a === "right" ? "left" : "right", f = t ? 80 : 72, _ = !!l, [u, c] = C(null), [I, L] = C(!1), b = A(null), y = A(!1), m = E(
|
|
723
724
|
(N) => {
|
|
724
725
|
if (typeof window > "u") return N;
|
|
725
726
|
const M = f / 2, F = Qt + M, re = window.innerHeight - Qt - M;
|
|
@@ -727,7 +728,7 @@ const vr = ({
|
|
|
727
728
|
},
|
|
728
729
|
[f]
|
|
729
730
|
);
|
|
730
|
-
|
|
731
|
+
T(() => {
|
|
731
732
|
const N = yr();
|
|
732
733
|
c(m(N ?? window.innerHeight / 2));
|
|
733
734
|
const M = () => {
|
|
@@ -750,7 +751,7 @@ const vr = ({
|
|
|
750
751
|
}
|
|
751
752
|
},
|
|
752
753
|
[u]
|
|
753
|
-
),
|
|
754
|
+
), $ = E(
|
|
754
755
|
(N) => {
|
|
755
756
|
const M = b.current;
|
|
756
757
|
if (!M) return;
|
|
@@ -758,7 +759,7 @@ const vr = ({
|
|
|
758
759
|
!M.moved && Math.abs(F) > gr && (M.moved = !0, L(!0)), M.moved && c(m(M.startCenterY + F));
|
|
759
760
|
},
|
|
760
761
|
[m]
|
|
761
|
-
),
|
|
762
|
+
), D = E(
|
|
762
763
|
(N) => {
|
|
763
764
|
const M = b.current;
|
|
764
765
|
if (M) {
|
|
@@ -776,7 +777,7 @@ const vr = ({
|
|
|
776
777
|
return;
|
|
777
778
|
}
|
|
778
779
|
i();
|
|
779
|
-
}, [i]),
|
|
780
|
+
}, [i]), R = E(
|
|
780
781
|
(N) => {
|
|
781
782
|
if (N.key === "ArrowUp" || N.key === "ArrowDown") {
|
|
782
783
|
N.preventDefault();
|
|
@@ -794,7 +795,7 @@ const vr = ({
|
|
|
794
795
|
`ll-hidden--${a}`,
|
|
795
796
|
t ? "ll-hidden--mobile" : "ll-hidden--desktop",
|
|
796
797
|
r ? "ll-hidden--speaking" : null,
|
|
797
|
-
|
|
798
|
+
I ? "is-dragging" : null,
|
|
798
799
|
_ ? "ll-hidden--with-avatar" : null
|
|
799
800
|
].filter(Boolean).join(" "), q = u === null ? void 0 : { top: `${u - f / 2}px`, transform: "none" };
|
|
800
801
|
return /* @__PURE__ */ n(
|
|
@@ -803,11 +804,11 @@ const vr = ({
|
|
|
803
804
|
type: "button",
|
|
804
805
|
className: B,
|
|
805
806
|
onPointerDown: S,
|
|
806
|
-
onPointerMove:
|
|
807
|
-
onPointerUp:
|
|
808
|
-
onPointerCancel:
|
|
807
|
+
onPointerMove: $,
|
|
808
|
+
onPointerUp: D,
|
|
809
|
+
onPointerCancel: D,
|
|
809
810
|
onClick: x,
|
|
810
|
-
onKeyDown:
|
|
811
|
+
onKeyDown: R,
|
|
811
812
|
"aria-label": o,
|
|
812
813
|
"data-position": e,
|
|
813
814
|
style: q,
|
|
@@ -855,12 +856,12 @@ const vr = ({
|
|
|
855
856
|
const _ = (Math.sqrt(5) - 1) / 2;
|
|
856
857
|
return Array.from({ length: t }, (u, c) => 0.5 + c * _ % 1 * 0.5);
|
|
857
858
|
}, [t]);
|
|
858
|
-
|
|
859
|
+
T(() => e.subscribe((u) => {
|
|
859
860
|
for (let c = 0; c < t; c++) {
|
|
860
|
-
const
|
|
861
|
-
if (!
|
|
861
|
+
const I = a.current[c];
|
|
862
|
+
if (!I) continue;
|
|
862
863
|
const L = Math.max(i, u * r * d[c]);
|
|
863
|
-
|
|
864
|
+
I.style.height = `${L}px`;
|
|
864
865
|
}
|
|
865
866
|
}), [e, t, r, i, d]);
|
|
866
867
|
const f = ["ll-waveform", o].filter(Boolean).join(" ");
|
|
@@ -1009,7 +1010,7 @@ const vr = ({
|
|
|
1009
1010
|
style: o
|
|
1010
1011
|
}) => {
|
|
1011
1012
|
const [l, s] = C(!1), a = A(e);
|
|
1012
|
-
if (
|
|
1013
|
+
if (T(() => {
|
|
1013
1014
|
a.current !== e && (a.current = e, s(!1));
|
|
1014
1015
|
}, [e]), !e) return null;
|
|
1015
1016
|
const d = {
|
|
@@ -1046,7 +1047,7 @@ const vr = ({
|
|
|
1046
1047
|
children: i
|
|
1047
1048
|
}) => {
|
|
1048
1049
|
const o = A(null), [l, s] = C(null);
|
|
1049
|
-
return
|
|
1050
|
+
return Tn(() => {
|
|
1050
1051
|
if (!e) {
|
|
1051
1052
|
s(null);
|
|
1052
1053
|
return;
|
|
@@ -1063,7 +1064,7 @@ const vr = ({
|
|
|
1063
1064
|
return d(), window.addEventListener("scroll", d, !0), window.addEventListener("resize", d), () => {
|
|
1064
1065
|
window.removeEventListener("scroll", d, !0), window.removeEventListener("resize", d);
|
|
1065
1066
|
};
|
|
1066
|
-
}, [e, r]),
|
|
1067
|
+
}, [e, r]), T(() => {
|
|
1067
1068
|
if (!e) return;
|
|
1068
1069
|
const a = (f) => {
|
|
1069
1070
|
const _ = f.target, u = o.current, c = r.current;
|
|
@@ -1108,7 +1109,7 @@ const vr = ({
|
|
|
1108
1109
|
allowTyping: _,
|
|
1109
1110
|
isTypingOpen: u,
|
|
1110
1111
|
onToggleTyping: c,
|
|
1111
|
-
onDisconnect:
|
|
1112
|
+
onDisconnect: I
|
|
1112
1113
|
}) => {
|
|
1113
1114
|
const [L, b] = C(!1), y = A(null);
|
|
1114
1115
|
return /* @__PURE__ */ v(ot, { children: [
|
|
@@ -1147,7 +1148,7 @@ const vr = ({
|
|
|
1147
1148
|
{
|
|
1148
1149
|
type: "button",
|
|
1149
1150
|
className: "ll-tool ll-tool--danger",
|
|
1150
|
-
onClick:
|
|
1151
|
+
onClick: I,
|
|
1151
1152
|
"aria-label": "End conversation",
|
|
1152
1153
|
children: /* @__PURE__ */ n(gn, {})
|
|
1153
1154
|
}
|
|
@@ -1284,16 +1285,16 @@ const Sr = ({
|
|
|
1284
1285
|
teamSwitcherOpen: _,
|
|
1285
1286
|
onToggleTeamSwitcher: u,
|
|
1286
1287
|
onSelectTeamMember: c,
|
|
1287
|
-
languageMenuOpen:
|
|
1288
|
+
languageMenuOpen: I,
|
|
1288
1289
|
onToggleLanguageMenu: L,
|
|
1289
1290
|
connectionState: b,
|
|
1290
1291
|
agentState: y,
|
|
1291
1292
|
transcript: m,
|
|
1292
1293
|
canResume: S,
|
|
1293
|
-
needsUserGesture:
|
|
1294
|
-
error:
|
|
1294
|
+
needsUserGesture: $,
|
|
1295
|
+
error: D,
|
|
1295
1296
|
isMuted: x,
|
|
1296
|
-
micError:
|
|
1297
|
+
micError: R,
|
|
1297
1298
|
micDevices: B,
|
|
1298
1299
|
activeMicId: q,
|
|
1299
1300
|
isCameraEnabled: N,
|
|
@@ -1322,15 +1323,15 @@ const Sr = ({
|
|
|
1322
1323
|
onToggleCamera: Re,
|
|
1323
1324
|
onSwitchCameraDevice: $e,
|
|
1324
1325
|
onToggleScreenShare: Ie,
|
|
1325
|
-
onToggleSpeaker:
|
|
1326
|
-
onSendMessage:
|
|
1326
|
+
onToggleSpeaker: Te,
|
|
1327
|
+
onSendMessage: z,
|
|
1327
1328
|
onMinimize: st,
|
|
1328
1329
|
onClose: dt,
|
|
1329
1330
|
onClearMicError: vt
|
|
1330
1331
|
}) => {
|
|
1331
|
-
var
|
|
1332
|
+
var Me;
|
|
1332
1333
|
const we = ((a == null ? void 0 : a.length) ?? 0) > 1, _e = b === "connecting" || b === "connected", te = b === "connected", bt = b === "idle" || b === "disconnected" || b === "error", [Je, ce] = C(!1);
|
|
1333
|
-
|
|
1334
|
+
T(() => {
|
|
1334
1335
|
if (!oe) {
|
|
1335
1336
|
ce(!1);
|
|
1336
1337
|
return;
|
|
@@ -1346,7 +1347,7 @@ const Sr = ({
|
|
|
1346
1347
|
};
|
|
1347
1348
|
}, [oe]);
|
|
1348
1349
|
const [X, Ke] = C(!1);
|
|
1349
|
-
|
|
1350
|
+
T(() => {
|
|
1350
1351
|
if (!te) {
|
|
1351
1352
|
Ke(!1);
|
|
1352
1353
|
return;
|
|
@@ -1356,24 +1357,24 @@ const Sr = ({
|
|
|
1356
1357
|
return () => clearTimeout(h);
|
|
1357
1358
|
}, [te, Je]);
|
|
1358
1359
|
const ze = b === "connecting" || te && !!i && !Je && !X, xe = A(null), se = A(null);
|
|
1359
|
-
|
|
1360
|
+
T(() => {
|
|
1360
1361
|
const h = xe.current;
|
|
1361
1362
|
h && (h.innerHTML = "", M && (M.style.width = "100%", M.style.height = "100%", M.style.objectFit = "cover", M.style.transform = "scaleX(-1)", h.appendChild(M)));
|
|
1362
|
-
}, [M]),
|
|
1363
|
+
}, [M]), T(() => {
|
|
1363
1364
|
const h = se.current;
|
|
1364
1365
|
h && (h.innerHTML = "", Z && (Z.style.width = "100%", Z.style.height = "100%", Z.style.objectFit = "contain", h.appendChild(Z)));
|
|
1365
1366
|
}, [Z]);
|
|
1366
1367
|
const [me, ke] = C(!1), [G, ne] = C(!1);
|
|
1367
|
-
|
|
1368
|
-
if (!me && !G && !
|
|
1368
|
+
T(() => {
|
|
1369
|
+
if (!me && !G && !I && !_) return;
|
|
1369
1370
|
const h = () => {
|
|
1370
|
-
ke(!1), ne(!1),
|
|
1371
|
+
ke(!1), ne(!1), I && L(), _ && u();
|
|
1371
1372
|
};
|
|
1372
1373
|
return document.addEventListener("click", h), () => document.removeEventListener("click", h);
|
|
1373
1374
|
}, [
|
|
1374
1375
|
me,
|
|
1375
1376
|
G,
|
|
1376
|
-
|
|
1377
|
+
I,
|
|
1377
1378
|
_,
|
|
1378
1379
|
L,
|
|
1379
1380
|
u
|
|
@@ -1382,9 +1383,9 @@ const Sr = ({
|
|
|
1382
1383
|
(h) => {
|
|
1383
1384
|
h.preventDefault();
|
|
1384
1385
|
const V = Ee.trim();
|
|
1385
|
-
V && (
|
|
1386
|
+
V && (z(V), Oe(""));
|
|
1386
1387
|
},
|
|
1387
|
-
[Ee,
|
|
1388
|
+
[Ee, z]
|
|
1388
1389
|
), Qe = s.productName || "Live Layer";
|
|
1389
1390
|
let de = null, Ce = null;
|
|
1390
1391
|
for (let h = m.length - 1; h >= 0; h--) {
|
|
@@ -1412,7 +1413,7 @@ const Sr = ({
|
|
|
1412
1413
|
alt: r,
|
|
1413
1414
|
className: "ll-expanded__bg-img"
|
|
1414
1415
|
}
|
|
1415
|
-
) : /* @__PURE__ */ n("div", { className: "ll-expanded__bg-fallback", children: /* @__PURE__ */ n("span", { className: "ll-expanded__bg-initial", children: ((
|
|
1416
|
+
) : /* @__PURE__ */ n("div", { className: "ll-expanded__bg-fallback", children: /* @__PURE__ */ n("span", { className: "ll-expanded__bg-initial", children: ((Me = r == null ? void 0 : r.charAt(0)) == null ? void 0 : Me.toUpperCase()) || "A" }) }),
|
|
1416
1417
|
o && !te && /* @__PURE__ */ n(
|
|
1417
1418
|
"video",
|
|
1418
1419
|
{
|
|
@@ -1430,7 +1431,7 @@ const Sr = ({
|
|
|
1430
1431
|
/* @__PURE__ */ n("div", { className: "ll-expanded__spinner" }),
|
|
1431
1432
|
/* @__PURE__ */ n("p", { className: "ll-expanded__overlay-text", children: f ? "Switching..." : "Connecting..." })
|
|
1432
1433
|
] }),
|
|
1433
|
-
|
|
1434
|
+
$ && te && /* @__PURE__ */ v(
|
|
1434
1435
|
"button",
|
|
1435
1436
|
{
|
|
1436
1437
|
type: "button",
|
|
@@ -1517,7 +1518,7 @@ const Sr = ({
|
|
|
1517
1518
|
h.stopPropagation(), L();
|
|
1518
1519
|
},
|
|
1519
1520
|
"aria-haspopup": "listbox",
|
|
1520
|
-
"aria-expanded":
|
|
1521
|
+
"aria-expanded": I,
|
|
1521
1522
|
"aria-label": "Language: English",
|
|
1522
1523
|
title: "Language: English",
|
|
1523
1524
|
children: [
|
|
@@ -1526,7 +1527,7 @@ const Sr = ({
|
|
|
1526
1527
|
]
|
|
1527
1528
|
}
|
|
1528
1529
|
),
|
|
1529
|
-
|
|
1530
|
+
I && /* @__PURE__ */ n(
|
|
1530
1531
|
"div",
|
|
1531
1532
|
{
|
|
1532
1533
|
className: "ll-hmenu",
|
|
@@ -1616,7 +1617,7 @@ const Sr = ({
|
|
|
1616
1617
|
bt && /* @__PURE__ */ (() => {
|
|
1617
1618
|
const h = S ? "Resume session" : b === "disconnected" ? "Reconnect to agent" : "Start video call";
|
|
1618
1619
|
return /* @__PURE__ */ v(ot, { children: [
|
|
1619
|
-
!
|
|
1620
|
+
!D && /* @__PURE__ */ v(
|
|
1620
1621
|
"button",
|
|
1621
1622
|
{
|
|
1622
1623
|
type: "button",
|
|
@@ -1776,7 +1777,7 @@ const Sr = ({
|
|
|
1776
1777
|
{
|
|
1777
1778
|
type: "button",
|
|
1778
1779
|
className: `ll-tool ${ae ? "is-muted" : ""}`,
|
|
1779
|
-
onClick:
|
|
1780
|
+
onClick: Te,
|
|
1780
1781
|
"aria-label": ae ? "Unmute speaker" : "Mute speaker",
|
|
1781
1782
|
title: ae ? "Unmute speaker" : "Mute speaker",
|
|
1782
1783
|
children: /* @__PURE__ */ n(mn, { muted: ae })
|
|
@@ -1806,7 +1807,7 @@ const Sr = ({
|
|
|
1806
1807
|
onToggleScreenShare: Ie,
|
|
1807
1808
|
allowScreenShare: ve,
|
|
1808
1809
|
isSpeakerMuted: ae,
|
|
1809
|
-
onToggleSpeaker:
|
|
1810
|
+
onToggleSpeaker: Te,
|
|
1810
1811
|
allowTyping: pe,
|
|
1811
1812
|
isTypingOpen: Le,
|
|
1812
1813
|
onToggleTyping: wt,
|
|
@@ -1837,9 +1838,9 @@ const Sr = ({
|
|
|
1837
1838
|
] })
|
|
1838
1839
|
] }) : null,
|
|
1839
1840
|
(() => {
|
|
1840
|
-
if (
|
|
1841
|
+
if (R && b !== "error")
|
|
1841
1842
|
return /* @__PURE__ */ v("div", { className: "ll-expanded__banner", role: "alert", children: [
|
|
1842
|
-
/* @__PURE__ */ n("span", { children:
|
|
1843
|
+
/* @__PURE__ */ n("span", { children: R }),
|
|
1843
1844
|
/* @__PURE__ */ n(
|
|
1844
1845
|
"button",
|
|
1845
1846
|
{
|
|
@@ -1851,9 +1852,9 @@ const Sr = ({
|
|
|
1851
1852
|
}
|
|
1852
1853
|
)
|
|
1853
1854
|
] });
|
|
1854
|
-
if (!
|
|
1855
|
+
if (!D || b !== "error") return null;
|
|
1855
1856
|
let h = "Failed to connect", V = "Try again";
|
|
1856
|
-
return
|
|
1857
|
+
return D === "MIC_PERMISSION_DENIED" ? h = "Microphone blocked. Allow access to talk." : D === "MIC_NOT_FOUND" ? h = "No microphone found. Plug one in + retry." : D === "MIC_UNAVAILABLE" ? h = "Mic unavailable. Check other apps using it." : D === "AGENT_TIMEOUT" ? h = "Agent didn't pick up. Try again." : D === "CONNECT_FAILED" ? h = "Connection failed. Check your network." : D.length < 80 && (h = D), /* @__PURE__ */ v("div", { className: "ll-expanded__banner ll-expanded__banner--error", role: "alert", children: [
|
|
1857
1858
|
/* @__PURE__ */ n("span", { children: h }),
|
|
1858
1859
|
/* @__PURE__ */ n(
|
|
1859
1860
|
"button",
|
|
@@ -1977,7 +1978,7 @@ function yt(e) {
|
|
|
1977
1978
|
}
|
|
1978
1979
|
return !0;
|
|
1979
1980
|
}
|
|
1980
|
-
const mt = 4096, Rr = 20, Ir = 20,
|
|
1981
|
+
const mt = 4096, Rr = 20, Ir = 20, Tr = 10, Mr = 10, Dr = 30, Pr = 20, on = 500, $r = [
|
|
1981
1982
|
'[data-ll-private="true"]',
|
|
1982
1983
|
".ll-widget",
|
|
1983
1984
|
"script",
|
|
@@ -2039,35 +2040,35 @@ function zr(e, t = {}) {
|
|
|
2039
2040
|
r.querySelectorAll("[data-ll-region]")
|
|
2040
2041
|
), a = [];
|
|
2041
2042
|
for (const x of s) {
|
|
2042
|
-
if (a.length >=
|
|
2043
|
+
if (a.length >= Tr) break;
|
|
2043
2044
|
if (rt(x) || !it(x)) continue;
|
|
2044
|
-
const
|
|
2045
|
+
const R = x.getAttribute("data-ll-region") ?? "", B = x.getAttribute("data-ll-intent") ?? void 0, q = ye(
|
|
2045
2046
|
(x.innerText || x.textContent || "").trim(),
|
|
2046
2047
|
on * 2
|
|
2047
2048
|
);
|
|
2048
|
-
!
|
|
2049
|
+
!R || !q || a.push({ id: R, intent: B, text: q });
|
|
2049
2050
|
}
|
|
2050
2051
|
const d = [], f = ["H1", "H2", "H3", "H4", "H5", "H6"], _ = Array.from(
|
|
2051
2052
|
r.querySelectorAll("h1, h2, h3, h4, h5, h6")
|
|
2052
2053
|
);
|
|
2053
2054
|
for (const x of _) {
|
|
2054
2055
|
if (rt(x) || !it(x)) continue;
|
|
2055
|
-
const
|
|
2056
|
-
|
|
2056
|
+
const R = (x.textContent || "").trim();
|
|
2057
|
+
R && d.push(`${x.tagName}: ${ye(R, 200)}`);
|
|
2057
2058
|
}
|
|
2058
2059
|
const u = Array.from(r.querySelectorAll("p, li"));
|
|
2059
2060
|
for (const x of u) {
|
|
2060
2061
|
if (rt(x) || !it(x) || f.includes(x.tagName)) continue;
|
|
2061
|
-
const
|
|
2062
|
-
|
|
2062
|
+
const R = (x.textContent || "").trim();
|
|
2063
|
+
R.length > 10 && d.push(ye(R, on));
|
|
2063
2064
|
}
|
|
2064
2065
|
const c = d.join(`
|
|
2065
|
-
`),
|
|
2066
|
+
`), I = [], L = Array.from(r.querySelectorAll("a[href]"));
|
|
2066
2067
|
for (const x of L) {
|
|
2067
|
-
if (
|
|
2068
|
+
if (I.length >= Rr) break;
|
|
2068
2069
|
if (rt(x) || !it(x)) continue;
|
|
2069
|
-
const
|
|
2070
|
-
!
|
|
2070
|
+
const R = x.getAttribute("href") || "", B = (x.textContent || "").trim();
|
|
2071
|
+
!R || !B || I.push({ href: R, text: ye(B, 100) });
|
|
2071
2072
|
}
|
|
2072
2073
|
const b = [], y = Array.from(
|
|
2073
2074
|
r.querySelectorAll(
|
|
@@ -2077,17 +2078,17 @@ function zr(e, t = {}) {
|
|
|
2077
2078
|
for (const x of y) {
|
|
2078
2079
|
if (b.length >= Ir) break;
|
|
2079
2080
|
if (rt(x) || !yt(x) || !it(x)) continue;
|
|
2080
|
-
const
|
|
2081
|
-
|
|
2081
|
+
const R = ln(x), B = x instanceof HTMLInputElement ? x.type : x.tagName.toLowerCase();
|
|
2082
|
+
R && b.push({ label: ye(R, 100), type: B });
|
|
2082
2083
|
}
|
|
2083
2084
|
const m = Array.from(
|
|
2084
2085
|
r.querySelectorAll("[data-ll-form]")
|
|
2085
2086
|
), S = [];
|
|
2086
2087
|
for (const x of m) {
|
|
2087
|
-
if (S.length >=
|
|
2088
|
+
if (S.length >= Mr) break;
|
|
2088
2089
|
if (At(x)) continue;
|
|
2089
|
-
const
|
|
2090
|
-
if (!
|
|
2090
|
+
const R = x.getAttribute("data-ll-form") || "";
|
|
2091
|
+
if (!R) continue;
|
|
2091
2092
|
const B = x.getAttribute("data-ll-intent") || void 0, q = Array.from(
|
|
2092
2093
|
x.querySelectorAll(
|
|
2093
2094
|
"[data-ll-field]"
|
|
@@ -2116,25 +2117,25 @@ function zr(e, t = {}) {
|
|
|
2116
2117
|
const ae = typeof M.validationMessage == "string" ? M.validationMessage : "";
|
|
2117
2118
|
ae && (Z.validationMessage = ye(ae, 200)), N.push(Z);
|
|
2118
2119
|
}
|
|
2119
|
-
S.push({ id:
|
|
2120
|
+
S.push({ id: R, intent: B, fields: N });
|
|
2120
2121
|
}
|
|
2121
|
-
const
|
|
2122
|
+
const $ = {
|
|
2122
2123
|
url: i,
|
|
2123
2124
|
title: l,
|
|
2124
2125
|
pathname: o,
|
|
2125
2126
|
regions: a,
|
|
2126
2127
|
visibleText: c,
|
|
2127
|
-
visibleLinks:
|
|
2128
|
+
visibleLinks: I,
|
|
2128
2129
|
visibleFields: b,
|
|
2129
2130
|
forms: S,
|
|
2130
2131
|
extras: e
|
|
2131
2132
|
};
|
|
2132
|
-
let
|
|
2133
|
-
for (;
|
|
2134
|
-
|
|
2135
|
-
for (;
|
|
2136
|
-
|
|
2137
|
-
return Be(
|
|
2133
|
+
let D = Be(JSON.stringify($.regions)) + Be($.visibleText) + Be(JSON.stringify($.visibleLinks)) + Be(JSON.stringify($.visibleFields));
|
|
2134
|
+
for (; D > mt && $.visibleFields.length > 0; )
|
|
2135
|
+
$.visibleFields.pop(), D = Be(JSON.stringify($.visibleFields));
|
|
2136
|
+
for (; D > mt && $.visibleLinks.length > 0; )
|
|
2137
|
+
$.visibleLinks.pop(), D -= 80;
|
|
2138
|
+
return Be($.visibleText) > mt && ($.visibleText = ye($.visibleText, mt - 100)), $;
|
|
2138
2139
|
}
|
|
2139
2140
|
let qe = null;
|
|
2140
2141
|
function an(e, t = {}) {
|
|
@@ -2295,16 +2296,16 @@ const Qr = /* @__PURE__ */ new Set([
|
|
|
2295
2296
|
autoConnect: _ = !1,
|
|
2296
2297
|
displayMode: u,
|
|
2297
2298
|
defaultDisplayMode: c = "expanded",
|
|
2298
|
-
onDisplayModeChange:
|
|
2299
|
+
onDisplayModeChange: I,
|
|
2299
2300
|
position: L = "bottom-right",
|
|
2300
2301
|
mobileBreakpoint: b = 640,
|
|
2301
2302
|
persistKey: y = "ll-widget",
|
|
2302
2303
|
disablePersistence: m = !1,
|
|
2303
2304
|
teamMembers: S,
|
|
2304
|
-
currentTeamMemberId:
|
|
2305
|
-
onTeamMemberChange:
|
|
2305
|
+
currentTeamMemberId: $,
|
|
2306
|
+
onTeamMemberChange: D,
|
|
2306
2307
|
idleLoopUrl: x,
|
|
2307
|
-
greeting:
|
|
2308
|
+
greeting: R,
|
|
2308
2309
|
avatarImageUrl: B,
|
|
2309
2310
|
agentName: q,
|
|
2310
2311
|
branding: N = {},
|
|
@@ -2333,31 +2334,31 @@ const Qr = /* @__PURE__ */ new Set([
|
|
|
2333
2334
|
onAgentState: Re,
|
|
2334
2335
|
onConnectionStateChange: $e,
|
|
2335
2336
|
onAgentEvent: Ie,
|
|
2336
|
-
onAgentCommand:
|
|
2337
|
-
controlledSession:
|
|
2337
|
+
onAgentCommand: Te,
|
|
2338
|
+
controlledSession: z,
|
|
2338
2339
|
className: st,
|
|
2339
2340
|
style: dt,
|
|
2340
2341
|
zIndex: vt = 2147483647
|
|
2341
2342
|
} = t, we = rr(he), _e = dr(we, pe, be);
|
|
2342
|
-
|
|
2343
|
+
T(() => {
|
|
2343
2344
|
Or(), Ur();
|
|
2344
2345
|
}, [we]);
|
|
2345
|
-
const te =
|
|
2346
|
+
const te = $ !== void 0, [bt, Je] = C(() => {
|
|
2346
2347
|
var g;
|
|
2347
|
-
return
|
|
2348
|
-
}), ce = te ?
|
|
2348
|
+
return $ ?? ((g = S == null ? void 0 : S[0]) == null ? void 0 : g.id);
|
|
2349
|
+
}), ce = te ? $ : bt, X = Ue(
|
|
2349
2350
|
() => (S == null ? void 0 : S.find((g) => g.id === ce)) ?? null,
|
|
2350
2351
|
[S, ce]
|
|
2351
2352
|
), Ke = (X == null ? void 0 : X.agentId) ?? i, ze = f === "EMBEDDED", [xe, se] = Zn({
|
|
2352
2353
|
value: ze ? "expanded" : u,
|
|
2353
2354
|
defaultValue: ze ? "expanded" : c,
|
|
2354
|
-
onChange:
|
|
2355
|
+
onChange: I,
|
|
2355
2356
|
persistKey: y,
|
|
2356
2357
|
disablePersistence: ze || m
|
|
2357
|
-
}), me = tr(b), ke = Bn(), G = qn(), ne = Un(), Le = jn(), Xe = Vn(), [wt, Ee] = C(!1), [Oe, ut] = C(!1), [Qe, de] = C(!1), [Ce, ft] = C(!1), [He, _t] = C(!1),
|
|
2358
|
-
h.current =
|
|
2359
|
-
const V = A(ee), xt = A(at), kt = A(Ve), Lt = A(Ye), Rt = A(je), It = A(ct),
|
|
2360
|
-
V.current = ee, xt.current = at, kt.current = Ve, Lt.current = Ye, Rt.current = je, It.current = ct,
|
|
2358
|
+
}), me = tr(b), ke = Bn(), G = qn(), ne = Un(), Le = jn(), Xe = Vn(), [wt, Ee] = C(!1), [Oe, ut] = C(!1), [Qe, de] = C(!1), [Ce, ft] = C(!1), [He, _t] = C(!1), Me = fr({ baseUrl: l, config: d }), h = A(Me);
|
|
2359
|
+
h.current = Me;
|
|
2360
|
+
const V = A(ee), xt = A(at), kt = A(Ve), Lt = A(Ye), Rt = A(je), It = A(ct), Tt = A(oe), Et = A(Ge), ue = A(null);
|
|
2361
|
+
V.current = ee, xt.current = at, kt.current = Ve, Lt.current = Ye, Rt.current = je, It.current = ct, Tt.current = oe, Et.current = Ge;
|
|
2361
2362
|
function Se(g) {
|
|
2362
2363
|
const p = Et.current;
|
|
2363
2364
|
return p ? p.includes(g) : !0;
|
|
@@ -2735,7 +2736,7 @@ const Qr = /* @__PURE__ */ new Set([
|
|
|
2735
2736
|
} catch (K) {
|
|
2736
2737
|
console.warn("[LiveLayer] request_routes: publishData failed.", K);
|
|
2737
2738
|
}
|
|
2738
|
-
}, j =
|
|
2739
|
+
}, j = Tt.current;
|
|
2739
2740
|
if (j) {
|
|
2740
2741
|
try {
|
|
2741
2742
|
const O = j(), K = (Q) => {
|
|
@@ -2766,25 +2767,25 @@ const Qr = /* @__PURE__ */ new Set([
|
|
|
2766
2767
|
}
|
|
2767
2768
|
return;
|
|
2768
2769
|
}
|
|
2769
|
-
Qr.has(p.type) ||
|
|
2770
|
+
Qr.has(p.type) || Te == null || Te(p);
|
|
2770
2771
|
}
|
|
2771
2772
|
},
|
|
2772
|
-
[
|
|
2773
|
+
[Te, Ie]
|
|
2773
2774
|
), J = Wn({
|
|
2774
|
-
agentId:
|
|
2775
|
+
agentId: z ? "__controlled__" : Ke,
|
|
2775
2776
|
baseUrl: l,
|
|
2776
2777
|
apiKey: o,
|
|
2777
2778
|
sessionEndpoint: s,
|
|
2778
2779
|
sessionBody: a,
|
|
2779
|
-
onDataMessage:
|
|
2780
|
+
onDataMessage: z ? void 0 : Ze
|
|
2780
2781
|
});
|
|
2781
|
-
|
|
2782
|
-
if (
|
|
2783
|
-
return
|
|
2784
|
-
}, [
|
|
2782
|
+
T(() => {
|
|
2783
|
+
if (z != null && z.subscribeToDataMessages)
|
|
2784
|
+
return z.subscribeToDataMessages(Ze);
|
|
2785
|
+
}, [z, Ze]), ue.current = () => {
|
|
2785
2786
|
var g;
|
|
2786
2787
|
return (g = J.getRoom) == null ? void 0 : g.call(J);
|
|
2787
|
-
},
|
|
2788
|
+
}, T(() => {
|
|
2788
2789
|
var Y;
|
|
2789
2790
|
if (typeof window > "u") return;
|
|
2790
2791
|
const g = ((Y = window.location) == null ? void 0 : Y.hostname) || "";
|
|
@@ -2799,19 +2800,19 @@ const Qr = /* @__PURE__ */ new Set([
|
|
|
2799
2800
|
delete window.__livelayerSimulateCommand;
|
|
2800
2801
|
};
|
|
2801
2802
|
}, [Ze]);
|
|
2802
|
-
const w = Ue(() =>
|
|
2803
|
-
connectionState:
|
|
2804
|
-
agentState:
|
|
2805
|
-
transcript:
|
|
2806
|
-
videoElement:
|
|
2807
|
-
audioElement:
|
|
2808
|
-
canResume:
|
|
2809
|
-
error:
|
|
2803
|
+
const w = Ue(() => z ? {
|
|
2804
|
+
connectionState: z.connectionState,
|
|
2805
|
+
agentState: z.agentState,
|
|
2806
|
+
transcript: z.transcript,
|
|
2807
|
+
videoElement: z.videoElement,
|
|
2808
|
+
audioElement: z.audioElement,
|
|
2809
|
+
canResume: z.canResume,
|
|
2810
|
+
error: z.error,
|
|
2810
2811
|
agentConfig: null,
|
|
2811
2812
|
connect: async () => {
|
|
2812
|
-
await
|
|
2813
|
+
await z.onConnect();
|
|
2813
2814
|
},
|
|
2814
|
-
disconnect: () =>
|
|
2815
|
+
disconnect: () => z.onDisconnect(),
|
|
2815
2816
|
// Dummy getRoom for shape compatibility — controlled consumers own the Room.
|
|
2816
2817
|
// Internal session's getRoom returns null when no real connect has happened,
|
|
2817
2818
|
// so we reuse its reference for type consistency.
|
|
@@ -2830,10 +2831,10 @@ const Qr = /* @__PURE__ */ new Set([
|
|
|
2830
2831
|
disconnect: J.disconnect,
|
|
2831
2832
|
getRoom: J.getRoom,
|
|
2832
2833
|
isControlled: !1
|
|
2833
|
-
}, [
|
|
2834
|
-
|
|
2835
|
-
const Dt = A(
|
|
2836
|
-
Dt.current =
|
|
2834
|
+
}, [z, J]), Mt = A(w);
|
|
2835
|
+
Mt.current = w;
|
|
2836
|
+
const Dt = A(z);
|
|
2837
|
+
Dt.current = z, Mn(
|
|
2837
2838
|
r,
|
|
2838
2839
|
() => ({
|
|
2839
2840
|
sendData: async (g) => {
|
|
@@ -2847,7 +2848,7 @@ const Qr = /* @__PURE__ */ new Set([
|
|
|
2847
2848
|
}
|
|
2848
2849
|
return;
|
|
2849
2850
|
}
|
|
2850
|
-
const Y = (nt = (ge =
|
|
2851
|
+
const Y = (nt = (ge = Mt.current) == null ? void 0 : ge.getRoom) == null ? void 0 : nt.call(ge), le = Y == null ? void 0 : Y.localParticipant;
|
|
2851
2852
|
if (le != null && le.publishData)
|
|
2852
2853
|
try {
|
|
2853
2854
|
const k = new TextEncoder().encode(JSON.stringify(g));
|
|
@@ -2860,13 +2861,13 @@ const Qr = /* @__PURE__ */ new Set([
|
|
|
2860
2861
|
[]
|
|
2861
2862
|
);
|
|
2862
2863
|
const Pt = A(null);
|
|
2863
|
-
|
|
2864
|
+
T(() => {
|
|
2864
2865
|
const g = w.videoElement, p = Pt.current;
|
|
2865
2866
|
if (!(!g || !p))
|
|
2866
2867
|
return p.appendChild(g), () => {
|
|
2867
2868
|
g.parentNode === p && p.removeChild(g);
|
|
2868
2869
|
};
|
|
2869
|
-
}, [w.videoElement]),
|
|
2870
|
+
}, [w.videoElement]), T(() => {
|
|
2870
2871
|
const g = w.audioElement;
|
|
2871
2872
|
if (!g) return;
|
|
2872
2873
|
ke.attach(g);
|
|
@@ -2876,7 +2877,7 @@ const Qr = /* @__PURE__ */ new Set([
|
|
|
2876
2877
|
}), () => {
|
|
2877
2878
|
ke.detach();
|
|
2878
2879
|
};
|
|
2879
|
-
}, [w.audioElement]),
|
|
2880
|
+
}, [w.audioElement]), T(() => {
|
|
2880
2881
|
if (w.isControlled || w.connectionState !== "connected") return;
|
|
2881
2882
|
const g = w.getRoom();
|
|
2882
2883
|
if (g)
|
|
@@ -2884,23 +2885,23 @@ const Qr = /* @__PURE__ */ new Set([
|
|
|
2884
2885
|
}), () => {
|
|
2885
2886
|
G.teardownMic();
|
|
2886
2887
|
};
|
|
2887
|
-
}, [w.isControlled, w.connectionState]),
|
|
2888
|
+
}, [w.isControlled, w.connectionState]), T(() => {
|
|
2888
2889
|
var p;
|
|
2889
2890
|
if (w.connectionState !== "connected") return;
|
|
2890
|
-
const g = w.isControlled ? (p =
|
|
2891
|
+
const g = w.isControlled ? (p = z == null ? void 0 : z.getRoom) == null ? void 0 : p.call(z) : w.getRoom();
|
|
2891
2892
|
if (g)
|
|
2892
2893
|
return ne.attachRoom(g), Le.attachRoom(g), w.isControlled && G.attachRoom(g), Xe.refresh(), () => {
|
|
2893
2894
|
ne.teardown(), Le.teardown();
|
|
2894
2895
|
};
|
|
2895
|
-
}, [w.isControlled, w.connectionState,
|
|
2896
|
+
}, [w.isControlled, w.connectionState, z]), T(() => {
|
|
2896
2897
|
const g = w.audioElement;
|
|
2897
2898
|
g && (g.muted = He);
|
|
2898
2899
|
}, [w.audioElement, He]);
|
|
2899
2900
|
const vn = E((g) => {
|
|
2900
2901
|
const p = { type: "user_message", text: g };
|
|
2901
|
-
if (
|
|
2902
|
+
if (z != null && z.publishData) {
|
|
2902
2903
|
try {
|
|
2903
|
-
|
|
2904
|
+
z.publishData(p);
|
|
2904
2905
|
} catch {
|
|
2905
2906
|
}
|
|
2906
2907
|
return;
|
|
@@ -2912,38 +2913,38 @@ const Qr = /* @__PURE__ */ new Set([
|
|
|
2912
2913
|
Y.localParticipant.publishData(le, { reliable: !0 });
|
|
2913
2914
|
} catch {
|
|
2914
2915
|
}
|
|
2915
|
-
}, [w,
|
|
2916
|
+
}, [w, z]), bn = E(() => {
|
|
2916
2917
|
_t((g) => !g);
|
|
2917
2918
|
}, []);
|
|
2918
|
-
|
|
2919
|
+
T(() => {
|
|
2919
2920
|
$e == null || $e(w.connectionState), w.connectionState === "connected" ? De == null || De() : w.connectionState === "disconnected" && (Ae == null || Ae());
|
|
2920
|
-
}, [w.connectionState, De, Ae, $e]),
|
|
2921
|
+
}, [w.connectionState, De, Ae, $e]), T(() => {
|
|
2921
2922
|
Pe == null || Pe(w.transcript);
|
|
2922
|
-
}, [w.transcript, Pe]),
|
|
2923
|
+
}, [w.transcript, Pe]), T(() => {
|
|
2923
2924
|
Re == null || Re(w.agentState);
|
|
2924
|
-
}, [w.agentState, Re]),
|
|
2925
|
-
|
|
2926
|
-
}, [w.agentState,
|
|
2925
|
+
}, [w.agentState, Re]), T(() => {
|
|
2926
|
+
Me.setThinking(w.agentState === "thinking");
|
|
2927
|
+
}, [w.agentState, Me]);
|
|
2927
2928
|
const $t = A(!1);
|
|
2928
|
-
|
|
2929
|
+
T(() => {
|
|
2929
2930
|
w.isControlled || !_ || $t.current || _e && w.connectionState === "idle" && ($t.current = !0, w.connect());
|
|
2930
2931
|
}, [_, w.connectionState, w, _e]);
|
|
2931
2932
|
const wn = E(
|
|
2932
2933
|
(g) => {
|
|
2933
2934
|
const p = S == null ? void 0 : S.find((Y) => Y.id === g);
|
|
2934
|
-
p && (de(!1), g !== ce && (ut(!0), w.disconnect(), te || Je(g),
|
|
2935
|
+
p && (de(!1), g !== ce && (ut(!0), w.disconnect(), te || Je(g), D == null || D(p)));
|
|
2935
2936
|
},
|
|
2936
2937
|
[
|
|
2937
2938
|
S,
|
|
2938
2939
|
ce,
|
|
2939
2940
|
w,
|
|
2940
2941
|
te,
|
|
2941
|
-
|
|
2942
|
+
D
|
|
2942
2943
|
]
|
|
2943
2944
|
);
|
|
2944
|
-
|
|
2945
|
+
T(() => {
|
|
2945
2946
|
Oe && w.connectionState === "connected" && ut(!1);
|
|
2946
|
-
}, [w.connectionState, Oe]),
|
|
2947
|
+
}, [w.connectionState, Oe]), T(() => {
|
|
2947
2948
|
if (!Qe) return;
|
|
2948
2949
|
const g = (p) => {
|
|
2949
2950
|
p.key === "Escape" && de(!1);
|
|
@@ -2952,7 +2953,7 @@ const Qr = /* @__PURE__ */ new Set([
|
|
|
2952
2953
|
}, [Qe]);
|
|
2953
2954
|
const _n = !!B || !!(X != null && X.avatarImageUrl) || w.isControlled, et = Yn(Ke, l, _n);
|
|
2954
2955
|
Ge === void 0 && ((Ot = et.info) != null && Ot.capabilities) && (Et.current = et.info.capabilities);
|
|
2955
|
-
const pt = (X == null ? void 0 : X.name) ?? q ?? ((Ht = w.agentConfig) == null ? void 0 : Ht.name) ?? ((Wt = et.info) == null ? void 0 : Wt.name) ?? "Live Layer", Ct = (X == null ? void 0 : X.avatarImageUrl) ?? B ?? ((Bt = w.agentConfig) == null ? void 0 : Bt.avatarImageUrl) ?? ((qt = et.info) == null ? void 0 : qt.avatarImageUrl) ?? null, xn = x ?? ((Ft = w.agentConfig) == null ? void 0 : Ft.idleLoopUrl) ?? ((Ut = et.info) == null ? void 0 : Ut.idleLoopUrl) ?? null, kn =
|
|
2956
|
+
const pt = (X == null ? void 0 : X.name) ?? q ?? ((Ht = w.agentConfig) == null ? void 0 : Ht.name) ?? ((Wt = et.info) == null ? void 0 : Wt.name) ?? "Live Layer", Ct = (X == null ? void 0 : X.avatarImageUrl) ?? B ?? ((Bt = w.agentConfig) == null ? void 0 : Bt.avatarImageUrl) ?? ((qt = et.info) == null ? void 0 : qt.avatarImageUrl) ?? null, xn = x ?? ((Ft = w.agentConfig) == null ? void 0 : Ft.idleLoopUrl) ?? ((Ut = et.info) == null ? void 0 : Ut.idleLoopUrl) ?? null, kn = R ?? null, Ln = E(() => se("expanded"), [se]), En = E(
|
|
2956
2957
|
() => se("minimized"),
|
|
2957
2958
|
[se]
|
|
2958
2959
|
), zt = E(() => {
|
|
@@ -3095,18 +3096,18 @@ const ci = ({
|
|
|
3095
3096
|
const a = A(null), d = A(null), f = A(o);
|
|
3096
3097
|
f.current = o;
|
|
3097
3098
|
const _ = E((u) => {
|
|
3098
|
-
var
|
|
3099
|
+
var I;
|
|
3099
3100
|
const c = u.detail;
|
|
3100
|
-
(
|
|
3101
|
+
(I = f.current) == null || I.call(f, c);
|
|
3101
3102
|
}, []);
|
|
3102
|
-
return
|
|
3103
|
+
return T(() => {
|
|
3103
3104
|
const u = a.current;
|
|
3104
3105
|
if (!u) return;
|
|
3105
3106
|
const c = document.createElement("livelayer-widget");
|
|
3106
3107
|
return c.setAttribute("agent-id", e), t && c.setAttribute("base-url", t), r && c.setAttribute("api-key", r), i && c.setAttribute("mode", i), c.addEventListener("agent-event", _), u.appendChild(c), d.current = c, () => {
|
|
3107
3108
|
c.removeEventListener("agent-event", _), u.removeChild(c), d.current = null;
|
|
3108
3109
|
};
|
|
3109
|
-
}, [e]),
|
|
3110
|
+
}, [e]), T(() => {
|
|
3110
3111
|
d.current && (i ? d.current.setAttribute("mode", i) : d.current.removeAttribute("mode"));
|
|
3111
3112
|
}, [i]), /* @__PURE__ */ n("div", { ref: a, className: l, style: s });
|
|
3112
3113
|
}, si = lt(
|
|
@@ -3151,13 +3152,13 @@ const ci = ({
|
|
|
3151
3152
|
}
|
|
3152
3153
|
);
|
|
3153
3154
|
} else if ("as" in t && t.as === "select") {
|
|
3154
|
-
const { name: d, label: f, labelClassName: _, as: u, children: c, ...
|
|
3155
|
+
const { name: d, label: f, labelClassName: _, as: u, children: c, ...I } = t;
|
|
3155
3156
|
a = /* @__PURE__ */ n(
|
|
3156
3157
|
"select",
|
|
3157
3158
|
{
|
|
3158
3159
|
ref: r,
|
|
3159
3160
|
...s,
|
|
3160
|
-
...
|
|
3161
|
+
...I,
|
|
3161
3162
|
children: c
|
|
3162
3163
|
}
|
|
3163
3164
|
);
|
|
@@ -3184,26 +3185,26 @@ function fi({
|
|
|
3184
3185
|
defaultOpen: t = !1,
|
|
3185
3186
|
storageKey: r = "ll-debug-open"
|
|
3186
3187
|
}) {
|
|
3187
|
-
const [i, o] = C(t), [l, s] = C([]), [a, d] = C(""), [f, _] = C(!1), u = A(/* @__PURE__ */ new Set()), c = A([]),
|
|
3188
|
-
|
|
3188
|
+
const [i, o] = C(t), [l, s] = C([]), [a, d] = C(""), [f, _] = C(!1), u = A(/* @__PURE__ */ new Set()), c = A([]), I = A(f);
|
|
3189
|
+
I.current = f, T(() => {
|
|
3189
3190
|
try {
|
|
3190
3191
|
const y = localStorage.getItem(r);
|
|
3191
3192
|
y === "1" && o(!0), y === "0" && o(!1);
|
|
3192
3193
|
} catch {
|
|
3193
3194
|
}
|
|
3194
|
-
}, [r]),
|
|
3195
|
+
}, [r]), T(() => {
|
|
3195
3196
|
try {
|
|
3196
3197
|
localStorage.setItem(r, i ? "1" : "0");
|
|
3197
3198
|
} catch {
|
|
3198
3199
|
}
|
|
3199
|
-
}, [i, r]),
|
|
3200
|
+
}, [i, r]), T(() => {
|
|
3200
3201
|
const y = (m) => {
|
|
3201
3202
|
(m.metaKey || m.ctrlKey) && m.shiftKey && m.key.toLowerCase() === "l" && (m.preventDefault(), o((S) => !S));
|
|
3202
3203
|
};
|
|
3203
3204
|
return window.addEventListener("keydown", y), () => window.removeEventListener("keydown", y);
|
|
3204
|
-
}, []),
|
|
3205
|
+
}, []), T(() => {
|
|
3205
3206
|
const y = setInterval(() => {
|
|
3206
|
-
if (c.current.length === 0 ||
|
|
3207
|
+
if (c.current.length === 0 || I.current) return;
|
|
3207
3208
|
const m = c.current.splice(0, c.current.length);
|
|
3208
3209
|
s(
|
|
3209
3210
|
(S) => [...m.reverse(), ...S].slice(0, 200)
|
|
@@ -3212,7 +3213,7 @@ function fi({
|
|
|
3212
3213
|
return () => clearInterval(y);
|
|
3213
3214
|
}, []);
|
|
3214
3215
|
const L = A(!1);
|
|
3215
|
-
if (
|
|
3216
|
+
if (T(() => {
|
|
3216
3217
|
!e || L.current || (L.current = !0, e((y) => {
|
|
3217
3218
|
c.current.push({
|
|
3218
3219
|
id: sn++,
|
|
@@ -3222,20 +3223,20 @@ function fi({
|
|
|
3222
3223
|
data: y.data
|
|
3223
3224
|
});
|
|
3224
3225
|
}));
|
|
3225
|
-
}, [e]),
|
|
3226
|
-
const y = console.warn, m = console.log, S = (D
|
|
3226
|
+
}, [e]), T(() => {
|
|
3227
|
+
const y = console.warn, m = console.log, S = ($, D) => function(...x) {
|
|
3227
3228
|
try {
|
|
3228
|
-
const
|
|
3229
|
-
|
|
3229
|
+
const R = typeof x[0] == "string" ? x[0] : "";
|
|
3230
|
+
R.startsWith("[LiveLayer]") && c.current.push({
|
|
3230
3231
|
id: sn++,
|
|
3231
3232
|
ts: Date.now(),
|
|
3232
|
-
kind:
|
|
3233
|
-
type:
|
|
3233
|
+
kind: $,
|
|
3234
|
+
type: R.slice(0, 120),
|
|
3234
3235
|
data: { args: x.slice(1).map((B) => ti(B)) }
|
|
3235
3236
|
});
|
|
3236
3237
|
} catch {
|
|
3237
3238
|
}
|
|
3238
|
-
return
|
|
3239
|
+
return D.apply(this, x);
|
|
3239
3240
|
};
|
|
3240
3241
|
return console.warn = S("warn", y), console.log = S("log", m), () => {
|
|
3241
3242
|
console.warn = y, console.log = m;
|