@streamoji/avatar-widget 0.3.4 → 0.3.5
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/avatar-widget.cjs +4 -4
- package/dist/avatar-widget.js +277 -274
- package/dist/avatar-widget.umd.js +155 -155
- package/dist/avatar-widget.umd.js.map +1 -1
- package/package.json +1 -1
package/dist/avatar-widget.js
CHANGED
|
@@ -1,38 +1,38 @@
|
|
|
1
1
|
import { jsx as l, jsxs as ae } from "react/jsx-runtime";
|
|
2
|
-
import { useGLTF as lt, Environment as
|
|
3
|
-
import { useFrame as
|
|
4
|
-
import { memo as
|
|
2
|
+
import { useGLTF as lt, Environment as Kt } from "@react-three/drei";
|
|
3
|
+
import { useFrame as Xt, Canvas as Zt, useThree as en } from "@react-three/fiber";
|
|
4
|
+
import { memo as tn, useMemo as ft, useRef as a, useState as b, useEffect as H, useCallback as Ke, useLayoutEffect as nn, Suspense as rn } from "react";
|
|
5
5
|
import * as He from "three";
|
|
6
|
-
import { GLTFLoader as
|
|
7
|
-
const ut = "https://ai.streamoji.com", $ = (...
|
|
8
|
-
},
|
|
9
|
-
}, Et = ({ analyser:
|
|
10
|
-
const L = a(null),
|
|
6
|
+
import { GLTFLoader as sn } from "three/examples/jsm/loaders/GLTFLoader.js";
|
|
7
|
+
const ut = "https://ai.streamoji.com", $ = (...d) => {
|
|
8
|
+
}, on = (...d) => {
|
|
9
|
+
}, Et = ({ analyser: d }) => {
|
|
10
|
+
const L = a(null), _ = a(null);
|
|
11
11
|
return H(() => {
|
|
12
12
|
const p = L.current;
|
|
13
13
|
if (!p) return;
|
|
14
|
-
const
|
|
15
|
-
if (!
|
|
14
|
+
const w = p.getContext("2d", { alpha: !0 });
|
|
15
|
+
if (!w) return;
|
|
16
16
|
let D, j = null;
|
|
17
|
-
|
|
17
|
+
d && (d.fftSize = 128, j = new Uint8Array(d.frequencyBinCount));
|
|
18
18
|
const fe = () => {
|
|
19
19
|
D = requestAnimationFrame(fe), (p.width !== p.offsetWidth || p.height !== p.offsetHeight) && (p.width = p.offsetWidth, p.height = p.offsetHeight);
|
|
20
20
|
const K = p.width, N = p.height;
|
|
21
21
|
if (K === 0 || N === 0) return;
|
|
22
22
|
const he = N / 2;
|
|
23
|
-
|
|
24
|
-
const E = 2,
|
|
25
|
-
(!
|
|
26
|
-
const me = U *
|
|
27
|
-
|
|
23
|
+
w.clearRect(0, 0, K, N), w.fillStyle = "#1e293b";
|
|
24
|
+
const E = 2, x = E + 2, R = K * 0.95, U = Math.floor(R / x);
|
|
25
|
+
(!_.current || _.current.length !== U) && (_.current = new Float32Array(U).fill(2));
|
|
26
|
+
const me = U * x, S = (K - me) / 2;
|
|
27
|
+
d && j && d.getByteFrequencyData(j);
|
|
28
28
|
const Ie = j ? j.length : 0, Y = Math.floor(Ie * 0.7) / U, be = new Float32Array(U);
|
|
29
29
|
for (let B = 0; B < U; B++) {
|
|
30
30
|
let J = 0;
|
|
31
31
|
if (j && Y > 0) {
|
|
32
32
|
const P = Math.floor(B * Y), _e = Math.floor((B + 1) * Y);
|
|
33
33
|
for (let M = P; M < _e; M++) {
|
|
34
|
-
const
|
|
35
|
-
|
|
34
|
+
const k = j[M] || 0;
|
|
35
|
+
k > J && (J = k);
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
J < 10 && (J = 0);
|
|
@@ -40,61 +40,61 @@ const ut = "https://ai.streamoji.com", $ = (...f) => {
|
|
|
40
40
|
be[B] = I;
|
|
41
41
|
}
|
|
42
42
|
for (let B = 0; B < U; B++) {
|
|
43
|
-
const J = U - 1 - B, z = Math.max(be[B], be[J]), I =
|
|
44
|
-
|
|
45
|
-
const P =
|
|
46
|
-
|
|
43
|
+
const J = U - 1 - B, z = Math.max(be[B], be[J]), I = _.current[B] + (z - _.current[B]) * 0.3;
|
|
44
|
+
_.current[B] = I;
|
|
45
|
+
const P = S + B * x, _e = he - I / 2;
|
|
46
|
+
w.beginPath(), w.roundRect ? w.roundRect(P, _e, E, I, 4) : w.fillRect(P, _e, E, I), w.fill();
|
|
47
47
|
}
|
|
48
48
|
};
|
|
49
49
|
return fe(), () => {
|
|
50
50
|
cancelAnimationFrame(D);
|
|
51
51
|
};
|
|
52
|
-
}, [
|
|
52
|
+
}, [d]), /* @__PURE__ */ l(
|
|
53
53
|
"canvas",
|
|
54
54
|
{
|
|
55
55
|
ref: L,
|
|
56
56
|
style: { width: "100%", height: "100%", display: "block" }
|
|
57
57
|
}
|
|
58
58
|
);
|
|
59
|
-
},
|
|
60
|
-
async function
|
|
59
|
+
}, an = "https://pub-48df6f7d60d6440bbd01676ea5d90e55.r2.dev", It = "https://pub-be53cae7bd99457a8c1f11b4d38f1672.r2.dev/default-models/avatar-blue-suit.glb";
|
|
60
|
+
async function cn(d) {
|
|
61
61
|
const L = await crypto.subtle.digest(
|
|
62
62
|
"SHA-256",
|
|
63
|
-
new TextEncoder().encode(
|
|
63
|
+
new TextEncoder().encode(d)
|
|
64
64
|
);
|
|
65
|
-
return Array.from(new Uint8Array(L)).map((
|
|
65
|
+
return Array.from(new Uint8Array(L)).map((_) => _.toString(16).padStart(2, "0")).join("");
|
|
66
66
|
}
|
|
67
|
-
function
|
|
68
|
-
const [L,
|
|
67
|
+
function ln(d) {
|
|
68
|
+
const [L, _] = b(null);
|
|
69
69
|
return H(() => {
|
|
70
|
-
if (!
|
|
71
|
-
|
|
70
|
+
if (!d) {
|
|
71
|
+
_(null);
|
|
72
72
|
return;
|
|
73
73
|
}
|
|
74
74
|
let p = !1;
|
|
75
|
-
return
|
|
75
|
+
return cn(d).then((w) => {
|
|
76
76
|
if (p) return;
|
|
77
|
-
const D = `${
|
|
77
|
+
const D = `${an}/${w}.glb`;
|
|
78
78
|
fetch(D, { method: "HEAD" }).then((j) => {
|
|
79
|
-
p ||
|
|
79
|
+
p || _(j.ok ? D : It);
|
|
80
80
|
}).catch(() => {
|
|
81
|
-
p ||
|
|
81
|
+
p || _(It);
|
|
82
82
|
});
|
|
83
83
|
}), () => {
|
|
84
84
|
p = !0;
|
|
85
85
|
};
|
|
86
|
-
}, [
|
|
86
|
+
}, [d]), L;
|
|
87
87
|
}
|
|
88
|
-
const
|
|
88
|
+
const un = [
|
|
89
89
|
"https://pub-be53cae7bd99457a8c1f11b4d38f1672.r2.dev/masculine/idle/M_Standing_Idle_Variations_001.glb",
|
|
90
90
|
"https://pub-be53cae7bd99457a8c1f11b4d38f1672.r2.dev/masculine/idle/M_Standing_Idle_Variations_002.glb",
|
|
91
91
|
"https://pub-be53cae7bd99457a8c1f11b4d38f1672.r2.dev/masculine/idle/M_Standing_Idle_002.glb",
|
|
92
92
|
"https://pub-be53cae7bd99457a8c1f11b4d38f1672.r2.dev/masculine/idle/M_Standing_Idle_Variations_005.glb"
|
|
93
|
-
],
|
|
93
|
+
], dn = [
|
|
94
94
|
"https://pub-be53cae7bd99457a8c1f11b4d38f1672.r2.dev/masculine/idle/F_Standing_Idle_Variations_001.glb",
|
|
95
95
|
"https://pub-be53cae7bd99457a8c1f11b4d38f1672.r2.dev/masculine/idle/F_Standing_Idle_Variations_003.glb",
|
|
96
96
|
"https://pub-be53cae7bd99457a8c1f11b4d38f1672.r2.dev/masculine/idle/F_Standing_Idle_Variations_003.glb"
|
|
97
|
-
],
|
|
97
|
+
], fn = [
|
|
98
98
|
{
|
|
99
99
|
id: "m_expr_01",
|
|
100
100
|
name: "Friendly Wave",
|
|
@@ -260,23 +260,23 @@ const cn = [
|
|
|
260
260
|
name: "Take It Easy",
|
|
261
261
|
url: "https://pub-be53cae7bd99457a8c1f11b4d38f1672.r2.dev/masculine/expression/F_Talking_Variations_006.glb"
|
|
262
262
|
}
|
|
263
|
-
],
|
|
263
|
+
], hn = [
|
|
264
264
|
"https://pub-be53cae7bd99457a8c1f11b4d38f1672.r2.dev/masculine/expression/M_Talking_Variations_005.glb",
|
|
265
265
|
"https://pub-be53cae7bd99457a8c1f11b4d38f1672.r2.dev/masculine/expression/M_Talking_Variations_007.glb",
|
|
266
266
|
"https://pub-be53cae7bd99457a8c1f11b4d38f1672.r2.dev/masculine/expression/M_Talking_Variations_006.glb"
|
|
267
|
-
],
|
|
268
|
-
"https://pub-be53cae7bd99457a8c1f11b4d38f1672.r2.dev/masculine/expression/
|
|
269
|
-
"https://pub-be53cae7bd99457a8c1f11b4d38f1672.r2.dev/masculine/expression/
|
|
270
|
-
"https://pub-be53cae7bd99457a8c1f11b4d38f1672.r2.dev/masculine/expression/
|
|
267
|
+
], mn = [
|
|
268
|
+
"https://pub-be53cae7bd99457a8c1f11b4d38f1672.r2.dev/masculine/expression/F_Talking_Variations_004.glb",
|
|
269
|
+
"https://pub-be53cae7bd99457a8c1f11b4d38f1672.r2.dev/masculine/expression/F_Talking_Variations_005.glb",
|
|
270
|
+
"https://pub-be53cae7bd99457a8c1f11b4d38f1672.r2.dev/masculine/expression/F_Talking_Variations_006.glb",
|
|
271
271
|
"https://pub-be53cae7bd99457a8c1f11b4d38f1672.r2.dev/masculine/expression/F_Talking_Variations_002.glb"
|
|
272
|
-
],
|
|
272
|
+
], pn = {
|
|
273
273
|
zoom: 0.85,
|
|
274
274
|
position: [0.15, -0.8, 0],
|
|
275
275
|
scale: 1.5,
|
|
276
276
|
rotation: [0.15, 0.02, 0]
|
|
277
|
-
},
|
|
277
|
+
}, gn = [-0.45, 1.9, 0.1], bn = {
|
|
278
278
|
browInnerUp: 0.2
|
|
279
|
-
}, dt = 0.18,
|
|
279
|
+
}, dt = 0.18, _n = 1, Mt = "__branding__", Xe = {
|
|
280
280
|
neutral: { eyeLookDownLeft: 0.1, eyeLookDownRight: 0.1 },
|
|
281
281
|
happy: {
|
|
282
282
|
mouthSmileLeft: 0.2,
|
|
@@ -358,7 +358,7 @@ const cn = [
|
|
|
358
358
|
mouthUpperUpLeft: 0.1,
|
|
359
359
|
mouthUpperUpRight: 0.1
|
|
360
360
|
}
|
|
361
|
-
},
|
|
361
|
+
}, wn = [
|
|
362
362
|
{ key: "viseme_aa", mix: { jawOpen: 0.6 } },
|
|
363
363
|
{
|
|
364
364
|
key: "viseme_E",
|
|
@@ -454,7 +454,7 @@ const cn = [
|
|
|
454
454
|
}
|
|
455
455
|
},
|
|
456
456
|
{ key: "viseme_sil", mix: {} }
|
|
457
|
-
],
|
|
457
|
+
], vn = {
|
|
458
458
|
aei: [
|
|
459
459
|
{ v: "E", w: 0.8 },
|
|
460
460
|
{ v: "I", w: 0.2 }
|
|
@@ -483,39 +483,39 @@ const cn = [
|
|
|
483
483
|
],
|
|
484
484
|
sil: [{ v: "sil", w: 1 }]
|
|
485
485
|
};
|
|
486
|
-
function
|
|
487
|
-
if (!
|
|
488
|
-
const L =
|
|
489
|
-
return
|
|
486
|
+
function yn(d) {
|
|
487
|
+
if (!d) return [{ v: "sil", w: 1 }];
|
|
488
|
+
const L = d.toLowerCase();
|
|
489
|
+
return vn[L] ?? [{ v: "sil", w: 1 }];
|
|
490
490
|
}
|
|
491
|
-
function
|
|
492
|
-
const { camera: L } =
|
|
491
|
+
function Sn({ target: d }) {
|
|
492
|
+
const { camera: L } = en();
|
|
493
493
|
return H(() => {
|
|
494
|
-
L.lookAt(...
|
|
495
|
-
}, [L,
|
|
494
|
+
L.lookAt(...d);
|
|
495
|
+
}, [L, d]), null;
|
|
496
496
|
}
|
|
497
|
-
function Q(
|
|
498
|
-
if (!
|
|
497
|
+
function Q(d, L, _) {
|
|
498
|
+
if (!d || !d.morphTargetDictionary)
|
|
499
499
|
return;
|
|
500
|
-
const p =
|
|
500
|
+
const p = d, w = p.morphTargetDictionary, D = p.morphTargetInfluences;
|
|
501
501
|
if (D)
|
|
502
|
-
for (const j in
|
|
503
|
-
j.toLowerCase() === L.toLowerCase() && (D[
|
|
502
|
+
for (const j in w)
|
|
503
|
+
j.toLowerCase() === L.toLowerCase() && (D[w[j]] = _);
|
|
504
504
|
}
|
|
505
|
-
function Ct(
|
|
506
|
-
if (!
|
|
507
|
-
const
|
|
508
|
-
if (
|
|
509
|
-
for (let p = 0; p <
|
|
510
|
-
|
|
505
|
+
function Ct(d, L = 0.97) {
|
|
506
|
+
if (!d) return;
|
|
507
|
+
const _ = d;
|
|
508
|
+
if (_.morphTargetInfluences)
|
|
509
|
+
for (let p = 0; p < _.morphTargetInfluences.length; p++)
|
|
510
|
+
_.morphTargetInfluences[p] *= L;
|
|
511
511
|
}
|
|
512
|
-
const
|
|
512
|
+
const xn = tn(
|
|
513
513
|
({
|
|
514
|
-
avatarUrl:
|
|
514
|
+
avatarUrl: d,
|
|
515
515
|
isPlayingRef: L,
|
|
516
|
-
visemeQueueRef:
|
|
516
|
+
visemeQueueRef: _,
|
|
517
517
|
audioContextRef: p,
|
|
518
|
-
responseAudioStartTimeRef:
|
|
518
|
+
responseAudioStartTimeRef: w,
|
|
519
519
|
adjustments: D,
|
|
520
520
|
mood: j,
|
|
521
521
|
expression: fe,
|
|
@@ -523,51 +523,51 @@ const yn = Zt(
|
|
|
523
523
|
isSpeaking: N,
|
|
524
524
|
nextStartTimeRef: he,
|
|
525
525
|
stopPlayback: E,
|
|
526
|
-
setIsSpeaking:
|
|
527
|
-
expressionUrl:
|
|
526
|
+
setIsSpeaking: y,
|
|
527
|
+
expressionUrl: x,
|
|
528
528
|
onExpressionFinished: R,
|
|
529
529
|
isNudgeResponse: U,
|
|
530
530
|
avatarGender: me
|
|
531
531
|
}) => {
|
|
532
|
-
const { scene:
|
|
533
|
-
() => Ue.flatMap((
|
|
532
|
+
const { scene: S } = lt(d), Ue = lt(me === "female" ? dn : un), Y = ft(
|
|
533
|
+
() => Ue.flatMap((f) => f.animations),
|
|
534
534
|
[Ue]
|
|
535
|
-
), B = lt(me === "female" ?
|
|
536
|
-
() => B.flatMap((
|
|
535
|
+
), B = lt(me === "female" ? mn : hn), J = ft(
|
|
536
|
+
() => B.flatMap((f) => f.animations),
|
|
537
537
|
[B]
|
|
538
|
-
), z = a(null), I = a(null), P = a(null), _e = a([]), [M] =
|
|
538
|
+
), z = a(null), I = a(null), P = a(null), _e = a([]), [M] = b(() => new He.AnimationMixer(S)), k = a({}), C = a(null), we = a(0), Me = a(!1), ve = a(0), ce = a(null);
|
|
539
539
|
H(() => {
|
|
540
|
-
if (!(!Y || !
|
|
541
|
-
if (Y.forEach((
|
|
540
|
+
if (!(!Y || !S)) {
|
|
541
|
+
if (Y.forEach((f, u) => {
|
|
542
542
|
const i = `idle_${u}`;
|
|
543
|
-
if (!
|
|
544
|
-
const s = M.clipAction(
|
|
545
|
-
s.name = i, s.setLoop(He.LoopOnce, 1), s.clampWhenFinished = !0,
|
|
543
|
+
if (!k.current[i]) {
|
|
544
|
+
const s = M.clipAction(f, S);
|
|
545
|
+
s.name = i, s.setLoop(He.LoopOnce, 1), s.clampWhenFinished = !0, k.current[i] = s;
|
|
546
546
|
}
|
|
547
|
-
}), J.forEach((
|
|
547
|
+
}), J.forEach((f, u) => {
|
|
548
548
|
const i = `talk_${u}`;
|
|
549
|
-
if (!
|
|
550
|
-
const s = M.clipAction(
|
|
551
|
-
s.name = i, s.setLoop(He.LoopOnce, 1), s.clampWhenFinished = !0,
|
|
549
|
+
if (!k.current[i]) {
|
|
550
|
+
const s = M.clipAction(f, S);
|
|
551
|
+
s.name = i, s.setLoop(He.LoopOnce, 1), s.clampWhenFinished = !0, k.current[i] = s;
|
|
552
552
|
}
|
|
553
553
|
}), Y.length > 0) {
|
|
554
|
-
const
|
|
555
|
-
|
|
554
|
+
const f = k.current.idle_0, u = C.current && M.existingAction(C.current.getClip());
|
|
555
|
+
f && !u && (f.reset().fadeIn(0.5).play(), C.current = f);
|
|
556
556
|
}
|
|
557
557
|
return () => {
|
|
558
|
-
M.stopAllAction(),
|
|
558
|
+
M.stopAllAction(), k.current = {}, C.current = null;
|
|
559
559
|
};
|
|
560
560
|
}
|
|
561
|
-
}, [Y, J,
|
|
561
|
+
}, [Y, J, S, M]);
|
|
562
562
|
const ye = a("");
|
|
563
563
|
H(() => {
|
|
564
|
-
if (!
|
|
565
|
-
ye.current =
|
|
566
|
-
|
|
564
|
+
if (!x || !S || x === ye.current) return;
|
|
565
|
+
ye.current = x, ce.current = x, new sn().load(
|
|
566
|
+
x,
|
|
567
567
|
(u) => {
|
|
568
568
|
if (u.animations && u.animations.length > 0) {
|
|
569
|
-
const i = u.animations[0], s = M.clipAction(i,
|
|
570
|
-
if (s.name = `EXPR_${
|
|
569
|
+
const i = u.animations[0], s = M.clipAction(i, S);
|
|
570
|
+
if (s.name = `EXPR_${x}`, s.setLoop(He.LoopOnce, 1), s.clampWhenFinished = !0, k.current[`EXPR_${x}`] = s, N && ce.current === x) {
|
|
571
571
|
const h = C.current;
|
|
572
572
|
s.reset().fadeIn(0.3).play(), h && h !== s && h.crossFadeTo(s, 0.3, !0), C.current = s, ce.current = null;
|
|
573
573
|
}
|
|
@@ -575,36 +575,36 @@ const yn = Zt(
|
|
|
575
575
|
},
|
|
576
576
|
void 0,
|
|
577
577
|
(u) => {
|
|
578
|
-
console.error(`[ANIMATION] Failed to load ${
|
|
578
|
+
console.error(`[ANIMATION] Failed to load ${x}`, u);
|
|
579
579
|
}
|
|
580
580
|
);
|
|
581
|
-
}, [
|
|
582
|
-
const
|
|
581
|
+
}, [x, S, M, N]), H(() => {
|
|
582
|
+
const f = (u) => {
|
|
583
583
|
const i = u.action, s = i.name || "";
|
|
584
584
|
if (s.startsWith("idle_")) {
|
|
585
|
-
const W = (parseInt(s.split("_")[1]) + 1) % Y.length, X =
|
|
585
|
+
const W = (parseInt(s.split("_")[1]) + 1) % Y.length, X = k.current[`idle_${W}`];
|
|
586
586
|
X && (X.reset().fadeIn(0.5).play(), i.crossFadeTo(X, 0.5, !0), C.current = X);
|
|
587
587
|
} else if (s.startsWith("EXPR_")) {
|
|
588
588
|
if (N) {
|
|
589
589
|
const h = Math.floor(
|
|
590
590
|
Math.random() * J.length
|
|
591
|
-
), W =
|
|
591
|
+
), W = k.current[`talk_${h}`];
|
|
592
592
|
W && (W.reset().fadeIn(0.5).play(), i.crossFadeTo(W, 0.5, !0), C.current = W);
|
|
593
593
|
} else {
|
|
594
|
-
const h =
|
|
594
|
+
const h = k.current.idle_0;
|
|
595
595
|
h && (h.reset().fadeIn(0.5).play(), i.crossFadeTo(h, 0.5, !0), C.current = h);
|
|
596
596
|
}
|
|
597
597
|
R && R();
|
|
598
598
|
} else if (s.startsWith("talk_"))
|
|
599
599
|
if (N && !U) {
|
|
600
|
-
const W = (parseInt(s.split("_")[1]) + 1) % J.length, X =
|
|
600
|
+
const W = (parseInt(s.split("_")[1]) + 1) % J.length, X = k.current[`talk_${W}`];
|
|
601
601
|
X && (X.reset().fadeIn(0.3).play(), i.crossFadeTo(X, 0.3, !0), C.current = X);
|
|
602
602
|
} else {
|
|
603
|
-
const h =
|
|
603
|
+
const h = k.current.idle_0;
|
|
604
604
|
h && (h.reset().fadeIn(0.5).play(), i.crossFadeTo(h, 0.5, !0), C.current = h);
|
|
605
605
|
}
|
|
606
606
|
};
|
|
607
|
-
return M.addEventListener("finished",
|
|
607
|
+
return M.addEventListener("finished", f), () => M.removeEventListener("finished", f);
|
|
608
608
|
}, [
|
|
609
609
|
M,
|
|
610
610
|
Y,
|
|
@@ -613,71 +613,71 @@ const yn = Zt(
|
|
|
613
613
|
U,
|
|
614
614
|
R
|
|
615
615
|
]), H(() => {
|
|
616
|
-
if (N &&
|
|
617
|
-
const
|
|
616
|
+
if (N && S) {
|
|
617
|
+
const f = C.current, u = f?.name || "";
|
|
618
618
|
if (u.startsWith("idle_") || u.startsWith("talk_") || u === "") {
|
|
619
619
|
const i = ce.current;
|
|
620
620
|
if (i) {
|
|
621
|
-
const s =
|
|
621
|
+
const s = k.current[`EXPR_${i}`];
|
|
622
622
|
if (s) {
|
|
623
|
-
s.reset().fadeIn(0.3).play(),
|
|
623
|
+
s.reset().fadeIn(0.3).play(), f && f !== s && f.crossFadeTo(s, 0.3, !0), C.current = s, ce.current = null;
|
|
624
624
|
return;
|
|
625
625
|
}
|
|
626
626
|
}
|
|
627
627
|
if (u.startsWith("idle_") || u === "") {
|
|
628
628
|
const s = Math.floor(
|
|
629
629
|
Math.random() * J.length
|
|
630
|
-
), h =
|
|
631
|
-
h && (h.reset().fadeIn(0.5).play(),
|
|
630
|
+
), h = k.current[`talk_${s}`];
|
|
631
|
+
h && (h.reset().fadeIn(0.5).play(), f && f.crossFadeTo(h, 0.5, !0), C.current = h);
|
|
632
632
|
}
|
|
633
633
|
}
|
|
634
|
-
} else if (!N &&
|
|
635
|
-
const
|
|
634
|
+
} else if (!N && S) {
|
|
635
|
+
const f = C.current, u = f?.name || "";
|
|
636
636
|
if (u.startsWith("talk_") || u.startsWith("EXPR_")) {
|
|
637
|
-
const i =
|
|
638
|
-
i && (i.reset().fadeIn(0.5).play(),
|
|
637
|
+
const i = k.current.idle_0;
|
|
638
|
+
i && (i.reset().fadeIn(0.5).play(), f && f.crossFadeTo(i, 0.5, !0), C.current = i);
|
|
639
639
|
}
|
|
640
640
|
}
|
|
641
|
-
}, [N,
|
|
642
|
-
if (!
|
|
643
|
-
|
|
641
|
+
}, [N, S, x]), H(() => {
|
|
642
|
+
if (!S) return;
|
|
643
|
+
S.traverse((i) => {
|
|
644
644
|
if (i.isMesh && i.morphTargetDictionary) {
|
|
645
645
|
const s = i.name.toLowerCase();
|
|
646
646
|
(s.includes("head") || s.includes("avatar")) && (I.current = i, $(`[ANIMATION] Found head mesh: ${i.name}`)), s.includes("teeth") && (P.current = i, $(`[ANIMATION] Found teeth mesh: ${i.name}`));
|
|
647
647
|
}
|
|
648
648
|
});
|
|
649
|
-
const
|
|
650
|
-
|
|
649
|
+
const f = I.current?.morphTargetDictionary;
|
|
650
|
+
f && Object.keys(f).filter(
|
|
651
651
|
(i) => i.toLowerCase().includes("brow")
|
|
652
652
|
);
|
|
653
653
|
const u = [];
|
|
654
|
-
|
|
654
|
+
S.traverse((i) => {
|
|
655
655
|
if (i.isMesh) {
|
|
656
656
|
const h = i.morphTargetDictionary;
|
|
657
657
|
h && Object.keys(h).some((W) => W.toLowerCase().includes("brow")) && u.push(i);
|
|
658
658
|
}
|
|
659
659
|
}), _e.current = u, u.length > 0 && $("[ANIMATION] Meshes with brow morphs:", u.length);
|
|
660
|
-
}, [
|
|
661
|
-
const Be = (
|
|
662
|
-
const i = `viseme_${
|
|
660
|
+
}, [S]);
|
|
661
|
+
const Be = (f, u = 1) => {
|
|
662
|
+
const i = `viseme_${f}`.toLowerCase(), s = wn.find((h) => h.key.toLowerCase() === i);
|
|
663
663
|
if (s)
|
|
664
664
|
for (const h in s.mix) {
|
|
665
665
|
const W = s.mix[h] * u;
|
|
666
666
|
Q(I.current, h, W), Q(P.current, h, W);
|
|
667
667
|
}
|
|
668
|
-
}, ke = (
|
|
669
|
-
const u = Xe[
|
|
668
|
+
}, ke = (f) => {
|
|
669
|
+
const u = Xe[f] ?? Xe.neutral;
|
|
670
670
|
for (const i in u)
|
|
671
671
|
Q(I.current, i, u[i]), Q(P.current, i, u[i]);
|
|
672
672
|
};
|
|
673
|
-
return
|
|
673
|
+
return Xt((f, u) => {
|
|
674
674
|
const i = Math.pow(0.88, 60 * u);
|
|
675
675
|
Ct(I.current, i), Ct(P.current, i), ke(j);
|
|
676
|
-
const s =
|
|
676
|
+
const s = f.clock.elapsedTime;
|
|
677
677
|
let h = 0;
|
|
678
678
|
if (Math.floor(s) % 5 === 0 && Math.floor((s - u) % 5) !== 0) {
|
|
679
679
|
let q = null;
|
|
680
|
-
|
|
680
|
+
S.traverse((Z) => {
|
|
681
681
|
Z.name.toLowerCase().includes("hips") && (q = Z);
|
|
682
682
|
});
|
|
683
683
|
const Se = q ? `Hips Y: ${q.position.y.toFixed(4)}` : "Hips not found";
|
|
@@ -691,10 +691,10 @@ const yn = Zt(
|
|
|
691
691
|
we.current = s + Z;
|
|
692
692
|
} else {
|
|
693
693
|
const Z = Se < 0.5 ? Se * 2 : (1 - Se) * 2;
|
|
694
|
-
Q(I.current, "eyeBlinkLeft", Z), Q(I.current, "eyeBlinkRight", Z), Q(P.current, "eyeBlinkLeft", Z), Q(P.current, "eyeBlinkRight", Z), h = Z *
|
|
694
|
+
Q(I.current, "eyeBlinkLeft", Z), Q(I.current, "eyeBlinkRight", Z), Q(P.current, "eyeBlinkLeft", Z), Q(P.current, "eyeBlinkRight", Z), h = Z * bn.browInnerUp;
|
|
695
695
|
}
|
|
696
696
|
}
|
|
697
|
-
const W = Xe[j] ?? Xe.neutral, X = W.browInnerUp ?? 0, Ze = W.browOuterUpLeft ?? 0, je = W.browOuterUpRight ?? 0, Pe = s *
|
|
697
|
+
const W = Xe[j] ?? Xe.neutral, X = W.browInnerUp ?? 0, Ze = W.browOuterUpLeft ?? 0, je = W.browOuterUpRight ?? 0, Pe = s * _n, Ae = dt * Math.sin(Pe), te = dt * 0.7 * Math.sin(Pe + 0.7), Je = dt * 0.7 * Math.sin(Pe + 1.3), re = (q) => Math.max(0, Math.min(1, q)), Te = re(X + Ae), Le = re(Ze + te), We = re(je + Je), Ce = re(Te + h);
|
|
698
698
|
if (Q(I.current, "browInnerUp", Ce), Q(P.current, "browInnerUp", Ce), Q(I.current, "browOuterUpLeft", Le), Q(P.current, "browOuterUpLeft", Le), Q(I.current, "browOuterUpRight", We), Q(P.current, "browOuterUpRight", We), z.current) {
|
|
699
699
|
const q = L.current ? 0 : D.rotation[1];
|
|
700
700
|
z.current.rotation.y = He.MathUtils.lerp(
|
|
@@ -704,44 +704,47 @@ const yn = Zt(
|
|
|
704
704
|
), z.current.position.set(...D.position), z.current.scale.setScalar(D.scale), z.current.rotation.x = D.rotation[0], z.current.rotation.z = D.rotation[2];
|
|
705
705
|
}
|
|
706
706
|
if (L.current && p.current) {
|
|
707
|
-
const q = p.current.currentTime, Oe = (q -
|
|
708
|
-
for (let ne = 0; ne <
|
|
709
|
-
const ie =
|
|
707
|
+
const q = p.current.currentTime, Oe = (q - w.current) * 1e3 - -150;
|
|
708
|
+
for (let ne = 0; ne < _.current.length; ne++) {
|
|
709
|
+
const ie = _.current[ne];
|
|
710
710
|
Oe >= ie.vtime && Oe < ie.vtime + ie.vduration && Be(ie.viseme, ie.weight ?? 1);
|
|
711
711
|
}
|
|
712
|
-
q > he.current + 0.5 && (E(),
|
|
712
|
+
q > he.current + 0.5 && (E(), y(!1));
|
|
713
713
|
}
|
|
714
|
-
}), /* @__PURE__ */ l("group", { ref: z, children: /* @__PURE__ */ l("primitive", { object:
|
|
714
|
+
}), /* @__PURE__ */ l("group", { ref: z, children: /* @__PURE__ */ l("primitive", { object: S }) });
|
|
715
715
|
}
|
|
716
716
|
);
|
|
717
|
-
function
|
|
718
|
-
return
|
|
717
|
+
function kn(d) {
|
|
718
|
+
return d ? d.charAt(0).toUpperCase() + d.slice(1).toLowerCase() : "";
|
|
719
719
|
}
|
|
720
|
-
|
|
721
|
-
|
|
720
|
+
function Ot(d) {
|
|
721
|
+
return d.replace(/\*(.*?)\*/g, " $1 ").replace(/\[.*?\]/g, " ").replace(/<.*?\/>/g, " ").replace(/<.*?>.*?<\/.*?>/g, " ").replace(/\s+/g, " ").trim();
|
|
722
|
+
}
|
|
723
|
+
const An = ({
|
|
724
|
+
token: d,
|
|
722
725
|
agentToken: L,
|
|
723
|
-
onNavigationRequested:
|
|
726
|
+
onNavigationRequested: _,
|
|
724
727
|
avatarGender: p,
|
|
725
|
-
presetUserDetails:
|
|
728
|
+
presetUserDetails: w
|
|
726
729
|
} = {}) => {
|
|
727
|
-
const D =
|
|
730
|
+
const D = d ?? L ?? "", j = ln(D || void 0), [fe, K] = b(""), [N, he] = b(""), [E, y] = b("Ready"), [x, R] = b(!1), [U, me] = b(!1), [S, Ie] = b([]), [Ue, Y] = b(""), be = a(null), [B, J] = b(
|
|
728
731
|
() => typeof window < "u" ? window.matchMedia("(max-width: 480px)").matches : !1
|
|
729
732
|
);
|
|
730
733
|
H(() => {
|
|
731
734
|
const e = window.matchMedia("(max-width: 480px)"), t = () => J(e.matches);
|
|
732
735
|
return e.addEventListener("change", t), () => e.removeEventListener("change", t);
|
|
733
736
|
}, []);
|
|
734
|
-
const z = B ? 80 : 600, I = a(!1), P = a([]), _e = a(0), M = a(!1),
|
|
737
|
+
const z = B ? 80 : 600, I = a(!1), P = a([]), _e = a(0), M = a(!1), k = a([]), C = a(null), we = a([]);
|
|
735
738
|
a([]);
|
|
736
|
-
const Me = a([]), ve = a(0), ce = a(0), ye = a(0), Be = a(0), ke = a(!1), [
|
|
739
|
+
const Me = a([]), ve = a(0), ce = a(0), ye = a(0), Be = a(0), ke = a(!1), [f, u] = b(
|
|
737
740
|
null
|
|
738
|
-
), i = a(null), [s, h] =
|
|
741
|
+
), i = a(null), [s, h] = b("neutral"), [W, X] = b(""), [Ze, je] = b(""), [Pe, Ae] = b("Chat with us"), [te, Je] = b(
|
|
739
742
|
null
|
|
740
|
-
), [re, Te] =
|
|
743
|
+
), [re, Te] = b("hidden"), [Le, We] = b(""), Ce = a(null), q = a(re);
|
|
741
744
|
q.current = re;
|
|
742
|
-
const [Se, Z] =
|
|
745
|
+
const [Se, Z] = b(null), Oe = a(null), ne = a(null), [ie, ht] = b(!1), mt = a(null), [le, qe] = b("hidden"), [pt, Dt] = b(""), et = a(le);
|
|
743
746
|
et.current = le;
|
|
744
|
-
const pe = a(""), De = a(!1), Ne = a(""), gt = a(Date.now()), tt = a([]), Ve = a(!1), [nt, $e] =
|
|
747
|
+
const pe = a(""), De = a(!1), Ne = a(""), gt = a(Date.now()), tt = a([]), Ve = a(!1), [nt, $e] = b(!1), [bt, _t] = b(!1), xe = a(null), Fe = ft(() => ie ? "Try again" : E === "Busy" ? "Busy" : E === "Thinking..." || E === "Processing Voice..." ? E : te != null && te !== "" && te !== "none" && te !== "<none>" ? `Enter ${kn(te)}` : le !== "hidden" || !bt ? null : Mt, [E, te, ie, le, bt]), wt = !ie && E !== "Busy" && E !== "Thinking..." && E !== "Processing Voice..." && (te == null || te === "" || te === "none" || te === "<none>");
|
|
745
748
|
H(() => {
|
|
746
749
|
if (le !== "hidden" || !wt) {
|
|
747
750
|
_t(!1), xe.current != null && (clearTimeout(xe.current), xe.current = null);
|
|
@@ -774,7 +777,7 @@ const xn = ({
|
|
|
774
777
|
return;
|
|
775
778
|
}
|
|
776
779
|
return ne.current = setTimeout(() => {
|
|
777
|
-
ne.current = null,
|
|
780
|
+
ne.current = null, y("Ready"), ht(!0);
|
|
778
781
|
}, 12e3), () => {
|
|
779
782
|
ne.current != null && (clearTimeout(ne.current), ne.current = null);
|
|
780
783
|
};
|
|
@@ -783,14 +786,14 @@ const xn = ({
|
|
|
783
786
|
const e = setTimeout(() => ht(!1), 2500);
|
|
784
787
|
return () => clearTimeout(e);
|
|
785
788
|
}, [ie]);
|
|
786
|
-
const
|
|
789
|
+
const Nt = Ke(() => {
|
|
787
790
|
const e = q.current;
|
|
788
791
|
if (e === "exiting") {
|
|
789
792
|
Te("hidden");
|
|
790
793
|
const t = Ce.current;
|
|
791
794
|
Ce.current = null, t != null && t !== "" && (We(t), Te("entering"));
|
|
792
795
|
} else e === "entering" && Te("visible");
|
|
793
|
-
}, []),
|
|
796
|
+
}, []), Ft = (e) => {
|
|
794
797
|
if (!e) return;
|
|
795
798
|
if (e.mood != null) {
|
|
796
799
|
const n = String(e.mood).toLowerCase();
|
|
@@ -799,7 +802,7 @@ const xn = ({
|
|
|
799
802
|
if (e.expression != null) {
|
|
800
803
|
const n = String(e.expression).trim();
|
|
801
804
|
X(n);
|
|
802
|
-
const c =
|
|
805
|
+
const c = fn.find(
|
|
803
806
|
(m) => m.name.toLowerCase() === n.toLowerCase()
|
|
804
807
|
);
|
|
805
808
|
$(
|
|
@@ -808,17 +811,17 @@ const xn = ({
|
|
|
808
811
|
}
|
|
809
812
|
if (e.navigation != null) {
|
|
810
813
|
const n = String(e.navigation).trim();
|
|
811
|
-
n !== "" && (
|
|
814
|
+
n !== "" && (_ ? _(n) : window.open(n, "_blank"));
|
|
812
815
|
}
|
|
813
816
|
const t = e.ask_for || e.lead_capture?.ask_for, r = t ? String(t).trim().toLowerCase() : "", o = r === "none" || r === "<none>";
|
|
814
817
|
if (t && !o) {
|
|
815
818
|
const n = r;
|
|
816
|
-
if (
|
|
819
|
+
if (w && (n === "email" && w.email || n === "name" && w.name || n === "phone" && w.phone))
|
|
817
820
|
return;
|
|
818
821
|
Je(n || null), Ae(n === "email" ? "Enter your email" : n === "name" ? "Enter your name" : n === "phone" ? "Enter your phone number" : "Chat with us");
|
|
819
822
|
} else (o || e.ask_for === null || e.lead_capture && e.lead_capture.ask_for === null || e.ask_for === "none") && (Je(null), Pe !== "Chat with us" && Ae("Chat with us"));
|
|
820
823
|
e.collected, e.valid;
|
|
821
|
-
},
|
|
824
|
+
}, Ut = (e) => {
|
|
822
825
|
const t = e.trim();
|
|
823
826
|
if (!t) return null;
|
|
824
827
|
if (t.startsWith("{"))
|
|
@@ -832,7 +835,7 @@ const xn = ({
|
|
|
832
835
|
return { [o]: n };
|
|
833
836
|
}
|
|
834
837
|
return null;
|
|
835
|
-
},
|
|
838
|
+
}, Bt = Ke(() => {
|
|
836
839
|
}, []), vt = (e) => {
|
|
837
840
|
if (De.current)
|
|
838
841
|
e === "§" ? De.current = !1 : (Ne.current += e, he((t) => t + e));
|
|
@@ -845,8 +848,8 @@ const xn = ({
|
|
|
845
848
|
const t = pe.current.indexOf(`
|
|
846
849
|
`), r = pe.current.slice(0, t).trim();
|
|
847
850
|
pe.current = pe.current.slice(t + 1);
|
|
848
|
-
const o =
|
|
849
|
-
o &&
|
|
851
|
+
const o = Ut(r);
|
|
852
|
+
o && Ft(o);
|
|
850
853
|
}
|
|
851
854
|
};
|
|
852
855
|
H(() => {
|
|
@@ -856,22 +859,22 @@ const xn = ({
|
|
|
856
859
|
)) {
|
|
857
860
|
const n = "secret", c = Math.floor(Date.now() / 1e3).toString();
|
|
858
861
|
try {
|
|
859
|
-
const m = new TextEncoder(),
|
|
862
|
+
const m = new TextEncoder(), g = await crypto.subtle.importKey(
|
|
860
863
|
"raw",
|
|
861
864
|
m.encode(n),
|
|
862
865
|
{ name: "HMAC", hash: "SHA-256" },
|
|
863
866
|
!1,
|
|
864
867
|
["sign"]
|
|
865
|
-
),
|
|
868
|
+
), v = await crypto.subtle.sign(
|
|
866
869
|
"HMAC",
|
|
867
|
-
|
|
870
|
+
g,
|
|
868
871
|
m.encode(c)
|
|
869
|
-
), T = Array.from(new Uint8Array(
|
|
872
|
+
), T = Array.from(new Uint8Array(v)).map((V) => V.toString(16).padStart(2, "0")).join("");
|
|
870
873
|
sessionStorage.setItem("STREAMOJI_LEADS_SESSION_LEAD_ID", T), $("[SESSION] New HMAC UID generated and saved:", T);
|
|
871
874
|
} catch (m) {
|
|
872
875
|
console.error("[SESSION] HMAC generation failed:", m);
|
|
873
|
-
const
|
|
874
|
-
sessionStorage.setItem("STREAMOJI_LEADS_SESSION_LEAD_ID",
|
|
876
|
+
const g = Math.random().toString(36) + Date.now().toString();
|
|
877
|
+
sessionStorage.setItem("STREAMOJI_LEADS_SESSION_LEAD_ID", g);
|
|
875
878
|
}
|
|
876
879
|
}
|
|
877
880
|
const r = sessionStorage.getItem("STREAMOJI_LEADS_SESSION_MESSAGES");
|
|
@@ -882,7 +885,7 @@ const xn = ({
|
|
|
882
885
|
} catch {
|
|
883
886
|
o = [];
|
|
884
887
|
}
|
|
885
|
-
o.length === 0 &&
|
|
888
|
+
o.length === 0 && w && (w.name || w.email) ? (o = [{ role: "user", content: `PRESET_USER_DETAILS: Name is "${w.name || ""}" , Email is "${w.email || ""}"` }], sessionStorage.setItem(
|
|
886
889
|
"STREAMOJI_LEADS_SESSION_MESSAGES",
|
|
887
890
|
JSON.stringify(o)
|
|
888
891
|
)) : r || sessionStorage.setItem(
|
|
@@ -890,13 +893,13 @@ const xn = ({
|
|
|
890
893
|
JSON.stringify([])
|
|
891
894
|
);
|
|
892
895
|
})();
|
|
893
|
-
}, [
|
|
896
|
+
}, [w]), H(() => {
|
|
894
897
|
const e = () => {
|
|
895
898
|
gt.current = Date.now(), Ve.current && (Ve.current = !1, $e(!1), Ie([]), Y(""), he(""), me(!1));
|
|
896
899
|
};
|
|
897
900
|
window.addEventListener("mousemove", e), window.addEventListener("keydown", e), window.addEventListener("mousedown", e), window.addEventListener("touchstart", e);
|
|
898
901
|
const t = setInterval(async () => {
|
|
899
|
-
if (Date.now() - gt.current >= 3e4 && !U && !
|
|
902
|
+
if (Date.now() - gt.current >= 3e4 && !U && !x && E === "Ready" && !Ve.current)
|
|
900
903
|
if (Ve.current = !0, tt.current.length > 0)
|
|
901
904
|
$e(!0), Ie(tt.current);
|
|
902
905
|
else
|
|
@@ -912,8 +915,8 @@ const xn = ({
|
|
|
912
915
|
body: JSON.stringify(c)
|
|
913
916
|
});
|
|
914
917
|
if (m.ok) {
|
|
915
|
-
const
|
|
916
|
-
|
|
918
|
+
const v = (await m.json()).nudge_questions;
|
|
919
|
+
v && v.length > 0 && ($("[NUDGE] Received nudge questions from API:", v), tt.current = v, $e(!0), Ie(v));
|
|
917
920
|
}
|
|
918
921
|
} catch (n) {
|
|
919
922
|
console.error("[NUDGE] Error calling /nudgeUser:", n), Ve.current = !1;
|
|
@@ -922,11 +925,11 @@ const xn = ({
|
|
|
922
925
|
return () => {
|
|
923
926
|
window.removeEventListener("mousemove", e), window.removeEventListener("keydown", e), window.removeEventListener("mousedown", e), window.removeEventListener("touchstart", e), clearInterval(t);
|
|
924
927
|
};
|
|
925
|
-
}, [D, U,
|
|
926
|
-
if (
|
|
928
|
+
}, [D, U, x, E]), H(() => {
|
|
929
|
+
if (S.length === 0) return;
|
|
927
930
|
let e = 0, t = 0, r = !1, o = 100;
|
|
928
931
|
const n = () => {
|
|
929
|
-
const c =
|
|
932
|
+
const c = S[e];
|
|
930
933
|
if (r) {
|
|
931
934
|
const m = c.substring(0, t - 1);
|
|
932
935
|
Y(m), t--, o = 50;
|
|
@@ -934,12 +937,12 @@ const xn = ({
|
|
|
934
937
|
const m = c.substring(0, t + 1);
|
|
935
938
|
Y(m), t++, o = 100;
|
|
936
939
|
}
|
|
937
|
-
!r && t === c.length ? (r = !0, o = 3e3) : r && t === 0 && (r = !1, e = (e + 1) %
|
|
940
|
+
!r && t === c.length ? (r = !0, o = 3e3) : r && t === 0 && (r = !1, e = (e + 1) % S.length, o = 500), be.current = setTimeout(n, o);
|
|
938
941
|
};
|
|
939
942
|
return n(), () => {
|
|
940
943
|
be.current && clearTimeout(be.current);
|
|
941
944
|
};
|
|
942
|
-
}, [
|
|
945
|
+
}, [S]);
|
|
943
946
|
const yt = () => {
|
|
944
947
|
try {
|
|
945
948
|
return JSON.parse(
|
|
@@ -948,25 +951,25 @@ const xn = ({
|
|
|
948
951
|
} catch {
|
|
949
952
|
return [];
|
|
950
953
|
}
|
|
951
|
-
},
|
|
954
|
+
}, Pt = (e) => {
|
|
952
955
|
sessionStorage.setItem(
|
|
953
956
|
"STREAMOJI_LEADS_SESSION_MESSAGES",
|
|
954
957
|
JSON.stringify(e)
|
|
955
958
|
);
|
|
956
|
-
}, [rt, it] =
|
|
959
|
+
}, [rt, it] = b(!1), [St, st] = b(0), ue = a(null), ze = a([]), xt = a(0), [kt, Wt] = b(
|
|
957
960
|
null
|
|
958
|
-
), [
|
|
961
|
+
), [Vt, ot] = b(
|
|
959
962
|
null
|
|
960
963
|
), ge = a(null), Re = a(
|
|
961
964
|
null
|
|
962
965
|
), Ye = Ke((e = !1) => {
|
|
963
|
-
e && (ke.current = !0, R(!1),
|
|
966
|
+
e && (ke.current = !0, R(!1), y("Ready")), k.current = [], P.current = [], M.current = !1, me(!1), ve.current = 0, ce.current = 0, ye.current = 0, we.current.forEach((t) => {
|
|
964
967
|
try {
|
|
965
968
|
t.stop();
|
|
966
969
|
} catch {
|
|
967
970
|
}
|
|
968
971
|
}), Oe.current && (clearTimeout(Oe.current), Oe.current = null), Z(null), je(""), we.current = [];
|
|
969
|
-
}, []),
|
|
972
|
+
}, []), $t = async () => {
|
|
970
973
|
try {
|
|
971
974
|
const e = await navigator.mediaDevices.getUserMedia({ audio: !0 }), t = window.AudioContext || window.webkitAudioContext, r = new t(), o = r.createMediaStreamSource(e), n = r.createAnalyser();
|
|
972
975
|
n.fftSize = 64, o.connect(n), ge.current = r, Re.current = o, ot(n);
|
|
@@ -976,21 +979,21 @@ const xn = ({
|
|
|
976
979
|
}, c.onstop = async () => {
|
|
977
980
|
const m = Date.now() - xt.current;
|
|
978
981
|
if (ot(null), Re.current && (Re.current.disconnect(), Re.current = null), ge.current && ge.current.state !== "closed" && (ge.current.close(), ge.current = null), m < 1e3) {
|
|
979
|
-
|
|
982
|
+
y("Recording too short. Hold or click longer."), R(!1);
|
|
980
983
|
return;
|
|
981
984
|
}
|
|
982
|
-
const
|
|
985
|
+
const g = new Blob(ze.current, {
|
|
983
986
|
type: "audio/wav"
|
|
984
987
|
});
|
|
985
|
-
await
|
|
986
|
-
}, xt.current = Date.now(), c.start(100), it(!0),
|
|
988
|
+
await qt(g);
|
|
989
|
+
}, xt.current = Date.now(), c.start(100), it(!0), y("Listening...");
|
|
987
990
|
} catch (e) {
|
|
988
|
-
console.error("Error accessing microphone:", e),
|
|
991
|
+
console.error("Error accessing microphone:", e), y("Mic Access Error");
|
|
989
992
|
}
|
|
990
|
-
}, $t = () => {
|
|
991
|
-
ue.current && ue.current.state !== "inactive" && (ue.current.stop(), ue.current.stream.getTracks().forEach((e) => e.stop()), it(!1));
|
|
992
993
|
}, Ht = () => {
|
|
993
|
-
ue.current && ue.current.state !== "inactive" && (ue.current.
|
|
994
|
+
ue.current && ue.current.state !== "inactive" && (ue.current.stop(), ue.current.stream.getTracks().forEach((e) => e.stop()), it(!1));
|
|
995
|
+
}, jt = () => {
|
|
996
|
+
ue.current && ue.current.state !== "inactive" && (ue.current.onstop = null, ue.current.stop(), ue.current.stream.getTracks().forEach((e) => e.stop()), ot(null), Re.current && (Re.current.disconnect(), Re.current = null), ge.current && ge.current.state !== "closed" && (ge.current.close(), ge.current = null), it(!1), ze.current = [], y("Ready"));
|
|
994
997
|
};
|
|
995
998
|
H(() => {
|
|
996
999
|
if (!U) return;
|
|
@@ -999,13 +1002,13 @@ const xn = ({
|
|
|
999
1002
|
if (t <= 0) return;
|
|
1000
1003
|
const r = C.current, o = ve.current;
|
|
1001
1004
|
if (!r) return;
|
|
1002
|
-
const n = r.currentTime - o, c = Math.min(Math.max(0, n), t),
|
|
1003
|
-
if (
|
|
1004
|
-
const
|
|
1005
|
-
Math.round(c / t *
|
|
1006
|
-
|
|
1005
|
+
const n = r.currentTime - o, c = Math.min(Math.max(0, n), t), g = Ot(N).trim().length;
|
|
1006
|
+
if (g <= 0) return;
|
|
1007
|
+
const v = Math.min(
|
|
1008
|
+
Math.round(c / t * g),
|
|
1009
|
+
g
|
|
1007
1010
|
);
|
|
1008
|
-
u(
|
|
1011
|
+
u(v);
|
|
1009
1012
|
};
|
|
1010
1013
|
return clearInterval(i.current ?? void 0), i.current = setInterval(e, 90), () => clearInterval(i.current ?? void 0);
|
|
1011
1014
|
}, [U, N, ye.current]), H(() => {
|
|
@@ -1014,21 +1017,21 @@ const xn = ({
|
|
|
1014
1017
|
st((t) => t + 1);
|
|
1015
1018
|
}, 1e3)) : st(0), () => clearInterval(e);
|
|
1016
1019
|
}, [rt]);
|
|
1017
|
-
const
|
|
1020
|
+
const Jt = (e) => {
|
|
1018
1021
|
const t = e.numberOfChannels, r = e.length * t * 2 + 44, o = new ArrayBuffer(r), n = new DataView(o);
|
|
1019
1022
|
let c = 0;
|
|
1020
1023
|
const m = (T) => {
|
|
1021
1024
|
n.setUint16(c, T, !0), c += 2;
|
|
1022
|
-
},
|
|
1025
|
+
}, g = (T) => {
|
|
1023
1026
|
n.setUint32(c, T, !0), c += 4;
|
|
1024
1027
|
};
|
|
1025
|
-
|
|
1026
|
-
const
|
|
1027
|
-
for (let T = 0; T < t; T++)
|
|
1028
|
+
g(1179011410), g(r - 8), g(1163280727), g(544501094), g(16), m(1), m(t), g(e.sampleRate), g(e.sampleRate * 2 * t), m(t * 2), m(16), g(1635017060), g(r - c - 4);
|
|
1029
|
+
const v = [];
|
|
1030
|
+
for (let T = 0; T < t; T++) v.push(e.getChannelData(T));
|
|
1028
1031
|
let A = 0;
|
|
1029
1032
|
for (; c < r; ) {
|
|
1030
1033
|
for (let T = 0; T < t; T++) {
|
|
1031
|
-
let V = Math.max(-1, Math.min(1,
|
|
1034
|
+
let V = Math.max(-1, Math.min(1, v[T][A]));
|
|
1032
1035
|
V = V < 0 ? V * 32768 : V * 32767, n.setInt16(c, V, !0), c += 2;
|
|
1033
1036
|
}
|
|
1034
1037
|
A++;
|
|
@@ -1051,16 +1054,16 @@ const xn = ({
|
|
|
1051
1054
|
const c = window.atob(e), m = new Uint8Array(c.length);
|
|
1052
1055
|
for (let F = 0; F < c.length; F++)
|
|
1053
1056
|
m[F] = c.charCodeAt(F);
|
|
1054
|
-
const
|
|
1055
|
-
ye.current +=
|
|
1056
|
-
const
|
|
1057
|
+
const g = await n.decodeAudioData(m.buffer.slice(0));
|
|
1058
|
+
ye.current += g.duration;
|
|
1059
|
+
const v = n.currentTime;
|
|
1057
1060
|
let A = ce.current;
|
|
1058
1061
|
const T = !M.current;
|
|
1059
|
-
A <
|
|
1062
|
+
A < v && (A = v + 0.1), ce.current = A + g.duration;
|
|
1060
1063
|
const V = n.createBufferSource();
|
|
1061
|
-
V.buffer =
|
|
1064
|
+
V.buffer = g;
|
|
1062
1065
|
let G = kt;
|
|
1063
|
-
if ((!G || G.context !== n) && (G = n.createAnalyser(), G.fftSize = 64, G.connect(n.destination),
|
|
1066
|
+
if ((!G || G.context !== n) && (G = n.createAnalyser(), G.fftSize = 64, G.connect(n.destination), Wt(G)), V.connect(G), we.current.push(V), ke.current) {
|
|
1064
1067
|
we.current = we.current.filter((F) => F !== V);
|
|
1065
1068
|
return;
|
|
1066
1069
|
}
|
|
@@ -1070,11 +1073,11 @@ const xn = ({
|
|
|
1070
1073
|
3
|
|
1071
1074
|
)}`
|
|
1072
1075
|
), ve.current = A;
|
|
1073
|
-
const F = (A -
|
|
1076
|
+
const F = (A - v) * 1e3;
|
|
1074
1077
|
_e.current = performance.now() + F, $(
|
|
1075
1078
|
`[AUDIO] Response started. Initial startTime: ${A.toFixed(
|
|
1076
1079
|
3
|
|
1077
|
-
)}, CT: ${
|
|
1080
|
+
)}, CT: ${v.toFixed(3)}`
|
|
1078
1081
|
);
|
|
1079
1082
|
}
|
|
1080
1083
|
V.start(A);
|
|
@@ -1086,13 +1089,13 @@ const xn = ({
|
|
|
1086
1089
|
)), t.forEach((F, se) => {
|
|
1087
1090
|
const O = F.symbol ?? "";
|
|
1088
1091
|
if (O) {
|
|
1089
|
-
const oe =
|
|
1092
|
+
const oe = yn(O), de = Math.round(F.start * 1e3), Ee = Math.round((F.duration ?? 0) * 1e3), Lt = Be.current + de;
|
|
1090
1093
|
se < 3 && $(
|
|
1091
1094
|
`[AUDIO] Viseme "${O}": segment_relative=${de}ms, segment_offset=${Be.current.toFixed(
|
|
1092
1095
|
0
|
|
1093
1096
|
)}ms => vtime=${Lt}ms`
|
|
1094
1097
|
), oe.forEach((Rt) => {
|
|
1095
|
-
|
|
1098
|
+
k.current.push({
|
|
1096
1099
|
viseme: Rt.v,
|
|
1097
1100
|
weight: Rt.w,
|
|
1098
1101
|
vtime: Lt,
|
|
@@ -1100,7 +1103,7 @@ const xn = ({
|
|
|
1100
1103
|
});
|
|
1101
1104
|
});
|
|
1102
1105
|
}
|
|
1103
|
-
}),
|
|
1106
|
+
}), y("Speaking...");
|
|
1104
1107
|
} finally {
|
|
1105
1108
|
if (I.current = !1, P.current.length > 0) {
|
|
1106
1109
|
const o = P.current.shift();
|
|
@@ -1108,16 +1111,16 @@ const xn = ({
|
|
|
1108
1111
|
}
|
|
1109
1112
|
}
|
|
1110
1113
|
}
|
|
1111
|
-
},
|
|
1114
|
+
}, qt = async (e) => {
|
|
1112
1115
|
try {
|
|
1113
|
-
R(!0), $e(!1), Ne.current = "", he(""),
|
|
1114
|
-
const t = await e.arrayBuffer(), o = await new (window.AudioContext || window.webkitAudioContext)().decodeAudioData(t), n =
|
|
1116
|
+
R(!0), $e(!1), Ne.current = "", he(""), y("Processing Voice...");
|
|
1117
|
+
const t = await e.arrayBuffer(), o = await new (window.AudioContext || window.webkitAudioContext)().decodeAudioData(t), n = Jt(o), c = new FileReader();
|
|
1115
1118
|
c.readAsDataURL(n), c.onloadend = async () => {
|
|
1116
1119
|
const m = c.result.split(",")[1];
|
|
1117
1120
|
Ye(), K(""), pe.current = "", De.current = !1;
|
|
1118
|
-
const
|
|
1121
|
+
const g = `${ut}/stt?token=${encodeURIComponent(
|
|
1119
1122
|
D
|
|
1120
|
-
)}`,
|
|
1123
|
+
)}`, v = await fetch(g, {
|
|
1121
1124
|
method: "POST",
|
|
1122
1125
|
headers: { "Content-Type": "application/json" },
|
|
1123
1126
|
body: JSON.stringify({
|
|
@@ -1125,17 +1128,17 @@ const xn = ({
|
|
|
1125
1128
|
audio_format: "wav"
|
|
1126
1129
|
})
|
|
1127
1130
|
});
|
|
1128
|
-
if (
|
|
1131
|
+
if (v.status === 429) {
|
|
1129
1132
|
try {
|
|
1130
|
-
const se = await
|
|
1133
|
+
const se = await v.text(), O = JSON.parse(se);
|
|
1131
1134
|
$("[STT] 429 agent at capacity:", O?.detail);
|
|
1132
1135
|
} catch {
|
|
1133
1136
|
}
|
|
1134
|
-
K(""),
|
|
1137
|
+
K(""), y("Busy"), R(!1);
|
|
1135
1138
|
return;
|
|
1136
1139
|
}
|
|
1137
|
-
if (!
|
|
1138
|
-
const se = await
|
|
1140
|
+
if (!v.ok) {
|
|
1141
|
+
const se = await v.text();
|
|
1139
1142
|
let O = "STT Failed";
|
|
1140
1143
|
try {
|
|
1141
1144
|
O = JSON.parse(se).error || O;
|
|
@@ -1144,9 +1147,9 @@ const xn = ({
|
|
|
1144
1147
|
}
|
|
1145
1148
|
throw new Error(O);
|
|
1146
1149
|
}
|
|
1147
|
-
const A =
|
|
1150
|
+
const A = v.body;
|
|
1148
1151
|
if ($("this is body" + A), !A) {
|
|
1149
|
-
|
|
1152
|
+
y("STT Failed"), R(!1);
|
|
1150
1153
|
return;
|
|
1151
1154
|
}
|
|
1152
1155
|
const T = A.getReader();
|
|
@@ -1169,11 +1172,11 @@ const xn = ({
|
|
|
1169
1172
|
break;
|
|
1170
1173
|
}
|
|
1171
1174
|
case "done": {
|
|
1172
|
-
ee = !0,
|
|
1175
|
+
ee = !0, y("Ready"), R(!1);
|
|
1173
1176
|
break;
|
|
1174
1177
|
}
|
|
1175
1178
|
case "error": {
|
|
1176
|
-
ee = !0,
|
|
1179
|
+
ee = !0, y("STT Failed"), R(!1);
|
|
1177
1180
|
break;
|
|
1178
1181
|
}
|
|
1179
1182
|
default:
|
|
@@ -1196,16 +1199,16 @@ const xn = ({
|
|
|
1196
1199
|
const de = Qe(G.trim());
|
|
1197
1200
|
de && await F(de.event, de.data);
|
|
1198
1201
|
}
|
|
1199
|
-
ee || (
|
|
1202
|
+
ee || (y("Ready"), R(!1));
|
|
1200
1203
|
break;
|
|
1201
1204
|
}
|
|
1202
1205
|
}
|
|
1203
1206
|
};
|
|
1204
1207
|
} catch (t) {
|
|
1205
|
-
console.error("Audio Submission Error:", t),
|
|
1208
|
+
console.error("Audio Submission Error:", t), y("STT Failed"), R(!1);
|
|
1206
1209
|
}
|
|
1207
|
-
},
|
|
1208
|
-
e && e.preventDefault(), $e(!1), Ne.current = "", he(""), !(!fe ||
|
|
1210
|
+
}, Gt = async (e) => {
|
|
1211
|
+
e && e.preventDefault(), $e(!1), Ne.current = "", he(""), !(!fe || x) && await zt(fe);
|
|
1209
1212
|
}, Qe = (e) => {
|
|
1210
1213
|
const t = e.split(/\r?\n/);
|
|
1211
1214
|
let r = "", o = "";
|
|
@@ -1241,24 +1244,24 @@ const xn = ({
|
|
|
1241
1244
|
{ role: "user", content: fe || "..." },
|
|
1242
1245
|
{ role: "assistant", content: o }
|
|
1243
1246
|
];
|
|
1244
|
-
|
|
1247
|
+
Pt(n), Me.current = [...k.current], y("Ready"), R(!1), K("");
|
|
1245
1248
|
break;
|
|
1246
1249
|
}
|
|
1247
1250
|
case "error": {
|
|
1248
1251
|
const r = t.message ?? "Unknown error";
|
|
1249
|
-
Ne.current = r, he(r),
|
|
1252
|
+
Ne.current = r, he(r), y("Agent Failed"), R(!1);
|
|
1250
1253
|
break;
|
|
1251
1254
|
}
|
|
1252
1255
|
}
|
|
1253
|
-
},
|
|
1254
|
-
R(!0),
|
|
1256
|
+
}, zt = async (e) => {
|
|
1257
|
+
R(!0), y("Thinking..."), Ne.current = "", pe.current = "", De.current = !1, Ye(), ye.current = 0, u(0);
|
|
1255
1258
|
const t = `${ut}/agent/chat?token=${encodeURIComponent(
|
|
1256
1259
|
D
|
|
1257
1260
|
)}`;
|
|
1258
1261
|
try {
|
|
1259
1262
|
const r = yt();
|
|
1260
1263
|
let o = sessionStorage.getItem("STREAMOJI_LEADS_SESSION_LEAD_ID");
|
|
1261
|
-
o || (
|
|
1264
|
+
o || (on(
|
|
1262
1265
|
"[CHAT] Session UID missing at send time! Generating emergency backup."
|
|
1263
1266
|
), o = "emergency-" + Math.random().toString(36).substring(7), sessionStorage.setItem("STREAMOJI_LEADS_SESSION_LEAD_ID", o));
|
|
1264
1267
|
const n = {
|
|
@@ -1281,25 +1284,25 @@ const xn = ({
|
|
|
1281
1284
|
$("[CHAT] 429 agent at capacity:", T?.detail);
|
|
1282
1285
|
} catch {
|
|
1283
1286
|
}
|
|
1284
|
-
K(""),
|
|
1287
|
+
K(""), y("Busy"), R(!1);
|
|
1285
1288
|
return;
|
|
1286
1289
|
}
|
|
1287
1290
|
if (!c.ok)
|
|
1288
1291
|
throw new Error("Agent request failed");
|
|
1289
1292
|
const m = c.body;
|
|
1290
1293
|
if (!m) {
|
|
1291
|
-
|
|
1294
|
+
y("Agent Failed"), R(!1);
|
|
1292
1295
|
return;
|
|
1293
1296
|
}
|
|
1294
|
-
const
|
|
1297
|
+
const g = m.getReader();
|
|
1295
1298
|
ke.current = !1;
|
|
1296
|
-
const
|
|
1299
|
+
const v = new TextDecoder();
|
|
1297
1300
|
let A = "";
|
|
1298
1301
|
for (; ; ) {
|
|
1299
|
-
const { done: T, value: V } = await
|
|
1302
|
+
const { done: T, value: V } = await g.read();
|
|
1300
1303
|
$(
|
|
1301
1304
|
`[SSE] Chunk received. done=${T}, length=${V?.length || 0}`
|
|
1302
|
-
), V && (A +=
|
|
1305
|
+
), V && (A += v.decode(V, { stream: !0 }));
|
|
1303
1306
|
const G = A.split(`
|
|
1304
1307
|
|
|
1305
1308
|
`);
|
|
@@ -1314,26 +1317,26 @@ const xn = ({
|
|
|
1314
1317
|
const ee = Qe(A.trim());
|
|
1315
1318
|
ee && At(ee.event, ee.data);
|
|
1316
1319
|
}
|
|
1317
|
-
|
|
1320
|
+
y("Ready"), R(!1), K("");
|
|
1318
1321
|
break;
|
|
1319
1322
|
}
|
|
1320
1323
|
}
|
|
1321
1324
|
} catch (r) {
|
|
1322
|
-
console.error("Chat Error:", r),
|
|
1325
|
+
console.error("Chat Error:", r), y("Agent Failed"), R(!1);
|
|
1323
1326
|
}
|
|
1324
|
-
},
|
|
1327
|
+
}, Yt = N.trim(), Tt = Ot(Yt), ct = Tt && U ? Tt.slice(
|
|
1325
1328
|
0,
|
|
1326
|
-
|
|
1329
|
+
f != null && f > 0 ? f : 0
|
|
1327
1330
|
) : "";
|
|
1328
1331
|
H(() => {
|
|
1329
1332
|
const e = et.current;
|
|
1330
|
-
e !== "exiting" && (ct ? (
|
|
1333
|
+
e !== "exiting" && (ct ? (Dt(ct), e === "hidden" && qe("entering")) : (e === "visible" || e === "entering") && qe("exiting"));
|
|
1331
1334
|
}, [ct, le]);
|
|
1332
|
-
const
|
|
1335
|
+
const Qt = Ke(() => {
|
|
1333
1336
|
const e = et.current;
|
|
1334
1337
|
e === "entering" ? qe("visible") : e === "exiting" && qe("hidden");
|
|
1335
1338
|
}, []);
|
|
1336
|
-
return
|
|
1339
|
+
return nn(() => {
|
|
1337
1340
|
const e = mt.current;
|
|
1338
1341
|
e && (e.scrollTop = e.scrollHeight);
|
|
1339
1342
|
}, [pt]), /* @__PURE__ */ ae("div", { className: "avatar-widget-container", children: [
|
|
@@ -1342,7 +1345,7 @@ const xn = ({
|
|
|
1342
1345
|
"div",
|
|
1343
1346
|
{
|
|
1344
1347
|
className: `avatar-thinking-tab${re === "exiting" ? " avatar-thinking-tab--exiting" : re === "entering" ? " avatar-thinking-tab--entering" : ""}`,
|
|
1345
|
-
onAnimationEnd:
|
|
1348
|
+
onAnimationEnd: Nt,
|
|
1346
1349
|
children: Le === Mt ? /* @__PURE__ */ l(
|
|
1347
1350
|
"a",
|
|
1348
1351
|
{
|
|
@@ -1369,7 +1372,7 @@ const xn = ({
|
|
|
1369
1372
|
{
|
|
1370
1373
|
type: "button",
|
|
1371
1374
|
className: "avatar-recording-cancel",
|
|
1372
|
-
onClick:
|
|
1375
|
+
onClick: jt,
|
|
1373
1376
|
title: "Cancel",
|
|
1374
1377
|
children: /* @__PURE__ */ ae(
|
|
1375
1378
|
"svg",
|
|
@@ -1403,7 +1406,7 @@ const xn = ({
|
|
|
1403
1406
|
minWidth: 0
|
|
1404
1407
|
},
|
|
1405
1408
|
children: [
|
|
1406
|
-
/* @__PURE__ */ l("div", { style: { flex: 1, height: "100%" }, children: /* @__PURE__ */ l(Et, { analyser:
|
|
1409
|
+
/* @__PURE__ */ l("div", { style: { flex: 1, height: "100%" }, children: /* @__PURE__ */ l(Et, { analyser: Vt }) }),
|
|
1407
1410
|
/* @__PURE__ */ ae(
|
|
1408
1411
|
"span",
|
|
1409
1412
|
{
|
|
@@ -1431,7 +1434,7 @@ const xn = ({
|
|
|
1431
1434
|
{
|
|
1432
1435
|
type: "button",
|
|
1433
1436
|
className: "avatar-recording-confirm",
|
|
1434
|
-
onClick:
|
|
1437
|
+
onClick: Ht,
|
|
1435
1438
|
title: "Send",
|
|
1436
1439
|
children: /* @__PURE__ */ l(
|
|
1437
1440
|
"svg",
|
|
@@ -1474,7 +1477,7 @@ const xn = ({
|
|
|
1474
1477
|
children: /* @__PURE__ */ l("span", { className: "avatar-speaking-stop__icon", "aria-hidden": !0 })
|
|
1475
1478
|
}
|
|
1476
1479
|
)
|
|
1477
|
-
] }) :
|
|
1480
|
+
] }) : x ? /* @__PURE__ */ l(
|
|
1478
1481
|
"div",
|
|
1479
1482
|
{
|
|
1480
1483
|
style: {
|
|
@@ -1489,7 +1492,7 @@ const xn = ({
|
|
|
1489
1492
|
) : /* @__PURE__ */ ae(
|
|
1490
1493
|
"form",
|
|
1491
1494
|
{
|
|
1492
|
-
onSubmit:
|
|
1495
|
+
onSubmit: Gt,
|
|
1493
1496
|
style: {
|
|
1494
1497
|
flex: 1,
|
|
1495
1498
|
display: "flex",
|
|
@@ -1505,7 +1508,7 @@ const xn = ({
|
|
|
1505
1508
|
value: fe,
|
|
1506
1509
|
onChange: (e) => K(e.target.value),
|
|
1507
1510
|
placeholder: E === "Busy" ? "Assisting another user" : Ue || "Ask me anything",
|
|
1508
|
-
disabled:
|
|
1511
|
+
disabled: x || E === "Busy",
|
|
1509
1512
|
autoComplete: "off",
|
|
1510
1513
|
style: { width: "100%", height: "100%" }
|
|
1511
1514
|
}
|
|
@@ -1542,8 +1545,8 @@ const xn = ({
|
|
|
1542
1545
|
{
|
|
1543
1546
|
type: "button",
|
|
1544
1547
|
className: "mic-button",
|
|
1545
|
-
onClick:
|
|
1546
|
-
disabled:
|
|
1548
|
+
onClick: $t,
|
|
1549
|
+
disabled: x,
|
|
1547
1550
|
style: { backgroundColor: "#1e4a5e" },
|
|
1548
1551
|
children: /* @__PURE__ */ ae(
|
|
1549
1552
|
"svg",
|
|
@@ -1577,7 +1580,7 @@ const xn = ({
|
|
|
1577
1580
|
{
|
|
1578
1581
|
type: "submit",
|
|
1579
1582
|
className: "mic-button",
|
|
1580
|
-
disabled:
|
|
1583
|
+
disabled: x,
|
|
1581
1584
|
style: { backgroundColor: "#1e4a5e" },
|
|
1582
1585
|
title: "Send",
|
|
1583
1586
|
children: /* @__PURE__ */ l(
|
|
@@ -1613,7 +1616,7 @@ const xn = ({
|
|
|
1613
1616
|
"div",
|
|
1614
1617
|
{
|
|
1615
1618
|
className: `avatar-bubble${le === "entering" ? " avatar-bubble--entering" : le === "exiting" ? " avatar-bubble--exiting" : ""}`,
|
|
1616
|
-
onAnimationEnd:
|
|
1619
|
+
onAnimationEnd: Qt,
|
|
1617
1620
|
children: /* @__PURE__ */ l("div", { ref: mt, className: `avatar-bubble__content${nt ? " avatar-bubble__content--nudge" : ""}`, children: pt })
|
|
1618
1621
|
}
|
|
1619
1622
|
),
|
|
@@ -1623,7 +1626,7 @@ const xn = ({
|
|
|
1623
1626
|
className: "avatar-canvas-layer",
|
|
1624
1627
|
style: { width: z, height: z },
|
|
1625
1628
|
children: /* @__PURE__ */ ae(
|
|
1626
|
-
|
|
1629
|
+
Zt,
|
|
1627
1630
|
{
|
|
1628
1631
|
shadows: !0,
|
|
1629
1632
|
camera: { position: [0.2, 1.4, 3], fov: 42 },
|
|
@@ -1631,19 +1634,19 @@ const xn = ({
|
|
|
1631
1634
|
dpr: 1.8,
|
|
1632
1635
|
style: { pointerEvents: "none", width: "100%", height: "100%" },
|
|
1633
1636
|
children: [
|
|
1634
|
-
/* @__PURE__ */ l(
|
|
1637
|
+
/* @__PURE__ */ l(Sn, { target: gn }),
|
|
1635
1638
|
/* @__PURE__ */ l("ambientLight", { intensity: 0.7 }),
|
|
1636
1639
|
/* @__PURE__ */ l("directionalLight", { position: [0, 2, 2], intensity: 1 }),
|
|
1637
|
-
/* @__PURE__ */ l(
|
|
1638
|
-
/* @__PURE__ */ l(
|
|
1639
|
-
|
|
1640
|
+
/* @__PURE__ */ l(Kt, { preset: "city" }),
|
|
1641
|
+
/* @__PURE__ */ l(rn, { fallback: null, children: j !== null && /* @__PURE__ */ l(
|
|
1642
|
+
xn,
|
|
1640
1643
|
{
|
|
1641
1644
|
avatarUrl: j,
|
|
1642
1645
|
isPlayingRef: M,
|
|
1643
|
-
visemeQueueRef:
|
|
1646
|
+
visemeQueueRef: k,
|
|
1644
1647
|
audioContextRef: C,
|
|
1645
1648
|
responseAudioStartTimeRef: ve,
|
|
1646
|
-
adjustments:
|
|
1649
|
+
adjustments: pn,
|
|
1647
1650
|
mood: s,
|
|
1648
1651
|
expression: W,
|
|
1649
1652
|
agentResponse: N,
|
|
@@ -1652,7 +1655,7 @@ const xn = ({
|
|
|
1652
1655
|
stopPlayback: Ye,
|
|
1653
1656
|
setIsSpeaking: me,
|
|
1654
1657
|
expressionUrl: Ze,
|
|
1655
|
-
onExpressionFinished:
|
|
1658
|
+
onExpressionFinished: Bt,
|
|
1656
1659
|
isNudgeResponse: nt,
|
|
1657
1660
|
avatarGender: p
|
|
1658
1661
|
}
|
|
@@ -1664,20 +1667,20 @@ const xn = ({
|
|
|
1664
1667
|
)
|
|
1665
1668
|
] }) })
|
|
1666
1669
|
] });
|
|
1667
|
-
},
|
|
1668
|
-
token:
|
|
1670
|
+
}, Mn = ({
|
|
1671
|
+
token: d,
|
|
1669
1672
|
avatarGender: L,
|
|
1670
|
-
onNavigationRequested:
|
|
1673
|
+
onNavigationRequested: _,
|
|
1671
1674
|
presetUserDetails: p
|
|
1672
1675
|
}) => /* @__PURE__ */ l(
|
|
1673
|
-
|
|
1676
|
+
An,
|
|
1674
1677
|
{
|
|
1675
|
-
token:
|
|
1676
|
-
onNavigationRequested:
|
|
1678
|
+
token: d,
|
|
1679
|
+
onNavigationRequested: _,
|
|
1677
1680
|
avatarGender: L,
|
|
1678
1681
|
presetUserDetails: p
|
|
1679
1682
|
}
|
|
1680
1683
|
);
|
|
1681
1684
|
export {
|
|
1682
|
-
|
|
1685
|
+
Mn as AvatarWidget
|
|
1683
1686
|
};
|